russell's picture

draw non power of two texture

I want to draw non power of two texture. How to do it? Are there some examples?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

All OpenGL 2.1-capable cards can use NPOT textures without additional work (you can call GL.TexImage2D and pass any value as width and height, up to max texture size.) This includes any Nvidia card since Geforce FX, any Ati card since 9500 (with some limitations) or X300 (without limitations) and recent Intel cards running on up-to-date drivers (GMA950 found on older netbooks being one notable exception).

Have you tried this? Did you get an error? If so, what video card/drivers are you using?

russell's picture

I use internal Intel video card which does not support NPOT textures. How to draw NPOT textures at this video card?

the Fiddler's picture

NPOT textures are offered by two different extensions: ARB_texture_non_power_of_two and ARB_texture_rectangle. If the card supports neither, the only solution is to use a larger POT texture with parts that go unused (e.g. 640x480 -> 1024x512). You could also split the NPOT texture into multiple POT parts that add up to the original size, but this will be harder to manage.

In any case, I'd also suggest sending an email to your computer vendor, demanding better OpenGL support. If enough users complain, vendors will pressure Intel to improve their drivers, which would be good for everyone. (The hardware is actually pretty capable, as evidenced by the Linux and Mac OS X drivers, it's Intel that doesn't want to spend time/money for proper OpenGL support on Windows.)

russell's picture

Thanks. I'll try to use multiple POT parts.

awdorrin's picture

I ran into this problem as well with my application. I need to support a PC that uses an older Intel integrated video chipset.

What I did was:
* Determine if the bitmap was a power of 2 or not
* if it was not, determine the next largest power of two
* Generated a texture of that size with color set to all zeros (for transparent black)
* used the 'GL.TexSubImage2D' to load the texture into the 'larger power of two' texture

You end up with your 'non power of two' texture inside of a power of two texture. If you keep track of your original texture's dimensions, you can scale the texture as needed when you use it.

Gunter's picture

I can report two OpenGL ES emulators for Windows:

The OpenGL ES 1.1 Emulator from mali Developer Center (ARM) doesn't support it.
The OpenGL ES 1.1 Emulator PVRVFrame from Imagination (PowerVR) does support it.