sharing gl textures(SWT)

How can i enable texture sharing, in swt with jogl

Not sure if I understand the question… but yeah, so long as you can reference the texture ID, you can share the texture.
As for enabling it, isn’t this sort of thing always on?

I have multiple viewports, so i need to share the context and drawable between them i think, but don’t know how

here a screenshot

http://home.hccnet.nl/pj.holverda/notextures.jpg only the first viewport has texturing(where i create my texture with glgentextures)

i can figure out one ‘solution’’ right now and that is to give each glcontext it’s own texturemanager, but this is a waste of mony

Ah, I think I’m starting to understand what you’re getting at. You want the same textures to be available to both viewports?

This is doable, so long as both of your viewports can manage reference the texture you want to draw. Unless I’m mistaken, a texture can be drawn to any context, so long as the context is current. So what you’ll end-up doing is not sharing the context, but rather switching between multiple (2?) contexts, 1 per viewport. This can be easily managed with JOGLs GLContext class.

So imagine, you make 1 texture, in that texturemanager you mentioned. Then 2 contexts, 1 for each viewport. Each context can get at the texture manager and request that same texture. Maybe something like:

Viewport1 Viewport2
| |
Context1 Context2
\ /
TextureManager
|
Texture

Your rendering loop will consist of:

  • enabling the context of the first viewport
  • drawing the texture to the first viewport
  • releasing the context of the first viewport
  • enabling the context of the second viewport
  • drawing the texture to the second viewport
  • releasing the context of the second viewport

i already had that, but i found this on the internet , maybe this is causing it
https://bugs.eclipse.org/bugs/show_bug.cgi?id=136515

Looks like you got me there. What I was speaking was purely theoretical, but it seems that SWTs GLCanvas is bugged for the moment.
In that link though, someone has managed a Windows-only fix if you wish to modify the SWT source.

Maybe you could try adding JOGLs GLCanvas to a SWT Shell instead? SWT has facilities for embedding AWT components into SWT ones. This does mean having to use an AWT event handler though, which isn’t exactly desireable.