Currently, bionic only build a subset of the examples. This changes turns on all...
[chromium-blink-merge.git] / mojo / examples / pepper_container_app / ppb_opengles2_thunk.cc
blobc5097bb0ddb258040a37c694dd6d3891fae257db
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"
12 namespace mojo {
13 namespace examples {
15 namespace {
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,
39 GLuint program,
40 GLuint index,
41 const char* name) {
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,
56 GLenum target,
57 GLuint framebuffer) {
58 Enter3D enter(context_id, true);
59 if (IsBoundGraphics(&enter)) {
60 glBindFramebuffer(target, framebuffer);
64 void BindRenderbuffer(PP_Resource context_id,
65 GLenum target,
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,
81 GLclampf red,
82 GLclampf green,
83 GLclampf blue,
84 GLclampf alpha) {
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,
99 GLenum modeRGB,
100 GLenum modeAlpha) {
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,
115 GLenum srcRGB,
116 GLenum dstRGB,
117 GLenum srcAlpha,
118 GLenum dstAlpha) {
119 Enter3D enter(context_id, true);
120 if (IsBoundGraphics(&enter)) {
121 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
125 void BufferData(PP_Resource context_id,
126 GLenum target,
127 GLsizeiptr size,
128 const void* data,
129 GLenum usage) {
130 Enter3D enter(context_id, true);
131 if (IsBoundGraphics(&enter)) {
132 glBufferData(target, size, data, usage);
136 void BufferSubData(PP_Resource context_id,
137 GLenum target,
138 GLintptr offset,
139 GLsizeiptr size,
140 const void* data) {
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);
151 } else {
152 return 0;
156 void Clear(PP_Resource context_id, GLbitfield mask) {
157 Enter3D enter(context_id, true);
158 if (IsBoundGraphics(&enter)) {
159 glClear(mask);
163 void ClearColor(PP_Resource context_id,
164 GLclampf red,
165 GLclampf green,
166 GLclampf blue,
167 GLclampf alpha) {
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)) {
184 glClearStencil(s);
188 void ColorMask(PP_Resource context_id,
189 GLboolean red,
190 GLboolean green,
191 GLboolean blue,
192 GLboolean alpha) {
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,
207 GLenum target,
208 GLint level,
209 GLenum internalformat,
210 GLsizei width,
211 GLsizei height,
212 GLint border,
213 GLsizei imageSize,
214 const void* data) {
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,
223 GLenum target,
224 GLint level,
225 GLint xoffset,
226 GLint yoffset,
227 GLsizei width,
228 GLsizei height,
229 GLenum format,
230 GLsizei imageSize,
231 const void* data) {
232 Enter3D enter(context_id, true);
233 if (IsBoundGraphics(&enter)) {
234 glCompressedTexSubImage2D(target,
235 level,
236 xoffset,
237 yoffset,
238 width,
239 height,
240 format,
241 imageSize,
242 data);
246 void CopyTexImage2D(PP_Resource context_id,
247 GLenum target,
248 GLint level,
249 GLenum internalformat,
250 GLint x,
251 GLint y,
252 GLsizei width,
253 GLsizei height,
254 GLint border) {
255 Enter3D enter(context_id, true);
256 if (IsBoundGraphics(&enter)) {
257 glCopyTexImage2D(
258 target, level, internalformat, x, y, width, height, border);
262 void CopyTexSubImage2D(PP_Resource context_id,
263 GLenum target,
264 GLint level,
265 GLint xoffset,
266 GLint yoffset,
267 GLint x,
268 GLint y,
269 GLsizei width,
270 GLsizei height) {
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();
281 } else {
282 return 0;
286 GLuint CreateShader(PP_Resource context_id, GLenum type) {
287 Enter3D enter(context_id, true);
288 if (IsBoundGraphics(&enter)) {
289 return glCreateShader(type);
290 } else {
291 return 0;
295 void CullFace(PP_Resource context_id, GLenum mode) {
296 Enter3D enter(context_id, true);
297 if (IsBoundGraphics(&enter)) {
298 glCullFace(mode);
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,
310 GLsizei n,
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,
326 GLsizei n,
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)) {
351 glDepthFunc(func);
355 void DepthMask(PP_Resource context_id, GLboolean flag) {
356 Enter3D enter(context_id, true);
357 if (IsBoundGraphics(&enter)) {
358 glDepthMask(flag);
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)) {
379 glDisable(cap);
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,
391 GLenum mode,
392 GLint first,
393 GLsizei count) {
394 Enter3D enter(context_id, true);
395 if (IsBoundGraphics(&enter)) {
396 glDrawArrays(mode, first, count);
400 void DrawElements(PP_Resource context_id,
401 GLenum mode,
402 GLsizei count,
403 GLenum type,
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)) {
414 glEnable(cap);
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)) {
428 glFinish();
432 void Flush(PP_Resource context_id) {
433 Enter3D enter(context_id, true);
434 if (IsBoundGraphics(&enter)) {
435 glFlush();
439 void FramebufferRenderbuffer(PP_Resource context_id,
440 GLenum target,
441 GLenum attachment,
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,
452 GLenum target,
453 GLenum attachment,
454 GLenum textarget,
455 GLuint texture,
456 GLint level) {
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)) {
466 glFrontFace(mode);
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,
492 GLsizei n,
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,
508 GLuint program,
509 GLuint index,
510 GLsizei bufsize,
511 GLsizei* length,
512 GLint* size,
513 GLenum* type,
514 char* name) {
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,
522 GLuint program,
523 GLuint index,
524 GLsizei bufsize,
525 GLsizei* length,
526 GLint* size,
527 GLenum* type,
528 char* name) {
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,
536 GLuint program,
537 GLsizei maxcount,
538 GLsizei* count,
539 GLuint* shaders) {
540 Enter3D enter(context_id, true);
541 if (IsBoundGraphics(&enter)) {
542 glGetAttachedShaders(program, maxcount, count, shaders);
546 GLint GetAttribLocation(PP_Resource context_id,
547 GLuint program,
548 const char* name) {
549 Enter3D enter(context_id, true);
550 if (IsBoundGraphics(&enter)) {
551 return glGetAttribLocation(program, name);
552 } else {
553 return -1;
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,
565 GLenum target,
566 GLenum pname,
567 GLint* params) {
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)) {
577 return glGetError();
578 } else {
579 return 0;
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,
591 GLenum target,
592 GLenum attachment,
593 GLenum pname,
594 GLint* params) {
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,
609 GLuint program,
610 GLenum pname,
611 GLint* params) {
612 Enter3D enter(context_id, true);
613 if (IsBoundGraphics(&enter)) {
614 glGetProgramiv(program, pname, params);
618 void GetProgramInfoLog(PP_Resource context_id,
619 GLuint program,
620 GLsizei bufsize,
621 GLsizei* length,
622 char* infolog) {
623 Enter3D enter(context_id, true);
624 if (IsBoundGraphics(&enter)) {
625 glGetProgramInfoLog(program, bufsize, length, infolog);
629 void GetRenderbufferParameteriv(PP_Resource context_id,
630 GLenum target,
631 GLenum pname,
632 GLint* params) {
633 Enter3D enter(context_id, true);
634 if (IsBoundGraphics(&enter)) {
635 glGetRenderbufferParameteriv(target, pname, params);
639 void GetShaderiv(PP_Resource context_id,
640 GLuint shader,
641 GLenum pname,
642 GLint* params) {
643 Enter3D enter(context_id, true);
644 if (IsBoundGraphics(&enter)) {
645 glGetShaderiv(shader, pname, params);
649 void GetShaderInfoLog(PP_Resource context_id,
650 GLuint shader,
651 GLsizei bufsize,
652 GLsizei* length,
653 char* infolog) {
654 Enter3D enter(context_id, true);
655 if (IsBoundGraphics(&enter)) {
656 glGetShaderInfoLog(shader, bufsize, length, infolog);
660 void GetShaderPrecisionFormat(PP_Resource context_id,
661 GLenum shadertype,
662 GLenum precisiontype,
663 GLint* range,
664 GLint* precision) {
665 Enter3D enter(context_id, true);
666 if (IsBoundGraphics(&enter)) {
667 glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
671 void GetShaderSource(PP_Resource context_id,
672 GLuint shader,
673 GLsizei bufsize,
674 GLsizei* length,
675 char* source) {
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);
686 } else {
687 return NULL;
691 void GetTexParameterfv(PP_Resource context_id,
692 GLenum target,
693 GLenum pname,
694 GLfloat* params) {
695 Enter3D enter(context_id, true);
696 if (IsBoundGraphics(&enter)) {
697 glGetTexParameterfv(target, pname, params);
701 void GetTexParameteriv(PP_Resource context_id,
702 GLenum target,
703 GLenum pname,
704 GLint* params) {
705 Enter3D enter(context_id, true);
706 if (IsBoundGraphics(&enter)) {
707 glGetTexParameteriv(target, pname, params);
711 void GetUniformfv(PP_Resource context_id,
712 GLuint program,
713 GLint location,
714 GLfloat* params) {
715 Enter3D enter(context_id, true);
716 if (IsBoundGraphics(&enter)) {
717 glGetUniformfv(program, location, params);
721 void GetUniformiv(PP_Resource context_id,
722 GLuint program,
723 GLint location,
724 GLint* params) {
725 Enter3D enter(context_id, true);
726 if (IsBoundGraphics(&enter)) {
727 glGetUniformiv(program, location, params);
731 GLint GetUniformLocation(PP_Resource context_id,
732 GLuint program,
733 const char* name) {
734 Enter3D enter(context_id, true);
735 if (IsBoundGraphics(&enter)) {
736 return glGetUniformLocation(program, name);
737 } else {
738 return -1;
742 void GetVertexAttribfv(PP_Resource context_id,
743 GLuint index,
744 GLenum pname,
745 GLfloat* params) {
746 Enter3D enter(context_id, true);
747 if (IsBoundGraphics(&enter)) {
748 glGetVertexAttribfv(index, pname, params);
752 void GetVertexAttribiv(PP_Resource context_id,
753 GLuint index,
754 GLenum pname,
755 GLint* params) {
756 Enter3D enter(context_id, true);
757 if (IsBoundGraphics(&enter)) {
758 glGetVertexAttribiv(index, pname, params);
762 void GetVertexAttribPointerv(PP_Resource context_id,
763 GLuint index,
764 GLenum pname,
765 void** pointer) {
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);
783 } else {
784 return GL_FALSE;
788 GLboolean IsEnabled(PP_Resource context_id, GLenum cap) {
789 Enter3D enter(context_id, true);
790 if (IsBoundGraphics(&enter)) {
791 return glIsEnabled(cap);
792 } else {
793 return GL_FALSE;
797 GLboolean IsFramebuffer(PP_Resource context_id, GLuint framebuffer) {
798 Enter3D enter(context_id, true);
799 if (IsBoundGraphics(&enter)) {
800 return glIsFramebuffer(framebuffer);
801 } else {
802 return GL_FALSE;
806 GLboolean IsProgram(PP_Resource context_id, GLuint program) {
807 Enter3D enter(context_id, true);
808 if (IsBoundGraphics(&enter)) {
809 return glIsProgram(program);
810 } else {
811 return GL_FALSE;
815 GLboolean IsRenderbuffer(PP_Resource context_id, GLuint renderbuffer) {
816 Enter3D enter(context_id, true);
817 if (IsBoundGraphics(&enter)) {
818 return glIsRenderbuffer(renderbuffer);
819 } else {
820 return GL_FALSE;
824 GLboolean IsShader(PP_Resource context_id, GLuint shader) {
825 Enter3D enter(context_id, true);
826 if (IsBoundGraphics(&enter)) {
827 return glIsShader(shader);
828 } else {
829 return GL_FALSE;
833 GLboolean IsTexture(PP_Resource context_id, GLuint texture) {
834 Enter3D enter(context_id, true);
835 if (IsBoundGraphics(&enter)) {
836 return glIsTexture(texture);
837 } else {
838 return GL_FALSE;
842 void LineWidth(PP_Resource context_id, GLfloat width) {
843 Enter3D enter(context_id, true);
844 if (IsBoundGraphics(&enter)) {
845 glLineWidth(width);
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,
871 GLint x,
872 GLint y,
873 GLsizei width,
874 GLsizei height,
875 GLenum format,
876 GLenum type,
877 void* pixels) {
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,
892 GLenum target,
893 GLenum internalformat,
894 GLsizei width,
895 GLsizei height) {
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,
910 GLint x,
911 GLint y,
912 GLsizei width,
913 GLsizei height) {
914 Enter3D enter(context_id, true);
915 if (IsBoundGraphics(&enter)) {
916 glScissor(x, y, width, height);
920 void ShaderBinary(PP_Resource context_id,
921 GLsizei n,
922 const GLuint* shaders,
923 GLenum binaryformat,
924 const void* binary,
925 GLsizei length) {
926 Enter3D enter(context_id, true);
927 if (IsBoundGraphics(&enter)) {
928 glShaderBinary(n, shaders, binaryformat, binary, length);
932 void ShaderSource(PP_Resource context_id,
933 GLuint shader,
934 GLsizei count,
935 const char** str,
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,
951 GLenum face,
952 GLenum func,
953 GLint ref,
954 GLuint mask) {
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)) {
964 glStencilMask(mask);
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,
976 GLenum fail,
977 GLenum zfail,
978 GLenum zpass) {
979 Enter3D enter(context_id, true);
980 if (IsBoundGraphics(&enter)) {
981 glStencilOp(fail, zfail, zpass);
985 void StencilOpSeparate(PP_Resource context_id,
986 GLenum face,
987 GLenum fail,
988 GLenum zfail,
989 GLenum zpass) {
990 Enter3D enter(context_id, true);
991 if (IsBoundGraphics(&enter)) {
992 glStencilOpSeparate(face, fail, zfail, zpass);
996 void TexImage2D(PP_Resource context_id,
997 GLenum target,
998 GLint level,
999 GLint internalformat,
1000 GLsizei width,
1001 GLsizei height,
1002 GLint border,
1003 GLenum format,
1004 GLenum type,
1005 const void* pixels) {
1006 Enter3D enter(context_id, true);
1007 if (IsBoundGraphics(&enter)) {
1008 glTexImage2D(target,
1009 level,
1010 internalformat,
1011 width,
1012 height,
1013 border,
1014 format,
1015 type,
1016 pixels);
1020 void TexParameterf(PP_Resource context_id,
1021 GLenum target,
1022 GLenum pname,
1023 GLfloat param) {
1024 Enter3D enter(context_id, true);
1025 if (IsBoundGraphics(&enter)) {
1026 glTexParameterf(target, pname, param);
1030 void TexParameterfv(PP_Resource context_id,
1031 GLenum target,
1032 GLenum pname,
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,
1041 GLenum target,
1042 GLenum pname,
1043 GLint param) {
1044 Enter3D enter(context_id, true);
1045 if (IsBoundGraphics(&enter)) {
1046 glTexParameteri(target, pname, param);
1050 void TexParameteriv(PP_Resource context_id,
1051 GLenum target,
1052 GLenum pname,
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,
1061 GLenum target,
1062 GLint level,
1063 GLint xoffset,
1064 GLint yoffset,
1065 GLsizei width,
1066 GLsizei height,
1067 GLenum format,
1068 GLenum type,
1069 const void* pixels) {
1070 Enter3D enter(context_id, true);
1071 if (IsBoundGraphics(&enter)) {
1072 glTexSubImage2D(
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,
1085 GLint location,
1086 GLsizei count,
1087 const GLfloat* v) {
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,
1102 GLint location,
1103 GLsizei count,
1104 const GLint* v) {
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,
1119 GLint location,
1120 GLsizei count,
1121 const GLfloat* v) {
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,
1136 GLint location,
1137 GLsizei count,
1138 const GLint* v) {
1139 Enter3D enter(context_id, true);
1140 if (IsBoundGraphics(&enter)) {
1141 glUniform2iv(location, count, v);
1145 void Uniform3f(PP_Resource context_id,
1146 GLint location,
1147 GLfloat x,
1148 GLfloat y,
1149 GLfloat z) {
1150 Enter3D enter(context_id, true);
1151 if (IsBoundGraphics(&enter)) {
1152 glUniform3f(location, x, y, z);
1156 void Uniform3fv(PP_Resource context_id,
1157 GLint location,
1158 GLsizei count,
1159 const GLfloat* v) {
1160 Enter3D enter(context_id, true);
1161 if (IsBoundGraphics(&enter)) {
1162 glUniform3fv(location, count, v);
1166 void Uniform3i(PP_Resource context_id,
1167 GLint location,
1168 GLint x,
1169 GLint y,
1170 GLint z) {
1171 Enter3D enter(context_id, true);
1172 if (IsBoundGraphics(&enter)) {
1173 glUniform3i(location, x, y, z);
1177 void Uniform3iv(PP_Resource context_id,
1178 GLint location,
1179 GLsizei count,
1180 const GLint* v) {
1181 Enter3D enter(context_id, true);
1182 if (IsBoundGraphics(&enter)) {
1183 glUniform3iv(location, count, v);
1187 void Uniform4f(PP_Resource context_id,
1188 GLint location,
1189 GLfloat x,
1190 GLfloat y,
1191 GLfloat z,
1192 GLfloat w) {
1193 Enter3D enter(context_id, true);
1194 if (IsBoundGraphics(&enter)) {
1195 glUniform4f(location, x, y, z, w);
1199 void Uniform4fv(PP_Resource context_id,
1200 GLint location,
1201 GLsizei count,
1202 const GLfloat* v) {
1203 Enter3D enter(context_id, true);
1204 if (IsBoundGraphics(&enter)) {
1205 glUniform4fv(location, count, v);
1209 void Uniform4i(PP_Resource context_id,
1210 GLint location,
1211 GLint x,
1212 GLint y,
1213 GLint z,
1214 GLint w) {
1215 Enter3D enter(context_id, true);
1216 if (IsBoundGraphics(&enter)) {
1217 glUniform4i(location, x, y, z, w);
1221 void Uniform4iv(PP_Resource context_id,
1222 GLint location,
1223 GLsizei count,
1224 const GLint* v) {
1225 Enter3D enter(context_id, true);
1226 if (IsBoundGraphics(&enter)) {
1227 glUniform4iv(location, count, v);
1231 void UniformMatrix2fv(PP_Resource context_id,
1232 GLint location,
1233 GLsizei count,
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,
1243 GLint location,
1244 GLsizei count,
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,
1254 GLint location,
1255 GLsizei count,
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,
1286 GLuint indx,
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,
1302 GLuint indx,
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,
1311 GLuint indx,
1312 GLfloat x,
1313 GLfloat y,
1314 GLfloat z) {
1315 Enter3D enter(context_id, true);
1316 if (IsBoundGraphics(&enter)) {
1317 glVertexAttrib3f(indx, x, y, z);
1321 void VertexAttrib3fv(PP_Resource context_id,
1322 GLuint indx,
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,
1331 GLuint indx,
1332 GLfloat x,
1333 GLfloat y,
1334 GLfloat z,
1335 GLfloat w) {
1336 Enter3D enter(context_id, true);
1337 if (IsBoundGraphics(&enter)) {
1338 glVertexAttrib4f(indx, x, y, z, w);
1342 void VertexAttrib4fv(PP_Resource context_id,
1343 GLuint indx,
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,
1352 GLuint indx,
1353 GLint size,
1354 GLenum type,
1355 GLboolean normalized,
1356 GLsizei stride,
1357 const void* ptr) {
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,
1365 GLint x,
1366 GLint y,
1367 GLsizei width,
1368 GLsizei height) {
1369 Enter3D enter(context_id, true);
1370 if (IsBoundGraphics(&enter)) {
1371 glViewport(x, y, width, height);
1375 } // namespace
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,
1401 &Finish, &Flush,
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,
1419 &Hint, &IsBuffer,
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
1454 } // namespace mojo