Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  2 glCanvas in a JFrame  (Read 1628 times)
0 Members and 1 Guest are viewing this topic.
Offline Bobza

Senior Newbie





« Posted 2011-01-26 16:46:02 »

Hi all,

I built a JFrame containing 2 glCanvases.
I linked each canvas with a different renderer, implementing the GLEventListener interface. Each renderer has its own Animator.

It doesn't work : rendering is weird. It looks like parts of rendering are past to the other glCanvas.

Any ideas ? is this GLContext or multi-threading issue ?

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  
/* Generated with neatbeans */
public class SelectorDialog extends javax.swing.JDialog {
....

    private GLCanvas canvas1;
    private GLCanvas canvas2;

    public GLCanvas getCanvas1() {
        return canvas1;
    }

    public GLCanvas getCanvas2() {
        return canvas2;
    }

}

public View1 implements GLEventListener {
...
}

public View2 implements GLEventListener {
...
}

public class MySelector extends Selector {

public MySelector() {

   GLCanvas canvas1 = getCanvas1();
   canvas1.setAutoSwapBufferMode(true);

   View1 view1 = new View1();
   canvas1.addGLEventListener(view1);
     
        FPSAnimator animator = new FPSAnimator( canvas1 , 60 );
        animator.setRunAsFastAsPossible(false);
        animator.start();
       
        GLCanvas canvas2 = getCanvas2();
        canvas2.setAutoSwapBufferMode(true);

   View2 view2 = new View2();
   canvas2.addGLEventListener(view2);
     
        FPSAnimator animator2 = new FPSAnimator( canvas2, 60 );
        animator2.setRunAsFastAsPossible(false);
        animator2.start();
       
        setVisible(true);
}

}


Offline gouessej

« In padded room »



TUER


« Reply #1 - Posted 2011-01-26 19:43:53 »

Which version of JOGL do you use? Have you tried to do the same thing with NEWT?

Offline lhkbob

JGO Knight


Medals: 32



« Reply #2 - Posted 2011-01-27 03:20:07 »

If you're using GLEventListeners it shouldn't be a multi-threading issue, the two canvases would just take turns.  It's likely that the two GLCanvases are being laid out incorrectly (and then overlapping heavy-weight components == bad) or the implementation of GLCanvas assumes that it can take over the entire window when it's rendering (but I don't know).

Can you post the actual code that adds the canvases to your JDialog? I'll give it a shot on my computer.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bobjob

JGO Knight


Medals: 10
Projects: 6


David Aaron Muhar


« Reply #3 - Posted 2011-01-27 05:24:04 »

do you need to use 2 canvas's? Why not just use multiple view ports?

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline Bobza

Senior Newbie





« Reply #4 - Posted 2011-01-27 12:35:49 »

Thanks all for your replies (and sorry for my approximate english writing)

It looks ok now ; my renderers were wrong and not dealing properly shared datas ; no troubles with multi-threading or so ! The code in my first post is ok. I'm sorry for making you waste your time.

I saw a previous thread on the same kind of trouble ; it was said in it to use a single animator for many canvases, and to deactivate autoSwapBuffering.
By the way, my GUI works with autoSwapBuffering enabled and with 2 animators, but that was an interesting way to explore.
However, I dont really understand the behaviour of all this. Where could I find some ressources on the subject ? How buffer swaping works or should work in a multi canvases context ?


do you need to use 2 canvas's? Why not just use multiple view ports?
I worked and thought on such a solution. However technics are much more complicated (i'm quite a beginner using opengl and dont want to go to far in it for now). And in my case, the idea was to create a GUI that mixes 3d rendering and other swing components (buttons, trees ... ) so that i dont have to re-create a 3d JTree-like component. I searched for a kind of jogl GUI "library", but couldn't find one.

Another question I cant find no response is about the "theory and technics" on the popup windows and dialogs in games.
Let's take Minecraft for example ; when you open the main menu, or the "material" menu : how does it work ? I guess he doesnt use a JFrame or JDialog ... Does he render the menu or dialog in a texture and rendering this texture over the main scene ? But with non modal dialogs how should this work ?

Thanks in advance
Offline gouessej

« In padded room »



TUER


« Reply #5 - Posted 2011-01-27 19:00:41 »

Don't disable auto swap buffer mode if you use JOGL 2.0 beta as it hugely increases the memory consumption.

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.

xsi3rr4x (64 views)
2014-04-15 18:08:23

BurntPizza (62 views)
2014-04-15 03:46:01

UprightPath (75 views)
2014-04-14 17:39:50

UprightPath (58 views)
2014-04-14 17:35:47

Porlus (76 views)
2014-04-14 15:48:38

tom_mai78101 (101 views)
2014-04-10 04:04:31

BurntPizza (161 views)
2014-04-08 23:06:04

tom_mai78101 (256 views)
2014-04-05 13:34:39

trollwarrior1 (209 views)
2014-04-04 12:06:45

CJLetsGame (216 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!