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



Recommended Posts

I''m trying to write a 2D scroller-type game, and I''m hoping someone here could help me out with a problem that I can''t seem to solve that would help me out immensely. In the code I''m posting below, the program basically loops through an array (called "Map") and returns the value of the current entry in the array. This number is then used to bind a texture to a quad. Now, my problem is this: I can''t seem to figure out how to draw a row of quads. Right now, it just draws one long quad. I''ve attempted to try some different things (such as incrementing each vertex''s X value by 1), but I can''t seem to make it draw 5 (the size of the array) seperate quads in a row. I know the solution is simple, but I have no clue how to do this. ANy help would be appreciated!
for (int i = 0; i < 5; i++)

tex = Map[i];
glBindTexture(GL_TEXTURE_2D, texture[1]);

glTexCoord2f(1.0f,0.0f); glVertex3f(pos1+i,0.2f,0.0f);
glTexCoord2f(1.0f,1.0f); glVertex3f(pos2+i,-0.2f,0.0f);
glTexCoord2f(0.0f,1.0f); glVertex3f(pos3+i,-0.2f,0.0f);
glTexCoord2f(0.0f,0.0f); glVertex3f(pos4+i,0.2f,0.0f);


Share this post

Link to post
Share on other sites
i dont quite understand what output u got, and what u want,
but what i can see from the code is,
bind should be
glBindTexture(GL_TEXTURE_2D, tex);

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
or maybe
glBindTexture(GL_TEXTURE_2D, texture[tex]);

Share this post

Link to post
Share on other sites