Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void TriangleWindow::render()
- {
- const qreal retinaScale = devicePixelRatio();
- glViewport(0, 0, width() * retinaScale, height() * retinaScale);
- glClear(GL_COLOR_BUFFER_BIT);
- m_program->bind();
- QMatrix4x4 matrix;
- matrix.perspective(60.0f, 16.0f/9.0f, 0.1f, 100.0f);
- matrix.translate(0, 0, -2);
- matrix.rotate(100.0f * m_frame / screen()->refreshRate(), 0, 1, 0);
- m_program->setUniformValue(m_matrixUniform, matrix);
- /*GLfloat vertices[] = {
- 0.0f, 0.5f,
- -0.5f, -0.5f,
- 0.5f, -0.5f
- };*/
- GLfloat vertices[] = {
- -0.5f, -0.5f,
- 0.5f, -0.5f,
- -0.5f, 0.5f,
- 0.5f, 0.5f
- };
- GLfloat colors[] = {
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f,
- 0.5f, 0.5f, 0.5f
- };
- glVertexAttribPointer(m_posAttr, 2, GL_FLOAT, GL_FALSE, 0, vertices);
- glVertexAttribPointer(m_colAttr, 3, GL_FLOAT, GL_FALSE, 0, colors);
- glEnableVertexAttribArray(0);
- glEnableVertexAttribArray(1);
- glDrawArrays(GL_TRIANGLES, 0, 3);
- glDisableVertexAttribArray(1);
- glDisableVertexAttribArray(0);
- m_program->release();
- ++m_frame;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement