Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (532)
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  
  How can I use TextureRenderer to render an image to the screen with an alpha ...  (Read 3847 times)
0 Members and 1 Guest are viewing this topic.
Offline a6767

Senior Newbie





« Posted 2007-02-17 19:26:02 »

value. I have rendered jpgs, pngs, etc with alpha=1.0 making this:

mi= TextureRender....
dest=mi.createGraphics();

[...]

mi.beginOrthoRendering(w,h);
dest.drawImage(Img,x,y,java.awt.color.WHITE,null);
mi.sync(0,0,w,h);
mi.drawOrthoRect(0,0);
mi.endOrthoRendering();

.....


Is this well done?

Now, I'm trying to render these lines with GL_BLEND activated , but doesn't work. What's wrong?

Offline Ken Russell

JGO Coder




Java games rock!


« Reply #1 - Posted 2007-02-17 19:41:48 »

Hard to tell without a test case. Make sure you requested an alpha channel in the TextureRenderer and 8 bits of alpha in your GLCapabilities, and that you have the glBlendFunc set up correctly. Take a look at the demos.j2d package in the jogl-demos workspace for some examples of using the TextureRenderer and other helper classes.
Offline a6767

Senior Newbie





« Reply #2 - Posted 2007-02-17 20:09:07 »

Is the code I wrote well done?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #3 - Posted 2007-02-17 21:43:14 »

I don't see anything wrong with it, although so far we have suggested you do all Graphics2D drawing operations and the sync() call before beginOrthoRendering() / draw() / endOrthoRendering().
Offline a6767

Senior Newbie





« Reply #4 - Posted 2007-02-17 22:38:13 »

Thanks Ken. I'll take a look at those demos for the alpha matter. Is any demo specially good for that matter?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #5 - Posted 2007-02-18 04:39:34 »

demos.j2d.TestTextureRenderer is probably the closest to what you're doing.
Offline a6767

Senior Newbie





« Reply #6 - Posted 2007-02-18 09:58:42 »

I've seen it . And I`ve done something like this:

mi = new TextureRenderer
dest=mi.createGraphics();
GL gl=auto.getGL(); //auto is the GLAutoDrawable

dest.drawImage(Img......)
mi.sync(---)
mi.beginOrthoRendering(0,0,auto.getWidth(),auto.getHeight());
gl.glEnable(GL.GL_BLEND);
gl.glColor4f(0.5f,0.5f,0.5f,0.5);
gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE);
mi.drawOrthoRect(0,0);
mi.endOrthoRendering();
gl.glDisable(GL.GL_BLEND);


It is doing more or less what I expected, but varying alfa with gl.glColor4f is doing nothing. And , if I change de blending parameters for GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA) doesn´t work ¿?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #7 - Posted 2007-02-18 13:23:49 »

I see. Internally the TextureRenderer is making a call to gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE). If you make a similar call after beginOrthoRendering() with GL_MODULATE instead of GL_REPLACE that should have the effect you're after. The TextRenderer does this to support its setColor() method, but I hadn't expected that people would generally do this with the TextureRenderer's results. Let me know if you think this should be added to the TextureRenderer's API.
Offline a6767

Senior Newbie





« Reply #8 - Posted 2007-02-18 15:41:54 »

Let me explain  what I'm doing and sorry for my horrible English. I'm trying to do fade effects with videos and pictures over 3D scenes. So I think, I need this feature . I would be grateful if you decide to support Alpha parameter into drawOrthoRect or something so, like in TextRenderer is supported
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #9 - Posted 2007-02-20 05:51:43 »

I've pulled the setColor() methods up to the TextureRenderer class. Please try a nightly build of JOGL dated 2/20 or later and post if you see any problems with the new methods.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline a6767

Senior Newbie





« Reply #10 - Posted 2007-02-20 23:35:10 »

Thanks . I've solved already it looking at the source. The trick was disabling and enabling the depth test because orthorendering is another quad. But thank you very much. I will test it too. I'm very grateful to you and your interest. I think this project is a superproject because the persons which are supporting it.
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.

pw (17 views)
2014-07-24 01:59:36

Riven (17 views)
2014-07-23 21:16:32

Riven (14 views)
2014-07-23 21:07:15

Riven (17 views)
2014-07-23 20:56:16

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

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

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

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

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

Riven (50 views)
2014-07-14 18:02:53
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!