[android-developers] Re: Transparent textures in OpenGL ES.. How?

2010-06-21 Thread Nightwolf
Part of my texture loading code looks like this:

final Bitmap bitmap =
BitmapFactory.decodeResource(context.getResources(), resId);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
bitmap.recycle();

Following lines should be somewhere in initialization:

// Blending Function For Translucency Based On Source Alpha Value
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
gl.glEnable(GL10.GL_BLEND);


On Jun 21, 9:30 pm, Navigateur  wrote:
> I got it working! The right data order is ARGB, but it just wasn't
> accepting my original data for some reason (even though the data is
> fine)... so by writing it, pixel by pixel, to a new Bitmap.. it works
> (that's why RGBA version was treating the "A" as "B") Can anyone tell
> me why I have to write a new Bitmap (it's a waste of processing). Does
> the Bitmap have to be "mutable" or something?
>
> On Jun 21, 6:13 pm, Navigateur  wrote:
>
>
>
> > Correction: if I use the original ARGB format of the .png without
> > converting it to RGBA, it doesn't work at all. (But with RGBA it has
> > the problem as stated).
>
> > On Jun 21, 5:30 pm, Navigateur  wrote:
>
> > > I should add, maybe GL10's glTexImage2D is the way to go here but I
> > > can't get that working at all. Maybe I have the pixel buffer pixels in
> > > the wrong order, since I use Bitmap's copyPixelsToBuffer to create the
> > > pixels buffer (what's the correct ordering for pixels in this buffer)?
> > > Or is GLUtils.texImage2D is the best one to call?
>
> > > On Jun 21, 4:57 pm, Navigateur  wrote:
>
> > > > I can't seem to get GLUtils.texImage2D to use my full RGBA (A=my alpha
> > > > component). I've tried doing setEGLConfigChooser(8, 8, 8, 8, 0, 0);
> > > > getHolder().setFormat(PixelFormat.RGBA_);
>
> > > > I've tried converting the source image (.png in ARGB) to RGBA.. which
> > > > works ok for the ordering of data before texImage2D, but when it
> > > > draws, it draws yellow where it should be "transparent white"... which
> > > > suggests it's diminishing the "B"(blue) component instead of the
> > > > A(alpha) component. But the same thing happens when I just use the
> > > > orignal ARGB data instead ("B" diminishes instead of "A", leaving
> > > > yellow). I have no idea why but I'll keep trying, but has anybody done
> > > > this properly and has the answer?- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Transparent textures in OpenGL ES.. How?

2010-06-21 Thread Navigateur
I got it working! The right data order is ARGB, but it just wasn't
accepting my original data for some reason (even though the data is
fine)... so by writing it, pixel by pixel, to a new Bitmap.. it works
(that's why RGBA version was treating the "A" as "B") Can anyone tell
me why I have to write a new Bitmap (it's a waste of processing). Does
the Bitmap have to be "mutable" or something?

On Jun 21, 6:13 pm, Navigateur  wrote:
> Correction: if I use the original ARGB format of the .png without
> converting it to RGBA, it doesn't work at all. (But with RGBA it has
> the problem as stated).
>
> On Jun 21, 5:30 pm, Navigateur  wrote:
>
>
>
> > I should add, maybe GL10's glTexImage2D is the way to go here but I
> > can't get that working at all. Maybe I have the pixel buffer pixels in
> > the wrong order, since I use Bitmap's copyPixelsToBuffer to create the
> > pixels buffer (what's the correct ordering for pixels in this buffer)?
> > Or is GLUtils.texImage2D is the best one to call?
>
> > On Jun 21, 4:57 pm, Navigateur  wrote:
>
> > > I can't seem to get GLUtils.texImage2D to use my full RGBA (A=my alpha
> > > component). I've tried doing setEGLConfigChooser(8, 8, 8, 8, 0, 0);
> > > getHolder().setFormat(PixelFormat.RGBA_);
>
> > > I've tried converting the source image (.png in ARGB) to RGBA.. which
> > > works ok for the ordering of data before texImage2D, but when it
> > > draws, it draws yellow where it should be "transparent white"... which
> > > suggests it's diminishing the "B"(blue) component instead of the
> > > A(alpha) component. But the same thing happens when I just use the
> > > orignal ARGB data instead ("B" diminishes instead of "A", leaving
> > > yellow). I have no idea why but I'll keep trying, but has anybody done
> > > this properly and has the answer?- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Transparent textures in OpenGL ES.. How?

2010-06-21 Thread Navigateur
Correction: if I use the original ARGB format of the .png without
converting it to RGBA, it doesn't work at all. (But with RGBA it has
the problem as stated).

On Jun 21, 5:30 pm, Navigateur  wrote:
> I should add, maybe GL10's glTexImage2D is the way to go here but I
> can't get that working at all. Maybe I have the pixel buffer pixels in
> the wrong order, since I use Bitmap's copyPixelsToBuffer to create the
> pixels buffer (what's the correct ordering for pixels in this buffer)?
> Or is GLUtils.texImage2D is the best one to call?
>
> On Jun 21, 4:57 pm, Navigateur  wrote:
>
>
>
> > I can't seem to get GLUtils.texImage2D to use my full RGBA (A=my alpha
> > component). I've tried doing setEGLConfigChooser(8, 8, 8, 8, 0, 0);
> > getHolder().setFormat(PixelFormat.RGBA_);
>
> > I've tried converting the source image (.png in ARGB) to RGBA.. which
> > works ok for the ordering of data before texImage2D, but when it
> > draws, it draws yellow where it should be "transparent white"... which
> > suggests it's diminishing the "B"(blue) component instead of the
> > A(alpha) component. But the same thing happens when I just use the
> > orignal ARGB data instead ("B" diminishes instead of "A", leaving
> > yellow). I have no idea why but I'll keep trying, but has anybody done
> > this properly and has the answer?- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Transparent textures in OpenGL ES.. How?

2010-06-21 Thread Navigateur
I should add, maybe GL10's glTexImage2D is the way to go here but I
can't get that working at all. Maybe I have the pixel buffer pixels in
the wrong order, since I use Bitmap's copyPixelsToBuffer to create the
pixels buffer (what's the correct ordering for pixels in this buffer)?
Or is GLUtils.texImage2D is the best one to call?

On Jun 21, 4:57 pm, Navigateur  wrote:
> I can't seem to get GLUtils.texImage2D to use my full RGBA (A=my alpha
> component). I've tried doing setEGLConfigChooser(8, 8, 8, 8, 0, 0);
> getHolder().setFormat(PixelFormat.RGBA_);
>
> I've tried converting the source image (.png in ARGB) to RGBA.. which
> works ok for the ordering of data before texImage2D, but when it
> draws, it draws yellow where it should be "transparent white"... which
> suggests it's diminishing the "B"(blue) component instead of the
> A(alpha) component. But the same thing happens when I just use the
> orignal ARGB data instead ("B" diminishes instead of "A", leaving
> yellow). I have no idea why but I'll keep trying, but has anybody done
> this properly and has the answer?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: transparent textures...

2009-02-15 Thread Jon Colverson

On Feb 15, 2:23 pm, petunio  wrote:
> Hi all
> I am using opengl for drawing 3d stuff, but so far I've been unable to
> use transparent textures...

You need at least:
gl.glEnable(GL10.GL_BLEND);

and probably also:
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
GL10.GL_REPLACE);

--
Jon

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Transparent textures in OpenGL

2008-12-29 Thread Tomei Ningen
Did you use  GL10.GL_MODULATE?

    gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
 //GL10.GL_REPLACE
 GL10.GL_MODULATE
 );

I had the same problem before and it's fixed after making the above change.


--- On Mon, 12/29/08, Chris McCurdy  wrote:
From: Chris McCurdy 
Subject: [android-developers] Transparent textures in OpenGL
To: "Android Developers" 
Date: Monday, December 29, 2008, 7:34 AM

I'm currently attempting to make a game using OpenGL and all is well
in the emulator. I'm using PNGs with transparencies to create the
textures, and in the emulator, they show up as expected. But when I
run it on the G1, all transparent areas show up as black.

I've seen some reports that I need to change the texture from ARGB to
RGBA, but that made my image really small and gave me 4 of the same
image (like it separated each color of the texture into its own
image). I've also seen a suggestion to disable GL_LIGHTING, but that
didn't help either. Is there anything I can do to actually get
transparencies to show up as transparent on the G1?




  
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---