Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

setupgl_win32.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: setupgl_win32.cpp,v 1.2 2001/02/19 14:57:01 sphair Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00015 #include "Core/precomp.h"
00016 #include <windows.h>
00017 #include "Core/System/Win32/init_win32.h"
00018 #include "API/GL/setupgl.h"
00019 #include "displaycard_opengl_win32.h"
00020 #include "API/Core/System/cl_assert.h"
00021 
00022 class CL_OpenGL_Initializer : public CL_Win32EventListener
00023 {
00024 public:
00025         CL_OpenGL_Initializer();
00026         ~CL_OpenGL_Initializer();
00027         virtual bool received_event(UINT uMsg, WPARAM wParam, LPARAM lParam);
00028 };
00029 
00030 // ------------------------------------------------------------------------
00031 
00032 CL_OpenGL_Initializer *opengl_initializer = NULL;
00033 
00034 void CL_SetupGL::init()
00035 {
00036         opengl_initializer = new CL_OpenGL_Initializer;
00037 }
00038 
00039 void CL_SetupGL::deinit()
00040 {
00041         delete opengl_initializer;
00042         opengl_initializer = NULL;
00043 }
00044 
00045 // ------------------------------------------------------------------------
00046 
00047 extern bool global_uses_opengl;
00048 extern void (*opengl_init_function)();
00049 
00050 CL_OpenGL_Initializer::CL_OpenGL_Initializer()
00051 {
00052         global_uses_opengl = true;
00053         CL_System_Win32::add_listener(this);
00054         opengl_init_function = CL_DisplayCard_OpenGL_Win32::add_display;
00055 }
00056 
00057 CL_OpenGL_Initializer::~CL_OpenGL_Initializer()
00058 {
00059         CL_System_Win32::remove_listener(this);
00060 }
00061 
00062 bool CL_OpenGL_Initializer::received_event(UINT uMsg, WPARAM wParam, LPARAM lParam)
00063 {
00064         switch (uMsg)
00065         {
00066         case WM_DESTROY:
00067                 wglMakeCurrent(NULL, NULL);
00068                 wglDeleteContext(CL_DisplayCard_OpenGL_Win32::context);
00069                 return true;
00070         
00071         }
00072         return false;
00073 }

Generated at Wed Apr 4 19:54:03 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001