Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  How to draw directly to Canvas3D  (Read 1347 times)
0 Members and 1 Guest are viewing this topic.
Offline chumDS

Senior Newbie





« Posted 2007-04-28 20:34:35 »

I want to draw text to my screen, AFTER the rendering is done.

I see that Canvas3D inherits from awt.Canvas, so I thought maybe I'd override paint(), postRender() or postSwap(), but none of those seemed to do what I want.

"Back in the day", when I was using JOGL, I'd complete my render, then go into glOrtho2D mode, then draw text onto the screen there, then do my GL-swap.  I'm ok with doing that in J3D, except I don't know how to interrupt the pipeline to do that.

Or I can just draw on the cavas, if there's a way to do that.

What I was trying that didn't work:

1  
2  
3  
4  
5  
6  
7  
   public   void   paint (Graphics gr)
   {
      super.paint (gr);

      gr.setColor (Color.white);
      gr.drawString ("Foo", 50, 50);
   }


(Tried similar things with postRender() & postSwap(), too -- except I had to call getGraphics().)

No text shows up on my screen.

Help?  Hints?  Snippets?

Thanks!

Now, with even MORE Java!
Offline chumDS

Senior Newbie





« Reply #1 - Posted 2007-04-28 21:29:57 »

To follow up, I found A way (Google!), but it's sub-optimal.  Basically, I've got:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
(My canvas class...)
   private      J3DGraphics2D   j3dgr   = null;

   public   void   postRender ()
   {
//*      super.postRender ();
     drawText();
   }


    private void drawText()
   {
      if (j3dgr == null)
         j3dgr = getGraphics2D();

      j3dgr.setColor(Color.WHITE);
      j3dgr.drawString ("foo", 10, 10);
      j3dgr.flush (true);
    }


Which works display-wise, but completely destroys my frame-rate.  (The slow part seems to be the flush().)

So my new & improved question is: how do I do this in a reasonable amount of time?

Now, with even MORE Java!
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #2 - Posted 2007-05-08 07:56:40 »

I don't have a good answer. Just that creating 2D overlays with Java3D is difficult. The postRender approach is know to destroy performance. So the only way seems to be to do the 2D stuff in 3D as well.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
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.

Dwinin (21 views)
2014-09-12 09:08:26

Norakomi (55 views)
2014-09-10 13:57:51

TehJavaDev (66 views)
2014-09-10 06:39:09

Tekkerue (33 views)
2014-09-09 02:24:56

mitcheeb (54 views)
2014-09-08 06:06:29

BurntPizza (38 views)
2014-09-07 01:13:42

Longarmx (24 views)
2014-09-07 01:12:14

Longarmx (30 views)
2014-09-07 01:11:22

Longarmx (28 views)
2014-09-07 01:10:19

mitcheeb (37 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!