View Full Version : OpenGL ES 1.1 sprites/textures non-power of 2?
04-05-2009, 01:16 PM
IŽd like to display a non-power of 2 sprite/image with OpenGL ES 1.1, preferably using point sprites. Or is it easier to use normal texturing and play with texture coordinates as in: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=241713
? Could someone explain this more specific? Do i need to load another black, background texture which will fit the scaled loaded texture and combine them somehow or what?
04-05-2009, 09:23 PM
AFAIK on ES all textures have to be POT, and Point Sprites are square on *all* OpenGL implementations I am aware of.
The only way to display NPOT textures in any situation on ES is by using texture coordinates and mapping into a POT texture to extract an NPOT portion.
And the only way to do NPOT Point Sprites is to either make your own QUADS (using Triangles), or use a non square image which only takes up a portion of the Point Sprite's area, and mask it somehow as you theorize.
I have not personally tried to override a Point Sprites texture coordinates with a texture matrix of my own, but perhaps that is possible, rather than having them generate automatically...
i.e. By not using GL_COORD_REPLACE_OES as a TextureEnv parameter.
Someone else might have experience of that... But I suspect it may not be possible, or might have other issues / overheads which make it inefficient depending on your application.
Personally I use large textures with multiple images in them (otherwise know as a texture atlas) when I want to both reduce binding calls and access images which are NPOT.
04-06-2009, 12:39 AM
So is just a matter of calling
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 256, 256,0, GL_RGB, GL_UNSIGNED_BYTE, iTextures);
with a next power of two texture size, and adjust the texture coordinates a bit? Or do i have to pad the image with mores bytes to black at byte level?
04-06-2009, 02:46 AM
Like I said I have not tried generating my own Point Sprite texcoords, but you certainly can map NPOT texture portions onto other geometry by simply using texture coords for an NPOT section of a POT texture.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.