Texture Mapping Problem

djohnson
Unregistered
 
Post: #1
Ok, I am having a small problem with texture mapping. I am learning OpenGL from the NeHe lessons. When I try and texture map a quad that is not a 1 to 1 relation with the image, ie 256 x 256 or 128 x 128, it will not show the image. I am trying to display a 640 x 480 image in the same size window. I am sure I can go up to 640 x 640, but I would prefer not to do that at this time. Anyone have any ideas??? The code works just fine if I change the image name to something that is 256 x 256 pixels. Thanks!
Quote this message in a reply
Moderator
Posts: 434
Joined: 2002.09
Post: #2
By default OpenGL textures need to be a power of two along each side.

On many video cards you can get around it by enabling the GL_EXT_texture_rectangle extension, if that extension is supported on your setup. For more information about that extension see:
http://developer.apple.com/opengl/extens..._rectangle

Measure twice, cut once, curse three or four times.
Quote this message in a reply
djohnson
Unregistered
 
Post: #3
Ok... I have been trying to display that and it wont work. I do have an ati 9700 in my laptop here. Should I be able to display a 640 x 640 image? Also, what depth would I need to place the quad so that it will completely fill the width of a 640 x 480 window? Sorry for the simple questions, I am finally learning OpenGL now that i have a computer that can handle it!!!
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #4
In order to use GL_EXT_texture_rectangle you need to do some random special stuff which I don't know off the top of my head. Your ATi 9700 can easily handle it, remember, however that not all computers can. In my opinion, the best option is to just use a slightly bigger power-of-two texture.
Quote this message in a reply
djohnson
Unregistered
 
Post: #5
I agree now. I am trying to display a map to do some basic racing stuff on top of it. I dont know if this is even what i really need. For now I am going to try parsing my image into smaller 128 x 128 files and then read those in to display on different quads. Anyone know of a good tutorial site that covers 2D stuff with OpenGL?
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
Go study this NeHe tutorial on orthographic projection.

After you understand how to set up a viewport and projection, then you can worry about texturing. The upshot is that Macs made in 2002 or later can use rectangle textures, and for certain applications it is easier (and faster) to use them instead of regular power-of-two textures. If you need to support older Macs then you have a few options, such as stitching several textures together, stretching the texture, or wasting texture space.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #7
arekkusu Wrote:Go study this NeHe tutorial on orthographic projection.

After you understand how to set up a viewport and projection, then you can worry about texturing. The upshot is that Macs made in 2002 or later can use rectangle textures, and for certain applications it is easier (and faster) to use them instead of regular power-of-two textures. If you need to support older Macs then you have a few options, such as stitching several textures together, stretching the texture, or wasting texture space.
Texture stitching is ungodly slow. This was actually the downfall of CocoaBlitz. I'd recommend stretching or wasting if you must support older cards. Though, with either of those, you're wasting what little texram there is anyways so you're going to get poor performance regardless. Mad

I would simply ditch non QE cards and require the RectTexExt. There's a CoreGraphics call that will let you interrogate whether QE is supported (and thus RectTex) that you can use, so you don't have to build any GL to interrogate.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Mapping 2D texture to multiple GL_TRIANGLES ardowz 2 998 Mar 12, 2014 08:56 AM
Last Post: ardowz
  Texture mapping single 3D object with one draw call jeonghyunhan 1 2,743 Jul 13, 2009 06:05 AM
Last Post: ThemsAllTook
  Texture coordinate problem Oddity007 0 2,010 Jan 21, 2009 06:20 PM
Last Post: Oddity007
  Texture Mapping: Loading a texture from a .bmp file? ishrock 5 6,123 Dec 13, 2008 09:27 AM
Last Post: ThemsAllTook
  Porting SDL to Cocoa OpenGL view--texture problem smittyz 7 5,133 Jul 21, 2007 07:53 PM
Last Post: smittyz