Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

transparent texture

4 views
Skip to first unread message

Michael Sgier

unread,
Dec 28, 2008, 3:44:02 AM12/28/08
to
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

unread,
Dec 28, 2008, 4:22:10 AM12/28/08
to
Michael Sgier wrote:

> 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: hexa...@jabber.org, ICQ: 134682867

Michael Sgier

unread,
Dec 28, 2008, 11:53:54 AM12/28/08
to
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

unread,
Dec 28, 2008, 12:18:57 PM12/28/08
to

"Michael Sgier" <sg...@nospam.com> wrote in message
news:d4bea$49573c8e$c299b4bb$31...@news.hispeed.ch...

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

unread,
Dec 28, 2008, 5:40:40 PM12/28/08
to

You probably want glAlphaFunc() instead of blending.


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

jbwest

unread,
Dec 28, 2008, 5:56:12 PM12/28/08
to

"fungus" <opengl...@artlum.com> wrote in message
news:4082a266-bc3e-4ed6...@a12g2000pro.googlegroups.com...

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

jbw


fungus

unread,
Dec 28, 2008, 7:10:55 PM12/28/08
to
On Dec 28, 11:56 pm, "jbwest" <jbw...@acm.org> wrote:
>
> >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.

Michael Sgier

unread,
Dec 30, 2008, 4:44:19 AM12/30/08
to
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

unread,
Dec 30, 2008, 7:52:19 AM12/30/08
to
Michael Sgier wrote:

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

http://openil.sourceforge.net/

Michael Sgier

unread,
Dec 30, 2008, 7:58:10 AM12/30/08
to
SDL_loadPNG
...
looks easiest for me? But aargh....any working code for the above?
Thanks
Michael

cathy

unread,
Dec 30, 2008, 10:28:56 AM12/30/08
to
Michael Sgier a écrit :

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

unread,
Nov 1, 2009, 11:32:19 AM11/1/09
to
0 new messages