Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glDrawElements call with wrong type in Simple_TextureCubemap example #8

Open
GoogleCodeExporter opened this issue Apr 7, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Compile the code of Chapter_9/Simple_TextureCubemap.
2. Try to execute compiled binary with OpenGL ES 2.0 lilbrary

What is the expected output? What do you see instead?
Expected result: To see a sphere.
Real result: No sphere.

What version of the product are you using? On what operating system?
Source from trunk (2012-05-27).
Using Mali's OpenGL ES 2.0 emulator.

Please provide any additional information below.
glDrawElements is called with type GL_UNSIGNED_INT which according to OpenGL ES 
2.0 specification is not supported. That generates GL_INVALID_ENUM error.
For reference see the description of glDrawElements() at: 
http://www.khronos.org/opengles/sdk/docs/man/

To be fixed GL_UNSIGNED_SHORT should be used instead of GL_UNSIGNED_INT. 
esShapes.c and and esUtil.h files should be changed accordingly. You can find 
my fix bellow. I've just compiled this example and not the other. So there may 
be the same error in them also.

--------------------- Fix start -----------------------

diff -r -x.svn -u3 
svn_trunk/opengles-book-samples-read-only/LinuxX11/Chapter_9/Simple_TextureCubem
ap/Simple_TextureCubemap.c 
workCopy/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c
--- 
svn_trunk/opengles-book-samples-read-only/LinuxX11/Chapter_9/Simple_TextureCubem
ap/Simple_TextureCubemap.c  2012-05-27 13:25:58.376169537 +0300
+++ workCopy/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c    2012-05-27 
13:57:57.293899986 +0300
@@ -34,7 +34,7 @@
    int      numIndices;
    GLfloat *vertices;
    GLfloat *normals;
-   GLuint *indices;
+   GLushort *indices;

 } UserData;

@@ -184,7 +184,7 @@
    glUniform1i ( userData->samplerLoc, 0 );

    glDrawElements ( GL_TRIANGLES, userData->numIndices, 
-                    GL_UNSIGNED_INT, userData->indices );
+                    GL_UNSIGNED_SHORT, userData->indices );
 }

 ///
diff -r -x.svn -u3 
svn_trunk/opengles-book-samples-read-only/LinuxX11/Common/esShapes.c 
workCopy/Common/esShapes.c
--- 
svn_trunk/opengles-book-samples-read-only/LinuxX11/Common/esShapes.c    2012-05-27 
13:25:58.348169402 +0300
+++ workCopy/Common/esShapes.c  2012-05-26 23:43:42.619519502 +0300
@@ -52,7 +52,7 @@
 ///         if it is not NULL ) as a GL_TRIANGLE_STRIP
 //
 int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals, 
-                             GLfloat **texCoords, GLuint **indices )
+                             GLfloat **texCoords, GLushort **indices )
 {
    int i;
    int j;
@@ -72,7 +72,7 @@
       *texCoords = malloc ( sizeof(GLfloat) * 2 * numVertices );

    if ( indices != NULL )
-      *indices = malloc ( sizeof(GLuint) * numIndices );
+      *indices = malloc ( sizeof(GLushort) * numIndices );

    for ( i = 0; i < numParallels + 1; i++ )
    {
@@ -108,7 +108,7 @@
    // Generate the indices
    if ( indices != NULL )
    {
-      GLuint *indexBuf = (*indices);
+      GLushort *indexBuf = (*indices);
       for ( i = 0; i < numParallels ; i++ ) 
       {
          for ( j = 0; j < numSlices; j++ )
diff -r -x.svn -u3 
svn_trunk/opengles-book-samples-read-only/LinuxX11/Common/esUtil.h 
workCopy/Common/esUtil.h
--- 
svn_trunk/opengles-book-samples-read-only/LinuxX11/Common/esUtil.h  2012-05-27 
13:25:58.348169402 +0300
+++ workCopy/Common/esUtil.h    2012-05-26 23:44:36.819788237 +0300
@@ -21,6 +21,7 @@
 //  Includes
 //
 #include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
 #include <EGL/egl.h>

 #ifdef __cplusplus
@@ -185,7 +186,7 @@
 ///         if it is not NULL ) as a GL_TRIANGLE_STRIP
 //
 int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals, 
-                             GLfloat **texCoords, GLuint **indices );
+                             GLfloat **texCoords, GLushort **indices );

 //
 /// \brief Generates geometry for a cube.  Allocates memory for the vertex data and stores 

---------------------- Fix end ------------------------


Original issue reported on code.google.com by [email protected] on 27 May 2012 at 11:20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant