PDA

View Full Version : OpenGL Issue



Wnt2bsleepin
13th February 2013, 00:35
I am having a problem using OpenGL. I included opengl in the pro file and put the include <QtOpenGL> but it is telling me that it cannot find OpenGL/gl.h



#include "openglpanel.h"
#include <QtOpenGL>

//Define the methods up top.
void OpenGLPanel::initializeGL(){}
void OpenGLPanel::resizeGL(int x, int h){}
void OpenGLPanel::paintGL(){}
void OpenGLPanel::changeSides(int s){}
void OpenGLPanel::changeRadius(double r){}

OpenGLPanel::OpenGLPanel(QWidget *parent) :
QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
sides = 3;
radius = 1.0;

}

void OpenGLPanel::initializeGL()
{
qglClearColor(qtPurple.dark());

glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHTO);
glEnable(GL_MULTISAMPLE);
static GLgloat lightPosition[4] = {0.5, 5.0, 7.0, 1.0};
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
}



I am running OSX and as far as I know, OpenGL is installed by default. Any help is appreciated.

alrawab
13th February 2013, 01:49
add this line to your pro file

QT += opengl

Wnt2bsleepin
13th February 2013, 01:56
Already in there.

wysota
13th February 2013, 02:31
You are missing OpenGL development files for your system. This has nothing to do with Qt.

Wnt2bsleepin
13th February 2013, 03:36
How do I install the dev files?

OpenGL should be installed by default, but I suppose the dev files are not.

wysota
13th February 2013, 10:48
How do I install the dev files?

I have no idea. I'm sure that if you ask this question to your favourite web search engine, it will come up with a number of solutions.

alrawab
13th February 2013, 12:32
How do I install the dev files?

OpenGL should be installed by default, but I suppose the dev files are not.

http://cacs.usc.edu/education/cs596/ogl_setup.pdf
http://www.opengl.org/

Wnt2bsleepin
13th February 2013, 20:55
http://cacs.usc.edu/education/cs596/ogl_setup.pdf
http://www.opengl.org/

Those work with XCode. I compiled and ran the one example and it worked fine. Both OpenGL and Glut are installed.

How do I get it to work with QtCreator? Is there a way to define where the headers/frameworks are?

wysota
13th February 2013, 21:16
Is there a way to define where the headers/frameworks are?

Yes. You can use the INCLUDEPATH variable in your project file.

Wnt2bsleepin
14th February 2013, 00:55
Apparently a .framework file also contains its own folders, so linking to those directly doesn't work



INCLUDEPATH += /System/Library/Frameworks/


According to this (http://stackoverflow.com/questions/2197223/where-are-the-opengl-header-files-located-on-macosx) page, the header files for OpengGL should be in the Headers directory, but it doesn't exists.

8714

Here is also a screenshot of the error.

8715

ChrisW67
14th February 2013, 01:04
According to that same page:


OpenGl is included <OpenGL/gl.h> rather than the more expected <gl/gl.h> on other platforms.

and I think you will see an OpenGL folder in that framework... what's in it?

Wnt2bsleepin
14th February 2013, 01:33
It's not a directory. It appears to be a binary file of some sort.

wysota
14th February 2013, 01:54
It's not a directory. It appears to be a binary file of some sort.

Your own screenshot claims it's an alias to something (probably some other bundle that contains those development files).

Wnt2bsleepin
14th February 2013, 02:40
Your own screenshot claims it's an alias to something (probably some other bundle that contains those development files).

Not familiar with that. Is there a way to find out where it goes?

wysota
14th February 2013, 09:52
My knowledge of MacOSX is very limited, I'm afraid I can't help you.