Author Topic: Overlay Behind Nearly Everything With Software Renderer  (Read 2485 times)

Offline AGP

  • quad
  • ******
  • Posts: 1620
    • View Profile
Overlay Behind Nearly Everything With Software Renderer
« on: December 27, 2011, 06:50:21 am »
It's pretty much only in front of the skybox. I'm creating the Overlay as follows.

Code: [Select]
     public void createOverlay(World theWorld, FrameBuffer buffer) {
BufferedImage radarMap = new BufferedImage(targetWidth, targetHeight+5, BufferedImage.TYPE_INT_RGB);
radarMap.getGraphics().drawImage(borders, 0, 5, null);
radarMap.getGraphics().drawImage(logo, targetWidth/2-logo.getWidth(null)/2, 0, null);
Texture radarTexture = new Texture(radarMap);
TextureManager.getInstance().addTexture("SuperRadar", radarTexture);
Overlay over = new Overlay(theWorld, buffer, "SuperRadar");
over.setNewCoordinates(540, 40, 540+targetWidth, 40+targetHeight);
over.setDepth(Config.nearPlane);//THIS WASN'T HERE. I ADDED IT TO TEST WHETHER IT FIXED FOR SOFTWARE (IT DIDN'T)
over.setTransparency(100);
     }

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11985
    • View Profile
    • http://www.jpct.net
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #1 on: December 27, 2011, 08:53:38 am »
Strange...do you have a screen shot and maybe a test case?

Offline AGP

  • quad
  • ******
  • Posts: 1620
    • View Profile
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #2 on: December 27, 2011, 06:45:50 pm »
Unless it's related to the scale of my models (I doubt it), a test case would be as simple as creating an Overlay with the code I posted. Here's a screenshot:

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11985
    • View Profile
    • http://www.jpct.net
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #3 on: December 27, 2011, 08:09:18 pm »
Which instance of world did you use the create the Overlay? Not the one of the sky box, i hope!?

Offline AGP

  • quad
  • ******
  • Posts: 1620
    • View Profile
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #4 on: December 27, 2011, 08:21:23 pm »
No, until a couple of days ago I wasn't even aware that the Skybox had its own World.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11985
    • View Profile
    • http://www.jpct.net
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #5 on: December 27, 2011, 08:28:43 pm »
I can't verify this problem. Everything works fine for me except that

Code: [Select]
over.setDepth(Config.nearPlane);
isn't a good idea because it places the overlay on the clipping plane, which means that it might get clipped or not, depending on some inaccuracies. Better is


Code: [Select]
over.setDepth(Config.nearPlane+1);
which is default anyway.

Are you applying a sort offset?

Offline AGP

  • quad
  • ******
  • Posts: 1620
    • View Profile
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #6 on: December 27, 2011, 09:48:29 pm »
No. I guess I'll send you my Metropolis with a stripped-down version of the game so you could verify it.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11985
    • View Profile
    • http://www.jpct.net
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #7 on: December 27, 2011, 10:45:45 pm »
Yes, please do that. Something must be different from my test cases... ???

Offline AGP

  • quad
  • ******
  • Posts: 1620
    • View Profile
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #8 on: December 28, 2011, 05:15:45 am »
Just e-mailed it to you. Sorry that I didn't chop it any more than I did, but it's already at a small fraction of its size. It should be a good enough test case.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11985
    • View Profile
    • http://www.jpct.net
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #9 on: December 28, 2011, 09:02:58 pm »
I had a look at it...what you have in your screen shot there is no Overlay. It's the result of a call to the draw()-method of your Radar-class, which you do right after rendering the sky box. In the software path in your test case, you don't even call the createOverlay()-method. If you do (and omit the call to Radar.draw()), you'll get the overlay at the right position and in  front of everything else.

Offline AGP

  • quad
  • ******
  • Posts: 1620
    • View Profile
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #10 on: December 29, 2011, 12:01:54 am »
Jesus, really? That code is quite a while old, but I tend to trust myself. Maybe I shouldn't. :- ) Anyway, thanks for noticing it.

Offline AGP

  • quad
  • ******
  • Posts: 1620
    • View Profile
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #11 on: December 29, 2011, 03:21:40 am »
OK, I see why I was calling draw(...): it has to be called in order to draw the position of the enemies on the radar. I just should've called createOverlay(...) outside of the if (hardRender) bit (and shouldn't draw the radar's borders on draw(...) although the borders as drawn by draw(...) do look better than the Overlay in software mode).

So is there a way for me to draw the enemies on the Overlay in such a way as for them to not be hidden by the buildings? Do I have to keep creating a Texture (that seems WAY too slow)?

Offline AGP

  • quad
  • ******
  • Posts: 1620
    • View Profile
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #12 on: December 31, 2011, 04:23:16 pm »
I take it that's a "no." But shouldn't there be?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11985
    • View Profile
    • http://www.jpct.net
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #13 on: December 31, 2011, 04:55:55 pm »
orry...i forgot to answer this... :-\ I suggest to display the enemies as seperate blits. Just like the car example does it for its basic radar.

Offline AGP

  • quad
  • ******
  • Posts: 1620
    • View Profile
Re: Overlay Behind Nearly Everything With Software Renderer
« Reply #14 on: January 04, 2012, 06:09:52 pm »
Thanks, I will look into it. But is it impossible to create a Texture.getGraphics()? If so, why? And if not, why not make one?