Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
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  
  3DzzD: Offscreen rendering  (Read 1394 times)
0 Members and 1 Guest are viewing this topic.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Posted 2011-02-14 20:53:47 »

I'm trying to get 3DzzD to render without having a visible display - i've got the following which almost works, but the actual library doesn't want to give me any output:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
public class DzzdAppTest
{

   public static void main(String[] args)
   {
      Toolkit.getDefaultToolkit();
     
      DzzdAppTest app = new DzzdAppTest();
      app.run();
   }
   
   private JFrame frame;
   private OwnCanvas canvas;
   
   
   IRender3D render3d;
   IScene3D scene3d;
   
   
   
   public DzzdAppTest()
   {
      createDzzd();
     
      frame = new JFrame();
      frame.setLayout(new BorderLayout());
     
      canvas = new OwnCanvas();
      canvas.setMinimumSize( new Dimension(200, 200));
      canvas.setPreferredSize( new Dimension(200, 200));
      canvas.setMaximumSize( new Dimension(200, 200));
     
      frame.getContentPane().add(render3d.getCanvas(), BorderLayout.NORTH);
      frame.getContentPane().add(canvas, BorderLayout.CENTER);
     
      frame.setSize(200, 400);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
      render3d.setScreenUpdateEnabled(true);
      render3d.setPixelUpdateEnabled(true);
      render3d.getCanvas().setVisible(true);
      render3d.getCanvas().invalidate();
     
      // This will not render anything
      renderSingleFrame();
     
      frame.pack();
      frame.setVisible(true);
     
      // Now the frame is visible (and the canvas is valid) this will render correctly
      renderSingleFrame();
   }
   
   private void createDzzd()
   {
      // Ask 3DzzD factory for a fresh Scene3D
      this.scene3d = DzzD.newScene3D();  
     
      //Create a Scene3D loader and link it to a 3DS file
      IScene3DLoader loader = DzzD.newScene3DLoader();
      loader.loadScene3D("file:/Users/Orangy/Documents/CodeRepository/Tectonicus/Data/Test/","CUBE.3DS");
     
      // Add the loader to the scene
      this.scene3d.setScene3DLoader(loader);
     
      // Wait until all object & texture are loaded
      while(this.scene3d.getNbMonitoredSceneObject()!=0)
      {
         this.scene3d.updateMonitoredSceneObjects();  
         DzzD.sleep(10);
      }
     
      // Set the active camera in the 3d scene
      this.scene3d.setCurrentCamera3DByName("Camera01");
     
      // Ask 3DzzD factory for a software 3D Render
      this.render3d = DzzD.newRender3D(this.getClass(), "SOFT", null);
     
      // Set the Render3D size and enable maximum antialias
      this.render3d.setSize(200, 200 ,7);
     
      // Set Camera Aspect ratio to 1:1
      this.scene3d.getCurrentCamera3D().setZoomY(((double)this.render3d.getWidth())/((double)this.render3d.getHeight()));  
     
      // Tell the Render3D wich camera it should use to render
      this.render3d.setCamera3D(this.scene3d.getCurrentCamera3D());
   }
   
   public void run()
   {
      Canvas c = new Canvas();
      Graphics g = c.getGraphics();
      System.out.println(g);
   }
   
   public void renderSingleFrame()
   {
      //Set the scene to world space
      this.scene3d.setScene3DObjectToWorld();
     
      //Set the scene to active camera space
      this.scene3d.setScene3DObjectToCamera();
     
      //Tell the 3D render to compute & draw the frame
      this.render3d.renderScene3D(this.scene3d);
   }
   
   private class OwnCanvas extends Canvas
   {
      private static final long serialVersionUID = 1L;

      @Override
      public void paint(Graphics g)
      {
         super.paint(g);
         
         g.setColor(Color.green);
         g.fillRect(0, 0, 200, 200);
         
         render3d.getCanvas().paint(g);
      }
   }
}


I've been poking around the source but unfortunately can't seem to spot anything obvious. Does anyone have any hints as to how to fix this? (Dzzd? You around?)

Thanks.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2011-02-14 20:58:51 »

Actually, this modification seems to fix things:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
   public final void drawPixelsOnCanvas(Canvas canvas)
   {
      Graphics g=canvas.getGraphics();
     
      if(this.useMIS)      
         this.imageMemoire.newPixels();

      // pulled this out of the g!=null test
      ((Render2D.PCanvas)canvas).image=this.image;                  
     
      if(g!=null)
      {
         canvas.update(g);
      }
   }

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline DzzD
« Reply #2 - Posted 2011-02-14 21:31:55 »

I never experienced with offlscrren rendering but maybe  try this one to disable screen update :
Quote
yourRender.setScreenUpdateEnabled(false);

then you will probably have to add a method in Render3D that return the rendered pixel as an int array and/or the Image object result

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.

trollwarrior1 (34 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!