Panda3D
 All Classes Functions Variables Enumerations
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   virtual bool get_supports_render_texture() const;
00057 
00058 protected:
00059   virtual void close_buffer();
00060   virtual bool open_buffer();
00061 
00062 private:
00063   void bind_texture_to_pbuffer();
00064   bool rebuild_bitplanes();
00065   void release_pbuffer();
00066 
00067   static void process_1_event();
00068 
00069   HPBUFFERARB _pbuffer;
00070   HDC _pbuffer_dc;
00071   bool _pbuffer_mipmap;
00072   Texture::TextureType _pbuffer_type;
00073   int _pbuffer_sizex;
00074   int _pbuffer_sizey;
00075   PT(Texture) _pbuffer_bound;
00076   
00077 public:
00078   static TypeHandle get_class_type() {
00079     return _type_handle;
00080   }
00081   static void init_type() {
00082     GraphicsBuffer::init_type();
00083     register_type(_type_handle, "wglGraphicsBuffer",
00084                   GraphicsBuffer::get_class_type());
00085   }
00086   virtual TypeHandle get_type() const {
00087     return get_class_type();
00088   }
00089   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00090 
00091 private:
00092   static TypeHandle _type_handle;
00093 
00094   friend class wglGraphicsStateGuardian;
00095 };
00096 
00097 #include "wglGraphicsBuffer.I"
00098 
00099 #endif
 All Classes Functions Variables Enumerations