mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
cogl-shader: Store the CoglShaderType in CoglShader
Instead of having to query GL and translate the GL enum into a CoglShaderType each time cogl_shader_get_type is called we now keep track of the type in CoglShader.
This commit is contained in:
parent
467c33a3e3
commit
8021d3e2eb
@ -32,6 +32,7 @@ struct _CoglShader
|
|||||||
{
|
{
|
||||||
CoglHandleObject _parent;
|
CoglHandleObject _parent;
|
||||||
GLhandleARB gl_handle;
|
GLhandleARB gl_handle;
|
||||||
|
CoglShaderType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
CoglShader *_cogl_shader_pointer_from_handle (CoglHandle handle);
|
CoglShader *_cogl_shader_pointer_from_handle (CoglHandle handle);
|
||||||
|
@ -77,6 +77,7 @@ cogl_create_shader (CoglShaderType type)
|
|||||||
|
|
||||||
shader = g_slice_new (CoglShader);
|
shader = g_slice_new (CoglShader);
|
||||||
shader->gl_handle = glCreateShader (gl_type);
|
shader->gl_handle = glCreateShader (gl_type);
|
||||||
|
shader->type = type;
|
||||||
|
|
||||||
return _cogl_shader_handle_new (shader);
|
return _cogl_shader_handle_new (shader);
|
||||||
}
|
}
|
||||||
@ -132,7 +133,6 @@ cogl_shader_get_info_log (CoglHandle handle)
|
|||||||
CoglShaderType
|
CoglShaderType
|
||||||
cogl_shader_get_type (CoglHandle handle)
|
cogl_shader_get_type (CoglHandle handle)
|
||||||
{
|
{
|
||||||
GLint type;
|
|
||||||
CoglShader *shader;
|
CoglShader *shader;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX);
|
_COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX);
|
||||||
@ -144,17 +144,7 @@ cogl_shader_get_type (CoglHandle handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
shader = _cogl_shader_pointer_from_handle (handle);
|
shader = _cogl_shader_pointer_from_handle (handle);
|
||||||
|
return shader->type;
|
||||||
GE (glGetShaderiv (shader->gl_handle, GL_SHADER_TYPE, &type));
|
|
||||||
if (type == GL_VERTEX_SHADER)
|
|
||||||
return COGL_SHADER_TYPE_VERTEX;
|
|
||||||
else if (type == GL_FRAGMENT_SHADER)
|
|
||||||
return COGL_SHADER_TYPE_VERTEX;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type);
|
|
||||||
return COGL_SHADER_TYPE_VERTEX;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -125,7 +125,6 @@ cogl_shader_get_info_log (CoglHandle handle)
|
|||||||
CoglShaderType
|
CoglShaderType
|
||||||
cogl_shader_get_type (CoglHandle handle)
|
cogl_shader_get_type (CoglHandle handle)
|
||||||
{
|
{
|
||||||
GLint type;
|
|
||||||
CoglShader *shader;
|
CoglShader *shader;
|
||||||
|
|
||||||
if (!cogl_is_shader (handle))
|
if (!cogl_is_shader (handle))
|
||||||
@ -135,17 +134,7 @@ cogl_shader_get_type (CoglHandle handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
shader = _cogl_shader_pointer_from_handle (handle);
|
shader = _cogl_shader_pointer_from_handle (handle);
|
||||||
|
return shader->type;
|
||||||
GE (glGetShaderiv (shader->gl_handle, GL_SHADER_TYPE, &type));
|
|
||||||
if (type == GL_VERTEX_SHADER)
|
|
||||||
return COGL_SHADER_TYPE_VERTEX;
|
|
||||||
else if (type == GL_FRAGMENT_SHADER)
|
|
||||||
return COGL_SHADER_TYPE_VERTEX;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type);
|
|
||||||
return COGL_SHADER_TYPE_VERTEX;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user