PDA

View Full Version : small question answer fast plz

HamsterofDeath
02-14-2003, 05:38 AM
is this (the parameters) correct ?

public void setArrays() {
if (hasVerticles) {
gl.glVertexPointer(3,gl.GL_FLOAT,0,vertex);
} else {
return;
}
if (hasNormals) {
gl.glNormalPointer(gl.GL_FLOAT,0,normal);
}
if (hasTexCoords) {
gl.glTexCoordPointer(2,gl.GL_FLOAT,0,texCoord);
}
if (hasColors) {
gl.glColorPointer(4,gl.GL_FLOAT,0,color);
}
}

Bob
02-14-2003, 06:17 AM
Can't say, because I don't know how you store your data.

Assuming everything is stored unpadded, vertices has three components, texture coordinates has two components and color has four components, all floats, then it looks correct.

HamsterofDeath
02-14-2003, 06:30 AM
yes, i use 3 floats per vertex (x,y,z), 2 for texcoord (x,y), and 4 for color (r,g,b,a)

is there a situation where you need 4 floats per vertex or 3 per texcoord ?

Bob
02-14-2003, 07:08 AM
Unpadded means there's no "empty" data between two consecutive elements.

You can use the W-component of a vertex to easily extend a shadow volume towards infinity, and three texture coordinates is used with cubemaps and 3D textures.

jebus
02-14-2003, 07:23 AM
you didn't tell us how you defined your functions, so ther's no way for us to know if the arguments are valid :p

jebus

HamsterofDeath
02-14-2003, 08:34 AM
define my functions ?
vertex is a floatarray [x,y,z,x2,y2,z2....]
normal is a floatarray [x,y,t,x2,y2,z2...]
etc.
etc.
what do you mean by define ?

shinpaughp
02-14-2003, 11:16 AM
Not sure exactly what you are looking for, but it looks right except for the first if(hasVerticles) which I assume should be if (hasVertices). Are you actually having a problem of some kind?