Jump to content
  • Advertisement
Sign in to follow this  
Cyndar

OpenGL Vertical Lines?

This topic is 3381 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

'Ello. I'm both new to this site and to OpenGL, but I come here in hopes of solving a problem I've been having. My current project is a first person something, and I've been doing pretty well so far, experimenting and concentrating on making things work, but one massive problem has been bothering me. Every vertical quad that I draw and texture ends up looking like nothing more than a series of lines, as if the texture went from 1d to 2d. Top and bottom textures are unaffected, but I really would like to solve this issue. I've included a picture below to describe my problem. http://i69.photobucket.com/albums/i58/bahamut1993/Screeny.png

Share this post


Link to post
Share on other sites
Advertisement
The texture coordinates for the vertical walls are just not what they should be. Impossible to point out anything specific though, as you haven't shown anything but the final result, when the means to get there is where the problem actually is.

Isolate the problem by looking at the coordinates of a single quad that appears wrong.

Share this post


Link to post
Share on other sites
Thanks for the prompt response. I looked at my code, and nothing seems wrong.

I define all the points of a rectangular volume in the initialization of the program...


Floor.Coordinates[0][0]=-20;Floor.Coordinates[0][1]=-20;Floor.Coordinates[0][2]=-14;
Floor.Coordinates[1][0]=20;Floor.Coordinates[1][1]=-20;Floor.Coordinates[1][2]=-14;
Floor.Coordinates[2][0]=20;Floor.Coordinates[2][1]=20;Floor.Coordinates[2][2]=-14;
Floor.Coordinates[3][0]=-20;Floor.Coordinates[3][1]=20;Floor.Coordinates[3][2]=-14;
Floor.Coordinates[4][0]=-20;Floor.Coordinates[4][1]=-20;Floor.Coordinates[4][2]=-15;
Floor.Coordinates[5][0]=20;Floor.Coordinates[5][1]=-20;Floor.Coordinates[5][2]=-15;
Floor.Coordinates[6][0]=20;Floor.Coordinates[6][1]=20;Floor.Coordinates[6][2]=-15;
Floor.Coordinates[7][0]=-20;Floor.Coordinates[7][1]=20;Floor.Coordinates[7][2]=-15;
Floor.BBox.min.x=-20;Floor.BBox.min.y=-20;Floor.BBox.min.z=-10.5;
Floor.BBox.max.x=20;Floor.BBox.max.y=20;Floor.BBox.max.z=-14;


Then load the texture, using NeHe's LoadBitmap function. Then, in the display function, I call functions to automatically draw quads based on the coordinates.


DrawRectVolume2(Wall1,CeilingTexture2);
DrawRectVolume2(Wall2,CeilingTexture2);
DrawRectVolume2(Wall3,CeilingTexture2);
DrawRectVolume2(Wall4,GroundTexture);
DrawRectVolume(Ceiling,CeilingTexture2);
DrawRectVolume(Floor,GroundTexture);
for (int i=0;i<Walls.size();i++)
DrawRectVolume2(Walls,GroundTexture);


These are the functions called by those lines:


void DrawQuad(RectVolume Volume,int C1, int C2, int C3, int C4,GLuint Texture)
{
glBindTexture(GL_TEXTURE_2D, Texture);
glBegin( GL_QUADS );
glTexCoord3f(Volume.Coordinates[C1][0],Volume.Coordinates[C1][1],Volume.Coordinates[C1][2]);
glVertex3f(Volume.Coordinates[C1][0],Volume.Coordinates[C1][1],Volume.Coordinates[C1][2]);
glTexCoord3f(Volume.Coordinates[C2][0],Volume.Coordinates[C2][1],Volume.Coordinates[C2][2]);
glVertex3f(Volume.Coordinates[C2][0],Volume.Coordinates[C2][1],Volume.Coordinates[C2][2]);
glTexCoord3f(Volume.Coordinates[C3][0],Volume.Coordinates[C3][1],Volume.Coordinates[C3][2]);
glVertex3f(Volume.Coordinates[C3][0],Volume.Coordinates[C3][1],Volume.Coordinates[C3][2]);
glTexCoord3f(Volume.Coordinates[C4][0],Volume.Coordinates[C4][1],Volume.Coordinates[C4][2]);
glVertex3f(Volume.Coordinates[C4][0],Volume.Coordinates[C4][1],Volume.Coordinates[C4][2]);
glEnd();
}

void DrawRectVolume(RectVolume Volume,GLuint Texture)
{
DrawQuad(Volume,0,1,5,4,Texture);
DrawQuad(Volume,1,2,6,5,Texture);
DrawQuad(Volume,2,3,7,6,Texture);
DrawQuad(Volume,3,0,4,7,Texture);
DrawQuad(Volume,0,1,2,3,Texture);
DrawQuad(Volume,4,5,6,7,Texture);
}

void DrawRectVolume2(RectVolume Volume,GLuint Texture)
{
DrawQuad(Volume,0,1,2,3,Texture);
DrawQuad(Volume,4,5,6,7,Texture);
DrawQuad(Volume,0,1,5,4,Texture);
DrawQuad(Volume,1,2,6,5,Texture);
DrawQuad(Volume,2,3,7,6,Texture);
DrawQuad(Volume,3,0,4,7,Texture);
}


Someone more experienced with OpenGL than me has been working with me for a while now, and we can't figure out the problem.

Share this post


Link to post
Share on other sites
You cannot, in general, have the same values for position and texture coordinates. Texture coordinates have nothing to do with position in world space (in which you specify your positions), but specifies what part of the texture goes where on the quad. Therefore, texture coordinates are specified in texture space, which range from 0 at the bottom/left to 1 at the top/right.

I suggest you stick to a single quad only and try to explore the texture coordinates. See what happens when you change the corners of the quad, and what happens when you change the texture coordinates. Then you will see that they are not related, as in your current code.

Try this simple code to begin with, and play with the values (these values should be reasonable, based on your code, but adjust to make the quad visible if not).

glTexCoord2f(0, 0); glVertex3f(-10, -10, 0);
glTexCoord2f(1, 0); glVertex3f( 10, -10, 0);
glTexCoord2f(1, 1); glVertex3f( 10, 10, 0);
glTexCoord2f(0, 1); glVertex3f(-10, 10, 0);

Share this post


Link to post
Share on other sites
It's all starting to make sense to me now. Those few lines of code helped me out a great deal, and I believe I'm going to solve my problem now. Thank you.

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!