Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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  
  Handling multiple opengl displays in a SWT application  (Read 5679 times)
0 Members and 1 Guest are viewing this topic.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Posted 2008-11-12 18:45:30 »

So you may or may not have seen my <a href="http://www.java-gaming.org/topics/analog-the-freeform-map-editor-v0-5/17441/view.html">map editor</a>, which is working nicely now but unfortuately doesn't seem to work on macs.

The snag seems to be drawing the map areas. Those screenshots don't show it, but there can be multiple maps open at a time, possibly open next to each other (ie. multiple visible at the same time). Currently what I do is use Slick + LWJGL to share a single opengl context, then actual display that via multiple AWT Canvas objects (via LWJGL's Display.setParent()), which in turn are embedded in a SWT Composite via SWT's "awt bridge". This is pretty ugly but on windows it actually works well.

Unfortunately the swt/awt bridge doesn't seem to be properly implemented on non-windows platforms, and on OS X it's Just Plain Broken (tm). I'd really like to get it working there, so I'm looking for ways around this.

All I'm after is multiple visible canvases which I can draw onto via OpenGL. I don't care whether the underlying components are SWT or AWT, I don't care if it's via LWGJL, Jogl or org.eclipse.swt.opengl, and I don't care if it uses one context or multiple contexts.

Possible workarounds I'm thinking about:
1. Switch to org.eclipse.swt.opengl and use one <a href="http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/opengl/GLCanvas.html">GLCanvas</a> per view. That'll give multiple opengl contexts though, so I'll have to load in each image multiple times (once for each view) so the memory usage would be sky high.

2. As for 1, but with some kind of caching for textures so they get loaded and unloaded on demand (but still duplicated across contexts) to try and keep memory usage reasonable. Would probably hurt performance though.

3. Somehow create a single off-screen opengl context and do all texture loading and rendering to this. Copy the final pixel data to a non-opengl swt canvas to display multiple views at the same time.

4. Something else?

Anyone any other suggestions or ideas?

Cheers

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

JGO Knight


Medals: 32



« Reply #1 - Posted 2008-11-13 01:33:31 »

I don't know how Slick works, but on semi-new macs (intel based, nvidia 8600+) I've been able to create and share contexts between multiple JOGL GLCanvas's and PBuffers.  It's pretty easy to say whether or not to share (just pass the shared context into the constructor), but the support isn't guaranteed on all platforms and doesn't always let you know, either. 

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #2 - Posted 2008-11-18 10:03:26 »

I don't know how Slick works, but on semi-new macs (intel based, nvidia 8600+) I've been able to create and share contexts between multiple JOGL GLCanvas's and PBuffers.  It's pretty easy to say whether or not to share (just pass the shared context into the constructor), but the support isn't guaranteed on all platforms and doesn't always let you know, either. 
This is largely what I'm currently doing with LWJGL and Slick (sharing a single context between multiple canvases). The problem is that to embed the LWJGL canvas within the SWT app I've got to use the AWT<->SWT bridge, which doesn't appear to work on mac. Switching to Jogl wouldn't help as I'd still have to use the bridge to embed Jogl's AWT canvas.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lhkbob

JGO Knight


Medals: 32



« Reply #3 - Posted 2008-11-23 06:33:46 »

What is your rendering scheme?  Do you only render when necessary? or is it a continuous update type deal.  I would think that if it's the first case and because it's an editor, performance is not such a big issue so you could get away with #3.

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #4 - Posted 2008-11-30 11:44:38 »

What is your rendering scheme?  Do you only render when necessary? or is it a continuous update type deal.  I would think that if it's the first case and because it's an editor, performance is not such a big issue so you could get away with #3.
It's event driven, so yes it should be only when necessary. The one thing I worry about with approach 3 is that it'll make scrolling and dragging less responsive (possibly to the point of being unusable?). I guess I should probably do a quick prototype and see what the performance is like.

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

JGO Knight


Medals: 32



« Reply #5 - Posted 2008-12-02 16:20:03 »

Well good luck, let me know how things play out.

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #6 - Posted 2012-02-24 12:25:50 »

Thread necromancy!

I never was able to fix this at the time, but now I'm looking into writing another swt/rcp editor and looking into the same problem, and google pointed me right back at my original problem. Smiley

Things have moved on a little, and now there's a proper swt gl canvas. Interestingly in the GLData init object it's got a param for an existing canvas so it can share the context. This looks like it was added in the Galileo release when the swt/osx end was overhauled to better support cocoa.

With a bit of luck this will do exactly what I was trying to do originally...

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
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.

rwatson462 (36 views)
2014-12-15 00:26:44

Mr.CodeIt (29 views)
2014-12-14 10:50:38

BurntPizza (61 views)
2014-12-09 13:41:13

BurntPizza (98 views)
2014-12-07 19:46:31

JscottyBieshaar (58 views)
2014-12-05 03:39:02

SHC (74 views)
2014-12-03 07:27:13

CopyableCougar4 (76 views)
2014-11-29 12:32:03

toopeicgaming1999 (137 views)
2014-11-26 06:22:04

toopeicgaming1999 (127 views)
2014-11-26 06:20:36

toopeicgaming1999 (37 views)
2014-11-26 06:20:08
Resources for WIP games
by kpars
2014-12-18 01:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 13:35:00

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

List of Learning Resources
by Longor1996
2014-08-16 01:40:00

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

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

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

List of Learning Resources
by SilverTiger
2014-07-31 07:29:50
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!