hostsupport/hostopengles20/src/GLES2/hgl.h
branchbug235_bringup_0
changeset 53 c2ef9095503a
parent 20 d2d6724aef32
equal deleted inserted replaced
52:39e5f73667ba 53:c2ef9095503a
       
     1 /* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2  *
       
     3  * Permission is hereby granted, free of charge, to any person obtaining a
       
     4  * copy of this software and associated documentation files (the "Software"),
       
     5  * to deal in the Software without restriction, including without limitation
       
     6  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
       
     7  * and/or sell copies of the Software, and to permit persons to whom the
       
     8  * Software is furnished to do so, subject to the following conditions:
       
     9  *
       
    10  * The above copyright notice and this permission notice shall be included
       
    11  * in all copies or substantial portions of the Software.
       
    12  *
       
    13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
       
    14  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
       
    15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
       
    16  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
       
    17  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
       
    18  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
       
    19  *
       
    20  * Initial Contributors:
       
    21  * Nokia Corporation - initial contribution.
       
    22  *
       
    23  * Contributors:
       
    24  *
       
    25  * Description:
       
    26  *
       
    27  */
       
    28 
       
    29 #ifndef HGL_H_
       
    30 #define HGL_H_
       
    31 
       
    32 #include <GLES2/gl2.h>
       
    33 
       
    34 // Things that desktop GL has, but GL ES doesn't.
       
    35 
       
    36 #define GL_BGR                              0x80E0
       
    37 #define GL_BGRA                             0x80E1
       
    38 #define GL_RGB8                             0x8051
       
    39 #define GL_RGBA8                            0x8058
       
    40 #ifndef DGLES2_NO_SRGB
       
    41 #define GL_SRGB8							0x8C41
       
    42 #define GL_SRGB8_ALPHA8						0x8C43
       
    43 #define GL_SLUMINANCE8						0x8C47
       
    44 #else
       
    45 // No sRGB support in OpenGL 2.0.
       
    46 #define GL_SRGB8							GL_RGB8
       
    47 #define GL_SRGB8_ALPHA8						GL_RGBA8
       
    48 #define GL_SLUMINANCE8						GL_LUMINANCE8
       
    49 #endif
       
    50 #define GL_LUMINANCE8                       0x8040
       
    51 #define GL_ALPHA8                           0x803C
       
    52 #define GL_DEPTH_COMPONENT24				0x81A6
       
    53 #define GL_DEPTH_COMPONENT32				0x81A7
       
    54 #define GL_UNSIGNED_INT_8_8_8_8_REV         0x8367
       
    55 #define GL_UNSIGNED_SHORT_1_5_5_5_REV       0x8366
       
    56 #define GL_UNSIGNED_SHORT_4_4_4_4_REV       0x8365
       
    57 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS	0x8B49
       
    58 #define GL_MAX_VARYING_FLOATS				0x8B4B
       
    59 #define GL_MAX_VERTEX_UNIFORM_COMPONENTS	0x8B4A
       
    60 #define GL_TEXTURE_WIDTH                    0x1000
       
    61 #define GL_TEXTURE_HEIGHT					0x1001
       
    62 #define GL_TEXTURE_RED_SIZE                 0x805C
       
    63 #define GL_TEXTURE_GREEN_SIZE               0x805D
       
    64 #define GL_TEXTURE_BLUE_SIZE                0x805E
       
    65 #define GL_TEXTURE_ALPHA_SIZE               0x805F
       
    66 #define GL_TEXTURE_LUMINANCE_SIZE           0x8060
       
    67 #define GL_TEXTURE_INTERNAL_FORMAT          0x1003
       
    68 typedef char GLchar;		/* native character */
       
    69 typedef double GLclampd;    /* double precision float in [0,1] */
       
    70 
       
    71 #define HGL_FUNCS \
       
    72 	HGL_FUNC(GLenum, GetError, (void)) \
       
    73 	HGL_FUNC(GLuint, CreateShader, (GLenum)) \
       
    74 	HGL_FUNC(void, ShaderSource, (GLuint, GLsizei, const GLchar* *, const GLint *)) \
       
    75 	HGL_FUNC(void, CompileShader, (GLuint)) \
       
    76 	HGL_FUNC(void, GetShaderiv, (GLuint, GLenum, GLint *)) \
       
    77 	HGL_FUNC(void, GetShaderInfoLog, (GLuint, GLsizei, GLsizei *, GLchar *)) \
       
    78 	HGL_FUNC(GLuint, CreateProgram, (void)) \
       
    79 	HGL_FUNC(void, AttachShader, (GLuint, GLuint)) \
       
    80 	HGL_FUNC(void, BindAttribLocation, (GLuint, GLuint, const GLchar *)) \
       
    81 	HGL_FUNC(void, LinkProgram, (GLuint)) \
       
    82 	HGL_FUNC(void, UseProgram, (GLuint)) \
       
    83 	HGL_FUNC(void, GetProgramiv, (GLuint, GLenum, GLint *)) \
       
    84 	HGL_FUNC(void, GetProgramInfoLog, (GLuint, GLsizei, GLsizei *, GLchar *)) \
       
    85 	HGL_FUNC(GLint, GetUniformLocation, (GLuint, const GLchar *)) \
       
    86 	HGL_FUNC(void, Uniform1f, (GLint, GLfloat)) \
       
    87 	HGL_FUNC(void, Uniform2f, (GLint, GLfloat, GLfloat)) \
       
    88 	HGL_FUNC(void, Uniform3f, (GLint, GLfloat, GLfloat, GLfloat)) \
       
    89 	HGL_FUNC(void, Uniform4f, (GLint, GLfloat, GLfloat, GLfloat, GLfloat)) \
       
    90 	HGL_FUNC(void, Uniform1i, (GLint, GLint)) \
       
    91 	HGL_FUNC(void, Uniform2i, (GLint, GLint, GLint)) \
       
    92 	HGL_FUNC(void, Uniform3i, (GLint, GLint, GLint, GLint)) \
       
    93 	HGL_FUNC(void, Uniform4i, (GLint, GLint, GLint, GLint, GLint)) \
       
    94 	HGL_FUNC(void, Uniform1fv, (GLint, GLsizei, const GLfloat *)) \
       
    95 	HGL_FUNC(void, Uniform2fv, (GLint, GLsizei, const GLfloat *)) \
       
    96 	HGL_FUNC(void, Uniform3fv, (GLint, GLsizei, const GLfloat *)) \
       
    97 	HGL_FUNC(void, Uniform4fv, (GLint, GLsizei, const GLfloat *)) \
       
    98 	HGL_FUNC(void, Uniform1iv, (GLint, GLsizei, const GLint *)) \
       
    99 	HGL_FUNC(void, Uniform2iv, (GLint, GLsizei, const GLint *)) \
       
   100 	HGL_FUNC(void, Uniform3iv, (GLint, GLsizei, const GLint *)) \
       
   101 	HGL_FUNC(void, Uniform4iv, (GLint, GLsizei, const GLint *)) \
       
   102 	HGL_FUNC(void, UniformMatrix2fv, (GLint, GLsizei, GLboolean, const GLfloat *)) \
       
   103 	HGL_FUNC(void, UniformMatrix3fv, (GLint, GLsizei, GLboolean, const GLfloat *)) \
       
   104 	HGL_FUNC(void, UniformMatrix4fv, (GLint, GLsizei, GLboolean, const GLfloat *)) \
       
   105 	HGL_FUNC(void, Clear, (GLbitfield mask )) \
       
   106 	HGL_FUNC(void, ClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )) \
       
   107 	HGL_FUNC(void, EnableVertexAttribArray, (GLuint)) \
       
   108 	HGL_FUNC(void, DisableVertexAttribArray, (GLuint)) \
       
   109 	HGL_FUNC(void, VertexAttribPointer, (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *)) \
       
   110 	HGL_FUNC(void, DrawArrays, (GLenum mode, GLint first, GLsizei count )) \
       
   111 	HGL_FUNC(void, GenBuffers, (GLsizei, GLuint *)) \
       
   112 	HGL_FUNC(void, BindBuffer, (GLenum, GLuint)) \
       
   113 	HGL_FUNC(void, BufferData, (GLenum, GLsizeiptr, const GLvoid *, GLenum)) \
       
   114 	HGL_FUNC(void, GenTextures, (GLsizei n, GLuint *textures)) \
       
   115 	HGL_FUNC(void, DeleteTextures, (GLsizei n, const GLuint *textures)) \
       
   116 	HGL_FUNC(void, BindTexture, (GLenum target, GLuint texture)) \
       
   117 	HGL_FUNC(void, TexImage2D, (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)) \
       
   118 	HGL_FUNC(void, TexParameterf, (GLenum target, GLenum pname, GLfloat param)) \
       
   119 	HGL_FUNC(void, TexParameteri, (GLenum target, GLenum pname, GLint param)) \
       
   120 	HGL_FUNC(void, TexParameterfv, (GLenum target, GLenum pname, const GLfloat *params)) \
       
   121 	HGL_FUNC(void, TexParameteriv, (GLenum target, GLenum pname, const GLint *params)) \
       
   122 	HGL_FUNC(const GLubyte*, GetString, (GLenum name)) \
       
   123 	HGL_FUNC(void, GetBooleanv, (GLenum pname, GLboolean *params)) \
       
   124 	HGL_FUNC(void, GetFloatv, (GLenum pname, GLfloat *params)) \
       
   125 	HGL_FUNC(void, GetIntegerv, (GLenum pname, GLint *params)) \
       
   126 	HGL_FUNC(void, BlendFunc, (GLenum sfactor, GLenum dfactor)) \
       
   127 	HGL_FUNC(void, ColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)) \
       
   128 	HGL_FUNC(void, CullFace, (GLenum mode)) \
       
   129 	HGL_FUNC(void, Enable, (GLenum cap)) \
       
   130 	HGL_FUNC(void, Disable, (GLenum cap)) \
       
   131 	HGL_FUNC(void, Viewport, (GLint x, GLint y, GLsizei width, GLsizei height)) \
       
   132 	HGL_FUNC(void, PixelStorei, (GLenum pname, GLint param)) \
       
   133 	HGL_FUNC(void, TexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)) \
       
   134 	HGL_FUNC(void, VertexAttrib1f, (GLuint, GLfloat)) \
       
   135 	HGL_FUNC(void, VertexAttrib1fv, (GLuint, const GLfloat *)) \
       
   136 	HGL_FUNC(void, VertexAttrib2f, (GLuint, GLfloat, GLfloat)) \
       
   137 	HGL_FUNC(void, VertexAttrib2fv, (GLuint, const GLfloat *)) \
       
   138 	HGL_FUNC(void, VertexAttrib3f, (GLuint, GLfloat, GLfloat, GLfloat)) \
       
   139 	HGL_FUNC(void, VertexAttrib3fv, (GLuint, const GLfloat *)) \
       
   140 	HGL_FUNC(void, VertexAttrib4f, (GLuint, GLfloat, GLfloat, GLfloat, GLfloat)) \
       
   141 	HGL_FUNC(void, VertexAttrib4fv, (GLuint, const GLfloat *)) \
       
   142 	HGL_FUNC(void, DeleteProgram, (GLuint)) \
       
   143 	HGL_FUNC(void, DeleteShader, (GLuint)) \
       
   144 	HGL_FUNC(void, DetachShader, (GLuint, GLuint)) \
       
   145 	HGL_FUNC(void, Hint, (GLenum target, GLenum mode)) \
       
   146 	HGL_FUNC(void, Scissor, (GLint x, GLint y, GLsizei width, GLsizei height)) \
       
   147 	HGL_FUNC(void, ReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)) \
       
   148 	HGL_FUNC(void, GenerateMipmapEXT, (GLenum)) \
       
   149 	HGL_FUNC(void, BlendEquation, (GLenum mode)) \
       
   150 	HGL_FUNC(void, BlendColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)) \
       
   151 	HGL_FUNC(void, BlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum)) \
       
   152 	HGL_FUNC(void, BlendEquationSeparate, (GLenum, GLenum)) \
       
   153 	HGL_FUNC(void, BindFramebufferEXT, (GLenum, GLuint)) \
       
   154 	HGL_FUNC(void, DeleteFramebuffersEXT, (GLsizei, const GLuint *)) \
       
   155 	HGL_FUNC(void, GenFramebuffersEXT, (GLsizei, GLuint *)) \
       
   156 	HGL_FUNC(void, BindRenderbufferEXT, (GLenum, GLuint)) \
       
   157 	HGL_FUNC(void, DeleteRenderbuffersEXT, (GLsizei, const GLuint *)) \
       
   158 	HGL_FUNC(void, GenRenderbuffersEXT, (GLsizei, GLuint *)) \
       
   159 	HGL_FUNC(GLboolean, IsEnabled, (GLenum cap)) \
       
   160 	HGL_FUNC(void, ActiveTexture, (GLenum texture)) \
       
   161 	HGL_FUNC(void, GetTexParameterfv, (GLenum target, GLenum pname, const GLfloat *params)) \
       
   162 	HGL_FUNC(void, GetTexParameteriv, (GLenum target, GLenum pname, const GLint *params)) \
       
   163 	HGL_FUNC(GLboolean, IsTexture, (GLuint texture)) \
       
   164 	HGL_FUNC(GLboolean, IsProgram, (GLuint program)) \
       
   165 	HGL_FUNC(GLboolean, IsShader, (GLuint shader)) \
       
   166 	HGL_FUNC(void, BufferSubData, (GLenum, GLintptr, GLsizeiptr, const GLvoid *)) \
       
   167 	HGL_FUNC(void, DeleteBuffers, (GLsizei, const GLuint *)) \
       
   168 	HGL_FUNC(GLboolean, IsBuffer, (GLuint)) \
       
   169 	HGL_FUNC(void, DrawElements, (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)) \
       
   170 	HGL_FUNC(GLint, GetAttribLocation, (GLuint, const GLchar *)) \
       
   171 	HGL_FUNC(void, StencilFunc, (GLenum func, GLint ref, GLuint mask)) \
       
   172 	HGL_FUNC(void, StencilMask, (GLuint mask)) \
       
   173 	HGL_FUNC(void, StencilOp, (GLenum fail, GLenum zfail, GLenum zpass)) \
       
   174 	HGL_FUNC(void, ClearStencil, (GLint s)) \
       
   175 	HGL_FUNC(void, FramebufferTexture2DEXT, (GLenum, GLenum, GLenum, GLuint, GLint)) \
       
   176 	HGL_FUNC(void, RenderbufferStorageEXT, (GLenum, GLenum, GLsizei, GLsizei)) \
       
   177 	HGL_FUNC(void, FramebufferRenderbufferEXT, (GLenum, GLenum, GLenum, GLuint)) \
       
   178 	HGL_FUNC(GLenum, CheckFramebufferStatusEXT, (GLenum)) \
       
   179 	HGL_FUNC(void, Finish, (void)) \
       
   180 	HGL_FUNC(void, Flush, (void)) \
       
   181 	HGL_FUNC(void, DepthFunc, (GLenum func)) \
       
   182 	HGL_FUNC(void, DepthMask, (GLboolean flag)) \
       
   183 	HGL_FUNC(void, DepthRange, (GLclampd zNear, GLclampd zFar)) \
       
   184 	HGL_FUNC(void, ClearDepth, (GLclampd depth)) \
       
   185 	HGL_FUNC(void, GetBufferParameteriv, (GLenum target, GLenum pname, GLint* params)) \
       
   186 	HGL_FUNC(void, GetActiveAttrib, (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)) \
       
   187 	HGL_FUNC(void, GetActiveUniform, (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)) \
       
   188 	HGL_FUNC(void, GetAttachedShaders, (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj)) \
       
   189 	HGL_FUNC(void, GetUniformfv, (GLuint program, GLint location, GLfloat *params)) \
       
   190 	HGL_FUNC(void, GetUniformiv, (GLuint program, GLint location, GLint *params)) \
       
   191 	HGL_FUNC(void, ValidateProgram, (GLuint program)) \
       
   192 	HGL_FUNC(void, GetShaderSource, (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source)) \
       
   193 	HGL_FUNC(void, LineWidth, (GLfloat width)) \
       
   194 	HGL_FUNC(void, FrontFace, (GLenum mode)) \
       
   195 	HGL_FUNC(void, PolygonOffset, (GLfloat factor, GLfloat units)) \
       
   196 	HGL_FUNC(void, SampleCoverage, (GLclampf value, GLboolean invert)) \
       
   197 	HGL_FUNC(void, StencilMaskSeparate, (GLenum face, GLuint mask)) \
       
   198 	HGL_FUNC(void, StencilFuncSeparate, (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask)) \
       
   199 	HGL_FUNC(void, StencilOpSeparate, (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)) \
       
   200 	HGL_FUNC(void, CopyTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)) \
       
   201 	HGL_FUNC(void, GetFramebufferAttachmentParameterivEXT, (GLenum target, GLenum attachment, GLenum pname, GLint *params)) \
       
   202 	HGL_FUNC(void, GetRenderbufferParameterivEXT, (GLenum target, GLenum pname, GLint *params)) \
       
   203 	HGL_FUNC(void, CopyTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)) \
       
   204 	HGL_FUNC(void, IsRenderbufferEXT, (GLuint renderbuffer)) \
       
   205 	HGL_FUNC(void, IsFramebufferEXT, (GLuint framebuffer)) \
       
   206 	HGL_FUNC(void, GetVertexAttribiv, (GLuint index, GLenum pname, GLint *params)) \
       
   207 	HGL_FUNC(void, GetVertexAttribfv, (GLuint index, GLenum pname, GLfloat *params)) \
       
   208 	HGL_FUNC(void, GetTexLevelParameteriv, (GLenum target, GLint level, GLenum pname, GLint *params)) \
       
   209 	HGL_FUNC(void, GetTexImage, (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels)) \
       
   210 	HGL_FUNC(void, DrawPixels, (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels))
       
   211 
       
   212 typedef struct HGL
       
   213 {
       
   214 #define HGL_FUNC(ret, name, attr) ret (GL_APIENTRY *name)attr;
       
   215 	HGL_FUNCS
       
   216 #undef HGL_FUNC
       
   217 } HGL;
       
   218 
       
   219 #ifndef HGL_NO_VARIABLES
       
   220 extern HGL hgl;
       
   221 
       
   222 extern int hglLoad();
       
   223 #endif // HGL_NO_VARIABLES
       
   224 
       
   225 #endif // HGL_H_