Transparency Revisited

Started by AGP, September 05, 2012, 01:37:29 AM

Previous topic - Next topic

AGP

Not having solved the shadow problem yet, I decided to move on to this one. :- ) The following image shows the result of a pressed button not set and set to TRANSPARENCY_MODE_ADD. Obviously, neither is the desired result. I've also tried making the Texture with alpha information (currently, the background is a solic black), but that didn't help either. Please help. Edit: I should mention that these buttons are being blitted onto the FrameBuffer.


EgonOlsen

You have to use an alpha channel and create the texture with appropriate constructor (the one that takes the useAlpha-parameter) and blit it in default mode.

AGP

Thanks a lot, that did it. Now, I'm trying to get blitting to work on the same screen with the software renderer, but the result is as follows. I'm using the FrameBuffer's Graphics object, in this case, to draw the position of my buttons, because the OpenGL-rendered ones seem to be in the wrong place (does the FrameBuffer use a different coordinate system or should I just translate my mouse coordinates by the title bar's height?). Anyway, either way, it's not working in software.


AGP

I should mention that I removed the references to the FrameBuffer's Graphics object to see if it made a difference (did not)  and that the background image is 1024x1024 is 32-bits (which, come to think of it, must be the problem!).

AGP

OK, I converted the image to 8 bits and it still looks like the above screenshot. The following is the code that works for hardware but that hasn't been working for the software renderer:


     public void draw(java.awt.Canvas glCanvas) {
buffer.clear(java.awt.Color.black);
buffer.update();
buffer.blit(background, 0, 0, 0, 0, background.getWidth(), background.getHeight(), buffer.getOutputWidth(), buffer.getOutputHeight(), -1, false);
playButton.draw(buffer);
loadButton.draw(buffer);
introButton.draw(buffer);
quitButton.draw(buffer);
if (buffer.usesRenderer(IRenderer.RENDERER_OPENGL)) {
     buffer.displayGLOnly();
     glCanvas.repaint();
}
else buffer.display(glCanvas.getGraphics());
     }

EgonOlsen

Scaled blitting in the software renderer uses an Overlay internally. Maybe that doesn't work right (anymore). I'll take a look...

EgonOlsen

I made myself a test case blitting a 512*512 texture to a 128*128 quad and one 1024*1024 as a backdrop in 1920*1200...works perfectly fine!? How are you initializing the software renderer? It somehow looks as if you are using the legacy mode instead of opengl. Can you post the part that enables the software renderer?

AGP

Isn't OpenGL default, now? I'm not setting it to legacy.


     buffer = new FrameBuffer((int)(1024*engineData.widthMul +.5d), (int)(768*engineData.heightMul +.5d), FrameBuffer.SAMPLINGMODE_NORMAL);

EgonOlsen

Yes openGL mode is default. There's no additonal enableRenderer call in your code?


EgonOlsen

Can you please post the complete log output!?

AGP

Sure:

