Author Topic: Transparency Revisited  (Read 2548 times)

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Transparency Revisited
« on: September 05, 2012, 01:37:29 am »
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.


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Transparency Revisited
« Reply #1 on: September 05, 2012, 08:33:13 am »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Transparency Revisited
« Reply #2 on: September 05, 2012, 10:16:02 am »
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.


Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Transparency Revisited
« Reply #3 on: September 05, 2012, 10:42:32 am »
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!).

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Transparency Revisited
« Reply #4 on: September 05, 2012, 08:21:48 pm »
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:

Code: [Select]
     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());
     }

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Transparency Revisited
« Reply #5 on: September 05, 2012, 09:05:25 pm »
Scaled blitting in the software renderer uses an Overlay internally. Maybe that doesn't work right (anymore). I'll take a look...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Transparency Revisited
« Reply #6 on: September 05, 2012, 09:23:46 pm »
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?

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Transparency Revisited
« Reply #7 on: September 05, 2012, 09:40:33 pm »
Isn't OpenGL default, now? I'm not setting it to legacy.

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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Transparency Revisited
« Reply #8 on: September 05, 2012, 09:42:36 pm »
Yes openGL mode is default. There's no additonal enableRenderer call in your code?

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Transparency Revisited
« Reply #9 on: September 05, 2012, 09:46:18 pm »
No.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Transparency Revisited
« Reply #10 on: September 05, 2012, 09:48:30 pm »
Can you please post the complete log output!?

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Transparency Revisited
« Reply #11 on: September 05, 2012, 10:10:11 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Transparency Revisited
« Reply #12 on: September 05, 2012, 10:25:12 pm »
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?
« Last Edit: September 05, 2012, 10:39:47 pm by EgonOlsen »

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Transparency Revisited
« Reply #13 on: September 05, 2012, 11:12:35 pm »
They blit the FrameBuffer individually. Not drawing them doesn't change anything. Using 1.25.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Transparency Revisited
« Reply #14 on: September 06, 2012, 07:06:23 am »
I need some test case then. It works fine for me, i can't reproduce this.