Results 1 to 1 of 1

Thread: QGLWidget Problems on Windows OS

  1. #1

    Default 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:
    Qt Code:
    1. QApplication a (argc, argv);
    2. fmt.setSampleBuffers(true);
    3. QTGLDisplay w(fmt);
    4. w.show();
    5. return a.exec();
    To copy to clipboard, switch view to plain text mode 

    QTGLDisplay:

    Qt Code:
    1. QTGLDisplay::QTGLDisplay(QGLFormat Format, QWidget * parent ) : QGLWidget( Format ,parent )
    2. {
    3. par = parent;
    4.  
    5. }
    6. QTGLDisplay::~QTGLDisplay()
    7. {
    8.  
    9. }
    10. void QTGLDisplay::initalizeGL()
    11. {
    12.  
    13. glClearColor(0.0, 0.0, 0.0, 0.0);
    14.  
    15.  
    16. }
    17. void QTGLDisplay::paintGL()
    18. {
    19. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    20. glLoadIdentity();
    21. //GLCockpitDisplay->drawCockpitDisplay();
    22.  
    23. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    24. glLoadIdentity();
    25. glColor3f(1.0f,0.0f,0.0f);
    26. glTranslatef(-1.5f,0.0f,-6.0f);
    27.  
    28. glBegin(GL_TRIANGLES);
    29. glVertex3f( 0.0f, 1.0f, 0.0f);
    30. glVertex3f(-1.0f,-1.0f, 0.0f);
    31. glVertex3f( 1.0f,-1.0f, 0.0f);
    32. glEnd();
    33.  
    34. glTranslatef(3.0f,0.0f,0.0f);
    35.  
    36. glBegin(GL_QUADS);
    37. glVertex3f(-1.0f, 1.0f, 0.0f);
    38. glVertex3f( 1.0f, 1.0f, 0.0f);
    39. glVertex3f( 1.0f,-1.0f, 0.0f);
    40. glVertex3f(-1.0f,-1.0f, 0.0f);
    41. glEnd();
    42. }
    43. void QTCockpitDisplay::glInit()
    44. {
    45.  
    46. }
    47. void QTCockpitDisplay::resizeGL(int width, int height)
    48. {
    49. if (height==0) // Prevent A Divide By Zero By
    50. {
    51. height=1; // Making Height Equal One
    52. }
    53.  
    54. glViewport(0, 0, width, height); // Reset The Current Viewport
    55.  
    56.  
    57.  
    58. glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
    59. glLoadIdentity(); // Reset The Projection Matrix
    60.  
    61. // Calculate The Aspect Ratio Of The Window
    62. gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
    63.  
    64. glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
    65. glLoadIdentity(); // Reset The Modelview Matrix
    66.  
    67. }
    68. void QTGLDisplay::glDraw()
    69. {
    70.  
    71. }
    To copy to clipboard, switch view to plain text mode 
    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.
    Last edited by wysota; 20th December 2009 at 09:39. Reason: missing [code] tags

Similar Threads

  1. Replies: 0
    Last Post: 29th September 2009, 02:28
  2. Deployment problems on Windows...help
    By Hookem in forum Installation and Deployment
    Replies: 2
    Last Post: 11th December 2008, 09:21
  3. Replies: 1
    Last Post: 21st November 2008, 07:00
  4. other windows affecting depth buffer in QGLwidget
    By mullwaden in forum Qt Programming
    Replies: 0
    Last Post: 10th September 2008, 13:43
  5. Linking problems with QT4 under Windows
    By Ancalagon in forum Qt Programming
    Replies: 2
    Last Post: 8th September 2008, 13:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.