WGLPBufferContext.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2006 Serious Hack Inc.
00004 // 
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #ifndef WGLPBUFFERCONTEXT_HPP
00021 #define WGLPBUFFERCONTEXT_HPP
00022 
00023 #include "ShStream.hpp"
00024 #include "ShProgram.hpp"
00025 #include "PBufferContext.hpp"
00026 
00027 namespace shgl {
00028 
00029 class WGLPBufferHandle : public PBufferHandle {
00030 public:
00031   WGLPBufferHandle(HDC drawable,
00032                    HGLRC context);
00033   
00034   virtual ~WGLPBufferHandle();
00035 
00036   virtual void restore();
00037 
00038 private:
00039   HDC m_dc;
00040   HGLRC m_hglrc;
00041 };
00042 
00043 class WGLPBufferContext : public PBufferContext {
00044 public:
00045   WGLPBufferContext(int width, int height,
00046                     void* id,
00047                     HPBUFFERARB pbuffer,
00048                     HDC dc, HGLRC hglrc);
00049   
00050   virtual ~WGLPBufferContext();
00051   
00052   virtual PBufferHandlePtr activate();
00053 
00054 private:
00055   HPBUFFERARB m_pbuffer;
00056   HDC m_dc;
00057   HGLRC m_hglrc;
00058 };
00059 
00060 typedef SH::ShPointer<WGLPBufferContext> WGLPBufferContextPtr;
00061 typedef SH::ShPointer<const WGLPBufferContext> WGLPBufferContextCPtr;
00062 
00063 class WGLPBufferFactory : public PBufferFactory {
00064 public:
00065   static WGLPBufferFactory* instance();
00066 
00067   PBufferContextPtr get_context(int width, int height, void* id);
00068   FloatExtension get_extension();
00069   
00070 protected:
00071   WGLPBufferFactory();
00072   virtual ~WGLPBufferFactory();
00073 
00074 private:
00075   WGLPBufferContextPtr create_context(int width, int height, void* id);
00076 
00077   void init_dc();
00078   void init_config();
00079 
00080   HDC m_dc;
00081   int m_format;
00082   FloatExtension m_extension;
00083 
00084   std::list<WGLPBufferContextPtr> m_contexts;
00085 
00086   static WGLPBufferFactory* m_instance;
00087 };
00088 
00089 }
00090 
00091 #endif

Generated on Thu Feb 16 14:51:40 2006 for Sh by  doxygen 1.4.6