Reputation: 154
I am using qt 5.0.2 (Windows x64) . The problem is that qt only supports OpenGl 3 functions and for example I can't use glBegin(), glortho() etc. Do you have any idea how I can use OpenGL 1.x within qt?
Upvotes: 1
Views: 1596
Reputation: 22826
Where did you get the (wrong) idea that Qt 5 supports Only OpenGL >= 3.0? Qt on its own supports all current Desktop OpenGL versions and profiles (from 1.1 to 4.3, Core/Compability) as well as OpenGL ES (1.1 to 3.0).
By any chance, are you using the binary OpenGL ES 2 downloads (through ANGLE) for Windows? If so, download the Desktop GL version (or build it yourself passing -opengl desktop
to configure).
Note that, in general,
Upvotes: 4
Reputation: 9789
I use this included as a header, "gl.h", in my Qt applications where I want to call OpenGL functions:
#ifndef GL_H
#define GL_H
#ifdef __APPLE__
#include <GL/glew.h>
#include <GLUT/glut.h>
#else
#include <GL/glew.h>
#include <GL/glut.h>
#endif
#endif // GL_H
Note, you need to have installed the correct builds of OpenGL, GLEW and GLUT for this include to work correctly. If you use MinGW, build GLEW and GLUT to use MinGW. If you use Visual C++ 2010, build them to support Visual C++ 2010.
Part of my mainwindow.cpp:
#include "gl.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "about.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_glWidget = new GLWidget();
this->setCentralWidget(m_glWidget);
}
MainWindow::~MainWindow()
{
delete ui;
}
Take a look at this code here to get the full context: https://bitbucket.org/pcmantinker/csc-4356/src/2843c59fa06d0f99d1ba90bf8e328cbb10b1cfb2/project2?at=master
My code is Qt 4.x but should be easy enough to port to Qt 5. Also, here is a reference to the class web page that I took in the fall of 2012: http://csc.lsu.edu/~kooima/csc4356/index.html
It includes pre-built dlls for Windows environments for both Visual C++ 2010 and MinGW.
Upvotes: 0