Cannot use gl primitives in my mobile application
-
i tried running the following code on a mobile device but i'm getting few errors. the code works fine for desktop or a simulator but shows error for a device..
errors:
'glBegin' was not declared in this scope
'glVertex3f' was not declared in this scope
'glEnd' was not declared in this scopeand so on....
File name:
glwidget.cpp@
#include "glwidget.h"
#include <QtOpenGL>Glwidget::Glwidget(QWidget *parent) :
QGLWidget(parent)
{
}
void Glwidget::initializeGL ()
{
glClearColor (1,1,0,1);
}void Glwidget::resizeGL (int w, int h){
}
void Glwidget::paintGL (){
glClear (GL_COLOR_BUFFER_BIT);
qglColor (QColor(255, 0, 0, 127));
glBegin(GL_TRIANGLES);
glVertex3f(1,1,0);
glVertex3f(-1,-1,0);
glVertex3f(0,5,0);glEnd();
}
@pro file:
@
Add files and directories to ship with the application
by adapting the examples below.
file1.source = myfile
dir1.source = mydir
DEPLOYMENTFOLDERS = # file1 dir1
symbian:TARGET.UID3 = 0xE0DB25C3
Allow network access on Symbian
symbian:TARGET.CAPABILITY += NetworkServices
If your application uses the Qt Mobility libraries, uncomment
the following lines and add the respective components to the
MOBILITY variable.
CONFIG += mobility
MOBILITY +=
QT+=opengl
SOURCES += main.cpp mainwindow.cpp
glwidget.cpp \HEADERS += mainwindow.h
glwidget.h
gl.h
FORMS += mainwindow.uiPlease do not modify the following two lines. Required for deployment.
include(deployment.pri)
qtcAddDeployment()
@if anyone finds a solution to the problem kindly help me out..
thanks :)
[Edit: Please wrap code in @ blocks. -mlong]
-
Most mobile devices do not have immediate mode OpenGL as they use OpenGL ES. This means all things such as glBegin glVertex are not part of the library and you will have to use either vertex arrays or vertex buffer objects.
You will also need to use some form of shader as the normal fixed function GL shading is also not present. This is a good place to start. http://www.khronos.org/opengles/2_X/