PixelLightAPI  .
ShaderLanguage.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: ShaderLanguage.h                               *
00003  *
00004  *  Copyright (C) 2002-2012 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] sArguments
00081         *    Optional shader compiler arguments, e.g. "version=150" when using Cg and a "glslv" profile
00082         *  @param[in] sEntry
00083         *    Entry point, if empty string, "main" is used as default
00084         *
00085         *  @return
00086         *    The created vertex shader, a null pointer on error
00087         *
00088         *  @see
00089         *    - Virtual "ShaderLanguage::CreateVertexShader()"-method
00090         *    - "Shader::SetSourceCode()"
00091         */
00092         PLRENDERER_API VertexShader *CreateVertexShader(const PLCore::String &sSourceCode, const PLCore::String &sProfile = "", const PLCore::String &sArguments = "", const PLCore::String &sEntry = "");
00093 
00094         /**
00095         *  @brief
00096         *    Creates a geometry shader and sets the shader source code
00097         *
00098         *  @param[in] sSourceCode
00099         *    Geometry shader source code, usually blank ASCII code
00100         *  @param[in] nInputPrimitiveType
00101         *    Input primitive type, for "Shader::SetSourceCode()" "InputTriangles" is used as default
00102         *  @param[in] nOutputPrimitiveType
00103         *    Output primitive type, for "Shader::SetSourceCode()" "OutputTriangles" is used as default
00104         *  @param[in] nNumOfOutputVertices
00105         *    Number of output vertices, 0 if the maximum possible number of output vertices should be used, for "Shader::SetSourceCode()" "0" is used as default
00106         *  @param[in] sProfile
00107         *    Geometry shader profile to use, if empty string, a default profile will be used which usually
00108         *    tries to use the best available profile that runs on most hardware
00109         *  @param[in] sArguments
00110         *    Optional shader compiler arguments, e.g. "version=150" when using Cg and a "glslg" profile
00111         *  @param[in] sEntry
00112         *    Entry point, if empty string, "main" is used as default
00113         *
00114         *  @return
00115         *    The created geometry shader, a null pointer on error
00116         *
00117         *  @see
00118         *    - Virtual "ShaderLanguage::CreateGeometryShader()"-method
00119         *    - "GeometryShader::SetSourceCode()"
00120         */
00121         PLRENDERER_API GeometryShader *CreateGeometryShader(const PLCore::String &sSourceCode, GeometryShader::EInputPrimitiveType nInputPrimitiveType, GeometryShader::EOutputPrimitiveType nOutputPrimitiveType, PLCore::uint32 nNumOfOutputVertices, const PLCore::String &sProfile = "", const PLCore::String &sArguments = "", const PLCore::String &sEntry = "");
00122 
00123         /**
00124         *  @brief
00125         *    Creates a fragment shader and sets the shader source code
00126         *
00127         *  @param[in] sSourceCode
00128         *    Shader source code, usually blank ASCII code
00129         *  @param[in] sProfile
00130         *    Shader profile to use, if empty string, a default profile will be used which usually
00131         *    tries to use the best available profile that runs on most hardware
00132         *  @param[in] sArguments
00133         *    Optional shader compiler arguments, e.g. "version=150" when using Cg and a "glslf" profile
00134         *  @param[in] sEntry
00135         *    Entry point, if empty string, "main" is used as default
00136         *
00137         *  @return
00138         *    The created fragment shader, a null pointer on error
00139         *
00140         *  @see
00141         *    - Virtual "ShaderLanguage::CreateFragmentShader()"-method
00142         *    - "Shader::SetSourceCode()"
00143         */
00144         PLRENDERER_API FragmentShader *CreateFragmentShader(const PLCore::String &sSourceCode, const PLCore::String &sProfile = "", const PLCore::String &sArguments = "", const PLCore::String &sEntry = "");
00145 
00146         /**
00147         *  @brief
00148         *    Creates a program and assigns a vertex and fragment shader to it
00149         *
00150         *  @param[in] pVertexShader
00151         *    Vertex shader the program is using, can be a null pointer, vertex shader and program language must match!
00152         *  @param[in] pFragmentShader
00153         *    Fragment shader the program is using, can be a null pointer, fragment shader and program language must match!
00154         *
00155         *  @return
00156         *    The created program, a null pointer on error
00157         *
00158         *  @see
00159         *    - Virtual "ShaderLanguage::CreateProgram()"-method
00160         *    - "Program::SetVertexShader()"
00161         *    - "Program::SetFragmentShader()"
00162         */
00163         PLRENDERER_API Program *CreateProgram(VertexShader *pVertexShader, FragmentShader *pFragmentShader);
00164 
00165         /**
00166         *  @brief
00167         *    Creates a program and assigns a vertex, geometry and fragment shader to it
00168         *
00169         *  @param[in] pVertexShader
00170         *    Vertex shader the program is using, can be a null pointer, vertex shader and program language must match!
00171         *  @param[in] pGeometryShader
00172         *    Geometry shader the program is using, can be a null pointer, geometry shader and program language must match!
00173         *  @param[in] pFragmentShader
00174         *    Fragment shader the program is using, can be a null pointer, fragment shader and program language must match!
00175         *
00176         *  @return
00177         *    The created program, a null pointer on error
00178         *
00179         *  @see
00180         *    - Virtual "ShaderLanguage::CreateProgram()"-method
00181         *    - "Program::SetVertexShader()"
00182         *    - "Program::SetGeometryShader()"
00183         *    - "Program::SetFragmentShader()"
00184         */
00185         PLRENDERER_API Program *CreateProgram(VertexShader *pVertexShader, GeometryShader *pGeometryShader, FragmentShader *pFragmentShader);
00186 
00187 
00188     //[-------------------------------------------------------]
00189     //[ Public virtual ShaderLanguage functions               ]
00190     //[-------------------------------------------------------]
00191     public:
00192         /**
00193         *  @brief
00194         *    Returns the name of the shader language
00195         *
00196         *  @return
00197         *    The name of the shader language (for example "GLSL" or "Cg")
00198         */
00199         virtual PLCore::String GetShaderLanguage() const = 0;
00200 
00201         /**
00202         *  @brief
00203         *    Creates a vertex shader
00204         *
00205         *  @return
00206         *    The created vertex shader, a null pointer on error
00207         */
00208         virtual VertexShader *CreateVertexShader() = 0;
00209 
00210         /**
00211         *  @brief
00212         *    Creates a geometry shader
00213         *
00214         *  @return
00215         *    The created geometry shader, a null pointer on error
00216         */
00217         virtual GeometryShader *CreateGeometryShader() = 0;
00218 
00219         /**
00220         *  @brief
00221         *    Creates a fragment shader
00222         *
00223         *  @return
00224         *    The created fragment shader, a null pointer on error
00225         */
00226         virtual FragmentShader *CreateFragmentShader() = 0;
00227 
00228         /**
00229         *  @brief
00230         *    Creates a program
00231         *
00232         *  @return
00233         *    The created program, a null pointer on error
00234         */
00235         virtual Program *CreateProgram() = 0;
00236 
00237         /**
00238         *  @brief
00239         *    Creates an uniform buffer
00240         *
00241         *  @return
00242         *    The created uniform buffer, a null pointer on error
00243         */
00244         virtual UniformBuffer *CreateUniformBuffer() = 0;
00245 
00246 
00247     //[-------------------------------------------------------]
00248     //[ Protected functions                                   ]
00249     //[-------------------------------------------------------]
00250     protected:
00251         /**
00252         *  @brief
00253         *    Constructor
00254         */
00255         PLRENDERER_API ShaderLanguage();
00256 
00257         /**
00258         *  @brief
00259         *    Destructor
00260         */
00261         PLRENDERER_API virtual ~ShaderLanguage();
00262 
00263 
00264     //[-------------------------------------------------------]
00265     //[ Private functions                                     ]
00266     //[-------------------------------------------------------]
00267     private:
00268         /**
00269         *  @brief
00270         *    Copy constructor
00271         *
00272         *  @param[in] cSource
00273         *    Source to copy from
00274         */
00275         ShaderLanguage(const ShaderLanguage &cSource);
00276 
00277         /**
00278         *  @brief
00279         *    Copy operator
00280         *
00281         *  @param[in] cSource
00282         *    Source to copy from
00283         *
00284         *  @return
00285         *    Reference to this instance
00286         */
00287         ShaderLanguage &operator =(const ShaderLanguage &cSource);
00288 
00289 
00290 };
00291 
00292 
00293 //[-------------------------------------------------------]
00294 //[ Namespace                                             ]
00295 //[-------------------------------------------------------]
00296 } // PLRenderer
00297 
00298 
00299 #endif // __PLRENDERER_SHADERLANGUAGE_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:59
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported