www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AGP on December 27, 2011, 06:50:21 am

Title: Overlay Behind Nearly Everything With Software Renderer
Post by: AGP 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);
     }
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: EgonOlsen on December 27, 2011, 08:53:38 am
Strange...do you have a screen shot and maybe a test case?
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: AGP 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:
(http://www.agpgames.com/SupermanInSoftware.png)
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: EgonOlsen 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!?
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: AGP 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.
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: EgonOlsen 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?
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: AGP 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.
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: EgonOlsen on December 27, 2011, 10:45:45 pm
Yes, please do that. Something must be different from my test cases... ???
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: AGP 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.
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: EgonOlsen 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.
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: AGP 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.
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: AGP 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)?
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: AGP on December 31, 2011, 04:23:16 pm
I take it that's a "no." But shouldn't there be?
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: EgonOlsen 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.
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: AGP 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?
Title: Re: Overlay Behind Nearly Everything With Software Renderer
Post by: EgonOlsen on January 04, 2012, 09:03:07 pm
No, that's not possible, because you can't use a graphics context to draw into a texture lying something in the GPU's memory. All you can do is to upload it again. And the fastest way to do this ATM is to use an ITextureEffect, but that's not really fast either.