Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. gl function not working
Forum Updated to NodeBB v4.3 + New Features

gl function not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 767 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manoj_prasanga
    wrote on last edited by Christian Ehrlicher
    #1

    this is my sourse code of openGL.

    #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
    QWidget(parent)
    {
    
    }
    
    void GLWidget:: initializeGL(){
    
    }
    void GLWidget:: paintGL(){
        glClear(GL_COLOR_BUFFER_BIT);
        glColor3f(1,1,0);
        glBegin(GL_TRIANGLES);
        glVertex2f(-0.7,-0.7);
        glVertex2f(+0.7,-0.7);
        glVertex2f(0.0,+0.7);
        glEnd();
    
    }
    void  GLWidget ::resizeGL(int w, int h){
       glViewport(0,0,w,h);
    }
    
    

    But it's not working properly.There is a messages

    "D:\Acedamic\4th year\PR410 Manufacturing project1\Qt\gui\glwidget.cpp:14: error: 'GL_COLOR_BUFFER_BIT' was not declared in this scope
    glClear(GL_COLOR_BUFFER_BIT);"

    and

    "D:\Acedamic\4th year\PR410 Manufacturing project1\Qt\gui\glwidget.cpp:14: error: 'glClear' was not declared in this scope
    glClear(GL_COLOR_BUFFER_BIT);"

    what can i do?

    /edit by moderator: added <code> tags

    aha_1980A 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @manoj_prasanga said in gl function not working:

      what can i do?

      Maybe include the header which defines glClear() which is imo gl.h

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      M 1 Reply Last reply
      1
      • M manoj_prasanga

        this is my sourse code of openGL.

        #include "glwidget.h"
        
        GLWidget::GLWidget(QWidget *parent) :
        QWidget(parent)
        {
        
        }
        
        void GLWidget:: initializeGL(){
        
        }
        void GLWidget:: paintGL(){
            glClear(GL_COLOR_BUFFER_BIT);
            glColor3f(1,1,0);
            glBegin(GL_TRIANGLES);
            glVertex2f(-0.7,-0.7);
            glVertex2f(+0.7,-0.7);
            glVertex2f(0.0,+0.7);
            glEnd();
        
        }
        void  GLWidget ::resizeGL(int w, int h){
           glViewport(0,0,w,h);
        }
        
        

        But it's not working properly.There is a messages

        "D:\Acedamic\4th year\PR410 Manufacturing project1\Qt\gui\glwidget.cpp:14: error: 'GL_COLOR_BUFFER_BIT' was not declared in this scope
        glClear(GL_COLOR_BUFFER_BIT);"

        and

        "D:\Acedamic\4th year\PR410 Manufacturing project1\Qt\gui\glwidget.cpp:14: error: 'glClear' was not declared in this scope
        glClear(GL_COLOR_BUFFER_BIT);"

        what can i do?

        /edit by moderator: added <code> tags

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @manoj_prasanga

        One more note:

        "D:\Acedamic\4th year\PR410 Manufacturing project1\Qt\gui\glwidget.cpp..."

        Avoid whitespaces and special characters in path and file names by all means.

        It will hurt you!

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        1
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by SGaist
          #4

          Hi,

          @manoj_prasanga said in gl function not working:

          GLWidget::GLWidget(QWidget *parent) :
          QWidget(parent)
          {

          }

          Is your GLWidget class really a subclass of QWidget ? If so you should first change that to QOpenGLWidget.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            @manoj_prasanga said in gl function not working:

            what can i do?

            Maybe include the header which defines glClear() which is imo gl.h

            M Offline
            M Offline
            manoj_prasanga
            wrote on last edited by
            #5

            @Christian-Ehrlicher thanx freind

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved