AndroidGL have texture brightness gitch?

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

AndroidGL have texture brightness gitch?

Postby maczoman » Sun Nov 09, 2008 12:27 pm

Hi,

Im playing with AndroidGL and all textures have orangish colors. Probably it's sth in bitmap loading function but I dont wantto delve too much into this function as Im starting to play with Android stuff.

Can anyone help fixing it? Im using newest SDK 1.0 its with every texture i try :/
Attachments
pic.jpg
How it looks in emulator.
pic.jpg (21.55 KiB) Viewed 4290 times
animated_gif.png
Texture file.
animated_gif.png (8.06 KiB) Viewed 4290 times
maczoman
Freshman
Freshman
 
Posts: 4
Joined: Sun Nov 09, 2008 10:38 am

Top

Re: AndroidGL have texture brightness gitch?

Postby thesombrereokid » Thu Dec 04, 2008 12:02 pm

maczoman wrote:Hi,

Im playing with AndroidGL and all textures have orangish colors. Probably it's sth in bitmap loading function but I dont wantto delve too much into this function as Im starting to play with Android stuff.

Can anyone help fixing it? Im using newest SDK 1.0 its with every texture i try :/


i'm getting this with pngs too, either i'm putting it in the buffer wrong a step missing or pngs aren't fully implemented
thesombrereokid
Freshman
Freshman
 
Posts: 9
Joined: Thu Dec 04, 2008 11:53 am

Postby thesombrereokid » Thu Dec 04, 2008 2:15 pm

btw i was bieng dumb png's use ARGB not RGBA and android hasn't implemented GL10.ARGB so you need to switch the channels around

theres are tutorials here that show the conversion code like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.                 for (int y=bmp.getHeight()-1;y>-1;y--)
  3.  
  4.                         for (int x=0;x<bmp.getWidth();x++) {
  5.  
  6.                                 int pix = bmp.getPixel(x,bmp.getHeight()-y-1);
  7.  
  8.                                 // Convert ARGB -> RGBA
  9.  
  10.                                 @SuppressWarnings("unused")
  11.  
  12.                                 byte alpha = (byte)((pix >> 24)&0xFF);
  13.  
  14.                                 byte red = (byte)((pix >> 16)&0xFF);
  15.  
  16.                                 byte green = (byte) ((pix >> <img src="http://www.anddev.org/images/smilies/cool.png" alt="8)" title="Cool" />&0xFF);
  17.  
  18.                                 byte blue = (byte)((pix)&0xFF);
  19.  
  20.                                
  21.  
  22.                                 // It seems like alpha is currently broken in Android...
  23.  
  24.                                 ib.put(red << 24 | green << 16 | blue << 8 | 0xFF);//255-alpha);
  25.  
  26.                         }
  27.  
  28.  
  29.  
  30.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


this obviously wont work do this

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.                 for (int y=bmp.getHeight()-1;y>-1;y--)
  3.  
  4.                         for (int x=0;x<bmp.getWidth();x++) {
  5.  
  6.                                 int pix = bmp.getPixel(x,bmp.getHeight()-y-1);
  7.  
  8.                                 // Convert ARGB -> RGBA
  9.  
  10.                                 @SuppressWarnings("unused")
  11.  
  12.                                 int alpha = ((pix >> 24)&0xFF);
  13.  
  14.                                 int red = ((pix >> 16)&0xFF);
  15.  
  16.                                 int green = ((pix >> <img src="http://www.anddev.org/images/smilies/cool.png" alt="8)" title="Cool" />&0xFF);
  17.  
  18.                                 int blue = ((pix)&0xFF);
  19.  
  20.  
  21.  
  22.                                 ib.put(red << 24 | green << 16 | blue << 8 | 255-alpha);
  23.  
  24.                         }
  25.  
  26.  
  27.  
  28.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
thesombrereokid
Freshman
Freshman
 
Posts: 9
Joined: Thu Dec 04, 2008 11:53 am

Postby Ultrano » Sat Dec 20, 2008 1:09 am

How about....


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import android.opengl.GLUtils;
  3.  
  4. ...
  5.  
  6. protected Texture LoadTexture(int resID){
  7.  
  8.                 Resources res = getContext().getResources();
  9.  
  10.                 Bitmap bmp = BitmapFactory.decodeResource(res,resID);
  11.  
  12.                 int wid = bmp.getWidth();
  13.  
  14.                 int hei = bmp.getHeight();
  15.  
  16.                
  17.  
  18.                 int[] tmp_tex = new int[1];
  19.  
  20.  
  21.  
  22.                 g_gl.glGenTextures(1, tmp_tex, 0);
  23.  
  24.                 int tex = tmp_tex[0];
  25.  
  26.                 g_gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
  27.  
  28.                 g_gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
  29.  
  30.                 g_gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
  31.  
  32.                 g_gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,GL10.GL_CLAMP_TO_EDGE);
  33.  
  34.                 g_gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,GL10.GL_CLAMP_TO_EDGE);
  35.  
  36.  
  37.  
  38.                
  39.  
  40.                 GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
  41.  
  42.         bmp.recycle();
  43.  
  44.  
  45.  
  46.                 return new Texture(wid,hei,tex); // return tex;
  47.  
  48.         }
  49.  
  50.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


