[cairo] [PATCH] [gl] Add shader support code for GL versions < 3.0.

Fernando Carrijo fcarrijo at yahoo.com.br
Thu Jan 14 11:05:33 PST 2010


Hi Zach,

Just realized that there are a few occurrences of _cairo_malloc whose
return value is not being checked, and thought that you might want to
be notified about them.

Zach Laine <whatwasthataddress at gmail.com> wrote:

> +static cairo_status_t
> +compile_shader_arb (GLuint *shader, GLenum type, const char *text)
> +{
> +    const char* strings[1] = { text };
> +    GLint gl_status;
> +
> +    *shader = glCreateShaderObjectARB (type);
> +    glShaderSourceARB (*shader, 1, strings, 0);
> +    glCompileShaderARB (*shader);
> +    glGetObjectParameterivARB (*shader, GL_OBJECT_COMPILE_STATUS_ARB,
> &gl_status);
> +    if (gl_status == GL_FALSE) {
> +        GLint log_size;
> +        glGetObjectParameterivARB (*shader,
> GL_OBJECT_INFO_LOG_LENGTH_ARB, &log_size);
> +        if (0 < log_size) {
> +            char *log = _cairo_malloc (log_size);

> +static cairo_status_t
> +link_shader_arb (GLuint *program, GLuint vert, GLuint frag)
> +{
> +    GLint gl_status;
> +
> +    *program = glCreateProgramObjectARB ();
> +    glAttachObjectARB (*program, vert);
> +    glAttachObjectARB (*program, frag);
> +    glLinkProgramARB (*program);
> +    glGetObjectParameterivARB (*program, GL_OBJECT_LINK_STATUS_ARB,
> &gl_status);
> +    if (gl_status == GL_FALSE) {
> +        GLint log_size;
> +        glGetObjectParameterivARB (*program,
> GL_OBJECT_INFO_LOG_LENGTH_ARB, &log_size);
> +        if (0 < log_size) {
> +            char *log = _cairo_malloc (log_size);

> +static cairo_status_t
> +compile_shader_core_2_0 (GLuint *shader, GLenum type, const char *text)
> +{
> +    const char* strings[1] = { text };
> +    GLint gl_status;
> +
> +    *shader = glCreateShader (type);
> +    glShaderSource (*shader, 1, strings, 0);
> +    glCompileShader (*shader);
> +    glGetShaderiv (*shader, GL_COMPILE_STATUS, &gl_status);
> +    if (gl_status == GL_FALSE) {
> +        GLint log_size;
> +        glGetShaderiv (*shader, GL_INFO_LOG_LENGTH, &log_size);
> +        if (0 < log_size) {
> +            char *log = _cairo_malloc (log_size);

> +static cairo_status_t
> +link_shader_core_2_0 (GLuint *program, GLuint vert, GLuint frag)
> +{
> +    GLint gl_status;
> +
> +    *program = glCreateProgram ();
> +    glAttachShader (*program, vert);
> +    glAttachShader (*program, frag);
> +    glLinkProgram (*program);
> +    glGetProgramiv (*program, GL_LINK_STATUS, &gl_status);
> +    if (gl_status == GL_FALSE) {
> +        GLint log_size;
> +        glGetProgramiv (*program, GL_INFO_LOG_LENGTH, &log_size);
> +        if (0 < log_size) {
> +            char *log = _cairo_malloc (log_size);

Cheers,
Fernando



More information about the cairo mailing list