summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 21:24:02 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 21:24:02 +0000
commit0f6bd72df6b38ef02909934aab3504f92913fb4b (patch)
tree18ff077ab4256c0e7fe66d2848f001a5460d3229 /o3d
parent5ed64d5f85cc2d2381748116374967f0cf5042d2 (diff)
downloadchromium_src-0f6bd72df6b38ef02909934aab3504f92913fb4b.zip
chromium_src-0f6bd72df6b38ef02909934aab3504f92913fb4b.tar.gz
chromium_src-0f6bd72df6b38ef02909934aab3504f92913fb4b.tar.bz2
A clear screen GLES2 demo.
I'm not sure if I should check the demo in or not. I expect it will be moved or deleted but I'd like to get it in. This demo currently only runs on Windows because of a few setup issues. All it does is clear the screen purple then yellow. It shows a tiny C segment including only gl2.h and calling a GL function. Also a tiny C++ segment including only gl2.h and calling a GL function. The setup code is currently in the gles2_demo.cc. I'd like to move to gles2_lib.cc but it needs to be NaCl specific for that since that's the use case for generic setup. WebGL and unit tests will have to do custom setup I think. Also, I found out glGetAttribLocation and glGetUniformLocation were not implemented. For now I mostly subbed them out. The quickest solution was to add class GetGLcharHandler to the code generator but my next step will be to delete class GetGLcharHandler and GLcharHandler given that they only represent 3 functions total that code should be written manually. Review URL: http://codereview.chromium.org/399108 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32546 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/build/o3d_all.gyp7
-rw-r--r--o3d/gpu/command_buffer/build_gles2_cmd_buffer.py415
-rw-r--r--o3d/gpu/command_buffer/client/gles2_c_lib.cc6
-rw-r--r--o3d/gpu/command_buffer/client/gles2_c_lib_autogen.h605
-rw-r--r--o3d/gpu/command_buffer/client/gles2_cmd_helper_autogen.h5
-rw-r--r--o3d/gpu/command_buffer/client/gles2_demo.cc203
-rw-r--r--o3d/gpu/command_buffer/client/gles2_demo_c.c15
-rw-r--r--o3d/gpu/command_buffer/client/gles2_demo_c.h22
-rw-r--r--o3d/gpu/command_buffer/client/gles2_demo_cc.cc21
-rw-r--r--o3d/gpu/command_buffer/client/gles2_demo_cc.h14
-rw-r--r--o3d/gpu/command_buffer/client/gles2_implementation.cc18
-rw-r--r--o3d/gpu/command_buffer/client/gles2_implementation.h17
-rw-r--r--o3d/gpu/command_buffer/client/gles2_implementation_autogen.h14
-rw-r--r--o3d/gpu/command_buffer/client/gles2_implementation_gen.h2
-rw-r--r--o3d/gpu/command_buffer/client/gles2_lib.cc7
-rw-r--r--o3d/gpu/command_buffer/client/gles2_lib.h10
-rw-r--r--o3d/gpu/command_buffer/client/gles2_lib_autogen.h493
-rw-r--r--o3d/gpu/command_buffer/common/GLES2/gl2.h616
-rw-r--r--o3d/gpu/command_buffer/common/GLES2/gl2types.h464
-rw-r--r--o3d/gpu/command_buffer/common/gles2_cmd_format.h2
-rw-r--r--o3d/gpu/command_buffer/common/gles2_cmd_format_autogen.h30
-rw-r--r--o3d/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h8
-rw-r--r--o3d/gpu/command_buffer/common/gles2_cmd_id_test.cc4
-rw-r--r--o3d/gpu/command_buffer/common/gles2_cmd_ids_autogen.h1
-rw-r--r--o3d/gpu/command_buffer/service/gles2_cmd_decoder.cc105
-rw-r--r--o3d/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h221
-rw-r--r--o3d/gpu/command_buffer/service/gles2_cmd_decoder_validate.h6
-rw-r--r--o3d/gpu/gpu.gyp24
28 files changed, 2005 insertions, 1350 deletions
diff --git a/o3d/build/o3d_all.gyp b/o3d/build/o3d_all.gyp
index b55d97b..d2ab921 100644
--- a/o3d/build/o3d_all.gyp
+++ b/o3d/build/o3d_all.gyp
@@ -54,6 +54,13 @@
],
},
],
+ ['renderer=="cb" and cb_service=="gl"',
+ {
+ 'dependencies': [
+ '../gpu/gpu.gyp:gles2_demo',
+ ],
+ },
+ ],
],
},
],
diff --git a/o3d/gpu/command_buffer/build_gles2_cmd_buffer.py b/o3d/gpu/command_buffer/build_gles2_cmd_buffer.py
index a1f60c8..04f9a7b 100644
--- a/o3d/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/o3d/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -16,12 +16,173 @@ _SIZE_OF_UINT32 = 4
_SIZE_OF_COMMAND_HEADER = 4
_FIRST_SPECIFIC_COMMAND_ID = 1024
-_LICENSE = "\n".join([
- "// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.",
- "// Use of this source code is governed by a BSD-style license that can be",
- "// found in the LICENSE file.",
- "",
-])
+_LICENSE = """
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+"""
+
+# This string is copied directly out of the gl2.h file from GLES2.0
+# the reasons it is copied out instead of parsed directly are
+#
+# 1) Because order is important. The command IDs need to stay constant forever
+# so if you add a new command it needs to be added to the bottom of the list.
+#
+# 2) So we can add more commands easily that are unrelated to GLES2.0 but still
+# needed for GLES2.0 command buffers.
+#
+# Edits:
+#
+# *) Any argument that is a resourceID has been changed to GLresourceID.
+# (not pointer arguments)
+#
+_GL_FUNCTIONS = """
+GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
+GL_APICALL void GL_APIENTRY glAttachShader (GLResourceId program, GLResourceId shader);
+GL_APICALL void GL_APIENTRY glBindAttribLocation (GLResourceId program, GLuint index, const char* name);
+GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLResourceId buffer);
+GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLResourceId framebuffer);
+GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLResourceId renderbuffer);
+GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLResourceId texture);
+GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode );
+GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
+GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
+GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage);
+GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
+GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
+GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
+GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth);
+GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
+GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GL_APICALL void GL_APIENTRY glCompileShader (GLResourceId shader);
+GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
+GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
+GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
+GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
+GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
+GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
+GL_APICALL void GL_APIENTRY glDeleteProgram (GLResourceId program);
+GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
+GL_APICALL void GL_APIENTRY glDeleteShader (GLResourceId shader);
+GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
+GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
+GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
+GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
+GL_APICALL void GL_APIENTRY glDetachShader (GLResourceId program, GLResourceId shader);
+GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
+GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
+GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
+GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void* indices);
+GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
+GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
+GL_APICALL void GL_APIENTRY glFinish (void);
+GL_APICALL void GL_APIENTRY glFlush (void);
+GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLResourceId renderbuffer);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLResourceId texture, GLint level);
+GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
+GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
+GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
+GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
+GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
+GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
+GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLResourceId program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+GL_APICALL void GL_APIENTRY glGetActiveUniform (GLResourceId program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLResourceId program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+GL_APICALL int GL_APIENTRY glGetAttribLocation (GLResourceId program, const char* name);
+GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
+GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL GLenum GL_APIENTRY glGetError (void);
+GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);
+GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetProgramiv (GLResourceId program, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLResourceId program, GLsizei bufsize, GLsizei* length, char* infolog);
+GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetShaderiv (GLResourceId shader, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLResourceId shader, GLsizei bufsize, GLsizei* length, char* infolog);
+GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+GL_APICALL void GL_APIENTRY glGetShaderSource (GLResourceId shader, GLsizei bufsize, GLsizei* length, char* source);
+GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);
+GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);
+GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetUniformfv (GLResourceId program, GLint location, GLfloat* params);
+GL_APICALL void GL_APIENTRY glGetUniformiv (GLResourceId program, GLint location, GLint* params);
+GL_APICALL int GL_APIENTRY glGetUniformLocation (GLResourceId program, const char* name);
+GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
+GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void** pointer);
+GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
+GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLResourceId buffer);
+GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
+GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLResourceId framebuffer);
+GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLResourceId program);
+GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLResourceId renderbuffer);
+GL_APICALL GLboolean GL_APIENTRY glIsShader (GLResourceId shader);
+GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLResourceId texture);
+GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
+GL_APICALL void GL_APIENTRY glLinkProgram (GLResourceId program);
+GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
+GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
+GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
+GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
+GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLResourceId* shaders, GLenum binaryformat, const void* binary, GLsizei length);
+GL_APICALL void GL_APIENTRY glShaderSource (GLResourceId shader, GLsizei count, const char** string, const GLint* length);
+GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
+GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels);
+GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);
+GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);
+GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
+GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x);
+GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x);
+GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
+GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
+GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
+GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
+GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUseProgram (GLResourceId program);
+GL_APICALL void GL_APIENTRY glValidateProgram (GLResourceId program);
+GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
+GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);
+GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);
+GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);
+GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);
+GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);
+GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
+GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+// Non-GL commands.
+GL_APICALL void GL_APIENTRY glSwapBuffers (void);
+"""
# This table specifies types and other special data for the commands that
# will be generated.
@@ -73,7 +234,7 @@ _FUNCTION_INFO = {
'GetActiveAttrib': {'type': 'Custom'},
'GetActiveUniform': {'type': 'Custom'},
'GetAttachedShaders': {'type': 'Custom'},
- 'GetAttribLocation': {'type': 'GLchar'},
+ 'GetAttribLocation': {'type': 'GetGLchar'},
'GetBooleanv': {'type': 'GETn'},
'GetBufferParameteriv': {'type': 'GETn'},
'GetError': {'type': 'Is'},
@@ -97,7 +258,7 @@ _FUNCTION_INFO = {
'GetTexParameteriv': {'type': 'GETn'},
'GetUniformfv': {'type': 'Custom', 'immediate': False},
'GetUniformiv': {'type': 'Custom', 'immediate': False},
- 'GetUniformLocation': {'type': 'GLchar'},
+ 'GetUniformLocation': {'type': 'GetGLchar'},
'GetVertexAttribfv': {'type': 'GETn'},
'GetVertexAttribiv': {'type': 'GETn'},
'GetVertexAttribPointerv': {'type': 'Custom', 'immediate': False},
@@ -144,6 +305,7 @@ _FUNCTION_INFO = {
'cmd_args': 'GLuint indx, GLint size, GLenum type, GLboolean normalized, '
'GLsizei stride, GLuint offset',
},
+ 'SwapBuffers': {'DecoderFunc': 'DoSwapBuffers'},
}
@@ -1218,7 +1380,7 @@ class PUTnHandler(TypeHandler):
class GLcharHandler(TypeHandler):
- """Handler for glBindAttrLoc, glGetAttibLoc, glGetUniformLoc."""
+ """Handler for functions that pass a single string ."""
def __init__(self):
TypeHandler.__init__(self)
@@ -1392,6 +1554,184 @@ class GLcharHandler(TypeHandler):
file.Write("}\n")
file.Write("\n")
+class GetGLcharHandler(GLcharHandler):
+ """Handler for glGetAttibLoc, glGetUniformLoc."""
+
+ def __init__(self):
+ GLcharHandler.__init__(self)
+
+ def WriteServiceImplementation(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write(
+ "parse_error::ParseError GLES2DecoderImpl::Handle%s(\n" % func.name)
+ file.Write(
+ " unsigned int arg_count, const gles2::%s& c) {\n" % func.name)
+ last_arg = func.GetLastOriginalArg()
+
+ all_but_last_arg = func.GetOriginalArgs()[:-1]
+ for arg in all_but_last_arg:
+ arg.WriteGetCode(file)
+
+ file.Write(" uint32 name_size = c.data_size;\n")
+ file.Write(" const char* name = GetSharedMemoryAs<%s>(\n" %
+ last_arg.type)
+ file.Write(" c.%s_shm_id, c.%s_shm_offset, name_size);\n" %
+ (last_arg.name, last_arg.name))
+ file.Write(" parse_error::ParseError result =\n")
+ file.Write(" Validate%s(this, arg_count%s);\n" %
+ (func.name, func.MakeOriginalArgString("", True)))
+ file.Write(" if (result != parse_error::kParseNoError) {\n")
+ file.Write(" return result;\n")
+ file.Write(" }\n")
+ arg_string = ", ".join(["%s" % arg.name for arg in all_but_last_arg])
+ file.Write(" String name_str(name, name_size);\n")
+ file.Write(" GLint location = %s(%s, name_str.c_str());\n" %
+ (func.GetGLFunctionName(), arg_string))
+ file.Write(" DCHECK(false); // TODO: return result.\n")
+ file.Write(" return parse_error::kParseNoError;\n")
+ file.Write("}\n")
+ file.Write("\n")
+
+ def WriteImmediateServiceImplementation(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write(
+ "parse_error::ParseError GLES2DecoderImpl::Handle%s(\n" % func.name)
+ file.Write(
+ " unsigned int arg_count, const gles2::%s& c) {\n" % func.name)
+ last_arg = func.GetLastOriginalArg()
+
+ all_but_last_arg = func.GetOriginalArgs()[:-1]
+ for arg in all_but_last_arg:
+ arg.WriteGetCode(file)
+
+ file.Write(" uint32 name_size = c.data_size;\n")
+ file.Write(
+ " const char* name = GetImmediateDataAs<const char*>(c);\n")
+ file.Write(" // TODO(gman): Make sure validate checks arg_count\n")
+ file.Write(" // covers data_size.\n")
+ file.Write(" parse_error::ParseError result =\n")
+ file.Write(" Validate%s(this, arg_count%s);\n" %
+ (func.name, func.MakeOriginalArgString("", True)))
+ file.Write(" if (result != parse_error::kParseNoError) {\n")
+ file.Write(" return result;\n")
+ file.Write(" }\n")
+ arg_string = ", ".join(["%s" % arg.name for arg in all_but_last_arg])
+ file.Write(" String name_str(name, name_size);\n")
+ file.Write(" GLint location = %s(%s, name_str.c_str());\n" %
+ (func.GetGLFunctionName(), arg_string))
+ file.Write(" DCHECK(false); // TODO: return result.\n")
+ file.Write(" return parse_error::kParseNoError;\n")
+ file.Write("}\n")
+ file.Write("\n")
+
+ def WriteGLES2ImplementationHeader(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write("%s %s(%s) {\n" %
+ (func.return_type, func.original_name,
+ func.MakeTypedOriginalArgString("")))
+ file.Write(" // TODO(gman): This needs to change to use SendString.\n")
+ file.Write(" GLint* result = shared_memory_.GetAddressAs<GLint*>(0);\n")
+ file.Write(" DCHECK(false); // pass in shared memory\n")
+ file.Write(" helper_->%sImmediate(%s);\n" %
+ (func.name, func.MakeOriginalArgString("")))
+ file.Write(" int32 token = helper_->InsertToken();\n")
+ file.Write(" helper_->WaitForToken(token);\n")
+ file.Write(" return *result;\n")
+ file.Write("}\n")
+ file.Write("\n")
+
+ def WriteGLES2ImplementationImpl(self, func, file):
+ """Overrriden from TypeHandler."""
+ pass
+
+ def WriteImmediateCmdComputeSize(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write(" static uint32 ComputeDataSize(const char* s) {\n")
+ file.Write(" return strlen(s);\n")
+ file.Write(" }\n")
+ file.Write("\n")
+ file.Write(" static uint32 ComputeSize(const char* s) {\n")
+ file.Write(" return static_cast<uint32>(\n")
+ file.Write(" sizeof(ValueType) + ComputeDataSize(s)); // NOLINT\n")
+ file.Write(" }\n")
+ file.Write("\n")
+
+ def WriteImmediateCmdSetHeader(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write(" void SetHeader(const char* s) {\n")
+ file.Write(" header.SetCmdByTotalSize<ValueType>(ComputeSize(s));\n")
+ file.Write(" }\n")
+ file.Write("\n")
+
+ def WriteImmediateCmdInit(self, func, file):
+ """Overrriden from TypeHandler."""
+ last_arg = func.GetLastOriginalArg()
+ file.Write(" void Init(%s) {\n" % func.MakeTypedOriginalArgString("_"))
+ file.Write(" SetHeader(_%s);\n" % last_arg.name)
+ args = func.GetCmdArgs()[:-1]
+ for arg in args:
+ file.Write(" %s = _%s;\n" % (arg.name, arg.name))
+ file.Write(" data_size = strlen(_%s);\n" % last_arg.name)
+ file.Write(" memcpy(ImmediateDataAddress(this), _%s, data_size);\n" %
+ last_arg.name)
+ file.Write(" }\n")
+ file.Write("\n")
+
+ def WriteImmediateCmdSet(self, func, file):
+ """Overrriden from TypeHandler."""
+ last_arg = func.GetLastOriginalArg()
+ file.Write(" void* Set(void* cmd%s) {\n" %
+ func.MakeTypedOriginalArgString("_", True))
+ file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" %
+ func.MakeOriginalArgString("_"))
+ file.Write(" const uint32 size = ComputeSize(_%s);\n" % last_arg.name)
+ file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>("
+ "cmd, size);\n")
+ file.Write(" }\n")
+ file.Write("\n")
+
+ def WriteImmediateCmdHelper(self, func, file):
+ """Overrriden from TypeHandler."""
+ args = func.MakeOriginalArgString("")
+ last_arg = func.GetLastOriginalArg()
+ file.Write(" void %s(%s) {\n" %
+ (func.name, func.MakeTypedOriginalArgString("")))
+ file.Write(" const uint32 size = gles2::%s::ComputeSize(%s);\n" %
+ (func.name, last_arg.name))
+ file.Write(" gles2::%s& c = GetImmediateCmdSpaceTotalSize<gles2::%s>("
+ "size);\n" %
+ (func.name, func.name))
+ file.Write(" c.Init(%s);\n" % args)
+ file.Write(" }\n\n")
+
+ def WriteImmediateFormatTest(self, func, file):
+ """Overrriden from TypeHandler."""
+ file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name)
+ file.Write(" int8 buf[256] = { 0, };\n")
+ file.Write(" %s& cmd = *static_cast<%s*>(static_cast<void*>(&buf));\n" %
+ (func.name, func.name))
+ file.Write(" static const char* const test_str = \"test string\";\n")
+ file.Write(" void* next_cmd = cmd.Set(\n")
+ file.Write(" &cmd")
+ all_but_last_arg = func.GetCmdArgs()[:-1]
+ value = 11
+ for arg in all_but_last_arg:
+ file.Write(",\n static_cast<%s>(%d)" % (arg.type, value))
+ value += 1
+ file.Write(",\n test_str);\n")
+ value = 11
+ file.Write(" EXPECT_EQ(%s::kCmdId, cmd.header.command);\n" % func.name)
+ file.Write(" EXPECT_EQ(sizeof(cmd) + // NOLINT\n")
+ file.Write(" RoundSizeToMultipleOfEntries(strlen(test_str)),\n")
+ file.Write(" cmd.header.size * 4);\n")
+ for arg in all_but_last_arg:
+ file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" %
+ (arg.type, value, arg.name))
+ value += 1
+ file.Write(" // TODO(gman): check that string got copied.\n")
+ file.Write("}\n")
+ file.Write("\n")
+
class IsHandler(TypeHandler):
"""Handler for glIs____ type and glGetError functions."""
@@ -1596,6 +1936,23 @@ class PointerArgument(Argument):
return ImmediatePointerArgument(self.name, self.type)
+class ResourceIdArgument(Argument):
+ """A class that represents a resource id argument to a function."""
+
+ def __init__(self, name, type):
+ type = type.replace("GLResourceId", "GLuint")
+ Argument.__init__(self, name, type)
+
+ def WriteGetCode(self, file):
+ """Overridden from Argument."""
+ file.Write(" %s %s;\n" % (self.type, self.name))
+ file.Write(" if (!id_map_.GetServiceId(c.%s, &%s)) {\n" %
+ (self.name, self.name))
+ file.Write(" SetGLError(GL_INVALID_VALUE);\n")
+ file.Write(" return parse_error::kParseNoError;\n")
+ file.Write(" }\n")
+
+
class Function(object):
"""A class that represents a function."""
@@ -1879,6 +2236,7 @@ class GLGenerator(object):
'DELn': DELnHandler(),
'GENn': GENnHandler(),
'GETn': GETnHandler(),
+ 'GetGLchar': GetGLcharHandler(),
'GLchar': GLcharHandler(),
'Is': IsHandler(),
'Manual': ManualHandler(),
@@ -1961,6 +2319,11 @@ class GLGenerator(object):
args.append(PointerArgument(
arg_parts[-1],
" ".join(arg_parts[0:-1])))
+ # Is this a resource argument? Must come after pointer check.
+ elif arg_parts[0] == 'GLResourceId':
+ args.append(ResourceIdArgument(
+ arg_parts[-1],
+ " ".join(arg_parts[0:-1])))
else:
args.append(Argument(
arg_parts[-1],
@@ -1969,8 +2332,7 @@ class GLGenerator(object):
def ParseGLH(self, filename):
"""Parses the GL2.h file and extracts the functions"""
- file = open(filename, "r")
- for line in file.readlines():
+ for line in _GL_FUNCTIONS.splitlines():
match = self._function_re.match(line)
if match:
func_name = match.group(2)[2:]
@@ -1991,7 +2353,6 @@ class GLGenerator(object):
self.original_functions.append(f)
self.AddFunction(f)
f.type_handler.AddImmediateFunction(self, f)
- file.close()
self.Log("Auto Generated Functions : %d" %
len([f for f in self.functions if f.can_auto_generate or
@@ -2123,31 +2484,6 @@ class GLGenerator(object):
self.WriteNamespaceClose(file)
file.Close()
- def WriteGLES2LibHeader(self, filename):
- """Writes the GLES2 lib header."""
- file = CWriter(filename)
- self.WriteHeader(file)
- file.Write("\n")
- file.Write("// These functions emluate GLES2 over command buffers.\n")
- file.Write("\n")
- file.Write("\n")
-
- for func in self.original_functions:
- file.Write("inline %s gl%s(%s) {\n" %
- (func.return_type, func.name,
- func.MakeTypedOriginalArgString("")))
- return_string = "return "
- if func.return_type == "void":
- return_string = ""
- file.Write(" %sg_gl_impl->%s(%s);\n" %
- (return_string, func.original_name,
- func.MakeOriginalArgString("")))
- file.Write("}\n")
-
- file.Write("\n")
-
- file.Close()
-
def WriteGLES2CLibImplementation(self, filename):
"""Writes the GLES2 c lib implementation."""
file = CWriter(filename)
@@ -2158,13 +2494,13 @@ class GLGenerator(object):
file.Write("\n")
for func in self.original_functions:
- file.Write("%s gl%s(%s) {\n" %
+ file.Write("%s GLES2%s(%s) {\n" %
(func.return_type, func.name,
func.MakeTypedOriginalArgString("")))
return_string = "return "
if func.return_type == "void":
return_string = ""
- file.Write(" %sg_gl_impl->%s(%s);\n" %
+ file.Write(" %sgles2::GetGLContext()->%s(%s);\n" %
(return_string, func.original_name,
func.MakeOriginalArgString("")))
file.Write("}\n")
@@ -2224,7 +2560,6 @@ def main(argv):
gen.WriteFormat("common/gles2_cmd_format_autogen.h")
gen.WriteFormatTest("common/gles2_cmd_format_test_autogen.h")
gen.WriteGLES2ImplementationHeader("client/gles2_implementation_autogen.h")
- gen.WriteGLES2LibHeader("client/gles2_lib_autogen.h")
gen.WriteGLES2CLibImplementation("client/gles2_c_lib_autogen.h")
gen.WriteCmdHelperHeader("client/gles2_cmd_helper_autogen.h")
gen.WriteServiceImplementation("service/gles2_cmd_decoder_autogen.h")
diff --git a/o3d/gpu/command_buffer/client/gles2_c_lib.cc b/o3d/gpu/command_buffer/client/gles2_c_lib.cc
index 9ebd26c..d311a5d 100644
--- a/o3d/gpu/command_buffer/client/gles2_c_lib.cc
+++ b/o3d/gpu/command_buffer/client/gles2_c_lib.cc
@@ -4,13 +4,13 @@
// These functions emluate GLES2 over command buffers for C.
-extern "C" {
-static ::command_buffer::gles2::GLES2Implementation* g_gl_impl;
+#include "gpu/command_buffer/client/gles2_lib.h"
+extern "C" {
// Include the auto-generated part of this file. We split this because it means
// we can easily edit the non-auto generated parts right here in this file
// instead of having to edit some template or the code generator.
-#include "gpu/command_buffer/client/gles2_lib_c_autogen.h"
+#include "gpu/command_buffer/client/gles2_c_lib_autogen.h"
} // extern "C"
diff --git a/o3d/gpu/command_buffer/client/gles2_c_lib_autogen.h b/o3d/gpu/command_buffer/client/gles2_c_lib_autogen.h
index d55c94e..c03a350 100644
--- a/o3d/gpu/command_buffer/client/gles2_c_lib_autogen.h
+++ b/o3d/gpu/command_buffer/client/gles2_c_lib_autogen.h
@@ -4,482 +4,501 @@
// These functions emluate GLES2 over command buffers.
-void glActiveTexture(GLenum texture) {
- g_gl_impl->ActiveTexture(texture);
+void GLES2ActiveTexture(GLenum texture) {
+ gles2::GetGLContext()->ActiveTexture(texture);
}
-void glAttachShader(GLuint program, GLuint shader) {
- g_gl_impl->AttachShader(program, shader);
+void GLES2AttachShader(GLuint program, GLuint shader) {
+ gles2::GetGLContext()->AttachShader(program, shader);
}
-void glBindAttribLocation(GLuint program, GLuint index, const char* name) {
- g_gl_impl->BindAttribLocation(program, index, name);
+void GLES2BindAttribLocation(GLuint program, GLuint index, const char* name) {
+ gles2::GetGLContext()->BindAttribLocation(program, index, name);
}
-void glBindBuffer(GLenum target, GLuint buffer) {
- g_gl_impl->BindBuffer(target, buffer);
+void GLES2BindBuffer(GLenum target, GLuint buffer) {
+ gles2::GetGLContext()->BindBuffer(target, buffer);
}
-void glBindFramebuffer(GLenum target, GLuint framebuffer) {
- g_gl_impl->BindFramebuffer(target, framebuffer);
+void GLES2BindFramebuffer(GLenum target, GLuint framebuffer) {
+ gles2::GetGLContext()->BindFramebuffer(target, framebuffer);
}
-void glBindRenderbuffer(GLenum target, GLuint renderbuffer) {
- g_gl_impl->BindRenderbuffer(target, renderbuffer);
+void GLES2BindRenderbuffer(GLenum target, GLuint renderbuffer) {
+ gles2::GetGLContext()->BindRenderbuffer(target, renderbuffer);
}
-void glBindTexture(GLenum target, GLuint texture) {
- g_gl_impl->BindTexture(target, texture);
+void GLES2BindTexture(GLenum target, GLuint texture) {
+ gles2::GetGLContext()->BindTexture(target, texture);
}
-void glBlendColor(
+void GLES2BlendColor(
GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
- g_gl_impl->BlendColor(red, green, blue, alpha);
+ gles2::GetGLContext()->BlendColor(red, green, blue, alpha);
}
-void glBlendEquation(GLenum mode) {
- g_gl_impl->BlendEquation(mode);
+void GLES2BlendEquation(GLenum mode) {
+ gles2::GetGLContext()->BlendEquation(mode);
}
-void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
- g_gl_impl->BlendEquationSeparate(modeRGB, modeAlpha);
+void GLES2BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
+ gles2::GetGLContext()->BlendEquationSeparate(modeRGB, modeAlpha);
}
-void glBlendFunc(GLenum sfactor, GLenum dfactor) {
- g_gl_impl->BlendFunc(sfactor, dfactor);
+void GLES2BlendFunc(GLenum sfactor, GLenum dfactor) {
+ gles2::GetGLContext()->BlendFunc(sfactor, dfactor);
}
-void glBlendFuncSeparate(
+void GLES2BlendFuncSeparate(
GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
- g_gl_impl->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+ gles2::GetGLContext()->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
-void glBufferData(
+void GLES2BufferData(
GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
- g_gl_impl->BufferData(target, size, data, usage);
+ gles2::GetGLContext()->BufferData(target, size, data, usage);
}
-void glBufferSubData(
+void GLES2BufferSubData(
GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
- g_gl_impl->BufferSubData(target, offset, size, data);
+ gles2::GetGLContext()->BufferSubData(target, offset, size, data);
}
-GLenum glCheckFramebufferStatus(GLenum target) {
- return g_gl_impl->CheckFramebufferStatus(target);
+GLenum GLES2CheckFramebufferStatus(GLenum target) {
+ return gles2::GetGLContext()->CheckFramebufferStatus(target);
}
-void glClear(GLbitfield mask) {
- g_gl_impl->Clear(mask);
+void GLES2Clear(GLbitfield mask) {
+ gles2::GetGLContext()->Clear(mask);
}
-void glClearColor(
+void GLES2ClearColor(
GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
- g_gl_impl->ClearColor(red, green, blue, alpha);
+ gles2::GetGLContext()->ClearColor(red, green, blue, alpha);
}
-void glClearDepthf(GLclampf depth) {
- g_gl_impl->ClearDepthf(depth);
+void GLES2ClearDepthf(GLclampf depth) {
+ gles2::GetGLContext()->ClearDepthf(depth);
}
-void glClearStencil(GLint s) {
- g_gl_impl->ClearStencil(s);
+void GLES2ClearStencil(GLint s) {
+ gles2::GetGLContext()->ClearStencil(s);
}
-void glColorMask(
+void GLES2ColorMask(
GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
- g_gl_impl->ColorMask(red, green, blue, alpha);
+ gles2::GetGLContext()->ColorMask(red, green, blue, alpha);
}
-void glCompileShader(GLuint shader) {
- g_gl_impl->CompileShader(shader);
+void GLES2CompileShader(GLuint shader) {
+ gles2::GetGLContext()->CompileShader(shader);
}
-void glCompressedTexImage2D(
+void GLES2CompressedTexImage2D(
GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLsizei imageSize, const void* data) {
- g_gl_impl->CompressedTexImage2D(
- target, level, internalformat, width, height, border, imageSize, data);
+ gles2::GetGLContext(
+ )->CompressedTexImage2D(
+ target, level, internalformat, width, height, border, imageSize,
+ data);
}
-void glCompressedTexSubImage2D(
+void GLES2CompressedTexSubImage2D(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLsizei imageSize, const void* data) {
- g_gl_impl->CompressedTexSubImage2D(
- target, level, xoffset, yoffset, width, height, format, imageSize, data);
+ gles2::GetGLContext(
+ )->CompressedTexSubImage2D(
+ target, level, xoffset, yoffset, width, height, format, imageSize,
+ data);
}
-void glCopyTexImage2D(
+void GLES2CopyTexImage2D(
GLenum target, GLint level, GLenum internalformat, GLint x, GLint y,
GLsizei width, GLsizei height, GLint border) {
- g_gl_impl->CopyTexImage2D(
- target, level, internalformat, x, y, width, height, border);
+ gles2::GetGLContext(
+ )->CopyTexImage2D(
+ target, level, internalformat, x, y, width, height, border);
}
-void glCopyTexSubImage2D(
+void GLES2CopyTexSubImage2D(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
GLsizei width, GLsizei height) {
- g_gl_impl->CopyTexSubImage2D(
- target, level, xoffset, yoffset, x, y, width, height);
+ gles2::GetGLContext(
+ )->CopyTexSubImage2D(
+ target, level, xoffset, yoffset, x, y, width, height);
}
-GLuint glCreateProgram() {
- return g_gl_impl->CreateProgram();
+GLuint GLES2CreateProgram() {
+ return gles2::GetGLContext()->CreateProgram();
}
-GLuint glCreateShader(GLenum type) {
- return g_gl_impl->CreateShader(type);
+GLuint GLES2CreateShader(GLenum type) {
+ return gles2::GetGLContext()->CreateShader(type);
}
-void glCullFace(GLenum mode) {
- g_gl_impl->CullFace(mode);
+void GLES2CullFace(GLenum mode) {
+ gles2::GetGLContext()->CullFace(mode);
}
-void glDeleteBuffers(GLsizei n, const GLuint* buffers) {
- g_gl_impl->DeleteBuffers(n, buffers);
+void GLES2DeleteBuffers(GLsizei n, const GLuint* buffers) {
+ gles2::GetGLContext()->DeleteBuffers(n, buffers);
}
-void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) {
- g_gl_impl->DeleteFramebuffers(n, framebuffers);
+void GLES2DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) {
+ gles2::GetGLContext()->DeleteFramebuffers(n, framebuffers);
}
-void glDeleteProgram(GLuint program) {
- g_gl_impl->DeleteProgram(program);
+void GLES2DeleteProgram(GLuint program) {
+ gles2::GetGLContext()->DeleteProgram(program);
}
-void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) {
- g_gl_impl->DeleteRenderbuffers(n, renderbuffers);
+void GLES2DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) {
+ gles2::GetGLContext()->DeleteRenderbuffers(n, renderbuffers);
}
-void glDeleteShader(GLuint shader) {
- g_gl_impl->DeleteShader(shader);
+void GLES2DeleteShader(GLuint shader) {
+ gles2::GetGLContext()->DeleteShader(shader);
}
-void glDeleteTextures(GLsizei n, const GLuint* textures) {
- g_gl_impl->DeleteTextures(n, textures);
+void GLES2DeleteTextures(GLsizei n, const GLuint* textures) {
+ gles2::GetGLContext()->DeleteTextures(n, textures);
}
-void glDepthFunc(GLenum func) {
- g_gl_impl->DepthFunc(func);
+void GLES2DepthFunc(GLenum func) {
+ gles2::GetGLContext()->DepthFunc(func);
}
-void glDepthMask(GLboolean flag) {
- g_gl_impl->DepthMask(flag);
+void GLES2DepthMask(GLboolean flag) {
+ gles2::GetGLContext()->DepthMask(flag);
}
-void glDepthRangef(GLclampf zNear, GLclampf zFar) {
- g_gl_impl->DepthRangef(zNear, zFar);
+void GLES2DepthRangef(GLclampf zNear, GLclampf zFar) {
+ gles2::GetGLContext()->DepthRangef(zNear, zFar);
}
-void glDetachShader(GLuint program, GLuint shader) {
- g_gl_impl->DetachShader(program, shader);
+void GLES2DetachShader(GLuint program, GLuint shader) {
+ gles2::GetGLContext()->DetachShader(program, shader);
}
-void glDisable(GLenum cap) {
- g_gl_impl->Disable(cap);
+void GLES2Disable(GLenum cap) {
+ gles2::GetGLContext()->Disable(cap);
}
-void glDisableVertexAttribArray(GLuint index) {
- g_gl_impl->DisableVertexAttribArray(index);
+void GLES2DisableVertexAttribArray(GLuint index) {
+ gles2::GetGLContext()->DisableVertexAttribArray(index);
}
-void glDrawArrays(GLenum mode, GLint first, GLsizei count) {
- g_gl_impl->DrawArrays(mode, first, count);
+void GLES2DrawArrays(GLenum mode, GLint first, GLsizei count) {
+ gles2::GetGLContext()->DrawArrays(mode, first, count);
}
-void glDrawElements(
+void GLES2DrawElements(
GLenum mode, GLsizei count, GLenum type, const void* indices) {
- g_gl_impl->DrawElements(mode, count, type, indices);
+ gles2::GetGLContext()->DrawElements(mode, count, type, indices);
}
-void glEnable(GLenum cap) {
- g_gl_impl->Enable(cap);
+void GLES2Enable(GLenum cap) {
+ gles2::GetGLContext()->Enable(cap);
}
-void glEnableVertexAttribArray(GLuint index) {
- g_gl_impl->EnableVertexAttribArray(index);
+void GLES2EnableVertexAttribArray(GLuint index) {
+ gles2::GetGLContext()->EnableVertexAttribArray(index);
}
-void glFinish() {
- g_gl_impl->Finish();
+void GLES2Finish() {
+ gles2::GetGLContext()->Finish();
}
-void glFlush() {
- g_gl_impl->Flush();
+void GLES2Flush() {
+ gles2::GetGLContext()->Flush();
}
-void glFramebufferRenderbuffer(
+void GLES2FramebufferRenderbuffer(
GLenum target, GLenum attachment, GLenum renderbuffertarget,
GLuint renderbuffer) {
- g_gl_impl->FramebufferRenderbuffer(
- target, attachment, renderbuffertarget, renderbuffer);
+ gles2::GetGLContext(
+ )->FramebufferRenderbuffer(
+ target, attachment, renderbuffertarget, renderbuffer);
}
-void glFramebufferTexture2D(
+void GLES2FramebufferTexture2D(
GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
GLint level) {
- g_gl_impl->FramebufferTexture2D(
- target, attachment, textarget, texture, level);
+ gles2::GetGLContext(
+ )->FramebufferTexture2D(target, attachment, textarget, texture, level);
}
-void glFrontFace(GLenum mode) {
- g_gl_impl->FrontFace(mode);
+void GLES2FrontFace(GLenum mode) {
+ gles2::GetGLContext()->FrontFace(mode);
}
-void glGenBuffers(GLsizei n, GLuint* buffers) {
- g_gl_impl->GenBuffers(n, buffers);
+void GLES2GenBuffers(GLsizei n, GLuint* buffers) {
+ gles2::GetGLContext()->GenBuffers(n, buffers);
}
-void glGenerateMipmap(GLenum target) {
- g_gl_impl->GenerateMipmap(target);
+void GLES2GenerateMipmap(GLenum target) {
+ gles2::GetGLContext()->GenerateMipmap(target);
}
-void glGenFramebuffers(GLsizei n, GLuint* framebuffers) {
- g_gl_impl->GenFramebuffers(n, framebuffers);
+void GLES2GenFramebuffers(GLsizei n, GLuint* framebuffers) {
+ gles2::GetGLContext()->GenFramebuffers(n, framebuffers);
}
-void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) {
- g_gl_impl->GenRenderbuffers(n, renderbuffers);
+void GLES2GenRenderbuffers(GLsizei n, GLuint* renderbuffers) {
+ gles2::GetGLContext()->GenRenderbuffers(n, renderbuffers);
}
-void glGenTextures(GLsizei n, GLuint* textures) {
- g_gl_impl->GenTextures(n, textures);
+void GLES2GenTextures(GLsizei n, GLuint* textures) {
+ gles2::GetGLContext()->GenTextures(n, textures);
}
-void glGetActiveAttrib(
+void GLES2GetActiveAttrib(
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
GLenum* type, char* name) {
- g_gl_impl->GetActiveAttrib(
- program, index, bufsize, length, size, type, name);
+ gles2::GetGLContext(
+ )->GetActiveAttrib(program, index, bufsize, length, size, type, name);
}
-void glGetActiveUniform(
+void GLES2GetActiveUniform(
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
GLenum* type, char* name) {
- g_gl_impl->GetActiveUniform(
- program, index, bufsize, length, size, type, name);
+ gles2::GetGLContext(
+ )->GetActiveUniform(program, index, bufsize, length, size, type, name);
}
-void glGetAttachedShaders(
+void GLES2GetAttachedShaders(
GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
- g_gl_impl->GetAttachedShaders(program, maxcount, count, shaders);
+ gles2::GetGLContext()->GetAttachedShaders(program, maxcount, count, shaders);
}
-int glGetAttribLocation(GLuint program, const char* name) {
- return g_gl_impl->GetAttribLocation(program, name);
+int GLES2GetAttribLocation(GLuint program, const char* name) {
+ return gles2::GetGLContext()->GetAttribLocation(program, name);
}
-void glGetBooleanv(GLenum pname, GLboolean* params) {
- g_gl_impl->GetBooleanv(pname, params);
+void GLES2GetBooleanv(GLenum pname, GLboolean* params) {
+ gles2::GetGLContext()->GetBooleanv(pname, params);
}
-void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
- g_gl_impl->GetBufferParameteriv(target, pname, params);
+void GLES2GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
+ gles2::GetGLContext()->GetBufferParameteriv(target, pname, params);
}
-GLenum glGetError() {
- return g_gl_impl->GetError();
+GLenum GLES2GetError() {
+ return gles2::GetGLContext()->GetError();
}
-void glGetFloatv(GLenum pname, GLfloat* params) {
- g_gl_impl->GetFloatv(pname, params);
+void GLES2GetFloatv(GLenum pname, GLfloat* params) {
+ gles2::GetGLContext()->GetFloatv(pname, params);
}
-void glGetFramebufferAttachmentParameteriv(
+void GLES2GetFramebufferAttachmentParameteriv(
GLenum target, GLenum attachment, GLenum pname, GLint* params) {
- g_gl_impl->GetFramebufferAttachmentParameteriv(
- target, attachment, pname, params);
+ gles2::GetGLContext(
+ )->GetFramebufferAttachmentParameteriv(
+ target, attachment, pname, params);
}
-void glGetIntegerv(GLenum pname, GLint* params) {
- g_gl_impl->GetIntegerv(pname, params);
+void GLES2GetIntegerv(GLenum pname, GLint* params) {
+ gles2::GetGLContext()->GetIntegerv(pname, params);
}
-void glGetProgramiv(GLuint program, GLenum pname, GLint* params) {
- g_gl_impl->GetProgramiv(program, pname, params);
+void GLES2GetProgramiv(GLuint program, GLenum pname, GLint* params) {
+ gles2::GetGLContext()->GetProgramiv(program, pname, params);
}
-void glGetProgramInfoLog(
+void GLES2GetProgramInfoLog(
GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) {
- g_gl_impl->GetProgramInfoLog(program, bufsize, length, infolog);
+ gles2::GetGLContext()->GetProgramInfoLog(program, bufsize, length, infolog);
}
-void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) {
- g_gl_impl->GetRenderbufferParameteriv(target, pname, params);
+void GLES2GetRenderbufferParameteriv(
+ GLenum target, GLenum pname, GLint* params) {
+ gles2::GetGLContext()->GetRenderbufferParameteriv(target, pname, params);
}
-void glGetShaderiv(GLuint shader, GLenum pname, GLint* params) {
- g_gl_impl->GetShaderiv(shader, pname, params);
+void GLES2GetShaderiv(GLuint shader, GLenum pname, GLint* params) {
+ gles2::GetGLContext()->GetShaderiv(shader, pname, params);
}
-void glGetShaderInfoLog(
+void GLES2GetShaderInfoLog(
GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) {
- g_gl_impl->GetShaderInfoLog(shader, bufsize, length, infolog);
+ gles2::GetGLContext()->GetShaderInfoLog(shader, bufsize, length, infolog);
}
-void glGetShaderPrecisionFormat(
+void GLES2GetShaderPrecisionFormat(
GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
- g_gl_impl->GetShaderPrecisionFormat(
- shadertype, precisiontype, range, precision);
+ gles2::GetGLContext(
+ )->GetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
}
-void glGetShaderSource(
+void GLES2GetShaderSource(
GLuint shader, GLsizei bufsize, GLsizei* length, char* source) {
- g_gl_impl->GetShaderSource(shader, bufsize, length, source);
+ gles2::GetGLContext()->GetShaderSource(shader, bufsize, length, source);
}
-const GLubyte* glGetString(GLenum name) {
- return g_gl_impl->GetString(name);
+const GLubyte* GLES2GetString(GLenum name) {
+ return gles2::GetGLContext()->GetString(name);
}
-void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) {
- g_gl_impl->GetTexParameterfv(target, pname, params);
+void GLES2GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) {
+ gles2::GetGLContext()->GetTexParameterfv(target, pname, params);
}
-void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) {
- g_gl_impl->GetTexParameteriv(target, pname, params);
+void GLES2GetTexParameteriv(GLenum target, GLenum pname, GLint* params) {
+ gles2::GetGLContext()->GetTexParameteriv(target, pname, params);
}
-void glGetUniformfv(GLuint program, GLint location, GLfloat* params) {
- g_gl_impl->GetUniformfv(program, location, params);
+void GLES2GetUniformfv(GLuint program, GLint location, GLfloat* params) {
+ gles2::GetGLContext()->GetUniformfv(program, location, params);
}
-void glGetUniformiv(GLuint program, GLint location, GLint* params) {
- g_gl_impl->GetUniformiv(program, location, params);
+void GLES2GetUniformiv(GLuint program, GLint location, GLint* params) {
+ gles2::GetGLContext()->GetUniformiv(program, location, params);
}
-int glGetUniformLocation(GLuint program, const char* name) {
- return g_gl_impl->GetUniformLocation(program, name);
+int GLES2GetUniformLocation(GLuint program, const char* name) {
+ return gles2::GetGLContext()->GetUniformLocation(program, name);
}
-void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) {
- g_gl_impl->GetVertexAttribfv(index, pname, params);
+void GLES2GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) {
+ gles2::GetGLContext()->GetVertexAttribfv(index, pname, params);
}
-void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) {
- g_gl_impl->GetVertexAttribiv(index, pname, params);
+void GLES2GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) {
+ gles2::GetGLContext()->GetVertexAttribiv(index, pname, params);
}
-void glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) {
- g_gl_impl->GetVertexAttribPointerv(index, pname, pointer);
+void GLES2GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) {
+ gles2::GetGLContext()->GetVertexAttribPointerv(index, pname, pointer);
}
-void glHint(GLenum target, GLenum mode) {
- g_gl_impl->Hint(target, mode);
+void GLES2Hint(GLenum target, GLenum mode) {
+ gles2::GetGLContext()->Hint(target, mode);
}
-GLboolean glIsBuffer(GLuint buffer) {
- return g_gl_impl->IsBuffer(buffer);
+GLboolean GLES2IsBuffer(GLuint buffer) {
+ return gles2::GetGLContext()->IsBuffer(buffer);
}
-GLboolean glIsEnabled(GLenum cap) {
- return g_gl_impl->IsEnabled(cap);
+GLboolean GLES2IsEnabled(GLenum cap) {
+ return gles2::GetGLContext()->IsEnabled(cap);
}
-GLboolean glIsFramebuffer(GLuint framebuffer) {
- return g_gl_impl->IsFramebuffer(framebuffer);
+GLboolean GLES2IsFramebuffer(GLuint framebuffer) {
+ return gles2::GetGLContext()->IsFramebuffer(framebuffer);
}
-GLboolean glIsProgram(GLuint program) {
- return g_gl_impl->IsProgram(program);
+GLboolean GLES2IsProgram(GLuint program) {
+ return gles2::GetGLContext()->IsProgram(program);
}
-GLboolean glIsRenderbuffer(GLuint renderbuffer) {
- return g_gl_impl->IsRenderbuffer(renderbuffer);
+GLboolean GLES2IsRenderbuffer(GLuint renderbuffer) {
+ return gles2::GetGLContext()->IsRenderbuffer(renderbuffer);
}
-GLboolean glIsShader(GLuint shader) {
- return g_gl_impl->IsShader(shader);
+GLboolean GLES2IsShader(GLuint shader) {
+ return gles2::GetGLContext()->IsShader(shader);
}
-GLboolean glIsTexture(GLuint texture) {
- return g_gl_impl->IsTexture(texture);
+GLboolean GLES2IsTexture(GLuint texture) {
+ return gles2::GetGLContext()->IsTexture(texture);
}
-void glLineWidth(GLfloat width) {
- g_gl_impl->LineWidth(width);
+void GLES2LineWidth(GLfloat width) {
+ gles2::GetGLContext()->LineWidth(width);
}
-void glLinkProgram(GLuint program) {
- g_gl_impl->LinkProgram(program);
+void GLES2LinkProgram(GLuint program) {
+ gles2::GetGLContext()->LinkProgram(program);
}
-void glPixelStorei(GLenum pname, GLint param) {
- g_gl_impl->PixelStorei(pname, param);
+void GLES2PixelStorei(GLenum pname, GLint param) {
+ gles2::GetGLContext()->PixelStorei(pname, param);
}
-void glPolygonOffset(GLfloat factor, GLfloat units) {
- g_gl_impl->PolygonOffset(factor, units);
+void GLES2PolygonOffset(GLfloat factor, GLfloat units) {
+ gles2::GetGLContext()->PolygonOffset(factor, units);
}
-void glReadPixels(
+void GLES2ReadPixels(
GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
void* pixels) {
- g_gl_impl->ReadPixels(x, y, width, height, format, type, pixels);
+ gles2::GetGLContext()->ReadPixels(x, y, width, height, format, type, pixels);
}
-void glRenderbufferStorage(
+void GLES2RenderbufferStorage(
GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
- g_gl_impl->RenderbufferStorage(target, internalformat, width, height);
+ gles2::GetGLContext(
+ )->RenderbufferStorage(target, internalformat, width, height);
}
-void glSampleCoverage(GLclampf value, GLboolean invert) {
- g_gl_impl->SampleCoverage(value, invert);
+void GLES2SampleCoverage(GLclampf value, GLboolean invert) {
+ gles2::GetGLContext()->SampleCoverage(value, invert);
}
-void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) {
- g_gl_impl->Scissor(x, y, width, height);
+void GLES2Scissor(GLint x, GLint y, GLsizei width, GLsizei height) {
+ gles2::GetGLContext()->Scissor(x, y, width, height);
}
-void glShaderSource(
+void GLES2ShaderSource(
GLuint shader, GLsizei count, const char** string, const GLint* length) {
- g_gl_impl->ShaderSource(shader, count, string, length);
+ gles2::GetGLContext()->ShaderSource(shader, count, string, length);
}
-void glStencilFunc(GLenum func, GLint ref, GLuint mask) {
- g_gl_impl->StencilFunc(func, ref, mask);
+void GLES2StencilFunc(GLenum func, GLint ref, GLuint mask) {
+ gles2::GetGLContext()->StencilFunc(func, ref, mask);
}
-void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) {
- g_gl_impl->StencilFuncSeparate(face, func, ref, mask);
+void GLES2StencilFuncSeparate(
+ GLenum face, GLenum func, GLint ref, GLuint mask) {
+ gles2::GetGLContext()->StencilFuncSeparate(face, func, ref, mask);
}
-void glStencilMask(GLuint mask) {
- g_gl_impl->StencilMask(mask);
+void GLES2StencilMask(GLuint mask) {
+ gles2::GetGLContext()->StencilMask(mask);
}
-void glStencilMaskSeparate(GLenum face, GLuint mask) {
- g_gl_impl->StencilMaskSeparate(face, mask);
+void GLES2StencilMaskSeparate(GLenum face, GLuint mask) {
+ gles2::GetGLContext()->StencilMaskSeparate(face, mask);
}
-void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) {
- g_gl_impl->StencilOp(fail, zfail, zpass);
+void GLES2StencilOp(GLenum fail, GLenum zfail, GLenum zpass) {
+ gles2::GetGLContext()->StencilOp(fail, zfail, zpass);
}
-void glStencilOpSeparate(
+void GLES2StencilOpSeparate(
GLenum face, GLenum fail, GLenum zfail, GLenum zpass) {
- g_gl_impl->StencilOpSeparate(face, fail, zfail, zpass);
+ gles2::GetGLContext()->StencilOpSeparate(face, fail, zfail, zpass);
}
-void glTexImage2D(
+void GLES2TexImage2D(
GLenum target, GLint level, GLint internalformat, GLsizei width,
GLsizei height, GLint border, GLenum format, GLenum type,
const void* pixels) {
- g_gl_impl->TexImage2D(
- target, level, internalformat, width, height, border, format, type,
- pixels);
+ gles2::GetGLContext(
+ )->TexImage2D(
+ target, level, internalformat, width, height, border, format, type,
+ pixels);
}
-void glTexParameterf(GLenum target, GLenum pname, GLfloat param) {
- g_gl_impl->TexParameterf(target, pname, param);
+void GLES2TexParameterf(GLenum target, GLenum pname, GLfloat param) {
+ gles2::GetGLContext()->TexParameterf(target, pname, param);
}
-void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) {
- g_gl_impl->TexParameterfv(target, pname, params);
+void GLES2TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) {
+ gles2::GetGLContext()->TexParameterfv(target, pname, params);
}
-void glTexParameteri(GLenum target, GLenum pname, GLint param) {
- g_gl_impl->TexParameteri(target, pname, param);
+void GLES2TexParameteri(GLenum target, GLenum pname, GLint param) {
+ gles2::GetGLContext()->TexParameteri(target, pname, param);
}
-void glTexParameteriv(GLenum target, GLenum pname, const GLint* params) {
- g_gl_impl->TexParameteriv(target, pname, params);
+void GLES2TexParameteriv(GLenum target, GLenum pname, const GLint* params) {
+ gles2::GetGLContext()->TexParameteriv(target, pname, params);
}
-void glTexSubImage2D(
+void GLES2TexSubImage2D(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLenum type, const void* pixels) {
- g_gl_impl->TexSubImage2D(
- target, level, xoffset, yoffset, width, height, format, type, pixels);
+ gles2::GetGLContext(
+ )->TexSubImage2D(
+ target, level, xoffset, yoffset, width, height, format, type,
+ pixels);
}
-void glUniform1f(GLint location, GLfloat x) {
- g_gl_impl->Uniform1f(location, x);
+void GLES2Uniform1f(GLint location, GLfloat x) {
+ gles2::GetGLContext()->Uniform1f(location, x);
}
-void glUniform1fv(GLint location, GLsizei count, const GLfloat* v) {
- g_gl_impl->Uniform1fv(location, count, v);
+void GLES2Uniform1fv(GLint location, GLsizei count, const GLfloat* v) {
+ gles2::GetGLContext()->Uniform1fv(location, count, v);
}
-void glUniform1i(GLint location, GLint x) {
- g_gl_impl->Uniform1i(location, x);
+void GLES2Uniform1i(GLint location, GLint x) {
+ gles2::GetGLContext()->Uniform1i(location, x);
}
-void glUniform1iv(GLint location, GLsizei count, const GLint* v) {
- g_gl_impl->Uniform1iv(location, count, v);
+void GLES2Uniform1iv(GLint location, GLsizei count, const GLint* v) {
+ gles2::GetGLContext()->Uniform1iv(location, count, v);
}
-void glUniform2f(GLint location, GLfloat x, GLfloat y) {
- g_gl_impl->Uniform2f(location, x, y);
+void GLES2Uniform2f(GLint location, GLfloat x, GLfloat y) {
+ gles2::GetGLContext()->Uniform2f(location, x, y);
}
-void glUniform2fv(GLint location, GLsizei count, const GLfloat* v) {
- g_gl_impl->Uniform2fv(location, count, v);
+void GLES2Uniform2fv(GLint location, GLsizei count, const GLfloat* v) {
+ gles2::GetGLContext()->Uniform2fv(location, count, v);
}
-void glUniform2i(GLint location, GLint x, GLint y) {
- g_gl_impl->Uniform2i(location, x, y);
+void GLES2Uniform2i(GLint location, GLint x, GLint y) {
+ gles2::GetGLContext()->Uniform2i(location, x, y);
}
-void glUniform2iv(GLint location, GLsizei count, const GLint* v) {
- g_gl_impl->Uniform2iv(location, count, v);
+void GLES2Uniform2iv(GLint location, GLsizei count, const GLint* v) {
+ gles2::GetGLContext()->Uniform2iv(location, count, v);
}
-void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) {
- g_gl_impl->Uniform3f(location, x, y, z);
+void GLES2Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) {
+ gles2::GetGLContext()->Uniform3f(location, x, y, z);
}
-void glUniform3fv(GLint location, GLsizei count, const GLfloat* v) {
- g_gl_impl->Uniform3fv(location, count, v);
+void GLES2Uniform3fv(GLint location, GLsizei count, const GLfloat* v) {
+ gles2::GetGLContext()->Uniform3fv(location, count, v);
}
-void glUniform3i(GLint location, GLint x, GLint y, GLint z) {
- g_gl_impl->Uniform3i(location, x, y, z);
+void GLES2Uniform3i(GLint location, GLint x, GLint y, GLint z) {
+ gles2::GetGLContext()->Uniform3i(location, x, y, z);
}
-void glUniform3iv(GLint location, GLsizei count, const GLint* v) {
- g_gl_impl->Uniform3iv(location, count, v);
+void GLES2Uniform3iv(GLint location, GLsizei count, const GLint* v) {
+ gles2::GetGLContext()->Uniform3iv(location, count, v);
}
-void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
- g_gl_impl->Uniform4f(location, x, y, z, w);
+void GLES2Uniform4f(
+ GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
+ gles2::GetGLContext()->Uniform4f(location, x, y, z, w);
}
-void glUniform4fv(GLint location, GLsizei count, const GLfloat* v) {
- g_gl_impl->Uniform4fv(location, count, v);
+void GLES2Uniform4fv(GLint location, GLsizei count, const GLfloat* v) {
+ gles2::GetGLContext()->Uniform4fv(location, count, v);
}
-void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) {
- g_gl_impl->Uniform4i(location, x, y, z, w);
+void GLES2Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) {
+ gles2::GetGLContext()->Uniform4i(location, x, y, z, w);
}
-void glUniform4iv(GLint location, GLsizei count, const GLint* v) {
- g_gl_impl->Uniform4iv(location, count, v);
+void GLES2Uniform4iv(GLint location, GLsizei count, const GLint* v) {
+ gles2::GetGLContext()->Uniform4iv(location, count, v);
}
-void glUniformMatrix2fv(
+void GLES2UniformMatrix2fv(
GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
- g_gl_impl->UniformMatrix2fv(location, count, transpose, value);
+ gles2::GetGLContext()->UniformMatrix2fv(location, count, transpose, value);
}
-void glUniformMatrix3fv(
+void GLES2UniformMatrix3fv(
GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
- g_gl_impl->UniformMatrix3fv(location, count, transpose, value);
+ gles2::GetGLContext()->UniformMatrix3fv(location, count, transpose, value);
}
-void glUniformMatrix4fv(
+void GLES2UniformMatrix4fv(
GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
- g_gl_impl->UniformMatrix4fv(location, count, transpose, value);
+ gles2::GetGLContext()->UniformMatrix4fv(location, count, transpose, value);
}
-void glUseProgram(GLuint program) {
- g_gl_impl->UseProgram(program);
+void GLES2UseProgram(GLuint program) {
+ gles2::GetGLContext()->UseProgram(program);
}
-void glValidateProgram(GLuint program) {
- g_gl_impl->ValidateProgram(program);
+void GLES2ValidateProgram(GLuint program) {
+ gles2::GetGLContext()->ValidateProgram(program);
}
-void glVertexAttrib1f(GLuint indx, GLfloat x) {
- g_gl_impl->VertexAttrib1f(indx, x);
+void GLES2VertexAttrib1f(GLuint indx, GLfloat x) {
+ gles2::GetGLContext()->VertexAttrib1f(indx, x);
}
-void glVertexAttrib1fv(GLuint indx, const GLfloat* values) {
- g_gl_impl->VertexAttrib1fv(indx, values);
+void GLES2VertexAttrib1fv(GLuint indx, const GLfloat* values) {
+ gles2::GetGLContext()->VertexAttrib1fv(indx, values);
}
-void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) {
- g_gl_impl->VertexAttrib2f(indx, x, y);
+void GLES2VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) {
+ gles2::GetGLContext()->VertexAttrib2f(indx, x, y);
}
-void glVertexAttrib2fv(GLuint indx, const GLfloat* values) {
- g_gl_impl->VertexAttrib2fv(indx, values);
+void GLES2VertexAttrib2fv(GLuint indx, const GLfloat* values) {
+ gles2::GetGLContext()->VertexAttrib2fv(indx, values);
}
-void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) {
- g_gl_impl->VertexAttrib3f(indx, x, y, z);
+void GLES2VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) {
+ gles2::GetGLContext()->VertexAttrib3f(indx, x, y, z);
}
-void glVertexAttrib3fv(GLuint indx, const GLfloat* values) {
- g_gl_impl->VertexAttrib3fv(indx, values);
+void GLES2VertexAttrib3fv(GLuint indx, const GLfloat* values) {
+ gles2::GetGLContext()->VertexAttrib3fv(indx, values);
}
-void glVertexAttrib4f(
+void GLES2VertexAttrib4f(
GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
- g_gl_impl->VertexAttrib4f(indx, x, y, z, w);
+ gles2::GetGLContext()->VertexAttrib4f(indx, x, y, z, w);
}
-void glVertexAttrib4fv(GLuint indx, const GLfloat* values) {
- g_gl_impl->VertexAttrib4fv(indx, values);
+void GLES2VertexAttrib4fv(GLuint indx, const GLfloat* values) {
+ gles2::GetGLContext()->VertexAttrib4fv(indx, values);
}
-void glVertexAttribPointer(
+void GLES2VertexAttribPointer(
GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
const void* ptr) {
- g_gl_impl->VertexAttribPointer(indx, size, type, normalized, stride, ptr);
+ gles2::GetGLContext(
+ )->VertexAttribPointer(indx, size, type, normalized, stride, ptr);
}
-void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
- g_gl_impl->Viewport(x, y, width, height);
+void GLES2Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {
+ gles2::GetGLContext()->Viewport(x, y, width, height);
+}
+void GLES2SwapBuffers() {
+ gles2::GetGLContext()->SwapBuffers();
}
diff --git a/o3d/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/o3d/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
index 9af93cd..1cfee5b 100644
--- a/o3d/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
+++ b/o3d/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
@@ -1136,3 +1136,8 @@
c.Init(x, y, width, height);
}
+ void SwapBuffers() {
+ gles2::SwapBuffers& c = GetCmdSpace<gles2::SwapBuffers>();
+ c.Init();
+ }
+
diff --git a/o3d/gpu/command_buffer/client/gles2_demo.cc b/o3d/gpu/command_buffer/client/gles2_demo.cc
new file mode 100644
index 0000000..04419c3
--- /dev/null
+++ b/o3d/gpu/command_buffer/client/gles2_demo.cc
@@ -0,0 +1,203 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is here so other GLES2 related files can have a common set of
+// includes where appropriate.
+
+#include <windows.h>
+#include <windowsx.h>
+#include <shellapi.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "base/ref_counted.h"
+#include "base/shared_memory.h"
+#include "base/scoped_ptr.h"
+#include "gpu/command_buffer/service/gpu_processor.h"
+#include "gpu/command_buffer/service/command_buffer_service.h"
+#include "gpu/np_utils/np_utils.h"
+#include "gpu/command_buffer/client/gles2_implementation.h"
+#include "gpu/command_buffer/client/gles2_lib.h"
+#include "gpu/command_buffer/client/gles2_demo_c.h"
+#include "gpu/command_buffer/client/gles2_demo_cc.h"
+
+using base::SharedMemory;
+using command_buffer::GPUProcessor;
+using command_buffer::CommandBufferService;
+using command_buffer::gles2::GLES2CmdHelper;
+using command_buffer::gles2::GLES2Implementation;
+
+class GLES2Demo {
+ public:
+ GLES2Demo();
+
+ bool GLES2Demo::Setup(NPP npp, void* hwnd, int32 size);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GLES2Demo);
+};
+
+GLES2Demo::GLES2Demo() {
+}
+
+bool GLES2Demo::Setup(NPP npp, void* hwnd, int32 size) {
+ scoped_ptr<SharedMemory> ring_buffer(new SharedMemory);
+ if (!ring_buffer->Create(std::wstring(), false, false, size)) {
+ return NULL;
+ }
+
+ if (!ring_buffer->Map(size)) {
+ return NULL;
+ }
+
+ scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService);
+ if (!command_buffer->Initialize(ring_buffer.release())) {
+ return NULL;
+ }
+
+ scoped_refptr<GPUProcessor> gpu_processor(
+ new GPUProcessor(npp, command_buffer.get()));
+ if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd))) {
+ return NULL;
+ }
+
+ command_buffer->SetPutOffsetChangeCallback(
+ NewCallback(gpu_processor.get(), &GPUProcessor::ProcessCommands));
+
+ GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get());
+ if (!helper->Initialize()) {
+ // TODO(gman): cleanup.
+ return false;
+ }
+
+ size_t transfer_buffer_size = 512 * 1024;
+ int32 transfer_buffer_id =
+ command_buffer->CreateTransferBuffer(transfer_buffer_size);
+ void* transfer_buffer =
+ command_buffer->GetTransferBuffer(transfer_buffer_id);
+
+ gles2::g_gl_impl = new GLES2Implementation(helper,
+ transfer_buffer,
+ transfer_buffer_id);
+
+ return command_buffer.release() != NULL;
+}
+
+#if defined(OS_WIN)
+LRESULT CALLBACK WindowProc(
+ HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
+ switch (msg) {
+ case WM_CLOSE:
+ DestroyWindow(hwnd);
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ case WM_PAINT: {
+ GLFromCPPTestFunction();
+ GLFromCTestFunction();
+ // TODO(gman): Not sure how SwapBuffer should be exposed.
+ gles2::GetGLContext()->SwapBuffers();
+ break;
+ }
+ default:
+ return ::DefWindowProc(hwnd, msg, w_param, l_param);
+ }
+ return 0;
+}
+
+HINSTANCE GetInstance(void) {
+ HWND hwnd = GetConsoleWindow();
+ return reinterpret_cast<HINSTANCE>(GetWindowLong(hwnd, GWL_HINSTANCE));
+}
+
+void ProcessMessages(void* in_hwnd) {
+ HWND hwnd = reinterpret_cast<HWND>(in_hwnd);
+ MSG msg;
+
+ bool done = false;
+ while (!done) {
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ if (msg.message == WM_QUIT) {
+ done = true;
+ }
+ // dispatch the message
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ if (!done) {
+ InvalidateRect(hwnd, NULL, TRUE);
+ }
+ }
+}
+
+#endif
+
+void* SetupWindow() {
+#if defined(OS_WIN)
+ HINSTANCE instance = GetInstance();
+ WNDCLASSEX wc = {0};
+ wc.lpszClassName = L"MY_WINDOWS_CLASS";
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = ::WindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = instance;
+ wc.hIcon = ::LoadIcon(instance, IDI_APPLICATION);
+ wc.hIconSm = NULL;
+ wc.hCursor = ::LoadCursor(instance, IDC_ARROW);
+ wc.hbrBackground = static_cast<HBRUSH>(::GetStockObject(BLACK_BRUSH));
+ wc.lpszMenuName = NULL;
+
+ if (!::RegisterClassEx(&wc))
+ return false;
+
+ // Leaving this window onscreen leads to a redraw error which makes it
+ // a hassle to debug tests in an IDE, so we place the window somewhere that
+ // won't happen.
+ HWND hwnd = ::CreateWindowExW(
+ NULL,
+ wc.lpszClassName,
+ L"",
+ WS_OVERLAPPEDWINDOW,
+ 10,
+ 0,
+ 512,
+ 512,
+ 0,
+ 0,
+ instance,
+ 0);
+
+ if (hwnd == NULL) {
+ return false;
+ }
+
+ ::ShowWindow(hwnd, SW_SHOWNORMAL);
+
+
+ return hwnd;
+#else
+#error Need code.
+#endif
+}
+
+int main(int argc, const char** argv) {
+ const int32 kCommandBufferSize = 1024 * 1024;
+ GLES2Demo* demo = new GLES2Demo();
+
+ void* hwnd = SetupWindow();
+ if (!hwnd) {
+ ::fprintf(stdout, "Could not setup window.\n");
+ return EXIT_FAILURE;
+ }
+
+ demo->Setup(NULL, hwnd, kCommandBufferSize);
+
+ ProcessMessages(hwnd);
+
+ return EXIT_SUCCESS;
+}
+
+
diff --git a/o3d/gpu/command_buffer/client/gles2_demo_c.c b/o3d/gpu/command_buffer/client/gles2_demo_c.c
new file mode 100644
index 0000000..44b2c57
--- /dev/null
+++ b/o3d/gpu/command_buffer/client/gles2_demo_c.c
@@ -0,0 +1,15 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is here so other GLES2 related files can have a common set of
+// includes where appropriate.
+
+#include <GLES2/gl2.h>
+#include "gpu/command_buffer/client/gles2_demo_c.h"
+
+void GLFromCTestFunction() {
+ glClear(GL_COLOR_BUFFER_BIT);
+}
+
+
diff --git a/o3d/gpu/command_buffer/client/gles2_demo_c.h b/o3d/gpu/command_buffer/client/gles2_demo_c.h
new file mode 100644
index 0000000..0cd1478
--- /dev/null
+++ b/o3d/gpu/command_buffer/client/gles2_demo_c.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// A Test that we can access GL from c.
+
+#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_DEMO_C_H
+#define GPU_COMMAND_BUFFER_CLIENT_GLES2_DEMO_C_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GLFromCTestFunction();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_DEMO_C_H
+
+
diff --git a/o3d/gpu/command_buffer/client/gles2_demo_cc.cc b/o3d/gpu/command_buffer/client/gles2_demo_cc.cc
new file mode 100644
index 0000000..d7a023c
--- /dev/null
+++ b/o3d/gpu/command_buffer/client/gles2_demo_cc.cc
@@ -0,0 +1,21 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is here so other GLES2 related files can have a common set of
+// includes where appropriate.
+
+#include <GLES2/gl2.h>
+#include "gpu/command_buffer/client/gles2_demo_cc.h"
+
+void GLFromCPPTestFunction() {
+ static bool foo = true;
+ foo = !foo;
+ glClearColor(
+ foo ? 1.0f : 0.0f,
+ foo ? 0.0f : 1.0f,
+ 1.0f,
+ 1.0f);
+}
+
+
diff --git a/o3d/gpu/command_buffer/client/gles2_demo_cc.h b/o3d/gpu/command_buffer/client/gles2_demo_cc.h
new file mode 100644
index 0000000..7f88d0e
--- /dev/null
+++ b/o3d/gpu/command_buffer/client/gles2_demo_cc.h
@@ -0,0 +1,14 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// A Test that we can access GL from C++.
+
+#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_DEMO_CC_H
+#define GPU_COMMAND_BUFFER_CLIENT_GLES2_DEMO_CC_H
+
+void GLFromCPPTestFunction();
+
+#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_DEMO_CC_H
+
+
diff --git a/o3d/gpu/command_buffer/client/gles2_implementation.cc b/o3d/gpu/command_buffer/client/gles2_implementation.cc
index 5f4e56f..e60e68b 100644
--- a/o3d/gpu/command_buffer/client/gles2_implementation.cc
+++ b/o3d/gpu/command_buffer/client/gles2_implementation.cc
@@ -14,11 +14,11 @@ namespace gles2 {
GLES2Implementation::GLES2Implementation(
GLES2CmdHelper* helper,
- ResourceId shared_memory_id,
- void* shared_memory_address)
+ void* transfer_buffer,
+ int transfer_buffer_id)
: util_(0), // TODO(gman): Get real number of compressed texture formats.
helper_(helper),
- shared_memory_(shared_memory_id, shared_memory_address),
+ shared_memory_(transfer_buffer, transfer_buffer_id),
pack_alignment_(4),
unpack_alignment_(4) {
}
@@ -35,6 +35,18 @@ void GLES2Implementation::FreeIds(GLsizei n, const GLuint* ids) {
}
}
+void GLES2Implementation::DrawElements(
+ GLenum mode, GLsizei count, GLenum type, const void* indices) {
+ helper_->DrawElements(mode, count, type, reinterpret_cast<GLuint>(indices));
+}
+
+void GLES2Implementation::VertexAttribPointer(
+ GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
+ const void* ptr) {
+ helper_->VertexAttribPointer(index, size, type, normalized, stride,
+ reinterpret_cast<GLuint>(ptr));
+}
+
void GLES2Implementation::ShaderSource(
GLuint shader, GLsizei count, const char** string, const GLint* length) {
// TODO(gman): change to use buckets and check that there is enough room.
diff --git a/o3d/gpu/command_buffer/client/gles2_implementation.h b/o3d/gpu/command_buffer/client/gles2_implementation.h
index dbeb9ad..2df52ca 100644
--- a/o3d/gpu/command_buffer/client/gles2_implementation.h
+++ b/o3d/gpu/command_buffer/client/gles2_implementation.h
@@ -5,6 +5,7 @@
#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H
#define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H
+#include "base/shared_memory.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
#include "gpu/command_buffer/client/id_allocator.h"
@@ -15,11 +16,9 @@ namespace gles2 {
// A class to help with shared memory.
class SharedMemoryHelper {
public:
- SharedMemoryHelper(
- unsigned int id,
- void* address)
- : id_(id),
- address_(address) {
+ SharedMemoryHelper(void* address, int id)
+ : address_(address),
+ id_(id) {
}
unsigned int GetOffset(void* address) const {
@@ -41,8 +40,8 @@ class SharedMemoryHelper {
}
private:
- ResourceId id_;
void* address_;
+ int id_;
DISALLOW_COPY_AND_ASSIGN(SharedMemoryHelper);
};
@@ -57,8 +56,8 @@ class GLES2Implementation {
public:
GLES2Implementation(
GLES2CmdHelper* helper,
- ResourceId shared_memory_id,
- void* shared_memory);
+ void* transfer_buffer,
+ int transfer_buffer_id); // TODO: add size.
// Include the auto-generated part of this class. We split this because
// it means we can easily edit the non-auto generated parts right here in
@@ -75,7 +74,7 @@ class GLES2Implementation {
GLES2Util util_;
GLES2CmdHelper* helper_;
IdAllocator id_allocator_;
- SharedMemoryHelper shared_memory_;
+ SharedMemoryHelper shared_memory_; // TODO(gman): rename transfer_buffer_.
// pack alignment as last set by glPixelStorei
GLint pack_alignment_;
diff --git a/o3d/gpu/command_buffer/client/gles2_implementation_autogen.h b/o3d/gpu/command_buffer/client/gles2_implementation_autogen.h
index 0d86245..940454b 100644
--- a/o3d/gpu/command_buffer/client/gles2_implementation_autogen.h
+++ b/o3d/gpu/command_buffer/client/gles2_implementation_autogen.h
@@ -254,7 +254,12 @@ void GetAttachedShaders(
int GetAttribLocation(GLuint program, const char* name) {
// TODO(gman): This needs to change to use SendString.
+ GLint* result = shared_memory_.GetAddressAs<GLint*>(0);
+ DCHECK(false); // pass in shared memory
helper_->GetAttribLocationImmediate(program, name);
+ int32 token = helper_->InsertToken();
+ helper_->WaitForToken(token);
+ return *result;
}
void GetBooleanv(GLenum pname, GLboolean* params) {
@@ -380,7 +385,12 @@ void GetUniformiv(GLuint program, GLint location, GLint* params);
int GetUniformLocation(GLuint program, const char* name) {
// TODO(gman): This needs to change to use SendString.
+ GLint* result = shared_memory_.GetAddressAs<GLint*>(0);
+ DCHECK(false); // pass in shared memory
helper_->GetUniformLocationImmediate(program, name);
+ int32 token = helper_->InsertToken();
+ helper_->WaitForToken(token);
+ return *result;
}
void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) {
@@ -668,3 +678,7 @@ void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {
helper_->Viewport(x, y, width, height);
}
+void SwapBuffers() {
+ helper_->SwapBuffers();
+}
+
diff --git a/o3d/gpu/command_buffer/client/gles2_implementation_gen.h b/o3d/gpu/command_buffer/client/gles2_implementation_gen.h
index 848a2f5..d385f8f 100644
--- a/o3d/gpu/command_buffer/client/gles2_implementation_gen.h
+++ b/o3d/gpu/command_buffer/client/gles2_implementation_gen.h
@@ -1,7 +1,9 @@
+
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+
// A class to emluate GLES2 over command buffers.
#include "gpu/command_buffer/client/gles2_implementation.h"
diff --git a/o3d/gpu/command_buffer/client/gles2_lib.cc b/o3d/gpu/command_buffer/client/gles2_lib.cc
index 924eb19..681f7ad 100644
--- a/o3d/gpu/command_buffer/client/gles2_lib.cc
+++ b/o3d/gpu/command_buffer/client/gles2_lib.cc
@@ -6,7 +6,12 @@
namespace gles2 {
-// Currently this is a place holder.
+::command_buffer::gles2::GLES2Implementation* g_gl_impl;
+
+bool InitGLES2Lib() {
+ // TODO(gman): Encapulate initalizing the GLES2 library for client apps.
+ return false;
+}
} // namespace gles2
diff --git a/o3d/gpu/command_buffer/client/gles2_lib.h b/o3d/gpu/command_buffer/client/gles2_lib.h
index 6cb413f..589d2050 100644
--- a/o3d/gpu/command_buffer/client/gles2_lib.h
+++ b/o3d/gpu/command_buffer/client/gles2_lib.h
@@ -13,10 +13,12 @@ namespace gles2 {
extern ::command_buffer::gles2::GLES2Implementation* g_gl_impl;
-// Include the auto-generated part of this file. We split this because it means
-// we can easily edit the non-auto generated parts right here in this file
-// instead of having to edit some template or the code generator.
-#include "gpu/command_buffer/client/gles2_lib_autogen.h"
+inline ::command_buffer::gles2::GLES2Implementation* GetGLContext() {
+ return g_gl_impl;
+}
+
+// Initializes the GLES2 library.
+bool InitGLES2Lib();
} // namespace gles2
diff --git a/o3d/gpu/command_buffer/client/gles2_lib_autogen.h b/o3d/gpu/command_buffer/client/gles2_lib_autogen.h
deleted file mode 100644
index d928c8c..0000000
--- a/o3d/gpu/command_buffer/client/gles2_lib_autogen.h
+++ /dev/null
@@ -1,493 +0,0 @@
-// This file is auto-generated. DO NOT EDIT!
-
-
-// These functions emluate GLES2 over command buffers.
-
-
-inline void glActiveTexture(GLenum texture) {
- g_gl_impl->ActiveTexture(texture);
-}
-inline void glAttachShader(GLuint program, GLuint shader) {
- g_gl_impl->AttachShader(program, shader);
-}
-inline void glBindAttribLocation(
- GLuint program, GLuint index, const char* name) {
- g_gl_impl->BindAttribLocation(program, index, name);
-}
-inline void glBindBuffer(GLenum target, GLuint buffer) {
- g_gl_impl->BindBuffer(target, buffer);
-}
-inline void glBindFramebuffer(GLenum target, GLuint framebuffer) {
- g_gl_impl->BindFramebuffer(target, framebuffer);
-}
-inline void glBindRenderbuffer(GLenum target, GLuint renderbuffer) {
- g_gl_impl->BindRenderbuffer(target, renderbuffer);
-}
-inline void glBindTexture(GLenum target, GLuint texture) {
- g_gl_impl->BindTexture(target, texture);
-}
-inline void glBlendColor(
- GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
- g_gl_impl->BlendColor(red, green, blue, alpha);
-}
-inline void glBlendEquation(GLenum mode) {
- g_gl_impl->BlendEquation(mode);
-}
-inline void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
- g_gl_impl->BlendEquationSeparate(modeRGB, modeAlpha);
-}
-inline void glBlendFunc(GLenum sfactor, GLenum dfactor) {
- g_gl_impl->BlendFunc(sfactor, dfactor);
-}
-inline void glBlendFuncSeparate(
- GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
- g_gl_impl->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
-}
-inline void glBufferData(
- GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
- g_gl_impl->BufferData(target, size, data, usage);
-}
-inline void glBufferSubData(
- GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
- g_gl_impl->BufferSubData(target, offset, size, data);
-}
-inline GLenum glCheckFramebufferStatus(GLenum target) {
- return g_gl_impl->CheckFramebufferStatus(target);
-}
-inline void glClear(GLbitfield mask) {
- g_gl_impl->Clear(mask);
-}
-inline void glClearColor(
- GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
- g_gl_impl->ClearColor(red, green, blue, alpha);
-}
-inline void glClearDepthf(GLclampf depth) {
- g_gl_impl->ClearDepthf(depth);
-}
-inline void glClearStencil(GLint s) {
- g_gl_impl->ClearStencil(s);
-}
-inline void glColorMask(
- GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
- g_gl_impl->ColorMask(red, green, blue, alpha);
-}
-inline void glCompileShader(GLuint shader) {
- g_gl_impl->CompileShader(shader);
-}
-inline void glCompressedTexImage2D(
- GLenum target, GLint level, GLenum internalformat, GLsizei width,
- GLsizei height, GLint border, GLsizei imageSize, const void* data) {
- g_gl_impl->CompressedTexImage2D(
- target, level, internalformat, width, height, border, imageSize, data);
-}
-inline void glCompressedTexSubImage2D(
- GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
- GLsizei height, GLenum format, GLsizei imageSize, const void* data) {
- g_gl_impl->CompressedTexSubImage2D(
- target, level, xoffset, yoffset, width, height, format, imageSize, data);
-}
-inline void glCopyTexImage2D(
- GLenum target, GLint level, GLenum internalformat, GLint x, GLint y,
- GLsizei width, GLsizei height, GLint border) {
- g_gl_impl->CopyTexImage2D(
- target, level, internalformat, x, y, width, height, border);
-}
-inline void glCopyTexSubImage2D(
- GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
- GLsizei width, GLsizei height) {
- g_gl_impl->CopyTexSubImage2D(
- target, level, xoffset, yoffset, x, y, width, height);
-}
-inline GLuint glCreateProgram() {
- return g_gl_impl->CreateProgram();
-}
-inline GLuint glCreateShader(GLenum type) {
- return g_gl_impl->CreateShader(type);
-}
-inline void glCullFace(GLenum mode) {
- g_gl_impl->CullFace(mode);
-}
-inline void glDeleteBuffers(GLsizei n, const GLuint* buffers) {
- g_gl_impl->DeleteBuffers(n, buffers);
-}
-inline void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) {
- g_gl_impl->DeleteFramebuffers(n, framebuffers);
-}
-inline void glDeleteProgram(GLuint program) {
- g_gl_impl->DeleteProgram(program);
-}
-inline void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) {
- g_gl_impl->DeleteRenderbuffers(n, renderbuffers);
-}
-inline void glDeleteShader(GLuint shader) {
- g_gl_impl->DeleteShader(shader);
-}
-inline void glDeleteTextures(GLsizei n, const GLuint* textures) {
- g_gl_impl->DeleteTextures(n, textures);
-}
-inline void glDepthFunc(GLenum func) {
- g_gl_impl->DepthFunc(func);
-}
-inline void glDepthMask(GLboolean flag) {
- g_gl_impl->DepthMask(flag);
-}
-inline void glDepthRangef(GLclampf zNear, GLclampf zFar) {
- g_gl_impl->DepthRangef(zNear, zFar);
-}
-inline void glDetachShader(GLuint program, GLuint shader) {
- g_gl_impl->DetachShader(program, shader);
-}
-inline void glDisable(GLenum cap) {
- g_gl_impl->Disable(cap);
-}
-inline void glDisableVertexAttribArray(GLuint index) {
- g_gl_impl->DisableVertexAttribArray(index);
-}
-inline void glDrawArrays(GLenum mode, GLint first, GLsizei count) {
- g_gl_impl->DrawArrays(mode, first, count);
-}
-inline void glDrawElements(
- GLenum mode, GLsizei count, GLenum type, const void* indices) {
- g_gl_impl->DrawElements(mode, count, type, indices);
-}
-inline void glEnable(GLenum cap) {
- g_gl_impl->Enable(cap);
-}
-inline void glEnableVertexAttribArray(GLuint index) {
- g_gl_impl->EnableVertexAttribArray(index);
-}
-inline void glFinish() {
- g_gl_impl->Finish();
-}
-inline void glFlush() {
- g_gl_impl->Flush();
-}
-inline void glFramebufferRenderbuffer(
- GLenum target, GLenum attachment, GLenum renderbuffertarget,
- GLuint renderbuffer) {
- g_gl_impl->FramebufferRenderbuffer(
- target, attachment, renderbuffertarget, renderbuffer);
-}
-inline void glFramebufferTexture2D(
- GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
- GLint level) {
- g_gl_impl->FramebufferTexture2D(
- target, attachment, textarget, texture, level);
-}
-inline void glFrontFace(GLenum mode) {
- g_gl_impl->FrontFace(mode);
-}
-inline void glGenBuffers(GLsizei n, GLuint* buffers) {
- g_gl_impl->GenBuffers(n, buffers);
-}
-inline void glGenerateMipmap(GLenum target) {
- g_gl_impl->GenerateMipmap(target);
-}
-inline void glGenFramebuffers(GLsizei n, GLuint* framebuffers) {
- g_gl_impl->GenFramebuffers(n, framebuffers);
-}
-inline void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) {
- g_gl_impl->GenRenderbuffers(n, renderbuffers);
-}
-inline void glGenTextures(GLsizei n, GLuint* textures) {
- g_gl_impl->GenTextures(n, textures);
-}
-inline void glGetActiveAttrib(
- GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
- GLenum* type, char* name) {
- g_gl_impl->GetActiveAttrib(
- program, index, bufsize, length, size, type, name);
-}
-inline void glGetActiveUniform(
- GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
- GLenum* type, char* name) {
- g_gl_impl->GetActiveUniform(
- program, index, bufsize, length, size, type, name);
-}
-inline void glGetAttachedShaders(
- GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
- g_gl_impl->GetAttachedShaders(program, maxcount, count, shaders);
-}
-inline int glGetAttribLocation(GLuint program, const char* name) {
- return g_gl_impl->GetAttribLocation(program, name);
-}
-inline void glGetBooleanv(GLenum pname, GLboolean* params) {
- g_gl_impl->GetBooleanv(pname, params);
-}
-inline void glGetBufferParameteriv(
- GLenum target, GLenum pname, GLint* params) {
- g_gl_impl->GetBufferParameteriv(target, pname, params);
-}
-inline GLenum glGetError() {
- return g_gl_impl->GetError();
-}
-inline void glGetFloatv(GLenum pname, GLfloat* params) {
- g_gl_impl->GetFloatv(pname, params);
-}
-inline void glGetFramebufferAttachmentParameteriv(
- GLenum target, GLenum attachment, GLenum pname, GLint* params) {
- g_gl_impl->GetFramebufferAttachmentParameteriv(
- target, attachment, pname, params);
-}
-inline void glGetIntegerv(GLenum pname, GLint* params) {
- g_gl_impl->GetIntegerv(pname, params);
-}
-inline void glGetProgramiv(GLuint program, GLenum pname, GLint* params) {
- g_gl_impl->GetProgramiv(program, pname, params);
-}
-inline void glGetProgramInfoLog(
- GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) {
- g_gl_impl->GetProgramInfoLog(program, bufsize, length, infolog);
-}
-inline void glGetRenderbufferParameteriv(
- GLenum target, GLenum pname, GLint* params) {
- g_gl_impl->GetRenderbufferParameteriv(target, pname, params);
-}
-inline void glGetShaderiv(GLuint shader, GLenum pname, GLint* params) {
- g_gl_impl->GetShaderiv(shader, pname, params);
-}
-inline void glGetShaderInfoLog(
- GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) {
- g_gl_impl->GetShaderInfoLog(shader, bufsize, length, infolog);
-}
-inline void glGetShaderPrecisionFormat(
- GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
- g_gl_impl->GetShaderPrecisionFormat(
- shadertype, precisiontype, range, precision);
-}
-inline void glGetShaderSource(
- GLuint shader, GLsizei bufsize, GLsizei* length, char* source) {
- g_gl_impl->GetShaderSource(shader, bufsize, length, source);
-}
-inline const GLubyte* glGetString(GLenum name) {
- return g_gl_impl->GetString(name);
-}
-inline void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) {
- g_gl_impl->GetTexParameterfv(target, pname, params);
-}
-inline void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) {
- g_gl_impl->GetTexParameteriv(target, pname, params);
-}
-inline void glGetUniformfv(GLuint program, GLint location, GLfloat* params) {
- g_gl_impl->GetUniformfv(program, location, params);
-}
-inline void glGetUniformiv(GLuint program, GLint location, GLint* params) {
- g_gl_impl->GetUniformiv(program, location, params);
-}
-inline int glGetUniformLocation(GLuint program, const char* name) {
- return g_gl_impl->GetUniformLocation(program, name);
-}
-inline void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) {
- g_gl_impl->GetVertexAttribfv(index, pname, params);
-}
-inline void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) {
- g_gl_impl->GetVertexAttribiv(index, pname, params);
-}
-inline void glGetVertexAttribPointerv(
- GLuint index, GLenum pname, void** pointer) {
- g_gl_impl->GetVertexAttribPointerv(index, pname, pointer);
-}
-inline void glHint(GLenum target, GLenum mode) {
- g_gl_impl->Hint(target, mode);
-}
-inline GLboolean glIsBuffer(GLuint buffer) {
- return g_gl_impl->IsBuffer(buffer);
-}
-inline GLboolean glIsEnabled(GLenum cap) {
- return g_gl_impl->IsEnabled(cap);
-}
-inline GLboolean glIsFramebuffer(GLuint framebuffer) {
- return g_gl_impl->IsFramebuffer(framebuffer);
-}
-inline GLboolean glIsProgram(GLuint program) {
- return g_gl_impl->IsProgram(program);
-}
-inline GLboolean glIsRenderbuffer(GLuint renderbuffer) {
- return g_gl_impl->IsRenderbuffer(renderbuffer);
-}
-inline GLboolean glIsShader(GLuint shader) {
- return g_gl_impl->IsShader(shader);
-}
-inline GLboolean glIsTexture(GLuint texture) {
- return g_gl_impl->IsTexture(texture);
-}
-inline void glLineWidth(GLfloat width) {
- g_gl_impl->LineWidth(width);
-}
-inline void glLinkProgram(GLuint program) {
- g_gl_impl->LinkProgram(program);
-}
-inline void glPixelStorei(GLenum pname, GLint param) {
- g_gl_impl->PixelStorei(pname, param);
-}
-inline void glPolygonOffset(GLfloat factor, GLfloat units) {
- g_gl_impl->PolygonOffset(factor, units);
-}
-inline void glReadPixels(
- GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
- void* pixels) {
- g_gl_impl->ReadPixels(x, y, width, height, format, type, pixels);
-}
-inline void glRenderbufferStorage(
- GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
- g_gl_impl->RenderbufferStorage(target, internalformat, width, height);
-}
-inline void glSampleCoverage(GLclampf value, GLboolean invert) {
- g_gl_impl->SampleCoverage(value, invert);
-}
-inline void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) {
- g_gl_impl->Scissor(x, y, width, height);
-}
-inline void glShaderSource(
- GLuint shader, GLsizei count, const char** string, const GLint* length) {
- g_gl_impl->ShaderSource(shader, count, string, length);
-}
-inline void glStencilFunc(GLenum func, GLint ref, GLuint mask) {
- g_gl_impl->StencilFunc(func, ref, mask);
-}
-inline void glStencilFuncSeparate(
- GLenum face, GLenum func, GLint ref, GLuint mask) {
- g_gl_impl->StencilFuncSeparate(face, func, ref, mask);
-}
-inline void glStencilMask(GLuint mask) {
- g_gl_impl->StencilMask(mask);
-}
-inline void glStencilMaskSeparate(GLenum face, GLuint mask) {
- g_gl_impl->StencilMaskSeparate(face, mask);
-}
-inline void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) {
- g_gl_impl->StencilOp(fail, zfail, zpass);
-}
-inline void glStencilOpSeparate(
- GLenum face, GLenum fail, GLenum zfail, GLenum zpass) {
- g_gl_impl->StencilOpSeparate(face, fail, zfail, zpass);
-}
-inline void glTexImage2D(
- GLenum target, GLint level, GLint internalformat, GLsizei width,
- GLsizei height, GLint border, GLenum format, GLenum type,
- const void* pixels) {
- g_gl_impl->TexImage2D(
- target, level, internalformat, width, height, border, format, type,
- pixels);
-}
-inline void glTexParameterf(GLenum target, GLenum pname, GLfloat param) {
- g_gl_impl->TexParameterf(target, pname, param);
-}
-inline void glTexParameterfv(
- GLenum target, GLenum pname, const GLfloat* params) {
- g_gl_impl->TexParameterfv(target, pname, params);
-}
-inline void glTexParameteri(GLenum target, GLenum pname, GLint param) {
- g_gl_impl->TexParameteri(target, pname, param);
-}
-inline void glTexParameteriv(
- GLenum target, GLenum pname, const GLint* params) {
- g_gl_impl->TexParameteriv(target, pname, params);
-}
-inline void glTexSubImage2D(
- GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
- GLsizei height, GLenum format, GLenum type, const void* pixels) {
- g_gl_impl->TexSubImage2D(
- target, level, xoffset, yoffset, width, height, format, type, pixels);
-}
-inline void glUniform1f(GLint location, GLfloat x) {
- g_gl_impl->Uniform1f(location, x);
-}
-inline void glUniform1fv(GLint location, GLsizei count, const GLfloat* v) {
- g_gl_impl->Uniform1fv(location, count, v);
-}
-inline void glUniform1i(GLint location, GLint x) {
- g_gl_impl->Uniform1i(location, x);
-}
-inline void glUniform1iv(GLint location, GLsizei count, const GLint* v) {
- g_gl_impl->Uniform1iv(location, count, v);
-}
-inline void glUniform2f(GLint location, GLfloat x, GLfloat y) {
- g_gl_impl->Uniform2f(location, x, y);
-}
-inline void glUniform2fv(GLint location, GLsizei count, const GLfloat* v) {
- g_gl_impl->Uniform2fv(location, count, v);
-}
-inline void glUniform2i(GLint location, GLint x, GLint y) {
- g_gl_impl->Uniform2i(location, x, y);
-}
-inline void glUniform2iv(GLint location, GLsizei count, const GLint* v) {
- g_gl_impl->Uniform2iv(location, count, v);
-}
-inline void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) {
- g_gl_impl->Uniform3f(location, x, y, z);
-}
-inline void glUniform3fv(GLint location, GLsizei count, const GLfloat* v) {
- g_gl_impl->Uniform3fv(location, count, v);
-}
-inline void glUniform3i(GLint location, GLint x, GLint y, GLint z) {
- g_gl_impl->Uniform3i(location, x, y, z);
-}
-inline void glUniform3iv(GLint location, GLsizei count, const GLint* v) {
- g_gl_impl->Uniform3iv(location, count, v);
-}
-inline void glUniform4f(
- GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
- g_gl_impl->Uniform4f(location, x, y, z, w);
-}
-inline void glUniform4fv(GLint location, GLsizei count, const GLfloat* v) {
- g_gl_impl->Uniform4fv(location, count, v);
-}
-inline void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) {
- g_gl_impl->Uniform4i(location, x, y, z, w);
-}
-inline void glUniform4iv(GLint location, GLsizei count, const GLint* v) {
- g_gl_impl->Uniform4iv(location, count, v);
-}
-inline void glUniformMatrix2fv(
- GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
- g_gl_impl->UniformMatrix2fv(location, count, transpose, value);
-}
-inline void glUniformMatrix3fv(
- GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
- g_gl_impl->UniformMatrix3fv(location, count, transpose, value);
-}
-inline void glUniformMatrix4fv(
- GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
- g_gl_impl->UniformMatrix4fv(location, count, transpose, value);
-}
-inline void glUseProgram(GLuint program) {
- g_gl_impl->UseProgram(program);
-}
-inline void glValidateProgram(GLuint program) {
- g_gl_impl->ValidateProgram(program);
-}
-inline void glVertexAttrib1f(GLuint indx, GLfloat x) {
- g_gl_impl->VertexAttrib1f(indx, x);
-}
-inline void glVertexAttrib1fv(GLuint indx, const GLfloat* values) {
- g_gl_impl->VertexAttrib1fv(indx, values);
-}
-inline void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) {
- g_gl_impl->VertexAttrib2f(indx, x, y);
-}
-inline void glVertexAttrib2fv(GLuint indx, const GLfloat* values) {
- g_gl_impl->VertexAttrib2fv(indx, values);
-}
-inline void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) {
- g_gl_impl->VertexAttrib3f(indx, x, y, z);
-}
-inline void glVertexAttrib3fv(GLuint indx, const GLfloat* values) {
- g_gl_impl->VertexAttrib3fv(indx, values);
-}
-inline void glVertexAttrib4f(
- GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
- g_gl_impl->VertexAttrib4f(indx, x, y, z, w);
-}
-inline void glVertexAttrib4fv(GLuint indx, const GLfloat* values) {
- g_gl_impl->VertexAttrib4fv(indx, values);
-}
-inline void glVertexAttribPointer(
- GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
- const void* ptr) {
- g_gl_impl->VertexAttribPointer(indx, size, type, normalized, stride, ptr);
-}
-inline void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
- g_gl_impl->Viewport(x, y, width, height);
-}
-
diff --git a/o3d/gpu/command_buffer/common/GLES2/gl2.h b/o3d/gpu/command_buffer/common/GLES2/gl2.h
index 94c643b..6293ee4 100644
--- a/o3d/gpu/command_buffer/common/GLES2/gl2.h
+++ b/o3d/gpu/command_buffer/common/GLES2/gl2.h
@@ -3,472 +3,172 @@
/* $Revision: 8784 $ on $Date:: 2009-09-02 09:49:17 -0700 #$ */
-#include <GLES2/gl2platform.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
-/*-------------------------------------------------------------------------
- * Data type definitions
- *-----------------------------------------------------------------------*/
-
-typedef void GLvoid;
-typedef unsigned int GLenum;
-typedef unsigned char GLboolean;
-typedef unsigned int GLbitfield;
-typedef khronos_int8_t GLbyte;
-typedef short GLshort;
-typedef int GLint;
-typedef int GLsizei;
-typedef khronos_uint8_t GLubyte;
-typedef unsigned short GLushort;
-typedef unsigned int GLuint;
-typedef khronos_float_t GLfloat;
-typedef khronos_float_t GLclampf;
-typedef khronos_int32_t GLfixed;
-
-/* GL types for handling large vertex buffer objects */
-typedef khronos_intptr_t GLintptr;
-typedef khronos_ssize_t GLsizeiptr;
-
-/* OpenGL ES core versions */
-#define GL_ES_VERSION_2_0 1
-
-/* ClearBufferMask */
-#define GL_DEPTH_BUFFER_BIT 0x00000100
-#define GL_STENCIL_BUFFER_BIT 0x00000400
-#define GL_COLOR_BUFFER_BIT 0x00004000
-
-/* Boolean */
-#define GL_FALSE 0
-#define GL_TRUE 1
-
-/* BeginMode */
-#define GL_POINTS 0x0000
-#define GL_LINES 0x0001
-#define GL_LINE_LOOP 0x0002
-#define GL_LINE_STRIP 0x0003
-#define GL_TRIANGLES 0x0004
-#define GL_TRIANGLE_STRIP 0x0005
-#define GL_TRIANGLE_FAN 0x0006
-
-/* AlphaFunction (not supported in ES20) */
-/* GL_NEVER */
-/* GL_LESS */
-/* GL_EQUAL */
-/* GL_LEQUAL */
-/* GL_GREATER */
-/* GL_NOTEQUAL */
-/* GL_GEQUAL */
-/* GL_ALWAYS */
-
-/* BlendingFactorDest */
-#define GL_ZERO 0
-#define GL_ONE 1
-#define GL_SRC_COLOR 0x0300
-#define GL_ONE_MINUS_SRC_COLOR 0x0301
-#define GL_SRC_ALPHA 0x0302
-#define GL_ONE_MINUS_SRC_ALPHA 0x0303
-#define GL_DST_ALPHA 0x0304
-#define GL_ONE_MINUS_DST_ALPHA 0x0305
-
-/* BlendingFactorSrc */
-/* GL_ZERO */
-/* GL_ONE */
-#define GL_DST_COLOR 0x0306
-#define GL_ONE_MINUS_DST_COLOR 0x0307
-#define GL_SRC_ALPHA_SATURATE 0x0308
-/* GL_SRC_ALPHA */
-/* GL_ONE_MINUS_SRC_ALPHA */
-/* GL_DST_ALPHA */
-/* GL_ONE_MINUS_DST_ALPHA */
-
-/* BlendEquationSeparate */
-#define GL_FUNC_ADD 0x8006
-#define GL_BLEND_EQUATION 0x8009
-#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
-#define GL_BLEND_EQUATION_ALPHA 0x883D
-
-/* BlendSubtract */
-#define GL_FUNC_SUBTRACT 0x800A
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-
-/* Separate Blend Functions */
-#define GL_BLEND_DST_RGB 0x80C8
-#define GL_BLEND_SRC_RGB 0x80C9
-#define GL_BLEND_DST_ALPHA 0x80CA
-#define GL_BLEND_SRC_ALPHA 0x80CB
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#define GL_BLEND_COLOR 0x8005
-
-/* Buffer Objects */
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#define GL_ARRAY_BUFFER_BINDING 0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-
-#define GL_STREAM_DRAW 0x88E0
-#define GL_STATIC_DRAW 0x88E4
-#define GL_DYNAMIC_DRAW 0x88E8
-
-#define GL_BUFFER_SIZE 0x8764
-#define GL_BUFFER_USAGE 0x8765
-
-#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-
-/* CullFaceMode */
-#define GL_FRONT 0x0404
-#define GL_BACK 0x0405
-#define GL_FRONT_AND_BACK 0x0408
-
-/* DepthFunction */
-/* GL_NEVER */
-/* GL_LESS */
-/* GL_EQUAL */
-/* GL_LEQUAL */
-/* GL_GREATER */
-/* GL_NOTEQUAL */
-/* GL_GEQUAL */
-/* GL_ALWAYS */
-
-/* EnableCap */
-#define GL_TEXTURE_2D 0x0DE1
-#define GL_CULL_FACE 0x0B44
-#define GL_BLEND 0x0BE2
-#define GL_DITHER 0x0BD0
-#define GL_STENCIL_TEST 0x0B90
-#define GL_DEPTH_TEST 0x0B71
-#define GL_SCISSOR_TEST 0x0C11
-#define GL_POLYGON_OFFSET_FILL 0x8037
-#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
-#define GL_SAMPLE_COVERAGE 0x80A0
-
-/* ErrorCode */
-#define GL_NO_ERROR 0
-#define GL_INVALID_ENUM 0x0500
-#define GL_INVALID_VALUE 0x0501
-#define GL_INVALID_OPERATION 0x0502
-#define GL_OUT_OF_MEMORY 0x0505
-
-/* FrontFaceDirection */
-#define GL_CW 0x0900
-#define GL_CCW 0x0901
-
-/* GetPName */
-#define GL_LINE_WIDTH 0x0B21
-#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-#define GL_CULL_FACE_MODE 0x0B45
-#define GL_FRONT_FACE 0x0B46
-#define GL_DEPTH_RANGE 0x0B70
-#define GL_DEPTH_WRITEMASK 0x0B72
-#define GL_DEPTH_CLEAR_VALUE 0x0B73
-#define GL_DEPTH_FUNC 0x0B74
-#define GL_STENCIL_CLEAR_VALUE 0x0B91
-#define GL_STENCIL_FUNC 0x0B92
-#define GL_STENCIL_FAIL 0x0B94
-#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
-#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
-#define GL_STENCIL_REF 0x0B97
-#define GL_STENCIL_VALUE_MASK 0x0B93
-#define GL_STENCIL_WRITEMASK 0x0B98
-#define GL_STENCIL_BACK_FUNC 0x8800
-#define GL_STENCIL_BACK_FAIL 0x8801
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
-#define GL_STENCIL_BACK_REF 0x8CA3
-#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
-#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
-#define GL_VIEWPORT 0x0BA2
-#define GL_SCISSOR_BOX 0x0C10
-/* GL_SCISSOR_TEST */
-#define GL_COLOR_CLEAR_VALUE 0x0C22
-#define GL_COLOR_WRITEMASK 0x0C23
-#define GL_UNPACK_ALIGNMENT 0x0CF5
-#define GL_PACK_ALIGNMENT 0x0D05
-#define GL_MAX_TEXTURE_SIZE 0x0D33
-#define GL_MAX_VIEWPORT_DIMS 0x0D3A
-#define GL_SUBPIXEL_BITS 0x0D50
-#define GL_RED_BITS 0x0D52
-#define GL_GREEN_BITS 0x0D53
-#define GL_BLUE_BITS 0x0D54
-#define GL_ALPHA_BITS 0x0D55
-#define GL_DEPTH_BITS 0x0D56
-#define GL_STENCIL_BITS 0x0D57
-#define GL_POLYGON_OFFSET_UNITS 0x2A00
-/* GL_POLYGON_OFFSET_FILL */
-#define GL_POLYGON_OFFSET_FACTOR 0x8038
-#define GL_TEXTURE_BINDING_2D 0x8069
-#define GL_SAMPLE_BUFFERS 0x80A8
-#define GL_SAMPLES 0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-
-/* GetTextureParameter */
-/* GL_TEXTURE_MAG_FILTER */
-/* GL_TEXTURE_MIN_FILTER */
-/* GL_TEXTURE_WRAP_S */
-/* GL_TEXTURE_WRAP_T */
-
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-
-/* HintMode */
-#define GL_DONT_CARE 0x1100
-#define GL_FASTEST 0x1101
-#define GL_NICEST 0x1102
-
-/* HintTarget */
-#define GL_GENERATE_MIPMAP_HINT 0x8192
+#include <GLES2/gl2types.h>
-/* DataType */
-#define GL_BYTE 0x1400
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_SHORT 0x1402
-#define GL_UNSIGNED_SHORT 0x1403
-#define GL_INT 0x1404
-#define GL_UNSIGNED_INT 0x1405
-#define GL_FLOAT 0x1406
-#define GL_FIXED 0x140C
-
-/* PixelFormat */
-#define GL_DEPTH_COMPONENT 0x1902
-#define GL_ALPHA 0x1906
-#define GL_RGB 0x1907
-#define GL_RGBA 0x1908
-#define GL_LUMINANCE 0x1909
-#define GL_LUMINANCE_ALPHA 0x190A
-
-/* PixelType */
-/* GL_UNSIGNED_BYTE */
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-
-/* Shaders */
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
-#define GL_MAX_VARYING_VECTORS 0x8DFC
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
-#define GL_SHADER_TYPE 0x8B4F
-#define GL_DELETE_STATUS 0x8B80
-#define GL_LINK_STATUS 0x8B82
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_ATTACHED_SHADERS 0x8B85
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#define GL_CURRENT_PROGRAM 0x8B8D
-
-/* StencilFunction */
-#define GL_NEVER 0x0200
-#define GL_LESS 0x0201
-#define GL_EQUAL 0x0202
-#define GL_LEQUAL 0x0203
-#define GL_GREATER 0x0204
-#define GL_NOTEQUAL 0x0205
-#define GL_GEQUAL 0x0206
-#define GL_ALWAYS 0x0207
-
-/* StencilOp */
-/* GL_ZERO */
-#define GL_KEEP 0x1E00
-#define GL_REPLACE 0x1E01
-#define GL_INCR 0x1E02
-#define GL_DECR 0x1E03
-#define GL_INVERT 0x150A
-#define GL_INCR_WRAP 0x8507
-#define GL_DECR_WRAP 0x8508
-
-/* StringName */
-#define GL_VENDOR 0x1F00
-#define GL_RENDERER 0x1F01
-#define GL_VERSION 0x1F02
-#define GL_EXTENSIONS 0x1F03
-
-/* TextureMagFilter */
-#define GL_NEAREST 0x2600
-#define GL_LINEAR 0x2601
-
-/* TextureMinFilter */
-/* GL_NEAREST */
-/* GL_LINEAR */
-#define GL_NEAREST_MIPMAP_NEAREST 0x2700
-#define GL_LINEAR_MIPMAP_NEAREST 0x2701
-#define GL_NEAREST_MIPMAP_LINEAR 0x2702
-#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-
-/* TextureParameterName */
-#define GL_TEXTURE_MAG_FILTER 0x2800
-#define GL_TEXTURE_MIN_FILTER 0x2801
-#define GL_TEXTURE_WRAP_S 0x2802
-#define GL_TEXTURE_WRAP_T 0x2803
-
-/* TextureTarget */
-/* GL_TEXTURE_2D */
-#define GL_TEXTURE 0x1702
-
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-
-/* TextureUnit */
-#define GL_TEXTURE0 0x84C0
-#define GL_TEXTURE1 0x84C1
-#define GL_TEXTURE2 0x84C2
-#define GL_TEXTURE3 0x84C3
-#define GL_TEXTURE4 0x84C4
-#define GL_TEXTURE5 0x84C5
-#define GL_TEXTURE6 0x84C6
-#define GL_TEXTURE7 0x84C7
-#define GL_TEXTURE8 0x84C8
-#define GL_TEXTURE9 0x84C9
-#define GL_TEXTURE10 0x84CA
-#define GL_TEXTURE11 0x84CB
-#define GL_TEXTURE12 0x84CC
-#define GL_TEXTURE13 0x84CD
-#define GL_TEXTURE14 0x84CE
-#define GL_TEXTURE15 0x84CF
-#define GL_TEXTURE16 0x84D0
-#define GL_TEXTURE17 0x84D1
-#define GL_TEXTURE18 0x84D2
-#define GL_TEXTURE19 0x84D3
-#define GL_TEXTURE20 0x84D4
-#define GL_TEXTURE21 0x84D5
-#define GL_TEXTURE22 0x84D6
-#define GL_TEXTURE23 0x84D7
-#define GL_TEXTURE24 0x84D8
-#define GL_TEXTURE25 0x84D9
-#define GL_TEXTURE26 0x84DA
-#define GL_TEXTURE27 0x84DB
-#define GL_TEXTURE28 0x84DC
-#define GL_TEXTURE29 0x84DD
-#define GL_TEXTURE30 0x84DE
-#define GL_TEXTURE31 0x84DF
-#define GL_ACTIVE_TEXTURE 0x84E0
-
-/* TextureWrapMode */
-#define GL_REPEAT 0x2901
-#define GL_CLAMP_TO_EDGE 0x812F
-#define GL_MIRRORED_REPEAT 0x8370
-
-/* Uniform Types */
-#define GL_FLOAT_VEC2 0x8B50
-#define GL_FLOAT_VEC3 0x8B51
-#define GL_FLOAT_VEC4 0x8B52
-#define GL_INT_VEC2 0x8B53
-#define GL_INT_VEC3 0x8B54
-#define GL_INT_VEC4 0x8B55
-#define GL_BOOL 0x8B56
-#define GL_BOOL_VEC2 0x8B57
-#define GL_BOOL_VEC3 0x8B58
-#define GL_BOOL_VEC4 0x8B59
-#define GL_FLOAT_MAT2 0x8B5A
-#define GL_FLOAT_MAT3 0x8B5B
-#define GL_FLOAT_MAT4 0x8B5C
-#define GL_SAMPLER_2D 0x8B5E
-#define GL_SAMPLER_CUBE 0x8B60
-
-/* Vertex Arrays */
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-
-/* Read Format */
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
-
-/* Shader Source */
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_INFO_LOG_LENGTH 0x8B84
-#define GL_SHADER_SOURCE_LENGTH 0x8B88
-#define GL_SHADER_COMPILER 0x8DFA
-
-/* Shader Binary */
-#define GL_SHADER_BINARY_FORMATS 0x8DF8
-#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
-
-/* Shader Precision-Specified Types */
-#define GL_LOW_FLOAT 0x8DF0
-#define GL_MEDIUM_FLOAT 0x8DF1
-#define GL_HIGH_FLOAT 0x8DF2
-#define GL_LOW_INT 0x8DF3
-#define GL_MEDIUM_INT 0x8DF4
-#define GL_HIGH_INT 0x8DF5
-
-/* Framebuffer Object. */
-#define GL_FRAMEBUFFER 0x8D40
-#define GL_RENDERBUFFER 0x8D41
-
-#define GL_RGBA4 0x8056
-#define GL_RGB5_A1 0x8057
-#define GL_RGB565 0x8D62
-#define GL_DEPTH_COMPONENT16 0x81A5
-#define GL_STENCIL_INDEX 0x1901
-#define GL_STENCIL_INDEX8 0x8D48
-
-#define GL_RENDERBUFFER_WIDTH 0x8D42
-#define GL_RENDERBUFFER_HEIGHT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
-#define GL_RENDERBUFFER_RED_SIZE 0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
-
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
-
-#define GL_COLOR_ATTACHMENT0 0x8CE0
-#define GL_DEPTH_ATTACHMENT 0x8D00
-#define GL_STENCIL_ATTACHMENT 0x8D20
-
-#define GL_NONE 0
-
-#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-
-#define GL_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_RENDERBUFFER_BINDING 0x8CA7
-#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-
-#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+#ifdef __cplusplus
+#include "gpu/command_buffer/client/gles2_lib.h"
+#define GLES2_GET_FUN(name) gles2::GetGLContext()->name
+#else
+#define GLES2_GET_FUN(name) GLES2 ## name
+#endif
/*-------------------------------------------------------------------------
* GL core functions.
*-----------------------------------------------------------------------*/
+#undef GL_APICALL
+#define GL_APICALL
+#undef GL_APIENTRY
+#define GL_APIENTRY
+
+#define glActiveTexture GLES2_GET_FUN(ActiveTexture)
+#define glAttachShader GLES2_GET_FUN(AttachShader)
+#define glBindAttribLocation GLES2_GET_FUN(BindAttribLocation)
+#define glBindBuffer GLES2_GET_FUN(BindBuffer)
+#define glBindFramebuffer GLES2_GET_FUN(BindFramebuffer)
+#define glBindRenderbuffer GLES2_GET_FUN(BindRenderbuffer)
+#define glBindTexture GLES2_GET_FUN(BindTexture)
+#define glBlendColor GLES2_GET_FUN(BlendColor)
+#define glBlendEquation GLES2_GET_FUN(BlendEquation)
+#define glBlendEquationSeparate GLES2_GET_FUN(BlendEquationSeparate)
+#define glBlendFunc GLES2_GET_FUN(BlendFunc)
+#define glBlendFuncSeparate GLES2_GET_FUN(BlendFuncSeparate)
+#define glBufferData GLES2_GET_FUN(BufferData)
+#define glBufferSubData GLES2_GET_FUN(BufferSubData)
+#define glCheckFramebufferStatus GLES2_GET_FUN(CheckFramebufferStatus)
+#define glClear GLES2_GET_FUN(Clear)
+#define glClearColor GLES2_GET_FUN(ClearColor)
+#define glClearDepthf GLES2_GET_FUN(ClearDepthf)
+#define glClearStencil GLES2_GET_FUN(ClearStencil)
+#define glColorMask GLES2_GET_FUN(ColorMask)
+#define glCompileShader GLES2_GET_FUN(CompileShader)
+#define glCompressedTexImage2D GLES2_GET_FUN(CompressedTexImage2D)
+#define glCompressedTexSubImage2D GLES2_GET_FUN(CompressedTexSubImage2D)
+#define glCopyTexImage2D GLES2_GET_FUN(CopyTexImage2D)
+#define glCopyTexSubImage2D GLES2_GET_FUN(CopyTexSubImage2D)
+#define glCreateProgram GLES2_GET_FUN(CreateProgram)
+#define glCreateShader GLES2_GET_FUN(CreateShader)
+#define glCullFace GLES2_GET_FUN(CullFace)
+#define glDeleteBuffers GLES2_GET_FUN(DeleteBuffers)
+#define glDeleteFramebuffers GLES2_GET_FUN(DeleteFramebuffers)
+#define glDeleteProgram GLES2_GET_FUN(DeleteProgram)
+#define glDeleteRenderbuffers GLES2_GET_FUN(DeleteRenderbuffers)
+#define glDeleteShader GLES2_GET_FUN(DeleteShader)
+#define glDeleteTextures GLES2_GET_FUN(DeleteTextures)
+#define glDepthFunc GLES2_GET_FUN(DepthFunc)
+#define glDepthMask GLES2_GET_FUN(DepthMask)
+#define glDepthRangef GLES2_GET_FUN(DepthRangef)
+#define glDetachShader GLES2_GET_FUN(DetachShader)
+#define glDisable GLES2_GET_FUN(Disable)
+#define glDisableVertexAttribArray GLES2_GET_FUN(DisableVertexAttribArray)
+#define glDrawArrays GLES2_GET_FUN(DrawArrays)
+#define glDrawElements GLES2_GET_FUN(DrawElements)
+#define glEnable GLES2_GET_FUN(Enable)
+#define glEnableVertexAttribArray GLES2_GET_FUN(EnableVertexAttribArray)
+#define glFinish GLES2_GET_FUN(Finish)
+#define glFlush GLES2_GET_FUN(Flush)
+#define glFramebufferRenderbuffer GLES2_GET_FUN(FramebufferRenderbuffer)
+#define glFramebufferTexture2D GLES2_GET_FUN(FramebufferTexture2D)
+#define glFrontFace GLES2_GET_FUN(FrontFace)
+#define glGenBuffers GLES2_GET_FUN(GenBuffers)
+#define glGenerateMipmap GLES2_GET_FUN(GenerateMipmap)
+#define glGenFramebuffers GLES2_GET_FUN(GenFramebuffers)
+#define glGenRenderbuffers GLES2_GET_FUN(GenRenderbuffers)
+#define glGenTextures GLES2_GET_FUN(GenTextures)
+#define glGetActiveAttrib GLES2_GET_FUN(GetActiveAttrib)
+#define glGetActiveUniform GLES2_GET_FUN(GetActiveUniform)
+#define glGetAttachedShaders GLES2_GET_FUN(GetAttachedShaders)
+#define glGetAttribLocation GLES2_GET_FUN(GetAttribLocation)
+#define glGetBooleanv GLES2_GET_FUN(GetBooleanv)
+#define glGetBufferParameteriv GLES2_GET_FUN(GetBufferParameteriv)
+#define glGetError GLES2_GET_FUN(GetError)
+#define glGetFloatv GLES2_GET_FUN(GetFloatv)
+#define glGetFramebufferAttachmentParameteriv GLES2_GET_FUN(GetFramebufferAttachmentParameteriv)
+#define glGetIntegerv GLES2_GET_FUN(GetIntegerv)
+#define glGetProgramiv GLES2_GET_FUN(GetProgramiv)
+#define glGetProgramInfoLog GLES2_GET_FUN(GetProgramInfoLog)
+#define glGetRenderbufferParameteriv GLES2_GET_FUN(GetRenderbufferParameteriv)
+#define glGetShaderiv GLES2_GET_FUN(GetShaderiv)
+#define glGetShaderInfoLog GLES2_GET_FUN(GetShaderInfoLog)
+#define glGetShaderPrecisionFormat GLES2_GET_FUN(GetShaderPrecisionFormat)
+#define glGetShaderSource GLES2_GET_FUN(GetShaderSource)
+#define glGetString GLES2_GET_FUN(GetString)
+#define glGetTexParameterfv GLES2_GET_FUN(GetTexParameterfv)
+#define glGetTexParameteriv GLES2_GET_FUN(GetTexParameteriv)
+#define glGetUniformfv GLES2_GET_FUN(GetUniformfv)
+#define glGetUniformiv GLES2_GET_FUN(GetUniformiv)
+#define glGetUniformLocation GLES2_GET_FUN(GetUniformLocation)
+#define glGetVertexAttribfv GLES2_GET_FUN(GetVertexAttribfv)
+#define glGetVertexAttribiv GLES2_GET_FUN(GetVertexAttribiv)
+#define glGetVertexAttribPointerv GLES2_GET_FUN(GetVertexAttribPointerv)
+#define glHint GLES2_GET_FUN(Hint)
+#define glIsBuffer GLES2_GET_FUN(IsBuffer)
+#define glIsEnabled GLES2_GET_FUN(IsEnabled)
+#define glIsFramebuffer GLES2_GET_FUN(IsFramebuffer)
+#define glIsProgram GLES2_GET_FUN(IsProgram)
+#define glIsRenderbuffer GLES2_GET_FUN(IsRenderbuffer)
+#define glIsShader GLES2_GET_FUN(IsShader)
+#define glIsTexture GLES2_GET_FUN(IsTexture)
+#define glLineWidth GLES2_GET_FUN(LineWidth)
+#define glLinkProgram GLES2_GET_FUN(LinkProgram)
+#define glPixelStorei GLES2_GET_FUN(PixelStorei)
+#define glPolygonOffset GLES2_GET_FUN(PolygonOffset)
+#define glReadPixels GLES2_GET_FUN(ReadPixels)
+#define glReleaseShaderCompiler GLES2_GET_FUN(ReleaseShaderCompiler)
+#define glRenderbufferStorage GLES2_GET_FUN(RenderbufferStorage)
+#define glSampleCoverage GLES2_GET_FUN(SampleCoverage)
+#define glScissor GLES2_GET_FUN(Scissor)
+#define glShaderBinary GLES2_GET_FUN(ShaderBinary)
+#define glShaderSource GLES2_GET_FUN(ShaderSource)
+#define glStencilFunc GLES2_GET_FUN(StencilFunc)
+#define glStencilFuncSeparate GLES2_GET_FUN(StencilFuncSeparate)
+#define glStencilMask GLES2_GET_FUN(StencilMask)
+#define glStencilMaskSeparate GLES2_GET_FUN(StencilMaskSeparate)
+#define glStencilOp GLES2_GET_FUN(StencilOp)
+#define glStencilOpSeparate GLES2_GET_FUN(StencilOpSeparate)
+#define glTexImage2D GLES2_GET_FUN(TexImage2D)
+#define glTexParameterf GLES2_GET_FUN(TexParameterf)
+#define glTexParameterfv GLES2_GET_FUN(TexParameterfv)
+#define glTexParameteri GLES2_GET_FUN(TexParameteri)
+#define glTexParameteriv GLES2_GET_FUN(TexParameteriv)
+#define glTexSubImage2D GLES2_GET_FUN(TexSubImage2D)
+#define glUniform1f GLES2_GET_FUN(Uniform1f)
+#define glUniform1fv GLES2_GET_FUN(Uniform1fv)
+#define glUniform1i GLES2_GET_FUN(Uniform1i)
+#define glUniform1iv GLES2_GET_FUN(Uniform1iv)
+#define glUniform2f GLES2_GET_FUN(Uniform2f)
+#define glUniform2fv GLES2_GET_FUN(Uniform2fv)
+#define glUniform2i GLES2_GET_FUN(Uniform2i)
+#define glUniform2iv GLES2_GET_FUN(Uniform2iv)
+#define glUniform3f GLES2_GET_FUN(Uniform3f)
+#define glUniform3fv GLES2_GET_FUN(Uniform3fv)
+#define glUniform3i GLES2_GET_FUN(Uniform3i)
+#define glUniform3iv GLES2_GET_FUN(Uniform3iv)
+#define glUniform4f GLES2_GET_FUN(Uniform4f)
+#define glUniform4fv GLES2_GET_FUN(Uniform4fv)
+#define glUniform4i GLES2_GET_FUN(Uniform4i)
+#define glUniform4iv GLES2_GET_FUN(Uniform4iv)
+#define glUniformMatrix2fv GLES2_GET_FUN(UniformMatrix2fv)
+#define glUniformMatrix3fv GLES2_GET_FUN(UniformMatrix3fv)
+#define glUniformMatrix4fv GLES2_GET_FUN(UniformMatrix4fv)
+#define glUseProgram GLES2_GET_FUN(UseProgram)
+#define glValidateProgram GLES2_GET_FUN(ValidateProgram)
+#define glVertexAttrib1f GLES2_GET_FUN(VertexAttrib1f)
+#define glVertexAttrib1fv GLES2_GET_FUN(VertexAttrib1fv)
+#define glVertexAttrib2f GLES2_GET_FUN(VertexAttrib2f)
+#define glVertexAttrib2fv GLES2_GET_FUN(VertexAttrib2fv)
+#define glVertexAttrib3f GLES2_GET_FUN(VertexAttrib3f)
+#define glVertexAttrib3fv GLES2_GET_FUN(VertexAttrib3fv)
+#define glVertexAttrib4f GLES2_GET_FUN(VertexAttrib4f)
+#define glVertexAttrib4fv GLES2_GET_FUN(VertexAttrib4fv)
+#define glVertexAttribPointer GLES2_GET_FUN(VertexAttribPointer)
+#define glViewport GLES2_GET_FUN(Viewport)
+
+#ifndef __cplusplus
GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
@@ -613,9 +313,7 @@ GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloa
GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
-#ifdef __cplusplus
-}
-#endif
+#endif // __cplusplus
#endif /* __gl2_h_ */
diff --git a/o3d/gpu/command_buffer/common/GLES2/gl2types.h b/o3d/gpu/command_buffer/common/GLES2/gl2types.h
new file mode 100644
index 0000000..85046d1
--- /dev/null
+++ b/o3d/gpu/command_buffer/common/GLES2/gl2types.h
@@ -0,0 +1,464 @@
+#ifndef __gl2types_h_
+#define __gl2types_h_
+
+#include <GLES2/gl2platform.h>
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/*-------------------------------------------------------------------------
+ * Data type definitions
+ *-----------------------------------------------------------------------*/
+
+typedef void GLvoid;
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef khronos_int8_t GLbyte;
+typedef short GLshort;
+typedef int GLint;
+typedef int GLsizei;
+typedef khronos_uint8_t GLubyte;
+typedef unsigned short GLushort;
+typedef unsigned int GLuint;
+typedef khronos_float_t GLfloat;
+typedef khronos_float_t GLclampf;
+typedef khronos_int32_t GLfixed;
+
+/* GL types for handling large vertex buffer objects */
+typedef khronos_intptr_t GLintptr;
+typedef khronos_ssize_t GLsizeiptr;
+
+/* OpenGL ES core versions */
+#define GL_ES_VERSION_2_0 1
+
+/* ClearBufferMask */
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_COLOR_BUFFER_BIT 0x00004000
+
+/* Boolean */
+#define GL_FALSE 0
+#define GL_TRUE 1
+
+/* BeginMode */
+#define GL_POINTS 0x0000
+#define GL_LINES 0x0001
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_FAN 0x0006
+
+/* AlphaFunction (not supported in ES20) */
+/* GL_NEVER */
+/* GL_LESS */
+/* GL_EQUAL */
+/* GL_LEQUAL */
+/* GL_GREATER */
+/* GL_NOTEQUAL */
+/* GL_GEQUAL */
+/* GL_ALWAYS */
+
+/* BlendingFactorDest */
+#define GL_ZERO 0
+#define GL_ONE 1
+#define GL_SRC_COLOR 0x0300
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_SRC_ALPHA 0x0302
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DST_ALPHA 0x0304
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+
+/* BlendingFactorSrc */
+/* GL_ZERO */
+/* GL_ONE */
+#define GL_DST_COLOR 0x0306
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_SRC_ALPHA_SATURATE 0x0308
+/* GL_SRC_ALPHA */
+/* GL_ONE_MINUS_SRC_ALPHA */
+/* GL_DST_ALPHA */
+/* GL_ONE_MINUS_DST_ALPHA */
+
+/* BlendEquationSeparate */
+#define GL_FUNC_ADD 0x8006
+#define GL_BLEND_EQUATION 0x8009
+#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+
+/* BlendSubtract */
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+
+/* Separate Blend Functions */
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_BLEND_COLOR 0x8005
+
+/* Buffer Objects */
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STATIC_DRAW 0x88E4
+#define GL_DYNAMIC_DRAW 0x88E8
+
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_USAGE 0x8765
+
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+
+/* CullFaceMode */
+#define GL_FRONT 0x0404
+#define GL_BACK 0x0405
+#define GL_FRONT_AND_BACK 0x0408
+
+/* DepthFunction */
+/* GL_NEVER */
+/* GL_LESS */
+/* GL_EQUAL */
+/* GL_LEQUAL */
+/* GL_GREATER */
+/* GL_NOTEQUAL */
+/* GL_GEQUAL */
+/* GL_ALWAYS */
+
+/* EnableCap */
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_CULL_FACE 0x0B44
+#define GL_BLEND 0x0BE2
+#define GL_DITHER 0x0BD0
+#define GL_STENCIL_TEST 0x0B90
+#define GL_DEPTH_TEST 0x0B71
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_COVERAGE 0x80A0
+
+/* ErrorCode */
+#define GL_NO_ERROR 0
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVALID_OPERATION 0x0502
+#define GL_OUT_OF_MEMORY 0x0505
+
+/* FrontFaceDirection */
+#define GL_CW 0x0900
+#define GL_CCW 0x0901
+
+/* GetPName */
+#define GL_LINE_WIDTH 0x0B21
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_FRONT_FACE 0x0B46
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#define GL_VIEWPORT 0x0BA2
+#define GL_SCISSOR_BOX 0x0C10
+/* GL_SCISSOR_TEST */
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_RED_BITS 0x0D52
+#define GL_GREEN_BITS 0x0D53
+#define GL_BLUE_BITS 0x0D54
+#define GL_ALPHA_BITS 0x0D55
+#define GL_DEPTH_BITS 0x0D56
+#define GL_STENCIL_BITS 0x0D57
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+/* GL_POLYGON_OFFSET_FILL */
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+
+/* GetTextureParameter */
+/* GL_TEXTURE_MAG_FILTER */
+/* GL_TEXTURE_MIN_FILTER */
+/* GL_TEXTURE_WRAP_S */
+/* GL_TEXTURE_WRAP_T */
+
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+
+/* HintMode */
+#define GL_DONT_CARE 0x1100
+#define GL_FASTEST 0x1101
+#define GL_NICEST 0x1102
+
+/* HintTarget */
+#define GL_GENERATE_MIPMAP_HINT 0x8192
+
+/* DataType */
+#define GL_BYTE 0x1400
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_SHORT 0x1402
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_INT 0x1404
+#define GL_UNSIGNED_INT 0x1405
+#define GL_FLOAT 0x1406
+#define GL_FIXED 0x140C
+
+/* PixelFormat */
+#define GL_DEPTH_COMPONENT 0x1902
+#define GL_ALPHA 0x1906
+#define GL_RGB 0x1907
+#define GL_RGBA 0x1908
+#define GL_LUMINANCE 0x1909
+#define GL_LUMINANCE_ALPHA 0x190A
+
+/* PixelType */
+/* GL_UNSIGNED_BYTE */
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+
+/* Shaders */
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_DELETE_STATUS 0x8B80
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
+
+/* StencilFunction */
+#define GL_NEVER 0x0200
+#define GL_LESS 0x0201
+#define GL_EQUAL 0x0202
+#define GL_LEQUAL 0x0203
+#define GL_GREATER 0x0204
+#define GL_NOTEQUAL 0x0205
+#define GL_GEQUAL 0x0206
+#define GL_ALWAYS 0x0207
+
+/* StencilOp */
+/* GL_ZERO */
+#define GL_KEEP 0x1E00
+#define GL_REPLACE 0x1E01
+#define GL_INCR 0x1E02
+#define GL_DECR 0x1E03
+#define GL_INVERT 0x150A
+#define GL_INCR_WRAP 0x8507
+#define GL_DECR_WRAP 0x8508
+
+/* StringName */
+#define GL_VENDOR 0x1F00
+#define GL_RENDERER 0x1F01
+#define GL_VERSION 0x1F02
+#define GL_EXTENSIONS 0x1F03
+
+/* TextureMagFilter */
+#define GL_NEAREST 0x2600
+#define GL_LINEAR 0x2601
+
+/* TextureMinFilter */
+/* GL_NEAREST */
+/* GL_LINEAR */
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+
+/* TextureParameterName */
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+
+/* TextureTarget */
+/* GL_TEXTURE_2D */
+#define GL_TEXTURE 0x1702
+
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+
+/* TextureUnit */
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+
+/* TextureWrapMode */
+#define GL_REPEAT 0x2901
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_MIRRORED_REPEAT 0x8370
+
+/* Uniform Types */
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_CUBE 0x8B60
+
+/* Vertex Arrays */
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+
+/* Read Format */
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+
+/* Shader Source */
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_SHADER_COMPILER 0x8DFA
+
+/* Shader Binary */
+#define GL_SHADER_BINARY_FORMATS 0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
+
+/* Shader Precision-Specified Types */
+#define GL_LOW_FLOAT 0x8DF0
+#define GL_MEDIUM_FLOAT 0x8DF1
+#define GL_HIGH_FLOAT 0x8DF2
+#define GL_LOW_INT 0x8DF3
+#define GL_MEDIUM_INT 0x8DF4
+#define GL_HIGH_INT 0x8DF5
+
+/* Framebuffer Object. */
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_RENDERBUFFER 0x8D41
+
+#define GL_RGBA4 0x8056
+#define GL_RGB5_A1 0x8057
+#define GL_RGB565 0x8D62
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_STENCIL_INDEX 0x1901
+#define GL_STENCIL_INDEX8 0x8D48
+
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_STENCIL_ATTACHMENT 0x8D20
+
+#define GL_NONE 0
+
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+
+#endif // __gl2types_h_
+
diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_format.h b/o3d/gpu/command_buffer/common/gles2_cmd_format.h
index fbf9e51..729149d 100644
--- a/o3d/gpu/command_buffer/common/gles2_cmd_format.h
+++ b/o3d/gpu/command_buffer/common/gles2_cmd_format.h
@@ -15,7 +15,7 @@
#include <GL/wglew.h>
#endif
#else
-#include <GLES2/gl2.h>
+#include <GLES2/gl2types.h>
#endif
#include "base/basictypes.h"
diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/o3d/gpu/command_buffer/common/gles2_cmd_format_autogen.h
index 88ccec0..e15713a 100644
--- a/o3d/gpu/command_buffer/common/gles2_cmd_format_autogen.h
+++ b/o3d/gpu/command_buffer/common/gles2_cmd_format_autogen.h
@@ -8244,5 +8244,35 @@ COMPILE_ASSERT(offsetof(Viewport, width) == 12,
COMPILE_ASSERT(offsetof(Viewport, height) == 16,
OffsetOf_Viewport_height_not_16);
+struct SwapBuffers {
+ typedef SwapBuffers ValueType;
+ static const CommandId kCmdId = kSwapBuffers;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+
+ static uint32 ComputeSize() {
+ return static_cast<uint32>(sizeof(ValueType)); // NOLINT
+ }
+
+ void SetHeader() {
+ header.SetCmd<ValueType>();
+ }
+
+ void Init() {
+ SetHeader();
+ }
+
+ void* Set(void* cmd) {
+ static_cast<ValueType*>(cmd)->Init();
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ command_buffer::CommandHeader header;
+};
+
+COMPILE_ASSERT(sizeof(SwapBuffers) == 4,
+ Sizeof_SwapBuffers_is_not_4);
+COMPILE_ASSERT(offsetof(SwapBuffers, header) == 0,
+ OffsetOf_SwapBuffers_header_not_0);
+
#pragma pack(pop)
diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/o3d/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
index 331efec..b914e07 100644
--- a/o3d/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
+++ b/o3d/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
@@ -2748,3 +2748,11 @@ TEST(GLES2FormatTest, Viewport) {
EXPECT_EQ(static_cast<GLsizei>(14), cmd.height);
}
+TEST(GLES2FormatTest, SwapBuffers) {
+ SwapBuffers cmd = { 0, };
+ void* next_cmd = cmd.Set(
+ &cmd);
+ EXPECT_EQ(SwapBuffers::kCmdId, cmd.header.command);
+ EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT
+}
+
diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_id_test.cc b/o3d/gpu/command_buffer/common/gles2_cmd_id_test.cc
index 8bcb00b..417ce3b 100644
--- a/o3d/gpu/command_buffer/common/gles2_cmd_id_test.cc
+++ b/o3d/gpu/command_buffer/common/gles2_cmd_id_test.cc
@@ -1,6 +1,8 @@
+
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+
// This file contains unit tests for gles2 commmand ids
#include "tests/common/win/testing_common.h"
@@ -362,6 +364,8 @@ TEST(GLES2CommandIdTest, CommandIdsMatch) {
GLES2_VertexAttribPointer_kCmdId_mismatch);
COMPILE_ASSERT(Viewport::kCmdId == 1198,
GLES2_Viewport_kCmdId_mismatch);
+ COMPILE_ASSERT(SwapBuffers::kCmdId == 1199,
+ GLES2_SwapBuffers_kCmdId_mismatch);
}
} // namespace gles2
} // namespace command_buffer
diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/o3d/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
index 3fee2f9..9e9d5c6 100644
--- a/o3d/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
+++ b/o3d/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
@@ -176,6 +176,7 @@
OP(VertexAttrib4fvImmediate) /* 1196 */ \
OP(VertexAttribPointer) /* 1197 */ \
OP(Viewport) /* 1198 */ \
+ OP(SwapBuffers) /* 1199 */ \
enum CommandId {
kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this.
diff --git a/o3d/gpu/command_buffer/service/gles2_cmd_decoder.cc b/o3d/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 7936713..159c5c5 100644
--- a/o3d/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/o3d/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -100,6 +100,53 @@ void GLDeleteTexturesHelper(GLsizei n, GLuint* ids) {
glDeleteTextures(n, ids);
}
+namespace GLErrorBit {
+enum GLErrorBit {
+ kNoError = 0,
+ kInvalidEnum,
+ kInvalidValue,
+ kInvalidOperation,
+ kOutOfMemory,
+ kInvalidFrameBufferOperation,
+};
+}
+
+uint32 GLErrorToErrorBit(GLenum error) {
+ switch(error) {
+ case GL_INVALID_ENUM:
+ return GLErrorBit::kInvalidEnum;
+ case GL_INVALID_VALUE:
+ return GLErrorBit::kInvalidValue;
+ case GL_INVALID_OPERATION:
+ return GLErrorBit::kInvalidOperation;
+ case GL_OUT_OF_MEMORY:
+ return GLErrorBit::kOutOfMemory;
+ case GL_INVALID_FRAMEBUFFER_OPERATION:
+ return GLErrorBit::kInvalidFrameBufferOperation;
+ default:
+ DCHECK(false);
+ return GLErrorBit::kNoError;
+ }
+}
+
+GLenum GLErrorBitToGLError(uint32 error_bit) {
+ switch(error_bit) {
+ case GLErrorBit::kInvalidEnum:
+ return GL_INVALID_ENUM;
+ case GLErrorBit::kInvalidValue:
+ return GL_INVALID_VALUE;
+ case GLErrorBit::kInvalidOperation:
+ return GL_INVALID_OPERATION;
+ case GLErrorBit::kOutOfMemory:
+ return GL_OUT_OF_MEMORY;
+ case GLErrorBit::kInvalidFrameBufferOperation:
+ return GL_INVALID_FRAMEBUFFER_OPERATION;
+ default:
+ DCHECK(false);
+ return GL_NO_ERROR;
+ }
+}
+
} // anonymous namespace.
GLES2Decoder::GLES2Decoder()
@@ -251,6 +298,15 @@ class GLES2DecoderImpl : public GLES2Decoder {
// Wrapper for glDeleteShader.
void DoDeleteShader(GLuint shader);
+ // Swaps the buffers (copies/renders to the current window).
+ void DoSwapBuffers();
+
+ // Gets the GLError through our wrapper.
+ GLenum GetGLError();
+
+ // Sets our wrapper for the GLError.
+ void SetGLError(GLenum error);
+
// Generate a member function prototype for each command in an automated and
// typesafe way.
#define GLES2_CMD_OP(name) \
@@ -262,8 +318,13 @@ class GLES2DecoderImpl : public GLES2Decoder {
#undef GLES2_CMD_OP
+ // Current GL error bits.
+ uint32 error_bits_;
+
// Map of client ids to GL ids.
IdMap id_map_;
+
+ // Util to help with GL.
GLES2Util util_;
// pack alignment as last set by glPixelStorei
@@ -296,6 +357,7 @@ GLES2Decoder* GLES2Decoder::Create() {
GLES2DecoderImpl::GLES2DecoderImpl()
: GLES2Decoder(),
+ error_bits_(0),
util_(0), // TODO(gman): Set to actual num compress texture formats.
pack_alignment_(4),
unpack_alignment_(4),
@@ -686,6 +748,43 @@ void GLES2DecoderImpl::DoDeleteShader(GLuint shader) {
}
}
+// NOTE: If you need to know the results of SwapBuffers (like losing
+// the context) then add a new command. Do NOT make SwapBuffers synchronous.
+void GLES2DecoderImpl::DoSwapBuffers() {
+#ifdef OS_WIN
+ ::SwapBuffers(device_context_);
+#endif
+
+#ifdef OS_LINUX
+ DCHECK(window());
+ window()->SwapBuffers();
+#endif
+}
+
+GLenum GLES2DecoderImpl::GetGLError() {
+ // Check the GL error first, then our wrapped error.
+ GLenum error = glGetError();
+ if (error == GL_NO_ERROR && error_bits_ != 0) {
+ uint32 mask = 1;
+ while (mask) {
+ if ((error_bits_ & mask) != 0) {
+ error = GLErrorBitToGLError(mask);
+ break;
+ }
+ }
+ }
+
+ if (error != GL_NO_ERROR) {
+ // There was an error, clear the corresponding wrapped error.
+ error_bits_ &= ~GLErrorToErrorBit(error);
+ }
+ return error;
+}
+
+void GLES2DecoderImpl::SetGLError(GLenum error) {
+ error_bits_ |= GLErrorToErrorBit(error);
+}
+
parse_error::ParseError GLES2DecoderImpl::HandleDrawElements(
unsigned int arg_count, const gles2::DrawElements& c) {
if (bound_element_array_buffer_ != 0) {
@@ -695,8 +794,7 @@ parse_error::ParseError GLES2DecoderImpl::HandleDrawElements(
const GLvoid* indices = reinterpret_cast<const GLvoid*>(c.index_offset);
glDrawElements(mode, count, type, indices);
} else {
- // TODO(gman): set our wrapped glGetError value to GL_INVALID_VALUE
- DCHECK(false);
+ SetGLError(GL_INVALID_VALUE);
}
return parse_error::kParseNoError;
}
@@ -783,8 +881,7 @@ parse_error::ParseError GLES2DecoderImpl::HandleVertexAttribPointer(
}
glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
} else {
- // TODO(gman): set our wrapped glGetError value to GL_INVALID_VALUE
- DCHECK(false);
+ SetGLError(GL_INVALID_VALUE);
}
return parse_error::kParseNoError;
}
diff --git a/o3d/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/o3d/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
index 581b280..1a247fd 100644
--- a/o3d/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/o3d/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -16,8 +16,16 @@ parse_error::ParseError GLES2DecoderImpl::HandleActiveTexture(
parse_error::ParseError GLES2DecoderImpl::HandleAttachShader(
unsigned int arg_count, const gles2::AttachShader& c) {
- GLuint program = static_cast<GLuint>(c.program);
- GLuint shader = static_cast<GLuint>(c.shader);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
+ GLuint shader;
+ if (!id_map_.GetServiceId(c.shader, &shader)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateAttachShader(this, arg_count, program, shader);
if (result != parse_error::kParseNoError) {
@@ -29,7 +37,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleAttachShader(
parse_error::ParseError GLES2DecoderImpl::HandleBindAttribLocation(
unsigned int arg_count, const gles2::BindAttribLocation& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLuint index = static_cast<GLuint>(c.index);
uint32 name_size = c.data_size;
const char* name = GetSharedMemoryAs<const char*>(
@@ -46,7 +58,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleBindAttribLocation(
parse_error::ParseError GLES2DecoderImpl::HandleBindAttribLocationImmediate(
unsigned int arg_count, const gles2::BindAttribLocationImmediate& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLuint index = static_cast<GLuint>(c.index);
uint32 name_size = c.data_size;
const char* name = GetImmediateDataAs<const char*>(c);
@@ -66,7 +82,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleBindAttribLocationImmediate(
parse_error::ParseError GLES2DecoderImpl::HandleBindBuffer(
unsigned int arg_count, const gles2::BindBuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
- GLuint buffer = static_cast<GLuint>(c.buffer);
+ GLuint buffer;
+ if (!id_map_.GetServiceId(c.buffer, &buffer)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateBindBuffer(this, arg_count, target, buffer);
if (result != parse_error::kParseNoError) {
@@ -79,7 +99,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleBindBuffer(
parse_error::ParseError GLES2DecoderImpl::HandleBindFramebuffer(
unsigned int arg_count, const gles2::BindFramebuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
- GLuint framebuffer = static_cast<GLuint>(c.framebuffer);
+ GLuint framebuffer;
+ if (!id_map_.GetServiceId(c.framebuffer, &framebuffer)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateBindFramebuffer(this, arg_count, target, framebuffer);
if (result != parse_error::kParseNoError) {
@@ -92,7 +116,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleBindFramebuffer(
parse_error::ParseError GLES2DecoderImpl::HandleBindRenderbuffer(
unsigned int arg_count, const gles2::BindRenderbuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
- GLuint renderbuffer = static_cast<GLuint>(c.renderbuffer);
+ GLuint renderbuffer;
+ if (!id_map_.GetServiceId(c.renderbuffer, &renderbuffer)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateBindRenderbuffer(this, arg_count, target, renderbuffer);
if (result != parse_error::kParseNoError) {
@@ -105,7 +133,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleBindRenderbuffer(
parse_error::ParseError GLES2DecoderImpl::HandleBindTexture(
unsigned int arg_count, const gles2::BindTexture& c) {
GLenum target = static_cast<GLenum>(c.target);
- GLuint texture = static_cast<GLuint>(c.texture);
+ GLuint texture;
+ if (!id_map_.GetServiceId(c.texture, &texture)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateBindTexture(this, arg_count, target, texture);
if (result != parse_error::kParseNoError) {
@@ -335,7 +367,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleColorMask(
parse_error::ParseError GLES2DecoderImpl::HandleCompileShader(
unsigned int arg_count, const gles2::CompileShader& c) {
- GLuint shader = static_cast<GLuint>(c.shader);
+ GLuint shader;
+ if (!id_map_.GetServiceId(c.shader, &shader)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateCompileShader(this, arg_count, shader);
if (result != parse_error::kParseNoError) {
@@ -582,7 +618,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
parse_error::ParseError GLES2DecoderImpl::HandleDeleteProgram(
unsigned int arg_count, const gles2::DeleteProgram& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateDeleteProgram(this, arg_count, program);
if (result != parse_error::kParseNoError) {
@@ -622,7 +662,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
parse_error::ParseError GLES2DecoderImpl::HandleDeleteShader(
unsigned int arg_count, const gles2::DeleteShader& c) {
- GLuint shader = static_cast<GLuint>(c.shader);
+ GLuint shader;
+ if (!id_map_.GetServiceId(c.shader, &shader)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateDeleteShader(this, arg_count, shader);
if (result != parse_error::kParseNoError) {
@@ -698,8 +742,16 @@ parse_error::ParseError GLES2DecoderImpl::HandleDepthRangef(
parse_error::ParseError GLES2DecoderImpl::HandleDetachShader(
unsigned int arg_count, const gles2::DetachShader& c) {
- GLuint program = static_cast<GLuint>(c.program);
- GLuint shader = static_cast<GLuint>(c.shader);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
+ GLuint shader;
+ if (!id_map_.GetServiceId(c.shader, &shader)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateDetachShader(this, arg_count, program, shader);
if (result != parse_error::kParseNoError) {
@@ -798,7 +850,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleFramebufferRenderbuffer(
GLenum target = static_cast<GLenum>(c.target);
GLenum attachment = static_cast<GLenum>(c.attachment);
GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget);
- GLuint renderbuffer = static_cast<GLuint>(c.renderbuffer);
+ GLuint renderbuffer;
+ if (!id_map_.GetServiceId(c.renderbuffer, &renderbuffer)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateFramebufferRenderbuffer(
this, arg_count, target, attachment, renderbuffertarget,
@@ -816,7 +872,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleFramebufferTexture2D(
GLenum target = static_cast<GLenum>(c.target);
GLenum attachment = static_cast<GLenum>(c.attachment);
GLenum textarget = static_cast<GLenum>(c.textarget);
- GLuint texture = static_cast<GLuint>(c.texture);
+ GLuint texture;
+ if (!id_map_.GetServiceId(c.texture, &texture)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLint level = static_cast<GLint>(c.level);
parse_error::ParseError result =
ValidateFramebufferTexture2D(
@@ -964,7 +1024,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleGenTexturesImmediate(
parse_error::ParseError GLES2DecoderImpl::HandleGetAttribLocation(
unsigned int arg_count, const gles2::GetAttribLocation& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
uint32 name_size = c.data_size;
const char* name = GetSharedMemoryAs<const char*>(
c.name_shm_id, c.name_shm_offset, name_size);
@@ -974,13 +1038,18 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetAttribLocation(
return result;
}
String name_str(name, name_size);
- glGetAttribLocation(program, name_str.c_str());
+ GLint location = glGetAttribLocation(program, name_str.c_str());
+ DCHECK(false); // TODO: return result.
return parse_error::kParseNoError;
}
parse_error::ParseError GLES2DecoderImpl::HandleGetAttribLocationImmediate(
unsigned int arg_count, const gles2::GetAttribLocationImmediate& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
uint32 name_size = c.data_size;
const char* name = GetImmediateDataAs<const char*>(c);
// TODO(gman): Make sure validate checks arg_count
@@ -991,7 +1060,8 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetAttribLocationImmediate(
return result;
}
String name_str(name, name_size);
- glGetAttribLocation(program, name_str.c_str());
+ GLint location = glGetAttribLocation(program, name_str.c_str());
+ DCHECK(false); // TODO: return result.
return parse_error::kParseNoError;
}
@@ -1101,7 +1171,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetIntegerv(
parse_error::ParseError GLES2DecoderImpl::HandleGetProgramiv(
unsigned int arg_count, const gles2::GetProgramiv& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLenum pname = static_cast<GLenum>(c.pname);
GLint* params;
GLsizei num_values = util_.GLGetNumValuesReturned(pname);
@@ -1119,7 +1193,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetProgramiv(
parse_error::ParseError GLES2DecoderImpl::HandleGetProgramInfoLog(
unsigned int arg_count, const gles2::GetProgramInfoLog& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLsizei bufsize = static_cast<GLsizei>(c.bufsize);
GLsizei* length = GetSharedMemoryAs<GLsizei*>(
c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */);
@@ -1156,7 +1234,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
parse_error::ParseError GLES2DecoderImpl::HandleGetShaderiv(
unsigned int arg_count, const gles2::GetShaderiv& c) {
- GLuint shader = static_cast<GLuint>(c.shader);
+ GLuint shader;
+ if (!id_map_.GetServiceId(c.shader, &shader)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLenum pname = static_cast<GLenum>(c.pname);
GLint* params;
GLsizei num_values = util_.GLGetNumValuesReturned(pname);
@@ -1174,7 +1256,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetShaderiv(
parse_error::ParseError GLES2DecoderImpl::HandleGetShaderInfoLog(
unsigned int arg_count, const gles2::GetShaderInfoLog& c) {
- GLuint shader = static_cast<GLuint>(c.shader);
+ GLuint shader;
+ if (!id_map_.GetServiceId(c.shader, &shader)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLsizei bufsize = static_cast<GLsizei>(c.bufsize);
GLsizei* length = GetSharedMemoryAs<GLsizei*>(
c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */);
@@ -1192,7 +1278,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetShaderInfoLog(
parse_error::ParseError GLES2DecoderImpl::HandleGetShaderSource(
unsigned int arg_count, const gles2::GetShaderSource& c) {
- GLuint shader = static_cast<GLuint>(c.shader);
+ GLuint shader;
+ if (!id_map_.GetServiceId(c.shader, &shader)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLsizei bufsize = static_cast<GLsizei>(c.bufsize);
GLsizei* length = GetSharedMemoryAs<GLsizei*>(
c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */);
@@ -1258,7 +1348,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetTexParameteriv(
parse_error::ParseError GLES2DecoderImpl::HandleGetUniformLocation(
unsigned int arg_count, const gles2::GetUniformLocation& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
uint32 name_size = c.data_size;
const char* name = GetSharedMemoryAs<const char*>(
c.name_shm_id, c.name_shm_offset, name_size);
@@ -1268,13 +1362,18 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetUniformLocation(
return result;
}
String name_str(name, name_size);
- glGetUniformLocation(program, name_str.c_str());
+ GLint location = glGetUniformLocation(program, name_str.c_str());
+ DCHECK(false); // TODO: return result.
return parse_error::kParseNoError;
}
parse_error::ParseError GLES2DecoderImpl::HandleGetUniformLocationImmediate(
unsigned int arg_count, const gles2::GetUniformLocationImmediate& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
uint32 name_size = c.data_size;
const char* name = GetImmediateDataAs<const char*>(c);
// TODO(gman): Make sure validate checks arg_count
@@ -1285,7 +1384,8 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetUniformLocationImmediate(
return result;
}
String name_str(name, name_size);
- glGetUniformLocation(program, name_str.c_str());
+ GLint location = glGetUniformLocation(program, name_str.c_str());
+ DCHECK(false); // TODO: return result.
return parse_error::kParseNoError;
}
@@ -1340,7 +1440,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleHint(
parse_error::ParseError GLES2DecoderImpl::HandleIsBuffer(
unsigned int arg_count, const gles2::IsBuffer& c) {
- GLuint buffer = static_cast<GLuint>(c.buffer);
+ GLuint buffer;
+ if (!id_map_.GetServiceId(c.buffer, &buffer)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
parse_error::ParseError result =
@@ -1368,7 +1472,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleIsEnabled(
parse_error::ParseError GLES2DecoderImpl::HandleIsFramebuffer(
unsigned int arg_count, const gles2::IsFramebuffer& c) {
- GLuint framebuffer = static_cast<GLuint>(c.framebuffer);
+ GLuint framebuffer;
+ if (!id_map_.GetServiceId(c.framebuffer, &framebuffer)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
parse_error::ParseError result =
@@ -1382,7 +1490,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleIsFramebuffer(
parse_error::ParseError GLES2DecoderImpl::HandleIsProgram(
unsigned int arg_count, const gles2::IsProgram& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
parse_error::ParseError result =
@@ -1396,7 +1508,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleIsProgram(
parse_error::ParseError GLES2DecoderImpl::HandleIsRenderbuffer(
unsigned int arg_count, const gles2::IsRenderbuffer& c) {
- GLuint renderbuffer = static_cast<GLuint>(c.renderbuffer);
+ GLuint renderbuffer;
+ if (!id_map_.GetServiceId(c.renderbuffer, &renderbuffer)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
parse_error::ParseError result =
@@ -1410,7 +1526,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleIsRenderbuffer(
parse_error::ParseError GLES2DecoderImpl::HandleIsShader(
unsigned int arg_count, const gles2::IsShader& c) {
- GLuint shader = static_cast<GLuint>(c.shader);
+ GLuint shader;
+ if (!id_map_.GetServiceId(c.shader, &shader)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
parse_error::ParseError result =
@@ -1424,7 +1544,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleIsShader(
parse_error::ParseError GLES2DecoderImpl::HandleIsTexture(
unsigned int arg_count, const gles2::IsTexture& c) {
- GLuint texture = static_cast<GLuint>(c.texture);
+ GLuint texture;
+ if (!id_map_.GetServiceId(c.texture, &texture)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>(
c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
parse_error::ParseError result =
@@ -1450,7 +1574,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleLineWidth(
parse_error::ParseError GLES2DecoderImpl::HandleLinkProgram(
unsigned int arg_count, const gles2::LinkProgram& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateLinkProgram(this, arg_count, program);
if (result != parse_error::kParseNoError) {
@@ -2254,7 +2382,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
parse_error::ParseError GLES2DecoderImpl::HandleUseProgram(
unsigned int arg_count, const gles2::UseProgram& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateUseProgram(this, arg_count, program);
if (result != parse_error::kParseNoError) {
@@ -2266,7 +2398,11 @@ parse_error::ParseError GLES2DecoderImpl::HandleUseProgram(
parse_error::ParseError GLES2DecoderImpl::HandleValidateProgram(
unsigned int arg_count, const gles2::ValidateProgram& c) {
- GLuint program = static_cast<GLuint>(c.program);
+ GLuint program;
+ if (!id_map_.GetServiceId(c.program, &program)) {
+ SetGLError(GL_INVALID_VALUE);
+ return parse_error::kParseNoError;
+ }
parse_error::ParseError result =
ValidateValidateProgram(this, arg_count, program);
if (result != parse_error::kParseNoError) {
@@ -2461,3 +2597,14 @@ parse_error::ParseError GLES2DecoderImpl::HandleViewport(
return parse_error::kParseNoError;
}
+parse_error::ParseError GLES2DecoderImpl::HandleSwapBuffers(
+ unsigned int arg_count, const gles2::SwapBuffers& c) {
+ parse_error::ParseError result =
+ ValidateSwapBuffers(this, arg_count);
+ if (result != parse_error::kParseNoError) {
+ return result;
+ }
+ DoSwapBuffers();
+ return parse_error::kParseNoError;
+}
+
diff --git a/o3d/gpu/command_buffer/service/gles2_cmd_decoder_validate.h b/o3d/gpu/command_buffer/service/gles2_cmd_decoder_validate.h
index 6d7696b..616d3fc 100644
--- a/o3d/gpu/command_buffer/service/gles2_cmd_decoder_validate.h
+++ b/o3d/gpu/command_buffer/service/gles2_cmd_decoder_validate.h
@@ -1,7 +1,9 @@
+
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+
namespace command_buffer {
namespace gles2 {
@@ -1243,6 +1245,10 @@ parse_error::ParseError ValidateViewport(
GLsizei width, GLsizei height) {
return parse_error::kParseNoError;
}
+parse_error::ParseError ValidateSwapBuffers(
+ GLES2Decoder* decoder, unsigned int arg_count) {
+ return parse_error::kParseNoError;
+}
} // anonymous namespace
} // namespace gles2
} // namespace command_buffer
diff --git a/o3d/gpu/gpu.gyp b/o3d/gpu/gpu.gyp
index a9bc9dfa..9d81e66 100644
--- a/o3d/gpu/gpu.gyp
+++ b/o3d/gpu/gpu.gyp
@@ -87,16 +87,15 @@
'sources': [
'command_buffer/client/gles2_lib.cc',
'command_buffer/client/gles2_lib.h',
- 'command_buffer/client/gles2_lib_autogen.h',
],
},
{
# Stub to expose gles2_implemenation in C instead of C++.
- # so GLES2 programs can work with no changes.
+ # so GLES2 C programs can work with no changes.
'target_name': 'gles2_c_lib',
'type': 'static_library',
'dependencies': [
- 'gles2_implementation',
+ 'gles2_lib',
],
'sources': [
'command_buffer/client/gles2_c_lib.h',
@@ -426,6 +425,25 @@
'np_utils_unittests',
],
},
+ {
+ 'target_name': 'gles2_demo',
+ 'type': 'executable',
+ 'dependencies': [
+ 'command_buffer_client',
+ 'command_buffer_service',
+ 'gles2_lib',
+ 'gles2_c_lib',
+ 'gpu_plugin',
+ 'np_utils',
+ ],
+ 'sources': [
+ 'command_buffer/client/gles2_demo.cc',
+ 'command_buffer/client/gles2_demo_c.h',
+ 'command_buffer/client/gles2_demo_c.c',
+ 'command_buffer/client/gles2_demo_cc.h',
+ 'command_buffer/client/gles2_demo_cc.cc',
+ ],
+ },
]
}