Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (121)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Masking with PNG  (Read 1191 times)
0 Members and 1 Guest are viewing this topic.
Offline psiegel

Junior Duke




Adamant about gaming.


« Posted 2003-04-25 23:12:31 »

I've been looking at converting my app from Graphics2D to LWJGL, learning OpenGL as I go.  I've run into a problem that I was hoping there might be a quick and dirty solution to.

I've been using PNG files for my sprites, using the alpha channel for simple bit-mask transparency (a bit of overkill, I know).  So I've only used alpha values of 0 and 255.  

Now, when I try and use these same graphics as textures, I get a sort of weird transparency when two images overlap, rather than the clean bit-masking I'm used to.  I've looked through NeHe's tutorials, and his solution is to use separate 2-bit mask files. I'd really hate to have to create 2-bit masks for all my graphics, especially when they have perfectly good alpha channels.  

Is there a quick fix for this?  Some combination of arguments passed to gl.blendFunc() that I haven't tried yet?  I've been attempting gl.blendFunc(GL.SRC_ALPHA, GL.ONE) and gl.blendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA).  The former gives me the odd transparency I've mentioned, the latter no transparency whatsoever.

I hope to go grab myself a copy of the red book this weekend, as NeHe's tutorials, while good, are just not enough.  Perhaps someone has some insights to save me a bit of time though?

Paul Siegel
Adamant Games, Inc.
http://www.adamantgames.com
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #1 - Posted 2003-04-26 01:11:15 »

Have you tried gl.enable(GL.ALPHA_TEST)? Blending only makes an image tranlucent.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline psiegel

Junior Duke




Adamant about gaming.


« Reply #2 - Posted 2003-04-26 03:54:33 »

Switching from BLEND to ALPHA_TEST was definately a great idea.  Thanks.  

However, when that didn't work, I continued to bang my head against it until I realized there was something very odd in my call to gl.texImage2D().  I had copied the code from an example (straight from lwjgl's cvs!) that had the third parameter of that method a hard coded 3.  I don't even know which constant 3 is, but clearly it wasn't GL.RGBA, which is what I wanted there.

Ah, not that that's fixed, I can get into the serious work of transitioning this code.  Thanks for pointer!

Paul Siegel
Adamant Games, Inc.
http://www.adamantgames.com
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #3 - Posted 2003-04-26 05:17:27 »

Oh yeah. That one.

Oh, Cas!!! Can you guys fix that one in future revisions before any more LWJGL newbies have trouble with this? Just use GIMP to convert the images to RGBA, then change the code to use a reasonable GL.RGBA instead of the 3. Everyone thinks the 3 is some sort of hardcoded value that can't be changed. To be perfectly honest, I can't even figure out what "3" is even supposed to represent. (scratches head)  Huh

Java Game Console Project
Last Journal Entry: 12/17/04
Offline princec

JGO Kernel


Medals: 409
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2003-04-26 06:54:21 »

"3" means "RGB" in OpenGL1.0
The constants 1, 2, 3, and 4 were replaced by named constants in 1.1. Using a 4 would have worked in this case.

Cas Smiley

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (20 views)
2014-10-25 15:46:29

Longarmx (53 views)
2014-10-17 03:59:02

Norakomi (47 views)
2014-10-16 15:22:06

Norakomi (35 views)
2014-10-16 15:20:20

lcass (39 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (69 views)
2014-10-14 00:35:47

TehJavaDev (61 views)
2014-10-14 00:32:37

BurntPizza (74 views)
2014-10-11 23:24:42

BurntPizza (46 views)
2014-10-11 23:10:45
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!