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
8640f527cb
commit
6e176f94fa
@ -32,6 +32,7 @@ struct _CoglShader
|
||||
{
|
||||
CoglHandleObject _parent;
|
||||
GLhandleARB gl_handle;
|
||||
CoglShaderType type;
|
||||
};
|
||||
|
||||
CoglShader *_cogl_shader_pointer_from_handle (CoglHandle handle);
|
||||
|
@ -77,6 +77,7 @@ cogl_create_shader (CoglShaderType type)
|
||||
|
||||
shader = g_slice_new (CoglShader);
|
||||
shader->gl_handle = glCreateShader (gl_type);
|
||||
shader->type = type;
|
||||
|
||||
return _cogl_shader_handle_new (shader);
|
||||
}
|
||||
@ -132,7 +133,6 @@ cogl_shader_get_info_log (CoglHandle handle)
|
||||
CoglShaderType
|
||||
cogl_shader_get_type (CoglHandle handle)
|
||||
{
|
||||
GLint type;
|
||||
CoglShader *shader;
|
||||
|
||||
_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);
|
||||
|
||||
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;
|
||||
}
|
||||
return shader->type;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -125,7 +125,6 @@ cogl_shader_get_info_log (CoglHandle handle)
|
||||
CoglShaderType
|
||||
cogl_shader_get_type (CoglHandle handle)
|
||||
{
|
||||
GLint type;
|
||||
CoglShader *shader;
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
@ -135,17 +134,7 @@ cogl_shader_get_type (CoglHandle handle)
|
||||
}
|
||||
|
||||
shader = _cogl_shader_pointer_from_handle (handle);
|
||||
|
||||
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;
|
||||
}
|
||||
return shader->type;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user