gl function not working
-
wrote on 7 Jul 2019, 17:01 last edited by Christian Ehrlicher 7 Jul 2019, 17:43
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
-
@manoj_prasanga said in gl function not working:
what can i do?
Maybe include the header which defines glClear() which is imo gl.h
-
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
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
-
Lifetime Qt Championwrote on 7 Jul 2019, 20:22 last edited by SGaist 7 Jul 2019, 20:23
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.
-
@manoj_prasanga said in gl function not working:
what can i do?
Maybe include the header which defines glClear() which is imo gl.h
wrote on 8 Jul 2019, 02:08 last edited by@Christian-Ehrlicher thanx freind
1/5