Texture Problems

Sta7ic
Unregistered
 
Post: #1
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
Quote this message in a reply
blb
Unregistered
 
Post: #2
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};
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
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.
Quote this message in a reply
Sta7ic
Unregistered
 
Post: #4
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
Quote this message in a reply
tod_baudais
Unregistered
 
Post: #5
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."
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL ES Texture Problems jhbau1000 1 5,351 Jul 12, 2010 05:57 AM
Last Post: Kezhaya
  Texture mapping problems thingythekid 1 2,283 Aug 26, 2005 03:56 AM
Last Post: OneSadCookie
  Texture problems Josh 17 7,535 Nov 18, 2002 05:22 PM
Last Post: henryj