Skip to main content
gamedev.net
🔒 Locked

loading image

Started by PG Apr 28, 2006 at 2:14 AM 1 replies 850+ views
Original Post
PG
PG
hi, i want to make some simple game using openGL library. thus, in my game, i need to load some images/sprites i got stuck because lot of my sprites' dimentions are not powers of two... does anyone know how to load images with dimentions not power of two? for example.. my sprites' dimention is 200 X 300 thanks
James Trotter
James Trotter
You could use the GL_ARB_texture_non_power_of_two extension (oss.sgi.com/projects/ogl-sample/ registry/ARB/texture_non_power_of_two.txt).
Another option is to create a texture which is a power of two, but where your sprite is only in the top-left or something, while the rest is black. Then you could adjust the texture coordinates to only display the sprite. If the sprites are small enough you could put several of them onto a 512x512 texture, for instance. This might also save you changing texture states that often, which might improve performance slightly. The cost is that you might be wasting a bit of texture memory.
cignox1
cignox1
[OT]
Quite funny, something strange happened to me right now: I was sure to have already answered to this post a couple of days ago...
[/OT]

As far as I know, non power of two textures are supported only by few latest models (don't know exactly which), so if you want to do this way you should carefully consider you target hw.
You might want pack more than one sprites in one texture (i.e. an animation): if you have 10 frames of animations, each 200x300, you can put them in a 1024x1024 texture in a 5x3 matrix, and using texture coordinates as you would access to a 2 dimensional vecto (more or less).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.