void paintGL(){ constexpr static float clearColor[] = \ {0.5f,0.3f,0.3f,1}; gl::NamedFrameBufferObject root; root.clearColor(clearColor); root.clearDepth(1); program.use(); program.bindFrameBuffer(root); program.bindVertexArray(vao); program.setUniformMatrix4fv( 1, 1, false, &(modelScale[0][0])); program.setUniformMatrix4fv( 3, 1, false, &(normalMatrix[0][0])); using namespace gl::DrawElements; Pack pack( Mode::TRIANGLES, indexCount, Type::UNSIGNED_INT, nullptr); gl::draw(pack); }
void initializeGL(){ glClearDepth(1); glClearColor(0,0,0,0); #ifdef _DEBUG_OPENGL_QT_ QGLDebugTool::setSimpleCallbackFunction(); QGLDebugTool::test(); #endif gl::createBuffers(1, &pointsBuffer); gl::createBuffers(1, &colorBuffer); gl::createVertexArrays(1,&vao); constexpr gl::Float points[] = { -0.0f,+0.5f, -0.1f,1, -0.5f,-0.5f, -0.1f,1, +0.5f,-0.5f, -0.1f,1, +0.2f,+0.5f, -0.5f,1, -0.3f,-0.5f, -0.5f,1, +0.7f,-0.5f, -0.5f,1, }; constexpr gl::Float colors[] = { 1,0,0,1, 0,1,0,1, 0,0,1,1, 1,1,0,1, 0,1,1,1, 1,0,1,1, }; gl::bufferData(pointsBuffer,sizeof(points),points); gl::bufferData(colorBuffer,sizeof(colors), colors); vao.bindBuffer(0, pointsBuffer); vao.bindBuffer(1, colorBuffer); constexpr char vs[] = R"(#version 450 layout(location=0) in vec4 ipos; layout(location=1) in vec4 icol; layout(location=2) uniform mat4 pMatrix; out vec4 color; void main(){ gl_Position = pMatrix*ipos; color = icol; } )"; constexpr char fs[] = R"(#version 450 in vec4 color; out vec4 fcolor; void main(){ fcolor = color; } )"; program = gl::VFProgramLoadSources(vs,fs); pMatrix = glm::lookAt( glm::vec3(0, 0, 1), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0) ); pMatrix = glm::ortho<float>(-1, 1, -1, 1, 0, 2)*pMatrix; std::cout << pMatrix << std::endl; program.setUniformMatrix4fv(2, 1, false,&(pMatrix[0][0])); gl::enableDepthTest(); }