Added basic opengl rendering
This commit is contained in:
parent
0e80188eaa
commit
89fb2f7ef3
3 changed files with 27 additions and 7 deletions
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = 3dobj-renderer
|
TARGET = 3dobj-renderer
|
||||||
INCLUDEPATH += .
|
INCLUDEPATH += . \
|
||||||
|
/usr/include/GL
|
||||||
|
DEPENDPATH += . \
|
||||||
|
/usr/include/GL
|
||||||
|
|
||||||
# You can make your code fail to compile if you use deprecated APIs.
|
# You can make your code fail to compile if you use deprecated APIs.
|
||||||
# In order to do so, uncomment the following line.
|
# In order to do so, uncomment the following line.
|
||||||
|
@ -14,7 +17,6 @@ INCLUDEPATH += .
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
# Input
|
# Input
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp opglwidget.cpp
|
||||||
FORMS += mainwindow.ui
|
FORMS += mainwindow.ui
|
||||||
|
|
||||||
QT += core gui widgets
|
QT += core gui widgets
|
||||||
|
|
|
@ -1,8 +1,22 @@
|
||||||
#include "opglwidget.h"
|
#include "opglwidget.h"
|
||||||
#include <QtGui/QOpenGLFunctions>
|
#include <GL/gl.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
//virtual void OPGLWidget::initializeGL() override {}
|
void OPGLWidget::initializeGL() {
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
//virtual void OPGLWidget::paintGL() override {}
|
void OPGLWidget::paintGL() {
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
//virtual void OPGLWidget::resizeGL(int w, int h) override {}
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -4,4 +4,8 @@ class OPGLWidget : public QOpenGLWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OPGLWidget(QWidget *parent) : QOpenGLWidget(parent) {}
|
OPGLWidget(QWidget *parent) : QOpenGLWidget(parent) {}
|
||||||
|
protected:
|
||||||
|
void paintGL();
|
||||||
|
void initializeGL();
|
||||||
|
void resizeGL(int w, int h);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue