Jump to content
  • Advertisement
Sign in to follow this  
PenguinGLX

Vertex Array confuse

This topic is 4170 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 Im newbee plzz help me If I have array of vertex for a cube like this
float CubeVert[24] = { a , b ,c ,   d, e,f ,
                       g , h ,i ,   k, l,m ,
                       n , o ,p ,   q, r,s ,
                       t , u ,v ,   w, s,y };

Each groups of three Letters presents 1 vertex Cube includes 8 vertices ; I also got
unsigned int CubeFace[24]={ a , b , c , d,
                            e , f , g , h,
                            i , k , l , m,
                            n , o , p , q,
                            r , s , t , u,
                            v , w , s , y};

6 Faces for the cube presented in index format (Letters presented in 2 arrays aboves a not the same numbers ,just use for fast and easy typing ) I know that if I call glDrawElements(GL_QUADS,24,GL_UNSIGNED_INT,CubeFaces); It will draw a cube But the thing I confuse is how to assgin texture to that cube for 6 faces float CubeTex[?] = { ? ? ?..... } what is the format of the CubeTex ? suppose I have one texture 2D For the CubeTex Array , Do I have to specify it in reference to the CubeFaces or CubeVert for Ex: +In respect to CubeFaces:
 CubeTex[48]= { a , b // TexCoord 0
                c , d // TexCoord 1
                ..... // TexCoord n
                x , y // Textcood 47

48 = (24 Indexed Vertices ~~ 24 TexCoords) * (2 Tex coordinates); +In respect to CubeVert :
 CubeTex[16]= { a , b // TexCoord 0
                c , d // TexCoord 1
                ..... // TexCoord n
                x , y // Textcood 15

16 = (8 Vertices ~~ 8 TexCoords) * 2( Tex Coordinates); -------------------- Those 2 formats above are just what I think , Im not sure if it right or not Plzzz help me , it would be great to me if an explanation goes with a simple Example Thanks [Edited by - PenguinGLX on April 21, 2007 1:26:31 PM]

Share this post


Link to post
Share on other sites
Advertisement
if each face has the same texture you proceed like this
bind_texture(...);
draw_array();

if the sides have different textures you need to proceed like this

//each facegroup represents all the faces with sharing the same texture
for(i=0 to numfacegroups)
{
bind_texture(texids);
draw_array(face)
}

if your faces have different textures, you most likely have to add duplicate vertices to your vertex array since the texture coordinates might vary dependent on the texture and each vertex is strictly associated with one texture coordinate(theres no index to texture coordinates on per vertex basis)


just pseudo code to point out the mechanism
theres nothing like a textureid_array!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!