Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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  
  YATQ - Yet Another Texture Question  (Read 808 times)
0 Members and 1 Guest are viewing this topic.
Offline MickeyB

Senior Member




my game will work, my game will work!


« Posted 2005-01-25 16:24:28 »

I am having the same problem that dsellars had on antoher thread.  I have png's that have black background.  I have set black as my clear color and the backgrounds are completely gone (what I want) but the image is transparent.

I am using the testure loader form LWJGL examples with the following line:
1  
BufferedImage tex = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_4BYTE_ABGR);


Anything other that that type_4byte_abgr or type_3byte_bgr will cause the following line to error out with a clas cast exception at the following line:
1  
byte data[] = (byte[]) tex.getRaster().getDataElements(0, 0, tex.getWidth(), tex.getHeight(), null);


my code for transparency is as follows and i have tried with with and without the commented code:
1  
2  
3  
4  
5  
6  
7  
            if(isTransparent()) {
                  GL11.glEnable(GL11.GL_BLEND);                                // Set up blending for transparency
                 //GL11.glDisable(GL11.GL_DEPTH_TEST);
             GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE);  // Blending Function For Translucency Based On Source Alpha Value
             //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
           }


regardless of changes, to have solid images, I must have solid backgrounds.
where is my clubieness at its highest?
M

EDIT: one note...if I use Fireworks and use a transparent canvas and use GL11.GL_ONE_MINUS_SRC_ALPHA it does what it should, but is this best practice?

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline dsellars

Junior Member




Need to write more games


« Reply #1 - Posted 2005-01-26 08:17:29 »

I got my stuff working in the end (I think as I've not got back to it to play with properly).

I used a modified version of the DevIL code in nehe lesson06 to load the image. (modified to load the alpa chanel)

I used the values that Cas suggested and it worked.  The only thing i can think of is that when I created my png's I created then with a transparent background.

I would have thought that having a black background on the texture will mean it gets drawn.

hth,

Dan.  
Offline MickeyB

Senior Member




my game will work, my game will work!


« Reply #2 - Posted 2005-01-26 15:44:40 »

Thanks.  I am in the middle of converting all the canvas backgrounds to transparent.   Wink

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline dsellars

Junior Member




Need to write more games


« Reply #3 - Posted 2005-01-27 07:05:24 »

Did you try it with just one sprite to see if it worked first? Grin

Dan.
Offline MickeyB

Senior Member




my game will work, my game will work!


« Reply #4 - Posted 2005-01-27 16:16:45 »

Canvases to transparent does the trick...seeems good enough for now.   Wink

Now back to picking!

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
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.

ctomni231 (34 views)
2014-07-18 06:55:21

Zero Volt (30 views)
2014-07-17 23:47:54

danieldean (25 views)
2014-07-17 23:41:23

MustardPeter (27 views)
2014-07-16 23:30:00

Cero (42 views)
2014-07-16 00:42:17

Riven (44 views)
2014-07-14 18:02:53

OpenGLShaders (33 views)
2014-07-14 16:23:47

Riven (34 views)
2014-07-14 11:51:35

quew8 (30 views)
2014-07-13 13:57:52

SHC (66 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!