Fix GLES 2 after the multiple-texture-rectangle branch merge
The GLES 2 wrapper needs to set up some state before each draw. Previously this was acheived by wrapping glDrawArrays. Since the multiple-texture-rectangle branch merge, glDrawElements is used instead so we also need a wrapper for that. It was also directly calling glBindTexture. GLES 2 uses a wrapper for this function so that it can cope with GL_ALPHA format textures. The format of the current texture needs to be stored as well as the target and object number for this to work.
This commit is contained in:
parent
453697fcad
commit
de114dead7
@ -72,6 +72,7 @@ typedef struct
|
|||||||
can be flushed */
|
can be flushed */
|
||||||
GLuint texture_current;
|
GLuint texture_current;
|
||||||
GLenum texture_target;
|
GLenum texture_target;
|
||||||
|
GLenum texture_format;
|
||||||
|
|
||||||
/* Framebuffer objects */
|
/* Framebuffer objects */
|
||||||
GArray *fbo_handles;
|
GArray *fbo_handles;
|
||||||
|
@ -891,8 +891,8 @@ cogl_gles2_do_set_uniform (GLint location, CoglBoxedValue *value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count)
|
cogl_wrap_prepare_for_draw (void)
|
||||||
{
|
{
|
||||||
CoglGles2WrapperProgram *program;
|
CoglGles2WrapperProgram *program;
|
||||||
|
|
||||||
@ -999,9 +999,25 @@ cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count)
|
|||||||
w->dirty_custom_uniforms = 0;
|
w->dirty_custom_uniforms = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count)
|
||||||
|
{
|
||||||
|
cogl_wrap_prepare_for_draw ();
|
||||||
|
|
||||||
glDrawArrays (mode, first, count);
|
glDrawArrays (mode, first, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_wrap_glDrawElements (GLenum mode, GLsizei count, GLenum type,
|
||||||
|
const GLvoid *indices)
|
||||||
|
{
|
||||||
|
cogl_wrap_prepare_for_draw ();
|
||||||
|
|
||||||
|
glDrawElements (mode, count, type, indices);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_gles2_wrapper_bind_texture (GLenum target, GLuint texture,
|
cogl_gles2_wrapper_bind_texture (GLenum target, GLuint texture,
|
||||||
GLenum internal_format)
|
GLenum internal_format)
|
||||||
|
@ -250,7 +250,8 @@ void cogl_wrap_glFogx (GLenum pname, GLfixed param);
|
|||||||
void cogl_wrap_glFogxv (GLenum pname, const GLfixed *params);
|
void cogl_wrap_glFogxv (GLenum pname, const GLfixed *params);
|
||||||
|
|
||||||
void cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count);
|
void cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count);
|
||||||
|
void cogl_wrap_glDrawElements (GLenum mode, GLsizei count, GLenum type,
|
||||||
|
const GLvoid *indices);
|
||||||
void cogl_wrap_glTexParameteri (GLenum target, GLenum pname, GLfloat param);
|
void cogl_wrap_glTexParameteri (GLenum target, GLenum pname, GLfloat param);
|
||||||
|
|
||||||
void cogl_gles2_wrapper_bind_texture (GLenum target, GLuint texture,
|
void cogl_gles2_wrapper_bind_texture (GLenum target, GLuint texture,
|
||||||
@ -274,6 +275,7 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program);
|
|||||||
|
|
||||||
#define cogl_wrap_glClearColorx glClearColorx
|
#define cogl_wrap_glClearColorx glClearColorx
|
||||||
#define cogl_wrap_glDrawArrays glDrawArrays
|
#define cogl_wrap_glDrawArrays glDrawArrays
|
||||||
|
#define cogl_wrap_glDrawElements glDrawElements
|
||||||
#define cogl_wrap_glPushMatrix glPushMatrix
|
#define cogl_wrap_glPushMatrix glPushMatrix
|
||||||
#define cogl_wrap_glPopMatrix glPopMatrix
|
#define cogl_wrap_glPopMatrix glPopMatrix
|
||||||
#define cogl_wrap_glMatrixMode glMatrixMode
|
#define cogl_wrap_glMatrixMode glMatrixMode
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#define glTexCoordPointer cogl_wrap_glTexCoordPointer
|
#define glTexCoordPointer cogl_wrap_glTexCoordPointer
|
||||||
#define glColorPointer cogl_wrap_glColorPointer
|
#define glColorPointer cogl_wrap_glColorPointer
|
||||||
#define glDrawArrays cogl_wrap_glDrawArrays
|
#define glDrawArrays cogl_wrap_glDrawArrays
|
||||||
|
#define glDrawElements cogl_wrap_glDrawElements
|
||||||
#define glTexParameteri cogl_wrap_glTexParameteri
|
#define glTexParameteri cogl_wrap_glTexParameteri
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2094,7 +2095,9 @@ _cogl_texture_flush_vertices (void)
|
|||||||
GE( glTexCoordPointer (2, GL_FLOAT,
|
GE( glTexCoordPointer (2, GL_FLOAT,
|
||||||
sizeof (CoglTextureGLVertex), p->t ) );
|
sizeof (CoglTextureGLVertex), p->t ) );
|
||||||
|
|
||||||
GE( glBindTexture (ctx->texture_target, ctx->texture_current) );
|
GE( cogl_gles2_wrapper_bind_texture (ctx->texture_target,
|
||||||
|
ctx->texture_current,
|
||||||
|
ctx->texture_format) );
|
||||||
GE( glDrawElements (GL_TRIANGLES,
|
GE( glDrawElements (GL_TRIANGLES,
|
||||||
needed_indices,
|
needed_indices,
|
||||||
GL_UNSIGNED_SHORT,
|
GL_UNSIGNED_SHORT,
|
||||||
@ -2284,6 +2287,7 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
_cogl_texture_flush_vertices ();
|
_cogl_texture_flush_vertices ();
|
||||||
ctx->texture_target = tex->gl_target;
|
ctx->texture_target = tex->gl_target;
|
||||||
ctx->texture_current = gl_handle;
|
ctx->texture_current = gl_handle;
|
||||||
|
ctx->texture_format = tex->gl_intformat;
|
||||||
|
|
||||||
_cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (slice_qx1),
|
_cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (slice_qx1),
|
||||||
COGL_FIXED_TO_FLOAT (slice_qy1),
|
COGL_FIXED_TO_FLOAT (slice_qy1),
|
||||||
@ -2328,6 +2332,7 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
_cogl_texture_flush_vertices ();
|
_cogl_texture_flush_vertices ();
|
||||||
ctx->texture_target = tex->gl_target;
|
ctx->texture_target = tex->gl_target;
|
||||||
ctx->texture_current = gl_handle;
|
ctx->texture_current = gl_handle;
|
||||||
|
ctx->texture_format = tex->gl_intformat;
|
||||||
|
|
||||||
/* Don't include the waste in the texture coordinates */
|
/* Don't include the waste in the texture coordinates */
|
||||||
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);
|
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user