Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (498)
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  
  [Q] Multiple JOGL canvases in single application  (Read 3450 times)
0 Members and 1 Guest are viewing this topic.
Offline nicholas_yue

Junior Newbie




Java games rock!


« Posted 2003-09-30 00:05:44 »

Hi,

 Is there an example illustrating the creation and management of multiple JOGL canvases within an application (like those in 3D modeller application with different views e.g. Top, Left, Front, Perspective views)

 How does the multiple canvases interact with the layout manager?

Cheers
--
Nicholas Yue
Offline vprise

Senior Newbie




Java games rock!


« Reply #1 - Posted 2003-11-07 21:42:04 »

Multiple canvases worked fine for me, but the Animator class just overloaded the CPU and caused serious crashes since (I assume) each one of them creates a thread that accesses OpenGL. I wrote my own Animator class to workaround this issue with multiple canvases, its really a copy and paste of the existing Animator that rather than invoke one draw, it invokes several.
Offline schneit

Senior Newbie




I like pie


« Reply #2 - Posted 2003-11-07 23:55:26 »

Beware of adding and removing canvas mutiple times.  We've (a coworker and myself) have discovered several issues surrounding this on Linux.  First, on NVidia, after 15 adds and removes, all you get is a blank canvas that never paints.  It's definitely a driver issue because native glxgears has the same problem after 32 instances.  On radeon based hardware, after 30 adds and removes, the screen freezes and requires a hard reboot.  We tracked this down to an issue of JOGL not deleting it's opengl contexts after they are no longer needed.  We have a fix that allows you to manually free the canvas resources, but probably won't get a chance to post it for a while.  (We've been pretty swamped at work lately)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Malek

Junior Member




Java games rock!


« Reply #3 - Posted 2005-07-14 15:14:42 »

Hi,
Is it possible to post a code example of this?
It is not clear to me how to handle the different display() etc... openGL functions?

Do you create all your GLcanvases in one class or you make one class for each GLcanvas to handle its behaviour?
I would think it has to be done in the second way but if someone can confirm it or tell me if i am wrong it would be nice  Wink
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #4 - Posted 2005-07-14 18:15:20 »

The JOGL demos have examples of how to do this. The JRefract, TestContextDestruction, TestContextSharing and other demos show how to update multiple GLCanvases and GLJPanels.
Offline Malek

Junior Member




Java games rock!


« Reply #5 - Posted 2005-07-15 10:40:35 »

Thx for information  Wink
Offline Malek

Junior Member




Java games rock!


« Reply #6 - Posted 2005-07-19 14:19:27 »

If i am setting many parameters to a GL Objects (like loading many textures "into" it), and then use the command setGL() to another canvas, shouldn't the textures ID be pointing to the right adress for both?

It seems they are not, I am having a Canvas with its GlEventListener, loading the textures into the VRAM and having the textures ID in an array.
Then i call a method on other canvas, passing them the array of ID and the GL object but when drawing in these canvas textures are not applied.

Is it normal or I just do not do it the right way. In Jrefract exemples the seem to clone directly the GL object but it sounds quite a rude operation no?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #7 - Posted 2005-07-19 16:29:33 »

The setGL() method is only used to install composable pipelines like the DebugGL and TraceGL. The GL object does not encapsulate texture state or anything else and it is illegal to put one GLDrawable's GL object into another. The JRefract demo does not clone GL objects. If you need to share textures and display lists between GLCanvases then you need to specify the "shareWIth" parameter when creating them.
Offline Malek

Junior Member




Java games rock!


« Reply #8 - Posted 2005-07-19 16:52:46 »

Sounds like i am really distracted these days  Roll Eyes

thanks anyway to show me the correct way
Offline Malek

Junior Member




Java games rock!


« Reply #9 - Posted 2005-07-20 18:34:18 »

Hi

I would have another question, textures and display list are shared but what about the VBOs?

It seems my app is quite unhappy when i try to draw from a VBO on a GL object that is shared. I mean by that, that it severly crashes complaining about an Illegal access made by the method DrawArray() not an exception but an error launched from JVM. I do not have the output here but i will add it as soon as i am back on the machine where it happened.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Malek

Junior Member




Java games rock!


« Reply #10 - Posted 2005-07-23 22:52:19 »

Here it is below attached as txt file

By the way i have noticed something strange.
In my main frame i create one GLJPanel in which i make the main display and later i create other GLJPanel "shared" with the main one to display others parts in new frame. The buildings display correctly in these latter frame but not in the main.

Has you can seen on the pictures below, on one (prob2.jpg) building appear with its chemney correctly but not on the other (prob.jpg) , but it is the same building created the same way. The chemney is drawn through a display list, and the same problem arise with all other parts of buildings being drawn from display lists (meaning that on the frames it is ok but not on the main frame)

So i guess the problem is the same as the VBOs which work fine in the small frames but not in the main one as the crash below show.

Is it a known problem?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #11 - Posted 2005-07-25 18:47:32 »

I would guess you are trying to make OpenGL calls from outside your GLEventListener's callbacks. With JOGL it is only valid to make OpenGL calls from inside your GLEventListener's init(), display(), etc. methods, or other methods called by those. The only way to legally perform sharing of OpenGL data is to pass in a GLDrawable "shareWith" parameter when creating your GLCanvas or GLJPanel and then use the shared texture and other IDs between the two drawables. See the TestContextSharing sample in the jogl-demos workspace for a simple example.
Offline Malek

Junior Member




Java games rock!


« Reply #12 - Posted 2005-07-26 10:29:24 »

I see, this one was kind of tricky, i was drawing the building from inside the GLeventlistener callback but was creating it from the response of a MouseListener callback.
I changed it and now everyone is happy  Smiley

Thanks a lot  Wink
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 (26 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (193 views)
2014-04-01 02:16:10
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

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