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

GLXPBufferContext.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 GLXPBUFFERCONTEXT_HPP
00025 #define GLXPBUFFERCONTEXT_HPP
00026 
00027 #include "ShStream.hpp"
00028 #include "ShProgram.hpp"
00029 #include "PBufferContext.hpp"
00030 
00031 namespace shgl {
00032 
00033 class GLXPBufferHandle : public PBufferHandle {
00034 public:
00035   GLXPBufferHandle(Display* display,
00036                    GLXDrawable drawable,
00037                    GLXContext context);
00038   
00039   virtual ~GLXPBufferHandle();
00040 
00041   virtual void restore();
00042 
00043 private:
00044   Display* m_display;
00045   
00046   GLXDrawable m_drawable;
00047   GLXContext m_context;
00048 };
00049 
00050 class GLXPBufferContext : public PBufferContext {
00051 public:
00052   GLXPBufferContext(int width, int height,
00053                     void* id,
00054                     Display* display, GLXPbuffer pbuffer,
00055                     GLXContext context);
00056   
00057   virtual ~GLXPBufferContext();
00058   
00059   virtual PBufferHandlePtr activate();
00060 
00061 private:
00062   Display* m_display;
00063 
00064   GLXPbuffer m_pbuffer;
00065   GLXContext m_context;
00066 };
00067 
00068 typedef SH::ShPointer<GLXPBufferContext> GLXPBufferContextPtr;
00069 typedef SH::ShPointer<const GLXPBufferContext> GLXPBufferContextCPtr;
00070 
00071 class GLXPBufferFactory : public PBufferFactory {
00072 public:
00073   static GLXPBufferFactory* instance();
00074 
00075   PBufferContextPtr get_context(int width, int height, void* id);
00076   FloatExtension get_extension();
00077   
00078 protected:
00079   GLXPBufferFactory();
00080   virtual ~GLXPBufferFactory();
00081 
00082 private:
00083   GLXPBufferContextPtr create_context(int width, int height, void* id);
00084 
00085   void init_display();
00086   void init_config();
00087 
00088   Display* m_display;
00089   GLXFBConfig* m_fb_config;
00090   FloatExtension m_extension;
00091 
00092   std::list<GLXPBufferContextPtr> m_contexts;
00093 
00094   static GLXPBufferFactory* m_instance;
00095 };
00096 
00097 }
00098 
00099 #endif

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