<QOpenGLWidget>
class MainWindow : public QOpenGLWidget, protected QOpenGLFunctions_3_3_Core //public QMainWindow, { //Q_OBJECT
GLuint uchwytProg1; //unsigned int
GLuint VertexArrayO; // Vertex Array Object int ilWierz; //ilosc wierzcholkow
GLuint tex0;
public: MainWindow(); ~MainWindow();
void initializeGL(); void paintGL(); void resizeGL(int w, int h);
# endif // MAINWINDOW_H
Plik mainwindow.cpp# include "mainwindow.h"
# include <QOpenGLFunctions_3_3_Core> # include <QFile> # include <Qdebug>
struct vec3 { float x,y,z; };
MainWindow::MainWindow() //QMainWindow(parent)
MainWindow::~MainWindow()
void MainWindow::initializeGL() { initializeOpenGLFunctions();
qDebug() << "initializeGL";
GLint status;
// program kopiujący teksture na ekran uchwytProg1 = glCreateProgram();
QFile file("vshaderS.sh"); if(file.open(QFile::ReadOnly))
QTextStream stream(&file); std::string vshader_zrodlo = stream.readAll().toStdString();
GLuint shader = glCreateShader(GL_VERTEX_SHADER); GLchar* srcs[] = {(GLchar*)vshader_zrodlo.c_str()}; glShaderSource(shader, 1, srcs, NULL); glCompileShader(shader);
glGetShaderiv(shader, GL_COMPILE_STATUS, &status); //skompilowany if( status == true )