{目录 ... 宏函数 绘制 //绘制数组 glDrawArrays (GLenum mode, GLint first, GLsizei count); //绘制元素 glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); 指定Shader内容 //创建/删除Shader程序 glCreateShader (GLenum type); glDeleteShader (GLuint shader); //参数是Shader的id //指定shader的源代码 glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length); //获取Shader源代码 glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); //检查Shader状态 glGetShaderiv (GLuint shader, GLenum pname, GLint* params); //编译Shader glCompileShader (GLuint shader); //获取Shader日志 glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); //指定二进制 shader(有的显卡支持在线编译,有的支持二进制shader文件) glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); //释放shader编译器占的资源 glReleaseShaderCompiler (void); 引用Shader中的属性(自己在Shader中写的一些需要传值的类型) //获取Shader程序中的属性(attribute 定义的变量) glGetAttribLocation (GLuint program, const GLchar* name); //获取Shader程序局部变量对象(uniform 定义的变量) glGetUniformLocation (GLuint program, const GLchar* name); //获取Shader精度值 glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); 设置Shader数据(Shader什么类型就用什么类型设置内容) glU/V... //设置Shader内Uniform变量的值 glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); //设置Shader内Uniform变量的值(值float) glUniform1f (GLint location, GLfloat x); glUniform1fv (GLint location, GLsizei count, const GLfloat* v); //设置Shader内Uniform变量的值(值int) glUniform1i (GLint location, GLint x); glUniform1iv (GLint location, GLsizei count, const GLint* v); glUniform2f (GLint location, GLfloat x, GLfloat y); glUniform2fv (GLint location, GLsizei count, const GLfloat* v); glUniform2i (GLint location, GLint x, GLint y); glUniform2iv (GLint location, GLsizei count, const GLint* v); glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); glUniform3fv (GLint location, GLsizei count, const GLfloat* v); glUniform3i (GLint location, GLint x, GLint y, GLint z); glUniform3iv (GLint location, GLsizei count, const GLint* v); glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); glUniform4fv (GLint location, GLsizei count, const GLfloat* v); glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); glUniform4iv (GLint location, GLsizei count, const GLint* v); glVertexAttrib1f (GLuint indx, GLfloat x); glVertexAttrib1fv (GLuint indx, const GLfloat* values); glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); glVertexAttrib2fv (GLuint indx, const GLfloat* values); glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); glVertexAttrib3fv (GLuint indx, const GLfloat* values); glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); glVertexAttrib4fv (GLuint indx, const GLfloat* values); //设置Shader数据 顶点数据源 glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); 创建程序(加载Shader) //创建程序 glCreateProgram (void); //删除程序 glDeleteProgram (GLuint program); //获取程序信息 glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); //验证程序 glValidateProgram (GLuint program); //加载Shader glAttachShader (GLuint program, GLuint shader); //链接程序 glLinkProgram (GLuint program); //使用程序 glUseProgram (GLuint program); //获取程序中的属性 glGetProgramiv (GLuint program, GLenum pname, GLint* params); glGetUniformfv (GLuint program, GLint location, GLfloat* params); glGetUniformiv (GLuint program, GLint location, GLint* params); //获取Shader程序中attribute变量 glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); //获取Shader程序中uniform变量 glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); 缓冲区 //生成/删除缓冲区的索引 glGenBuffers (GLsizei n, GLuint* buffers); glDeleteBuffers (GLsizei n, const GLuint* buffers); //生成/删除帧缓冲区的索引 glGenFramebuffers (GLsizei n, GLuint* framebuffers); glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); //创建/删除渲染缓冲区 glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); //绑定/取消缓冲区 glBindBuffer (GLenum target, GLuint buffer); //绑定/取消渲染缓冲区 glBindRenderbuffer (GLenum target, GLuint renderbuffer); //绑定/取消框架(Frame)缓冲区 glBindFramebuffer (GLenum target, GLuint framebuffer); //设置缓冲区数据 glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); //修改部分缓冲区数据 glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); //绘制渲染缓冲区的存储大小 glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); //帧缓冲区数据渲染到纹理上 glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); //帧缓冲区与渲染缓冲区绑定 glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); //帧缓冲区参数 glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); //渲染缓冲区参数 glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); //获取帧缓冲状态 glCheckFramebufferStatus (GLenum target); //获取缓冲区参数内容 glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); 纹理 //关联纹理层(GL_TEXTURE0 ~ GL_TEXTURE31) glActiveTexture (GLenum texture); //生成纹理 glGenTextures (GLsizei n, GLuint* textures); //删除纹理 glDeleteTextures (GLsizei n, const GLuint* textures); //绑定纹理 glBindTexture (GLenum target, GLuint texture); //将图片数据传给opengl glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); //将图片局部数据传给opengl glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); //压缩纹理 glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); //将图片局部数据传给opengl glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); //拷贝纹理 glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); //拷贝局部纹理 glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); //设置纹理参数(i/f) glTexParameterf (GLenum target, GLenum pname, GLfloat param); glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); glTexParameteri (GLenum target, GLenum pname, GLint param); glTexParameteriv (GLenum target, GLenum pname, const GLint* params); //获取纹理参数(i/f) glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); 获取数据类型 glGetBooleanv (GLenum pname, GLboolean* params); glGetFloatv (GLenum pname, GLfloat* params); glGetIntegerv (GLenum pname, GLint* params); //获取标签名字内容 glGetString (GLenum name); 混合 glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); glBlendEquation ( GLenum mode ); glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); //指定像素混合算法 glBlendFunc (GLenum sfactor, GLenum dfactor); glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); ---- //视口大小 glViewport (GLint x, GLint y, GLsizei width, GLsizei height); glClear (GLbitfield mask); //清楚颜色(rgba) glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); glClearDepthf (GLclampf depth); glClearStencil (GLint s); glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); //启用/禁用顶点数组 glEnableVertexAttribArray (GLuint index); glDisableVertexAttribArray (GLuint index); glDepthFunc (GLenum func); glDepthMask (GLboolean flag); glDepthRangef (GLclampf zNear, GLclampf zFar); glDetachShader (GLuint program, GLuint shader); //启动/废弃状态 glEnable (GLenum cap); glDisable (GLenum cap); glFinish (void); glFlush (void); //剔除方向(顺/逆时针) glFrontFace (GLenum mode); //剔除那个面(背/正/全部面) glCullFace (GLenum mode); glGenerateMipmap (GLenum target); glGetError (void); glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); glHint (GLenum target, GLenum mode); //抗锯齿 glIsBuffer (GLuint buffer); glIsEnabled (GLenum cap); glIsFramebuffer (GLuint framebuffer); glIsProgram (GLuint program); glIsRenderbuffer (GLuint renderbuffer); glIsShader (GLuint shader); glIsTexture (GLuint texture); glLineWidth (GLfloat width); //设置像素存储模式 glPixelStorei (GLenum pname, GLint param); //从帧缓冲区读取一组数据 glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); //设定opengl用于计算深度值的比例和单元 glPolygonOffset (GLfloat factor, GLfloat units); glSampleCoverage (GLclampf value, GLboolean invert); //裁剪的位置 glScissor (GLint x, GLint y, GLsizei width, GLsizei height); glStencilFunc (GLenum func, GLint ref, GLuint mask); glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); glStencilMask (GLuint mask); glStencilMaskSeparate (GLenum face, GLuint mask); glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); }
#ifndef __gl2_h_ #define __gl2_h_ /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ #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 char GLchar; 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 //false(布尔类型) #define GL_TRUE 1 //true(布尔类型) /* 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 // RGB混合因子(0,0,0) #define GL_ONE 1 // (1,1,1) #define GL_SRC_COLOR 0x0300 // 源颜色 #define GL_ONE_MINUS_SRC_COLOR 0x0301 // 1减去源颜色 (1,1,1)-(Rs1,Gs1,Bs) #define GL_SRC_ALPHA 0x0302 // 源颜色alpha值(As1,As1,As) #define GL_ONE_MINUS_SRC_ALPHA 0x0303 // 1减去源颜色alpha值 (1,1,1)-(As1,As1,As) #define GL_DST_ALPHA 0x0304 // 目标颜色alpha值 #define GL_ONE_MINUS_DST_ALPHA 0x0305 // 1减去目标颜色alpha值(1,1,1)-(Ad,Ad1,Ad) /* 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 // 2维纹理 #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 // 片段Shader #define GL_VERTEX_SHADER 0x8B31 // 顶点Shader #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 //niform属性变量个数 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 //niform属性变量的最大值 #define GL_ACTIVE_ATTRIBUTES 0x8B89 //attribure属性变量个数 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A //attribute属性变量的最大值 #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 // OpenGL的提供厂商 #define GL_RENDERER 0x1F01 // OpenGL渲染的设备,通常就是显卡的名字 #define GL_VERSION 0x1F02 // OpenGL 版本号 #define GL_EXTENSIONS 0x1F03 // 所支持的所有扩展,用空格隔开。详细情况参见下面的关于“OpenGL扩展”的叙述 /* 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 // /* 纹理层级别(GL_TEXTURE0 ~ GL_TEXTURE31) */ #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 //纹理超过1的话用边缘的像素填充 #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 // 初始化log长度 #define GL_SHADER_SOURCE_LENGTH 0x8B88 // 源代码长度 #define GL_SHADER_COMPILER 0x8DFA // Shader编译器 /* 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 // /*------------------------------------------------------------------------- * GL core functions. *-----------------------------------------------------------------------*/ /** 绘制数组 * @param mode 绘制模式 * @param first 第几个开始(顶点数组) * @param count 绘制数据大小(绘制多少个点) * @return */ GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); /**绘制元素 * @param mode 绘制模式(GL_TRIANGLES三角形...) * @param count 绘制数据大小(绘制多少个点) * @param type 数据类型(GL_UNSIGNED_BYTE ...) * @param indices * 0:顶点缓冲和索引缓冲数据都用 * indexBuf:用顶点缓冲区数据不要索引缓冲区数据,就把索引数据传入 * @return */ GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); /** 创建Shader程序 * @param type * GL_VERTEX_SHADER 顶点Shader * GL_FRAGMENT_SHADER 像素Shader * @return */ GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); /**删除Shader程序 * @param shader Shader的ID * @return */ GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); /** 指定shader的源代码 * @param shader ShaderID * @param count 源代码个数 * @param string 源代码字符串 * @param length 源代码字符串长度(给0就可以,它自己会算) * @return */ GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length); /** 获取Shader源代码 * @param shader ShaderID * @param bufsize 用来保存源代码的大小 * @param length 用来保存源代码的长度(给0就可以,它自己会算) * @param source 保存源代码变量 * @return */ GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); /** 检查Shader状态 * @param shader ShaderID * @param pname * GL_COMPILE_STATUS 编译状态 * GL_INFO_LOG_LENGTH 初始化log长度 * GL_SHADER_SOURCE_LENGTH 源代码长度 * GL_SHADER_COMPILER Shader编译器 * @param params * @return */ GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); /** 编译Shader * @param shader ShaderID * @return */ GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); /** 获取Shader日志 * @param shader ShaderID * @param bufsize 要保存日志的大小 * @param length 日志长度 * @param infolog 日志 * @return */ GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); /** 指定二进制 shader * @param n * @param shaders * @param binaryformat * @param binary * @param length */ GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); /** 释放shader编译器占的资源 */ GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); /** 获取Shader程序中的属性 * @param program 程序ID * @param name 属性名字 * @return */ GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); /** 获取局部变量中的指定对象 * @param program * @param name 获取 * @return */ GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); /** 获取Shader精度类型 * @param shadertype Shader类型 * GL_VERTEX_SHADER 顶点Shader * GL_FRAGMENT_SHADER 像素Shader * @param precisiontype 精度类型 * GL_LOW_FLOAT 低精度 浮点 * GL_MEDIUM_FLOAT 中精度 浮点 * GL_HIGH_FLOAT 高精度 浮点 * GL_LOW_INT 低精度 整形 * GL_MEDIUM_INT 中精度 整形 * GL_HIGH_INT 高精度 整形 * @param range 范围(GL_HIGH_FLOAT {127,127}) * @param precision 精度值 * * 范例: * int rangehigh[2], precisionhigh; * glGetShaderPrecisionFormat(GL_VERTEX_SHADER, GL_HIGH_FLOAT, rangehigh, &precisionhigh); */ GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); /** * @param program 程序ID * @param index * @param name Shader中的变量_position(attribute vec3 _position) * 范例: * https://www.opengl.org/wiki/Generic_Vertex_Attribute_-_examples */ GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); /** 设置Shader内Uniform变量的值 * @param location Shader中的属性 * @param count 数据类型个数 * @param transpose 是否需要转置 * @param value 要传入的数据 * @return */ GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); /** 设置Shader内Uniform变量的值 * @param location Shader中的属性 * @param count 数据类型个数 * @param transpose 是否需要转置 * @param value 要传入的数据 * @return */ GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); /** 设置Shader内Uniform变量的值 * @param location Shader中的属性 * @param count 数据类型个数 * @param transpose 是否需要转置 * @param value 要传入的数据 */ GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); /** 设置Shader内Uniform变量的值(值float) * @param location Shader中定义的 Uniform location * @param x 值(值float) */ GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); // /** 设置Shader内Uniform变量的值(值int) * @param location Shader中定义的 Uniform location * @param x 值(值int) */ GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); /** * @param location * @param x * @param y */ GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); /** * @param location Shader中定义的 Uniform location * @param count 数量(类似for循环的的判断) * @param v 索引开始指针 * 实例:1 * float pos[3]={1.0f,2.0f,3.0f}; * glUniform3fv ( shader._pos, 1, &pos[0] ); * 实例:2 * struct Vpos {float x;float y;float z;}; * Vpos pos; * pos.x=1.0f; * pos.y=2.0f; * pos.z=3.0f; * glUniform3fv ( shader._pos, 1, &pos.x); */ 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); /** * @param location * @param x * @param y * @param z * @return */ 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); /** * @param location * @param x * @param y * @param z * @param w * @return */ 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); /** * [glVertexAttrib1f description] * @param indx [description] * @param x [description] * @return [description] */ GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); /** * [glVertexAttrib1fv description] * @param indx [description] * @param values [description] * @return [description] */ GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); /** * @param indx * @param x * @param y * @return */ GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); /** * @param indx * @param x * @param y * @param z * @return */ 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); /** * @param indx * @param x * @param y * @param z * @param w * @return */ 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); /** 设置Shader数据 顶点数据源 * 指定顶点数据源(位置,颜色,法线,uv坐标,副法线,切线...需要绘制的顶点数据都叫属性) * @param indx Shader中的属性 * @param size 数量(位置(x,y,z)数量3,颜色(r,g,b,a)数量4) * @param type 数据类型(GL_FLOAT,GL_BYTE, GL_UNSIGNED_BYTE ...) * @param normalized 是否规格化 指定当被访问时,固定点数据值是否应该被归一化(GL_TRUE)或者直接转换为固定点值(GL_FALSE) * @param stride 偏移量,初始值为0。 * @param ptr 要传入的数据。初始值为0; * @return */ GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); /** 创建程序 * @return 程序ID */ GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); /**删除程序 * @param program 程序ID * @return */ GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); /** 获取程序信息 * @param program 程序ID * @param bufsize 要保存日志的大小 * @param length 日志长度 * @param infolog 日志内容 * @return */ GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); /** 验证程序 * @param program 程序ID */ GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); /** 加载Shader * @param program 程序 ID * @param shader Shader ID * @return */ GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); /** 连接程序 * @param program 程序ID * @return */ GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); /** 使用程序 * @param program 程序ID (输入0,就是弃用上一条程序) * @return */ GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); /** 获取程序中的属性 * @param program 程序id * @param pname * GL_ACTIVE_UNIFORMS niform属性变量个数 * GL_ACTIVE_UNIFORM_MAX_LENGTH niform属性变量的最大值 * GL_ACTIVE_ATTRIBUTES attribure属性变量个数 * GL_ACTIVE_ATTRIBUTE_MAX_LENGTH attribute属性变量的最大值 * ... * @param params 保存属性的值 */ GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); /** * @param program * @param location * @param params * @return */ GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); /** * @param program * @param location * @param params * @return */ GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); /** 获取Shader程序中attribute变量 * @param program 程序id * @param index 第几个attribute变量的id(顶点Shader中总共有几个,这是第几个) * @param bufsize 缓冲区大小(attribute变量缓冲大小) * @param length 获取attribute变量的长度 * @param size 获取attribute变量的大小 * @param type 获取attribute变量的类型 * @param name 获取attribute变量名字 * 范例: * const char *vs = { * ... * "attribute vec3 _position;" * "attribute vec4 _color;" //外边出入的颜色 * "attribute vec2 _tpos;" //纹理坐标 * ... * }; * * GLint maxLength, nAttribs; * GLchar * name; * glGetProgramiv(shaderValue.pID, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxLength); * glGetProgramiv(shaderValue.pID, GL_ACTIVE_ATTRIBUTES, &nAttribs); * name = (GLchar *)malloc(maxLength); * for (int i = 0; i < nAttribs; i++){ * GLint written, size, location; * GLenum type; * glGetActiveAttrib(shaderValue.pID, i, maxLength, &written, &size, &type, name); * location = glGetAttribLocation(shaderValue.pID, name); * printf(" %-5d | %s\n", location, name); * } * nAttribs 输出 3 * name 输出 "_position","_color","_tpos" * */ GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); /** 获取Shader程序中uniform变量 * @param program 程序id * @param index 第几个uniform变量的id(Shader中总共有几个,这是第几个) * @param bufsize 缓冲区大小(uniform变量缓冲大小) * @param length 获取uniform变量的长度 * @param size 获取uniform变量的大小 * @param type attribute变量的类型 * @param name attribute变量名字 * 范例: * const char *vs = { * ... * "uniform mat4 _MVP;" * ... * }; * const char *fs = { * ... * "uniform sampler2D _tId;" //纹理id * ... * }; * * GLint maxLength, nAttribs; * GLchar * name; * glGetProgramiv(shaderValue.pID, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength); * glGetProgramiv(shaderValue.pID, GL_ACTIVE_UNIFORMS, &nAttribs); * * name = (GLchar *)malloc(maxLength); * * for (int i = 0; i < nAttribs; i++){ * GLint written, size, location; * GLenum type; * glGetActiveUniform(shaderValue.pID, i, maxLength, &written, &size, &type, name); * location = glGetUniformLocation(shaderValue.pID, name); * printf(" %-5d | %s\n", location, name); * } * nAttribs 输出 2 * name 输出 "_tId","_MVP" */ GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); /** * @param program * @param maxcount * @param count * @param shaders */ GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); /** 生成/删除缓冲区的索引 * @param n 用来生成缓冲区的数量 * @param buffers 绑定缓存区id */ GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); /** 生成/删除帧缓冲区的索引 * @param n * @param framebuffers * @return */ GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); /** 创建/删除渲染缓存区 * @param n 创建的个数 * @param renderbuffers 缓存值 * @return */ GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); /** 绑定缓冲区 * @param target 缓冲类型 * @param buffer 绑定的id * @return */ GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); /**绑定/取消渲染缓存区 * @param target 缓存区类型 * @param renderbuffer * 0 取消 * @return */ GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); /** 绑定/取消框架(Frame)缓存区 * @param target * @param framebuffer * framebuffer 绑定缓存值 * 0 取消绑定的缓存值 * * @return */ GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); /** 设置缓冲区数据 * @param target 缓冲类型 * @param size 数据大小 * @param data 数据 * @param usage 数据改动类型 * GL_STREAM_DRAW 偶尔需要改动数据 * GL_STATIC_DRAW 不改动数据 * GL_DYNAMIC_DRAW 经常改动数据 * @return */ GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); /** 修改部分缓冲区数据 * @param target 缓冲类型 * @param offset 偏移量 * @param size 数据大小 * @param data 数据 * @return */ GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); /** 绘制渲染缓冲区的存储大小 * @param target 帧缓冲类型(GL_RENDERBUFFER ...) * @param internalformat 存储数据格式(GL_DEPTH_COMPONENT16 深度信息) * @param width 存储的宽 * @param height 存储的高 */ GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); /** 帧缓冲区数据渲染到纹理上 * @param target 帧缓冲类型(GL_RENDERBUFFER ...) * @param attachment 缓存区类型 (GL_COLOR_ATTACHMENT0 颜色缓存区) * @param textarget 纹理类型 (GL_TEXTURE_2D ...) * @param texture 纹理id * @param level 层级别(数据渲染到纹理的什么层级别上) */ GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); /** 帧缓冲区与渲染缓冲区绑定 * @param target 帧缓冲区类型(GL_FRAMEBUFFER 帧缓冲区) * @param attachment 关联的类型(GL_DEPTH_ATTACHMENT 深度) * @param renderbuffertarget 渲染缓冲区类型(GL_RENDERBUFFER 渲染缓冲区) * @param renderbuffer 渲染缓冲区id */ GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); /** 帧缓冲区参数 * @param target * @param attachment * @param pname * @param params * @return */ GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); /** 渲染缓冲区参数 * @param target * @param pname * @param params * @return */ GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); /** 获取帧缓冲状态 * @param target * GL_FRAMEBUFFER 帧缓冲区 * @return * GL_FRAMEBUFFER_COMPLETE 完整的帧缓冲 * 实例 * GLint state=glCheckFramebufferStatus(GL_FRAMEBUFFER); * if (state != GL_FRAMEBUFFER_COMPLETE){ * 这个缓冲区有问题 * } */ GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); /** 获取缓冲区参数内容 * @param target 指定缓冲区对象 * GL_ARRAY_BUFFER 顶点缓冲区 * GL_ELEMENT_ARRAY_BUFFER 索引缓冲区 * @param pname 缓冲区对象参数 * GL_BUFFER_SIZE * GL_BUFFER_USAGE * @param params 获取的指 */ GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); /** 关联纹理层(GL_TEXTURE0 ~ GL_TEXTURE31) * @param texture 纹理层一共能关联32个 GL_TEXTURE0 ~ GL_TEXTURE31 * @return */ GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); /** 生成纹理的索引 * 功能:函数根据纹理参数返回n个纹理索引。纹理名称集合不必是一个连续的整数集合。 * @param n 用来生成纹理的数量 * @param textures 存储纹理索引的第一个元素指针 * 删除 * unsigned tId=0; * glGenTextures(1,&tId);//生成纹理的索引 * ... * glDeleteTextures(1,&tId); */ GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); /** 删除纹理 * @param n 产生纹理的数量 * @param textures 存储纹理索引的第一个元素指针 * 删除 * unsigned tId=0; * glGenTextures(1,&tId); * ... * glDeleteTextures(1,&tId); */ GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); /** 绑定纹理 * @param target 纹理是几维的 * @param texture 纹理id * @return */ GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); /** 将图片数据传给opengl * @param target 纹理是几维的 GL_TEXTURE_2D ... * @param level 纹理层级别[0,10] 0最大,10最小 * @param internalformat 纹理存储格式(显冲用的纹理格式) * @param width 纹理宽度,老一点的显卡,不支持不规则的纹理,即宽度和高度不是2^n。 * @param height 纹理高度,老一点的显卡,不支持不规则的纹理,即宽度和高度不是2^n。 * @param border 是否有边框 * @param format 数据的格式(传入图片数据的格式)RGB,GRBA ... * @param type 纹理数据类型 unsigned byte ... * @param pixels 纹理数据 */ GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); /** 将图片局部数据传给opengl * @param target 纹理是几维的 GL_TEXTURE_2D ... * @param level 纹理层级别[0,10] 0最大,10最小 * @param xoffset 偏移量x(相对整张图片(0,0)点偏移多少) * @param yoffset 偏移量y * @param width 纹理宽度,老一点的显卡,不支持不规则的纹理,即宽度和高度不是2^n。 * @param height 纹理高度,老一点的显卡,不支持不规则的纹理,即宽度和高度不是2^n。 * @param format 数据的格式(传入图片数据的格式)RGB,GRBA ... * @param type 纹理数据类型 unsigned byte ... * @param pixels 纹理数据 */ GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); /** 压缩纹理 * @param target 纹理是几维的 GL_TEXTURE_2D ... * @param level 纹理层级别[0,10] 0最大,10最小 * @param internalformat 压缩格式 * @param width 纹理宽度 * @param height 纹理高度 * @param border 是否有边框 * @param imageSize 图片大小(宽x高) * @param data 纹理数据 * @return */ GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); /** 将图片局部数据传给opengl * @param target 纹理是几维的 GL_TEXTURE_2D ... * @param level 纹理层级别[0,10] 0最大,10最小 * @param xoffset 偏移量x(相对整张图片(0,0)点偏移多少) * @param yoffset 偏移量y * @param width 纹理宽度 * @param height 纹理高度 * @param format 数据的格式(传入图片数据的格式)RGB,GRBA ... * @param imageSize 图片大小(宽x高) * @param data 纹理数据 * @return */ GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); /** 拷贝纹理 * @param target 纹理是几维的 GL_TEXTURE_2D ... * @param level 纹理层级别[0,10] 0最大,10最小 * @param internalformat * @param x 起始位x(相对屏幕(0,0)点偏移多少) * @param y 起始位x * @param width 纹理宽度 * @param height 纹理高度 * @param border 是否有边框 */ GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); /** 拷贝局部纹理 * @param target 纹理是几维的 GL_TEXTURE_2D ... * @param level 纹理层级别[0,10] 0最大,10最小 * @param xoffset 偏移量x(相对屏幕(0,0)点偏移多少) * @param yoffset 偏移量y * @param x * @param y * @param width 纹理宽度 * @param height 纹理高度 */ GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); /** 设置纹理参数(float) * @param target * @param pname * @param param * @return */ 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); /** 设置纹理参数(int) * @param target 纹理是几维的 GL_TEXTURE_2D ... * @param pname * GL_TEXTURE_MAG_FILTER 放大滤波(参数) * GL_NEAREST 最近的(用第0级) * GL_LINEAR 线性的(用第0级) * GL_TEXTURE_MIN_FILTER 缩小滤波(参数) * GL_NEAREST 最近的(用第0级) * GL_LINEAR 线性的(用第0级) * GL_NEAREST_MIPMAP_NEAREST(用mipmap) (NEAREST:本级之间的算法,GL_LINEAR:级与级之间是否做了差值过滤) * GL_LINEAR_MIPMAP_NEAREST (用mipmap) * GL_NEAREST_MIPMAP_LINEAR (用mipmap) * GL_LINEAR_MIPMAP_LINEAR (用mipmap) 最好级别 * GL_TEXTURE_WRAP_S s方向(水平方向,uv坐标xy轴,这st是一个意思) * GL_TEXTURE_WRAP_T t方向(垂直方向) * GL_REPEAT 重复(默认) * GL_CLAMP_TO_EDGE 用边缘的像素填充(纹理超过1的话) * GL_MIRRORED_REPEAT 纹理镜像重复(纹理超过1的话) * @param param */ 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); /** 获取纹理参数 * @param target 纹理是几维的 GL_TEXTURE_2D ... * @param pname 参数 * @param params 内容 * @return */ GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); /** * @param pname * @param params */ GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); /** * @param pname * @param params */ GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); /** * @param pname * @param params */ GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); /** 获取标签名字内容 * @param name 标签名字 * GL_VENDOR OpenGL的提供厂商 * GL_RENDERER OpenGL渲染的设备,通常就是显卡的名字 * GL_VERSION OpenGL 版本号 * GL_EXTENSIONS 所支持的所有扩展,用空格隔开。详细情况参见下面的关于“OpenGL扩展”的叙述 * @return 返回内容 * 实例 * std::string str4 =(const char *)glGetString(GL_VERSION); 输出 "OpenGL ES 2.0 (ANGLE 1.0.0.2249)" */ GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); /** * @param red * @param green * @param blue * @param alpha * @return */ GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); /** * @param mode * @return */ GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ); /** * @param modeRGB * @param modeAlpha * @return */ GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); /** 指定像素混合算法 * @param sfactor 源因子 * @param dfactor 目标因子 * 两个因子在代入这个公式 * (Rs*Sr+Rd*Dr , Gs*Sg+Gd*Dg , Bs*Sb+Bd*Db , As*Sa+Ad*Da) */ GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); /** * @param srcRGB * @param dstRGB * @param srcAlpha * @param dstAlpha * @return */ GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); /** 视口大小 * @param x * @param y * @param width * @param height * @return */ GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); /** * @param mask * @return */ GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); /** 清楚颜色(rgba) * @param red 红 * @param green 绿 * @param blue 蓝 * @param alpha * @return */ GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); /** * @param depth * @return */ GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); /** * @param s * @return */ GL_APICALL void GL_APIENTRY glClearStencil (GLint s); /** * @param red * @param green * @param blue * @param alpha * @return */ GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); /** 启用/禁用顶点数组 * @param index 顶点数组ID * @return */ GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); /** * @param func * @return */ GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); /** * @param flag * @return */ GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); /** * @param zNear * @param zFar * @return */ GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); /** * @param program * @param shader * @return */ GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); /** 启动/废弃状态 * @param cap * @return */ GL_APICALL void GL_APIENTRY glEnable (GLenum cap); GL_APICALL void GL_APIENTRY glDisable (GLenum cap); /** * *return */ GL_APICALL void GL_APIENTRY glFinish (void); /** * *return */ GL_APICALL void GL_APIENTRY glFlush (void); /** 剔除方向(顺/逆时针) * @param mode * GL_CW 顺时针 * GL_CCW 逆时针 (默认值) * @return */ GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); /** 剔除那个面 * @param mode * GL_BACK 剔除反面 * GL_FRONT 剔除正面 * GL_FRONT_AND_BACK 剔除正反面 * @return */ GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); /** * @param target * @return */ GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); /** * *return */ GL_APICALL GLenum GL_APIENTRY glGetError (void); /** * @param index * @param pname * @param params */ GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); /** * @param index * @param pname * @param pointer * @return */ GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); /** 抗锯齿 * @param target * @param mode * GL_FASTEST 速度优先 * GL_NICEST 质量优先 * @return */ GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); /** * @param buffer * @return */ GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); /** * @param cap * @return */ GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); /** * @param framebuffer * @return */ GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); /** * @param program * @return */ GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); /** * @param renderbuffer * @return */ GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); /** * @param shader * @return */ GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); /** * @param texture * @return */ GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); /** * @param width * @return */ GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); /** 设置像素存储模式 * @param pname 模式 * GL_PACK_ALIGNMENT 它影响将像素数据写回到主存的打包形式 对glReadPixels的调用产生影响 * GL_UNPACK_ALIGNMENT 它影响从主存读到的像素数据的解包形式 对glTexImage2D以及glTexSubImage2D产生影响。 * @param param 相应的 pname 设置为什么值。 * 这个数值一般是1,2,4(默认)或8,用于指定存储器中每个像素行有多少个字节对齐。对齐的字节数越高,系统就越能优化。 * @return */ GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); /** 从帧缓冲区读取一组数据 * @param x * @param y * @param width * @param height * @param format * @param type * @param pixels * @return */ GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); /** 设定opengl用于计算深度值的比例和单元 * @param factor * @param units */ GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); /** * @param value * @param invert * @return */ GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); /** 裁剪的位置 * @param x * @param y * @param width * @param height * @return */ GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); /** * @param func * @param ref * @param mask * @return */ GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); /** * @param face * @param func * @param ref * @param mask * @return */ GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); /** * @param mask * @return */ GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); /** * @param face * @param mask * @return */ GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); /** * @param fail * @param zfail * @param zpass * @return */ GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); /** * @param face * @param fail * @param zfail * @param zpass * @return */ GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); #ifdef __cplusplus } #endif #endif /* __gl2_h_ */