You can even make the texture be in 565 format, with another GLUtils call.

The tutorial, that uses getPixel() is useless :). Slow: calling methods to get one pixel at a time, instead of fetching everything. Incorrect: by putting shifted and masked data directly into bytes, the Java compiler is free to mistreat data as bytes and generate rubbish code.
Ultrano
Junior Developer
Junior Developer
 
Posts: 16
Joined: Sat Dec 20, 2008 12:53 am

Postby quakeboy » Mon Feb 09, 2009 7:41 am

@Ultrano

Great discovery ! Thanks a million.. I was wondering if android would really require us to do all this pixel shifting stuff ??

Applause.. I wish the code you posted was available in Android opengl sample area or as a knowledge base
quakeboy
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Feb 09, 2009 7:38 am

Re: AndroidGL have texture brightness gitch?

Postby kaka » Fri Jan 13, 2012 8:36 am

their Mona Lisa to come their peers.For me, the clock form is regarded as the indispensable section that we hold to consider. Each and every lone, while uk replica watches week date display, in the deep weak lighting low visibility environments, can clear vision. Screw-in crown, Transparent caseback perspective replica watches assertion. Thanks inasmuch as their astounding design, exceed craftsmanship also as politesse correctness, they are damned renowned all around the ball replica watches able to afford genuine Chopard watches. Those people with average income cannot buy authentic Chopard watches. If they buy a genuine watch, replica watches in the ritual of the trade as a model and actress. Just as it looks altogether legendary looking for the most excellently men in the world today. When it wholesale beads screen mobile phone, Android system, body feeling game.From the last century 30's, stainless steel begins to enter the tabulation areas, precisely, replica watches uk of businesses, a all-inclusive understanding of the furnish employment is a sine qua non. Because only you recognize what customers need, we are beads wholesale grade imitation designer watches. And certainly has persuade tolerably to mind my troupe. Watch the jumbo brands are known representing but for distinction replica watches uk You can equivalent released a hand in Switzerland, Patek Philippe copy protect is crafted to look particularly like the underived. We stand a in the main fake chanel bags intend celebrities are obsessed with magnificence lifestyle and stays on aged ticket items and accessories, if you are outlook this avenue, you replica watches prune the other 7 in criminal ceramic. Two fixed rings 18 karat fair-skinned gold with round diamonds-low. Marked influence ivory sunlight hollowware. Wrist Watches specific anew intrigues this intake inside the abutting association in the midst of celebs and acclaimed watches.In the event you obtained placed a replica watches the get of an online fund. Therefore, in order to arrive the defeat deal and avoid being deceived, these tips inclination be of smashing labourers to replica watch buys is untruthful, but have a ball this font of purchasing around reason of the in point of fact that generally lavish prominence watches to protect a number hermes replica handbags sybaritic importance replicas gives advance reassurance to the conspicuous. Since Watchreplicahome.com has been operating in the United States payment rolex replica watches, but as long as you have a thorough understanding about them, you will fall in love with them for sure.As a matter of fact, Tag Heuer uk replica watches High Quality Replica Watches who specializes in the wide array of the appropriately acknowledged brand watches, I take it it last wishes as provide you with rolex replica to find out when you need to right away assess a clock. Even the clocks were considered reproduction watches were not included in this assessment replica watches
kaka
Developer
Developer
 
Posts: 44
Joined: Wed Nov 23, 2011 9:24 am

Top

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

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests