Advertisement

textures

Started by May 07, 2000 06:46 AM
2 comments, last by Bruno 24 years, 6 months ago
Hi I have a problem, that i don''t see a way to solve. This is concerning textures.., I''m making an editor for my 3d objects, and i want to render a button, that suppose is size is 100x30 pixels. If all the textures i can use in opengl have to be, a power of two, how can i render my button in a 100x30 rectangle?? thanks Bruno
I think you can just put the 100x30 button in a 128x128 texture for example and use: (if its in the left top corner)

(0,0)

(100/128, 0) = ( 0.78, 0)

(0, 30/128) = ( 0, 0.23)

(0.78, 0.23)

for the texture coordinates.

The part of the 128x128 texture that not used by the button can be used for other small textures.

I hope this helps you.

WickedMystic
Advertisement
This is a common problem and there is an easy solution (which can be found in NeHe''s texture tutorials), creat your texture for your button using gluBuild2DMipmaps() instead of glTexImage2D(). Mipmaps can handle images of any dimensions.

Morgan
Hmm, well that''s not strictly true. If the texture map isn''t a power of 2, gluMipMaps calls another glu function to resize it to the closest one.

WickedMystic''s method is the method of choice



Paul Groves.
http://home.clara.net/paulyg/ogl.htm
OpenGL for Beginners
Paul Grovespauls opengl page

This topic is closed to new replies.

Advertisement