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?
|
|
|
|
|
Ken Russell
|
 |
«
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.
|
|
|
|
|
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!
|
|
Ken Russell
|
 |
«
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().
|
|
|
|
|
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?
|
|
|
|
|
Ken Russell
|
 |
«
Reply #5 - Posted
2007-02-18 04:39:34 » |
|
demos.j2d.TestTextureRenderer is probably the closest to what you're doing.
|
|
|
|
|
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 ¿?
|
|
|
|
|
Ken Russell
|
 |
«
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.
|
|
|
|
|
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
|
|
|
|
|
Ken Russell
|
 |
«
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!
|
|
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.
|
|
|
|
|
|