Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved gl function not working

    General and Desktop
    4
    5
    325
    Loading More Posts
    • 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
      manoj_prasanga last edited by Christian Ehrlicher

      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_1980 1 Reply Last reply Reply Quote 0
      • Christian Ehrlicher
        Christian Ehrlicher Lifetime Qt Champion last edited by

        @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 has to stay free or it will die.

        M 1 Reply Last reply Reply Quote 1
        • aha_1980
          aha_1980 Lifetime Qt Champion @manoj_prasanga last edited by

          @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 Reply Quote 1
          • SGaist
            SGaist Lifetime Qt Champion last edited by SGaist

            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 Reply Quote 1
            • M
              manoj_prasanga @Christian Ehrlicher last edited by

              @Christian-Ehrlicher thanx freind

              1 Reply Last reply Reply Quote 0
              • First post
                Last post