Panda3D

wglGraphicsBuffer.h

00001 // Filename: wglGraphicsBuffer.h
00002 // Created by:  drose (08Feb04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef WGLGRAPHICSBUFFER_H
00016 #define WGLGRAPHICSBUFFER_H
00017 
00018 #include "pandabase.h"
00019 #include "graphicsBuffer.h"
00020 #include "glgsg.h"
00021 
00022 // This must be included after we have included glgsg.h (which
00023 // includes gl.h).
00024 #include "wglext.h"
00025 #define WIN32_LEAN_AND_MEAN
00026 #include <windows.h>
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : wglGraphicsBuffer
00030 // Description : An offscreen render buffer.  In OpenGL under Windows,
00031 //               this simply renders into a window that is never made
00032 //               visible.  There's a Windows interface for rendering
00033 //               into a DIB, but this puts restrictions on the kind of
00034 //               pixelformat we can use, and thus makes it difficult
00035 //               to support one GSG rendering into an offscreen buffer
00036 //               and also into a window.
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDAGL wglGraphicsBuffer : public GraphicsBuffer {
00039 public:
00040   wglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, 
00041                     const string &name,
00042                     const FrameBufferProperties &fb_prop,
00043                     const WindowProperties &win_prop,
00044                     int flags,
00045                     GraphicsStateGuardian *gsg,
00046                     GraphicsOutput *host);
00047   virtual ~wglGraphicsBuffer();
00048 
00049   virtual bool begin_frame(FrameMode mode, Thread *current_thread);
00050   virtual void end_frame(FrameMode mode, Thread *current_thread);
00051 
00052   virtual void select_cube_map(int cube_map_index);
00053 
00054   virtual void process_events();
00055 
00056 protected:
00057   virtual void close_buffer();
00058   virtual bool open_buffer();
00059 
00060 private:
00061   void bind_texture_to_pbuffer();
00062   bool rebuild_bitplanes();
00063   void release_pbuffer();
00064 
00065   static void process_1_event();
00066 
00067   HPBUFFERARB _pbuffer;
00068   HDC _pbuffer_dc;
00069   bool _pbuffer_mipmap;
00070   Texture::TextureType _pbuffer_type;
00071   int _pbuffer_sizex;
00072   int _pbuffer_sizey;
00073   PT(Texture) _pbuffer_bound;
00074   
00075 public:
00076   static TypeHandle get_class_type() {
00077     return _type_handle;
00078   }
00079   static void init_type() {
00080     GraphicsBuffer::init_type();
00081     register_type(_type_handle, "wglGraphicsBuffer",
00082                   GraphicsBuffer::get_class_type());
00083   }
00084   virtual TypeHandle get_type() const {
00085     return get_class_type();
00086   }
00087   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00088 
00089 private:
00090   static TypeHandle _type_handle;
00091 
00092   friend class wglGraphicsStateGuardian;
00093 };
00094 
00095 #include "wglGraphicsBuffer.I"
00096 
00097 #endif
 All Classes Functions Variables Enumerations