3dobj-renderer/opglwidget.cpp

23 lines
512 B
C++
Raw Normal View History

2023-05-02 13:02:56 +05:00
#include "opglwidget.h"
2023-05-02 14:16:05 +05:00
#include <GL/gl.h>
#include <math.h>
2023-05-02 13:02:56 +05:00
2023-05-02 14:16:05 +05:00
void OPGLWidget::initializeGL() {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
2023-05-02 13:02:56 +05:00
2023-05-02 14:16:05 +05:00
void OPGLWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT);
}
2023-05-02 13:02:56 +05:00
2023-05-02 14:16:05 +05:00
void OPGLWidget::resizeGL(int w, int h) {
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float aspect = w / float(h);
float top = 0.2f * tan(M_PI / 8);
float right = 0.2f * tan(M_PI / 8) * aspect;
glFrustum(-right , right, -top, top, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
}