iDevGames Forums
Texture Problems - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Texture Problems (/thread-7060.html)



Texture Problems - Sta7ic - May 27, 2003 10:17 PM

From some very strange reason, this breaks my app:

void drawTexture(){
static unsigned int sa_index[6]={0, 1, 2, 1, 3, 2};
static double sa_vertex[12]={20, 0, -20, 60, 0, -20, 20, 0, 20, 60, 0, 20};
static double sa_normal[12]={0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0};
static double sa_texture[8]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0};
glBindTexture(GL_TEXTURE_2D, g_texID);
glVertexPointer(3, GL_DOUBLE, 0, sa_vertex);
glNormalPointer(GL_DOUBLE, 0, sa_normal);
glTexCoordPointer(2, GL_DOUBLE, 0, sa_texture);
// Draw by index[]
glDrawElements(GL_TRIANGLES, (GLsizei)6, GL_UNSIGNED_INT, sa_index);
}

This is the complete method. Vertex, Normal, and TexCoord array pointers are enabled. Index and Color array pointers are disabled.

Why on earth is this throwing sigseg (signal 11) at runtime?!?

-Sta7ic with a growing headache


Texture Problems - blb - May 28, 2003 12:40 AM

Make sure all your arrays are declared with OpenGL types instead of basic types:
Code:
static GLuint sa_index[6]={0, 1, 2, 1, 3, 2};
static GLdouble sa_vertex[12]={20, 0, -20, 60, 0, -20, 20, 0, 20, 60, 0, 20};
static GLdouble sa_normal[12]={0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0};
static GLdouble sa_texture[8]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0};



Texture Problems - OneSadCookie - May 28, 2003 01:02 AM

GLfloat/GL_FLOAT is the path more travelled. If changing double to float throughout fixes the problem, it's time to file a driver bug.


Texture Problems - Sta7ic - May 28, 2003 07:53 AM

The funny thing about GL types is that they're just typedef-ed basic types. There's nothing fancy about them, as long as you don't do strange conversions with them (GLint -> GLdouble).

It's not working with GLfloats, either. Using glArrayElements(), it chokes on the first indice ... with all of the array addresses *right there* and the program choking on the first element, the only things that I can still think of are the textures being bad.

-Sta7ic

...

Update @ 11 am PST:

Funny how you're supposed to read and trace the debugging comments ... an incrimenter was going +6 because it was being used for both the color and texcoord arrays ... one's [k*2] and the other [k*4]...

Sorry about the noise, but now the whole scene's doing wierd stuff, not drawing past the first triangle by the looks of it. Go figure.

-Sta7ic


Texture Problems - tod_baudais - May 28, 2003 11:36 AM

Looks like your stride is wrong in your gl*Pointer calls. It's not zero.

Tod.

EDIT: I'm blind. "If stride is 0, the vertices are understood to be tightly packed in the array. The initial value is 0."


Texture Problems - OneSadCookie - May 28, 2003 01:51 PM

Quote:Originally posted by Sta7ic
The funny thing about GL types is that they're just typedef-ed basic types. There's nothing fancy about them, as long as you don't do strange conversions with them (GLint -> GLdouble).

Of course they're just typedefed basic types... what else could they be?

The problem is that you don't know what they're typedefed from. For example, you don't know whether GLfloat/GLdouble are float/double or double/long double, and you don't know whether GLint is int, long or long long.

Sure, you can look at the header and find out for this platform what types they are, but they differ across platforms.