PixelLightAPI  .
ShaderLanguage.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: ShaderLanguage.h                               *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLRENDERER_SHADERLANGUAGE_H__
00024 #define __PLRENDERER_SHADERLANGUAGE_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Object.h>
00032 #include "PLRenderer/Renderer/GeometryShader.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLRenderer {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Forward declarations                                  ]
00043 //[-------------------------------------------------------]
00044 class Program;
00045 class VertexShader;
00046 class UniformBuffer;
00047 class FragmentShader;
00048 
00049 
00050 //[-------------------------------------------------------]
00051 //[ Classes                                               ]
00052 //[-------------------------------------------------------]
00053 /**
00054 *  @brief
00055 *    Abstract shader language class
00056 */
00057 class ShaderLanguage : public PLCore::Object {
00058 
00059 
00060     //[-------------------------------------------------------]
00061     //[ RTTI interface                                        ]
00062     //[-------------------------------------------------------]
00063     pl_class(PLRENDERER_RTTI_EXPORT, ShaderLanguage, "PLRenderer", PLCore::Object, "Abstract shader language class")
00064     pl_class_end
00065 
00066 
00067     //[-------------------------------------------------------]
00068     //[ Public functions                                      ]
00069     //[-------------------------------------------------------]
00070     public:
00071         /**
00072         *  @brief
00073         *    Creates a vertex shader and sets the shader source code
00074         *
00075         *  @param[in] sSourceCode
00076         *    Shader source code, usually blank ASCII code
00077         *  @param[in] sProfile
00078         *    Shader profile to use, if empty string, a default profile will be used which usually
00079         *    tries to use the best available profile that runs on most hardware
00080         *  @param[in] sEntry
00081         *    Entry point, if empty string, "main" is used as default
00082         *
00083         *  @return
00084         *    The created vertex shader, a null pointer on error
00085         *
00086         *  @see
00087         *    - Virtual "ShaderLanguage::CreateVertexShader()"-method
00088         *    - "Shader::SetSourceCode()"
00089         */
00090         PLRENDERER_API VertexShader *CreateVertexShader(const PLCore::String &sSourceCode, const PLCore::String &sProfile = "", const PLCore::String &sEntry = "");
00091 
00092         /**
00093         *  @brief
00094         *    Creates a geometry shader and sets the shader source code
00095         *
00096         *  @param[in] sSourceCode
00097         *    Geometry shader source code, usually blank ASCII code
00098         *  @param[in] nInputPrimitiveType
00099         *    Input primitive type, for "Shader::SetSourceCode()" "InputTriangles" is used as default
00100         *  @param[in] nOutputPrimitiveType
00101         *    Output primitive type, for "Shader::SetSourceCode()" "OutputTriangles" is used as default
00102         *  @param[in] nNumOfOutputVertices
00103         *    Number of output vertices, 0 if the maximum possible number of output vertices should be used, for "Shader::SetSourceCode()" "0" is used as default
00104         *  @param[in] sProfile
00105         *    Geometry shader profile to use, if empty string, a default profile will be used which usually
00106         *    tries to use the best available profile that runs on most hardware
00107         *  @param[in] sEntry
00108         *    Entry point, if empty string, "main" is used as default
00109         *
00110         *  @return
00111         *    The created geometry shader, a null pointer on error
00112         *
00113         *  @see
00114         *    - Virtual "ShaderLanguage::CreateGeometryShader()"-method
00115         *    - "GeometryShader::SetSourceCode()"
00116         */
00117         PLRENDERER_API GeometryShader *CreateGeometryShader(const PLCore::String &sSourceCode, GeometryShader::EInputPrimitiveType nInputPrimitiveType, GeometryShader::EOutputPrimitiveType nOutputPrimitiveType, PLCore::uint32 nNumOfOutputVertices, const PLCore::String &sProfile = "", const PLCore::String &sEntry = "");
00118 
00119         /**
00120         *  @brief
00121         *    Creates a fragment shader and sets the shader source code
00122         *
00123         *  @param[in] sSourceCode
00124         *    Shader source code, usually blank ASCII code
00125         *  @param[in] sProfile
00126         *    Shader profile to use, if empty string, a default profile will be used which usually
00127         *    tries to use the best available profile that runs on most hardware
00128         *  @param[in] sEntry
00129         *    Entry point, if empty string, "main" is used as default
00130         *
00131         *  @return
00132         *    The created fragment shader, a null pointer on error
00133         *
00134         *  @see
00135         *    - Virtual "ShaderLanguage::CreateFragmentShader()"-method
00136         *    - "Shader::SetSourceCode()"
00137         */
00138         PLRENDERER_API FragmentShader *CreateFragmentShader(const PLCore::String &sSourceCode, const PLCore::String &sProfile = "", const PLCore::String &sEntry = "");
00139 
00140         /**
00141         *  @brief
00142         *    Creates a program and assigns a vertex and fragment shader to it
00143         *
00144         *  @param[in] pVertexShader
00145         *    Vertex shader the program is using, can be a null pointer, vertex shader and program language must match!
00146         *  @param[in] pFragmentShader
00147         *    Fragment shader the program is using, can be a null pointer, fragment shader and program language must match!
00148         *
00149         *  @return
00150         *    The created program, a null pointer on error
00151         *
00152         *  @see
00153         *    - Virtual "ShaderLanguage::CreateProgram()"-method
00154         *    - "Program::SetVertexShader()"
00155         *    - "Program::SetFragmentShader()"
00156         */
00157         PLRENDERER_API Program *CreateProgram(VertexShader *pVertexShader, FragmentShader *pFragmentShader);
00158 
00159         /**
00160         *  @brief
00161         *    Creates a program and assigns a vertex, geometry and fragment shader to it
00162         *
00163         *  @param[in] pVertexShader
00164         *    Vertex shader the program is using, can be a null pointer, vertex shader and program language must match!
00165         *  @param[in] pGeometryShader
00166         *    Geometry shader the program is using, can be a null pointer, geometry shader and program language must match!
00167         *  @param[in] pFragmentShader
00168         *    Fragment shader the program is using, can be a null pointer, fragment shader and program language must match!
00169         *
00170         *  @return
00171         *    The created program, a null pointer on error
00172         *
00173         *  @see
00174         *    - Virtual "ShaderLanguage::CreateProgram()"-method
00175         *    - "Program::SetVertexShader()"
00176         *    - "Program::SetGeometryShader()"
00177         *    - "Program::SetFragmentShader()"
00178         */
00179         PLRENDERER_API Program *CreateProgram(VertexShader *pVertexShader, GeometryShader *pGeometryShader, FragmentShader *pFragmentShader);
00180 
00181 
00182     //[-------------------------------------------------------]
00183     //[ Public virtual ShaderLanguage functions               ]
00184     //[-------------------------------------------------------]
00185     public:
00186         /**
00187         *  @brief
00188         *    Returns the name of the shader language
00189         *
00190         *  @return
00191         *    The name of the shader language (for example "GLSL" or "Cg")
00192         */
00193         virtual PLCore::String GetShaderLanguage() const = 0;
00194 
00195         /**
00196         *  @brief
00197         *    Creates a vertex shader
00198         *
00199         *  @return
00200         *    The created vertex shader, a null pointer on error
00201         */
00202         virtual VertexShader *CreateVertexShader() = 0;
00203 
00204         /**
00205         *  @brief
00206         *    Creates a geometry shader
00207         *
00208         *  @return
00209         *    The created geometry shader, a null pointer on error
00210         */
00211         virtual GeometryShader *CreateGeometryShader() = 0;
00212 
00213         /**
00214         *  @brief
00215         *    Creates a fragment shader
00216         *
00217         *  @return
00218         *    The created fragment shader, a null pointer on error
00219         */
00220         virtual FragmentShader *CreateFragmentShader() = 0;
00221 
00222         /**
00223         *  @brief
00224         *    Creates a program
00225         *
00226         *  @return
00227         *    The created program, a null pointer on error
00228         */
00229         virtual Program *CreateProgram() = 0;
00230 
00231         /**
00232         *  @brief
00233         *    Creates an uniform buffer
00234         *
00235         *  @return
00236         *    The created uniform buffer, a null pointer on error
00237         */
00238         virtual UniformBuffer *CreateUniformBuffer() = 0;
00239 
00240 
00241     //[-------------------------------------------------------]
00242     //[ Protected functions                                   ]
00243     //[-------------------------------------------------------]
00244     protected:
00245         /**
00246         *  @brief
00247         *    Constructor
00248         */
00249         PLRENDERER_API ShaderLanguage();
00250 
00251         /**
00252         *  @brief
00253         *    Destructor
00254         */
00255         PLRENDERER_API virtual ~ShaderLanguage();
00256 
00257 
00258     //[-------------------------------------------------------]
00259     //[ Private functions                                     ]
00260     //[-------------------------------------------------------]
00261     private:
00262         /**
00263         *  @brief
00264         *    Copy constructor
00265         *
00266         *  @param[in] cSource
00267         *    Source to copy from
00268         */
00269         ShaderLanguage(const ShaderLanguage &cSource);
00270 
00271         /**
00272         *  @brief
00273         *    Copy operator
00274         *
00275         *  @param[in] cSource
00276         *    Source to copy from
00277         *
00278         *  @return
00279         *    Reference to this instance
00280         */
00281         ShaderLanguage &operator =(const ShaderLanguage &cSource);
00282 
00283 
00284 };
00285 
00286 
00287 //[-------------------------------------------------------]
00288 //[ Namespace                                             ]
00289 //[-------------------------------------------------------]
00290 } // PLRenderer
00291 
00292 
00293 #endif // __PLRENDERER_SHADERLANGUAGE_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:01
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported