How different is GLES 1 from GL ?


clop

Member
Joined
Aug 17, 2010
Messages
176
Hi fellow developers,


Here's a question for you. I'm just starting to experiment with openGL and I've understood that GLES1 was a subset of GL1, and that a working GLES1 code would work with a "standard" openGL.


But my experiments proved me wrong. So, am I right? Is my experiment right? Please, help me :)


My experiment: Drawing a single coloured triangle.


Relevant code:



Code:
#if !defined(HAVE_GLES)

	#define GLfloat	 GLdouble

	#define GL_CLAMP_TO_EDGE	 GL_CLAMP

	#define glClearDepthf glClearDepth

	#define glOrthof	  glOrtho

#endif

GLfloat triangle[] = {

	0.125f, 0.125f, 0.0f,

	0.75f, 0.125f, 0.0f,

	0.125f, 0.75f, 0.0f

};

GLfloat colors[] = {

	0.0f, 0.0f, 1.0f, 1.0f,

	0.0f, 1.0f, 0.0f, 1.0f,

	1.0f, 0.0f, 0.0f, 1.0f

};

void initGL()

{

	glClearColor (0.0f, 0.0f, 0.0f, 0.0f);

	glMatrixMode(GL_PROJECTION);

	glLoadIdentity();

	glOrthof(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);

	glShadeModel(GL_SMOOTH);

}

void drawTriangle(GLfloat *vertices, GLfloat *color)

{

	glEnableClientState(GL_VERTEX_ARRAY);

	glVertexPointer(3, GL_FLOAT, 0, vertices);

	glEnableClientState(GL_COLOR_ARRAY);

	glColorPointer(4, GL_FLOAT, 0, color);

	glDrawArrays(GL_TRIANGLES, 0, 3);

	glDisableClientState(GL_COLOR_ARRAY);

	glDisableClientState(GL_VERTEX_ARRAY);

}


For openGL, I use SDL with flag SDL_OPENGL flag, for openGLES I use EGL.


Result are attached, first one is openGL and second and correct one (I guess) is openGLES rendering.

gl.png

gles.png
 
Last edited by a moderator:
The OpenGL ES one is working as expected, right?


I think your problem is that in the OpenGL version you redefine GLfloat to GLdouble, but you still pass GL_FLOAT to glVertexPointer. So it's interpreting your doubles (64-bit) as floats (32-bit). You should pair GLdouble arrays with GL_DOUBLE, although I don't see why you can't use GLfloat with the OpenGL version, nor any of the other float functions.
 
Nice eye, Exophase, that was it!


That's the problem with first steps, I just assumed that part from the GL->GLES porting tutorial. I really need to better understand what I'm doing :)


Thanks!
 
Back
Top