nux-1.14.0
GLDeviceObjects.cpp
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 #include "GLResource.h"
00024 #include "GpuDevice.h"
00025 #include "GLDeviceObjects.h"
00026 #include "GLResourceManager.h"
00027 
00028 #include "GLTextureResourceManager.h"
00029 #include "GLVertexResourceManager.h"
00030 #include "GLDeviceFrameBufferObject.h"
00031 #include "GLTemplatePrimitiveBuffer.h"
00032 #include "GraphicsEngine.h"
00033 
00034 namespace nux
00035 {
00036 
00037   extern PixelFormatInfo GPixelFormats[];
00038 //NObjectType IOpenGLResource::StaticObjectType(TEXT("IOpenGLResource"), 0);
00039   NUX_IMPLEMENT_OBJECT_TYPE (IOpenGLResource);
00040 
00041 
00043   /*
00044   GLSL Built-in vertex attribute (Deprecated in GLSL 1.30)
00045   -------------------------------
00046   Built-in vertex attribute name      Incompatible aliased vertex attribute index
00047   gl_Vertex                           0
00048   gl_Normal                           2
00049   gl_Color                            3
00050   gl_SecondaryColor                   4
00051   gl_FogCoord                         5
00052   gl_MultiTexCoord0                   8
00053   gl_MultiTexCoord1                   9
00054   gl_MultiTexCoord2                   10
00055   gl_MultiTexCoord3                   11
00056   gl_MultiTexCoord4                   12
00057   gl_MultiTexCoord5                   13
00058   gl_MultiTexCoord6                   14
00059   gl_MultiTexCoord7                   15
00060 
00061 
00062   gl_Vertex:
00063       - glVertex{234sifd}
00064       - glEnableClientState/glDisableClientState(GL_VERTEX_ARRAY); glVertexPointer(...);
00065   gl_Normal:
00066       - glNormal{3sifd}
00067       - glEnableClientState/glDisableClientState(GL_NORMAL_ARRAY); glNormalPointer(...);
00068   gl_Color:
00069       - glColor{34sifd}
00070       - glEnableClientState/glDisableClientState(GL_COLOR_ARRAY); glColorPointer(...);
00071   gl_SecondaryColor (requires GL_EXT_secondary_color)
00072       - glSecondaryColor3{bsifd};
00073       - glEnableClientState/glDisableClientState(SECONDARY_COLOR_ARRAY_EXT); glSecondaryColorPointerEXT(...);
00074   gl_FogCoord (requires GL_EXT_fog_coord)
00075       - glFogCoord{fd};
00076       - glEnableClientState/glDisableClientState(FOG_COORDINATE_ARRAY_EXT); glFogCoordPointerEXT(...);
00077   gl_MultiTexCoordXXX
00078       - glMultiTexCoord{234fd}
00079       - glClientActiveTextureARB(GL_TEXTUREXXX_ARB); glEnableClientState/glDisableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(...);
00080 
00081   GLSL Vertex Shader Special output variables (write)
00082   ----------------------------------------------------
00083       gl_Position     (must be written to)
00084       gl_PointSize    (may be written to)
00085       gl_ClipVertex   (may be written to)
00086 
00087   GLSL Vertex Shader Built-in varying (write)                     GLSL Fragment Shader Built-in varying (read)
00088   -------------------------------------------                     -------------------------------------------
00089       varying vec4    gl_FrontColor;                     ---->    gl_Color
00090       varying vec4    gl_BackColor;                      ---->    gl_Color
00091       varying vec4    gl_FrontSecondaryColor;            ---->    gl_SecondaryColor
00092       varying vec4    gl_BackSecondaryColor;             ---->    gl_SecondaryColor
00093       varying vec4    gl_TexCoord[];                     ---->    gl_TexCoord[]
00094       varying float   gl_FogFragCoord;                   ---->    gl_FogFragCoord
00095 
00096   GLSL Fragment Built-in variables
00097   --------------------------------
00098       vec4    gl_FragCoord    (read only)
00099       bool    gl_FrontFacing  (read only)
00100       vec2    gl_PointCoord   (read only)
00101 
00102   GLSL Fragment Shader Special output variables
00103   ---------------------------------------------
00104       vec4    gl_FragColor    (may be written to)
00105       vec4    gl_FragData[gl_MaxDrawBuffers]  (may be written to)
00106       float   gl_FragDepth    (may be written to)
00107       vec2    gl_PointCoord   (read only)
00108 
00109 
00110 
00111   Binding Semantics for Cg programs
00112   Binding Semantics for Varying Input/Output Data
00113   -----------------------------------------------
00114       Table 23 summarizes the valid binding semantics for varying input parameters
00115       in the vp30 profile.
00116         One can also use TANGENT and BINORMAL instead of TEXCOORD6 and
00117         TEXCOORD7. These binding semantics map to NV_vertex_program2 input
00118         attribute parameters. The two sets act as aliases to each other.
00119 
00120       Table 23 vp30 Varying Input Binding Semantics
00121                 Binding Semantics                           Name Corresponding Data
00122                 POSITION, ATTR0                             Input Vertex, Generic Attribute 0
00123                 BLENDWEIGHT, ATTR1                          Input vertex weight, Generic Attribute 1
00124                 NORMAL, ATTR2                               Input normal, Generic Attribute 2
00125                 COLOR0, DIFFUSE, ATTR3                      Input primary color, Generic Attribute 3
00126                 COLOR1, SPECULAR, ATTR4                     Input secondary color, Generic Attribute 4
00127                 TESSFACTOR, FOGCOORD, ATTR5                 Input fog coordinate, Generic Attribute 5
00128                 PSIZE, ATTR6                                Input point size, Generic Attribute 6
00129                 BLENDINDICES, ATTR7                         Generic Attribute 7
00130                 TEXCOORD0-TEXCOORD7, ATTR8-ATTR15           Input texture coordinates (texcoord0-texcoord7), Generic Attributes 8–15
00131                 TANGENT, ATTR14                             Generic Attribute 14
00132                 BINORMAL, ATTR15                            Generic Attribute 15
00133 
00134       Table 24 summarizes the valid binding semantics for varying output parameters
00135       in the vp30 profile. These binding semantics map to NV_vertex_program2 output registers. The
00136       two sets act as aliases to each other.
00137 
00138 
00139       Table 24 vp30 Varying Output Binding Semantics
00140                 Binding Semantics                           Name Corresponding Data
00141                 POSITION, HPOS                              Output position
00142                 PSIZE, PSIZ                                 Output point size
00143                 FOG, FOGC                                   Output fog coordinate
00144                 COLOR0, COL0                                Output primary color
00145                 COLOR1, COL1                                Output secondary color
00146                 BCOL0                                       Output backface primary color
00147                 BCOL1                                       Output backface secondary color
00148                 TEXCOORD0-TEXCOORD7, TEX0-TEX7              Output texture coordinates
00149                 CLP0-CL5                                    Output Clip distances
00150   */
00151 
00152 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends