Jump to content
  • Advertisement

Archived

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

nildo

Better way to draw a wall

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

Hello ! I wish to know the best way to draw a wall ! Must have the 4 sides: Back, front, left side, right side. Thank you ! Ahh if possible how to repeat the texture till the end of the wall. Thank you

Share this post


Link to post
Share on other sites
Advertisement
in this site there are 42 tutorials, try to read some of the firsts...



There aren''''t problems that can''''t be solved with a gun...

Share this post


Link to post
Share on other sites
I guess there would only be one way to draw a wall... with polygons..

To repeat the texture use this:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

if you supply texture coordinates > 1.0, it will repeat the texture... For example, glTexCoord(2.0f, 2.0f); will repeat the texture twice in each direction

Share this post


Link to post
Share on other sites
Thats the problem. I dont want to inform how many times i want it to repeat. I want something that will repeat until the wall finishes

Share this post


Link to post
Share on other sites
You have to tell it how many times to repeat. The way you do that is you need a conversion ratio from ''opengl units'' to pixels, and you use that ratio to set the texture coordinates. If the wall is 5 units long and the ratio from opengl units to pixels is 1ogl to 128 pixels, then the coordinates for a 32 pixel texture would need to start at 0 and go to 20(128/32*5) to fill up the wall.

Of course, you need to do the conversion for both texture dimensions and you might need an offset to make them line up correctly, but its a start.

Share this post


Link to post
Share on other sites
"a conversion ratio from ''opengl units'' to pixels" Thants it !!!

Do you know a way to do it ?

Share this post


Link to post
Share on other sites
Well, an ''opengl unit'' has no unit of measure attached, and it depends on how big you make everything. You could decide that 1 unit is a foot and make all your human models about 6 units tall, or you could decide 1 unit is a meter and make your human models 2 units tall. After you choose a unit of measure, you need to decide how many pixels you want to use per unit measure. If you pick feet, you could choose to have 32 pixels per foot and design your textures and models accordingly. You probably want a higher number if you choose meters, like maybe 128 pixels per meter.

Its all really arbitrary, so just pick some numbers and test them out until you like how it looks and feels.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!