From: Markus R. <rol...@us...> - 2007-02-10 16:17:33
|
Update of /cvsroot/simspark/simspark/spark/kerosin/openglserver In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv21404 Modified Files: Tag: WIN32 openglserver.cpp openglserver.h Log Message: - remove dependency from OpenGLServer on auto generated gl extension reg. Currently only one extension is used (glActiveTextureARB). For this extension a static method is provided Index: openglserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/openglserver/openglserver.cpp,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** openglserver.cpp 5 Dec 2005 21:38:23 -0000 1.1 --- openglserver.cpp 10 Feb 2007 16:17:28 -0000 1.1.2.1 *************** *** 48,53 **** using namespace zeitgeist; ! OpenGLServer::OpenGLServer() : Leaf(), mExtensionReg(new GLExtensionReg()), ! mWantsToQuit(false), mHolder( new MapHolder() ) { } --- 48,52 ---- using namespace zeitgeist; ! OpenGLServer::OpenGLServer() : Leaf(), mWantsToQuit(false), mHolder( new MapHolder() ) { } *************** *** 57,65 **** } - boost::shared_ptr<GLExtensionReg> OpenGLServer::GetExtensionReg() const - { - return mExtensionReg; - } - void OpenGLServer::Quit() { --- 56,59 ---- *************** *** 155,176 **** unsigned int OpenGLServer::LoadARBVertexProgram(const char* fileName) { ! // only try to load stuff if the extension is supported ! if (!mExtensionReg->Has_GL_ARB_vertex_program()) ! { ! return 0; ! } ! ! return LoadARBProgram(GL_VERTEX_PROGRAM_ARB, fileName); } unsigned int OpenGLServer::LoadARBFragmentProgram(const char* /*fileName*/) { - // only try to load stuff if the extension is supported - // if (!mExtensionReg->Has_GL_ARB_fragment_program()) - // { - // return 0; - // } - - // return LoadARBProgram(GL_FRAGMENT_PROGRAM_ARB, fileName); return 0; } --- 149,157 ---- unsigned int OpenGLServer::LoadARBVertexProgram(const char* fileName) { ! return 0; } unsigned int OpenGLServer::LoadARBFragmentProgram(const char* /*fileName*/) { return 0; } *************** *** 203,212 **** } - mExtensionReg->Init(); - - // if (!mExtensionReg->Has_GL_ARB_vertex_program() || !mExtensionReg->Has_GL_ARB_fragment_program()) - // { - // GetLog()->Normal() << "WARNING: GL_ARB_vertex_program not supported. " - // << "disabling fancy lighting\n" << endl; mSupportsFancyLighting = false; --- 184,187 ---- *************** *** 258,260 **** --- 233,257 ---- } + void* OpenGLServer::GetExtension(const char* name) + { + #ifdef WIN32 + return wglGetProcAddress(name); + #else + return glXGetProcAddressARB((unsigned char*)name); + #endif + } + #define PROC_ADDRESS(_ptr, _function)\ + static _ptr proc = (_ptr) GetExtension(#_function); + + void OpenGLServer::glActiveTextureARB(GLenum texture) + { + PROC_ADDRESS(PFNGLACTIVETEXTUREARBPROC, "glActiveTextureARB"); + + if (! proc) + { + return; + } + + (proc)(texture); + } Index: openglserver.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/openglserver/openglserver.h,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** openglserver.h 5 Dec 2005 21:38:23 -0000 1.1 --- openglserver.h 10 Feb 2007 16:17:28 -0000 1.1.2.1 *************** *** 27,31 **** #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> ! #include "glextensionreg.h" namespace kerosin --- 27,47 ---- #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> ! ! #define GL_GLEXT_PROTOTYPES ! ! #ifdef WIN32 ! #define WIN32_LEAN_AND_MEAN 1 ! #include <windows.h> ! #endif ! ! #include <GL/gl.h> ! #include <GL/glext.h> ! ! #if defined(WIN32) ! #include <GL/wglext.h> ! #else ! #include <GL/glx.h> ! #include <GL/glxext.h> ! #endif namespace kerosin *************** *** 68,73 **** bool Init(const std::string& openGLSysName); - boost::shared_ptr<GLExtensionReg> GetExtensionReg() const; - //! if this is called, the application will 'want to quit' void Quit(); --- 84,87 ---- *************** *** 102,105 **** --- 116,125 ---- void PutLight(int l); + /** returns the address of an OpenGL extension by name */ + static void* GetExtension(const char* name); + + /** looksup and calls glActiveTextureARB extension if available */ + static void glActiveTextureARB(GLenum texture); + protected: //! set up opengl viewport *************** *** 110,116 **** // protected: - //! this contains information on all available extensions - boost::shared_ptr<GLExtensionReg> mExtensionReg; - //! a flag, which can be used to control the shutdown of the display window and the application bool mWantsToQuit; --- 130,133 ---- |