How to texture files which do not have height /width thats a power of 2

Started by
22 comments, last by frmzero2hero 21 years, 6 months ago
i want to create texture from a bmp file with resolution 800x600.I I do not want to strech or shrink the resolution ..ie i want to display it as it is. Is there a way to do it?If yes,PLz tell me . note:I am working on Linux for this project. Any help will be appreciated and will be thankful to u all my life
Tell me More
Advertisement
Generate mipmaps for that texture with gluBuild2DMipmaps() :

quote:Red Book, p 385
"If your original has dimensions that are not exact powers of 2, gluBuild*DMipmaps() helpfully scales the image to the nearest power of 2. Also if your texture is too large, gluBuild*DMipmaps reduces the size of the image until it fits".


Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
The only way to display it as is without stretching/shrinking is to break it up into power of 2 chunks.

Only DirectDraw can avoid that annoyance.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting | Dot Com | GameShot ]
quote:Original post by KalvinB
Only DirectDraw can avoid that annoyance.


DirectDraw ? In OpenGL ? On Linux ? ...

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
well i donot know what i Direct Draw .
And not have mip mapping convert it into the nearest power of 2.
Any other way out like loading the bmp file on the screen???
HELP!!!!!
Tell me More
glDrawPixels can render a chunk of memory to the screen, if that''s all you want to do. It will be slow though. But if you want a texture, there is no other way... and don''t dismiss the solution I gave you before even trying it.

As for DirectDraw, it is Windows+DirectX only, hence my comment.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
I believe that there''s actually an OpenGL extension you can enable which will allow you to use textures whose heights and/or widths are not powers of two. I''m not sure of it''s name, though. Anyone else know?

You might want to try searching for it here: http://oss.sgi.com/projects/ogl-sample/registry/. This is list of all the OpenGL extensions currently available, maintained by SGI. Have a look through (although there are about 300 of them...sorry )

Movie Quote of the Week:

"You''ve been eating retard sandwiches again."
- Birdman, Beautiful Girls.Try http://uk.geocities.com/mentalmantle. Seriously. It''s brilliant.
And I just completely redesigned it so it looks even better.
DarkVertex Beta 0.8 available soon!
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Hey my requirements are very stringent in terms of shrinking/streching because this is being developed for a Physcology experiment and they want to track the exact position of the eye for a picture which is displayed full screen.
I am trying glDrawPixels..but if u have sum code that reads bmp and dumps its pixel info on the screen it will be great

thanks a lot for your Help
Tell me More
*sigh* Mipmapping fits the requirements. Which you would realise if you would only read the *censored* manual, or even done a quick search on the concept.

Get your psychology department to buy you a copy if you can't afford it yourself.

As to sharing code, I don't see why I should bother when you're not even doing your share of the research work.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]


[edited by - Fruny on October 3, 2002 3:47:04 PM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Well, glDrawPixels would seem to be the only answer then, if you have to have the exact image you load on the screen.
Mipmapping will distort the image or shrink it (most systems can''t handle textures over 512x512). Either way, you''ll lose pixels...

Look up glReadPixels in the Red Book...

Movie Quote of the Week:

"You''ve been eating retard sandwiches again."
- Birdman, Beautiful Girls.Try http://uk.geocities.com/mentalmantle. Seriously. It''s brilliant.
And I just completely redesigned it so it looks even better.
DarkVertex Beta 0.8 available soon!
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]

This topic is closed to new replies.

Advertisement