| Computers Forum Index » Computer - Graphics - API (Opengl) » transparent texture... |
|
Page 1 of 1 |
|
| 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(); |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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. |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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. |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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+_]". |
|
|
| Back to top |
|
|
|
| Michael... |
Posted: Sun Nov 01, 2009 9:32 pm |
|
|
|
Guest
|
|
| Back to top |
|
|
|
|