4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
7 * Stanislav Vorobiov <s.vorobiov@samsung.com>
8 * Jinhyung Jo <jinhyung.jo@samsung.com>
9 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 #include "GLES2/gl2.h"
35 #include "GLES2/gl2ext.h"
36 #include "yagl_host_gles_calls.h"
37 #include "yagl_gles2_program.h"
38 #include "yagl_gles2_shader.h"
39 #include "yagl_gles2_validate.h"
40 #include "yagl_gles2_context.h"
41 #include "yagl_gles_validate.h"
42 #include "yagl_gles_vertex_array.h"
43 #include "yagl_gles_array.h"
44 #include "yagl_gles_buffer.h"
45 #include "yagl_gles_texture_unit.h"
46 #include "yagl_gles_texture.h"
47 #include "yagl_impl.h"
48 #include "yagl_malloc.h"
49 #include "yagl_sharegroup.h"
50 #include "yagl_transport.h"
51 #include "yagl_utils.h"
52 #include "yagl_pixel_format.h"
53 #include "yagl_glsl_state.h"
61 * We can't include GL/gl.h here
63 #define GL_INT_2_10_10_10_REV 0x8D9F
64 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
66 #define YAGL_SET_ERR(err) \
67 yagl_gles_context_set_error(&ctx->base, err); \
68 YAGL_LOG_ERROR("error = 0x%X", err)
70 #define YAGL_GET_CTX_IMPL(ret_expr) \
71 struct yagl_gles2_context *ctx = \
72 (struct yagl_gles2_context*)yagl_get_client_context(); \
73 if (!ctx || ((ctx->base.base.client_api & (yagl_client_api_gles2|yagl_client_api_gles3)) == 0)) { \
74 YAGL_LOG_WARN("no current context"); \
75 YAGL_LOG_FUNC_EXIT(NULL); \
79 #define YAGL_GET_CTX_RET(ret) YAGL_GET_CTX_IMPL(return ret)
81 #define YAGL_GET_CTX() YAGL_GET_CTX_IMPL(return)
83 YAGL_API void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
87 YAGL_LOG_FUNC_ENTER_SPLIT4(glStencilFuncSeparate, GLenum, GLenum, GLint, GLuint, face, func, ref, mask);
91 if (!yagl_gles_is_stencil_func_valid(func)) {
92 YAGL_SET_ERR(GL_INVALID_ENUM);
96 if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) {
97 ctx->base.stencil_front.func = func;
98 ctx->base.stencil_front.ref = ref;
99 ctx->base.stencil_front.mask = mask;
104 if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK)) {
105 ctx->base.stencil_back.func = func;
106 ctx->base.stencil_back.ref = ref;
107 ctx->base.stencil_back.mask = mask;
113 yagl_host_glStencilFuncSeparate(face, func, ref, mask);
115 YAGL_SET_ERR(GL_INVALID_ENUM);
119 YAGL_LOG_FUNC_EXIT(NULL);
122 YAGL_API void glStencilMaskSeparate(GLenum face, GLuint mask)
126 YAGL_LOG_FUNC_ENTER_SPLIT2(glStencilMaskSeparate, GLenum, GLuint, face, mask);
130 if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) {
131 ctx->base.stencil_front.writemask = mask;
136 if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK)) {
137 ctx->base.stencil_back.writemask = mask;
143 yagl_host_glStencilMaskSeparate(face, mask);
145 YAGL_SET_ERR(GL_INVALID_ENUM);
148 YAGL_LOG_FUNC_EXIT(NULL);
151 YAGL_API void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
155 YAGL_LOG_FUNC_ENTER_SPLIT4(glStencilOpSeparate, GLenum, GLenum, GLenum, GLenum, face, fail, zfail, zpass);
159 if (!yagl_gles_is_stencil_op_valid(fail) ||
160 !yagl_gles_is_stencil_op_valid(zfail) ||
161 !yagl_gles_is_stencil_op_valid(zpass)) {
162 YAGL_SET_ERR(GL_INVALID_ENUM);
166 if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) {
167 ctx->base.stencil_front.fail = fail;
168 ctx->base.stencil_front.zfail = zfail;
169 ctx->base.stencil_front.zpass = zpass;
174 if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK)) {
175 ctx->base.stencil_back.fail = fail;
176 ctx->base.stencil_back.zfail = zfail;
177 ctx->base.stencil_back.zpass = zpass;
183 yagl_host_glStencilOpSeparate(face, fail, zfail, zpass);
185 YAGL_SET_ERR(GL_INVALID_ENUM);
189 YAGL_LOG_FUNC_EXIT(NULL);
192 YAGL_API void glAttachShader(GLuint program, GLuint shader)
194 struct yagl_gles2_program *program_obj = NULL;
195 struct yagl_gles2_shader *shader_obj = NULL;
197 YAGL_LOG_FUNC_ENTER_SPLIT2(glAttachShader, GLuint, GLuint, program, shader);
201 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
202 YAGL_NS_SHADER_PROGRAM, program);
205 YAGL_SET_ERR(GL_INVALID_VALUE);
209 if (program_obj->is_shader) {
210 YAGL_SET_ERR(GL_INVALID_OPERATION);
214 shader_obj = (struct yagl_gles2_shader*)yagl_sharegroup_acquire_object(ctx->sg,
215 YAGL_NS_SHADER_PROGRAM, shader);
218 YAGL_SET_ERR(GL_INVALID_VALUE);
222 if (!shader_obj->is_shader) {
223 YAGL_SET_ERR(GL_INVALID_OPERATION);
227 if (!yagl_gles2_program_attach_shader(program_obj, shader_obj)) {
228 YAGL_SET_ERR(GL_INVALID_OPERATION);
233 yagl_gles2_shader_release(shader_obj);
234 yagl_gles2_program_release(program_obj);
236 YAGL_LOG_FUNC_EXIT(NULL);
239 YAGL_API void glBindAttribLocation(GLuint program, GLuint index, const GLchar *name)
241 struct yagl_gles2_program *program_obj = NULL;
243 YAGL_LOG_FUNC_ENTER_SPLIT3(glBindAttribLocation, GLuint, GLuint, const GLchar*, program, index, name);
247 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
248 YAGL_NS_SHADER_PROGRAM, program);
251 YAGL_SET_ERR(GL_INVALID_VALUE);
255 if (program_obj->is_shader) {
256 YAGL_SET_ERR(GL_INVALID_OPERATION);
260 if (index >= ctx->base.num_arrays) {
261 YAGL_SET_ERR(GL_INVALID_VALUE);
266 if (strncmp(name, "gl_", 3) == 0) {
267 YAGL_SET_ERR(GL_INVALID_OPERATION);
271 YAGL_LOG_TRACE("binding attrib %s location to %d", name, index);
274 yagl_host_glBindAttribLocation(program_obj->global_name,
277 yagl_transport_string_count(name));
280 yagl_gles2_program_release(program_obj);
282 YAGL_LOG_FUNC_EXIT(NULL);
285 YAGL_API void glBlendColor(GLclampf red,
290 YAGL_LOG_FUNC_ENTER_SPLIT4(glBlendColor, GLclampf, GLclampf, GLclampf, GLclampf, red, green, blue, alpha);
294 ctx->blend_color[0] = yagl_clampf(red);
295 ctx->blend_color[1] = yagl_clampf(green);
296 ctx->blend_color[2] = yagl_clampf(blue);
297 ctx->blend_color[3] = yagl_clampf(alpha);
299 yagl_host_glBlendColor(red, green, blue, alpha);
301 YAGL_LOG_FUNC_EXIT(NULL);
304 YAGL_API void glCompileShader(GLuint shader)
306 struct yagl_gles2_shader *shader_obj = NULL;
308 YAGL_LOG_FUNC_ENTER_SPLIT1(glCompileShader, GLuint, shader);
312 shader_obj = (struct yagl_gles2_shader*)yagl_sharegroup_acquire_object(ctx->sg,
313 YAGL_NS_SHADER_PROGRAM, shader);
316 YAGL_SET_ERR(GL_INVALID_VALUE);
320 if (!shader_obj->is_shader) {
321 YAGL_SET_ERR(GL_INVALID_OPERATION);
325 yagl_host_glCompileShader(shader_obj->global_name);
328 yagl_gles2_shader_release(shader_obj);
330 YAGL_LOG_FUNC_EXIT(NULL);
333 YAGL_API GLuint glCreateProgram(void)
336 struct yagl_gles2_program *program = NULL;
338 YAGL_LOG_FUNC_ENTER_SPLIT0(glCreateProgram);
342 program = yagl_gles2_program_create(ctx->gen_locations);
348 yagl_sharegroup_add(ctx->sg, YAGL_NS_SHADER_PROGRAM, &program->base);
349 res = program->base.local_name;
352 yagl_gles2_program_release(program);
354 YAGL_LOG_FUNC_EXIT_SPLIT(GLuint, res);
359 YAGL_API GLuint glCreateShader(GLenum type)
362 struct yagl_gles2_shader *shader = NULL;
364 YAGL_LOG_FUNC_ENTER_SPLIT1(glCreateShader, GLenum, type);
368 if (yagl_gles2_is_shader_type_valid(type)) {
369 shader = yagl_gles2_shader_create(type);
375 yagl_sharegroup_add(ctx->sg, YAGL_NS_SHADER_PROGRAM, &shader->base);
376 res = shader->base.local_name;
378 YAGL_SET_ERR(GL_INVALID_ENUM);
382 yagl_gles2_shader_release(shader);
384 YAGL_LOG_FUNC_EXIT_SPLIT(GLuint, res);
389 YAGL_API void glDeleteProgram(GLuint program)
391 struct yagl_gles2_program *program_obj = NULL;
393 YAGL_LOG_FUNC_ENTER_SPLIT1(glDeleteProgram, GLuint, program);
401 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
402 YAGL_NS_SHADER_PROGRAM, program);
405 YAGL_SET_ERR(GL_INVALID_VALUE);
409 if (program_obj->is_shader) {
413 yagl_gles2_context_unuse_program(ctx, program_obj);
415 yagl_sharegroup_remove(ctx->sg,
416 YAGL_NS_SHADER_PROGRAM,
420 yagl_gles2_program_release(program_obj);
422 YAGL_LOG_FUNC_EXIT(NULL);
425 YAGL_API void glDeleteShader(GLuint shader)
427 struct yagl_gles2_shader *shader_obj = NULL;
429 YAGL_LOG_FUNC_ENTER_SPLIT1(glDeleteShader, GLuint, shader);
437 shader_obj = (struct yagl_gles2_shader*)yagl_sharegroup_acquire_object(ctx->sg,
438 YAGL_NS_SHADER_PROGRAM, shader);
441 YAGL_SET_ERR(GL_INVALID_VALUE);
445 if (!shader_obj->is_shader) {
449 yagl_sharegroup_remove(ctx->sg,
450 YAGL_NS_SHADER_PROGRAM,
454 yagl_gles2_shader_release(shader_obj);
456 YAGL_LOG_FUNC_EXIT(NULL);
459 YAGL_API void glDetachShader(GLuint program, GLuint shader)
461 struct yagl_gles2_program *program_obj = NULL;
462 struct yagl_gles2_shader *shader_obj = NULL;
464 YAGL_LOG_FUNC_ENTER_SPLIT2(glDetachShader, GLuint, GLuint, program, shader);
468 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
469 YAGL_NS_SHADER_PROGRAM, program);
472 YAGL_SET_ERR(GL_INVALID_VALUE);
476 if (program_obj->is_shader) {
477 YAGL_SET_ERR(GL_INVALID_OPERATION);
481 if (program_obj->vertex_shader &&
482 (program_obj->vertex_shader->base.local_name == shader)) {
483 shader_obj = program_obj->vertex_shader;
484 yagl_gles2_shader_acquire(shader_obj);
485 } else if (program_obj->fragment_shader &&
486 (program_obj->fragment_shader->base.local_name == shader)) {
487 shader_obj = program_obj->fragment_shader;
488 yagl_gles2_shader_acquire(shader_obj);
490 shader_obj = (struct yagl_gles2_shader*)yagl_sharegroup_acquire_object(ctx->sg,
491 YAGL_NS_SHADER_PROGRAM, shader);
494 YAGL_SET_ERR(GL_INVALID_OPERATION);
496 YAGL_SET_ERR(GL_INVALID_VALUE);
502 yagl_gles2_program_detach_shader(program_obj, shader_obj);
505 yagl_gles2_shader_release(shader_obj);
506 yagl_gles2_program_release(program_obj);
508 YAGL_LOG_FUNC_EXIT(NULL);
511 YAGL_API void glEnableVertexAttribArray(GLuint index)
513 YAGL_LOG_FUNC_ENTER_SPLIT1(glEnableVertexAttribArray, GLuint, index);
517 if (index < ctx->base.num_arrays) {
518 yagl_gles_array_enable(&ctx->base.vao->arrays[index], 1);
521 yagl_host_glEnableVertexAttribArray(index);
523 YAGL_LOG_FUNC_EXIT(NULL);
526 YAGL_API void glDisableVertexAttribArray(GLuint index)
528 YAGL_LOG_FUNC_ENTER_SPLIT1(glDisableVertexAttribArray, GLuint, index);
532 if (index < ctx->base.num_arrays) {
533 yagl_gles_array_enable(&ctx->base.vao->arrays[index], 0);
536 yagl_host_glDisableVertexAttribArray(index);
538 YAGL_LOG_FUNC_EXIT(NULL);
541 YAGL_API void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
543 struct yagl_gles2_program *program_obj = NULL;
545 YAGL_LOG_FUNC_ENTER_SPLIT7(glGetActiveAttrib, GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*, program, index, bufsize, length, size, type, name);
549 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
550 YAGL_NS_SHADER_PROGRAM, program);
553 YAGL_SET_ERR(GL_INVALID_VALUE);
557 if (program_obj->is_shader) {
558 YAGL_SET_ERR(GL_INVALID_OPERATION);
563 YAGL_SET_ERR(GL_INVALID_VALUE);
567 if (index >= program_obj->num_active_attribs) {
568 YAGL_SET_ERR(GL_INVALID_VALUE);
572 yagl_gles2_program_get_active_attrib(program_obj, index, bufsize, length, size, type, name);
575 yagl_gles2_program_release(program_obj);
577 YAGL_LOG_FUNC_EXIT(NULL);
580 YAGL_API void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
582 struct yagl_gles2_program *program_obj = NULL;
584 YAGL_LOG_FUNC_ENTER_SPLIT7(glGetActiveUniform, GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*, program, index, bufsize, length, size, type, name);
588 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
589 YAGL_NS_SHADER_PROGRAM, program);
592 YAGL_SET_ERR(GL_INVALID_VALUE);
596 if (program_obj->is_shader) {
597 YAGL_SET_ERR(GL_INVALID_OPERATION);
602 YAGL_SET_ERR(GL_INVALID_VALUE);
606 if (index >= program_obj->num_active_uniforms) {
607 YAGL_SET_ERR(GL_INVALID_VALUE);
611 yagl_gles2_program_get_active_uniform(program_obj, index, bufsize, length, size, type, name);
614 yagl_gles2_program_release(program_obj);
616 YAGL_LOG_FUNC_EXIT(NULL);
619 YAGL_API void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders)
621 struct yagl_gles2_program *program_obj = NULL;
624 YAGL_LOG_FUNC_ENTER_SPLIT4(glGetAttachedShaders, GLuint, GLsizei, GLsizei*, GLuint*, program, maxcount, count, shaders);
628 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
629 YAGL_NS_SHADER_PROGRAM, program);
632 YAGL_SET_ERR(GL_INVALID_VALUE);
636 if (program_obj->is_shader) {
637 YAGL_SET_ERR(GL_INVALID_OPERATION);
642 YAGL_SET_ERR(GL_INVALID_VALUE);
648 if (program_obj->vertex_shader) {
649 if (tmp < maxcount) {
651 shaders[tmp] = program_obj->vertex_shader->base.local_name;
657 if (program_obj->fragment_shader) {
658 if (tmp < maxcount) {
660 shaders[tmp] = program_obj->fragment_shader->base.local_name;
671 yagl_gles2_program_release(program_obj);
673 YAGL_LOG_FUNC_EXIT(NULL);
676 YAGL_API int glGetAttribLocation(GLuint program, const GLchar *name)
678 struct yagl_gles2_program *program_obj = NULL;
681 YAGL_LOG_FUNC_ENTER_SPLIT2(glGetAttribLocation, GLuint, const GLchar*, program, name);
685 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
686 YAGL_NS_SHADER_PROGRAM, program);
689 YAGL_SET_ERR(GL_INVALID_VALUE);
693 if (program_obj->is_shader) {
694 YAGL_SET_ERR(GL_INVALID_OPERATION);
698 if (!program_obj->linked) {
699 YAGL_SET_ERR(GL_INVALID_OPERATION);
703 ret = yagl_gles2_program_get_attrib_location(program_obj, name);
706 yagl_gles2_program_release(program_obj);
708 YAGL_LOG_FUNC_EXIT_SPLIT(int, ret);
713 YAGL_API void glGetProgramiv(GLuint program, GLenum pname, GLint *params)
715 struct yagl_gles2_program *program_obj = NULL;
717 YAGL_LOG_FUNC_ENTER_SPLIT3(glGetProgramiv, GLuint, GLenum, GLint*, program, pname, params);
721 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
722 YAGL_NS_SHADER_PROGRAM, program);
725 YAGL_SET_ERR(GL_INVALID_VALUE);
729 if (program_obj->is_shader) {
730 YAGL_SET_ERR(GL_INVALID_OPERATION);
734 if (!ctx->get_programiv(ctx, program_obj, pname, params)) {
736 case GL_VALIDATE_STATUS:
737 yagl_host_glGetProgramiv(program_obj->global_name, pname, params);
740 YAGL_SET_ERR(GL_INVALID_ENUM);
745 yagl_gles2_program_release(program_obj);
747 YAGL_LOG_FUNC_EXIT(NULL);
750 YAGL_API void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog)
752 struct yagl_gles2_program *program_obj = NULL;
755 YAGL_LOG_FUNC_ENTER_SPLIT4(glGetProgramInfoLog, GLuint, GLsizei, GLsizei*, GLchar*, program, bufsize, length, infolog);
759 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
760 YAGL_NS_SHADER_PROGRAM, program);
763 YAGL_SET_ERR(GL_INVALID_VALUE);
767 if (program_obj->is_shader) {
768 YAGL_SET_ERR(GL_INVALID_OPERATION);
773 YAGL_SET_ERR(GL_INVALID_VALUE);
777 if (yagl_host_glGetProgramInfoLog(program_obj->global_name, infolog, bufsize, &tmp)) {
779 *length = (tmp > 0) ? (tmp - 1) : 0;
781 YAGL_LOG_TRACE("infolog = %s", infolog);
785 yagl_gles2_program_release(program_obj);
787 YAGL_LOG_FUNC_EXIT(NULL);
790 YAGL_API void glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
792 struct yagl_gles2_shader *shader_obj = NULL;
794 YAGL_LOG_FUNC_ENTER_SPLIT3(glGetShaderiv, GLuint, GLenum, GLint*, shader, pname, params);
798 shader_obj = (struct yagl_gles2_shader*)yagl_sharegroup_acquire_object(ctx->sg,
799 YAGL_NS_SHADER_PROGRAM, shader);
802 YAGL_SET_ERR(GL_INVALID_VALUE);
806 if (!shader_obj->is_shader) {
807 YAGL_SET_ERR(GL_INVALID_OPERATION);
813 *params = shader_obj->type;
815 case GL_SHADER_SOURCE_LENGTH:
816 *params = shader_obj->source ? (strlen(shader_obj->source) + 1) : 0;
818 case GL_INFO_LOG_LENGTH:
819 case GL_DELETE_STATUS:
820 case GL_COMPILE_STATUS:
821 yagl_host_glGetShaderiv(shader_obj->global_name, pname, params);
824 YAGL_SET_ERR(GL_INVALID_ENUM);
829 yagl_gles2_shader_release(shader_obj);
831 YAGL_LOG_FUNC_EXIT(NULL);
834 YAGL_API void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog)
837 struct yagl_gles2_shader *shader_obj = NULL;
839 YAGL_LOG_FUNC_ENTER_SPLIT4(glGetShaderInfoLog, GLuint, GLsizei, GLsizei*, GLchar*, shader, bufsize, length, infolog);
843 shader_obj = (struct yagl_gles2_shader*)yagl_sharegroup_acquire_object(ctx->sg,
844 YAGL_NS_SHADER_PROGRAM, shader);
847 YAGL_SET_ERR(GL_INVALID_VALUE);
851 if (!shader_obj->is_shader) {
852 YAGL_SET_ERR(GL_INVALID_OPERATION);
857 YAGL_SET_ERR(GL_INVALID_VALUE);
861 if (yagl_host_glGetShaderInfoLog(shader_obj->global_name, infolog, bufsize, &tmp)) {
863 *length = (tmp > 0) ? (tmp - 1) : 0;
865 YAGL_LOG_TRACE("infolog = %s", infolog);
869 yagl_gles2_shader_release(shader_obj);
871 YAGL_LOG_FUNC_EXIT(NULL);
874 YAGL_API void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision)
876 YAGL_LOG_FUNC_ENTER_SPLIT4(glGetShaderPrecisionFormat, GLenum, GLenum, GLint*, GLint*, shadertype, precisiontype, range, precision);
880 switch (precisiontype) {
885 range[0] = range[1] = 16;
892 case GL_MEDIUM_FLOAT:
895 range[0] = range[1] = 127;
902 YAGL_SET_ERR(GL_INVALID_ENUM);
906 YAGL_LOG_FUNC_EXIT(NULL);
909 YAGL_API void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source)
911 struct yagl_gles2_shader *shader_obj = NULL;
914 YAGL_LOG_FUNC_ENTER_SPLIT4(glGetShaderSource, GLuint, GLsizei, GLsizei*, GLchar*, shader, bufsize, length, source);
918 shader_obj = (struct yagl_gles2_shader*)yagl_sharegroup_acquire_object(ctx->sg,
919 YAGL_NS_SHADER_PROGRAM, shader);
922 YAGL_SET_ERR(GL_INVALID_VALUE);
926 if (!shader_obj->is_shader) {
927 YAGL_SET_ERR(GL_INVALID_OPERATION);
932 YAGL_SET_ERR(GL_INVALID_VALUE);
936 if (!shader_obj->source) {
943 tmp = strlen(shader_obj->source) + 1;
944 tmp = (bufsize <= tmp) ? bufsize : tmp;
946 if (source && (tmp > 0)) {
947 strncpy(source, shader_obj->source, tmp);
948 source[tmp - 1] = '\0';
960 yagl_gles2_shader_release(shader_obj);
962 YAGL_LOG_FUNC_EXIT(NULL);
965 YAGL_API void glGetUniformfv(GLuint program, GLint location, GLfloat *params)
967 struct yagl_gles2_program *program_obj = NULL;
969 YAGL_LOG_FUNC_ENTER_SPLIT3(glGetUniformfv, GLuint, GLint, GLfloat*, program, location, params);
973 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
974 YAGL_NS_SHADER_PROGRAM, program);
977 YAGL_SET_ERR(GL_INVALID_VALUE);
981 if (program_obj->is_shader) {
982 YAGL_SET_ERR(GL_INVALID_OPERATION);
986 if (!program_obj->linked) {
987 YAGL_SET_ERR(GL_INVALID_OPERATION);
992 YAGL_SET_ERR(GL_INVALID_OPERATION);
996 if (!yagl_gles2_program_get_uniformfv(program_obj, location, params)) {
997 YAGL_SET_ERR(GL_INVALID_OPERATION);
1002 yagl_gles2_program_release(program_obj);
1004 YAGL_LOG_FUNC_EXIT(NULL);
1007 YAGL_API void glGetUniformiv(GLuint program, GLint location, GLint *params)
1009 struct yagl_gles2_program *program_obj = NULL;
1011 YAGL_LOG_FUNC_ENTER_SPLIT3(glGetUniformiv, GLuint, GLint, GLint*, program, location, params);
1015 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
1016 YAGL_NS_SHADER_PROGRAM, program);
1019 YAGL_SET_ERR(GL_INVALID_VALUE);
1023 if (program_obj->is_shader) {
1024 YAGL_SET_ERR(GL_INVALID_OPERATION);
1028 if (!program_obj->linked) {
1029 YAGL_SET_ERR(GL_INVALID_OPERATION);
1034 YAGL_SET_ERR(GL_INVALID_OPERATION);
1038 if (!yagl_gles2_program_get_uniformiv(program_obj, location, params)) {
1039 YAGL_SET_ERR(GL_INVALID_OPERATION);
1044 yagl_gles2_program_release(program_obj);
1046 YAGL_LOG_FUNC_EXIT(NULL);
1049 YAGL_API int glGetUniformLocation(GLuint program, const GLchar *name)
1051 struct yagl_gles2_program *program_obj = NULL;
1054 YAGL_LOG_FUNC_ENTER_SPLIT2(glGetUniformLocation, GLuint, const GLchar*, program, name);
1056 YAGL_GET_CTX_RET(0);
1058 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
1059 YAGL_NS_SHADER_PROGRAM, program);
1062 YAGL_SET_ERR(GL_INVALID_VALUE);
1066 if (program_obj->is_shader) {
1067 YAGL_SET_ERR(GL_INVALID_OPERATION);
1071 if (!program_obj->linked) {
1072 YAGL_SET_ERR(GL_INVALID_OPERATION);
1077 YAGL_LOG_TRACE("getting uniform %s location", name);
1080 ret = yagl_gles2_program_get_uniform_location(program_obj, name);
1083 yagl_gles2_program_release(program_obj);
1085 YAGL_LOG_FUNC_EXIT_SPLIT(int, ret);
1090 YAGL_API void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
1093 GLfloat tmp[100]; // This fits all cases.
1096 YAGL_LOG_FUNC_ENTER_SPLIT3(glGetVertexAttribfv, GLuint, GLenum, GLfloat*, index, pname, params);
1101 (pname == GL_CURRENT_VERTEX_ATTRIB)) {
1103 switch (ctx->vertex_attrib0.type) {
1105 params[0] = ctx->vertex_attrib0.value.i[0];
1106 params[1] = ctx->vertex_attrib0.value.i[1];
1107 params[2] = ctx->vertex_attrib0.value.i[2];
1108 params[3] = ctx->vertex_attrib0.value.i[3];
1110 case GL_UNSIGNED_INT:
1111 params[0] = ctx->vertex_attrib0.value.ui[0];
1112 params[1] = ctx->vertex_attrib0.value.ui[1];
1113 params[2] = ctx->vertex_attrib0.value.ui[2];
1114 params[3] = ctx->vertex_attrib0.value.ui[3];
1119 params[0] = ctx->vertex_attrib0.value.f[0];
1120 params[1] = ctx->vertex_attrib0.value.f[1];
1121 params[2] = ctx->vertex_attrib0.value.f[2];
1122 params[3] = ctx->vertex_attrib0.value.f[3];
1130 if (yagl_gles2_context_get_array_param(ctx,
1138 yagl_host_glGetVertexAttribfv(index, pname, tmp, sizeof(tmp)/sizeof(tmp[0]), &num);
1140 memcpy(params, tmp, num * sizeof(tmp[0]));
1145 YAGL_LOG_FUNC_EXIT(NULL);
1148 YAGL_API void glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params)
1150 GLint tmp[100]; // This fits all cases.
1153 YAGL_LOG_FUNC_ENTER_SPLIT3(glGetVertexAttribiv, GLuint, GLenum, GLint*, index, pname, params);
1158 (pname == GL_CURRENT_VERTEX_ATTRIB)) {
1160 switch (ctx->vertex_attrib0.type) {
1162 params[0] = ctx->vertex_attrib0.value.i[0];
1163 params[1] = ctx->vertex_attrib0.value.i[1];
1164 params[2] = ctx->vertex_attrib0.value.i[2];
1165 params[3] = ctx->vertex_attrib0.value.i[3];
1167 case GL_UNSIGNED_INT:
1168 params[0] = ctx->vertex_attrib0.value.ui[0];
1169 params[1] = ctx->vertex_attrib0.value.ui[1];
1170 params[2] = ctx->vertex_attrib0.value.ui[2];
1171 params[3] = ctx->vertex_attrib0.value.ui[3];
1176 params[0] = ctx->vertex_attrib0.value.f[0];
1177 params[1] = ctx->vertex_attrib0.value.f[1];
1178 params[2] = ctx->vertex_attrib0.value.f[2];
1179 params[3] = ctx->vertex_attrib0.value.f[3];
1187 if (yagl_gles2_context_get_array_param(ctx,
1192 yagl_host_glGetVertexAttribiv(index, pname, tmp, sizeof(tmp)/sizeof(tmp[0]), &num);
1194 memcpy(params, tmp, num * sizeof(tmp[0]));
1199 YAGL_LOG_FUNC_EXIT(NULL);
1202 YAGL_API void glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer)
1204 struct yagl_gles_array *array = NULL;
1206 YAGL_LOG_FUNC_ENTER_SPLIT3(glGetVertexAttribPointerv, GLuint, GLenum, GLvoid**, index, pname, pointer);
1210 if (index >= ctx->base.num_arrays) {
1211 YAGL_SET_ERR(GL_INVALID_VALUE);
1215 array = &ctx->base.vao->arrays[index];
1219 *pointer = (GLvoid*)array->offset;
1221 *pointer = (GLvoid*)array->ptr;
1226 YAGL_LOG_FUNC_EXIT(NULL);
1229 YAGL_API GLboolean glIsProgram(GLuint program)
1231 GLboolean res = GL_FALSE;
1232 struct yagl_gles2_program *program_obj = NULL;
1234 YAGL_LOG_FUNC_ENTER_SPLIT1(glIsProgram, GLuint, program);
1236 YAGL_GET_CTX_RET(GL_FALSE);
1238 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
1239 YAGL_NS_SHADER_PROGRAM, program);
1242 res = program_obj->is_shader ? GL_FALSE : GL_TRUE;
1245 yagl_gles2_program_release(program_obj);
1247 YAGL_LOG_FUNC_EXIT_SPLIT(GLboolean, res);
1252 YAGL_API GLboolean glIsShader(GLuint shader)
1254 GLboolean res = GL_FALSE;
1255 struct yagl_gles2_shader *shader_obj = NULL;
1257 YAGL_LOG_FUNC_ENTER_SPLIT1(glIsShader, GLuint, shader);
1259 YAGL_GET_CTX_RET(GL_FALSE);
1261 shader_obj = (struct yagl_gles2_shader*)yagl_sharegroup_acquire_object(ctx->sg,
1262 YAGL_NS_SHADER_PROGRAM, shader);
1265 res = shader_obj->is_shader ? GL_TRUE : GL_FALSE;
1268 yagl_gles2_shader_release(shader_obj);
1270 YAGL_LOG_FUNC_EXIT_SPLIT(GLboolean, res);
1275 YAGL_API void glLinkProgram(GLuint program)
1277 struct yagl_gles2_program *program_obj = NULL;
1279 YAGL_LOG_FUNC_ENTER_SPLIT1(glLinkProgram, GLuint, program);
1283 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
1284 YAGL_NS_SHADER_PROGRAM, program);
1287 YAGL_SET_ERR(GL_INVALID_VALUE);
1291 if (program_obj->is_shader) {
1292 YAGL_SET_ERR(GL_INVALID_OPERATION);
1296 if (!ctx->pre_link_program(ctx, program_obj)) {
1300 yagl_gles2_program_link(program_obj);
1303 yagl_gles2_program_release(program_obj);
1305 YAGL_LOG_FUNC_EXIT(NULL);
1308 YAGL_API void glReleaseShaderCompiler(void)
1310 YAGL_LOG_FUNC_ENTER_SPLIT0(glReleaseShaderCompiler);
1318 YAGL_LOG_FUNC_EXIT(NULL);
1321 YAGL_API void glShaderBinary(GLsizei n, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length)
1323 YAGL_LOG_FUNC_ENTER_SPLIT5(glShaderBinary, GLsizei, const GLuint*, GLenum, const GLvoid*, GLsizei, n, shaders, binaryformat, binary, length);
1331 YAGL_LOG_FUNC_EXIT(NULL);
1334 YAGL_API void glShaderSource(GLuint shader, GLsizei count, const GLchar * const *string, const GLint *length)
1336 struct yagl_gles2_shader *shader_obj = NULL;
1337 int have_strings = 0;
1338 uint32_t total_length = 0;
1341 YAGL_LOG_FUNC_ENTER_SPLIT4(glShaderSource, GLuint, GLsizei, const GLchar**, const GLint*, shader, count, string, length);
1346 YAGL_SET_ERR(GL_INVALID_VALUE);
1350 shader_obj = (struct yagl_gles2_shader*)yagl_sharegroup_acquire_object(ctx->sg,
1351 YAGL_NS_SHADER_PROGRAM, shader);
1354 YAGL_SET_ERR(GL_INVALID_VALUE);
1358 if (!shader_obj->is_shader) {
1359 YAGL_SET_ERR(GL_INVALID_OPERATION);
1364 for (i = 0; i < count; ++i) {
1366 if (length && (length[i] >= 0)) {
1367 total_length += length[i];
1370 total_length += strlen(string[i]);
1379 struct yagl_glsl_state glsl_state;
1381 int patched_len = 0;
1382 char *patched_source;
1384 tmp_buff = yagl_malloc(total_length + 1);
1387 for (i = 0; i < count; ++i) {
1389 if (length && (length[i] >= 0)) {
1390 strncat((char*)tmp_buff, string[i], length[i]);
1392 strcat((char*)tmp_buff, string[i]);
1397 tmp_buff[total_length] = '\0';
1399 YAGL_LOG_TRACE("orig source = %s", tmp_buff);
1401 yagl_glsl_state_init(&glsl_state,
1405 (ctx->base.base.client_api == yagl_client_api_gles3));
1407 ret = yagl_glsl_parse(&glsl_state);
1409 if ((ret == 0) && !glsl_state.have_error) {
1410 patched_source = yagl_glsl_state_get_output(&glsl_state,
1413 YAGL_LOG_TRACE("patched source = %s", patched_source);
1415 yagl_gles2_shader_source(shader_obj,
1420 yagl_free(patched_source);
1423 * Unable to parse source, pass as-is.
1425 yagl_gles2_shader_source(shader_obj,
1431 yagl_glsl_state_cleanup(&glsl_state);
1435 yagl_gles2_shader_release(shader_obj);
1437 YAGL_LOG_FUNC_EXIT(NULL);
1440 YAGL_API void glUniform1f(GLint location, GLfloat x)
1442 YAGL_LOG_FUNC_ENTER_SPLIT2(glUniform1f, GLint, GLfloat, location, x);
1446 if (!ctx->program) {
1447 YAGL_SET_ERR(GL_INVALID_OPERATION);
1451 if (location == -1) {
1456 YAGL_SET_ERR(GL_INVALID_OPERATION);
1460 if (!yagl_gles2_program_uniform1f(ctx->program, location, x)) {
1461 YAGL_SET_ERR(GL_INVALID_OPERATION);
1466 YAGL_LOG_FUNC_EXIT(NULL);
1469 YAGL_API void glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
1471 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform1fv, GLint, GLsizei, const GLfloat*, location, count, v);
1475 if (!ctx->program) {
1476 YAGL_SET_ERR(GL_INVALID_OPERATION);
1481 YAGL_SET_ERR(GL_INVALID_VALUE);
1485 if (location == -1) {
1490 YAGL_SET_ERR(GL_INVALID_OPERATION);
1494 if (!yagl_gles2_program_uniform1fv(ctx->program, location, count, v)) {
1495 YAGL_SET_ERR(GL_INVALID_OPERATION);
1500 YAGL_LOG_FUNC_EXIT(NULL);
1503 YAGL_API void glUniform1i(GLint location, GLint x)
1505 YAGL_LOG_FUNC_ENTER_SPLIT2(glUniform1i, GLint, GLint, location, x);
1509 if (!ctx->program) {
1510 YAGL_SET_ERR(GL_INVALID_OPERATION);
1514 if (location == -1) {
1519 YAGL_SET_ERR(GL_INVALID_OPERATION);
1523 if (!yagl_gles2_program_uniform1i(ctx->program, location, x)) {
1524 YAGL_SET_ERR(GL_INVALID_OPERATION);
1529 YAGL_LOG_FUNC_EXIT(NULL);
1532 YAGL_API void glUniform1iv(GLint location, GLsizei count, const GLint* v)
1534 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform1iv, GLint, GLsizei, const GLint*, location, count, v);
1538 if (!ctx->program) {
1539 YAGL_SET_ERR(GL_INVALID_OPERATION);
1544 YAGL_SET_ERR(GL_INVALID_VALUE);
1548 if (location == -1) {
1553 YAGL_SET_ERR(GL_INVALID_OPERATION);
1557 if (!yagl_gles2_program_uniform1iv(ctx->program, location, count, v)) {
1558 YAGL_SET_ERR(GL_INVALID_OPERATION);
1563 YAGL_LOG_FUNC_EXIT(NULL);
1566 YAGL_API void glUniform2f(GLint location, GLfloat x, GLfloat y)
1568 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform2f, GLint, GLfloat, GLfloat, location, x, y);
1572 if (!ctx->program) {
1573 YAGL_SET_ERR(GL_INVALID_OPERATION);
1577 if (location == -1) {
1582 YAGL_SET_ERR(GL_INVALID_OPERATION);
1586 if (!yagl_gles2_program_uniform2f(ctx->program, location, x, y)) {
1587 YAGL_SET_ERR(GL_INVALID_OPERATION);
1592 YAGL_LOG_FUNC_EXIT(NULL);
1595 YAGL_API void glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
1597 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform2fv, GLint, GLsizei, const GLfloat*, location, count, v);
1601 if (!ctx->program) {
1602 YAGL_SET_ERR(GL_INVALID_OPERATION);
1607 YAGL_SET_ERR(GL_INVALID_VALUE);
1611 if (location == -1) {
1616 YAGL_SET_ERR(GL_INVALID_OPERATION);
1620 if (!yagl_gles2_program_uniform2fv(ctx->program, location, count, v)) {
1621 YAGL_SET_ERR(GL_INVALID_OPERATION);
1626 YAGL_LOG_FUNC_EXIT(NULL);
1629 YAGL_API void glUniform2i(GLint location, GLint x, GLint y)
1631 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform2i, GLint, GLint, GLint, location, x, y);
1635 if (!ctx->program) {
1636 YAGL_SET_ERR(GL_INVALID_OPERATION);
1640 if (location == -1) {
1645 YAGL_SET_ERR(GL_INVALID_OPERATION);
1649 if (!yagl_gles2_program_uniform2i(ctx->program, location, x, y)) {
1650 YAGL_SET_ERR(GL_INVALID_OPERATION);
1655 YAGL_LOG_FUNC_EXIT(NULL);
1658 YAGL_API void glUniform2iv(GLint location, GLsizei count, const GLint* v)
1660 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform2iv, GLint, GLsizei, const GLint*, location, count, v);
1664 if (!ctx->program) {
1665 YAGL_SET_ERR(GL_INVALID_OPERATION);
1670 YAGL_SET_ERR(GL_INVALID_VALUE);
1674 if (location == -1) {
1679 YAGL_SET_ERR(GL_INVALID_OPERATION);
1683 if (!yagl_gles2_program_uniform2iv(ctx->program, location, count, v)) {
1684 YAGL_SET_ERR(GL_INVALID_OPERATION);
1689 YAGL_LOG_FUNC_EXIT(NULL);
1692 YAGL_API void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1694 YAGL_LOG_FUNC_ENTER_SPLIT4(glUniform3f, GLint, GLfloat, GLfloat, GLfloat, location, x, y, z);
1698 if (!ctx->program) {
1699 YAGL_SET_ERR(GL_INVALID_OPERATION);
1703 if (location == -1) {
1708 YAGL_SET_ERR(GL_INVALID_OPERATION);
1712 if (!yagl_gles2_program_uniform3f(ctx->program, location, x, y, z)) {
1713 YAGL_SET_ERR(GL_INVALID_OPERATION);
1718 YAGL_LOG_FUNC_EXIT(NULL);
1721 YAGL_API void glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
1723 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform3fv, GLint, GLsizei, const GLfloat*, location, count, v);
1727 if (!ctx->program) {
1728 YAGL_SET_ERR(GL_INVALID_OPERATION);
1733 YAGL_SET_ERR(GL_INVALID_VALUE);
1737 if (location == -1) {
1742 YAGL_SET_ERR(GL_INVALID_OPERATION);
1746 if (!yagl_gles2_program_uniform3fv(ctx->program, location, count, v)) {
1747 YAGL_SET_ERR(GL_INVALID_OPERATION);
1752 YAGL_LOG_FUNC_EXIT(NULL);
1755 YAGL_API void glUniform3i(GLint location, GLint x, GLint y, GLint z)
1757 YAGL_LOG_FUNC_ENTER_SPLIT4(glUniform3i, GLint, GLint, GLint, GLint, location, x, y, z);
1761 if (!ctx->program) {
1762 YAGL_SET_ERR(GL_INVALID_OPERATION);
1766 if (location == -1) {
1771 YAGL_SET_ERR(GL_INVALID_OPERATION);
1775 if (!yagl_gles2_program_uniform3i(ctx->program, location, x, y, z)) {
1776 YAGL_SET_ERR(GL_INVALID_OPERATION);
1781 YAGL_LOG_FUNC_EXIT(NULL);
1784 YAGL_API void glUniform3iv(GLint location, GLsizei count, const GLint* v)
1786 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform3iv, GLint, GLsizei, const GLint*, location, count, v);
1790 if (!ctx->program) {
1791 YAGL_SET_ERR(GL_INVALID_OPERATION);
1796 YAGL_SET_ERR(GL_INVALID_VALUE);
1800 if (location == -1) {
1805 YAGL_SET_ERR(GL_INVALID_OPERATION);
1809 if (!yagl_gles2_program_uniform3iv(ctx->program, location, count, v)) {
1810 YAGL_SET_ERR(GL_INVALID_OPERATION);
1815 YAGL_LOG_FUNC_EXIT(NULL);
1818 YAGL_API void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1820 YAGL_LOG_FUNC_ENTER_SPLIT5(glUniform4f, GLint, GLfloat, GLfloat, GLfloat, GLfloat, location, x, y, z, w);
1824 if (!ctx->program) {
1825 YAGL_SET_ERR(GL_INVALID_OPERATION);
1829 if (location == -1) {
1834 YAGL_SET_ERR(GL_INVALID_OPERATION);
1838 if (!yagl_gles2_program_uniform4f(ctx->program, location, x, y, z, w)) {
1839 YAGL_SET_ERR(GL_INVALID_OPERATION);
1844 YAGL_LOG_FUNC_EXIT(NULL);
1847 YAGL_API void glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
1849 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform4fv, GLint, GLsizei, const GLfloat*, location, count, v);
1853 if (!ctx->program) {
1854 YAGL_SET_ERR(GL_INVALID_OPERATION);
1859 YAGL_SET_ERR(GL_INVALID_VALUE);
1863 if (location == -1) {
1868 YAGL_SET_ERR(GL_INVALID_OPERATION);
1872 if (!yagl_gles2_program_uniform4fv(ctx->program, location, count, v)) {
1873 YAGL_SET_ERR(GL_INVALID_OPERATION);
1878 YAGL_LOG_FUNC_EXIT(NULL);
1881 YAGL_API void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1883 YAGL_LOG_FUNC_ENTER_SPLIT5(glUniform4i, GLint, GLint, GLint, GLint, GLint, location, x, y, z, w);
1887 if (!ctx->program) {
1888 YAGL_SET_ERR(GL_INVALID_OPERATION);
1892 if (location == -1) {
1897 YAGL_SET_ERR(GL_INVALID_OPERATION);
1901 if (!yagl_gles2_program_uniform4i(ctx->program, location, x, y, z, w)) {
1902 YAGL_SET_ERR(GL_INVALID_OPERATION);
1907 YAGL_LOG_FUNC_EXIT(NULL);
1910 YAGL_API void glUniform4iv(GLint location, GLsizei count, const GLint* v)
1912 YAGL_LOG_FUNC_ENTER_SPLIT3(glUniform4iv, GLint, GLsizei, const GLint*, location, count, v);
1916 if (!ctx->program) {
1917 YAGL_SET_ERR(GL_INVALID_OPERATION);
1922 YAGL_SET_ERR(GL_INVALID_VALUE);
1926 if (location == -1) {
1931 YAGL_SET_ERR(GL_INVALID_OPERATION);
1935 if (!yagl_gles2_program_uniform4iv(ctx->program, location, count, v)) {
1936 YAGL_SET_ERR(GL_INVALID_OPERATION);
1941 YAGL_LOG_FUNC_EXIT(NULL);
1944 YAGL_API void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1946 YAGL_LOG_FUNC_ENTER_SPLIT4(glUniformMatrix2fv, GLint, GLsizei, GLboolean, const GLfloat*, location, count, transpose, value);
1950 if (!ctx->program) {
1951 YAGL_SET_ERR(GL_INVALID_OPERATION);
1956 YAGL_SET_ERR(GL_INVALID_VALUE);
1960 if (location == -1) {
1965 YAGL_SET_ERR(GL_INVALID_OPERATION);
1969 if (!yagl_gles2_program_uniform_matrix2fv(ctx->program, location, count, transpose, value)) {
1970 YAGL_SET_ERR(GL_INVALID_OPERATION);
1975 YAGL_LOG_FUNC_EXIT(NULL);
1978 YAGL_API void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1980 YAGL_LOG_FUNC_ENTER_SPLIT4(glUniformMatrix3fv, GLint, GLsizei, GLboolean, const GLfloat*, location, count, transpose, value);
1984 if (!ctx->program) {
1985 YAGL_SET_ERR(GL_INVALID_OPERATION);
1990 YAGL_SET_ERR(GL_INVALID_VALUE);
1994 if (location == -1) {
1999 YAGL_SET_ERR(GL_INVALID_OPERATION);
2003 if (!yagl_gles2_program_uniform_matrix3fv(ctx->program, location, count, transpose, value)) {
2004 YAGL_SET_ERR(GL_INVALID_OPERATION);
2009 YAGL_LOG_FUNC_EXIT(NULL);
2012 YAGL_API void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
2014 YAGL_LOG_FUNC_ENTER_SPLIT4(glUniformMatrix4fv, GLint, GLsizei, GLboolean, const GLfloat*, location, count, transpose, value);
2018 if (!ctx->program) {
2019 YAGL_SET_ERR(GL_INVALID_OPERATION);
2024 YAGL_SET_ERR(GL_INVALID_VALUE);
2028 if (location == -1) {
2033 YAGL_SET_ERR(GL_INVALID_OPERATION);
2037 if (!yagl_gles2_program_uniform_matrix4fv(ctx->program, location, count, transpose, value)) {
2038 YAGL_SET_ERR(GL_INVALID_OPERATION);
2043 YAGL_LOG_FUNC_EXIT(NULL);
2046 YAGL_API void glUseProgram(GLuint program)
2048 struct yagl_gles2_program *program_obj = NULL;
2050 YAGL_LOG_FUNC_ENTER_SPLIT1(glUseProgram, GLuint, program);
2055 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
2056 YAGL_NS_SHADER_PROGRAM, program);
2059 YAGL_SET_ERR(GL_INVALID_VALUE);
2063 if (program_obj->is_shader) {
2064 YAGL_SET_ERR(GL_INVALID_OPERATION);
2068 if (!program_obj->linked) {
2069 YAGL_SET_ERR(GL_INVALID_OPERATION);
2074 if (!ctx->pre_use_program(ctx, program_obj)) {
2078 yagl_gles2_context_use_program(ctx, program_obj);
2081 yagl_gles2_program_release(program_obj);
2083 YAGL_LOG_FUNC_EXIT(NULL);
2086 YAGL_API void glValidateProgram(GLuint program)
2088 struct yagl_gles2_program *program_obj = NULL;
2090 YAGL_LOG_FUNC_ENTER_SPLIT1(glValidateProgram, GLuint, program);
2094 program_obj = (struct yagl_gles2_program*)yagl_sharegroup_acquire_object(ctx->sg,
2095 YAGL_NS_SHADER_PROGRAM, program);
2098 YAGL_SET_ERR(GL_INVALID_VALUE);
2102 if (program_obj->is_shader) {
2103 YAGL_SET_ERR(GL_INVALID_OPERATION);
2107 yagl_host_glValidateProgram(program_obj->global_name);
2110 yagl_gles2_program_release(program_obj);
2112 YAGL_LOG_FUNC_EXIT(NULL);
2115 YAGL_API void glVertexAttrib1f(GLuint indx, GLfloat x)
2117 YAGL_LOG_FUNC_ENTER_SPLIT2(glVertexAttrib1f, GLuint, GLfloat, indx, x);
2122 ctx->vertex_attrib0.value.f[0] = x;
2123 ctx->vertex_attrib0.value.f[1] = 0.0f;
2124 ctx->vertex_attrib0.value.f[2] = 0.0f;
2125 ctx->vertex_attrib0.value.f[3] = 1.0f;
2126 ctx->vertex_attrib0.type = GL_FLOAT;
2128 yagl_host_glVertexAttrib1f(indx, x);
2131 YAGL_LOG_FUNC_EXIT(NULL);
2134 YAGL_API void glVertexAttrib1fv(GLuint indx, const GLfloat* values)
2136 YAGL_LOG_FUNC_ENTER_SPLIT2(glVertexAttrib1fv, GLuint, const GLfloat*, indx, values);
2141 ctx->vertex_attrib0.value.f[0] = values[0];
2142 ctx->vertex_attrib0.value.f[1] = 0.0f;
2143 ctx->vertex_attrib0.value.f[2] = 0.0f;
2144 ctx->vertex_attrib0.value.f[3] = 1.0f;
2145 ctx->vertex_attrib0.type = GL_FLOAT;
2147 yagl_host_glVertexAttrib1fv(indx, values, 1);
2150 YAGL_LOG_FUNC_EXIT(NULL);
2153 YAGL_API void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
2155 YAGL_LOG_FUNC_ENTER_SPLIT3(glVertexAttrib2f, GLuint, GLfloat, GLfloat, indx, x, y);
2160 ctx->vertex_attrib0.value.f[0] = x;
2161 ctx->vertex_attrib0.value.f[1] = y;
2162 ctx->vertex_attrib0.value.f[2] = 0.0f;
2163 ctx->vertex_attrib0.value.f[3] = 1.0f;
2164 ctx->vertex_attrib0.type = GL_FLOAT;
2166 yagl_host_glVertexAttrib2f(indx, x, y);
2169 YAGL_LOG_FUNC_EXIT(NULL);
2172 YAGL_API void glVertexAttrib2fv(GLuint indx, const GLfloat* values)
2174 YAGL_LOG_FUNC_ENTER_SPLIT2(glVertexAttrib2fv, GLuint, const GLfloat*, indx, values);
2179 ctx->vertex_attrib0.value.f[0] = values[0];
2180 ctx->vertex_attrib0.value.f[1] = values[1];
2181 ctx->vertex_attrib0.value.f[2] = 0.0f;
2182 ctx->vertex_attrib0.value.f[3] = 1.0f;
2183 ctx->vertex_attrib0.type = GL_FLOAT;
2185 yagl_host_glVertexAttrib2fv(indx, values, 2);
2188 YAGL_LOG_FUNC_EXIT(NULL);
2191 YAGL_API void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
2193 YAGL_LOG_FUNC_ENTER_SPLIT4(glVertexAttrib3f, GLuint, GLfloat, GLfloat, GLfloat, indx, x, y, z);
2198 ctx->vertex_attrib0.value.f[0] = x;
2199 ctx->vertex_attrib0.value.f[1] = y;
2200 ctx->vertex_attrib0.value.f[2] = z;
2201 ctx->vertex_attrib0.value.f[3] = 1.0f;
2202 ctx->vertex_attrib0.type = GL_FLOAT;
2204 yagl_host_glVertexAttrib3f(indx, x, y, z);
2207 YAGL_LOG_FUNC_EXIT(NULL);
2210 YAGL_API void glVertexAttrib3fv(GLuint indx, const GLfloat* values)
2212 YAGL_LOG_FUNC_ENTER_SPLIT2(glVertexAttrib3fv, GLuint, const GLfloat*, indx, values);
2217 ctx->vertex_attrib0.value.f[0] = values[0];
2218 ctx->vertex_attrib0.value.f[1] = values[1];
2219 ctx->vertex_attrib0.value.f[2] = values[2];
2220 ctx->vertex_attrib0.value.f[3] = 1.0f;
2221 ctx->vertex_attrib0.type = GL_FLOAT;
2223 yagl_host_glVertexAttrib3fv(indx, values, 3);
2226 YAGL_LOG_FUNC_EXIT(NULL);
2229 YAGL_API void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
2231 YAGL_LOG_FUNC_ENTER_SPLIT5(glVertexAttrib4f, GLuint, GLfloat, GLfloat, GLfloat, GLfloat, indx, x, y, z, w);
2236 ctx->vertex_attrib0.value.f[0] = x;
2237 ctx->vertex_attrib0.value.f[1] = y;
2238 ctx->vertex_attrib0.value.f[2] = z;
2239 ctx->vertex_attrib0.value.f[3] = w;
2240 ctx->vertex_attrib0.type = GL_FLOAT;
2242 yagl_host_glVertexAttrib4f(indx, x, y, z, w);
2245 YAGL_LOG_FUNC_EXIT(NULL);
2248 YAGL_API void glVertexAttrib4fv(GLuint indx, const GLfloat* values)
2250 YAGL_LOG_FUNC_ENTER_SPLIT2(glVertexAttrib4fv, GLuint, const GLfloat*, indx, values);
2255 ctx->vertex_attrib0.value.f[0] = values[0];
2256 ctx->vertex_attrib0.value.f[1] = values[1];
2257 ctx->vertex_attrib0.value.f[2] = values[2];
2258 ctx->vertex_attrib0.value.f[3] = values[3];
2259 ctx->vertex_attrib0.type = GL_FLOAT;
2261 yagl_host_glVertexAttrib4fv(indx, values, 4);
2264 YAGL_LOG_FUNC_EXIT(NULL);
2267 YAGL_API void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
2269 struct yagl_gles_array *array;
2271 YAGL_LOG_FUNC_ENTER_SPLIT6(glVertexAttribPointer, GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*, indx, size, type, normalized, stride, ptr);
2275 if (indx >= ctx->base.num_arrays) {
2276 YAGL_SET_ERR(GL_INVALID_VALUE);
2280 if ((stride < 0) || (size < 1) || (size > 4)) {
2281 YAGL_SET_ERR(GL_INVALID_VALUE);
2285 if ((type == GL_INT_2_10_10_10_REV) ||
2286 (type == GL_UNSIGNED_INT_2_10_10_10_REV)) {
2287 if (ctx->base.base.client_api == yagl_client_api_gles2) {
2288 YAGL_SET_ERR(GL_INVALID_ENUM);
2290 } else if (size != 4) {
2291 YAGL_SET_ERR(GL_INVALID_OPERATION);
2296 array = &ctx->base.vao->arrays[indx];
2298 if (ctx->base.vbo) {
2299 if (!yagl_gles_array_update_vbo(array,
2308 YAGL_SET_ERR(GL_INVALID_ENUM);
2312 * GL_OES_vertex_array_object:
2313 * "Binding a zero-named vertex array buffer:
2314 * this can be detected by *Pointer(ES1) or VertexAttribPointer(ES2);
2315 * if the pointer argument is not NULL:
2316 * this means to bind a client vertex array;
2317 * an INVALID_OPERATION error will be returned."
2319 if ((ctx->base.vao != ctx->base.va_zero) && ptr) {
2320 YAGL_SET_ERR(GL_INVALID_OPERATION);
2324 if (!yagl_gles_array_update(array,
2332 YAGL_SET_ERR(GL_INVALID_ENUM);
2337 YAGL_LOG_FUNC_EXIT(NULL);
2341 * GL_EXT_instanced_arrays.
2345 YAGL_API void glDrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
2348 YAGL_LOG_FUNC_ENTER_SPLIT4(glDrawArraysInstanced, GLenum, GLint, GLsizei, GLsizei, mode, start, count, primcount);
2352 if (!ctx->instanced_arrays) {
2353 YAGL_SET_ERR(GL_INVALID_OPERATION);
2357 if (primcount < 0) {
2358 YAGL_SET_ERR(GL_INVALID_VALUE);
2362 yagl_gles_context_draw_arrays(&ctx->base, mode, start, count, primcount);
2365 YAGL_LOG_FUNC_EXIT(NULL);
2367 YAGL_API YAGL_ALIAS(glDrawArraysInstanced, glDrawArraysInstancedEXT);
2369 YAGL_API void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
2370 const void *indices, GLsizei primcount)
2372 YAGL_LOG_FUNC_ENTER_SPLIT5(glDrawElementsInstanced, GLenum, GLsizei, GLenum, const void*, GLsizei, mode, count, type, indices, primcount);
2376 if (!ctx->instanced_arrays) {
2377 YAGL_SET_ERR(GL_INVALID_OPERATION);
2381 if (primcount < 0) {
2382 YAGL_SET_ERR(GL_INVALID_VALUE);
2386 yagl_gles_context_draw_elements(&ctx->base, mode, count, type, indices, primcount);
2389 YAGL_LOG_FUNC_EXIT(NULL);
2391 YAGL_API YAGL_ALIAS(glDrawElementsInstanced, glDrawElementsInstancedEXT);
2393 YAGL_API void glVertexAttribDivisor(GLuint index, GLuint divisor)
2395 struct yagl_gles_array *array;
2397 YAGL_LOG_FUNC_ENTER_SPLIT2(glVertexAttribDivisor, GLuint, GLuint, index, divisor);
2401 if (!ctx->instanced_arrays) {
2402 YAGL_SET_ERR(GL_INVALID_OPERATION);
2406 if (index >= ctx->base.num_arrays) {
2407 YAGL_SET_ERR(GL_INVALID_VALUE);
2411 array = &ctx->base.vao->arrays[index];
2413 yagl_gles_array_set_divisor(array, divisor);
2416 YAGL_LOG_FUNC_EXIT(NULL);
2418 YAGL_API YAGL_ALIAS(glVertexAttribDivisor, glVertexAttribDivisorEXT);
2425 * GL_OES_texture_3D.
2429 YAGL_API void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels)
2431 yagl_gles_texture_target texture_target;
2432 struct yagl_gles_texture_target_state *tex_target_state;
2433 struct yagl_pixel_format *pf;
2437 YAGL_LOG_FUNC_ENTER_SPLIT10(glTexImage3D, GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const void*, target, level, internalformat, width, height, depth, border, format, type, pixels);
2441 if (!yagl_gles_context_validate_texture_target(&ctx->base,
2444 YAGL_SET_ERR(GL_INVALID_ENUM);
2448 if (!yagl_gles2_is_texture_target_layered(target)) {
2449 YAGL_SET_ERR(GL_INVALID_ENUM);
2454 yagl_gles_context_get_active_texture_target_state(&ctx->base,
2457 if ((width < 0) || (height < 0) || (depth < 0)) {
2458 YAGL_SET_ERR(GL_INVALID_VALUE);
2462 if ((width == 0) || (height == 0) || (depth == 0)) {
2463 width = height = depth = 0;
2466 pf = yagl_gles_context_validate_teximage_format(&ctx->base,
2472 YAGL_SET_ERR(GL_INVALID_OPERATION);
2476 if ((texture_target == yagl_gles_texture_target_3d) &&
2477 ((pf->src_format == GL_DEPTH_COMPONENT) ||
2478 (pf->src_format == GL_DEPTH_STENCIL_OES))) {
2479 YAGL_SET_ERR(GL_INVALID_OPERATION);
2483 if ((width != 0) && !yagl_gles_context_pre_unpack(&ctx->base, &pixels, pf->need_convert, &using_pbo)) {
2484 YAGL_SET_ERR(GL_INVALID_OPERATION);
2488 if (pixels || using_pbo) {
2489 pixels += yagl_pixel_format_get_info(pf, &ctx->base.unpack,
2490 width, height, depth, &size);
2492 yagl_pixel_format_get_info(pf, &ctx->base.unpack,
2493 width, height, depth, &size);
2497 yagl_host_glTexImage3DOffset(target,
2499 pf->dst_internalformat,
2508 yagl_host_glTexImage3DData(target,
2510 pf->dst_internalformat,
2517 yagl_pixel_format_unpack(pf,
2527 yagl_gles_context_post_unpack(&ctx->base, pf->need_convert);
2530 yagl_gles_texture_set_internalformat(tex_target_state->texture,
2533 yagl_gles_context_convert_textures(&ctx->base));
2536 YAGL_LOG_FUNC_EXIT(NULL);
2538 YAGL_API YAGL_ALIAS(glTexImage3D, glTexImage3DOES);
2540 YAGL_API void glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels)
2542 yagl_gles_texture_target texture_target;
2543 struct yagl_gles_texture_target_state *tex_target_state;
2544 struct yagl_pixel_format *pf;
2548 YAGL_LOG_FUNC_ENTER_SPLIT11(glTexSubImage3D, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const void*, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
2552 if (!yagl_gles_context_validate_texture_target(&ctx->base,
2555 YAGL_SET_ERR(GL_INVALID_ENUM);
2559 if (!yagl_gles2_is_texture_target_layered(target)) {
2560 YAGL_SET_ERR(GL_INVALID_ENUM);
2565 yagl_gles_context_get_active_texture_target_state(&ctx->base,
2568 if ((width < 0) || (height < 0) || (depth < 0)) {
2569 YAGL_SET_ERR(GL_INVALID_VALUE);
2573 if ((width == 0) || (height == 0) || (depth == 0)) {
2574 width = height = depth = 0;
2577 pf = yagl_gles_context_validate_teximage_format(&ctx->base,
2578 tex_target_state->texture->internalformat, format, type);
2581 YAGL_SET_ERR(GL_INVALID_OPERATION);
2585 if ((width != 0) && !yagl_gles_context_pre_unpack(&ctx->base, &pixels, pf->need_convert, &using_pbo)) {
2586 YAGL_SET_ERR(GL_INVALID_OPERATION);
2590 pixels += yagl_pixel_format_get_info(pf, &ctx->base.unpack,
2591 width, height, depth, &size);
2594 yagl_host_glTexSubImage3DOffset(target,
2606 yagl_host_glTexSubImage3DData(target,
2616 yagl_pixel_format_unpack(pf,
2626 yagl_gles_context_post_unpack(&ctx->base, pf->need_convert);
2630 YAGL_LOG_FUNC_EXIT(NULL);
2632 YAGL_API YAGL_ALIAS(glTexSubImage3D, glTexSubImage3DOES);
2634 YAGL_API void glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
2636 yagl_gles_texture_target texture_target;
2638 YAGL_LOG_FUNC_ENTER_SPLIT9(glCopyTexSubImage3D, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, target, level, xoffset, yoffset, zoffset, x, y, width, height);
2642 if (!yagl_gles_context_validate_texture_target(&ctx->base,
2645 YAGL_SET_ERR(GL_INVALID_ENUM);
2649 if (!yagl_gles2_is_texture_target_layered(target)) {
2650 YAGL_SET_ERR(GL_INVALID_ENUM);
2654 yagl_host_glCopyTexSubImage3D(target,
2665 YAGL_LOG_FUNC_EXIT(NULL);
2667 YAGL_API YAGL_ALIAS(glCopyTexSubImage3D, glCopyTexSubImage3DOES);
2669 YAGL_API void glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data)
2671 yagl_gles_texture_target texture_target;
2672 struct yagl_gles_texture_target_state *tex_target_state;
2675 YAGL_LOG_FUNC_ENTER_SPLIT9(glCompressedTexImage3D, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*, target, level, internalformat, width, height, depth, border, imageSize, data);
2679 if (!yagl_gles_context_validate_texture_target(&ctx->base,
2682 YAGL_SET_ERR(GL_INVALID_ENUM);
2686 if (!yagl_gles2_is_texture_target_layered(target)) {
2687 YAGL_SET_ERR(GL_INVALID_ENUM);
2692 yagl_gles_context_get_active_texture_target_state(&ctx->base,
2695 if ((width < 0) || (height < 0) || (depth < 0)) {
2696 YAGL_SET_ERR(GL_INVALID_VALUE);
2700 if ((width == 0) || (height == 0) || (depth == 0)) {
2701 width = height = depth = 0;
2704 if ((width != 0) && !yagl_gles_context_pre_unpack(&ctx->base, &data, 1, &using_pbo)) {
2705 YAGL_SET_ERR(GL_INVALID_OPERATION);
2711 yagl_gles2_context_compressed_tex_image_3d(ctx,
2713 tex_target_state->texture,
2724 yagl_gles_context_post_unpack(&ctx->base, 1);
2728 YAGL_LOG_FUNC_EXIT(NULL);
2730 YAGL_API YAGL_ALIAS(glCompressedTexImage3D, glCompressedTexImage3DOES);
2732 YAGL_API void glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data)
2734 yagl_gles_texture_target texture_target;
2737 YAGL_LOG_FUNC_ENTER_SPLIT11(glCompressedTexSubImage3D, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*, target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
2741 if (!yagl_gles_context_validate_texture_target(&ctx->base,
2744 YAGL_SET_ERR(GL_INVALID_ENUM);
2748 if (!yagl_gles2_is_texture_target_layered(target)) {
2749 YAGL_SET_ERR(GL_INVALID_ENUM);
2753 if ((width < 0) || (height < 0) || (depth < 0)) {
2754 YAGL_SET_ERR(GL_INVALID_VALUE);
2758 if ((width == 0) || (height == 0) || (depth == 0)) {
2759 width = height = depth = 0;
2762 if ((width != 0) && !yagl_gles_context_pre_unpack(&ctx->base, &data, 1, &using_pbo)) {
2763 YAGL_SET_ERR(GL_INVALID_OPERATION);
2769 yagl_gles2_context_compressed_tex_sub_image_3d(ctx,
2783 yagl_gles_context_post_unpack(&ctx->base, 1);
2787 YAGL_LOG_FUNC_EXIT(NULL);
2789 YAGL_API YAGL_ALIAS(glCompressedTexSubImage3D, glCompressedTexSubImage3DOES);
2791 YAGL_API void glFramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
2793 fprintf(stderr, "glFramebufferTexture3D not supported in YaGL\n");
2795 YAGL_API YAGL_ALIAS(glFramebufferTexture3D, glFramebufferTexture3DOES);
2802 * GL_EXT_texture_storage.
2806 YAGL_API void glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
2808 yagl_gles_texture_target texture_target;
2809 struct yagl_gles_texture_target_state *tex_target_state;
2810 GLenum base_internalformat, format, type;
2813 YAGL_LOG_FUNC_ENTER_SPLIT6(glTexStorage3D, GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei, target, levels, internalformat, width, height, depth);
2817 if ((levels <= 0) || (width <= 0) || (height <= 0)) {
2818 YAGL_SET_ERR(GL_INVALID_VALUE);
2822 if (!yagl_gles_context_validate_texstorage_format(&ctx->base,
2824 &base_internalformat,
2827 YAGL_SET_ERR(GL_INVALID_ENUM);
2831 if (!yagl_gles_context_validate_texture_target(&ctx->base, target, &texture_target)) {
2832 YAGL_SET_ERR(GL_INVALID_ENUM);
2836 tex_target_state = yagl_gles_context_get_active_texture_target_state(&ctx->base,
2839 if ((tex_target_state->texture == tex_target_state->texture_zero) ||
2840 tex_target_state->texture->immutable) {
2841 YAGL_SET_ERR(GL_INVALID_OPERATION);
2845 if ((texture_target == yagl_gles_texture_target_3d) &&
2846 ((format == GL_DEPTH_COMPONENT) ||
2847 (format == GL_DEPTH_STENCIL_OES))) {
2848 YAGL_SET_ERR(GL_INVALID_OPERATION);
2852 switch (texture_target) {
2853 case yagl_gles_texture_target_3d:
2854 for (i = 0; i < levels; ++i) {
2855 yagl_host_glTexImage3DData(target, i, internalformat,
2856 width, height, depth, 0, format, type,
2875 case yagl_gles_texture_target_2d_array:
2876 for (i = 0; i < levels; ++i) {
2877 yagl_host_glTexImage3DData(target, i, internalformat,
2878 width, height, depth, 0, format, type,
2893 YAGL_SET_ERR(GL_INVALID_ENUM);
2897 yagl_gles_texture_set_immutable(tex_target_state->texture,
2898 base_internalformat,
2900 yagl_gles_context_convert_textures(&ctx->base));
2903 YAGL_LOG_FUNC_EXIT(NULL);
2905 YAGL_API YAGL_ALIAS(glTexStorage3D, glTexStorage3DEXT);