1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/logging.h"
6 #include "mojo/examples/pepper_container_app/graphics_3d_resource.h"
7 #include "mojo/examples/pepper_container_app/thunk.h"
8 #include "mojo/public/c/gles2/gles2.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_graphics_3d_api.h"
17 typedef ppapi::thunk::EnterResource
<ppapi::thunk::PPB_Graphics3D_API
> Enter3D
;
19 bool IsBoundGraphics(Enter3D
* enter
) {
20 return enter
->succeeded() &&
21 static_cast<Graphics3DResource
*>(enter
->object())->IsBoundGraphics();
24 void ActiveTexture(PP_Resource context_id
, GLenum texture
) {
25 Enter3D
enter(context_id
, true);
26 if (IsBoundGraphics(&enter
)) {
27 glActiveTexture(texture
);
31 void AttachShader(PP_Resource context_id
, GLuint program
, GLuint shader
) {
32 Enter3D
enter(context_id
, true);
33 if (IsBoundGraphics(&enter
)) {
34 glAttachShader(program
, shader
);
38 void BindAttribLocation(PP_Resource context_id
,
42 Enter3D
enter(context_id
, true);
43 if (IsBoundGraphics(&enter
)) {
44 glBindAttribLocation(program
, index
, name
);
48 void BindBuffer(PP_Resource context_id
, GLenum target
, GLuint buffer
) {
49 Enter3D
enter(context_id
, true);
50 if (IsBoundGraphics(&enter
)) {
51 glBindBuffer(target
, buffer
);
55 void BindFramebuffer(PP_Resource context_id
,
58 Enter3D
enter(context_id
, true);
59 if (IsBoundGraphics(&enter
)) {
60 glBindFramebuffer(target
, framebuffer
);
64 void BindRenderbuffer(PP_Resource context_id
,
66 GLuint renderbuffer
) {
67 Enter3D
enter(context_id
, true);
68 if (IsBoundGraphics(&enter
)) {
69 glBindRenderbuffer(target
, renderbuffer
);
73 void BindTexture(PP_Resource context_id
, GLenum target
, GLuint texture
) {
74 Enter3D
enter(context_id
, true);
75 if (IsBoundGraphics(&enter
)) {
76 glBindTexture(target
, texture
);
80 void BlendColor(PP_Resource context_id
,
85 Enter3D
enter(context_id
, true);
86 if (IsBoundGraphics(&enter
)) {
87 glBlendColor(red
, green
, blue
, alpha
);
91 void BlendEquation(PP_Resource context_id
, GLenum mode
) {
92 Enter3D
enter(context_id
, true);
93 if (IsBoundGraphics(&enter
)) {
94 glBlendEquation(mode
);
98 void BlendEquationSeparate(PP_Resource context_id
,
101 Enter3D
enter(context_id
, true);
102 if (IsBoundGraphics(&enter
)) {
103 glBlendEquationSeparate(modeRGB
, modeAlpha
);
107 void BlendFunc(PP_Resource context_id
, GLenum sfactor
, GLenum dfactor
) {
108 Enter3D
enter(context_id
, true);
109 if (IsBoundGraphics(&enter
)) {
110 glBlendFunc(sfactor
, dfactor
);
114 void BlendFuncSeparate(PP_Resource context_id
,
119 Enter3D
enter(context_id
, true);
120 if (IsBoundGraphics(&enter
)) {
121 glBlendFuncSeparate(srcRGB
, dstRGB
, srcAlpha
, dstAlpha
);
125 void BufferData(PP_Resource context_id
,
130 Enter3D
enter(context_id
, true);
131 if (IsBoundGraphics(&enter
)) {
132 glBufferData(target
, size
, data
, usage
);
136 void BufferSubData(PP_Resource context_id
,
141 Enter3D
enter(context_id
, true);
142 if (IsBoundGraphics(&enter
)) {
143 glBufferSubData(target
, offset
, size
, data
);
147 GLenum
CheckFramebufferStatus(PP_Resource context_id
, GLenum target
) {
148 Enter3D
enter(context_id
, true);
149 if (IsBoundGraphics(&enter
)) {
150 return glCheckFramebufferStatus(target
);
156 void Clear(PP_Resource context_id
, GLbitfield mask
) {
157 Enter3D
enter(context_id
, true);
158 if (IsBoundGraphics(&enter
)) {
163 void ClearColor(PP_Resource context_id
,
168 Enter3D
enter(context_id
, true);
169 if (IsBoundGraphics(&enter
)) {
170 glClearColor(red
, green
, blue
, alpha
);
174 void ClearDepthf(PP_Resource context_id
, GLclampf depth
) {
175 Enter3D
enter(context_id
, true);
176 if (IsBoundGraphics(&enter
)) {
177 glClearDepthf(depth
);
181 void ClearStencil(PP_Resource context_id
, GLint s
) {
182 Enter3D
enter(context_id
, true);
183 if (IsBoundGraphics(&enter
)) {
188 void ColorMask(PP_Resource context_id
,
193 Enter3D
enter(context_id
, true);
194 if (IsBoundGraphics(&enter
)) {
195 glColorMask(red
, green
, blue
, alpha
);
199 void CompileShader(PP_Resource context_id
, GLuint shader
) {
200 Enter3D
enter(context_id
, true);
201 if (IsBoundGraphics(&enter
)) {
202 glCompileShader(shader
);
206 void CompressedTexImage2D(PP_Resource context_id
,
209 GLenum internalformat
,
215 Enter3D
enter(context_id
, true);
216 if (IsBoundGraphics(&enter
)) {
217 glCompressedTexImage2D(
218 target
, level
, internalformat
, width
, height
, border
, imageSize
, data
);
222 void CompressedTexSubImage2D(PP_Resource context_id
,
232 Enter3D
enter(context_id
, true);
233 if (IsBoundGraphics(&enter
)) {
234 glCompressedTexSubImage2D(target
,
246 void CopyTexImage2D(PP_Resource context_id
,
249 GLenum internalformat
,
255 Enter3D
enter(context_id
, true);
256 if (IsBoundGraphics(&enter
)) {
258 target
, level
, internalformat
, x
, y
, width
, height
, border
);
262 void CopyTexSubImage2D(PP_Resource context_id
,
271 Enter3D
enter(context_id
, true);
272 if (IsBoundGraphics(&enter
)) {
273 glCopyTexSubImage2D(target
, level
, xoffset
, yoffset
, x
, y
, width
, height
);
277 GLuint
CreateProgram(PP_Resource context_id
) {
278 Enter3D
enter(context_id
, true);
279 if (IsBoundGraphics(&enter
)) {
280 return glCreateProgram();
286 GLuint
CreateShader(PP_Resource context_id
, GLenum type
) {
287 Enter3D
enter(context_id
, true);
288 if (IsBoundGraphics(&enter
)) {
289 return glCreateShader(type
);
295 void CullFace(PP_Resource context_id
, GLenum mode
) {
296 Enter3D
enter(context_id
, true);
297 if (IsBoundGraphics(&enter
)) {
302 void DeleteBuffers(PP_Resource context_id
, GLsizei n
, const GLuint
* buffers
) {
303 Enter3D
enter(context_id
, true);
304 if (IsBoundGraphics(&enter
)) {
305 glDeleteBuffers(n
, buffers
);
309 void DeleteFramebuffers(PP_Resource context_id
,
311 const GLuint
* framebuffers
) {
312 Enter3D
enter(context_id
, true);
313 if (IsBoundGraphics(&enter
)) {
314 glDeleteFramebuffers(n
, framebuffers
);
318 void DeleteProgram(PP_Resource context_id
, GLuint program
) {
319 Enter3D
enter(context_id
, true);
320 if (IsBoundGraphics(&enter
)) {
321 glDeleteProgram(program
);
325 void DeleteRenderbuffers(PP_Resource context_id
,
327 const GLuint
* renderbuffers
) {
328 Enter3D
enter(context_id
, true);
329 if (IsBoundGraphics(&enter
)) {
330 glDeleteRenderbuffers(n
, renderbuffers
);
334 void DeleteShader(PP_Resource context_id
, GLuint shader
) {
335 Enter3D
enter(context_id
, true);
336 if (IsBoundGraphics(&enter
)) {
337 glDeleteShader(shader
);
341 void DeleteTextures(PP_Resource context_id
, GLsizei n
, const GLuint
* textures
) {
342 Enter3D
enter(context_id
, true);
343 if (IsBoundGraphics(&enter
)) {
344 glDeleteTextures(n
, textures
);
348 void DepthFunc(PP_Resource context_id
, GLenum func
) {
349 Enter3D
enter(context_id
, true);
350 if (IsBoundGraphics(&enter
)) {
355 void DepthMask(PP_Resource context_id
, GLboolean flag
) {
356 Enter3D
enter(context_id
, true);
357 if (IsBoundGraphics(&enter
)) {
362 void DepthRangef(PP_Resource context_id
, GLclampf zNear
, GLclampf zFar
) {
363 Enter3D
enter(context_id
, true);
364 if (IsBoundGraphics(&enter
)) {
365 glDepthRangef(zNear
, zFar
);
369 void DetachShader(PP_Resource context_id
, GLuint program
, GLuint shader
) {
370 Enter3D
enter(context_id
, true);
371 if (IsBoundGraphics(&enter
)) {
372 glDetachShader(program
, shader
);
376 void Disable(PP_Resource context_id
, GLenum cap
) {
377 Enter3D
enter(context_id
, true);
378 if (IsBoundGraphics(&enter
)) {
383 void DisableVertexAttribArray(PP_Resource context_id
, GLuint index
) {
384 Enter3D
enter(context_id
, true);
385 if (IsBoundGraphics(&enter
)) {
386 glDisableVertexAttribArray(index
);
390 void DrawArrays(PP_Resource context_id
,
394 Enter3D
enter(context_id
, true);
395 if (IsBoundGraphics(&enter
)) {
396 glDrawArrays(mode
, first
, count
);
400 void DrawElements(PP_Resource context_id
,
404 const void* indices
) {
405 Enter3D
enter(context_id
, true);
406 if (IsBoundGraphics(&enter
)) {
407 glDrawElements(mode
, count
, type
, indices
);
411 void Enable(PP_Resource context_id
, GLenum cap
) {
412 Enter3D
enter(context_id
, true);
413 if (IsBoundGraphics(&enter
)) {
418 void EnableVertexAttribArray(PP_Resource context_id
, GLuint index
) {
419 Enter3D
enter(context_id
, true);
420 if (IsBoundGraphics(&enter
)) {
421 glEnableVertexAttribArray(index
);
425 void Finish(PP_Resource context_id
) {
426 Enter3D
enter(context_id
, true);
427 if (IsBoundGraphics(&enter
)) {
432 void Flush(PP_Resource context_id
) {
433 Enter3D
enter(context_id
, true);
434 if (IsBoundGraphics(&enter
)) {
439 void FramebufferRenderbuffer(PP_Resource context_id
,
442 GLenum renderbuffertarget
,
443 GLuint renderbuffer
) {
444 Enter3D
enter(context_id
, true);
445 if (IsBoundGraphics(&enter
)) {
446 glFramebufferRenderbuffer(
447 target
, attachment
, renderbuffertarget
, renderbuffer
);
451 void FramebufferTexture2D(PP_Resource context_id
,
457 Enter3D
enter(context_id
, true);
458 if (IsBoundGraphics(&enter
)) {
459 glFramebufferTexture2D(target
, attachment
, textarget
, texture
, level
);
463 void FrontFace(PP_Resource context_id
, GLenum mode
) {
464 Enter3D
enter(context_id
, true);
465 if (IsBoundGraphics(&enter
)) {
470 void GenBuffers(PP_Resource context_id
, GLsizei n
, GLuint
* buffers
) {
471 Enter3D
enter(context_id
, true);
472 if (IsBoundGraphics(&enter
)) {
473 glGenBuffers(n
, buffers
);
477 void GenerateMipmap(PP_Resource context_id
, GLenum target
) {
478 Enter3D
enter(context_id
, true);
479 if (IsBoundGraphics(&enter
)) {
480 glGenerateMipmap(target
);
484 void GenFramebuffers(PP_Resource context_id
, GLsizei n
, GLuint
* framebuffers
) {
485 Enter3D
enter(context_id
, true);
486 if (IsBoundGraphics(&enter
)) {
487 glGenFramebuffers(n
, framebuffers
);
491 void GenRenderbuffers(PP_Resource context_id
,
493 GLuint
* renderbuffers
) {
494 Enter3D
enter(context_id
, true);
495 if (IsBoundGraphics(&enter
)) {
496 glGenRenderbuffers(n
, renderbuffers
);
500 void GenTextures(PP_Resource context_id
, GLsizei n
, GLuint
* textures
) {
501 Enter3D
enter(context_id
, true);
502 if (IsBoundGraphics(&enter
)) {
503 glGenTextures(n
, textures
);
507 void GetActiveAttrib(PP_Resource context_id
,
515 Enter3D
enter(context_id
, true);
516 if (IsBoundGraphics(&enter
)) {
517 glGetActiveAttrib(program
, index
, bufsize
, length
, size
, type
, name
);
521 void GetActiveUniform(PP_Resource context_id
,
529 Enter3D
enter(context_id
, true);
530 if (IsBoundGraphics(&enter
)) {
531 glGetActiveUniform(program
, index
, bufsize
, length
, size
, type
, name
);
535 void GetAttachedShaders(PP_Resource context_id
,
540 Enter3D
enter(context_id
, true);
541 if (IsBoundGraphics(&enter
)) {
542 glGetAttachedShaders(program
, maxcount
, count
, shaders
);
546 GLint
GetAttribLocation(PP_Resource context_id
,
549 Enter3D
enter(context_id
, true);
550 if (IsBoundGraphics(&enter
)) {
551 return glGetAttribLocation(program
, name
);
557 void GetBooleanv(PP_Resource context_id
, GLenum pname
, GLboolean
* params
) {
558 Enter3D
enter(context_id
, true);
559 if (IsBoundGraphics(&enter
)) {
560 glGetBooleanv(pname
, params
);
564 void GetBufferParameteriv(PP_Resource context_id
,
568 Enter3D
enter(context_id
, true);
569 if (IsBoundGraphics(&enter
)) {
570 glGetBufferParameteriv(target
, pname
, params
);
574 GLenum
GetError(PP_Resource context_id
) {
575 Enter3D
enter(context_id
, true);
576 if (IsBoundGraphics(&enter
)) {
583 void GetFloatv(PP_Resource context_id
, GLenum pname
, GLfloat
* params
) {
584 Enter3D
enter(context_id
, true);
585 if (IsBoundGraphics(&enter
)) {
586 glGetFloatv(pname
, params
);
590 void GetFramebufferAttachmentParameteriv(PP_Resource context_id
,
595 Enter3D
enter(context_id
, true);
596 if (IsBoundGraphics(&enter
)) {
597 glGetFramebufferAttachmentParameteriv(target
, attachment
, pname
, params
);
601 void GetIntegerv(PP_Resource context_id
, GLenum pname
, GLint
* params
) {
602 Enter3D
enter(context_id
, true);
603 if (IsBoundGraphics(&enter
)) {
604 glGetIntegerv(pname
, params
);
608 void GetProgramiv(PP_Resource context_id
,
612 Enter3D
enter(context_id
, true);
613 if (IsBoundGraphics(&enter
)) {
614 glGetProgramiv(program
, pname
, params
);
618 void GetProgramInfoLog(PP_Resource context_id
,
623 Enter3D
enter(context_id
, true);
624 if (IsBoundGraphics(&enter
)) {
625 glGetProgramInfoLog(program
, bufsize
, length
, infolog
);
629 void GetRenderbufferParameteriv(PP_Resource context_id
,
633 Enter3D
enter(context_id
, true);
634 if (IsBoundGraphics(&enter
)) {
635 glGetRenderbufferParameteriv(target
, pname
, params
);
639 void GetShaderiv(PP_Resource context_id
,
643 Enter3D
enter(context_id
, true);
644 if (IsBoundGraphics(&enter
)) {
645 glGetShaderiv(shader
, pname
, params
);
649 void GetShaderInfoLog(PP_Resource context_id
,
654 Enter3D
enter(context_id
, true);
655 if (IsBoundGraphics(&enter
)) {
656 glGetShaderInfoLog(shader
, bufsize
, length
, infolog
);
660 void GetShaderPrecisionFormat(PP_Resource context_id
,
662 GLenum precisiontype
,
665 Enter3D
enter(context_id
, true);
666 if (IsBoundGraphics(&enter
)) {
667 glGetShaderPrecisionFormat(shadertype
, precisiontype
, range
, precision
);
671 void GetShaderSource(PP_Resource context_id
,
676 Enter3D
enter(context_id
, true);
677 if (IsBoundGraphics(&enter
)) {
678 glGetShaderSource(shader
, bufsize
, length
, source
);
682 const GLubyte
* GetString(PP_Resource context_id
, GLenum name
) {
683 Enter3D
enter(context_id
, true);
684 if (IsBoundGraphics(&enter
)) {
685 return glGetString(name
);
691 void GetTexParameterfv(PP_Resource context_id
,
695 Enter3D
enter(context_id
, true);
696 if (IsBoundGraphics(&enter
)) {
697 glGetTexParameterfv(target
, pname
, params
);
701 void GetTexParameteriv(PP_Resource context_id
,
705 Enter3D
enter(context_id
, true);
706 if (IsBoundGraphics(&enter
)) {
707 glGetTexParameteriv(target
, pname
, params
);
711 void GetUniformfv(PP_Resource context_id
,
715 Enter3D
enter(context_id
, true);
716 if (IsBoundGraphics(&enter
)) {
717 glGetUniformfv(program
, location
, params
);
721 void GetUniformiv(PP_Resource context_id
,
725 Enter3D
enter(context_id
, true);
726 if (IsBoundGraphics(&enter
)) {
727 glGetUniformiv(program
, location
, params
);
731 GLint
GetUniformLocation(PP_Resource context_id
,
734 Enter3D
enter(context_id
, true);
735 if (IsBoundGraphics(&enter
)) {
736 return glGetUniformLocation(program
, name
);
742 void GetVertexAttribfv(PP_Resource context_id
,
746 Enter3D
enter(context_id
, true);
747 if (IsBoundGraphics(&enter
)) {
748 glGetVertexAttribfv(index
, pname
, params
);
752 void GetVertexAttribiv(PP_Resource context_id
,
756 Enter3D
enter(context_id
, true);
757 if (IsBoundGraphics(&enter
)) {
758 glGetVertexAttribiv(index
, pname
, params
);
762 void GetVertexAttribPointerv(PP_Resource context_id
,
766 Enter3D
enter(context_id
, true);
767 if (IsBoundGraphics(&enter
)) {
768 glGetVertexAttribPointerv(index
, pname
, pointer
);
772 void Hint(PP_Resource context_id
, GLenum target
, GLenum mode
) {
773 Enter3D
enter(context_id
, true);
774 if (IsBoundGraphics(&enter
)) {
775 glHint(target
, mode
);
779 GLboolean
IsBuffer(PP_Resource context_id
, GLuint buffer
) {
780 Enter3D
enter(context_id
, true);
781 if (IsBoundGraphics(&enter
)) {
782 return glIsBuffer(buffer
);
788 GLboolean
IsEnabled(PP_Resource context_id
, GLenum cap
) {
789 Enter3D
enter(context_id
, true);
790 if (IsBoundGraphics(&enter
)) {
791 return glIsEnabled(cap
);
797 GLboolean
IsFramebuffer(PP_Resource context_id
, GLuint framebuffer
) {
798 Enter3D
enter(context_id
, true);
799 if (IsBoundGraphics(&enter
)) {
800 return glIsFramebuffer(framebuffer
);
806 GLboolean
IsProgram(PP_Resource context_id
, GLuint program
) {
807 Enter3D
enter(context_id
, true);
808 if (IsBoundGraphics(&enter
)) {
809 return glIsProgram(program
);
815 GLboolean
IsRenderbuffer(PP_Resource context_id
, GLuint renderbuffer
) {
816 Enter3D
enter(context_id
, true);
817 if (IsBoundGraphics(&enter
)) {
818 return glIsRenderbuffer(renderbuffer
);
824 GLboolean
IsShader(PP_Resource context_id
, GLuint shader
) {
825 Enter3D
enter(context_id
, true);
826 if (IsBoundGraphics(&enter
)) {
827 return glIsShader(shader
);
833 GLboolean
IsTexture(PP_Resource context_id
, GLuint texture
) {
834 Enter3D
enter(context_id
, true);
835 if (IsBoundGraphics(&enter
)) {
836 return glIsTexture(texture
);
842 void LineWidth(PP_Resource context_id
, GLfloat width
) {
843 Enter3D
enter(context_id
, true);
844 if (IsBoundGraphics(&enter
)) {
849 void LinkProgram(PP_Resource context_id
, GLuint program
) {
850 Enter3D
enter(context_id
, true);
851 if (IsBoundGraphics(&enter
)) {
852 glLinkProgram(program
);
856 void PixelStorei(PP_Resource context_id
, GLenum pname
, GLint param
) {
857 Enter3D
enter(context_id
, true);
858 if (IsBoundGraphics(&enter
)) {
859 glPixelStorei(pname
, param
);
863 void PolygonOffset(PP_Resource context_id
, GLfloat factor
, GLfloat units
) {
864 Enter3D
enter(context_id
, true);
865 if (IsBoundGraphics(&enter
)) {
866 glPolygonOffset(factor
, units
);
870 void ReadPixels(PP_Resource context_id
,
878 Enter3D
enter(context_id
, true);
879 if (IsBoundGraphics(&enter
)) {
880 glReadPixels(x
, y
, width
, height
, format
, type
, pixels
);
884 void ReleaseShaderCompiler(PP_Resource context_id
) {
885 Enter3D
enter(context_id
, true);
886 if (IsBoundGraphics(&enter
)) {
887 glReleaseShaderCompiler();
891 void RenderbufferStorage(PP_Resource context_id
,
893 GLenum internalformat
,
896 Enter3D
enter(context_id
, true);
897 if (IsBoundGraphics(&enter
)) {
898 glRenderbufferStorage(target
, internalformat
, width
, height
);
902 void SampleCoverage(PP_Resource context_id
, GLclampf value
, GLboolean invert
) {
903 Enter3D
enter(context_id
, true);
904 if (IsBoundGraphics(&enter
)) {
905 glSampleCoverage(value
, invert
);
909 void Scissor(PP_Resource context_id
,
914 Enter3D
enter(context_id
, true);
915 if (IsBoundGraphics(&enter
)) {
916 glScissor(x
, y
, width
, height
);
920 void ShaderBinary(PP_Resource context_id
,
922 const GLuint
* shaders
,
926 Enter3D
enter(context_id
, true);
927 if (IsBoundGraphics(&enter
)) {
928 glShaderBinary(n
, shaders
, binaryformat
, binary
, length
);
932 void ShaderSource(PP_Resource context_id
,
936 const GLint
* length
) {
937 Enter3D
enter(context_id
, true);
938 if (IsBoundGraphics(&enter
)) {
939 glShaderSource(shader
, count
, str
, length
);
943 void StencilFunc(PP_Resource context_id
, GLenum func
, GLint ref
, GLuint mask
) {
944 Enter3D
enter(context_id
, true);
945 if (IsBoundGraphics(&enter
)) {
946 glStencilFunc(func
, ref
, mask
);
950 void StencilFuncSeparate(PP_Resource context_id
,
955 Enter3D
enter(context_id
, true);
956 if (IsBoundGraphics(&enter
)) {
957 glStencilFuncSeparate(face
, func
, ref
, mask
);
961 void StencilMask(PP_Resource context_id
, GLuint mask
) {
962 Enter3D
enter(context_id
, true);
963 if (IsBoundGraphics(&enter
)) {
968 void StencilMaskSeparate(PP_Resource context_id
, GLenum face
, GLuint mask
) {
969 Enter3D
enter(context_id
, true);
970 if (IsBoundGraphics(&enter
)) {
971 glStencilMaskSeparate(face
, mask
);
975 void StencilOp(PP_Resource context_id
,
979 Enter3D
enter(context_id
, true);
980 if (IsBoundGraphics(&enter
)) {
981 glStencilOp(fail
, zfail
, zpass
);
985 void StencilOpSeparate(PP_Resource context_id
,
990 Enter3D
enter(context_id
, true);
991 if (IsBoundGraphics(&enter
)) {
992 glStencilOpSeparate(face
, fail
, zfail
, zpass
);
996 void TexImage2D(PP_Resource context_id
,
999 GLint internalformat
,
1005 const void* pixels
) {
1006 Enter3D
enter(context_id
, true);
1007 if (IsBoundGraphics(&enter
)) {
1008 glTexImage2D(target
,
1020 void TexParameterf(PP_Resource context_id
,
1024 Enter3D
enter(context_id
, true);
1025 if (IsBoundGraphics(&enter
)) {
1026 glTexParameterf(target
, pname
, param
);
1030 void TexParameterfv(PP_Resource context_id
,
1033 const GLfloat
* params
) {
1034 Enter3D
enter(context_id
, true);
1035 if (IsBoundGraphics(&enter
)) {
1036 glTexParameterfv(target
, pname
, params
);
1040 void TexParameteri(PP_Resource context_id
,
1044 Enter3D
enter(context_id
, true);
1045 if (IsBoundGraphics(&enter
)) {
1046 glTexParameteri(target
, pname
, param
);
1050 void TexParameteriv(PP_Resource context_id
,
1053 const GLint
* params
) {
1054 Enter3D
enter(context_id
, true);
1055 if (IsBoundGraphics(&enter
)) {
1056 glTexParameteriv(target
, pname
, params
);
1060 void TexSubImage2D(PP_Resource context_id
,
1069 const void* pixels
) {
1070 Enter3D
enter(context_id
, true);
1071 if (IsBoundGraphics(&enter
)) {
1073 target
, level
, xoffset
, yoffset
, width
, height
, format
, type
, pixels
);
1077 void Uniform1f(PP_Resource context_id
, GLint location
, GLfloat x
) {
1078 Enter3D
enter(context_id
, true);
1079 if (IsBoundGraphics(&enter
)) {
1080 glUniform1f(location
, x
);
1084 void Uniform1fv(PP_Resource context_id
,
1088 Enter3D
enter(context_id
, true);
1089 if (IsBoundGraphics(&enter
)) {
1090 glUniform1fv(location
, count
, v
);
1094 void Uniform1i(PP_Resource context_id
, GLint location
, GLint x
) {
1095 Enter3D
enter(context_id
, true);
1096 if (IsBoundGraphics(&enter
)) {
1097 glUniform1i(location
, x
);
1101 void Uniform1iv(PP_Resource context_id
,
1105 Enter3D
enter(context_id
, true);
1106 if (IsBoundGraphics(&enter
)) {
1107 glUniform1iv(location
, count
, v
);
1111 void Uniform2f(PP_Resource context_id
, GLint location
, GLfloat x
, GLfloat y
) {
1112 Enter3D
enter(context_id
, true);
1113 if (IsBoundGraphics(&enter
)) {
1114 glUniform2f(location
, x
, y
);
1118 void Uniform2fv(PP_Resource context_id
,
1122 Enter3D
enter(context_id
, true);
1123 if (IsBoundGraphics(&enter
)) {
1124 glUniform2fv(location
, count
, v
);
1128 void Uniform2i(PP_Resource context_id
, GLint location
, GLint x
, GLint y
) {
1129 Enter3D
enter(context_id
, true);
1130 if (IsBoundGraphics(&enter
)) {
1131 glUniform2i(location
, x
, y
);
1135 void Uniform2iv(PP_Resource context_id
,
1139 Enter3D
enter(context_id
, true);
1140 if (IsBoundGraphics(&enter
)) {
1141 glUniform2iv(location
, count
, v
);
1145 void Uniform3f(PP_Resource context_id
,
1150 Enter3D
enter(context_id
, true);
1151 if (IsBoundGraphics(&enter
)) {
1152 glUniform3f(location
, x
, y
, z
);
1156 void Uniform3fv(PP_Resource context_id
,
1160 Enter3D
enter(context_id
, true);
1161 if (IsBoundGraphics(&enter
)) {
1162 glUniform3fv(location
, count
, v
);
1166 void Uniform3i(PP_Resource context_id
,
1171 Enter3D
enter(context_id
, true);
1172 if (IsBoundGraphics(&enter
)) {
1173 glUniform3i(location
, x
, y
, z
);
1177 void Uniform3iv(PP_Resource context_id
,
1181 Enter3D
enter(context_id
, true);
1182 if (IsBoundGraphics(&enter
)) {
1183 glUniform3iv(location
, count
, v
);
1187 void Uniform4f(PP_Resource context_id
,
1193 Enter3D
enter(context_id
, true);
1194 if (IsBoundGraphics(&enter
)) {
1195 glUniform4f(location
, x
, y
, z
, w
);
1199 void Uniform4fv(PP_Resource context_id
,
1203 Enter3D
enter(context_id
, true);
1204 if (IsBoundGraphics(&enter
)) {
1205 glUniform4fv(location
, count
, v
);
1209 void Uniform4i(PP_Resource context_id
,
1215 Enter3D
enter(context_id
, true);
1216 if (IsBoundGraphics(&enter
)) {
1217 glUniform4i(location
, x
, y
, z
, w
);
1221 void Uniform4iv(PP_Resource context_id
,
1225 Enter3D
enter(context_id
, true);
1226 if (IsBoundGraphics(&enter
)) {
1227 glUniform4iv(location
, count
, v
);
1231 void UniformMatrix2fv(PP_Resource context_id
,
1234 GLboolean transpose
,
1235 const GLfloat
* value
) {
1236 Enter3D
enter(context_id
, true);
1237 if (IsBoundGraphics(&enter
)) {
1238 glUniformMatrix2fv(location
, count
, transpose
, value
);
1242 void UniformMatrix3fv(PP_Resource context_id
,
1245 GLboolean transpose
,
1246 const GLfloat
* value
) {
1247 Enter3D
enter(context_id
, true);
1248 if (IsBoundGraphics(&enter
)) {
1249 glUniformMatrix3fv(location
, count
, transpose
, value
);
1253 void UniformMatrix4fv(PP_Resource context_id
,
1256 GLboolean transpose
,
1257 const GLfloat
* value
) {
1258 Enter3D
enter(context_id
, true);
1259 if (IsBoundGraphics(&enter
)) {
1260 glUniformMatrix4fv(location
, count
, transpose
, value
);
1264 void UseProgram(PP_Resource context_id
, GLuint program
) {
1265 Enter3D
enter(context_id
, true);
1266 if (IsBoundGraphics(&enter
)) {
1267 glUseProgram(program
);
1271 void ValidateProgram(PP_Resource context_id
, GLuint program
) {
1272 Enter3D
enter(context_id
, true);
1273 if (IsBoundGraphics(&enter
)) {
1274 glValidateProgram(program
);
1278 void VertexAttrib1f(PP_Resource context_id
, GLuint indx
, GLfloat x
) {
1279 Enter3D
enter(context_id
, true);
1280 if (IsBoundGraphics(&enter
)) {
1281 glVertexAttrib1f(indx
, x
);
1285 void VertexAttrib1fv(PP_Resource context_id
,
1287 const GLfloat
* values
) {
1288 Enter3D
enter(context_id
, true);
1289 if (IsBoundGraphics(&enter
)) {
1290 glVertexAttrib1fv(indx
, values
);
1294 void VertexAttrib2f(PP_Resource context_id
, GLuint indx
, GLfloat x
, GLfloat y
) {
1295 Enter3D
enter(context_id
, true);
1296 if (IsBoundGraphics(&enter
)) {
1297 glVertexAttrib2f(indx
, x
, y
);
1301 void VertexAttrib2fv(PP_Resource context_id
,
1303 const GLfloat
* values
) {
1304 Enter3D
enter(context_id
, true);
1305 if (IsBoundGraphics(&enter
)) {
1306 glVertexAttrib2fv(indx
, values
);
1310 void VertexAttrib3f(PP_Resource context_id
,
1315 Enter3D
enter(context_id
, true);
1316 if (IsBoundGraphics(&enter
)) {
1317 glVertexAttrib3f(indx
, x
, y
, z
);
1321 void VertexAttrib3fv(PP_Resource context_id
,
1323 const GLfloat
* values
) {
1324 Enter3D
enter(context_id
, true);
1325 if (IsBoundGraphics(&enter
)) {
1326 glVertexAttrib3fv(indx
, values
);
1330 void VertexAttrib4f(PP_Resource context_id
,
1336 Enter3D
enter(context_id
, true);
1337 if (IsBoundGraphics(&enter
)) {
1338 glVertexAttrib4f(indx
, x
, y
, z
, w
);
1342 void VertexAttrib4fv(PP_Resource context_id
,
1344 const GLfloat
* values
) {
1345 Enter3D
enter(context_id
, true);
1346 if (IsBoundGraphics(&enter
)) {
1347 glVertexAttrib4fv(indx
, values
);
1351 void VertexAttribPointer(PP_Resource context_id
,
1355 GLboolean normalized
,
1358 Enter3D
enter(context_id
, true);
1359 if (IsBoundGraphics(&enter
)) {
1360 glVertexAttribPointer(indx
, size
, type
, normalized
, stride
, ptr
);
1364 void Viewport(PP_Resource context_id
,
1369 Enter3D
enter(context_id
, true);
1370 if (IsBoundGraphics(&enter
)) {
1371 glViewport(x
, y
, width
, height
);
1377 const PPB_OpenGLES2
* GetPPB_OpenGLES2_Thunk() {
1378 static const struct PPB_OpenGLES2 ppb_opengles2
= {
1379 &ActiveTexture
, &AttachShader
,
1380 &BindAttribLocation
, &BindBuffer
,
1381 &BindFramebuffer
, &BindRenderbuffer
,
1382 &BindTexture
, &BlendColor
,
1383 &BlendEquation
, &BlendEquationSeparate
,
1384 &BlendFunc
, &BlendFuncSeparate
,
1385 &BufferData
, &BufferSubData
,
1386 &CheckFramebufferStatus
, &Clear
,
1387 &ClearColor
, &ClearDepthf
,
1388 &ClearStencil
, &ColorMask
,
1389 &CompileShader
, &CompressedTexImage2D
,
1390 &CompressedTexSubImage2D
, &CopyTexImage2D
,
1391 &CopyTexSubImage2D
, &CreateProgram
,
1392 &CreateShader
, &CullFace
,
1393 &DeleteBuffers
, &DeleteFramebuffers
,
1394 &DeleteProgram
, &DeleteRenderbuffers
,
1395 &DeleteShader
, &DeleteTextures
,
1396 &DepthFunc
, &DepthMask
,
1397 &DepthRangef
, &DetachShader
,
1398 &Disable
, &DisableVertexAttribArray
,
1399 &DrawArrays
, &DrawElements
,
1400 &Enable
, &EnableVertexAttribArray
,
1402 &FramebufferRenderbuffer
, &FramebufferTexture2D
,
1403 &FrontFace
, &GenBuffers
,
1404 &GenerateMipmap
, &GenFramebuffers
,
1405 &GenRenderbuffers
, &GenTextures
,
1406 &GetActiveAttrib
, &GetActiveUniform
,
1407 &GetAttachedShaders
, &GetAttribLocation
,
1408 &GetBooleanv
, &GetBufferParameteriv
,
1409 &GetError
, &GetFloatv
,
1410 &GetFramebufferAttachmentParameteriv
, &GetIntegerv
,
1411 &GetProgramiv
, &GetProgramInfoLog
,
1412 &GetRenderbufferParameteriv
, &GetShaderiv
,
1413 &GetShaderInfoLog
, &GetShaderPrecisionFormat
,
1414 &GetShaderSource
, &GetString
,
1415 &GetTexParameterfv
, &GetTexParameteriv
,
1416 &GetUniformfv
, &GetUniformiv
,
1417 &GetUniformLocation
, &GetVertexAttribfv
,
1418 &GetVertexAttribiv
, &GetVertexAttribPointerv
,
1420 &IsEnabled
, &IsFramebuffer
,
1421 &IsProgram
, &IsRenderbuffer
,
1422 &IsShader
, &IsTexture
,
1423 &LineWidth
, &LinkProgram
,
1424 &PixelStorei
, &PolygonOffset
,
1425 &ReadPixels
, &ReleaseShaderCompiler
,
1426 &RenderbufferStorage
, &SampleCoverage
,
1427 &Scissor
, &ShaderBinary
,
1428 &ShaderSource
, &StencilFunc
,
1429 &StencilFuncSeparate
, &StencilMask
,
1430 &StencilMaskSeparate
, &StencilOp
,
1431 &StencilOpSeparate
, &TexImage2D
,
1432 &TexParameterf
, &TexParameterfv
,
1433 &TexParameteri
, &TexParameteriv
,
1434 &TexSubImage2D
, &Uniform1f
,
1435 &Uniform1fv
, &Uniform1i
,
1436 &Uniform1iv
, &Uniform2f
,
1437 &Uniform2fv
, &Uniform2i
,
1438 &Uniform2iv
, &Uniform3f
,
1439 &Uniform3fv
, &Uniform3i
,
1440 &Uniform3iv
, &Uniform4f
,
1441 &Uniform4fv
, &Uniform4i
,
1442 &Uniform4iv
, &UniformMatrix2fv
,
1443 &UniformMatrix3fv
, &UniformMatrix4fv
,
1444 &UseProgram
, &ValidateProgram
,
1445 &VertexAttrib1f
, &VertexAttrib1fv
,
1446 &VertexAttrib2f
, &VertexAttrib2fv
,
1447 &VertexAttrib3f
, &VertexAttrib3fv
,
1448 &VertexAttrib4f
, &VertexAttrib4fv
,
1449 &VertexAttribPointer
, &Viewport
};
1450 return &ppb_opengles2
;
1453 } // namespace examples