Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
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 3536 times)
0 Members and 1 Guest are viewing this topic.
Offline Breakfast

Senior Devvie

for great justice!

« Posted 2005-01-21 13: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 Devvie

« Reply #1 - Posted 2005-01-21 23: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.


Special Effects for Java 3D games:
Offline Breakfast

Senior Devvie

for great justice!

« Reply #2 - Posted 2005-01-22 17: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 Devvie

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

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


Special Effects for Java 3D games:
Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

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


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



Offline bmyers

Junior Devvie

« Reply #5 - Posted 2005-03-29 17: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) 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 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 Devvie

java forever!

« Reply #6 - Posted 2005-03-30 16: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 07: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)
        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.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));


        j3dg2d.drawAndFlushImage(bufim, 0, 0, this);
Pages: [1]
  ignore  |  Print  

DesertCoockie (20 views)
2018-05-13 18:23:11

nelsongames (68 views)
2018-04-24 18:15:36

nelsongames (65 views)
2018-04-24 18:14:32

ivj94 (749 views)
2018-03-24 14:47:39

ivj94 (79 views)
2018-03-24 14:46:31

ivj94 (595 views)
2018-03-24 14:43:53

Solater (95 views)
2018-03-17 05:04:08

nelsongames (168 views)
2018-03-05 17:56:34

Gornova (378 views)
2018-03-02 22:15:33

buddyBro (1038 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!