JavaGaming.org

July 30, 2010, 09:44:52 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
Advanced search  
Pages: [1]   Go Down
Print
Author Topic: Explicitly creating context for GLJPanel  (Read 318 times)
0 Members and 1 Guest are viewing this topic.
utku
JGO n00b
*
Offline Offline

Posts: 2


View Profile
« on: February 13, 2009, 10:29:15 pm »

Hello,

I am writing a swing applet which needs multiple GLJPanel instances sharing a single context. But after creating GLJPanel I can not use getContext method to access the GLContext instance being used due to null pointer exception. It seems like the context creating is being done after component gets visible. Even my attempts to use invokeLater to get context after component creation events are processed failed also. Even it is possible, it does not seem like an elegant way to get context after creating the first GLJPanel instance and create other panels later.

I tried GLDrawableFactory.getFactory().createExternalGLContext() to create a context but it fails with: 
javax.media.opengl.GLException: Error: attempted to make an external GLContext without a drawable/context current.

Is there a way to explicitly create GL context that can be used by GLJPanel instances ?

regards
« Last Edit: February 13, 2009, 10:33:38 pm by utku » Logged
bienator
JGO Ninja
*****
Offline Offline

Gender: Male
Posts: 613


OutOfCoffeeException


View Profile WWW
« Reply #1 on: February 14, 2009, 04:43:21 am »

Yes thats true, GLJPanel and GLCanvas delay context creation until they are visible (on windows).

To get a shared context for all of your components you could use a GLPBuffer and pass it as shared context to your components:

Code:
GLPBuffer sharedPBuffer = GLDrawableFactory.createGLPbuffer(...,1,1, null);

new GLJPanel(...,sharedPBuffer.getContext());
new GLCanvas(...,sharedPBuffer.getContext());
Logged

utku
JGO n00b
*
Offline Offline

Posts: 2


View Profile
« Reply #2 on: February 14, 2009, 09:35:54 pm »

Code:
GLPBuffer sharedPBuffer = GLDrawableFactory.createGLPbuffer(...,1,1, null);

new GLJPanel(...,sharedPBuffer.getContext());
new GLCanvas(...,sharedPBuffer.getContext());

Thanks a lot, it worked. I have passed a new GLCapabilities instance, Should I assume this uses the same fallback mechanism normally GLJPanel uses, line non-hardware support etc. to be chosen if needed ?
Logged
bienator
JGO Ninja
*****
Offline Offline

Gender: Male
Posts: 613


OutOfCoffeeException


View Profile WWW
« Reply #3 on: February 15, 2009, 04:48:28 am »

GLJPanel uses pbuffers internally too. This means you should check if your hardware has pbuffer support anyway.

I am not aware of a GLJPanel software fallback mode. The last time i used GLJPanels they where just created with the capabilities i passed in but this may have changed. I usually use the GLCanvas so i haven't much experience with GLJPanels.

(btw i guess you need the shared context to share things like display lists, textures or vbos, if yes it probably doesn't matter what capabilities you pass to the shared buffer context since you don't use it for rendering)
Logged

Pages: [1]   Go Up
Print
 
Jump to: