QGLWidget Problems on Windows OS
I am just trying to get opengl code to work in a QGLWidget using the QT v4.6 Framework on a Windows XP OS. I am running the example from this website:
http://www.digitalfanatics.org/proje...chapter14.html
My code compiles fine. When I run my executable, the executable's window just displays whatever window that is behind it.( ) Does the Windows OS need something special to have the QGLWidget display properly? Here is my source:
Main:
Code:
fmt.setSampleBuffers(true);
QTGLDisplay w(fmt);
w.show();
return a.exec();
QTGLDisplay:
Code:
{
par = parent;
}
QTGLDisplay::~QTGLDisplay()
{
}
void QTGLDisplay::initalizeGL()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
}
void QTGLDisplay::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//GLCockpitDisplay->drawCockpitDisplay();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor3f(1.0f,0.0f,0.0f);
glTranslatef(-1.5f,0.0f,-6.0f);
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();
glTranslatef(3.0f,0.0f,0.0f);
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();
}
void QTCockpitDisplay::glInit()
{
}
void QTCockpitDisplay::resizeGL(int width, int height)
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}
glViewport(0, 0, width, height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
void QTGLDisplay::glDraw()
{
}
Myprofile.pro:
QT += opengl
TEMPLATE = app
HEADERS = QTGLDisplay/QtGLDisplay.h MainMaceWindow.h ScenarioManagerWindow.h ScenarioWidget.h
SOURCES = QTGLDisplay/QtGLDisplay.cpp MainMaceWindow.cpp ScenarioManagerWindow.cpp ScenarioWidget.cpp main.cpp
TARGET = QTGLTest
LIBS += -L"c:/MinGW/lib/" \
-glu32
INCLUDEPATH += "c/:/Qt/QtFWK4.6.0/Test/"
# install
sources.files = README *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials
INSTALLS += sources
Does anyone know how I can get this working properly.