00001 // Copyright NVIDIA Corporation 2002-2004 00002 // TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED 00003 // *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS 00004 // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY 00005 // AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS 00006 // BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES 00007 // WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, 00008 // BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) 00009 // ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS 00010 // BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 00011 00012 #pragma once 00013 00015 #include <vector> 00016 #include "nvgl/nvgl.h" 00017 00018 // No need to document this internal helper class 00019 #if ! defined( DOXYGEN_IGNORE ) 00020 00021 namespace nvgl 00022 { 00023 //Helper class for managing pbuffers. 00024 class PBuffer 00025 { 00026 public: 00027 // Constructor 00028 // Chooses a pixel format according to the arguments and assembles an attribute list for creating a 00029 // pbuffer. After construction, the pbuffer is not yet valid; a pbuffer is created on \c resize(). 00030 PBuffer( int bitsPerChannel, bool alpha, int depth, bool isFloat ); 00031 ~PBuffer(); 00032 00033 public: 00034 // Clear all resources of this pbuffer. 00035 // After this function, the pbuffer is no longer valid. 00036 void clear(); 00037 00038 // Get the depth texture of the pbuffer. 00039 // If the pbuffer has a depth, a depth texture is created. 00040 // returns depth texture id 00041 GLuint getDepthTexture() const; 00042 00043 #if defined(_WIN32) 00044 // Gets the HDC of the pbuffer. 00045 // returns HDC of the pbuffer 00046 HDC getHDC() const; 00047 00048 // Get the HGLRC of the pbuffer. 00049 // returns HGLRC of the pbuffer 00050 HGLRC getHGLRC() const; 00051 00052 // Get the handle of the pbuffer. 00053 // returns handle of the pbuffer 00054 HPBUFFERARB getPBuffer() const; 00055 #elif defined(LINUX) 00056 // Gets the HDC of the pbuffer. 00057 // returns HDC of the pbuffer 00058 Drawable getHDC() const; 00059 00060 // Gets the HGLRC of the pbuffer. 00061 // returns HGLRC of the pbuffer 00062 GLXContext getHGLRC() const; 00063 00064 // Get the handle of the pbuffer. 00065 // returns handle of the pbuffer 00066 GLXPbuffer getPBuffer() const; 00067 #endif 00068 00069 // Get the height of the pbuffer. 00070 // returns height of the pbuffer 00071 int getHeight() const; 00072 00073 // Get the texture of the pbuffer. 00074 // Every pbuffer has a texture bound to the color buffer of the pbuffer. 00075 // returns texture id 00076 GLuint getTexture() const; 00077 00078 // Get the width of the pbuffer. 00079 // returns width of the pbuffer 00080 int getWidth() const; 00081 00082 // Resize the pbuffer. 00083 // On resize, the current pbuffer is cleared and is completely initialized. 00084 // The pbuffer then shares the lists with the current OpenGL context. 00085 // After resizing the OpenGL context of the pbuffer is current. If the pbuffer 00086 // has a depth, a depth texture is also created. The viewport and the projection 00087 // and modelview matrix are initialized to orthographic projection and identity, 00088 // respectively. 00089 // returns \c true if the resize operation completed successfully, \c false otherwise. 00090 bool resize( int width, int height); 00091 00092 private: 00093 std::vector<int> m_attribList; 00094 int m_depth; 00095 GLuint m_depthTexture; 00096 int m_format; 00097 int m_height; 00098 #if defined(_WIN32) 00099 HDC m_HDC; 00100 HGLRC m_HGLRC; 00101 HPBUFFERARB m_pBuffer; 00102 #elif defined(LINUX) 00103 Drawable m_HDC; 00104 GLXContext m_HGLRC; 00105 GLXPbuffer m_pBuffer; 00106 #endif 00107 GLuint m_texture; 00108 int m_width; 00109 }; 00110 00111 } // namespace nvgl 00112 00113 #endif //DOXYGEN_IGNORE