Turn gl_ff_vertex/gl_ff_matrix into functions

This commit is contained in:
twinaphex 2015-03-30 02:59:39 +02:00
parent 8eab7e6631
commit 09c481342b
4 changed files with 35 additions and 29 deletions

View File

@ -182,9 +182,7 @@ static bool gl_cg_set_mvp(void *data, const math_matrix_4x4 *mat)
return true; return true;
} }
#ifndef NO_GL_FF_MATRIX
gl_ff_matrix(mat); gl_ff_matrix(mat);
#endif
return false; return false;
} }
@ -213,9 +211,7 @@ static bool gl_cg_set_coords(const void *data)
return true; return true;
fallback: fallback:
#ifndef NO_GL_FF_VERTEX
gl_ff_vertex(coords); gl_ff_vertex(coords);
#endif
return false; return false;
} }

View File

@ -1143,9 +1143,7 @@ static bool gl_glsl_set_mvp(void *data, const math_matrix_4x4 *mat)
if (!glsl || !glsl->glsl_shader->modern) if (!glsl || !glsl->glsl_shader->modern)
{ {
#ifndef NO_GL_FF_MATRIX
gl_ff_matrix(mat); gl_ff_matrix(mat);
#endif
return false; return false;
} }
@ -1171,9 +1169,7 @@ static bool gl_glsl_set_coords(const void *data)
if (!glsl || !glsl->glsl_shader->modern || !coords) if (!glsl || !glsl->glsl_shader->modern || !coords)
{ {
#ifndef NO_GL_FF_VERTEX
gl_ff_vertex(coords); gl_ff_vertex(coords);
#endif
return false; return false;
} }
@ -1184,9 +1180,7 @@ static bool gl_glsl_set_coords(const void *data)
if (!buffer) if (!buffer)
{ {
#ifndef NO_GL_FF_VERTEX
gl_ff_vertex(coords); gl_ff_vertex(coords);
#endif
return false; return false;
} }

View File

@ -16,6 +16,38 @@
#include "gl_common.h" #include "gl_common.h"
void gl_ff_vertex(const void *data)
{
#ifndef NO_GL_FF_VERTEX
const struct gl_coords *coords = (const struct gl_coords*)data;
/* Fall back to fixed function-style if needed and possible. */
glClientActiveTexture(GL_TEXTURE1);
glTexCoordPointer(2, GL_FLOAT, 0, coords->lut_tex_coord);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(GL_TEXTURE0);
glVertexPointer(2, GL_FLOAT, 0, coords->vertex);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_FLOAT, 0, coords->color);
glEnableClientState(GL_COLOR_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, coords->tex_coord);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
}
void gl_ff_matrix(const void *data)
{
#ifndef NO_GL_FF_MATRIX
const math_matrix_4x4 *mat = (const math_matrix_4x4*)data;
/* Fall back to fixed function-style if needed and possible. */
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(mat->data);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
#endif
}
void gl_load_texture_data(GLuint id, void gl_load_texture_data(GLuint id,
enum gfx_wrap_type wrap_type, enum gfx_wrap_type wrap_type,
enum texture_filter_type filter_type, enum texture_filter_type filter_type,

View File

@ -181,25 +181,6 @@
#endif #endif
#endif #endif
/* Fall back to FF-style if needed and possible. */
#define gl_ff_vertex(coords) \
glClientActiveTexture(GL_TEXTURE1); \
glTexCoordPointer(2, GL_FLOAT, 0, coords->lut_tex_coord); \
glEnableClientState(GL_TEXTURE_COORD_ARRAY); \
glClientActiveTexture(GL_TEXTURE0); \
glVertexPointer(2, GL_FLOAT, 0, coords->vertex); \
glEnableClientState(GL_VERTEX_ARRAY); \
glColorPointer(4, GL_FLOAT, 0, coords->color); \
glEnableClientState(GL_COLOR_ARRAY); \
glTexCoordPointer(2, GL_FLOAT, 0, coords->tex_coord); \
glEnableClientState(GL_TEXTURE_COORD_ARRAY)
/* Fall back to FF-style if needed and possible. */
#define gl_ff_matrix(mat) \
glMatrixMode(GL_PROJECTION); \
glLoadMatrixf(mat->data); \
glMatrixMode(GL_MODELVIEW); \
glLoadIdentity()
struct gl_fbo_rect struct gl_fbo_rect
{ {
@ -455,4 +436,7 @@ static INLINE unsigned gl_wrap_type_to_enum(enum gfx_wrap_type type)
bool gl_coord_array_add(gl_coord_array_t *ca, const gl_coords_t *coords, unsigned count); bool gl_coord_array_add(gl_coord_array_t *ca, const gl_coords_t *coords, unsigned count);
void gl_coord_array_free(gl_coord_array_t *ca); void gl_coord_array_free(gl_coord_array_t *ca);
void gl_ff_vertex(const void *data);
void gl_ff_matrix(const void *data);
#endif #endif