From: Pepijn V. E. <pep...@lu...> - 2003-05-11 10:10:06
|
I've been trying to come up with a clean mechanism to handle extensions in OpenGL. The current solution is to throw all methods and tokens (core OpenGL and extensions) into one big class. This leaves you with a class that has many methods that simply do nothing. I'm hoping we can do better than this. The best solution I've been able to come up with is the following: - We keep the GLFunc class but it only contains the core OpenGL functions and tokens - For each extension we provide a class that contais the necessary methods and tokens. This extension class can then be loaded if a user needs it. I've made a dummy example for the vertex program extension (not 100% correct, but it's a good illustration. If this is the way to go it might be a good idea to do the same loading type mechanism for the core functions as well, for consistency's sake. You're application would then be responsible for creating an instance of GL, GLU, and any other extension objects and maintaining them. This would have to be done in the init method, because the GLContext object must already have been created. Example: private GL gl; private GLU glu; private ARBVertexProgram vertProg; public void init(GLDrawable gld) { GLContext context = gld.getContext(); gl = GL.createNewInstance(context); glu = GLU.createNewInstance(context); vertProg = ARBVertexProgram.loadExtension(context); } I would love to here some other ideas and feedback about this. Pepijn P.S. Maybe we should move our development discussions to the devel list... Alex: sorry I ended up playing Metroid Prime all night. Damn Nintendo :) |