How can I use TextureRenderer to render an image to the screen with an alpha ...

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?

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.

Is the code I wrote well done?

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().

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

demos.j2d.TestTextureRenderer is probably the closest to what you’re doing.

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 ¿?

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.

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

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.

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.