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 AST(tstate != NULL); \
22 AST(tstate->cstate != NULL); \
23 current_ctx = (GLGlueContext *)tstate->cstate->data; \
24 AST(current_ctx != NULL);
26 #define GET_REAL_OBJ(type, glue_handle, real_handle) \
27 _get_real_obj(current_ctx->sostate, type, glue_handle, real_handle)
30 _get_real_obj(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_handle, GLuint *real_handle)
39 *real_handle = sostate_get_object(sostate, type, glue_handle);
40 if (*real_handle == 0)
47 _set_gl_error(GLenum error)
49 GLenum glerror = GL_NONE;
50 DEFINE_FAST_GL_FUNC();
53 glerror = _sym_glGetError();
55 if (current_ctx->gl_error == GL_NO_ERROR &&
56 glerror == GL_NO_ERROR &&
59 current_ctx->gl_error = error;
68 DEFINE_FAST_GL_FUNC();
69 _COREGL_FAST_FUNC_BEGIN();
72 if (current_ctx->gl_error != GL_NO_ERROR)
74 ret = current_ctx->gl_error;
78 ret = _sym_glGetError();
83 _COREGL_FAST_FUNC_END();
87 ////////////////////////////////////////////////////////////////////////
90 fpgl_glActiveTexture(GLenum texture)
92 DEFINE_FAST_GL_FUNC();
93 _COREGL_FAST_FUNC_BEGIN();
96 CURR_STATE_COMPARE(gl_active_texture, texture)
98 _sym_glActiveTexture(texture);
100 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
102 current_ctx->_tex_flag1 |= FLAG_BIT_1;
103 current_ctx->gl_active_texture[0] = texture;
108 _COREGL_FAST_FUNC_END();
113 fpgl_glGenTextures(GLsizei n, GLuint* textures)
116 GLuint *objid_array = NULL;
118 DEFINE_FAST_GL_FUNC();
119 _COREGL_FAST_FUNC_BEGIN();
122 if (textures == NULL) goto finish;
124 AST(current_ctx->sostate != NULL);
126 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
128 _sym_glGenTextures(n, objid_array);
130 for (i = 0; i < n; i++)
132 textures[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, objid_array[i]);
138 if (objid_array != NULL)
143 _COREGL_FAST_FUNC_END();
148 fpgl_glBindTexture(GLenum target, GLuint texture)
153 DEFINE_FAST_GL_FUNC();
154 _COREGL_FAST_FUNC_BEGIN();
157 active_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0;
159 if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1)
161 _set_gl_error(GL_OUT_OF_MEMORY);
165 if (target == GL_TEXTURE_2D)
167 if (current_ctx->gl_tex_2d_state[active_idx] != real_obj)
169 _sym_glBindTexture(target, real_obj);
171 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
173 current_ctx->_tex_flag1 |= FLAG_BIT_3;
175 current_ctx->gl_tex_2d_state[active_idx] = real_obj;
178 else if (target == GL_TEXTURE_CUBE_MAP)
180 if (current_ctx->gl_tex_cube_state[active_idx] != real_obj)
182 _sym_glBindTexture(target, real_obj);
184 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
186 current_ctx->_tex_flag1 |= FLAG_BIT_4;
188 current_ctx->gl_tex_cube_state[active_idx] = real_obj;
194 _COREGL_FAST_FUNC_END();
199 fpgl_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
203 DEFINE_FAST_GL_FUNC();
204 _COREGL_FAST_FUNC_BEGIN();
207 if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1)
209 _set_gl_error(GL_OUT_OF_MEMORY);
213 _sym_glFramebufferTexture2D(target, attachment, textarget, real_obj, level);
215 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
219 _COREGL_FAST_FUNC_END();
223 fpgl_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
227 DEFINE_FAST_GL_FUNC();
228 _COREGL_FAST_FUNC_BEGIN();
231 if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1)
233 _set_gl_error(GL_OUT_OF_MEMORY);
237 _sym_glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, real_obj, level, samples);
239 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
243 _COREGL_FAST_FUNC_END();
247 fpgl_glIsTexture(GLuint texture)
252 DEFINE_FAST_GL_FUNC();
253 _COREGL_FAST_FUNC_BEGIN();
256 if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1)
262 ret = _sym_glIsTexture(real_obj);
264 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
269 _COREGL_FAST_FUNC_END();
275 fpgl_glDeleteTextures(GLsizei n, const GLuint* textures)
278 GLuint *objid_array = NULL;
280 DEFINE_FAST_GL_FUNC();
281 _COREGL_FAST_FUNC_BEGIN();
284 if (textures == NULL) goto finish;
286 AST(current_ctx->sostate != NULL);
288 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
292 for (i = 0; i < n; i++)
294 int real_objid = _COREGL_INT_INIT_VALUE;
295 if (textures[i] == 0) continue;
297 real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]);
298 if (real_objid == 0) continue;
300 sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]);
301 objid_array[real_n++] = real_objid;
304 _sym_glDeleteTextures(real_n, objid_array);
305 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
307 for (i = 0; i < real_n; i++)
309 for (j = 0; j < current_ctx->gl_num_tex_units[0]; j++)
311 if (current_ctx->gl_tex_2d_state[j] == objid_array[i])
312 current_ctx->gl_tex_2d_state[j] = 0;
313 if (current_ctx->gl_tex_cube_state[j] == objid_array[i])
314 current_ctx->gl_tex_cube_state[j] = 0;
322 if (objid_array != NULL)
327 _COREGL_FAST_FUNC_END();
330 ////////////////////////////////////////////////////////////////////////
333 fpgl_glGenBuffers(GLsizei n, GLuint* buffers)
336 GLuint *objid_array = NULL;
338 DEFINE_FAST_GL_FUNC();
339 _COREGL_FAST_FUNC_BEGIN();
342 if (buffers == NULL) goto finish;
344 AST(current_ctx->sostate != NULL);
346 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
348 _sym_glGenBuffers(n, objid_array);
350 for (i = 0; i < n; i++)
352 buffers[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, objid_array[i]);
358 if (objid_array != NULL)
363 _COREGL_FAST_FUNC_END();
368 fpgl_glBindBuffer(GLenum target, GLuint buffer)
372 DEFINE_FAST_GL_FUNC();
373 _COREGL_FAST_FUNC_BEGIN();
376 if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1)
378 _set_gl_error(GL_OUT_OF_MEMORY);
382 if (target == GL_ARRAY_BUFFER)
384 CURR_STATE_COMPARE(gl_array_buffer_binding, real_obj)
386 _sym_glBindBuffer(target, real_obj);
388 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
391 current_ctx->_bind_flag &= (~FLAG_BIT_0);
393 current_ctx->_bind_flag |= FLAG_BIT_0;
394 current_ctx->gl_array_buffer_binding[0] = real_obj;
397 else if (target == GL_ELEMENT_ARRAY_BUFFER)
399 CURR_STATE_COMPARE(gl_element_array_buffer_binding, real_obj)
401 _sym_glBindBuffer(target, real_obj);
402 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
405 current_ctx->_bind_flag &= (~FLAG_BIT_1);
407 current_ctx->_bind_flag |= FLAG_BIT_1;
408 current_ctx->gl_element_array_buffer_binding[0] = real_obj;
413 // For error recording
414 _sym_glBindBuffer(target, real_obj);
415 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
420 _COREGL_FAST_FUNC_END();
424 fpgl_glIsBuffer(GLuint buffer)
429 DEFINE_FAST_GL_FUNC();
430 _COREGL_FAST_FUNC_BEGIN();
433 if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1)
439 ret = _sym_glIsBuffer(real_obj);
441 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
446 _COREGL_FAST_FUNC_END();
452 fpgl_glDeleteBuffers(GLsizei n, const GLuint* buffers)
455 GLuint *objid_array = NULL;
457 DEFINE_FAST_GL_FUNC();
458 _COREGL_FAST_FUNC_BEGIN();
461 if (buffers == NULL) goto finish;
463 AST(current_ctx->sostate != NULL);
465 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
469 for (i = 0; i < n; i++)
471 int real_objid = _COREGL_INT_INIT_VALUE;
472 if (buffers[i] == 0) continue;
474 real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, buffers[i]);
475 if (real_objid == 0) continue;
477 sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, buffers[i]);
478 objid_array[real_n++] = real_objid;
481 _sym_glDeleteBuffers(real_n, objid_array);
482 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
484 for (i = 0; i < real_n; i++)
486 if (current_ctx->gl_array_buffer_binding[0] == objid_array[i])
488 current_ctx->_bind_flag &= (~FLAG_BIT_0);
489 current_ctx->gl_array_buffer_binding[0] = 0;
491 if (current_ctx->gl_element_array_buffer_binding[0] == objid_array[i])
493 current_ctx->_bind_flag &= (~FLAG_BIT_1);
494 current_ctx->gl_element_array_buffer_binding[0] = 0;
502 if (objid_array != NULL)
507 _COREGL_FAST_FUNC_END();
510 //////////////////////////////////////////////////////////////////////////////////
513 fpgl_glGenFramebuffers(GLsizei n, GLuint* framebuffers)
516 GLuint *objid_array = NULL;
518 DEFINE_FAST_GL_FUNC();
519 _COREGL_FAST_FUNC_BEGIN();
522 if (framebuffers == NULL) goto finish;
524 AST(current_ctx->sostate != NULL);
526 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
528 _sym_glGenFramebuffers(n, objid_array);
530 for (i = 0; i < n; i++)
532 framebuffers[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, objid_array[i]);
538 if (objid_array != NULL)
543 _COREGL_FAST_FUNC_END();
548 fpgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
552 DEFINE_FAST_GL_FUNC();
553 _COREGL_FAST_FUNC_BEGIN();
556 if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1)
558 _set_gl_error(GL_OUT_OF_MEMORY);
562 if (target == GL_FRAMEBUFFER)
564 CURR_STATE_COMPARE(gl_framebuffer_binding, real_obj)
566 _sym_glBindFramebuffer(target, real_obj);
567 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
570 current_ctx->_bind_flag &= (~FLAG_BIT_2);
572 current_ctx->_bind_flag |= FLAG_BIT_2;
573 current_ctx->gl_framebuffer_binding[0] = real_obj;
578 // For error recording
579 _sym_glBindFramebuffer(target, real_obj);
580 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
586 _COREGL_FAST_FUNC_END();
590 fpgl_glIsFramebuffer(GLuint framebuffer)
595 DEFINE_FAST_GL_FUNC();
596 _COREGL_FAST_FUNC_BEGIN();
599 if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1)
605 ret = _sym_glIsFramebuffer(real_obj);
607 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
612 _COREGL_FAST_FUNC_END();
618 fpgl_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
621 GLuint *objid_array = NULL;
623 DEFINE_FAST_GL_FUNC();
624 _COREGL_FAST_FUNC_BEGIN();
627 if (framebuffers == NULL) goto finish;
629 AST(current_ctx->sostate != NULL);
631 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
635 for (i = 0; i < n; i++)
637 int real_objid = _COREGL_INT_INIT_VALUE;
638 if (framebuffers[i] == 0) continue;
640 real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]);
641 if (real_objid == 0) continue;
643 sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]);
644 objid_array[real_n++] = real_objid;
647 _sym_glDeleteFramebuffers(real_n, objid_array);
648 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
650 for (i = 0; i < real_n; i++)
652 if (current_ctx->gl_framebuffer_binding[0] == framebuffers[i])
654 current_ctx->_bind_flag &= (~FLAG_BIT_2);
655 current_ctx->gl_framebuffer_binding[0] = 0;
663 if (objid_array != NULL)
668 _COREGL_FAST_FUNC_END();
671 //////////////////////////////////////////////////////////////////////////////////
674 fpgl_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
677 GLuint *objid_array = NULL;
679 DEFINE_FAST_GL_FUNC();
680 _COREGL_FAST_FUNC_BEGIN();
683 if (renderbuffers == NULL) goto finish;
685 AST(current_ctx->sostate != NULL);
687 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
689 _sym_glGenRenderbuffers(n, objid_array);
691 for (i = 0; i < n; i++)
693 renderbuffers[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, objid_array[i]);
699 if (objid_array != NULL)
704 _COREGL_FAST_FUNC_END();
709 fpgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
713 DEFINE_FAST_GL_FUNC();
714 _COREGL_FAST_FUNC_BEGIN();
717 if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1)
719 _set_gl_error(GL_OUT_OF_MEMORY);
723 if (target == GL_RENDERBUFFER)
725 CURR_STATE_COMPARE(gl_renderbuffer_binding, real_obj)
727 _sym_glBindRenderbuffer(target, real_obj);
728 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
731 current_ctx->_bind_flag &= (~FLAG_BIT_3);
733 current_ctx->_bind_flag |= FLAG_BIT_3;
734 current_ctx->gl_renderbuffer_binding[0] = real_obj;
739 // For error recording
740 _sym_glBindRenderbuffer(target, real_obj);
741 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
746 _COREGL_FAST_FUNC_END();
750 fpgl_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
754 DEFINE_FAST_GL_FUNC();
755 _COREGL_FAST_FUNC_BEGIN();
758 if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1)
760 _set_gl_error(GL_OUT_OF_MEMORY);
764 _sym_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, real_obj);
766 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
771 _COREGL_FAST_FUNC_END();
775 fpgl_glIsRenderbuffer(GLuint renderbuffer)
780 DEFINE_FAST_GL_FUNC();
781 _COREGL_FAST_FUNC_BEGIN();
784 if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1)
790 ret = _sym_glIsRenderbuffer(real_obj);
792 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
797 _COREGL_FAST_FUNC_END();
803 fpgl_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
806 GLuint *objid_array = NULL;
808 DEFINE_FAST_GL_FUNC();
809 _COREGL_FAST_FUNC_BEGIN();
812 if (renderbuffers == NULL) goto finish;
814 AST(current_ctx->sostate != NULL);
816 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
820 for (i = 0; i < n; i++)
822 int real_objid = _COREGL_INT_INIT_VALUE;
823 if (renderbuffers[i] == 0) continue;
825 real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]);
826 if (real_objid == 0) continue;
828 sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]);
829 objid_array[real_n++] = real_objid;
832 _sym_glDeleteRenderbuffers(real_n, objid_array);
833 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
835 for (i = 0; i < real_n; i++)
837 if (current_ctx->gl_renderbuffer_binding[0] == renderbuffers[i])
839 current_ctx->_bind_flag &= (~FLAG_BIT_3);
840 current_ctx->gl_renderbuffer_binding[0] = 0;
848 if (objid_array != NULL)
853 _COREGL_FAST_FUNC_END();
856 //////////////////////////////////////////////////////////////////////////////////
859 fpgl_glCreateProgram(void)
861 GLuint ret = _COREGL_INT_INIT_VALUE;
862 GLuint real_obj = _COREGL_INT_INIT_VALUE;
864 DEFINE_FAST_GL_FUNC();
865 _COREGL_FAST_FUNC_BEGIN();
868 AST(current_ctx->sostate != NULL);
870 real_obj = _sym_glCreateProgram();
871 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
873 ret = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, real_obj);
878 _COREGL_FAST_FUNC_END();
883 fpgl_glCreateShader(GLenum type)
885 GLuint ret = _COREGL_INT_INIT_VALUE;
886 GLuint real_obj = _COREGL_INT_INIT_VALUE;
888 DEFINE_FAST_GL_FUNC();
889 _COREGL_FAST_FUNC_BEGIN();
892 AST(current_ctx->sostate != NULL);
894 real_obj = _sym_glCreateShader(type);
895 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
897 ret = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, real_obj);
902 _COREGL_FAST_FUNC_END();
907 fpgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
911 DEFINE_FAST_GL_FUNC();
912 _COREGL_FAST_FUNC_BEGIN();
915 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
917 _set_gl_error(GL_INVALID_VALUE);
920 _sym_glShaderSource(real_obj, count, string, length);
921 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
925 _COREGL_FAST_FUNC_END();
929 fpgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
932 GLuint *objid_array = NULL;
934 DEFINE_FAST_GL_FUNC();
935 _COREGL_FAST_FUNC_BEGIN();
938 if (shaders == NULL) goto finish;
940 AST(current_ctx->sostate != NULL);
942 objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
944 for (i = 0; i < n; i++)
946 if (shaders[i] == 0) continue;
947 objid_array[i] = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shaders[i]);
950 #ifndef _COREGL_DESKTOP_GL
951 _sym_glShaderBinary(n, objid_array, binaryformat, binary, length);
952 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
954 // FIXME: need to dlsym/getprocaddress for this
956 n = binaryformat = length = 0;
957 shaders = binary = 0;
963 if (objid_array != NULL)
969 _COREGL_FAST_FUNC_END();
973 fpgl_glCompileShader(GLuint shader)
977 DEFINE_FAST_GL_FUNC();
978 _COREGL_FAST_FUNC_BEGIN();
981 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
983 _set_gl_error(GL_INVALID_VALUE);
987 _sym_glCompileShader(real_obj);
988 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
992 _COREGL_FAST_FUNC_END();
996 fpgl_glBindAttribLocation(GLuint program, GLuint index, const char* name)
1000 DEFINE_FAST_GL_FUNC();
1001 _COREGL_FAST_FUNC_BEGIN();
1002 INIT_FAST_GL_FUNC();
1004 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1006 _set_gl_error(GL_INVALID_VALUE);
1010 _sym_glBindAttribLocation(real_obj, index, name);
1011 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1015 _COREGL_FAST_FUNC_END();
1019 fpgl_glAttachShader(GLuint program, GLuint shader)
1021 GLuint real_obj_program;
1022 GLuint real_obj_shader;
1024 DEFINE_FAST_GL_FUNC();
1025 _COREGL_FAST_FUNC_BEGIN();
1026 INIT_FAST_GL_FUNC();
1028 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj_program) != 1 ||
1029 GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj_shader) != 1)
1031 _set_gl_error(GL_INVALID_VALUE);
1035 _sym_glAttachShader(real_obj_program, real_obj_shader);
1036 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1040 _COREGL_FAST_FUNC_END();
1044 fpgl_glDetachShader(GLuint program, GLuint shader)
1046 GLuint real_obj_program;
1047 GLuint real_obj_shader;
1049 DEFINE_FAST_GL_FUNC();
1050 _COREGL_FAST_FUNC_BEGIN();
1051 INIT_FAST_GL_FUNC();
1053 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj_program) != 1 ||
1054 GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj_shader) != 1)
1056 _set_gl_error(GL_INVALID_VALUE);
1060 _sym_glDetachShader(real_obj_program, real_obj_shader);
1061 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1065 _COREGL_FAST_FUNC_END();
1069 fpgl_glIsShader(GLuint shader)
1074 DEFINE_FAST_GL_FUNC();
1075 _COREGL_FAST_FUNC_BEGIN();
1076 INIT_FAST_GL_FUNC();
1078 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1084 ret = _sym_glIsShader(real_obj);
1085 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1089 _COREGL_FAST_FUNC_END();
1094 fpgl_glIsProgram(GLuint program)
1099 DEFINE_FAST_GL_FUNC();
1100 _COREGL_FAST_FUNC_BEGIN();
1101 INIT_FAST_GL_FUNC();
1103 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1109 ret = _sym_glIsProgram(real_obj);
1110 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1114 _COREGL_FAST_FUNC_END();
1119 fpgl_glLinkProgram(GLuint program)
1123 DEFINE_FAST_GL_FUNC();
1124 _COREGL_FAST_FUNC_BEGIN();
1125 INIT_FAST_GL_FUNC();
1127 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1129 _set_gl_error(GL_INVALID_VALUE);
1133 _sym_glLinkProgram(real_obj);
1134 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1138 _COREGL_FAST_FUNC_END();
1142 fpgl_glValidateProgram(GLuint program)
1146 DEFINE_FAST_GL_FUNC();
1147 _COREGL_FAST_FUNC_BEGIN();
1148 INIT_FAST_GL_FUNC();
1150 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1152 _set_gl_error(GL_INVALID_VALUE);
1156 _sym_glValidateProgram(real_obj);
1157 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1161 _COREGL_FAST_FUNC_END();
1165 fpgl_glUseProgram(GLuint program)
1169 DEFINE_FAST_GL_FUNC();
1170 _COREGL_FAST_FUNC_BEGIN();
1171 INIT_FAST_GL_FUNC();
1173 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1175 _set_gl_error(GL_INVALID_VALUE);
1179 CURR_STATE_COMPARE(gl_current_program, real_obj)
1181 _sym_glUseProgram(real_obj);
1183 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1185 current_ctx->_clear_flag1 |= FLAG_BIT_1;
1186 current_ctx->gl_current_program[0] = real_obj;
1191 _COREGL_FAST_FUNC_END();
1195 fpgl_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
1199 DEFINE_FAST_GL_FUNC();
1200 _COREGL_FAST_FUNC_BEGIN();
1201 INIT_FAST_GL_FUNC();
1203 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1205 _set_gl_error(GL_INVALID_VALUE);
1209 _sym_glGetActiveAttrib(real_obj, index, bufsize, length, size, type, name);
1210 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1214 _COREGL_FAST_FUNC_END();
1218 fpgl_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
1222 DEFINE_FAST_GL_FUNC();
1223 _COREGL_FAST_FUNC_BEGIN();
1224 INIT_FAST_GL_FUNC();
1226 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1228 _set_gl_error(GL_INVALID_VALUE);
1232 _sym_glGetActiveUniform(real_obj, index, bufsize, length, size, type, name);
1233 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1237 _COREGL_FAST_FUNC_END();
1241 fpgl_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
1244 GLsizei real_count = _COREGL_INT_INIT_VALUE;
1247 DEFINE_FAST_GL_FUNC();
1248 _COREGL_FAST_FUNC_BEGIN();
1249 INIT_FAST_GL_FUNC();
1251 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1253 _set_gl_error(GL_INVALID_VALUE);
1257 _sym_glGetAttachedShaders(real_obj, maxcount, &real_count, shaders);
1259 for (i = 0; i < real_count; i++)
1261 if (shaders[i] != 0)
1262 shaders[i] = sostate_find_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shaders[i]);
1264 if (count != NULL) *count = real_count;
1266 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1270 _COREGL_FAST_FUNC_END();
1274 fpgl_glGetAttribLocation(GLuint program, const char* name)
1276 int ret = _COREGL_INT_INIT_VALUE;
1279 DEFINE_FAST_GL_FUNC();
1280 _COREGL_FAST_FUNC_BEGIN();
1281 INIT_FAST_GL_FUNC();
1283 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1285 _set_gl_error(GL_INVALID_VALUE);
1289 ret = _sym_glGetAttribLocation(real_obj, name);
1290 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1294 _COREGL_FAST_FUNC_END();
1299 fpgl_glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
1303 DEFINE_FAST_GL_FUNC();
1304 _COREGL_FAST_FUNC_BEGIN();
1305 INIT_FAST_GL_FUNC();
1307 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1309 _set_gl_error(GL_INVALID_VALUE);
1313 _sym_glGetShaderiv(real_obj, pname, params);
1314 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1318 _COREGL_FAST_FUNC_END();
1322 fpgl_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
1326 DEFINE_FAST_GL_FUNC();
1327 _COREGL_FAST_FUNC_BEGIN();
1328 INIT_FAST_GL_FUNC();
1330 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1332 _set_gl_error(GL_INVALID_VALUE);
1336 _sym_glGetShaderInfoLog(real_obj, bufsize, length, infolog);
1337 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1341 _COREGL_FAST_FUNC_END();
1345 fpgl_glGetProgramiv(GLuint program, GLenum pname, GLint* params)
1349 DEFINE_FAST_GL_FUNC();
1350 _COREGL_FAST_FUNC_BEGIN();
1351 INIT_FAST_GL_FUNC();
1353 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1355 _set_gl_error(GL_INVALID_VALUE);
1359 _sym_glGetProgramiv(real_obj, pname, params);
1360 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1364 _COREGL_FAST_FUNC_END();
1368 fpgl_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
1372 DEFINE_FAST_GL_FUNC();
1373 _COREGL_FAST_FUNC_BEGIN();
1374 INIT_FAST_GL_FUNC();
1376 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1378 _set_gl_error(GL_INVALID_VALUE);
1382 _sym_glGetProgramInfoLog(real_obj, bufsize, length, infolog);
1383 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1387 _COREGL_FAST_FUNC_END();
1391 fpgl_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
1395 DEFINE_FAST_GL_FUNC();
1396 _COREGL_FAST_FUNC_BEGIN();
1397 INIT_FAST_GL_FUNC();
1399 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1401 _set_gl_error(GL_INVALID_VALUE);
1405 _sym_glGetShaderSource(real_obj, bufsize, length, source);
1406 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1410 _COREGL_FAST_FUNC_END();
1414 fpgl_glGetUniformfv(GLuint program, GLint location, GLfloat* params)
1418 DEFINE_FAST_GL_FUNC();
1419 _COREGL_FAST_FUNC_BEGIN();
1420 INIT_FAST_GL_FUNC();
1422 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1424 _set_gl_error(GL_INVALID_VALUE);
1428 _sym_glGetUniformfv(real_obj, location, params);
1429 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1433 _COREGL_FAST_FUNC_END();
1437 fpgl_glGetUniformiv(GLuint program, GLint location, GLint* params)
1441 DEFINE_FAST_GL_FUNC();
1442 _COREGL_FAST_FUNC_BEGIN();
1443 INIT_FAST_GL_FUNC();
1445 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1447 _set_gl_error(GL_INVALID_VALUE);
1451 _sym_glGetUniformiv(real_obj, location, params);
1452 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1456 _COREGL_FAST_FUNC_END();
1460 fpgl_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum* binaryFormat, void* binary)
1464 DEFINE_FAST_GL_FUNC();
1465 _COREGL_FAST_FUNC_BEGIN();
1466 INIT_FAST_GL_FUNC();
1468 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1470 _set_gl_error(GL_INVALID_VALUE);
1474 _sym_glGetProgramBinary(real_obj, bufsize, length, binaryFormat, binary);
1475 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1479 _COREGL_FAST_FUNC_END();
1483 fpgl_glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GLint length)
1487 DEFINE_FAST_GL_FUNC();
1488 _COREGL_FAST_FUNC_BEGIN();
1489 INIT_FAST_GL_FUNC();
1491 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1493 _set_gl_error(GL_INVALID_VALUE);
1497 _sym_glProgramBinary(real_obj, binaryFormat, binary, length);
1498 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1502 _COREGL_FAST_FUNC_END();
1507 fpgl_glProgramParameteri(GLuint program, GLuint pname, GLint value)
1511 DEFINE_FAST_GL_FUNC();
1512 _COREGL_FAST_FUNC_BEGIN();
1513 INIT_FAST_GL_FUNC();
1515 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1517 _set_gl_error(GL_INVALID_VALUE);
1521 _sym_glProgramParameteri(real_obj, pname, value);
1522 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1526 _COREGL_FAST_FUNC_END();
1530 fpgl_glGetUniformLocation(GLuint program, const char* name)
1532 int ret = _COREGL_INT_INIT_VALUE;
1535 DEFINE_FAST_GL_FUNC();
1536 _COREGL_FAST_FUNC_BEGIN();
1537 INIT_FAST_GL_FUNC();
1539 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1541 _set_gl_error(GL_INVALID_VALUE);
1546 ret = _sym_glGetUniformLocation(real_obj, name);
1547 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1551 _COREGL_FAST_FUNC_END();
1556 fpgl_glDeleteShader(GLuint shader)
1560 DEFINE_FAST_GL_FUNC();
1561 _COREGL_FAST_FUNC_BEGIN();
1562 INIT_FAST_GL_FUNC();
1564 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1)
1566 _set_gl_error(GL_INVALID_VALUE);
1570 _sym_glDeleteShader(real_obj);
1573 AST(sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shader) == 1);
1576 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1580 _COREGL_FAST_FUNC_END();
1584 fpgl_glDeleteProgram(GLuint program)
1588 DEFINE_FAST_GL_FUNC();
1589 _COREGL_FAST_FUNC_BEGIN();
1590 INIT_FAST_GL_FUNC();
1592 if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1)
1594 _set_gl_error(GL_INVALID_VALUE);
1598 _sym_glDeleteProgram(real_obj);
1601 AST(sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, program) == 1);
1604 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1608 _COREGL_FAST_FUNC_END();
1613 //////////////////////////////////////////////////////////////////////////////////
1616 fpgl_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1618 DEFINE_FAST_GL_FUNC();
1619 _COREGL_FAST_FUNC_BEGIN();
1620 INIT_FAST_GL_FUNC();
1622 if ((current_ctx->gl_blend_color[0] != red) ||
1623 (current_ctx->gl_blend_color[1] != green) ||
1624 (current_ctx->gl_blend_color[2] != blue) ||
1625 (current_ctx->gl_blend_color[3] != alpha))
1627 _sym_glBlendColor(red, green, blue, alpha);
1629 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1631 current_ctx->_blend_flag |= FLAG_BIT_0;
1632 current_ctx->gl_blend_color[0] = red;
1633 current_ctx->gl_blend_color[1] = green;
1634 current_ctx->gl_blend_color[2] = blue;
1635 current_ctx->gl_blend_color[3] = alpha;
1640 _COREGL_FAST_FUNC_END();
1646 fpgl_glBlendEquation(GLenum mode)
1648 DEFINE_FAST_GL_FUNC();
1649 _COREGL_FAST_FUNC_BEGIN();
1650 INIT_FAST_GL_FUNC();
1652 _sym_glBlendEquation(mode);
1654 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1656 current_ctx->_blend_flag |= (FLAG_BIT_5 | FLAG_BIT_6);
1657 _sym_glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*) & (current_ctx->gl_blend_equation_rgb));
1658 _sym_glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*) & (current_ctx->gl_blend_equation_alpha));
1662 _COREGL_FAST_FUNC_END();
1667 fpgl_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
1669 DEFINE_FAST_GL_FUNC();
1670 _COREGL_FAST_FUNC_BEGIN();
1671 INIT_FAST_GL_FUNC();
1673 if ((current_ctx->gl_blend_equation_rgb[0] != modeRGB) ||
1674 (current_ctx->gl_blend_equation_alpha[0] != modeAlpha))
1676 _sym_glBlendEquationSeparate(modeRGB, modeAlpha);
1678 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1680 current_ctx->_blend_flag |= (FLAG_BIT_5 | FLAG_BIT_6);
1681 current_ctx->gl_blend_equation_rgb[0] = modeRGB;
1682 current_ctx->gl_blend_equation_alpha[0] = modeAlpha;
1687 _COREGL_FAST_FUNC_END();
1693 fpgl_glBlendFunc(GLenum sfactor, GLenum dfactor)
1695 DEFINE_FAST_GL_FUNC();
1696 _COREGL_FAST_FUNC_BEGIN();
1697 INIT_FAST_GL_FUNC();
1699 _sym_glBlendFunc(sfactor, dfactor);
1701 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1703 current_ctx->_blend_flag |= (FLAG_BIT_1 | FLAG_BIT_2 | FLAG_BIT_3 | FLAG_BIT_4);
1704 _sym_glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*) & (current_ctx->gl_blend_src_rgb));
1705 _sym_glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*) & (current_ctx->gl_blend_src_alpha));
1706 _sym_glGetIntegerv(GL_BLEND_DST_RGB, (GLint*) & (current_ctx->gl_blend_dst_rgb));
1707 _sym_glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*) & (current_ctx->gl_blend_dst_alpha));
1711 _COREGL_FAST_FUNC_END();
1716 fpgl_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
1718 DEFINE_FAST_GL_FUNC();
1719 _COREGL_FAST_FUNC_BEGIN();
1720 INIT_FAST_GL_FUNC();
1722 if ((current_ctx->gl_blend_src_rgb[0] != srcRGB) ||
1723 (current_ctx->gl_blend_dst_rgb[0] != dstRGB) ||
1724 (current_ctx->gl_blend_src_alpha[0] != srcAlpha) ||
1725 (current_ctx->gl_blend_dst_alpha[0] != dstAlpha))
1727 _sym_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
1729 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1731 current_ctx->_blend_flag |= (FLAG_BIT_1 | FLAG_BIT_2 | FLAG_BIT_3 | FLAG_BIT_4);
1732 current_ctx->gl_blend_src_rgb[0] = srcRGB;
1733 current_ctx->gl_blend_dst_rgb[0] = dstRGB;
1734 current_ctx->gl_blend_src_alpha[0] = srcAlpha;
1735 current_ctx->gl_blend_dst_alpha[0] = dstAlpha;
1740 _COREGL_FAST_FUNC_END();
1745 fpgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1747 DEFINE_FAST_GL_FUNC();
1748 _COREGL_FAST_FUNC_BEGIN();
1749 INIT_FAST_GL_FUNC();
1751 if ((current_ctx->gl_color_clear_value[0] != red) ||
1752 (current_ctx->gl_color_clear_value[1] != green) ||
1753 (current_ctx->gl_color_clear_value[2] != blue) ||
1754 (current_ctx->gl_color_clear_value[3] != alpha))
1756 _sym_glClearColor(red, green, blue, alpha);
1758 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1760 current_ctx->_clear_flag1 |= (FLAG_BIT_2);
1761 current_ctx->gl_color_clear_value[0] = red;
1762 current_ctx->gl_color_clear_value[1] = green;
1763 current_ctx->gl_color_clear_value[2] = blue;
1764 current_ctx->gl_color_clear_value[3] = alpha;
1769 _COREGL_FAST_FUNC_END();
1774 fpgl_glClearDepthf(GLclampf depth)
1776 DEFINE_FAST_GL_FUNC();
1777 _COREGL_FAST_FUNC_BEGIN();
1778 INIT_FAST_GL_FUNC();
1780 CURR_STATE_COMPARE(gl_depth_clear_value, depth)
1782 _sym_glClearDepthf(depth);
1784 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1786 current_ctx->_clear_flag2 |= FLAG_BIT_2;
1787 current_ctx->gl_depth_clear_value[0] = depth;
1792 _COREGL_FAST_FUNC_END();
1797 fpgl_glClearStencil(GLint s)
1799 DEFINE_FAST_GL_FUNC();
1800 _COREGL_FAST_FUNC_BEGIN();
1801 INIT_FAST_GL_FUNC();
1803 CURR_STATE_COMPARE(gl_stencil_clear_value, s)
1805 _sym_glClearStencil(s);
1807 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1809 current_ctx->_stencil_flag2 |= FLAG_BIT_7;
1810 current_ctx->gl_stencil_clear_value[0] = s;
1815 _COREGL_FAST_FUNC_END();
1820 fpgl_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
1822 DEFINE_FAST_GL_FUNC();
1823 _COREGL_FAST_FUNC_BEGIN();
1824 INIT_FAST_GL_FUNC();
1826 if ((current_ctx->gl_color_writemask[0] != red) ||
1827 (current_ctx->gl_color_writemask[1] != green) ||
1828 (current_ctx->gl_color_writemask[2] != blue) ||
1829 (current_ctx->gl_color_writemask[3] != alpha))
1831 _sym_glColorMask(red, green, blue, alpha);
1833 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1835 current_ctx->_clear_flag2 |= FLAG_BIT_0;
1836 current_ctx->gl_color_writemask[0] = red;
1837 current_ctx->gl_color_writemask[1] = green;
1838 current_ctx->gl_color_writemask[2] = blue;
1839 current_ctx->gl_color_writemask[3] = alpha;
1844 _COREGL_FAST_FUNC_END();
1849 fpgl_glCullFace(GLenum mode)
1851 DEFINE_FAST_GL_FUNC();
1852 _COREGL_FAST_FUNC_BEGIN();
1853 INIT_FAST_GL_FUNC();
1855 CURR_STATE_COMPARE(gl_cull_face_mode, mode)
1857 _sym_glCullFace(mode);
1859 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1861 current_ctx->_clear_flag2 |= FLAG_BIT_5;
1862 current_ctx->gl_cull_face_mode[0] = mode;
1867 _COREGL_FAST_FUNC_END();
1872 fpgl_glDepthFunc(GLenum func)
1874 DEFINE_FAST_GL_FUNC();
1875 _COREGL_FAST_FUNC_BEGIN();
1876 INIT_FAST_GL_FUNC();
1878 CURR_STATE_COMPARE(gl_depth_func, func)
1880 _sym_glDepthFunc(func);
1882 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1884 current_ctx->_clear_flag2 |= FLAG_BIT_3;
1885 current_ctx->gl_depth_func[0] = func;
1890 _COREGL_FAST_FUNC_END();
1895 fpgl_glDepthMask(GLboolean flag)
1897 DEFINE_FAST_GL_FUNC();
1898 _COREGL_FAST_FUNC_BEGIN();
1899 INIT_FAST_GL_FUNC();
1901 CURR_STATE_COMPARE(gl_depth_writemask, flag)
1903 _sym_glDepthMask(flag);
1905 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1907 current_ctx->_clear_flag2 |= FLAG_BIT_4;
1908 current_ctx->gl_depth_writemask[0] = flag;
1913 _COREGL_FAST_FUNC_END();
1918 fpgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
1920 DEFINE_FAST_GL_FUNC();
1921 _COREGL_FAST_FUNC_BEGIN();
1922 INIT_FAST_GL_FUNC();
1924 if ((current_ctx->gl_depth_range[0] != zNear) ||
1925 (current_ctx->gl_depth_range[1] != zFar))
1927 _sym_glDepthRangef(zNear, zFar);
1929 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1931 current_ctx->_clear_flag2 |= FLAG_BIT_1;
1932 current_ctx->gl_depth_range[0] = zNear;
1933 current_ctx->gl_depth_range[1] = zFar;
1938 _COREGL_FAST_FUNC_END();
1943 fpgl_glDisable(GLenum cap)
1945 DEFINE_FAST_GL_FUNC();
1946 _COREGL_FAST_FUNC_BEGIN();
1947 INIT_FAST_GL_FUNC();
1952 CURR_STATE_COMPARE(gl_blend, GL_FALSE)
1954 _sym_glDisable(cap);
1955 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1956 current_ctx->_enable_flag1 &= (~FLAG_BIT_0);
1957 current_ctx->gl_blend[0] = GL_FALSE;
1961 CURR_STATE_COMPARE(gl_cull_face, GL_FALSE)
1963 _sym_glDisable(cap);
1964 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1965 current_ctx->_enable_flag1 &= (~FLAG_BIT_1);
1966 current_ctx->gl_cull_face[0] = GL_FALSE;
1970 CURR_STATE_COMPARE(gl_depth_test, GL_FALSE)
1972 _sym_glDisable(cap);
1973 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1974 current_ctx->_enable_flag1 &= (~FLAG_BIT_2);
1975 current_ctx->gl_depth_test[0] = GL_FALSE;
1979 CURR_STATE_COMPARE(gl_dither, GL_FALSE)
1981 _sym_glDisable(cap);
1982 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1983 current_ctx->_enable_flag1 &= (~FLAG_BIT_3);
1984 current_ctx->gl_dither[0] = GL_FALSE;
1987 case GL_POLYGON_OFFSET_FILL:
1988 CURR_STATE_COMPARE(gl_polygon_offset_fill, GL_FALSE)
1990 _sym_glDisable(cap);
1991 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1992 current_ctx->_enable_flag2 &= (~FLAG_BIT_0);
1993 current_ctx->gl_polygon_offset_fill[0] = GL_FALSE;
1996 case GL_SAMPLE_ALPHA_TO_COVERAGE:
1997 CURR_STATE_COMPARE(gl_sample_alpha_to_coverage, GL_FALSE)
1999 _sym_glDisable(cap);
2000 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2001 current_ctx->_enable_flag2 &= (~FLAG_BIT_1);
2002 current_ctx->gl_sample_alpha_to_coverage[0] = GL_FALSE;
2005 case GL_SAMPLE_COVERAGE:
2006 CURR_STATE_COMPARE(gl_sample_coverage, GL_FALSE)
2008 _sym_glDisable(cap);
2009 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2010 current_ctx->_enable_flag2 &= (~FLAG_BIT_2);
2011 current_ctx->gl_sample_coverage[0] = GL_FALSE;
2014 case GL_SCISSOR_TEST:
2015 CURR_STATE_COMPARE(gl_scissor_test, GL_FALSE)
2017 _sym_glDisable(cap);
2018 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2019 current_ctx->_enable_flag2 &= (~FLAG_BIT_3);
2020 current_ctx->gl_scissor_test[0] = GL_FALSE;
2023 case GL_STENCIL_TEST:
2024 CURR_STATE_COMPARE(gl_stencil_test, GL_FALSE)
2026 _sym_glDisable(cap);
2027 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2028 current_ctx->_enable_flag2 &= (~FLAG_BIT_4);
2029 current_ctx->gl_stencil_test[0] = GL_FALSE;
2036 _COREGL_FAST_FUNC_END();
2041 fpgl_glDisableVertexAttribArray(GLuint index)
2043 DEFINE_FAST_GL_FUNC();
2044 _COREGL_FAST_FUNC_BEGIN();
2045 INIT_FAST_GL_FUNC();
2047 _sym_glDisableVertexAttribArray(index);
2049 current_ctx->_vattrib_flag |= FLAG_BIT_1;
2050 current_ctx->gl_vertex_array_enabled[index] = GL_FALSE;
2055 _COREGL_FAST_FUNC_END();
2060 fpgl_glDrawArrays(GLenum mode, GLint first, GLsizei count)
2062 DEFINE_FAST_GL_FUNC();
2063 _COREGL_FAST_FUNC_BEGIN();
2064 INIT_FAST_GL_FUNC();
2066 _sym_glDrawArrays(mode, first, count);
2070 _COREGL_FAST_FUNC_END();
2075 fpgl_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
2077 DEFINE_FAST_GL_FUNC();
2078 _COREGL_FAST_FUNC_BEGIN();
2079 INIT_FAST_GL_FUNC();
2081 _sym_glDrawElements(mode, count, type, indices);
2085 _COREGL_FAST_FUNC_END();
2090 fpgl_glEnable(GLenum cap)
2092 DEFINE_FAST_GL_FUNC();
2093 _COREGL_FAST_FUNC_BEGIN();
2094 INIT_FAST_GL_FUNC();
2099 CURR_STATE_COMPARE(gl_blend, GL_TRUE)
2102 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2104 current_ctx->_enable_flag1 |= FLAG_BIT_0;
2105 current_ctx->gl_blend[0] = GL_TRUE;
2109 CURR_STATE_COMPARE(gl_cull_face, GL_TRUE)
2112 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2115 current_ctx->_enable_flag1 |= FLAG_BIT_1;
2116 current_ctx->gl_cull_face[0] = GL_TRUE;
2120 CURR_STATE_COMPARE(gl_depth_test, GL_TRUE)
2123 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2126 current_ctx->_enable_flag1 |= FLAG_BIT_2;
2127 current_ctx->gl_depth_test[0] = GL_TRUE;
2131 CURR_STATE_COMPARE(gl_dither, GL_TRUE)
2134 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2137 current_ctx->_enable_flag1 |= FLAG_BIT_3;
2138 current_ctx->gl_dither[0] = GL_TRUE;
2141 case GL_POLYGON_OFFSET_FILL:
2142 CURR_STATE_COMPARE(gl_polygon_offset_fill, GL_TRUE)
2145 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2148 current_ctx->_enable_flag2 |= FLAG_BIT_0;
2149 current_ctx->gl_polygon_offset_fill[0] = GL_TRUE;
2152 case GL_SAMPLE_ALPHA_TO_COVERAGE:
2153 CURR_STATE_COMPARE(gl_sample_alpha_to_coverage, GL_TRUE)
2156 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2159 current_ctx->_enable_flag2 |= FLAG_BIT_1;
2160 current_ctx->gl_sample_alpha_to_coverage[0] = GL_TRUE;
2163 case GL_SAMPLE_COVERAGE:
2164 CURR_STATE_COMPARE(gl_sample_coverage, GL_TRUE)
2167 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2170 current_ctx->_enable_flag2 |= FLAG_BIT_2;
2171 current_ctx->gl_sample_coverage[0] = GL_TRUE;
2174 case GL_SCISSOR_TEST:
2175 CURR_STATE_COMPARE(gl_scissor_test, GL_TRUE)
2178 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2181 current_ctx->_enable_flag2 |= FLAG_BIT_3;
2182 current_ctx->gl_scissor_test[0] = GL_TRUE;
2185 case GL_STENCIL_TEST:
2186 CURR_STATE_COMPARE(gl_stencil_test, GL_TRUE)
2189 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2192 current_ctx->_enable_flag2 |= FLAG_BIT_4;
2193 current_ctx->gl_stencil_test[0] = GL_TRUE;
2200 _COREGL_FAST_FUNC_END();
2206 fpgl_glEnableVertexAttribArray(GLuint index)
2208 DEFINE_FAST_GL_FUNC();
2209 _COREGL_FAST_FUNC_BEGIN();
2210 INIT_FAST_GL_FUNC();
2212 _sym_glEnableVertexAttribArray(index);
2214 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2216 current_ctx->_vattrib_flag |= FLAG_BIT_1;
2217 current_ctx->gl_vertex_array_enabled[index] = GL_TRUE;
2222 _COREGL_FAST_FUNC_END();
2227 fpgl_glFrontFace(GLenum mode)
2229 DEFINE_FAST_GL_FUNC();
2230 _COREGL_FAST_FUNC_BEGIN();
2231 INIT_FAST_GL_FUNC();
2233 CURR_STATE_COMPARE(gl_front_face, mode)
2235 _sym_glFrontFace(mode);
2237 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2239 current_ctx->_misc_flag1 |= FLAG_BIT_0;
2240 current_ctx->gl_front_face[0] = mode;
2245 _COREGL_FAST_FUNC_END();
2250 fpgl_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
2252 DEFINE_FAST_GL_FUNC();
2253 _COREGL_FAST_FUNC_BEGIN();
2254 INIT_FAST_GL_FUNC();
2256 _sym_glGetVertexAttribfv(index, pname, params);
2258 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2262 _COREGL_FAST_FUNC_END();
2267 fpgl_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
2269 DEFINE_FAST_GL_FUNC();
2270 _COREGL_FAST_FUNC_BEGIN();
2271 INIT_FAST_GL_FUNC();
2273 _sym_glGetVertexAttribiv(index, pname, params);
2275 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2279 _COREGL_FAST_FUNC_END();
2284 fpgl_glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
2286 DEFINE_FAST_GL_FUNC();
2287 _COREGL_FAST_FUNC_BEGIN();
2288 INIT_FAST_GL_FUNC();
2290 _sym_glGetVertexAttribPointerv(index, pname, pointer);
2292 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2297 _COREGL_FAST_FUNC_END();
2302 fpgl_glHint(GLenum target, GLenum mode)
2304 DEFINE_FAST_GL_FUNC();
2305 _COREGL_FAST_FUNC_BEGIN();
2306 INIT_FAST_GL_FUNC();
2308 if (target == GL_GENERATE_MIPMAP_HINT)
2310 CURR_STATE_COMPARE(gl_generate_mipmap_hint, mode)
2312 _sym_glHint(target, mode);
2314 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2316 current_ctx->_tex_flag1 |= FLAG_BIT_2;
2317 current_ctx->gl_generate_mipmap_hint[0] = mode;
2322 // For GL Error to be picked up
2323 _sym_glHint(target, mode);
2324 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2329 _COREGL_FAST_FUNC_END();
2334 fpgl_glLineWidth(GLfloat width)
2336 DEFINE_FAST_GL_FUNC();
2337 _COREGL_FAST_FUNC_BEGIN();
2338 INIT_FAST_GL_FUNC();
2340 CURR_STATE_COMPARE(gl_line_width, width)
2342 _sym_glLineWidth(width);
2344 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2346 current_ctx->_misc_flag1 |= FLAG_BIT_1;
2347 current_ctx->gl_line_width[0] = width;
2352 _COREGL_FAST_FUNC_END();
2357 fpgl_glPixelStorei(GLenum pname, GLint param)
2359 DEFINE_FAST_GL_FUNC();
2360 _COREGL_FAST_FUNC_BEGIN();
2361 INIT_FAST_GL_FUNC();
2363 if (pname == GL_PACK_ALIGNMENT)
2365 CURR_STATE_COMPARE(gl_pack_alignment, param)
2367 _sym_glPixelStorei(pname, param);
2369 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2371 current_ctx->_misc_flag2 |= FLAG_BIT_1;
2372 current_ctx->gl_pack_alignment[0] = param;
2375 else if (pname == GL_UNPACK_ALIGNMENT)
2377 CURR_STATE_COMPARE(gl_unpack_alignment, param)
2379 _sym_glPixelStorei(pname, param);
2381 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2383 current_ctx->_misc_flag2 |= FLAG_BIT_2;
2384 current_ctx->gl_unpack_alignment[0] = param;
2389 // For GL Error to be picked up
2390 _sym_glPixelStorei(pname, param);
2391 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2396 _COREGL_FAST_FUNC_END();
2401 fpgl_glPolygonOffset(GLfloat factor, GLfloat units)
2403 DEFINE_FAST_GL_FUNC();
2404 _COREGL_FAST_FUNC_BEGIN();
2405 INIT_FAST_GL_FUNC();
2407 if ((current_ctx->gl_polygon_offset_factor[0] != factor) ||
2408 (current_ctx->gl_polygon_offset_units[0] != units))
2410 _sym_glPolygonOffset(factor, units);
2412 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2414 current_ctx->_misc_flag1 |= (FLAG_BIT_2 | FLAG_BIT_3);
2415 current_ctx->gl_polygon_offset_factor[0] = factor;
2416 current_ctx->gl_polygon_offset_units[0] = units;
2421 _COREGL_FAST_FUNC_END();
2426 fpgl_glSampleCoverage(GLclampf value, GLboolean invert)
2428 DEFINE_FAST_GL_FUNC();
2429 _COREGL_FAST_FUNC_BEGIN();
2430 INIT_FAST_GL_FUNC();
2432 if ((current_ctx->gl_sample_coverage_value[0] != value) ||
2433 (current_ctx->gl_sample_coverage_invert[0] != invert))
2435 _sym_glSampleCoverage(value, invert);
2437 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2439 current_ctx->_misc_flag1 |= (FLAG_BIT_4 | FLAG_BIT_5);
2440 current_ctx->gl_sample_coverage_value[0] = value;
2441 current_ctx->gl_sample_coverage_invert[0] = invert;
2446 _COREGL_FAST_FUNC_END();
2451 fpgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
2453 DEFINE_FAST_GL_FUNC();
2454 _COREGL_FAST_FUNC_BEGIN();
2455 INIT_FAST_GL_FUNC();
2457 if ((current_ctx->gl_scissor_box[0] != x) ||
2458 (current_ctx->gl_scissor_box[1] != y) ||
2459 (current_ctx->gl_scissor_box[2] != width) ||
2460 (current_ctx->gl_scissor_box[3] != height))
2462 _sym_glScissor(x, y, width, height);
2464 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2466 current_ctx->_misc_flag2 |= FLAG_BIT_0;
2467 current_ctx->gl_scissor_box[0] = x;
2468 current_ctx->gl_scissor_box[1] = y;
2469 current_ctx->gl_scissor_box[2] = width;
2470 current_ctx->gl_scissor_box[3] = height;
2475 _COREGL_FAST_FUNC_END();
2480 fpgl_glStencilFunc(GLenum func, GLint ref, GLuint mask)
2482 DEFINE_FAST_GL_FUNC();
2483 _COREGL_FAST_FUNC_BEGIN();
2484 INIT_FAST_GL_FUNC();
2486 if ((current_ctx->gl_stencil_func[0] != func) ||
2487 (current_ctx->gl_stencil_ref[0] != ref) ||
2488 (current_ctx->gl_stencil_value_mask[0] != mask) ||
2489 (current_ctx->gl_stencil_back_func[0] != func) ||
2490 (current_ctx->gl_stencil_back_ref[0] != ref) ||
2491 (current_ctx->gl_stencil_back_value_mask[0] != mask))
2493 _sym_glStencilFunc(func, ref, mask);
2495 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2497 current_ctx->_stencil_flag1 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
2498 current_ctx->gl_stencil_func[0] = func;
2499 current_ctx->gl_stencil_ref[0] = ref;
2500 current_ctx->gl_stencil_value_mask[0] = mask;
2502 current_ctx->_stencil_flag2 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
2503 current_ctx->gl_stencil_back_func[0] = func;
2504 current_ctx->gl_stencil_back_ref[0] = ref;
2505 current_ctx->gl_stencil_back_value_mask[0] = mask;
2510 _COREGL_FAST_FUNC_END();
2515 fpgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
2517 DEFINE_FAST_GL_FUNC();
2518 _COREGL_FAST_FUNC_BEGIN();
2519 INIT_FAST_GL_FUNC();
2521 if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
2523 if ((current_ctx->gl_stencil_func[0] != func) ||
2524 (current_ctx->gl_stencil_ref[0] != ref) ||
2525 (current_ctx->gl_stencil_value_mask[0] != mask))
2527 _sym_glStencilFuncSeparate(face, func, ref, mask);
2529 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2531 current_ctx->_stencil_flag1 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
2533 current_ctx->gl_stencil_func[0] = func;
2534 current_ctx->gl_stencil_ref[0] = ref;
2535 current_ctx->gl_stencil_value_mask[0] = mask;
2538 else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
2540 if ((current_ctx->gl_stencil_back_func[0] != func) ||
2541 (current_ctx->gl_stencil_back_ref[0] != ref) ||
2542 (current_ctx->gl_stencil_back_value_mask[0] != mask))
2544 _sym_glStencilFuncSeparate(face, func, ref, mask);
2546 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2548 current_ctx->_stencil_flag2 |= (FLAG_BIT_0 | FLAG_BIT_1 | FLAG_BIT_2);
2550 current_ctx->gl_stencil_back_func[0] = func;
2551 current_ctx->gl_stencil_back_ref[0] = ref;
2552 current_ctx->gl_stencil_back_value_mask[0] = mask;
2557 // Have GL pick up the error
2558 _sym_glStencilFuncSeparate(face, func, ref, mask);
2560 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2565 _COREGL_FAST_FUNC_END();
2570 fpgl_glStencilMask(GLuint mask)
2572 DEFINE_FAST_GL_FUNC();
2573 _COREGL_FAST_FUNC_BEGIN();
2574 INIT_FAST_GL_FUNC();
2576 if ((current_ctx->gl_stencil_writemask[0] != mask) ||
2577 (current_ctx->gl_stencil_back_writemask[0] != mask))
2579 _sym_glStencilMask(mask);
2581 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2583 current_ctx->_stencil_flag1 |= (FLAG_BIT_6);
2584 current_ctx->_stencil_flag2 |= (FLAG_BIT_6);
2586 current_ctx->gl_stencil_writemask[0] = mask;
2587 current_ctx->gl_stencil_back_writemask[0] = mask;
2592 _COREGL_FAST_FUNC_END();
2597 fpgl_glStencilMaskSeparate(GLenum face, GLuint mask)
2599 DEFINE_FAST_GL_FUNC();
2600 _COREGL_FAST_FUNC_BEGIN();
2601 INIT_FAST_GL_FUNC();
2603 if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
2605 if (current_ctx->gl_stencil_writemask[0] != mask)
2607 _sym_glStencilMaskSeparate(face, mask);
2609 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2611 current_ctx->_stencil_flag1 |= (FLAG_BIT_6);
2612 current_ctx->gl_stencil_writemask[0] = mask;
2615 else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
2617 if (current_ctx->gl_stencil_back_writemask[0] != mask)
2619 _sym_glStencilMaskSeparate(face, mask);
2621 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2623 current_ctx->_stencil_flag2 |= (FLAG_BIT_6);
2624 current_ctx->gl_stencil_back_writemask[0] = mask;
2629 // Have GL pick up the error
2630 _sym_glStencilMaskSeparate(face, mask);
2631 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2636 _COREGL_FAST_FUNC_END();
2641 fpgl_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
2643 DEFINE_FAST_GL_FUNC();
2644 _COREGL_FAST_FUNC_BEGIN();
2645 INIT_FAST_GL_FUNC();
2647 if ((current_ctx->gl_stencil_fail[0] != fail) ||
2648 (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) ||
2649 (current_ctx->gl_stencil_pass_depth_pass[0] != zpass) ||
2650 (current_ctx->gl_stencil_back_fail[0] != fail) ||
2651 (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) ||
2652 (current_ctx->gl_stencil_back_pass_depth_pass[0] != zpass))
2654 _sym_glStencilOp(fail, zfail, zpass);
2656 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2658 current_ctx->_stencil_flag1 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
2659 current_ctx->gl_stencil_fail[0] = fail;
2660 current_ctx->gl_stencil_pass_depth_fail[0] = zfail;
2661 current_ctx->gl_stencil_pass_depth_pass[0] = zpass;
2663 current_ctx->_stencil_flag2 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
2664 current_ctx->gl_stencil_back_fail[0] = fail;
2665 current_ctx->gl_stencil_back_pass_depth_fail[0] = zfail;
2666 current_ctx->gl_stencil_back_pass_depth_pass[0] = zpass;
2671 _COREGL_FAST_FUNC_END();
2676 fpgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
2678 DEFINE_FAST_GL_FUNC();
2679 _COREGL_FAST_FUNC_BEGIN();
2680 INIT_FAST_GL_FUNC();
2682 if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK))
2684 if ((current_ctx->gl_stencil_fail[0] != fail) ||
2685 (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) ||
2686 (current_ctx->gl_stencil_pass_depth_pass[0] != zpass))
2688 _sym_glStencilOpSeparate(face, fail, zfail, zpass);
2689 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2691 current_ctx->_stencil_flag1 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
2692 current_ctx->gl_stencil_fail[0] = fail;
2693 current_ctx->gl_stencil_pass_depth_fail[0] = zfail;
2694 current_ctx->gl_stencil_pass_depth_pass[0] = zpass;
2697 else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK))
2699 if ((current_ctx->gl_stencil_back_fail[0] != fail) ||
2700 (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) ||
2701 (current_ctx->gl_stencil_back_pass_depth_pass[0] != zpass))
2703 _sym_glStencilOpSeparate(face, fail, zfail, zpass);
2704 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2706 current_ctx->_stencil_flag2 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5);
2707 current_ctx->gl_stencil_back_fail[0] = fail;
2708 current_ctx->gl_stencil_back_pass_depth_fail[0] = zfail;
2709 current_ctx->gl_stencil_back_pass_depth_pass[0] = zpass;
2714 // For picking up error purpose
2715 _sym_glStencilOpSeparate(face, fail, zfail, zpass);
2716 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2721 _COREGL_FAST_FUNC_END();
2726 fpgl_glVertexAttrib1f(GLuint indx, GLfloat x)
2728 DEFINE_FAST_GL_FUNC();
2729 _COREGL_FAST_FUNC_BEGIN();
2730 INIT_FAST_GL_FUNC();
2732 _sym_glVertexAttrib1f(indx, x);
2734 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2736 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2737 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
2738 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = 0;
2739 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
2740 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2744 _COREGL_FAST_FUNC_END();
2750 fpgl_glVertexAttrib1fv(GLuint indx, const GLfloat* values)
2752 DEFINE_FAST_GL_FUNC();
2753 _COREGL_FAST_FUNC_BEGIN();
2754 INIT_FAST_GL_FUNC();
2756 _sym_glVertexAttrib1fv(indx, values);
2758 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2760 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2761 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
2762 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = 0;
2763 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
2764 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2768 _COREGL_FAST_FUNC_END();
2774 fpgl_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
2776 DEFINE_FAST_GL_FUNC();
2777 _COREGL_FAST_FUNC_BEGIN();
2778 INIT_FAST_GL_FUNC();
2780 _sym_glVertexAttrib2f(indx, x, y);
2782 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2784 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2785 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
2786 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = y;
2787 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
2788 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2792 _COREGL_FAST_FUNC_END();
2798 fpgl_glVertexAttrib2fv(GLuint indx, const GLfloat* values)
2800 DEFINE_FAST_GL_FUNC();
2801 _COREGL_FAST_FUNC_BEGIN();
2802 INIT_FAST_GL_FUNC();
2804 _sym_glVertexAttrib2fv(indx, values);
2806 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2808 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2809 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
2810 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = values[1];
2811 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = 0;
2812 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2816 _COREGL_FAST_FUNC_END();
2822 fpgl_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
2824 DEFINE_FAST_GL_FUNC();
2825 _COREGL_FAST_FUNC_BEGIN();
2826 INIT_FAST_GL_FUNC();
2828 _sym_glVertexAttrib3f(indx, x, y, z);
2830 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2832 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2833 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
2834 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = y;
2835 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = z;
2836 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2840 _COREGL_FAST_FUNC_END();
2846 fpgl_glVertexAttrib3fv(GLuint indx, const GLfloat* values)
2848 DEFINE_FAST_GL_FUNC();
2849 _COREGL_FAST_FUNC_BEGIN();
2850 INIT_FAST_GL_FUNC();
2852 _sym_glVertexAttrib3fv(indx, values);
2854 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2856 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2857 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
2858 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = values[1];
2859 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = values[2];
2860 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = 1;
2864 _COREGL_FAST_FUNC_END();
2870 fpgl_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
2872 DEFINE_FAST_GL_FUNC();
2873 _COREGL_FAST_FUNC_BEGIN();
2874 INIT_FAST_GL_FUNC();
2876 _sym_glVertexAttrib4f(indx, x, y, z, w);
2878 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2880 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2881 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = x;
2882 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = y;
2883 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = z;
2884 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = w;
2888 _COREGL_FAST_FUNC_END();
2894 fpgl_glVertexAttrib4fv(GLuint indx, const GLfloat* values)
2896 DEFINE_FAST_GL_FUNC();
2897 _COREGL_FAST_FUNC_BEGIN();
2898 INIT_FAST_GL_FUNC();
2900 _sym_glVertexAttrib4fv(indx, values);
2902 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2904 current_ctx->_vattrib_flag |= FLAG_BIT_0;
2905 current_ctx->gl_vertex_attrib_value[indx * 4 + 0] = values[0];
2906 current_ctx->gl_vertex_attrib_value[indx * 4 + 1] = values[1];
2907 current_ctx->gl_vertex_attrib_value[indx * 4 + 2] = values[2];
2908 current_ctx->gl_vertex_attrib_value[indx * 4 + 3] = values[3];
2912 _COREGL_FAST_FUNC_END();
2919 fpgl_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
2921 DEFINE_FAST_GL_FUNC();
2922 _COREGL_FAST_FUNC_BEGIN();
2923 INIT_FAST_GL_FUNC();
2925 _sym_glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
2927 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2929 current_ctx->_vattrib_flag |= FLAG_BIT_1;
2931 current_ctx->gl_vertex_array_buf_id[indx] = current_ctx->gl_array_buffer_binding[0];
2932 current_ctx->gl_vertex_array_size[indx] = size;
2933 current_ctx->gl_vertex_array_type[indx] = type;
2934 current_ctx->gl_vertex_array_normalized[indx] = normalized;
2935 current_ctx->gl_vertex_array_stride[indx] = stride;
2936 current_ctx->gl_vertex_array_pointer[indx] = (GLvoid *)ptr;
2940 _COREGL_FAST_FUNC_END();
2945 fpgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
2947 DEFINE_FAST_GL_FUNC();
2948 _COREGL_FAST_FUNC_BEGIN();
2949 INIT_FAST_GL_FUNC();
2951 if ((current_ctx->gl_viewport[0] != x) ||
2952 (current_ctx->gl_viewport[1] != y) ||
2953 (current_ctx->gl_viewport[2] != width) ||
2954 (current_ctx->gl_viewport[3] != height))
2956 _sym_glViewport(x, y, width, height);
2958 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2960 current_ctx->_clear_flag1 |= FLAG_BIT_0;
2961 current_ctx->gl_viewport[0] = x;
2962 current_ctx->gl_viewport[1] = y;
2963 current_ctx->gl_viewport[2] = width;
2964 current_ctx->gl_viewport[3] = height;
2969 _COREGL_FAST_FUNC_END();
2973 fpgl_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
2977 DEFINE_FAST_GL_FUNC();
2978 _COREGL_FAST_FUNC_BEGIN();
2979 INIT_FAST_GL_FUNC();
2981 tex_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0;
2986 current_ctx->gl_tex_2d_state[tex_idx] = -1;
2988 case GL_TEXTURE_CUBE_MAP:
2989 current_ctx->gl_tex_cube_state[tex_idx] = -1;
2993 _sym_glEGLImageTargetTexture2DOES(target, image);
2995 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3000 _COREGL_FAST_FUNC_END();
3004 _process_getfunc(GLenum pname, GLvoid *ptr, GLenum get_type)
3006 GLboolean ret = GL_FALSE;
3008 DEFINE_FAST_GL_FUNC();
3009 INIT_FAST_GL_FUNC();
3013 case GL_TEXTURE_BINDING_2D:
3015 GLint real_tex_id = _COREGL_INT_INIT_VALUE;
3016 GLuint glue_tex_id = _COREGL_INT_INIT_VALUE;
3017 _sym_glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)real_tex_id);
3019 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3021 if (real_tex_id == 0)
3027 AST(current_ctx->sostate != NULL);
3028 glue_tex_id = sostate_find_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, real_tex_id);
3034 ((GLint *)ptr)[0] = glue_tex_id;
3037 ((GLfloat *)ptr)[0] = (GLfloat)glue_tex_id;
3040 ((GLboolean *)ptr)[0] = (glue_tex_id == 0) ? GL_FALSE : GL_TRUE;
3055 fpgl_glGetBooleanv(GLenum pname, GLboolean* params)
3057 DEFINE_FAST_GL_FUNC();
3058 _COREGL_FAST_FUNC_BEGIN();
3059 INIT_FAST_GL_FUNC();
3061 if (_process_getfunc(pname, params, GL_BOOL) != GL_TRUE)
3063 _sym_glGetBooleanv(pname, params);
3064 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3069 _COREGL_FAST_FUNC_END();
3073 fpgl_glGetFloatv(GLenum pname, GLfloat* params)
3075 DEFINE_FAST_GL_FUNC();
3076 _COREGL_FAST_FUNC_BEGIN();
3077 INIT_FAST_GL_FUNC();
3079 if (_process_getfunc(pname, params, GL_FLOAT) != GL_TRUE)
3081 _sym_glGetFloatv(pname, params);
3082 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3087 _COREGL_FAST_FUNC_END();
3091 fpgl_glGetIntegerv(GLenum pname, GLint* params)
3093 DEFINE_FAST_GL_FUNC();
3094 _COREGL_FAST_FUNC_BEGIN();
3095 INIT_FAST_GL_FUNC();
3097 if (_process_getfunc(pname, params, GL_INT) != GL_TRUE)
3099 _sym_glGetIntegerv(pname, params);
3100 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
3105 _COREGL_FAST_FUNC_END();