Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Overlays/Interface Panels - best way?  (Read 2626 times)
0 Members and 1 Guest are viewing this topic.
Offline Breakfast

Senior Member




for great justice!


« Posted 2005-01-21 14:13:35 »

Apologies for cross-post with the J3D-INTEREST mailing list, but I got no responses there and I could use some advice on this.

Following on from my question on updateable textures, I have managed to sort that part out but I don't really know what to do next.

Currently I have got some planes with dynamically updated textures attached as platformgeometry on my viewplatform. That works fine but I'm not sure a) how to move forward and b) whether this is the best way of doing things at all.

If I am continuing with this approach what is the best way to texture more extensive components- the square texture thing is an obvious limitation - if I have a rectangular shape should I be creating several small textures to match it as closely as I can (and if so, do I have to create a separate plane for each texture?) or should I be creating a single larger texture and fitting it using texture coordinates?

Alternatively, am I completely barking up the wrong tree by using geometry in the scene when there is some really clever way of getting around this altogether?

I know there are a few libraries to do this type of thing but I'm trying to better myself by understanding how it all works...
Offline Mike Jacobs

Junior Member





« Reply #1 - Posted 2005-01-22 00:13:10 »

Breakfast, By updating the texture on the platform geometry what effect are you after?  Are you creating a dashboard of sorts?

The (power of 2) square texture limitation is a pain.  The next version of OpenGL no longer has that limitation so maybe we should see if J3D 1.4 could include that support.  I have taken the approach of fitting the desired texture in the smallest possible power of 2 size and adjusting the texture coordinates.  While I have not tried it, the texture unit support allows you to apply multiple textures with different texture coordinates.  You might be able to save some memory depending on the shape of the texture.

Mike

Special Effects for Java 3D games: http://www.indietechnologies.com
Offline Breakfast

Senior Member




for great justice!


« Reply #2 - Posted 2005-01-22 18:24:54 »

That's it- the typical user status monitor stuff- you have 50% health and this way is north. I just really couldn't tell whether one big texture on one piece of geometry or lots of smaller textures on lots of smaller bits of geometry would be better and then when I was searching the Java-3d archives for more on this I was finding people talking about writing directly to the raster (or something like that- once you get into the close detail of graphics programming I get a bit lost) and I was wondering if that might be a better way to work.

I guess the best way to find out is to try both and do a bit of testing on them to see what is more efficient...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mike Jacobs

Junior Member





« Reply #3 - Posted 2005-01-22 22:38:40 »

Breakfast, You might want to have a look at using javax.media.j3d.J3DGraphics2D (drawAndFlushImage method).  I haven't used it but may be an option for you.

Mike

Special Effects for Java 3D games: http://www.indietechnologies.com
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #4 - Posted 2005-03-11 10:53:27 »

Hi

Drawing using the J3DGraphics2D is very slow. I had this same issue my self and went down the drawing onto planes with dynamic textures. The code is still around in the Early access libraries section on the newdawn website, but it's not been looked at or touched for some time. If nothing else it might be a usefull reference

HTH

Endolf

Offline bmyers

Junior Member





« Reply #5 - Posted 2005-03-29 19:52:17 »

I have just gone through the same exercise, since the J3DGraphics2D performance was supposed to have improved with Java3D 1.3.2.

However, I have found that, while better, it is still nowhere near the performance of using textures attached to the viewport.  Here's some performance results that I found, using a fairly simple scene capped at 60 fps, with a WakeupOnElapsedFrames(0) to force rendering every frame, using J3DGraphics2D vs. textures.

I tried one approach using a separate BufferedImage for each overlay, and called drawAndFlush() for each one, and another approach where I used one combined BufferedImage with one drawAndFlush() operation.

0) No overlays:  60 fps
1) J3DGraphics2D, Java3D 1.3.1, using separate BufferedImages: 1-2 fps
2) J3DGraphics2D, java3D 1.3.2, using separate BufferedImages: 5-6 fps
3) J3DGraphics2D, using combined BufferedImage for all overlays: 4-5 fps
4) j3d.org.Overlay library, with separate translucent Overlays: 56-57 fps

I have not tried using one texture for all of the overlays, since I was convinced after step 3 that textures was the way to go.

I believe I read somewhere (on j3d.org?) that the reason using textures is so much faster is because of the video architecture -- the 3D scene gets rendered on the video card, then J3DGraphics2D pulls the entire scene over the bus into main memory, then you draw on it, then you send the updated screen image back to the video card.  If you are using textures then the whole thing is done on the card and you only incur the extra overhead when updating the textures.  So static textures are the fastest.  And drawing Swing-like visual updates as you move the mouse around is the slowest.  Also, texture size makes a huge difference, possibly O(n^2)?

Offline misterX

Junior Member




java forever!


« Reply #6 - Posted 2005-03-30 18:21:04 »

it's a long time ago but i tried the same, using J3DGraphics2D. And the framerates dropped from 100 to 40 or so. It's a big lost but not as drastic as your experience. (I used j3d dx version on win)

Offline mokopa

Senior Newbie





« Reply #7 - Posted 2005-07-12 09:08:53 »

I have had much success with the extension of Canvas3D, overriding postRender(). I have also solved the flickering issue. Using this method my (complex scene) fps drops from 45 without overlay to about 40+-3 with overlay, behaviors and timers, and my very un-optimized drawing code does a lot of scaling calculations:

class DrawOnCanvas3D extends Canvas3D
{
    private J3DGraphics2D j3dg2d;
    private int width = 512, height = width;
    private BufferedImage bufim;
    private Graphics2D g2d;

    public DrawOnCanvas3D(GraphicsConfiguration gc)
    {
        super(gc);
        bufim = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
        g2d = bufim.createGraphics();
        j3dg2d = this.getGraphics2D();
    }

    public void postRender()
    {
        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
        g2d.fillRect(0,0,width,height);
        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
        g2d.setColor(Color.WHITE);

  /*---->
         g2d.drawingStuffHappensHere(...)
  <----*/

        j3dg2d.drawAndFlushImage(bufim, 0, 0, this);
    }
}
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (3 views)
2014-07-29 12:53:52

Dwinin (7 views)
2014-07-29 10:59:34

E.R. Fleming (20 views)
2014-07-29 03:07:13

E.R. Fleming (8 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (51 views)
2014-07-17 23:47:54
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!