🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Texture area selecting in openGL

Started by
3 comments, last by kolpo 24 years, 6 months ago
Is there a similar command to glTexCoord2d that determinate wich area of the bitmap is used as texture ? The current problem is that I use small quads to create realistic lighting but I have high res textures.
Advertisement
If I''m following you, can''t you just multiply the texture''s width and height by the T and S parameters passed to glTexCoord?

Do that with each set of parameters and you''ll have the (approximate) area of the bitmap being used(since texels have integer locations, not fp).
-the logistical one-http://members.bellatlantic.net/~olsongt
What about this:

glTexSubImage2D(...)
I don't know if this is what you're looking for but what I've done in OpenGL was to create a single wall 10 by 10 feet in dimensions and draw this wall 10 times to create one long side of a room. I've also wrote a tesselation algorithm to help me split one 10x10 wall into smaller quads exactly 10 horizontally and 10 vertically for dynamic lighting purposes. I gave the inside quads texture coords values that were 1/10th of the length of the wall. So the first bottom left quad's text.coords look like this:

Bottom left 0,0
Top left 0,0.10
Top right 0.10,0.10
Bottom right 0.10,0

The quad next to this one was:

Bottom left 0.10,0
Top left 0.10,0.10
Top right 0.20,0.10
Bottom right 0.20,0

The third bottom quad was:

Bottom left 0.20,0
Top left 0.20,0.10
Top right 0.30,0.10
Bottom right 0.30,0

And this continued across horizontally and vertically. If you don't care about tesselation, then create one long wall 100 feet long 10 feet high out of one quad and give the bottom left texture coord a value of 0,0 top left a value of 0,1 bottom right is 10,0 and top right is 10,1. This will tile the bitmap ten times in the horizontal direction and one time in vertical direction, which I did in D3D except there I created the wall out of 2 triangles (triangle strip) for the lack of quad support in that api. Hope this will give you some ideas.

Edited by - JD on 1/3/00 11:00:12 PM
With glTexCoord2d is it indeed easy. The raison of my misunderstanding is that I thought that the values of glValue where boolean values: 0 or 1 but they are normal floating points.

This topic is closed to new replies.

Advertisement