Files
opengl-learn/qopengltest/glwidget.cpp
2025-12-18 09:26:50 +08:00

27 lines
615 B
C++

#include "glwidget.h"
#include <GL/gl.h>
#include <QtWidgets/qopenglwidget.h>
GLWidget::GLWidget(QWidget* parent): QOpenGLWidget(parent) {}
GLWidget::~GLWidget() {
makeCurrent();
doneCurrent();
}
void GLWidget::initializeGL() {
initializeOpenGLFunctions();
glEnable(GL_DEPTH_TEST);
// TODO: 1.编译shader 2.创建VAO VBO 3.加载texture 4.加载model
}
void GLWidget::resizeGL(int w, int h) {
glViewport(0, 0, w, h);
}
void GLWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// TODO 1.绑定shader 2.设置uniform 3.draw calls
// 不要swapBuffers
}