Java-Gaming.org
Java4K - to go         Javadoc:
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources or peek at the official java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Explicitly creating context for GLJPanel  (Read 672 times)
0 Members and 1 Guest are viewing this topic.
Offline utku

JGO n00b
*

Posts: 2



« on: 2009-02-14 01:29:15 »

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
Offline bienator

JGO Ninja
***

Posts: 632
Medals: 1


OutOfCoffeeException


« Reply #1 on: 2009-02-14 07:43:21 »

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:

1  
2  
3  
4  
GLPBuffer sharedPBuffer = GLDrawableFactory.createGLPbuffer(...,1,1, null);

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

Offline utku

JGO n00b
*

Posts: 2



« Reply #2 on: 2009-02-15 00:35:54 »

1  
2  
3  
4  
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 ?
Games published by our own members! Go get 'em!
Offline bienator

JGO Ninja
***

Posts: 632
Medals: 1


OutOfCoffeeException


« Reply #3 on: 2009-02-15 07:48:28 »

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)

Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.132 seconds with 21 queries.