开发者

How to create textured wall which continuously updated while player is moving up in opengl?

开发者 https://www.devze.com 2023-01-12 16:42 出处:网络
I was wondering how to create wall in opengl and it is continuously appears from up and disappers at down screen. I am able to construct wall by GL_QUADS with texture mapping. but do not k开发者_JS百科

I was wondering how to create wall in opengl and it is continuously appears from up and disappers at down screen. I am able to construct wall by GL_QUADS with texture mapping. but do not k开发者_JS百科now how to generate it dynamically whenever player climbs up.


You have several possibilities.

  • Create one quad for, say, one meter. Render it 100 times, from floor(playerPos.z) to 100 meters ahead. Repeat for the opposite wall
  • Create one quad for 100 meters. Set the U texture coordinate of the quad to playerPos.z and playerPos.z + 100. Set the texture mapping to GL_REPEAT.

The second one is faster (only 2 quads) but doesn't let you choose different textures for different parts of the wall.


You don't have to make a "dynamic wall" (et. change glVertex* values every frame). Just change your camera position (modelview matrix) with glTranslatef function.

(I hope I understood your question correctly)

0

精彩评论

暂无评论...
验证码 换一张
取 消