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

panda/src/wgldisplay/wglGraphicsStateGuardian.cxx

Go to the documentation of this file.
00001 // Filename: wglGraphicsStateGuardian.cxx
00002 // Created by:  drose (27Jan03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "wglGraphicsStateGuardian.h"
00020 
00021 
00022 TypeHandle wglGraphicsStateGuardian::_type_handle;
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: wglGraphicsStateGuardian::Constructor
00026 //       Access: Public
00027 //  Description:
00028 ////////////////////////////////////////////////////////////////////
00029 wglGraphicsStateGuardian::
00030 wglGraphicsStateGuardian(const FrameBufferProperties &properties,
00031                          int pfnum) : 
00032   GLGraphicsStateGuardian(properties),
00033   _pfnum(pfnum)
00034 {
00035   _made_context = false;
00036   _context = (HGLRC)NULL;
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: wglGraphicsStateGuardian::Destructor
00041 //       Access: Public
00042 //  Description:
00043 ////////////////////////////////////////////////////////////////////
00044 wglGraphicsStateGuardian::
00045 ~wglGraphicsStateGuardian() {
00046   if (_context != (HGLRC)NULL) {
00047     wglDeleteContext(_context);
00048     _context = (HGLRC)NULL;
00049   }
00050 }
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //     Function: wglGraphicsStateGuardian::make_context
00054 //       Access: Private
00055 //  Description: Creates a suitable context for rendering into the
00056 //               given window.  This should only be called from the
00057 //               draw thread.
00058 ////////////////////////////////////////////////////////////////////
00059 void wglGraphicsStateGuardian::
00060 make_context(HDC hdc) {
00061   // We should only call this once for a particular GSG.
00062   nassertv(!_made_context);
00063 
00064   _made_context = true;
00065 
00066   // Attempt to create a context.
00067   _context = wglCreateContext(hdc);
00068 
00069   if (_context == NULL) {
00070     wgldisplay_cat.error()
00071       << "Could not create GL context.\n";
00072     return;
00073   }
00074 }

Generated on Fri May 2 00:44:43 2003 for Panda by doxygen1.3