Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  How can I use TextureRenderer to render an image to the screen with an alpha ...  (Read 2424 times)
0 Members and 1 Guest are viewing this topic.
Offline a6767

JGO n00b
*

Posts: 39



« on: 2007-02-17 13: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 Kernel
*****

Posts: 3446
Medals: 3


Java games rock!


« Reply #1 on: 2007-02-17 13: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

JGO n00b
*

Posts: 39



« Reply #2 on: 2007-02-17 14:09:07 »

Is the code I wrote well done?
Games published by our own members! Go get 'em!
Offline Ken Russell

JGO Kernel
*****

Posts: 3446
Medals: 3


Java games rock!


« Reply #3 on: 2007-02-17 15: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

JGO n00b
*

Posts: 39



« Reply #4 on: 2007-02-17 16: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 Kernel
*****

Posts: 3446
Medals: 3


Java games rock!


« Reply #5 on: 2007-02-17 22:39:34 »

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

JGO n00b
*

Posts: 39



« Reply #6 on: 2007-02-18 03: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 Kernel
*****

Posts: 3446
Medals: 3


Java games rock!


« Reply #7 on: 2007-02-18 07: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

JGO n00b
*

Posts: 39



« Reply #8 on: 2007-02-18 09: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 Kernel
*****

Posts: 3446
Medals: 3


Java games rock!


« Reply #9 on: 2007-02-19 23: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! Go get 'em!
Offline a6767

JGO n00b
*

Posts: 39



« Reply #10 on: 2007-02-20 17: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]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.184 seconds with 21 queries.