Jump to content
  • Advertisement

Archived

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

Bruno

textures

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

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

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!