OpenGL Non power of two

Problems with Canvas, OpenGL, etc...

OpenGL Non power of two

Postby puxdroid » Sat May 07, 2011 4:01 pm

Hi every body!
I have a problem with some devices that doesn't support non power of two images, and I would like to know if a device support this kind of operations or not.

Thanks!
puxdroid
Developer
Developer
 
Posts: 49
Joined: Wed Nov 25, 2009 11:57 am

Top

Re: OpenGL Non power of two

Postby bxm » Tue May 10, 2011 4:59 am

You can try querying the extensions string for GL_OES_texture_npot to see if it's supported, AFAIK no 1.x GL devices support NPOT textures.

ex:
Code: Select all
       String extensions = " " + gl.glGetString (GL10.GL_EXTENSIONS) + " ";

       if (extensions.contains (" GL_OES_texture_npot ") == false)
              ; // NPOT not supported


At the same time, it may be possible to load the NPOT Bitmap and then copy it into the a new Bitmap with the nearest POT dimensions, then use the new Bitmap to create the texture with texImage2D.

This could dramatically increase loading time however.
bxm
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue May 10, 2011 2:51 am

Re: OpenGL Non power of two

Postby moblcade.com » Fri Jul 01, 2011 3:36 pm

I haven't noticed much of an increase on loading times using this method as it's mostly using apis compiled in native code. However it will be a memory hog... if you've got a texture that's 257x257 pixels in size you will need to create a bitmap 512x512 pixels... that's a lot of wasted memory. You'd be better off putting all your images together into as few images as possible that already have power of two dimensions and use these as resources. This is called a Texture Atlas and there are many ways to do this manually or semi-automatically. You could even implement it in code and build them dynamically, but it's really just easier not to.
moblcade.com
Junior Developer
Junior Developer
 
Posts: 19
Joined: Tue Sep 07, 2010 6:31 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 1 guest