cogl-program: Add private functions to check if have each shader type

This adds two internal functions:

gboolean
_cogl_program_has_fragment_shader (CoglHandle handle);

gboolean
_cogl_program_has_vertex_shader (CoglHandle handle);

They just check whether any of the contained shaders are of that type.
This commit is contained in:
Neil Roberts 2010-12-02 13:54:15 +00:00
parent 7562a17685
commit 91132871ad
2 changed files with 35 additions and 0 deletions

View File

@ -75,4 +75,10 @@ _cogl_program_flush_uniforms (CoglProgram *program,
CoglShaderLanguage
_cogl_program_get_language (CoglHandle handle);
gboolean
_cogl_program_has_fragment_shader (CoglHandle handle);
gboolean
_cogl_program_has_vertex_shader (CoglHandle handle);
#endif /* __COGL_PROGRAM_H */

View File

@ -681,3 +681,32 @@ _cogl_program_get_language (CoglHandle handle)
else
return COGL_SHADER_LANGUAGE_GLSL;
}
static gboolean
_cogl_program_has_shader_type (CoglProgram *program,
CoglShaderType type)
{
GSList *l;
for (l = program->attached_shaders; l; l = l->next)
{
CoglShader *shader = l->data;
if (shader->type == type)
return TRUE;
}
return FALSE;
}
gboolean
_cogl_program_has_fragment_shader (CoglHandle handle)
{
return _cogl_program_has_shader_type (handle, COGL_SHADER_TYPE_FRAGMENT);
}
gboolean
_cogl_program_has_vertex_shader (CoglHandle handle)
{
return _cogl_program_has_shader_type (handle, COGL_SHADER_TYPE_VERTEX);
}