Java version is: 1.7.0_01
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Loading Texture...NewLevel\barkA.png
Loading Texture...NewLevel\grassA.png
Loading Texture...NewLevel\grassB.png
Loading Texture...NewLevel\grassC.png
Loading Texture...NewLevel\ground.png
Loading Texture...NewLevel\plantA.png
Loading Texture...NewLevel\plantB.png
Loading Texture...NewLevel\treeHa.png
Loading Texture...NewLevel\treeHb.png
Loading Texture...NewLevel\treeHc.png
Loading Texture...NewLevel\treeHd.png
Loading Texture...Silmaria\arbusto_001.png
Loading Texture...Silmaria\Banco_difuse1_copy.png
Loading Texture...Silmaria\Barco_Porto_001.png
Loading Texture...Silmaria\Barrel_difuse_copy.png
Loading Texture...Silmaria\Canal.png
Loading Texture...Silmaria\Carroτa_Frutas_difuse_copy.png
Loading Texture...Silmaria\CasaPrincipal1_difuse.png
Loading Texture...Silmaria\casa_bandeira_difuse1_copy.png
Loading Texture...Silmaria\casa_tenda_difuse1_copy.png
Loading Texture...Silmaria\DIfuse_Casa1.png
Loading Texture...Silmaria\Difuse_Casa2.png
Loading Texture...Silmaria\difuse_Casa3.png
Loading Texture...Silmaria\Difuse_CasaPrincipal.png
Loading Texture...Silmaria\difuse_condominio_copy.png
Loading Texture...Silmaria\Difuse_muralhaeprops_copy.png
Loading Texture...Silmaria\Difuse_MuralhaPrincipal.png
Loading Texture...Silmaria\Difuse_Muralhas1_2.png
Loading Texture...Silmaria\Difuse_prefeitura1.png
Loading Texture...Silmaria\Difuse_props1copy.png
Loading Texture...Silmaria\Difuse_teatro1_copy.png
Loading Texture...Silmaria\escadaria_dfuse1_copy.png
Loading Texture...Silmaria\folhagem_002.png
Loading Texture...Silmaria\Museu01_difuse_copy.png
Loading Texture...Silmaria\palmeira_001.png
Loading Texture...Silmaria\pedras_001.png
Loading Texture...Silmaria\pinheiro_001.png
Loading Texture...Silmaria\ponte_difuse_copy.png
Loading Texture...Silmaria\rio_001.png
Loading Texture...Silmaria\Solo_001.png
Loading Texture...Silmaria\Solo_002.png
Loading Texture...Silmaria\Solo_003.png
Loading Texture...Silmaria\Solo_004.png
Loading Texture...Silmaria\splash_001.png
Loading Texture...Silmaria\telhadoprincipal_difuse_copy.png
Loading Texture...Silmaria\Templo_difuse_copy.png
Loading Texture...Silmaria\Tenda1_difuse_copy.png
Loading Texture...Silmaria\tonel_difuse_copy.png
Loading Texture...Girl.jpg
Loading Texture...GirlLingerie.jpg
Loading Texture...MaleQGHero.png
Loading Texture...MistressBrown.png
Loading Texture...SunnySky/left.jpg
[ Wed Sep 05 17:12:03 EDT 2012 ] - WARNING: Unsupported Texture width (600)...re
sizing to a width of 256 pixels!
Loading Texture...SunnySky/front.jpg
[ Wed Sep 05 17:12:03 EDT 2012 ] - WARNING: Unsupported Texture width (600)...re
sizing to a width of 256 pixels!
Loading Texture...SunnySky/right.jpg
[ Wed Sep 05 17:12:03 EDT 2012 ] - WARNING: Unsupported Texture width (600)...re
sizing to a width of 256 pixels!
Loading Texture...SunnySky/back.jpg
[ Wed Sep 05 17:12:03 EDT 2012 ] - WARNING: Unsupported Texture width (600)...re
sizing to a width of 256 pixels!
Loading Texture...SunnySky/top.jpg
[ Wed Sep 05 17:12:03 EDT 2012 ] - WARNING: Unsupported Texture width (600)...re
sizing to a width of 256 pixels!
Loading Texture...SunnySky/top.jpg
[ Wed Sep 05 17:12:03 EDT 2012 ] - WARNING: Unsupported Texture width (600)...re
sizing to a width of 256 pixels!
OS Version: Windows 7
Loading Texture...from Image
Loading Texture...playOpening_off.png
Loading Texture...playOpening_on.png
Loading Texture...load_off.png
Loading Texture...load_on.png
Loading Texture...introduction_off.png
Loading Texture...introduction_on.png
Loading Texture...quit_off.png
Loading Texture...quit_on.png
New WorldProcessor created using 1 thread(s) and granularity of 1!
Creating new world processor buffer for thread main
Loading Texture...from Image
Wrapping input stream in a BufferedInputStream
Loading Texture...from Image
Loading Texture...from Image
Loading Texture...from Image
Loading Texture...from Image
Loading Texture...from Image
Loading Texture...import_off.png
Loading Texture...import_on.png
Loading Texture...cancel_off.png
Loading Texture...cancel_on.png
Loading Texture...play_off.png
Loading Texture...play_on.png
Visibility lists disposed!
Software renderer disposed

EgonOlsen

#12
Looks fine. What are these xxxButton.draw()-methods doing? Does it change something if you remove them and only blit the background? Which version of jPCT are you using? The latest official release?

AGP

They blit the FrameBuffer individually. Not drawing them doesn't change anything. Using 1.25.

EgonOlsen

I need some test case then. It works fine for me, i can't reproduce this.