Newbie texture problem

Started by
7 comments, last by Lord FlatHead 22 years, 6 months ago
Hi all. I''m working on my first serious OpenGL application for the moment: a top-down game quite similar to Grand Theft Auto. I''ve run into a problem (or at least: something I don''t understand). When I try to display a 640*480 texture on a quad for my title screen, the texture won''t display and instead I get a fully white quad. Textures only display if they''re 256x256 or 512x256 or some other ''typical'' size... I was wondering what I can do about this, and what the exact limits are. I''ve tried just changing the pic''s size to 1024x512 but that just eats up unnecessary disk space. If there''s any way to load a 640*480 (or 800*600) .TGA file and display it fine in OpenGL, I''d like to know soon as it''s pretty urgent. Thanks in advance. "Maybe this world is another planet''''s hell." -- Aldous Huxley
_________"Maybe this world is another planet''s hell." -- Aldous Huxley
Advertisement
To get the Maximum texture size use
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &nMaxTextureSize) 

The size must be 2^n for some integer n if youre texture doesn''t have any border.
This information can either be found in the OGL specification or in the MSDN library.
Did you consider using two textures instead of a single one? 512x512 and 128x512 will result not exactly in 640x480 resolution, but it should work.
I don''t think it has anything to do with maximum texture size: 1024*512 textures work, where 640*480 ones don''t. I think it has something to do with either the aspect ratio of the texture, or that texture dimensions need to be multiples of 16. But 640 and 480 are both multiples of 16, so I don''t see a problem there. Anyway, thanks for replying.

If anyone''s had this problem before and has come up with a solution, please let me know.

_________"Maybe this world is another planet''s hell." -- Aldous Huxley
The dimensions must be powers of 2.

baldurkarlsson
As I've said before: the texture size must be of the form 2^n. Valid sizes are 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, ...
Neither 640 nor 480 is a valid size for a texture.
And remember the maximum texture size for some older cards is 256.

Edited by - VolkerG on October 14, 2001 3:34:40 PM
I''m drunk and rubbish at OpenGL myself, but here goes!

Load the image into memory, then create mipmaps using the glaux lib, that should enable you to use textures of any size (It''s what I do)

goodluck with your project, Dave AKA TerraX.
Alright, thanks for the info. I''ll let you know once the game''s presentable

"Maybe this world is another planet''''s hell." -- Aldous Huxley
_________"Maybe this world is another planet''s hell." -- Aldous Huxley
There''s a really easy way to do this. Do your title screen at 1024x768 or whatever normal res you''d use, 4:3 aspect ratio as usual.

Then, before saving it in PhotoShop or wherever, just scale it to 512x512. When you do that it will of course look squished and wierd, but when you load it and use it as a texture for a full-screen quad it''ll be fine as it''s stretched back to 4:3. Worked perfectly for me.

hth...

-=aSe=-
-=aSe=-

This topic is closed to new replies.

Advertisement