• Advertisement

Archived

This topic is now archived and is closed to further replies.

Multitexturing & Interleaved vertices VBO

This topic is 5251 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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);

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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*/

Share this post


Link to post
Share on other sites
thanks man, that was exactly the problem. thank''s to you both.

I don''t have an OpenGL book, all I know about OGL I got from little code snippets here and there, maybe that''s not exactly the best way of perfectly understanding what''s going on behind the API.

Share this post


Link to post
Share on other sites

  • Advertisement