From: Kenneth B. R. <kbr...@al...> - 2002-03-04 08:12:58
|
> 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? As mentioned in my earlier message, it will be necessary to add code to the library to implement this. You can check out the latest source code via CVS; see http://sourceforge.net/projects/gl4java/ . We'll gladly incorporate changes you make into the source base. (I'm personally busy with JavaOne preparations and can't do this work at the moment.) > 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). Look at GLCanvas.java, in particular the paint() method where the GLContext is instantiated. This, combined with the SharedGLTest demo, should give you an idea of the proper instantiation of GLContext objects. It shouldn't be too difficult to add the necessary constructors to GLCanvas, GLAnimCanvas, GLJPanel, and GLJAnimPanel to take the shared context as an argument instead of requiring the classes to be subclassed in order to set it. Then the GLDrawableFactory can be extended with additional methods taking a GLContext with which to share textures and display lists. > "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? > > --Boundary_(ID_UghF3EvwTtxuxRiWRwukeg) > Content-type: text/html; charset=us-ascii > Content-transfer-encoding: 7BIT > > <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> > <html> > 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? > <p>I'd like to stay with the GLEvenListener, and avoid sub-classing, for > several reasons: > <br>1) GL4Java documentation recommends this method > <br>2) The GLDrawableFactory creates the AnimCanvas properly on all platforms > (ie, no need to worry about X11 vs Win32 visuals) > <br>3) It would require a lot of changes in my app to abandon the GLEventListener > <p>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? > <p>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). > <p>Please help. > <br>-Mark > <br> > <p>"Kenneth B. Russell" wrote: > <p>The GLDrawable APIs (largely borrowed from Magician) were added > <br>fairly late, so there is still missing functionality like this. > <p>The underlying mechanism should be available; GLContext can take > <br>a "shared" GLContext in its constructor. There are some > <br>demonstrations (all of which depend on subclassing GLCanvas) of > <br>this functionality in the demos. > <blockquote>> I am porting my application from Magician to GL4Java, and > there are some > <br>> differences in the two APIs that I am trying to figure out. > <br>> Specifically, I was sharing display lists and textures between two > <br>> displays (ie, two GLDrawables) in my app. In the old API, I was able > to > <br>> create my second "GLDrawable" by passing in my first "GLDrawable" > as an > <br>> argument during creation. This linked the two OpenGL state machines > and > <br>> allowed the desired sharing. > <br>> > <br>> Does anyone know the proper way to do this in GL4Java? In the > <br>> GLDrawableFactory class, I saw that createGLAnimCanvas() was overloaded > <br>> to take the arguments 'glName' and 'gluName', but I don't think that > is > <br>> what I am looking for, is it? We tried getting the Context from the > <br>> first GLDrawable and setting it in the second GLDrawable, but that > <br>> caused nothing to be rendered at all. Does anyone have some advice?</blockquote> > </html> > > --Boundary_(ID_UghF3EvwTtxuxRiWRwukeg)-- > > _______________________________________________ > gl4java-usergroup mailing list > gl4...@li... > https://lists.sourceforge.net/lists/listinfo/gl4java-usergroup |