首页 > 代码库 > 获取 OpenGL 常用信息

获取 OpenGL 常用信息

 void Context::getGLExtension()
   {
           const char* sVersion = (const char*)glGetString(GL_VERSION);
           this->_version = std::string(sVersion);

           const char* sShadingLanguageVersion =  (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
           this->_shadingLanguageVersion = std::string(sShadingLanguageVersion);

           const char* sVendor =  (const char*)glGetString(GL_VENDOR);
           this->_vendor = std::string(sVendor);

           const char* sRenderer =  (const char*)glGetString(GL_RENDERER);
           this->_renderer = std::string(sRenderer);

           glGetIntegerv(GL_RED_BITS, &this->_redBits);
           glGetIntegerv(GL_GREEN_BITS, &this->_greenBits);
           glGetIntegerv(GL_BLUE_BITS, &this->_blueBits);
           glGetIntegerv(GL_ALPHA_BITS, &this->_alphaBits);

           glGetIntegerv(GL_DEPTH_BITS, &this->_depthBits);
           glGetIntegerv(GL_STENCIL_BITS, &this->_stencilBits);


           glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &this->_maximumCombinedTextureImageUnits); // min: 8
           glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &this->_maximumCubeMapSize); // min: 16
           glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &this->_maximumFragmentUniformVectors); // min: 16
           glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &this->_maximumTextureImageUnits); // min: 8
           glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &this->_maximumRenderbufferSize); // min: 1
           glGetIntegerv(GL_MAX_TEXTURE_SIZE, &this->_maximumTextureSize); // min: 64
           glGetIntegerv(GL_MAX_VARYING_VECTORS, &this->_maximumVaryingVectors); // min: 8
           glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &this->_maximumVertexAttributes); // min: 8
           glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &this->_maximumVertexTextureImageUnits); // min: 0
           glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &this->_maximumVertexUniformVectors); // min: 128
           glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, &this->_aliasedLineWidthRange); // must include 1
           glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, &this->_aliasedPointSizeRange); // must include 1
           glGetIntegerv(GL_MAX_VIEWPORT_DIMS, this->_maximumViewportDimensions);

           // Query and initialize extensions
           this->_standardDerivatives = GL_OES_standard_derivatives;
           this->_elementIndexUint = GL_OES_element_index_uint;
           this->_depthTexture = GL_OES_depth_texture;
           this->_textureFloat = GL_OES_texture_float;

           this->_textureFilterAnisotropic = GL_EXT_texture_filter_anisotropic;
           this->_maximumTextureFilterAnisotropy =  1.0;

           this->_vertexArrayObject = GL_OES_vertex_array_object;
           //this->_fragDepth = getExtension(gl, [‘EXT_frag_depth‘]);

           //this._drawBuffers = getExtension(gl, [‘WEBGL_draw_buffers‘]);
           //this->_maximumDrawBuffers = defined(this._drawBuffers) ? gl.getParameter(this._drawBuffers.MAX_DRAW_BUFFERS_WEBGL) : 1;
           //this->_maximumColorAttachments = defined(this._drawBuffers) ? gl.getParameter(this._drawBuffers.MAX_COLOR_ATTACHMENTS_WEBGL) : 1; // min when supported: 4

            GLfloat cc[4] = { 0.0, 0.0, 0.0, 0.0 };
            glGetFloatv( GL_COLOR_CLEAR_VALUE, cc );
           this->_clearColor = new Color(cc[0], cc[1], cc[2], cc[3]);

           glGetIntegerv(GL_DEPTH_CLEAR_VALUE, &this->_clearDepth);
           glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &this->_clearStencil);
   }

获取 OpenGL 常用信息