mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
[cogl-shader] Make get_info_log() slightly nicer
The cogl_shader_get_info_log() function is very inconvenient for language bindings and for regular use, as it requires a static buffer to be filled -- basically just providing a wrapper around glGetInfoLogARB(). Since COGL aims to be a more convenient API than raw GL we should just make cogl_shader_get_info_log() return an allocated string with the GLSL compiler log.
This commit is contained in:
parent
9d41a27f61
commit
c0c7565ffc
@ -106,7 +106,7 @@ gboolean cogl_is_shader (CoglHandle handle);
|
||||
* one.
|
||||
*/
|
||||
void cogl_shader_source (CoglHandle shader,
|
||||
const char *source);
|
||||
const gchar *source);
|
||||
/**
|
||||
* cogl_shader_compile:
|
||||
* @handle: #CoglHandle for a shader.
|
||||
@ -119,17 +119,16 @@ void cogl_shader_compile (CoglHandle handle);
|
||||
/**
|
||||
* cogl_shader_get_info_log:
|
||||
* @handle: #CoglHandle for a shader.
|
||||
* @size: maximum number of bytes to retrieve.
|
||||
* @buffer: location for info log.
|
||||
*
|
||||
* Retrieves the information log for a coglobject, can be used in conjunction
|
||||
* with #cogl_shader_get_parameteriv to retrieve the compiler warnings/error
|
||||
* with cogl_shader_get_parameteriv() to retrieve the compiler warnings/error
|
||||
* messages that caused a shader to not compile correctly, mainly useful for
|
||||
* debugging purposes.
|
||||
*
|
||||
* Return value: a newly allocated string containing the info log. Use
|
||||
* g_free() to free it
|
||||
*/
|
||||
void cogl_shader_get_info_log (CoglHandle handle,
|
||||
size_t size,
|
||||
char *buffer);
|
||||
gchar * cogl_shader_get_info_log (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* cogl_shader_get_type:
|
||||
|
@ -108,22 +108,23 @@ cogl_shader_compile (CoglHandle handle)
|
||||
glCompileShaderARB (shader->gl_handle);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_shader_get_info_log (CoglHandle handle,
|
||||
size_t size,
|
||||
char *buffer)
|
||||
gchar *
|
||||
cogl_shader_get_info_log (CoglHandle handle)
|
||||
{
|
||||
CoglShader *shader;
|
||||
char buffer[512];
|
||||
int len;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
_COGL_GET_CONTEXT (ctx, NULL);
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
shader = _cogl_shader_pointer_from_handle (handle);
|
||||
|
||||
glGetInfoLogARB (shader->gl_handle, size-1, &len, buffer);
|
||||
glGetInfoLogARB (shader->gl_handle, 511, &len, buffer);
|
||||
buffer[len]='\0';
|
||||
|
||||
return g_strdup (buffer);
|
||||
}
|
||||
|
||||
CoglShaderType
|
||||
|
@ -99,22 +99,23 @@ cogl_shader_compile (CoglHandle handle)
|
||||
glCompileShader (shader->gl_handle);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_shader_get_info_log (CoglHandle handle,
|
||||
size_t size,
|
||||
char *buffer)
|
||||
gchar *
|
||||
cogl_shader_get_info_log (CoglHandle handle)
|
||||
{
|
||||
CoglShader *shader;
|
||||
char buffer[512]
|
||||
int len = 0;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
_COGL_GET_CONTEXT (ctx, NULL);
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
shader = _cogl_shader_pointer_from_handle (handle);
|
||||
|
||||
glGetShaderInfoLog (shader->gl_handle, size - 1, &len, buffer);
|
||||
glGetShaderInfoLog (shader->gl_handle, 511, &len, buffer);
|
||||
buffer[len] = '\0';
|
||||
|
||||
return g_strdup (buffer);
|
||||
}
|
||||
|
||||
CoglShaderType
|
||||
|
Loading…
Reference in New Issue
Block a user