Multitexturing & Interleaved vertices VBO
Hi there!
Let''s say, I want use vertex_buffer_object with an interleaved vertex array. I also use DrawElements and element arrays.
A vertex contains of 1 position vector and 2 texture coord vectors, one for the geometry texture, one for the lightmap.
without using lightmap, I just passed the VertexPointer,
and the TexcoordPointer to the 1st texcoord.
this works.
but what will I have to do, if want to make GL using the second texcoord, too, for the second texture unit?
I can''t just pass a second TexcoordPointer, that doesnt work.
Thanks in advance,
unshaven
Assuming:
stuct MyVertex
{
float coords[3];
float texcoord[2];
float lightmaptexcoord[2];
};
The gl*Pointer calls would look like:
glVertexPointer (3, GL_FLOAT, sizeof (MyVertex), 0);
glClientActiveTexture (GL_TEXTURE0_ARB);
glTexCoordPointer (2, GL_FLOAT, sizeof (MyVertex), (char)* NULL + sizeof (float) * 3);
glClientActiveTexture (GL_TEXTURE1_ARB);
glTexCoordPointer (2, GL_FLOAT, sizeof (MyVertex), (char)* NULL + sizeof (float) * 5);
IIRC, textures are bound as such:
glActiveTexture (GL_TEXTURE0_ARB);
glEnable (GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D, nBaseTexture);
glActiveTexture (GL_TEXTURE1_ARB);
glEnable (GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D, nLightMap);
stuct MyVertex
{
float coords[3];
float texcoord[2];
float lightmaptexcoord[2];
};
The gl*Pointer calls would look like:
glVertexPointer (3, GL_FLOAT, sizeof (MyVertex), 0);
glClientActiveTexture (GL_TEXTURE0_ARB);
glTexCoordPointer (2, GL_FLOAT, sizeof (MyVertex), (char)* NULL + sizeof (float) * 3);
glClientActiveTexture (GL_TEXTURE1_ARB);
glTexCoordPointer (2, GL_FLOAT, sizeof (MyVertex), (char)* NULL + sizeof (float) * 5);
IIRC, textures are bound as such:
glActiveTexture (GL_TEXTURE0_ARB);
glEnable (GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D, nBaseTexture);
glActiveTexture (GL_TEXTURE1_ARB);
glEnable (GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D, nLightMap);
damn it, it doesn''t work as it''s supposed to do.
my geometry appeares BLACK. when I turn my screen''s brightness up to the max, I then hardly see the pattern of the light-texture (which is a pattern of some light shades of gray, alomst white, in original).
when I have the #0 texture unit disabled with
glActiveTexture (GL_TEXTURE0);
glDisable (GL_TEXTURE_2D);
then the geometry appeares colored by the test light texture in its full brightness.
the texture for the texunit #0 I can only see if I
enable TU #0 with
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_2D);
the #1 TU disabled like above,
AND outcommented this:
glClientActiveTexture (GL_TEXTURE1_ARB);
glTexCoordPointer (2, GL_FLOAT, sizeof (MyVertex), (char)* NULL + sizeof (float) * 5);
in the place where I initialize this stuff (every frame, just before starting to render the level geometry)
I also disable the #1 TU when drawing a skybox, right before passing the vertex & texcoord pointers and rendering the level.
I ensured that the bytes to shift are correct by, instead of hardcoding the 3*sizeof() and 5*sizeof(), I did something like
((char*) &VertexArray[0].pos - (char*) &VertexArray[0])
((char*) &VertexArray[0].tex[0] - (char*) &VertexArray[0])
((char*) &VertexArray[0].tex[1] - (char*) &VertexArray[0])
(I thought maybe wrong packing would result in false numbers otherwise)
So, why the hell does this not work?
Do I have to enable multitexturing in a special way?
Without using evrtex arrays, I would pass glMultiTexcoord2f instead of glTexcord2f.
Does the usage of VBO automatically turn multitexturing on, when I activate more than one texture unit?
Any ideas?
maybe I''m just dumb, but I don''t get it working
without using VBOs, multitexturing worked fine...
without using VBOs, multitexturing worked fine...
did you do this? (enable texcoord array for both textures) :
GL.ClientActiveTexture(GL_TEXTURE0_ARB);
GL.EnableClientState(GL_TEXTURE_COORD_ARRAY);
GL.ClientActiveTexture(GL_TEXTURE1_ARB);
GL.EnableClientState(GL_TEXTURE_COORD_ARRAY);
if not i think you have to..
[ My Site ]
''I wish life was not so short,'' he thought. ''Languages take such a time, and so do all the things one wants to know about.'' - J.R.R Tolkien
/*ilici*/
GL.ClientActiveTexture(GL_TEXTURE0_ARB);
GL.EnableClientState(GL_TEXTURE_COORD_ARRAY);
GL.ClientActiveTexture(GL_TEXTURE1_ARB);
GL.EnableClientState(GL_TEXTURE_COORD_ARRAY);
if not i think you have to..
[ My Site ]
''I wish life was not so short,'' he thought. ''Languages take such a time, and so do all the things one wants to know about.'' - J.R.R Tolkien
/*ilici*/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement