Back to index

unity  6.0.0
ScreenEffectFramebufferObject.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /* Compiz unity plugin
00003  * unity.h
00004  *
00005  * Copyright (c) 2010-11 Canonical Ltd.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 3
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
00018  */
00019 
00020 #ifndef UNITY_SCREENEFFECT_FRAMEBUFFER_H
00021 #define UNITY_SCREENEFFECT_FRAMEBUFFER_H
00022 
00023 #ifndef USE_MODERN_COMPIZ_GL
00024 #include <Nux/Nux.h>
00025 
00026 namespace unity
00027 {
00028 class ScreenEffectFramebufferObject
00029 {
00030 public:
00031 
00032   typedef boost::shared_ptr <ScreenEffectFramebufferObject> Ptr;
00033   typedef void (*FuncPtr) (void);
00034   typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
00035 
00036   ScreenEffectFramebufferObject (GLXGetProcAddressProc, const nux::Geometry &geom);
00037   ~ScreenEffectFramebufferObject ();
00038 
00039 public:
00040 
00041   void bind (const nux::Geometry &geom);
00042   void unbind ();
00043 
00044   bool status ();
00045   void paint (const nux::Geometry &geom);
00046   bool bound () { return mBoundCnt > 0; }
00047 
00048   GLuint texture () { return mFBTexture; }
00049   
00050   void onScreenSizeChanged (const nux::Geometry &screenSize);
00051 
00052 private:
00053 
00054   FuncPtr getProcAddr (const std::string &);
00055 
00056   typedef void (*GLActiveTextureProc) (GLenum texture);
00057   typedef void (*GLGenFramebuffersProc) (GLsizei n,
00058                                          GLuint  *framebuffers);
00059   typedef void (*GLDeleteFramebuffersProc) (GLsizei n,
00060                                             GLuint  *framebuffers);
00061   typedef void (*GLBindFramebufferProc) (GLenum target,
00062                                          GLuint framebuffer);
00063   typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);
00064   typedef void (*GLFramebufferTexture2DProc) (GLenum target,
00065                                               GLenum attachment,
00066                                               GLenum textarget,
00067                                               GLuint texture,
00068                                               GLint  level);
00069   
00070   GLXGetProcAddressProc getProcAddressGLX;
00071   GLActiveTextureProc activeTexture;
00072   GLGenFramebuffersProc genFramebuffers;
00073   GLDeleteFramebuffersProc deleteFramebuffers;
00074   GLBindFramebufferProc bindFramebuffer;
00075   GLCheckFramebufferStatusProc checkFramebufferStatus;
00076   GLFramebufferTexture2DProc framebufferTexture2D;
00077   /* compiz fbo handle that goes through to nux */
00078   GLuint   mFboHandle; // actual handle to the framebuffer_ext
00079   bool    mFboStatus; // did the framebuffer texture bind succeed
00080   GLuint   mFBTexture;
00081   nux::Geometry mGeometry;
00082   unsigned int mBoundCnt;
00083   
00084   nux::Geometry mScreenSize;
00085 };
00086 } // namespace unity
00087 
00088 #endif // USE_MODERN_COMPIZ_GL
00089 #endif