Main Page | Report this Page
Computers Forum Index  »  Computer - Graphics - API (Opengl)  »  transparent texture...
Page 1 of 1    

transparent texture...

Author Message
Michael Sgier...
Posted: Sun Dec 28, 2008 2:44 pm
Guest
HI
I tried that below in vain but how can I show a *.bmp texture file with
transparent regions?
Many thanks and regards
Michael


glColor4f(Red, Green, Blue, 0.75);

glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glPushMatrix();

XPLMBindTexture2d(gTexture[GAUGE_TEXTURE], 0);
glBegin(GL_QUADS);
glTexCoord2f(1, 0.0f); glVertex2f(GaugeRight, GaugeBottom); // Bottom
Right Of The Texture and Quad
glTexCoord2f(0, 0.0f); glVertex2f(GaugeLeft, GaugeBottom); // Bottom
Left Of The Texture and Quad
glTexCoord2f(0, 1.0f); glVertex2f(GaugeLeft, GaugeTop); // Top Left
Of The Texture and Quad
glTexCoord2f(1, 1.0f); glVertex2f(GaugeRight, GaugeTop); // Top Right
Of The Texture and Quad
glEnd();

glPopMatrix();
glFlush();
 
Wolfgang Draxinger...
Posted: Sun Dec 28, 2008 3:22 pm
Guest
Michael Sgier wrote:

Quote:
HI
I tried that below in vain but how can I show a *.bmp texture
file with transparent regions?

The official BMP specification doesn't include a alpha channel,
(though it would be possible to include one). So just don't use
BMP. Use a file format, which supports an alpha channel. There
are plenty to choose from:

PNG, TGA, OpenEXR

JPEG does not provide an alpha channel.
Wolfgang Draxinger
--
E-Mail address works, Jabber: hexarith at (no spam) jabber.org, ICQ: 134682867
 
fungus...
Posted: Sun Dec 28, 2008 10:40 pm
Guest
On Dec 28, 5:53 pm, Michael Sgier <sg... at (no spam) nospam.com> wrote:
Quote:
Thanks Wolfgang

Would my code work with PNG or would I need to make some changes? (
apart the png loading ) Alpha blending etc.?


You probably want glAlphaFunc() instead of blending.


--
<\___/>
/ O O \
\_____/ FTB.
 
Michael Sgier...
Posted: Sun Dec 28, 2008 10:53 pm
Guest
Thanks Wolfgang

Would my code work with PNG or would I need to make some changes? (
apart the png loading ) Alpha blending etc.?

Michael
 
jbwest...
Posted: Sun Dec 28, 2008 11:18 pm
Guest
"Michael Sgier" <sgier at (no spam) nospam.com> wrote in message
news:d4bea$49573c8e$c299b4bb$31407 at (no spam) news.hispeed.ch...
Quote:
HI
I tried that below in vain but how can I show a *.bmp texture file with
transparent regions?
Many thanks and regards
Michael


glColor4f(Red, Green, Blue, 0.75);

glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glPushMatrix();

XPLMBindTexture2d(gTexture[GAUGE_TEXTURE], 0);
glBegin(GL_QUADS);
glTexCoord2f(1, 0.0f); glVertex2f(GaugeRight, GaugeBottom); // Bottom
Right Of The Texture and Quad
glTexCoord2f(0, 0.0f); glVertex2f(GaugeLeft, GaugeBottom); // Bottom Left
Of The Texture and Quad
glTexCoord2f(0, 1.0f); glVertex2f(GaugeLeft, GaugeTop); // Top Left Of The
Texture and Quad
glTexCoord2f(1, 1.0f); glVertex2f(GaugeRight, GaugeTop); // Top Right Of
The Texture and Quad
glEnd();

glPopMatrix();
glFlush()

Consider the texture envornment & what you want to do:

The default texture environment is GL_MODULATE, which multiplies the
texture color by the primitive (or lighting) color. Most applications that
use both OpenGL lighting and texture mapping use the GL_MODULATE texture
environment.



Look at GL_DECAL to GL_MODULATE, depending on what you want with texture
alpha & quad alpha (and color).



-jbw
 
fungus...
Posted: Mon Dec 29, 2008 12:10 am
Guest
On Dec 28, 11:56 pm, "jbwest" <jbw... at (no spam) acm.org> wrote:
Quote:

You probably want glAlphaFunc() instead of blending.

Well, he is setting the background quad to .75 alpha, so I would assume he
does want blending.


Oh, yes...

Still he might want both. Rejecting pixels is never bad.


--
<\___/>
/ O O \
\_____/ FTB.
 
jbwest...
Posted: Mon Dec 29, 2008 4:56 am
Guest
"fungus" <openglMYSOCKS at (no spam) artlum.com> wrote in message
news:4082a266-bc3e-4ed6-990f-0990dd35297b at (no spam) a12g2000pro.googlegroups.com...
On Dec 28, 5:53 pm, Michael Sgier <sg... at (no spam) nospam.com> wrote:
Quote:
Thanks Wolfgang

Would my code work with PNG or would I need to make some changes? (
apart the png loading ) Alpha blending etc.?


You probably want glAlphaFunc() instead of blending.


--
<\___/>
/ O O \
\_____/ FTB.

Well, he is setting the background quad to .75 alpha, so I would assume he
does want blending.

jbw
 
Michael Sgier...
Posted: Tue Dec 30, 2008 3:44 pm
Guest
So I downloaded libpng for windows but no zlib included not even
mentioned. downloading some zlib header I get errors.

Anyone could send me all the png loading files. This could save me
apparently a lot of time.
bxcvs AT yahoo DOT com
THANKS
 
Wolfgang Draxinger...
Posted: Tue Dec 30, 2008 6:52 pm
Guest
Michael Sgier wrote:

Quote:
So I downloaded libpng for windows but no zlib included not
even mentioned. downloading some zlib header I get errors.

http://openil.sourceforge.net/

Wolfgang Draxinger
--
E-Mail address works, Jabber: hexarith at (no spam) jabber.org, ICQ: 134682867
 
Michael Sgier...
Posted: Tue Dec 30, 2008 6:58 pm
Guest
SDL_loadPNG
....
looks easiest for me? But aargh....any working code for the above?
Thanks
Michael
 
cathy...
Posted: Tue Dec 30, 2008 9:28 pm
Guest
Michael Sgier a écrit :
Quote:
So I downloaded libpng for windows but no zlib included not even
mentioned. downloading some zlib header I get errors.

Anyone could send me all the png loading files. This could save me
apparently a lot of time.
bxcvs AT yahoo DOT com
THANKS

I had problem compiling the zlib with lines "movd mm_,[esp+_]" and
googling gave me the solution: you must add "dword ptr" this way "movd
mm_,dword ptr [esp+_]".
 
Michael...
Posted: Sun Nov 01, 2009 9:32 pm
Guest
Dear Sirs
google finds bxcvs at (no spam) yahoo.com. Please REMOVE all containing this email like:


http://webnews.mt.net.mk/dnewsweb.exe?cmd=article&group=comp.graphics.api.opengl&item=35262&utag=

Many thanks and regards
Michael
 
 
Page 1 of 1    
All times are GMT
The time now is Fri Dec 04, 2009 10:00 pm