at first, another question. will this work ?
(i’m using gl4java, just ignore the gl.* and glEnum.*)
public void setStates(GLFunc gl)
{
gl.glEnableClientState(GLEnum.GL_VERTEX_ARRAY);
if (hasNormals)
{
gl.glEnableClientState(GLEnum.GL_NORMAL_ARRAY);
}
if (hasColors)
{
gl.glEnableClientState(GLEnum.GL_COLOR_ARRAY);
}
if (hasFog)
{
gl.glEnableClientState(GLEnum.GL_FOG_COORDINATE_ARRAY_EXT);
}
if (hasUnit0TexCoords)
{
gl.glActiveTexture(0);
gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
}
if (hasUnit1TexCoords)
{
gl.glActiveTexture(1);
gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
}
if (hasUnit1TexCoords)
{
gl.glActiveTexture(2);
gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
}
if (hasUnit1TexCoords)
{
gl.glActiveTexture(3);
gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
}
}
or do i have to use glActiveTextureARB ? whats the difference ?
next question : i already have working vertex arrays. how can i make them faster by using vars ?
can i still manipulate single elements inside this array ?
final question :
when i’m done, i want to use an interleaved array, storing all data that is needed, making use of indexed access, AND use all this as a var.
is it possible, and if yes, how ?
Use VBO (Vertex Buffer Objects) instead. It´s much easier to implement, it´s an ARB extension and it´s the way drivers like the data most (because the drivers optimize it most, VAR will certainly get dropped in the near future.
Three issues with your coude:
1)Earlier calls to setstate() may have left some arrays enabled, so you must make sure to disable them if they’re not needed.
public void setStates(GLFunc gl)
{
gl.glEnableClientState(GLEnum.GL_VERTEX_ARRAY);
if (hasNormals)
{
gl.glEnableClientState(GLEnum.GL_NORMAL_ARRAY);
}
[b] else
{
gl.glDisableClientState(GLEnum.GL_NORMAL_ARRAY);
}[/b]
.
.
.
2)For setting array pointers and enables, you need to use glClientActiveTexture. glActiveTexture (w/o Client) routes texture bindings and texture environment state, not vertex array state.
if (hasUnit0TexCoords)
{
gl.gl[b]Client[/b]ActiveTexture(0);
gl.glEnableClientState(GLEnum.GL_TEXTURE_COORD_ARRAY);
}
This will most likely require changes to other places in your code, wherever you set your texture coord pointers.
3)“if (hasUnit1TexCoords)” occurs three times. C&P related typos, I guess
in my case, gl.glVertexPointer(3,GL_FLOAT,?,myarray);
3 is for 3 floats, x,y & z coordinate
float means, the data is stored in floats
? is what i don’t know.
is it the number of array indices i’ll have to add until i get from my old z to the next x ? or is it the number of floats between the old z and the new x ?
if i store x,y,z,texx,texy,x2,y2,z2,texx2,texy2, is the stride value 2 or 3 ?