void ViewerGL::Implementation::initializeGL() { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); _this->makeCurrent(); supportsOpenGL = initAndCheckGlExtensions(); if (!supportsOpenGL) { return; } displayTextures[0].reset( new Texture(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST, GL_CLAMP_TO_EDGE) ); displayTextures[1].reset( new Texture(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST, GL_CLAMP_TO_EDGE) ); // glGenVertexArrays(1, &_vaoId); glGenBuffers(1, &this->vboVerticesId); glGenBuffers(1, &this->vboTexturesId); glGenBuffers(1, &this->iboTriangleStripId); glBindBuffer(GL_ARRAY_BUFFER, this->vboTexturesId); glBufferData(GL_ARRAY_BUFFER, 32 * sizeof(GLfloat), 0, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, this->vboVerticesId); glBufferData(GL_ARRAY_BUFFER, 32 * sizeof(GLfloat), 0, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->iboTriangleStripId); glBufferData(GL_ELEMENT_ARRAY_BUFFER, 28 * sizeof(GLubyte), triangleStrip, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glCheckError(); initializeCheckerboardTexture(true); if (this->supportsGLSL) { _this->initShaderGLSL(); glCheckError(); } glCheckError(); }
void ViewerGL::Implementation::initializeGL() { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); _this->makeCurrent(); initAndCheckGlExtensions(); int format, internalFormat, glType; Texture::getRecommendedTexParametersForRGBAByteTexture(&format, &internalFormat, &glType); displayTextures[0].texture.reset( new Texture(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST, GL_CLAMP_TO_EDGE, Texture::eDataTypeByte, format, internalFormat, glType) ); displayTextures[1].texture.reset( new Texture(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST, GL_CLAMP_TO_EDGE, Texture::eDataTypeByte, format, internalFormat, glType) ); // glGenVertexArrays(1, &_vaoId); glGenBuffers(1, &this->vboVerticesId); glGenBuffers(1, &this->vboTexturesId); glGenBuffers(1, &this->iboTriangleStripId); glBindBuffer(GL_ARRAY_BUFFER, this->vboTexturesId); glBufferData(GL_ARRAY_BUFFER, 32 * sizeof(GLfloat), 0, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, this->vboVerticesId); glBufferData(GL_ARRAY_BUFFER, 32 * sizeof(GLfloat), 0, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->iboTriangleStripId); glBufferData(GL_ELEMENT_ARRAY_BUFFER, 28 * sizeof(GLubyte), triangleStrip, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glCheckError(); initializeCheckerboardTexture(true); _this->initShaderGLSL(); glCheckError(); }