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 Update on Tuesday, May 27th 2025

gl function not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 765 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 7 Jul 2019, 17:01 last edited by Christian Ehrlicher 7 Jul 2019, 17:43
    #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

    A 1 Reply Last reply 7 Jul 2019, 18:22
    0
    • C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 7 Jul 2019, 17:45 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 8 Jul 2019, 02:08
      1
      • M manoj_prasanga
        7 Jul 2019, 17:01

        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

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 7 Jul 2019, 18:22 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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 Jul 2019, 20:22 last edited by SGaist 7 Jul 2019, 20:23
          #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
          • C Christian Ehrlicher
            7 Jul 2019, 17:45

            @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 8 Jul 2019, 02:08 last edited by
            #5

            @Christian-Ehrlicher thanx freind

            1 Reply Last reply
            0

            1/5

            7 Jul 2019, 17:01

            • Login

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