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

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