Back to index

nux  3.0.0
IOpenGLResource.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef IOPENGLRESOURCE_H
00024 #define IOPENGLRESOURCE_H
00025 
00026 namespace nux
00027 {
00028 
00029   class GpuDevice;
00030   class IOpenGLBaseTexture;
00031   class IOpenGLTexture2D;
00032   class IOpenGLRectangleTexture;
00033   class IOpenGLCubeTexture;
00034   class IOpenGLSurface;
00035   class IOpenGLVolumeTexture;
00036   class IOpenGLVolume;
00037   class IOpenGLQuery;
00038   class IOpenGLShader;
00039   class IOpenGLVertexShader;
00040   class IOpenGLPixelShader;
00041 
00042   template<typename T> class ObjectPtr;
00043 
00044 #define NUM_VERTEX_SHADER_INPUT_ATTRIBUTE      16
00045   enum VertexAttributeType
00046   {
00047     VAT_UNDEFINED = 0,
00048     VAT_FLOAT = 1,
00049     VAT_FLOAT2,
00050     VAT_FLOAT3,
00051     VAT_FLOAT4,
00052     VAT_FLOAT_MAT2,
00053     VAT_FLOAT_MAT3,
00054     VAT_FLOAT_MAT4,
00055   };
00056 
00057   enum ShaderType
00058   {
00059     SHADER_TYPE_GLSL = 0,
00060     SHADER_TYPE_CG,
00061     SHADER_TYPE_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */
00062   };
00063   struct ShaderAttributeDefinition
00064   {
00065     int attribute_index;    // 0 to 15
00066     std::string attribute_name;
00067     int type;          // 1, 2, 3 or 4 component,
00068     bool valid;             // true is the attribute is used
00069   };
00070 
00071 
00073   class IOpenGLResource: public Object
00074   {
00075     NUX_DECLARE_OBJECT_TYPE(IOpenGLResource, Object);
00076 
00077   public:
00078     IOpenGLResource(OpenGLResourceType ResourceType, NUX_FILE_LINE_PROTO)
00079       : Object(true, NUX_FILE_LINE_PARAM)
00080       , _OpenGLID(0)
00081       , _RefCount(0)
00082       , _ResourceType(ResourceType)
00083     {
00084     }
00085 
00086     virtual ~IOpenGLResource()
00087     {
00088 
00089     }
00090 
00091     virtual int RefCount() const
00092     {
00093       return GetReferenceCount();
00094     }
00095 
00096     OpenGLResourceType GetResourceType() const
00097     {
00098       return _ResourceType;
00099     }
00100 
00101     int GetOpenGLID() const
00102     {
00103       return _OpenGLID;
00104     }
00105 
00106   private:
00107     GLuint _OpenGLID;
00108     int _RefCount;
00109     OpenGLResourceType _ResourceType;
00110 
00111     friend class IOpenGLFrameBufferObject;
00112     friend class IOpenGLSurface;
00113     friend class IOpenGLBaseTexture;
00114     friend class IOpenGLCubeTexture;
00115     friend class IOpenGLVolumeTexture;
00116     friend class IOpenGLAnimatedTexture;
00117     friend class IOpenGLTexture2D;
00118     friend class IOpenGLRectangleTexture;
00119     friend class IOpenGLVolume;
00120     friend class IOpenGLQuery;
00121     friend class GpuDevice;
00122     friend class IOpenGLIndexBuffer;
00123     friend class IOpenGLVertexBuffer;
00124     friend class IOpenGLVertexDeclaration;
00125     friend class IOpenGLShader;
00126     friend class IOpenGLVertexShader;
00127     friend class IOpenGLPixelShader;
00128     friend class IOpenGLGeometryShader;
00129     friend class IOpenGLShaderProgram;
00130     friend class IOpenGLAsmVertexShader;
00131     friend class IOpenGLAsmPixelShader;
00132     friend class IOpenGLAsmShaderProgram;
00133     friend class IOpenGLPixelBufferObject;
00134   };
00135 
00136 }
00137 
00138 #endif // IOPENGLRESOURCE_H