1 #include "coregl_fastpath.h"
5 //----------------------------------------------------------------//
7 // Fastpath GL Functions //
8 // The functions have prefix 'fpgl_' for (fastpath gl) //
10 //----------------------------------------------------------------//
12 #define CURR_STATE_COMPARE(curr_state, state ) \
13 if ((current_ctx->curr_state[0]) != (state))
15 #define DEFINE_FAST_GL_FUNC() \
16 GLThreadState *tstate = NULL; \
17 GLGlueContext *current_ctx = NULL;
19 #define INIT_FAST_GL_FUNC() \
20 tstate = get_current_thread_state(); \
21 if (tstate == NULL || tstate->cstate == NULL) \
23 ERR("\E[0;31;1mWARNING : '%s' called when GLES2 context is not binded (Check MakeCurrent)!\E[0m\n", __func__); \
26 current_ctx = (GLGlueContext *)tstate->cstate->data; \
27 AST(current_ctx != NULL);
29 #define GET_REAL_OBJ(type, glue_handle, real_handle) \
30 _get_real_obj(current_ctx->sostate, type, glue_handle, real_handle)
33 _get_real_obj(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_handle, GLuint *real_handle)
42 *real_handle = sostate_get_object(sostate, type, glue_handle);
43 if (*real_handle == 0)
50 _set_gl_error(GLenum error)
52 GLenum glerror = GL_NONE;
53 DEFINE_FAST_GL_FUNC();
56 glerror = _sym_glGetError();
58 if (current_ctx->gl_error == GL_NO_ERROR &&
59 glerror == GL_NO_ERROR &&
62 current_ctx->gl_error = error;
75 DEFINE_FAST_GL_FUNC();
76 _COREGL_FAST_FUNC_BEGIN();
79 if (current_ctx->gl_error != GL_NO_ERROR)
81 ret = current_ctx->gl_error;
85 ret = _sym_glGetError();
90 _COREGL_FAST_FUNC_END();
94 ////////////////////////////////////////////////////////////////////////
97 fpgl_glActiveTexture(GLenum texture)
99 DEFINE_FAST_GL_FUNC();
100 _COREGL_FAST_FUNC_BEGIN();
103 CURR_STATE_COMPARE(gl_active_texture, texture)
105 _sym_glActiveTexture(texture);
107 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
109 current_ctx->_tex_flag1 |= FLAG_BIT_1;
110 current_ctx->gl_active_texture[0] = texture;
115 _COREGL_FAST_FUNC_END();
120 fpgl_glGenTextures(GLsizei n, GLuint* textures)
123 GLuint *objid_array = NULL;
125 DEFINE_FAST_GL_FUNC();
126 _COREGL_FAST_FUNC_BEGIN();
129 if (textures == NULL) goto finish;
131 AST(current_ctx->sostate != NULL);
133 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
135 _sym_glGenTextures(n, objid_array);
137 for (i = 0; i < n; i++)
139 textures[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, objid_array[i]);
145 if (objid_array != NULL)
150 _COREGL_FAST_FUNC_END();
155 fpgl_glBindTexture(GLenum target, GLuint texture)
160 DEFINE_FAST_GL_FUNC();
161 _COREGL_FAST_FUNC_BEGIN();
164 active_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0;
166 if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1)
168 _set_gl_error(GL_OUT_OF_MEMORY);
172 if (target == GL_TEXTURE_2D)
174 if (current_ctx->gl_tex_2d_state[active_idx] != real_obj)
176 _sym_glBindTexture(target, real_obj);
178 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
180 current_ctx->_tex_flag1 |= FLAG_BIT_3;
182 current_ctx->gl_tex_2d_state[active_idx] = real_obj;
185 else if (target == GL_TEXTURE_CUBE_MAP)
187 if (current_ctx->gl_tex_cube_state[active_idx] != real_obj)
189 _sym_glBindTexture(target, real_obj);
191 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
193 current_ctx->_tex_flag1 |= FLAG_BIT_4;
195 current_ctx->gl_tex_cube_state[active_idx] = real_obj;
201 _COREGL_FAST_FUNC_END();
206 fpgl_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
210 DEFINE_FAST_GL_FUNC();
211 _COREGL_FAST_FUNC_BEGIN();
214 if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1)
216 _set_gl_error(GL_OUT_OF_MEMORY);
220 _sym_glFramebufferTexture2D(target, attachment, textarget, real_obj, level);
222 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
226 _COREGL_FAST_FUNC_END();
230 fpgl_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
234 DEFINE_FAST_GL_FUNC();
235 _COREGL_FAST_FUNC_BEGIN();
238 if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1)
240 _set_gl_error(GL_OUT_OF_MEMORY);
244 _sym_glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, real_obj, level, samples);
246 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
250 _COREGL_FAST_FUNC_END();
254 fpgl_glIsTexture(GLuint texture)
256 GLboolean ret = GL_FALSE;
259 DEFINE_FAST_GL_FUNC();
260 _COREGL_FAST_FUNC_BEGIN();
263 if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1)
269 ret = _sym_glIsTexture(real_obj);
271 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
276 _COREGL_FAST_FUNC_END();
282 fpgl_glDeleteTextures(GLsizei n, const GLuint* textures)
285 GLuint *objid_array = NULL;
287 DEFINE_FAST_GL_FUNC();
288 _COREGL_FAST_FUNC_BEGIN();
291 if (textures == NULL) goto finish;
293 AST(current_ctx->sostate != NULL);
295 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
299 for (i = 0; i < n; i++)
301 int real_objid = _COREGL_INT_INIT_VALUE;
302 if (textures[i] == 0) continue;
304 real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]);
305 if (real_objid == 0) continue;
307 sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]);
308 objid_array[real_n++] = real_objid;
311 _sym_glDeleteTextures(real_n, objid_array);
312 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
314 for (i = 0; i < real_n; i++)
316 for (j = 0; j < current_ctx->gl_num_tex_units[0]; j++)
318 if (current_ctx->gl_tex_2d_state[j] == objid_array[i])
319 current_ctx->gl_tex_2d_state[j] = 0;
320 if (current_ctx->gl_tex_cube_state[j] == objid_array[i])
321 current_ctx->gl_tex_cube_state[j] = 0;
329 if (objid_array != NULL)
334 _COREGL_FAST_FUNC_END();
337 ////////////////////////////////////////////////////////////////////////
340 fpgl_glGenBuffers(GLsizei n, GLuint* buffers)
343 GLuint *objid_array = NULL;
345 DEFINE_FAST_GL_FUNC();
346 _COREGL_FAST_FUNC_BEGIN();
349 if (buffers == NULL) goto finish;
351 AST(current_ctx->sostate != NULL);
353 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
355 _sym_glGenBuffers(n, objid_array);
357 for (i = 0; i < n; i++)
359 buffers[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, objid_array[i]);
365 if (objid_array != NULL)
370 _COREGL_FAST_FUNC_END();
375 fpgl_glBindBuffer(GLenum target, GLuint buffer)
379 DEFINE_FAST_GL_FUNC();
380 _COREGL_FAST_FUNC_BEGIN();
383 if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1)
385 _set_gl_error(GL_OUT_OF_MEMORY);
389 if (target == GL_ARRAY_BUFFER)
391 CURR_STATE_COMPARE(gl_array_buffer_binding, real_obj)
393 _sym_glBindBuffer(target, real_obj);
395 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
398 current_ctx->_bind_flag &= (~FLAG_BIT_0);
400 current_ctx->_bind_flag |= FLAG_BIT_0;
401 current_ctx->gl_array_buffer_binding[0] = real_obj;
404 else if (target == GL_ELEMENT_ARRAY_BUFFER)
406 CURR_STATE_COMPARE(gl_element_array_buffer_binding, real_obj)
408 _sym_glBindBuffer(target, real_obj);
409 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
412 current_ctx->_bind_flag &= (~FLAG_BIT_1);
414 current_ctx->_bind_flag |= FLAG_BIT_1;
415 current_ctx->gl_element_array_buffer_binding[0] = real_obj;
420 // For error recording
421 _sym_glBindBuffer(target, real_obj);
422 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
427 _COREGL_FAST_FUNC_END();
431 fpgl_glIsBuffer(GLuint buffer)
433 GLboolean ret = GL_FALSE;
436 DEFINE_FAST_GL_FUNC();
437 _COREGL_FAST_FUNC_BEGIN();
440 if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1)
446 ret = _sym_glIsBuffer(real_obj);
448 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
453 _COREGL_FAST_FUNC_END();
459 fpgl_glDeleteBuffers(GLsizei n, const GLuint* buffers)
462 GLuint *objid_array = NULL;
464 DEFINE_FAST_GL_FUNC();
465 _COREGL_FAST_FUNC_BEGIN();
468 if (buffers == NULL) goto finish;
470 AST(current_ctx->sostate != NULL);
472 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
476 for (i = 0; i < n; i++)
478 int real_objid = _COREGL_INT_INIT_VALUE;
479 if (buffers[i] == 0) continue;
481 real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, buffers[i]);
482 if (real_objid == 0) continue;
484 sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, buffers[i]);
485 objid_array[real_n++] = real_objid;
488 _sym_glDeleteBuffers(real_n, objid_array);
489 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
491 for (i = 0; i < real_n; i++)
493 if (current_ctx->gl_array_buffer_binding[0] == objid_array[i])
495 current_ctx->_bind_flag &= (~FLAG_BIT_0);
496 current_ctx->gl_array_buffer_binding[0] = 0;
498 if (current_ctx->gl_element_array_buffer_binding[0] == objid_array[i])
500 current_ctx->_bind_flag &= (~FLAG_BIT_1);
501 current_ctx->gl_element_array_buffer_binding[0] = 0;
509 if (objid_array != NULL)
514 _COREGL_FAST_FUNC_END();
517 //////////////////////////////////////////////////////////////////////////////////
520 fpgl_glGenFramebuffers(GLsizei n, GLuint* framebuffers)
523 GLuint *objid_array = NULL;
525 DEFINE_FAST_GL_FUNC();
526 _COREGL_FAST_FUNC_BEGIN();
529 if (framebuffers == NULL) goto finish;
531 AST(current_ctx->sostate != NULL);
533 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
535 _sym_glGenFramebuffers(n, objid_array);
537 for (i = 0; i < n; i++)
539 framebuffers[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, objid_array[i]);
545 if (objid_array != NULL)
550 _COREGL_FAST_FUNC_END();
555 fpgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
559 DEFINE_FAST_GL_FUNC();
560 _COREGL_FAST_FUNC_BEGIN();
563 if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1)
565 _set_gl_error(GL_OUT_OF_MEMORY);
569 if (target == GL_FRAMEBUFFER)
571 CURR_STATE_COMPARE(gl_framebuffer_binding, real_obj)
573 _sym_glBindFramebuffer(target, real_obj);
574 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
577 current_ctx->_bind_flag &= (~FLAG_BIT_2);
579 current_ctx->_bind_flag |= FLAG_BIT_2;
580 current_ctx->gl_framebuffer_binding[0] = real_obj;
585 // For error recording
586 _sym_glBindFramebuffer(target, real_obj);
587 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
593 _COREGL_FAST_FUNC_END();
597 fpgl_glIsFramebuffer(GLuint framebuffer)
599 GLboolean ret = GL_FALSE;
602 DEFINE_FAST_GL_FUNC();
603 _COREGL_FAST_FUNC_BEGIN();
606 if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1)
612 ret = _sym_glIsFramebuffer(real_obj);
614 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
619 _COREGL_FAST_FUNC_END();
625 fpgl_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
628 GLuint *objid_array = NULL;
630 DEFINE_FAST_GL_FUNC();
631 _COREGL_FAST_FUNC_BEGIN();
634 if (framebuffers == NULL) goto finish;
636 AST(current_ctx->sostate != NULL);
638 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
642 for (i = 0; i < n; i++)
644 int real_objid = _COREGL_INT_INIT_VALUE;
645 if (framebuffers[i] == 0) continue;
647 real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]);
648 if (real_objid == 0) continue;
650 sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]);
651 objid_array[real_n++] = real_objid;
654 _sym_glDeleteFramebuffers(real_n, objid_array);
655 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
657 for (i = 0; i < real_n; i++)
659 if (current_ctx->gl_framebuffer_binding[0] == framebuffers[i])
661 current_ctx->_bind_flag &= (~FLAG_BIT_2);
662 current_ctx->gl_framebuffer_binding[0] = 0;
670 if (objid_array != NULL)
675 _COREGL_FAST_FUNC_END();
678 //////////////////////////////////////////////////////////////////////////////////
681 fpgl_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
684 GLuint *objid_array = NULL;
686 DEFINE_FAST_GL_FUNC();
687 _COREGL_FAST_FUNC_BEGIN();
690 if (renderbuffers == NULL) goto finish;
692 AST(current_ctx->sostate != NULL);
694 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
696 _sym_glGenRenderbuffers(n, objid_array);
698 for (i = 0; i < n; i++)
700 renderbuffers[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, objid_array[i]);
706 if (objid_array != NULL)
711 _COREGL_FAST_FUNC_END();
716 fpgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
720 DEFINE_FAST_GL_FUNC();
721 _COREGL_FAST_FUNC_BEGIN();
724 if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1)
726 _set_gl_error(GL_OUT_OF_MEMORY);
730 if (target == GL_RENDERBUFFER)
732 CURR_STATE_COMPARE(gl_renderbuffer_binding, real_obj)
734 _sym_glBindRenderbuffer(target, real_obj);
735 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
738 current_ctx->_bind_flag &= (~FLAG_BIT_3);
740 current_ctx->_bind_flag |= FLAG_BIT_3;
741 current_ctx->gl_renderbuffer_binding[0] = real_obj;
746 // For error recording
747 _sym_glBindRenderbuffer(target, real_obj);
748 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
753 _COREGL_FAST_FUNC_END();
757 fpgl_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
761 DEFINE_FAST_GL_FUNC();
762 _COREGL_FAST_FUNC_BEGIN();
765 if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1)
767 _set_gl_error(GL_OUT_OF_MEMORY);
771 _sym_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, real_obj);
773 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
778 _COREGL_FAST_FUNC_END();
782 fpgl_glIsRenderbuffer(GLuint renderbuffer)
784 GLboolean ret = GL_FALSE;
787 DEFINE_FAST_GL_FUNC();
788 _COREGL_FAST_FUNC_BEGIN();
791 if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1)
797 ret = _sym_glIsRenderbuffer(real_obj);
799 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
804 _COREGL_FAST_FUNC_END();
810 fpgl_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
813 GLuint *objid_array = NULL;
815 DEFINE_FAST_GL_FUNC();
816 _COREGL_FAST_FUNC_BEGIN();
819 if (renderbuffers == NULL) goto finish;
821 AST(current_ctx->sostate != NULL);
823 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
827 for (i = 0; i < n; i++)
829 int real_objid = _COREGL_INT_INIT_VALUE;
830 if (renderbuffers[i] == 0) continue;
832 real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]);
833 if (real_objid == 0) continue;
835 sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]);
836 objid_array[real_n++] = real_objid;
839 _sym_glDeleteRenderbuffers(real_n, objid_array);
840 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
842 for (i = 0; i < real_n; i++)
844 if (current_ctx->gl_renderbuffer_binding[0] == renderbuffers[i])
846 current_ctx->_bind_flag &= (~FLAG_BIT_3);
847 current_ctx->gl_renderbuffer_binding[0] = 0;
855 if (objid_array != NULL)
860 _COREGL_FAST_FUNC_END();
863 //////////////////////////////////////////////////////////////////////////////////
866 fpgl_glCreateProgram(void)
868 GLuint ret = _COREGL_INT_INIT_VALUE;
869 GLuint real_obj = _COREGL_INT_INIT_VALUE;
871 DEFINE_FAST_GL_FUNC();
872 _COREGL_FAST_FUNC_BEGIN();
875 AST(current_ctx->sostate != NULL);
877 real_obj = _sym_glCreateProgram();
878 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
880 ret = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, real_obj);
885 _COREGL_FAST_FUNC_END();
890 fpgl_glCreateShader(GLenum type)
892 GLuint ret = _COREGL_INT_INIT_VALUE;
893 GLuint real_obj = _COREGL_INT_INIT_VALUE;
895 DEFINE_FAST_GL_FUNC();
896 _COREGL_FAST_FUNC_BEGIN();
899 AST(current_ctx->sostate != NULL);
901 real_obj = _sym_glCreateShader(type);
902 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
904 ret = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, real_obj);
909 _COREGL_FAST_FUNC_END();
914 fpgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
918 DEFINE_FAST_GL_FUNC();
919 _COREGL_FAST_FUNC_BEGIN();
922 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
924 _set_gl_error(GL_INVALID_VALUE);
927 _sym_glShaderSource(real_obj, count, string, length);
928 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
932 _COREGL_FAST_FUNC_END();
936 fpgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
939 GLuint *objid_array = NULL;
941 DEFINE_FAST_GL_FUNC();
942 _COREGL_FAST_FUNC_BEGIN();
945 if (shaders == NULL) goto finish;
947 AST(current_ctx->sostate != NULL);
949 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
951 for (i = 0; i < n; i++)
953 if (shaders[i] == 0) continue;
954 objid_array[i] = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shaders[i]);
957 #ifndef _COREGL_DESKTOP_GL
958 _sym_glShaderBinary(n, objid_array, binaryformat, binary, length);
959 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
961 // FIXME: need to dlsym/getprocaddress for this
963 n = binaryformat = length = 0;
964 shaders = binary = 0;
970 if (objid_array != NULL)
976 _COREGL_FAST_FUNC_END();
980 fpgl_glCompileShader(GLuint shader)
984 DEFINE_FAST_GL_FUNC();
985 _COREGL_FAST_FUNC_BEGIN();
988 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
990 _set_gl_error(GL_INVALID_VALUE);
994 _sym_glCompileShader(real_obj);
995 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
999 _COREGL_FAST_FUNC_END();
1003 fpgl_glBindAttribLocation(GLuint program, GLuint index, const char* name)
1007 DEFINE_FAST_GL_FUNC();
1008 _COREGL_FAST_FUNC_BEGIN();
1009 INIT_FAST_GL_FUNC();
1011 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1013 _set_gl_error(GL_INVALID_VALUE);
1017 _sym_glBindAttribLocation(real_obj, index, name);
1018 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1022 _COREGL_FAST_FUNC_END();
1026 fpgl_glAttachShader(GLuint program, GLuint shader)
1028 GLuint real_obj_program;
1029 GLuint real_obj_shader;
1031 DEFINE_FAST_GL_FUNC();
1032 _COREGL_FAST_FUNC_BEGIN();
1033 INIT_FAST_GL_FUNC();
1035 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj_program) != 1 ||
1036 GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj_shader) != 1)
1038 _set_gl_error(GL_INVALID_VALUE);
1042 _sym_glAttachShader(real_obj_program, real_obj_shader);
1043 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1047 _COREGL_FAST_FUNC_END();
1051 fpgl_glDetachShader(GLuint program, GLuint shader)
1053 GLuint real_obj_program;
1054 GLuint real_obj_shader;
1056 DEFINE_FAST_GL_FUNC();
1057 _COREGL_FAST_FUNC_BEGIN();
1058 INIT_FAST_GL_FUNC();
1060 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj_program) != 1 ||
1061 GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj_shader) != 1)
1063 _set_gl_error(GL_INVALID_VALUE);
1067 _sym_glDetachShader(real_obj_program, real_obj_shader);
1068 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1072 _COREGL_FAST_FUNC_END();
1076 fpgl_glIsShader(GLuint shader)
1078 GLboolean ret = GL_FALSE;
1081 DEFINE_FAST_GL_FUNC();
1082 _COREGL_FAST_FUNC_BEGIN();
1083 INIT_FAST_GL_FUNC();
1085 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1091 ret = _sym_glIsShader(real_obj);
1092 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1096 _COREGL_FAST_FUNC_END();
1101 fpgl_glIsProgram(GLuint program)
1103 GLboolean ret = GL_FALSE;
1106 DEFINE_FAST_GL_FUNC();
1107 _COREGL_FAST_FUNC_BEGIN();
1108 INIT_FAST_GL_FUNC();
1110 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1116 ret = _sym_glIsProgram(real_obj);
1117 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1121 _COREGL_FAST_FUNC_END();
1126 fpgl_glLinkProgram(GLuint program)
1130 DEFINE_FAST_GL_FUNC();
1131 _COREGL_FAST_FUNC_BEGIN();
1132 INIT_FAST_GL_FUNC();
1134 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1136 _set_gl_error(GL_INVALID_VALUE);
1140 _sym_glLinkProgram(real_obj);
1141 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1145 _COREGL_FAST_FUNC_END();
1149 fpgl_glValidateProgram(GLuint program)
1153 DEFINE_FAST_GL_FUNC();
1154 _COREGL_FAST_FUNC_BEGIN();
1155 INIT_FAST_GL_FUNC();
1157 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1159 _set_gl_error(GL_INVALID_VALUE);
1163 _sym_glValidateProgram(real_obj);
1164 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1168 _COREGL_FAST_FUNC_END();
1172 fpgl_glUseProgram(GLuint program)
1176 DEFINE_FAST_GL_FUNC();
1177 _COREGL_FAST_FUNC_BEGIN();
1178 INIT_FAST_GL_FUNC();
1180 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1182 _set_gl_error(GL_INVALID_VALUE);
1186 CURR_STATE_COMPARE(gl_current_program, real_obj)
1188 _sym_glUseProgram(real_obj);
1190 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1192 current_ctx->_clear_flag1 |= FLAG_BIT_1;
1193 current_ctx->gl_current_program[0] = real_obj;
1198 _COREGL_FAST_FUNC_END();
1202 fpgl_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
1206 DEFINE_FAST_GL_FUNC();
1207 _COREGL_FAST_FUNC_BEGIN();
1208 INIT_FAST_GL_FUNC();
1210 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1212 _set_gl_error(GL_INVALID_VALUE);
1216 _sym_glGetActiveAttrib(real_obj, index, bufsize, length, size, type, name);
1217 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1221 _COREGL_FAST_FUNC_END();
1225 fpgl_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
1229 DEFINE_FAST_GL_FUNC();
1230 _COREGL_FAST_FUNC_BEGIN();
1231 INIT_FAST_GL_FUNC();
1233 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1235 _set_gl_error(GL_INVALID_VALUE);
1239 _sym_glGetActiveUniform(real_obj, index, bufsize, length, size, type, name);
1240 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1244 _COREGL_FAST_FUNC_END();
1248 fpgl_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
1251 GLsizei real_count = _COREGL_INT_INIT_VALUE;
1254 DEFINE_FAST_GL_FUNC();
1255 _COREGL_FAST_FUNC_BEGIN();
1256 INIT_FAST_GL_FUNC();
1258 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1260 _set_gl_error(GL_INVALID_VALUE);
1264 _sym_glGetAttachedShaders(real_obj, maxcount, &real_count, shaders);
1266 for (i = 0; i < real_count; i++)
1268 if (shaders[i] != 0)
1269 shaders[i] = sostate_find_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shaders[i]);
1271 if (count != NULL) *count = real_count;
1273 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1277 _COREGL_FAST_FUNC_END();
1281 fpgl_glGetAttribLocation(GLuint program, const char* name)
1283 int ret = _COREGL_INT_INIT_VALUE;
1286 DEFINE_FAST_GL_FUNC();
1287 _COREGL_FAST_FUNC_BEGIN();
1288 INIT_FAST_GL_FUNC();
1290 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1292 _set_gl_error(GL_INVALID_VALUE);
1296 ret = _sym_glGetAttribLocation(real_obj, name);
1297 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1301 _COREGL_FAST_FUNC_END();
1306 fpgl_glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
1310 DEFINE_FAST_GL_FUNC();
1311 _COREGL_FAST_FUNC_BEGIN();
1312 INIT_FAST_GL_FUNC();
1314 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1316 _set_gl_error(GL_INVALID_VALUE);
1320 _sym_glGetShaderiv(real_obj, pname, params);
1321 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1325 _COREGL_FAST_FUNC_END();
1329 fpgl_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
1333 DEFINE_FAST_GL_FUNC();
1334 _COREGL_FAST_FUNC_BEGIN();
1335 INIT_FAST_GL_FUNC();
1337 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1339 _set_gl_error(GL_INVALID_VALUE);
1343 _sym_glGetShaderInfoLog(real_obj, bufsize, length, infolog);
1344 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1348 _COREGL_FAST_FUNC_END();
1352 fpgl_glGetProgramiv(GLuint program, GLenum pname, GLint* params)
1356 DEFINE_FAST_GL_FUNC();
1357 _COREGL_FAST_FUNC_BEGIN();
1358 INIT_FAST_GL_FUNC();
1360 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1362 _set_gl_error(GL_INVALID_VALUE);
1366 _sym_glGetProgramiv(real_obj, pname, params);
1367 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1371 _COREGL_FAST_FUNC_END();
1375 fpgl_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
1379 DEFINE_FAST_GL_FUNC();
1380 _COREGL_FAST_FUNC_BEGIN();
1381 INIT_FAST_GL_FUNC();
1383 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1385 _set_gl_error(GL_INVALID_VALUE);
1389 _sym_glGetProgramInfoLog(real_obj, bufsize, length, infolog);
1390 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1394 _COREGL_FAST_FUNC_END();
1398 fpgl_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
1402 DEFINE_FAST_GL_FUNC();
1403 _COREGL_FAST_FUNC_BEGIN();
1404 INIT_FAST_GL_FUNC();
1406 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1408 _set_gl_error(GL_INVALID_VALUE);
1412 _sym_glGetShaderSource(real_obj, bufsize, length, source);
1413 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1417 _COREGL_FAST_FUNC_END();
1421 fpgl_glGetUniformfv(GLuint program, GLint location, GLfloat* params)
1425 DEFINE_FAST_GL_FUNC();
1426 _COREGL_FAST_FUNC_BEGIN();
1427 INIT_FAST_GL_FUNC();
1429 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1431 _set_gl_error(GL_INVALID_VALUE);
1435 _sym_glGetUniformfv(real_obj, location, params);
1436 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1440 _COREGL_FAST_FUNC_END();
1444 fpgl_glGetUniformiv(GLuint program, GLint location, GLint* params)
1448 DEFINE_FAST_GL_FUNC();
1449 _COREGL_FAST_FUNC_BEGIN();
1450 INIT_FAST_GL_FUNC();
1452 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1454 _set_gl_error(GL_INVALID_VALUE);
1458 _sym_glGetUniformiv(real_obj, location, params);
1459 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1463 _COREGL_FAST_FUNC_END();
1467 fpgl_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum* binaryFormat, void* binary)
1471 DEFINE_FAST_GL_FUNC();
1472 _COREGL_FAST_FUNC_BEGIN();
1473 INIT_FAST_GL_FUNC();
1475 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1477 _set_gl_error(GL_INVALID_VALUE);
1481 _sym_glGetProgramBinary(real_obj, bufsize, length, binaryFormat, binary);
1482 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1486 _COREGL_FAST_FUNC_END();
1490 fpgl_glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GLint length)
1494 DEFINE_FAST_GL_FUNC();
1495 _COREGL_FAST_FUNC_BEGIN();
1496 INIT_FAST_GL_FUNC();
1498 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1500 _set_gl_error(GL_INVALID_VALUE);
1504 _sym_glProgramBinary(real_obj, binaryFormat, binary, length);
1505 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1509 _COREGL_FAST_FUNC_END();
1514 fpgl_glProgramParameteri(GLuint program, GLuint pname, GLint value)
1518 DEFINE_FAST_GL_FUNC();
1519 _COREGL_FAST_FUNC_BEGIN();
1520 INIT_FAST_GL_FUNC();
1522 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1524 _set_gl_error(GL_INVALID_VALUE);
1528 _sym_glProgramParameteri(real_obj, pname, value);
1529 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1533 _COREGL_FAST_FUNC_END();
1537 fpgl_glGetUniformLocation(GLuint program, const char* name)
1539 int ret = _COREGL_INT_INIT_VALUE;
1542 DEFINE_FAST_GL_FUNC();
1543 _COREGL_FAST_FUNC_BEGIN();
1544 INIT_FAST_GL_FUNC();
1546 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1548 _set_gl_error(GL_INVALID_VALUE);
1553 ret = _sym_glGetUniformLocation(real_obj, name);
1554 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1558 _COREGL_FAST_FUNC_END();
1563 fpgl_glDeleteShader(GLuint shader)
1567 DEFINE_FAST_GL_FUNC();
1568 _COREGL_FAST_FUNC_BEGIN();
1569 INIT_FAST_GL_FUNC();
1571 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1573 _set_gl_error(GL_INVALID_VALUE);
1577 _sym_glDeleteShader(real_obj);
1580 AST(sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shader) == 1);
1583 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1587 _COREGL_FAST_FUNC_END();
1591 fpgl_glDeleteProgram(GLuint program)
1595 DEFINE_FAST_GL_FUNC();
1596 _COREGL_FAST_FUNC_BEGIN();
1597 INIT_FAST_GL_FUNC();
1599 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1601 _set_gl_error(GL_INVALID_VALUE);
1605 _sym_glDeleteProgram(real_obj);
1608 AST(sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, program) == 1);
1611 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1615 _COREGL_FAST_FUNC_END();
1620 //////////////////////////////////////////////////////////////////////////////////
1623 fpgl_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1625 DEFINE_FAST_GL_FUNC();
1626 _COREGL_FAST_FUNC_BEGIN();
1627 INIT_FAST_GL_FUNC();
1629 if ((current_ctx->gl_blend_color[0] != red) ||
1630 (current_ctx->gl_blend_color[1] != green) ||
1631 (current_ctx->gl_blend_color[2] != blue) ||
1632 (current_ctx->gl_blend_color[3] != alpha))
1634 _sym_glBlendColor(red, green, blue, alpha);
1636 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1638 current_ctx->_blend_flag |= FLAG_BIT_0;
1639 current_ctx->gl_blend_color[0] = red;
1640 current_ctx->gl_blend_color[1] = green;
1641 current_ctx->gl_blend_color[2] = blue;
1642 current_ctx->gl_blend_color[3] = alpha;
1647 _COREGL_FAST_FUNC_END();
1653 fpgl_glBlendEquation(GLenum mode)
1655 DEFINE_FAST_GL_FUNC();
1656 _COREGL_FAST_FUNC_BEGIN();
1657 INIT_FAST_GL_FUNC();
1659 _sym_glBlendEquation(mode);
1661 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1663 current_ctx->_blend_flag |= (FLAG_BIT_5 | FLAG_BIT_6);
1664 _sym_glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*) & (current_ctx->gl_blend_equation_rgb));
1665 _sym_glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*) & (current_ctx->gl_blend_equation_alpha));
1669 _COREGL_FAST_FUNC_END();
1674 fpgl_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
1676 DEFINE_FAST_GL_FUNC();
1677 _COREGL_FAST_FUNC_BEGIN();
1678 INIT_FAST_GL_FUNC();
1680 if ((current_ctx->gl_blend_equation_rgb[0] != modeRGB) ||
1681 (current_ctx->gl_blend_equation_alpha[0] != modeAlpha))
1683 _sym_glBlendEquationSeparate(modeRGB, modeAlpha);
1685 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1687 current_ctx->_blend_flag |= (FLAG_BIT_5 | FLAG_BIT_6);
1688 current_ctx->gl_blend_equation_rgb[0] = modeRGB;
1689 current_ctx->gl_blend_equation_alpha[0] = modeAlpha;
1694 _COREGL_FAST_FUNC_END();
1700 fpgl_glBlendFunc(GLenum sfactor, GLenum dfactor)
1702 DEFINE_FAST_GL_FUNC();
1703 _COREGL_FAST_FUNC_BEGIN();
1704 INIT_FAST_GL_FUNC();
1706 _sym_glBlendFunc(sfactor, dfactor);
1708 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1710 current_ctx->_blend_flag |= (FLAG_BIT_1 | FLAG_BIT_2 | FLAG_BIT_3 | FLAG_BIT_4);
1711 _sym_glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*) & (current_ctx->gl_blend_src_rgb));
1712 _sym_glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*) & (current_ctx->gl_blend_src_alpha));
1713 _sym_glGetIntegerv(GL_BLEND_DST_RGB, (GLint*) & (current_ctx->gl_blend_dst_rgb));
1714 _sym_glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*) & (current_ctx->gl_blend_dst_alpha));
1718 _COREGL_FAST_FUNC_END();
1723 fpgl_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
1725 DEFINE_FAST_GL_FUNC();
1726 _COREGL_FAST_FUNC_BEGIN();
1727 INIT_FAST_GL_FUNC();
1729 if ((current_ctx->gl_blend_src_rgb[0] != srcRGB) ||
1730 (current_ctx->gl_blend_dst_rgb[0] != dstRGB) ||
1731 (current_ctx->gl_blend_src_alpha[0] != srcAlpha) ||
1732 (current_ctx->gl_blend_dst_alpha[0] != dstAlpha))
1734 _sym_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
1736 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1738 current_ctx->_blend_flag |= (FLAG_BIT_1 | FLAG_BIT_2 | FLAG_BIT_3 | FLAG_BIT_4);
1739 current_ctx->gl_blend_src_rgb[0] = srcRGB;
1740 current_ctx->gl_blend_dst_rgb[0] = dstRGB;
1741 current_ctx->gl_blend_src_alpha[0] = srcAlpha;
1742 current_ctx->gl_blend_dst_alpha[0] = dstAlpha;
1747 _COREGL_FAST_FUNC_END();
1752 fpgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1754 DEFINE_FAST_GL_FUNC();
1755 _COREGL_FAST_FUNC_BEGIN();
1756 INIT_FAST_GL_FUNC();
1758 if ((current_ctx->gl_color_clear_value[0] != red) ||
1759 (current_ctx->gl_color_clear_value[1] != green) ||
1760 (current_ctx->gl_color_clear_value[2] != blue) ||
1761 (current_ctx->gl_color_clear_value[3] != alpha))
1763 _sym_glClearColor(red, green, blue, alpha);
1765 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1767 current_ctx->_clear_flag1 |= (FLAG_BIT_2);
1768 current_ctx->gl_color_clear_value[0] = red;
1769 current_ctx->gl_color_clear_value[1] = green;
1770 current_ctx->gl_color_clear_value[2] = blue;
1771 current_ctx->gl_color_clear_value[3] = alpha;
1776 _COREGL_FAST_FUNC_END();
1781 fpgl_glClearDepthf(GLclampf depth)
1783 DEFINE_FAST_GL_FUNC();
1784 _COREGL_FAST_FUNC_BEGIN();
1785 INIT_FAST_GL_FUNC();
1787 CURR_STATE_COMPARE(gl_depth_clear_value, depth)
1789 _sym_glClearDepthf(depth);
1791 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1793 current_ctx->_clear_flag2 |= FLAG_BIT_2;
1794 current_ctx->gl_depth_clear_value[0] = depth;
1799 _COREGL_FAST_FUNC_END();
1804 fpgl_glClearStencil(GLint s)
1806 DEFINE_FAST_GL_FUNC();
1807 _COREGL_FAST_FUNC_BEGIN();
1808 INIT_FAST_GL_FUNC();
1810 CURR_STATE_COMPARE(gl_stencil_clear_value, s)
1812 _sym_glClearStencil(s);
1814 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1816 current_ctx->_stencil_flag2 |= FLAG_BIT_7;
1817 current_ctx->gl_stencil_clear_value[0] = s;
1822 _COREGL_FAST_FUNC_END();
1827 fpgl_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
1829 DEFINE_FAST_GL_FUNC();
1830 _COREGL_FAST_FUNC_BEGIN();
1831 INIT_FAST_GL_FUNC();
1833 if ((current_ctx->gl_color_writemask[0] != red) ||
1834 (current_ctx->gl_color_writemask[1] != green) ||
1835 (current_ctx->gl_color_writemask[2] != blue) ||
1836 (current_ctx->gl_color_writemask[3] != alpha))
1838 _sym_glColorMask(red, green, blue, alpha);
1840 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1842 current_ctx->_clear_flag2 |= FLAG_BIT_0;
1843 current_ctx->gl_color_writemask[0] = red;
1844 current_ctx->gl_color_writemask[1] = green;
1845 current_ctx->gl_color_writemask[2] = blue;
1846 current_ctx->gl_color_writemask[3] = alpha;
1851 _COREGL_FAST_FUNC_END();
1856 fpgl_glCullFace(GLenum mode)
1858 DEFINE_FAST_GL_FUNC();
1859 _COREGL_FAST_FUNC_BEGIN();
1860 INIT_FAST_GL_FUNC();
1862 CURR_STATE_COMPARE(gl_cull_face_mode, mode)
1864 _sym_glCullFace(mode);
1866 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1868 current_ctx->_clear_flag2 |= FLAG_BIT_5;
1869 current_ctx->gl_cull_face_mode[0] = mode;
1874 _COREGL_FAST_FUNC_END();
1879 fpgl_glDepthFunc(GLenum func)
1881 DEFINE_FAST_GL_FUNC();
1882 _COREGL_FAST_FUNC_BEGIN();
1883 INIT_FAST_GL_FUNC();
1885 CURR_STATE_COMPARE(gl_depth_func, func)
1887 _sym_glDepthFunc(func);
1889 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1891 current_ctx->_clear_flag2 |= FLAG_BIT_3;
1892 current_ctx->gl_depth_func[0] = func;
1897 _COREGL_FAST_FUNC_END();
1902 fpgl_glDepthMask(GLboolean flag)
1904 DEFINE_FAST_GL_FUNC();
1905 _COREGL_FAST_FUNC_BEGIN();
1906 INIT_FAST_GL_FUNC();
1908 CURR_STATE_COMPARE(gl_depth_writemask, flag)
1910 _sym_glDepthMask(flag);
1912 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1914 current_ctx->_clear_flag2 |= FLAG_BIT_4;
1915 current_ctx->gl_depth_writemask[0] = flag;
1920 _COREGL_FAST_FUNC_END();
1925 fpgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
1927 DEFINE_FAST_GL_FUNC();
1928 _COREGL_FAST_FUNC_BEGIN();
1929 INIT_FAST_GL_FUNC();
1931 if ((current_ctx->gl_depth_range[0] != zNear) ||
1932 (current_ctx->gl_depth_range[1] != zFar))
1934 _sym_glDepthRangef(zNear, zFar);
1936 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1938 current_ctx->_clear_flag2 |= FLAG_BIT_1;
1939 current_ctx->gl_depth_range[0] = zNear;
1940 current_ctx->gl_depth_range[1] = zFar;
1945 _COREGL_FAST_FUNC_END();
1950 fpgl_glDisable(GLenum cap)
1952 DEFINE_FAST_GL_FUNC();
1953 _COREGL_FAST_FUNC_BEGIN();
1954 INIT_FAST_GL_FUNC();
1959 CURR_STATE_COMPARE(gl_blend, GL_FALSE)
1961 _sym_glDisable(cap);
1962 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1963 current_ctx->_enable_flag1 &= (~FLAG_BIT_0);
1964 current_ctx->gl_blend[0] = GL_FALSE;
1968 CURR_STATE_COMPARE(gl_cull_face, GL_FALSE)
1970 _sym_glDisable(cap);
1971 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1972 current_ctx->_enable_flag1 &= (~FLAG_BIT_1);
1973 current_ctx->gl_cull_face[0] = GL_FALSE;
1977 CURR_STATE_COMPARE(gl_depth_test, GL_FALSE)
1979 _sym_glDisable(cap);
1980 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1981 current_ctx->_enable_flag1 &= (~FLAG_BIT_2);
1982 current_ctx->gl_depth_test[0] = GL_FALSE;
1986 CURR_STATE_COMPARE(gl_dither, GL_FALSE)
1988 _sym_glDisable(cap);
1989 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1990 current_ctx->_enable_flag1 &= (~FLAG_BIT_3);
1991 current_ctx->gl_dither[0] = GL_FALSE;
1994 case GL_POLYGON_OFFSET_FILL:
1995 CURR_STATE_COMPARE(gl_polygon_offset_fill, GL_FALSE)
1997 _sym_glDisable(cap);
1998 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1999 current_ctx->_enable_flag2 &= (~FLAG_BIT_0);
2000 current_ctx->gl_polygon_offset_fill[0] = GL_FALSE;
2003 case GL_SAMPLE_ALPHA_TO_COVERAGE:
2004 CURR_STATE_COMPARE(gl_sample_alpha_to_coverage, GL_FALSE)
2006 _sym_glDisable(cap);
2007 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2008 current_ctx->_enable_flag2 &= (~FLAG_BIT_1);
2009 current_ctx->gl_sample_alpha_to_coverage[0] = GL_FALSE;
2012 case GL_SAMPLE_COVERAGE:
2013 CURR_STATE_COMPARE(gl_sample_coverage, GL_FALSE)
2015 _sym_glDisable(cap);
2016 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2017 current_ctx->_enable_flag2 &= (~FLAG_BIT_2);
2018 current_ctx->gl_sample_coverage[0] = GL_FALSE;
2021 case GL_SCISSOR_TEST:
2022 CURR_STATE_COMPARE(gl_scissor_test, GL_FALSE)
2024 _sym_glDisable(cap);
2025 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2026 current_ctx->_enable_flag2 &= (~FLAG_BIT_3);
2027 current_ctx->gl_scissor_test[0] = GL_FALSE;
2030 case GL_STENCIL_TEST:
2031 CURR_STATE_COMPARE(gl_stencil_test, GL_FALSE)
2033 _sym_glDisable(cap);
2034 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2035 current_ctx->_enable_flag2 &= (~FLAG_BIT_4);
2036 current_ctx->gl_stencil_test[0] = GL_FALSE;
2043 _COREGL_FAST_FUNC_END();
2048 fpgl_glDisableVertexAttribArray(GLuint index)
2050 DEFINE_FAST_GL_FUNC();
2051 _COREGL_FAST_FUNC_BEGIN();
2052 INIT_FAST_GL_FUNC();
2054 _sym_glDisableVertexAttribArray(index);
2056 current_ctx->_vattrib_flag |= FLAG_BIT_1;
2057 current_ctx->gl_vertex_array_enabled[index] = GL_FALSE;
2062 _COREGL_FAST_FUNC_END();
2067 fpgl_glDrawArrays(GLenum mode, GLint first, GLsizei count)
2069 DEFINE_FAST_GL_FUNC();
2070 _COREGL_FAST_FUNC_BEGIN();
2071 INIT_FAST_GL_FUNC();
2073 _sym_glDrawArrays(mode, first, count);
2077 _COREGL_FAST_FUNC_END();
2082 fpgl_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
2084 DEFINE_FAST_GL_FUNC();
2085 _COREGL_FAST_FUNC_BEGIN();
2086 INIT_FAST_GL_FUNC();
2088 _sym_glDrawElements(mode, count, type, indices);
2092 _COREGL_FAST_FUNC_END();
2097 fpgl_glEnable(GLenum cap)
2099 DEFINE_FAST_GL_FUNC();
2100 _COREGL_FAST_FUNC_BEGIN();
2101 INIT_FAST_GL_FUNC();
2106 CURR_STATE_COMPARE(gl_blend, GL_TRUE)
2109 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2111 current_ctx->_enable_flag1 |= FLAG_BIT_0;
2112 current_ctx->gl_blend[0] = GL_TRUE;
2116 CURR_STATE_COMPARE(gl_cull_face, GL_TRUE)
2119 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2122 current_ctx->_enable_flag1 |= FLAG_BIT_1;
2123 current_ctx->gl_cull_face[0] = GL_TRUE;
2127 CURR_STATE_COMPARE(gl_depth_test, GL_TRUE)
2130 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2133 current_ctx->_enable_flag1 |= FLAG_BIT_2;
2134 current_ctx->gl_depth_test[0] = GL_TRUE;
2138 CURR_STATE_COMPARE(gl_dither, GL_TRUE)
2141 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2144 current_ctx->_enable_flag1 |= FLAG_BIT_3;
2145 current_ctx->gl_dither[0] = GL_TRUE;
2148 case GL_POLYGON_OFFSET_FILL:
2149 CURR_STATE_COMPARE(gl_polygon_offset_fill, GL_TRUE)
2152 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2155 current_ctx->_enable_flag2 |= FLAG_BIT_0;
2156 current_ctx->gl_polygon_offset_fill[0] = GL_TRUE;
2159 case GL_SAMPLE_ALPHA_TO_COVERAGE:
2160 CURR_STATE_COMPARE(gl_sample_alpha_to_coverage, GL_TRUE)
2163 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2166 current_ctx->_enable_flag2 |= FLAG_BIT_1;
2167 current_ctx->gl_sample_alpha_to_coverage[0] = GL_TRUE;
2170 case GL_SAMPLE_COVERAGE:
2171 CURR_STATE_COMPARE(gl_sample_coverage, GL_TRUE)
2174 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2177 current_ctx->_enable_flag2 |= FLAG_BIT_2;
2178 current_ctx->gl_sample_coverage[0] = GL_TRUE;
2181 case GL_SCISSOR_TEST:
2182 CURR_STATE_COMPARE(gl_scissor_test, GL_TRUE)
2185 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2188 current_ctx->_enable_flag2 |= FLAG_BIT_3;
2189 current_ctx->gl_scissor_test[0] = GL_TRUE;
2192 case GL_STENCIL_TEST:
2193 CURR_STATE_COMPARE(gl_stencil_test, GL_TRUE)
2196 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2199 current_ctx->_enable_flag2 |= FLAG_BIT_4;
2200 current_ctx->gl_stencil_test[0] = GL_TRUE;
2207 _COREGL_FAST_FUNC_END();
2213 fpgl_glEnableVertexAttribArray(GLuint index)
2215 DEFINE_FAST_GL_FUNC();
2216 _COREGL_FAST_FUNC_BEGIN();
2217 INIT_FAST_GL_FUNC();
2219 _sym_glEnableVertexAttribArray(index);
2221 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2223 current_ctx->_vattrib_flag |= FLAG_BIT_1;
2224 current_ctx->gl_vertex_array_enabled[index] = GL_TRUE;
2229 _COREGL_FAST_FUNC_END();
2234 fpgl_glFrontFace(GLenum mode)
2236 DEFINE_FAST_GL_FUNC();
2237 _COREGL_FAST_FUNC_BEGIN();
2238 INIT_FAST_GL_FUNC();
2240 CURR_STATE_COMPARE(gl_front_face, mode)
2242 _sym_glFrontFace(mode);
2244 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2246 current_ctx->_misc_flag1 |= FLAG_BIT_0;
2247 current_ctx->gl_front_face[0] = mode;
2252 _COREGL_FAST_FUNC_END();
2257 fpgl_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
2259 DEFINE_FAST_GL_FUNC();
2260 _COREGL_FAST_FUNC_BEGIN();
2261 INIT_FAST_GL_FUNC();
2263 _sym_glGetVertexAttribfv(index, pname, params);
2265 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2269 _COREGL_FAST_FUNC_END();
2274 fpgl_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
2276 DEFINE_FAST_GL_FUNC();
2277 _COREGL_FAST_FUNC_BEGIN();
2278 INIT_FAST_GL_FUNC();
2280 _sym_glGetVertexAttribiv(index, pname, params);
2282 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2286 _COREGL_FAST_FUNC_END();
2291 fpgl_glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
2293 DEFINE_FAST_GL_FUNC();
2294 _COREGL_FAST_FUNC_BEGIN();
2295 INIT_FAST_GL_FUNC();
2297 _sym_glGetVertexAttribPointerv(index, pname, pointer);
2299 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2304 _COREGL_FAST_FUNC_END();
2309 fpgl_glHint(GLenum target, GLenum mode)
2311 DEFINE_FAST_GL_FUNC();
2312 _COREGL_FAST_FUNC_BEGIN();
2313 INIT_FAST_GL_FUNC();
2315 if (target == GL_GENERATE_MIPMAP_HINT)
2317 CURR_STATE_COMPARE(gl_generate_mipmap_hint, mode)
2319 _sym_glHint(target, mode);
2321 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2323 current_ctx->_tex_flag1 |= FLAG_BIT_2;
2324 current_ctx->gl_generate_mipmap_hint[0] = mode;
2329 // For GL Error to be picked up
2330 _sym_glHint(target, mode);
2331 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2336 _COREGL_FAST_FUNC_END();
2341 fpgl_glLineWidth(GLfloat width)
2343 DEFINE_FAST_GL_FUNC();
2344 _COREGL_FAST_FUNC_BEGIN();
2345 INIT_FAST_GL_FUNC();
2347 CURR_STATE_COMPARE(gl_line_width, width)
2349 _sym_glLineWidth(width);
2351 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2353 current_ctx->_misc_flag1 |= FLAG_BIT_1;
2354 current_ctx->gl_line_width[0] = width;
2359 _COREGL_FAST_FUNC_END();
2364 fpgl_glPixelStorei(GLenum pname, GLint param)
2366 DEFINE_FAST_GL_FUNC();
2367 _COREGL_FAST_FUNC_BEGIN();
2368 INIT_FAST_GL_FUNC();
2370 if (pname == GL_PACK_ALIGNMENT)
2372 CURR_STATE_COMPARE(gl_pack_alignment, param)
2374 _sym_glPixelStorei(pname, param);
2376 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2378 current_ctx->_misc_flag2 |= FLAG_BIT_1;
2379 current_ctx->gl_pack_alignment[0] = param;
2382 else if (pname == GL_UNPACK_ALIGNMENT)
2384 CURR_STATE_COMPARE(gl_unpack_alignment, param)
2386 _sym_glPixelStorei(pname, param);
2388 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2390 current_ctx->_misc_flag2 |= FLAG_BIT_2;
2391 current_ctx->gl_unpack_alignment[0] = param;
2396 // For GL Error to be picked up
2397 _sym_glPixelStorei(pname, param);
2398 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2403 _COREGL_FAST_FUNC_END();
2408 fpgl_glPolygonOffset(GLfloat factor, GLfloat units)
2410 DEFINE_FAST_GL_FUNC();
2411 _COREGL_FAST_FUNC_BEGIN();
2412 INIT_FAST_GL_FUNC();
2414 if ((current_ctx->gl_polygon_offset_factor[0] != factor) ||
2415 (current_ctx->gl_polygon_offset_units[0] != units))
2417 _sym_glPolygonOffset(factor, units);
2419 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2421 current_ctx->_misc_flag1 |= (FLAG_BIT_2 | FLAG_BIT_3);
2422 current_ctx->gl_polygon_offset_factor[0] = factor;
2423 current_ctx->gl_polygon_offset_units[0] = units;
2428 _COREGL_FAST_FUNC_END();
2433 fpgl_glSampleCoverage(GLclampf value, GLboolean invert)
2435 DEFINE_FAST_GL_FUNC();
2436 _COREGL_FAST_FUNC_BEGIN();
2437 INIT_FAST_GL_FUNC();
2439 if ((current_ctx->gl_sample_coverage_value[0] != value) ||
2440 (current_ctx->gl_sample_coverage_invert[0] != invert))
2442 _sym_glSampleCoverage(value, invert);
2444 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2446 current_ctx->_misc_flag1 |= (FLAG_BIT_4 | FLAG_BIT_5);
2447 current_ctx->gl_sample_coverage_value[0] = value;
2448 current_ctx->gl_sample_coverage_invert[0] = invert;
2453 _COREGL_FAST_FUNC_END();
2458 fpgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
2460 DEFINE_FAST_GL_FUNC();
2461 _COREGL_FAST_FUNC_BEGIN();
2462 INIT_FAST_GL_FUNC();
2464 if ((current_ctx->gl_scissor_box[0] != x) ||
2465 (current_ctx->gl_scissor_box[1] != y) ||
2466 (current_ctx->gl_scissor_box[2] != width) ||
2467 (current_ctx->gl_scissor_box[3] != height))
2469 _sym_glScissor(x, y, width, height);
2471 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2473 current_ctx->_misc_flag2 |= FLAG_BIT_0;
2474 current_ctx->gl_scissor_box[0] = x;
2475 current_ctx->gl_scissor_box[1] = y;
2476 current_ctx->gl_scissor_box[2] = width;
2477 current_ctx->gl_scissor_box[3] = height;
2482 _COREGL_FAST_FUNC_END();
2487 fpgl_glStencilFunc(GLenum func, GLint ref, GLuint mask)
2489 DEFINE_FAST_GL_FUNC();
2490 _COREGL_FAST_FUNC_BEGIN();
2491 INIT_FAST_GL_FUNC();
2493 if ((current_ctx->gl_stencil_func[0] != func) ||
2494 (current_ctx->gl_stencil_ref[0] != ref) ||
2495 (current_ctx->gl_stencil_value_mask[0] != mask) ||
2496 (current_ctx->gl_stencil_back_func[0] != func) ||
2497 (current_ctx->gl_stencil_back_ref[0] != ref) ||
2498 (current_ctx->gl_stencil_back_value_mask[0] != mask))
2500 _sym_glStencilFunc(func, ref, mask);
2502 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2504 current_ctx->_stencil_flag1 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
2505 current_ctx->gl_stencil_func[0] = func;
2506 current_ctx->gl_stencil_ref[0] = ref;
2507 current_ctx->gl_stencil_value_mask[0] = mask;
2509 current_ctx->_stencil_flag2 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
2510 current_ctx->gl_stencil_back_func[0] = func;
2511 current_ctx->gl_stencil_back_ref[0] = ref;
2512 current_ctx->gl_stencil_back_value_mask[0] = mask;
2517 _COREGL_FAST_FUNC_END();
2522 fpgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
2524 DEFINE_FAST_GL_FUNC();
2525 _COREGL_FAST_FUNC_BEGIN();
2526 INIT_FAST_GL_FUNC();
2528 if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
2530 if ((current_ctx->gl_stencil_func[0] != func) ||
2531 (current_ctx->gl_stencil_ref[0] != ref) ||
2532 (current_ctx->gl_stencil_value_mask[0] != mask))
2534 _sym_glStencilFuncSeparate(face, func, ref, mask);
2536 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2538 current_ctx->_stencil_flag1 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
2540 current_ctx->gl_stencil_func[0] = func;
2541 current_ctx->gl_stencil_ref[0] = ref;
2542 current_ctx->gl_stencil_value_mask[0] = mask;
2545 else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
2547 if ((current_ctx->gl_stencil_back_func[0] != func) ||
2548 (current_ctx->gl_stencil_back_ref[0] != ref) ||
2549 (current_ctx->gl_stencil_back_value_mask[0] != mask))
2551 _sym_glStencilFuncSeparate(face, func, ref, mask);
2553 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2555 current_ctx->_stencil_flag2 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
2557 current_ctx->gl_stencil_back_func[0] = func;
2558 current_ctx->gl_stencil_back_ref[0] = ref;
2559 current_ctx->gl_stencil_back_value_mask[0] = mask;
2564 // Have GL pick up the error
2565 _sym_glStencilFuncSeparate(face, func, ref, mask);
2567 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2572 _COREGL_FAST_FUNC_END();
2577 fpgl_glStencilMask(GLuint mask)
2579 DEFINE_FAST_GL_FUNC();
2580 _COREGL_FAST_FUNC_BEGIN();
2581 INIT_FAST_GL_FUNC();
2583 if ((current_ctx->gl_stencil_writemask[0] != mask) ||
2584 (current_ctx->gl_stencil_back_writemask[0] != mask))
2586 _sym_glStencilMask(mask);
2588 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2590 current_ctx->_stencil_flag1 |= (FLAG_BIT_6);
2591 current_ctx->_stencil_flag2 |= (FLAG_BIT_6);
2593 current_ctx->gl_stencil_writemask[0] = mask;
2594 current_ctx->gl_stencil_back_writemask[0] = mask;
2599 _COREGL_FAST_FUNC_END();
2604 fpgl_glStencilMaskSeparate(GLenum face, GLuint mask)
2606 DEFINE_FAST_GL_FUNC();
2607 _COREGL_FAST_FUNC_BEGIN();
2608 INIT_FAST_GL_FUNC();
2610 if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
2612 if (current_ctx->gl_stencil_writemask[0] != mask)
2614 _sym_glStencilMaskSeparate(face, mask);
2616 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2618 current_ctx->_stencil_flag1 |= (FLAG_BIT_6);
2619 current_ctx->gl_stencil_writemask[0] = mask;
2622 else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
2624 if (current_ctx->gl_stencil_back_writemask[0] != mask)
2626 _sym_glStencilMaskSeparate(face, mask);
2628 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2630 current_ctx->_stencil_flag2 |= (FLAG_BIT_6);
2631 current_ctx->gl_stencil_back_writemask[0] = mask;
2636 // Have GL pick up the error
2637 _sym_glStencilMaskSeparate(face, mask);
2638 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2643 _COREGL_FAST_FUNC_END();
2648 fpgl_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
2650 DEFINE_FAST_GL_FUNC();
2651 _COREGL_FAST_FUNC_BEGIN();
2652 INIT_FAST_GL_FUNC();
2654 if ((current_ctx->gl_stencil_fail[0] != fail) ||
2655 (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) ||
2656 (current_ctx->gl_stencil_pass_depth_pass[0] != zpass) ||
2657 (current_ctx->gl_stencil_back_fail[0] != fail) ||
2658 (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) ||
2659 (current_ctx->gl_stencil_back_pass_depth_pass[0] != zpass))
2661 _sym_glStencilOp(fail, zfail, zpass);
2663 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2665 current_ctx->_stencil_flag1 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
2666 current_ctx->gl_stencil_fail[0] = fail;
2667 current_ctx->gl_stencil_pass_depth_fail[0] = zfail;
2668 current_ctx->gl_stencil_pass_depth_pass[0] = zpass;
2670 current_ctx->_stencil_flag2 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
2671 current_ctx->gl_stencil_back_fail[0] = fail;
2672 current_ctx->gl_stencil_back_pass_depth_fail[0] = zfail;
2673 current_ctx->gl_stencil_back_pass_depth_pass[0] = zpass;
2678 _COREGL_FAST_FUNC_END();
2683 fpgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
2685 DEFINE_FAST_GL_FUNC();
2686 _COREGL_FAST_FUNC_BEGIN();
2687 INIT_FAST_GL_FUNC();
2689 if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
2691 if ((current_ctx->gl_stencil_fail[0] != fail) ||
2692 (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) ||
2693 (current_ctx->gl_stencil_pass_depth_pass[0] != zpass))
2695 _sym_glStencilOpSeparate(face, fail, zfail, zpass);
2696 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2698 current_ctx->_stencil_flag1 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
2699 current_ctx->gl_stencil_fail[0] = fail;
2700 current_ctx->gl_stencil_pass_depth_fail[0] = zfail;
2701 current_ctx->gl_stencil_pass_depth_pass[0] = zpass;
2704 else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
2706 if ((current_ctx->gl_stencil_back_fail[0] != fail) ||
2707 (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) ||
2708 (current_ctx->gl_stencil_back_pass_depth_pass[0] != zpass))
2710 _sym_glStencilOpSeparate(face, fail, zfail, zpass);
2711 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2713 current_ctx->_stencil_flag2 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
2714 current_ctx->gl_stencil_back_fail[0] = fail;
2715 current_ctx->gl_stencil_back_pass_depth_fail[0] = zfail;
2716 current_ctx->gl_stencil_back_pass_depth_pass[0] = zpass;
2721 // For picking up error purpose
2722 _sym_glStencilOpSeparate(face, fail, zfail, zpass);
2723 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2728 _COREGL_FAST_FUNC_END();
2733 fpgl_glVertexAttrib1f(GLuint indx, GLfloat x)
2735 DEFINE_FAST_GL_FUNC();
2736 _COREGL_FAST_FUNC_BEGIN();
2737 INIT_FAST_GL_FUNC();
2739 _sym_glVertexAttrib1f(indx, x);
2741 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2743 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2744 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
2745 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = 0;
2746 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
2747 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2751 _COREGL_FAST_FUNC_END();
2757 fpgl_glVertexAttrib1fv(GLuint indx, const GLfloat* values)
2759 DEFINE_FAST_GL_FUNC();
2760 _COREGL_FAST_FUNC_BEGIN();
2761 INIT_FAST_GL_FUNC();
2763 _sym_glVertexAttrib1fv(indx, values);
2765 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2767 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2768 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
2769 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = 0;
2770 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
2771 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2775 _COREGL_FAST_FUNC_END();
2781 fpgl_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
2783 DEFINE_FAST_GL_FUNC();
2784 _COREGL_FAST_FUNC_BEGIN();
2785 INIT_FAST_GL_FUNC();
2787 _sym_glVertexAttrib2f(indx, x, y);
2789 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2791 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2792 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
2793 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = y;
2794 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
2795 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2799 _COREGL_FAST_FUNC_END();
2805 fpgl_glVertexAttrib2fv(GLuint indx, const GLfloat* values)
2807 DEFINE_FAST_GL_FUNC();
2808 _COREGL_FAST_FUNC_BEGIN();
2809 INIT_FAST_GL_FUNC();
2811 _sym_glVertexAttrib2fv(indx, values);
2813 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2815 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2816 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
2817 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = values[1];
2818 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
2819 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2823 _COREGL_FAST_FUNC_END();
2829 fpgl_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
2831 DEFINE_FAST_GL_FUNC();
2832 _COREGL_FAST_FUNC_BEGIN();
2833 INIT_FAST_GL_FUNC();
2835 _sym_glVertexAttrib3f(indx, x, y, z);
2837 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2839 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2840 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
2841 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = y;
2842 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = z;
2843 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2847 _COREGL_FAST_FUNC_END();
2853 fpgl_glVertexAttrib3fv(GLuint indx, const GLfloat* values)
2855 DEFINE_FAST_GL_FUNC();
2856 _COREGL_FAST_FUNC_BEGIN();
2857 INIT_FAST_GL_FUNC();
2859 _sym_glVertexAttrib3fv(indx, values);
2861 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2863 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2864 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
2865 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = values[1];
2866 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = values[2];
2867 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2871 _COREGL_FAST_FUNC_END();
2877 fpgl_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
2879 DEFINE_FAST_GL_FUNC();
2880 _COREGL_FAST_FUNC_BEGIN();
2881 INIT_FAST_GL_FUNC();
2883 _sym_glVertexAttrib4f(indx, x, y, z, w);
2885 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2887 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2888 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
2889 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = y;
2890 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = z;
2891 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = w;
2895 _COREGL_FAST_FUNC_END();
2901 fpgl_glVertexAttrib4fv(GLuint indx, const GLfloat* values)
2903 DEFINE_FAST_GL_FUNC();
2904 _COREGL_FAST_FUNC_BEGIN();
2905 INIT_FAST_GL_FUNC();
2907 _sym_glVertexAttrib4fv(indx, values);
2909 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2911 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2912 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
2913 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = values[1];
2914 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = values[2];
2915 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = values[3];
2919 _COREGL_FAST_FUNC_END();
2926 fpgl_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
2928 DEFINE_FAST_GL_FUNC();
2929 _COREGL_FAST_FUNC_BEGIN();
2930 INIT_FAST_GL_FUNC();
2932 _sym_glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
2934 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2936 current_ctx->_vattrib_flag |= FLAG_BIT_1;
2938 current_ctx->gl_vertex_array_buf_id[indx] = current_ctx->gl_array_buffer_binding[0];
2939 current_ctx->gl_vertex_array_size[indx] = size;
2940 current_ctx->gl_vertex_array_type[indx] = type;
2941 current_ctx->gl_vertex_array_normalized[indx] = normalized;
2942 current_ctx->gl_vertex_array_stride[indx] = stride;
2943 current_ctx->gl_vertex_array_pointer[indx] = (GLvoid *)ptr;
2947 _COREGL_FAST_FUNC_END();
2952 fpgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
2954 DEFINE_FAST_GL_FUNC();
2955 _COREGL_FAST_FUNC_BEGIN();
2956 INIT_FAST_GL_FUNC();
2958 if ((current_ctx->gl_viewport[0] != x) ||
2959 (current_ctx->gl_viewport[1] != y) ||
2960 (current_ctx->gl_viewport[2] != width) ||
2961 (current_ctx->gl_viewport[3] != height))
2963 _sym_glViewport(x, y, width, height);
2965 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2967 current_ctx->_clear_flag1 |= FLAG_BIT_0;
2968 current_ctx->gl_viewport[0] = x;
2969 current_ctx->gl_viewport[1] = y;
2970 current_ctx->gl_viewport[2] = width;
2971 current_ctx->gl_viewport[3] = height;
2976 _COREGL_FAST_FUNC_END();
2980 fpgl_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
2984 DEFINE_FAST_GL_FUNC();
2985 _COREGL_FAST_FUNC_BEGIN();
2986 INIT_FAST_GL_FUNC();
2988 tex_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0;
2993 current_ctx->gl_tex_2d_state[tex_idx] = -1;
2995 case GL_TEXTURE_CUBE_MAP:
2996 current_ctx->gl_tex_cube_state[tex_idx] = -1;
3000 _sym_glEGLImageTargetTexture2DOES(target, image);
3002 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3007 _COREGL_FAST_FUNC_END();
3011 _process_getfunc(GLenum pname, GLvoid *ptr, GLenum get_type)
3013 GLboolean ret = GL_FALSE;
3015 DEFINE_FAST_GL_FUNC();
3016 INIT_FAST_GL_FUNC();
3020 case GL_TEXTURE_BINDING_2D:
3022 GLint real_tex_id = _COREGL_INT_INIT_VALUE;
3023 GLuint glue_tex_id = _COREGL_INT_INIT_VALUE;
3024 _sym_glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)real_tex_id);
3026 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3028 if (real_tex_id == 0)
3034 AST(current_ctx->sostate != NULL);
3035 glue_tex_id = sostate_find_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, real_tex_id);
3041 ((GLint *)ptr)[0] = glue_tex_id;
3044 ((GLfloat *)ptr)[0] = (GLfloat)glue_tex_id;
3047 ((GLboolean *)ptr)[0] = (glue_tex_id == 0) ? GL_FALSE : GL_TRUE;
3062 fpgl_glGetBooleanv(GLenum pname, GLboolean* params)
3064 DEFINE_FAST_GL_FUNC();
3065 _COREGL_FAST_FUNC_BEGIN();
3066 INIT_FAST_GL_FUNC();
3068 if (_process_getfunc(pname, params, GL_BOOL) != GL_TRUE)
3070 _sym_glGetBooleanv(pname, params);
3071 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3076 _COREGL_FAST_FUNC_END();
3080 fpgl_glGetFloatv(GLenum pname, GLfloat* params)
3082 DEFINE_FAST_GL_FUNC();
3083 _COREGL_FAST_FUNC_BEGIN();
3084 INIT_FAST_GL_FUNC();
3086 if (_process_getfunc(pname, params, GL_FLOAT) != GL_TRUE)
3088 _sym_glGetFloatv(pname, params);
3089 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3094 _COREGL_FAST_FUNC_END();
3098 fpgl_glGetIntegerv(GLenum pname, GLint* params)
3100 DEFINE_FAST_GL_FUNC();
3101 _COREGL_FAST_FUNC_BEGIN();
3102 INIT_FAST_GL_FUNC();
3104 if (_process_getfunc(pname, params, GL_INT) != GL_TRUE)
3106 _sym_glGetIntegerv(pname, params);
3107 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3112 _COREGL_FAST_FUNC_END();