Multiple canvas support for SWT (we need help!)

We have been working on getting jme2 to be able to display to more than one canvas in SWT.

A simple question:

Is it actually possible?

There is no problem to have several canvas, rendering geometry works without a problem, but as soon as you introduce textures everything gets wild.

Textures disappear or colors blend through to other canvas instances.

I guess JME is simply is not built to support more than one renderer or that one renderer is not capable to render to several individual OpenGL contexts.




Textures are resources, and they have to be explictly shared between contexts when the contexts are created. That is hopefully relativly simple to put in the code where the context for the SWT canvas is created, if it's not there yet…



For example when using LWJGL to set up a regular Display context you can simple use create(PixelFormat pixel_format, Drawable shared_drawable) instead of a regular create(PixelFormat pixel_format)…



I'm not much of an expert on how the SWT contexts are set up though… 

Our main problem are the texures.

Just let me see if I got it right:

Normally a texture gets loaded into texture memory in opengl, you get your id and later on asign the id to the texturing units on the GPU.

When I load textures with the TextureManager they shoudl have their id and be stored in texture memory. The TextureState then takes care during rendering that the ids are asigned to the texturing units.

Is that right?

Uhm I'm sure it is. But each SWT canvas has it's own context, and each context has it's own resources (such as textures), unless they are shared. So that would be step 1 (to check if this is already done in the code).



After that, there might be some state problems… but that would be step 2.

Urgs, didn't read your first post carefully enough.

That clarified a lot. LWJGL doesn't have SWT support for context sharing (there is only an AWT implementation available).

So I guess we are screwed.

Looking (only a bit) at how SWT does OpenGL, it seems like SWT creates the context and then you tell LWJGL to use it… so it's SWT that should add support for sharing.



Didn't look very hard though…

LWJGL has a wrapper for AWT. There is no warpper available for SWT. But I guess htere should be something hidden in the guts of GLCanvas in SWT.

I posted to the SWT newsgroup and I hope to find some answers there.

Thanks for your help  :slight_smile:

?

Does that mention how to tell SWT to share a context?



http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/opengl/GLCanvas.html



I don't see anything there…

I already read through most of the Javadoc but there is no mentioning about sharing a context.

I have been using the GLCanvas now for quite some time and I don't remember having seen anything about it.

So far there is also no answer from the newsgroup.

I looked throught the GLCanvas source code and it doesn't look like as if they have support for a shared context in there.