From: Mark M. <pat...@lm...> - 2002-03-01 04:24:16
|
I looked at the GL4Java demos that show how to share a GLContext (share display lists) between two canvases. They use the inheritence method when creating a GLCanvas. In my app I am not using the inheritence method for my GLAnimCanvas. Instead, I am creating the GLAnimCanvas via the GLDrawableFactory, and I am registering a GLEventListener. So, how do I share a GLContext in this paradigm? I'd like to stay with the GLEvenListener, and avoid sub-classing, for several reasons: 1) GL4Java documentation recommends this method 2) The GLDrawableFactory creates the AnimCanvas properly on all platforms (ie, no need to worry about X11 vs Win32 visuals) 3) It would require a lot of changes in my app to abandon the GLEventListener The simple demo program (called MiscDemos\ShardedGLTest.java) just sets the protected member called SharedGLContext in the parent GLCanvas class. But I cannot do this because I am not sub-classing. Furthermore, there is no mutator method (set method) in the GLCanvas class for the SharedGLContext variable. How can I share my GLContext in this scenario? I looked at the constructors for the GLContext class, and I see that one of the constructors takes a sharedContext. But it is not obvious to me how to use this constructor. Which component do I pass into the constructor (the 1st or the 2nd, and BTW shouldn't the type of this argument be GLCanvas and not awt.Component)? More importantly, what do I do with this newly created GLContext? (Since there is NO set method in GLCanvas that would allow me to use this new GLContext). Please help. -Mark "Kenneth B. Russell" wrote: The GLDrawable APIs (largely borrowed from Magician) were added fairly late, so there is still missing functionality like this. The underlying mechanism should be available; GLContext can take a "shared" GLContext in its constructor. There are some demonstrations (all of which depend on subclassing GLCanvas) of this functionality in the demos. > I am porting my application from Magician to GL4Java, and there are some > differences in the two APIs that I am trying to figure out. > Specifically, I was sharing display lists and textures between two > displays (ie, two GLDrawables) in my app. In the old API, I was able to > create my second "GLDrawable" by passing in my first "GLDrawable" as an > argument during creation. This linked the two OpenGL state machines and > allowed the desired sharing. > > Does anyone know the proper way to do this in GL4Java? In the > GLDrawableFactory class, I saw that createGLAnimCanvas() was overloaded > to take the arguments 'glName' and 'gluName', but I don't think that is > what I am looking for, is it? We tried getting the Context from the > first GLDrawable and setting it in the second GLDrawable, but that > caused nothing to be rendered at all. Does anyone have some advice? |