Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

WGLPBufferContext.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 Serious Hack Inc.
00004 // 
00005 // This software is provided 'as-is', without any express or implied
00006 // warranty. In no event will the authors be held liable for any damages
00007 // arising from the use of this software.
00008 // 
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it
00011 // freely, subject to the following restrictions:
00012 // 
00013 // 1. The origin of this software must not be misrepresented; you must
00014 // not claim that you wrote the original software. If you use this
00015 // software in a product, an acknowledgment in the product documentation
00016 // would be appreciated but is not required.
00017 // 
00018 // 2. Altered source versions must be plainly marked as such, and must
00019 // not be misrepresented as being the original software.
00020 // 
00021 // 3. This notice may not be removed or altered from any source
00022 // distribution.
00024 #ifndef WGLPBUFFERCONTEXT_HPP
00025 #define WGLPBUFFERCONTEXT_HPP
00026 
00027 #include "ShStream.hpp"
00028 #include "ShProgram.hpp"
00029 #include "PBufferContext.hpp"
00030 
00031 namespace shgl {
00032 
00033 class WGLPBufferHandle : public PBufferHandle {
00034 public:
00035   WGLPBufferHandle(HDC drawable,
00036                    HGLRC context);
00037   
00038   virtual ~WGLPBufferHandle();
00039 
00040   virtual void restore();
00041 
00042 private:
00043   HDC m_dc;
00044   HGLRC m_hglrc;
00045 };
00046 
00047 class WGLPBufferContext : public PBufferContext {
00048 public:
00049   WGLPBufferContext(int width, int height,
00050                     void* id,
00051                     HPBUFFERARB pbuffer,
00052                     HDC dc, HGLRC hglrc);
00053   
00054   virtual ~WGLPBufferContext();
00055   
00056   virtual PBufferHandlePtr activate();
00057 
00058 private:
00059   HPBUFFERARB m_pbuffer;
00060   HDC m_dc;
00061   HGLRC m_hglrc;
00062 };
00063 
00064 typedef SH::ShPointer<WGLPBufferContext> WGLPBufferContextPtr;
00065 typedef SH::ShPointer<const WGLPBufferContext> WGLPBufferContextCPtr;
00066 
00067 class WGLPBufferFactory : public PBufferFactory {
00068 public:
00069   static WGLPBufferFactory* instance();
00070 
00071   PBufferContextPtr get_context(int width, int height, void* id);
00072   FloatExtension get_extension();
00073   
00074 protected:
00075   WGLPBufferFactory();
00076   virtual ~WGLPBufferFactory();
00077 
00078 private:
00079   WGLPBufferContextPtr create_context(int width, int height, void* id);
00080 
00081   void init_dc();
00082   void init_config();
00083 
00084   HDC m_dc;
00085   int m_format;
00086   FloatExtension m_extension;
00087 
00088   std::list<WGLPBufferContextPtr> m_contexts;
00089 
00090   static WGLPBufferFactory* m_instance;
00091 };
00092 
00093 }
00094 
00095 #endif

Generated on Wed Jun 15 18:12:42 2005 for Sh by  doxygen 1.4.3-20050530