Commit c0586e30 authored by hybrid's avatar hybrid

Add some convenience wrappers for simplified shader generation in the default...

Add some convenience wrappers for simplified shader generation in the default cases. Suggested and implemented by curaga.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4027 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c5758363
......@@ -34,36 +34,36 @@ public:
//! Adds a new high-level shading material renderer to the VideoDriver.
/** Currently only HLSL/D3D9 and GLSL/OpenGL are supported.
\param vertexShaderProgram: String containing the source of the vertex
\param vertexShaderProgram String containing the source of the vertex
shader program. This can be 0 if no vertex program shall be used.
\param vertexShaderEntryPointName: Name of the entry function of the
\param vertexShaderEntryPointName Name of the entry function of the
vertexShaderProgram (p.e. "main")
\param vsCompileTarget: Vertex shader version the high level shader
\param vsCompileTarget Vertex shader version the high level shader
shall be compiled to.
\param pixelShaderProgram: String containing the source of the pixel
\param pixelShaderProgram String containing the source of the pixel
shader program. This can be 0 if no pixel shader shall be used.
\param pixelShaderEntryPointName: Entry name of the function of the
\param pixelShaderEntryPointName Entry name of the function of the
pixelShaderProgram (p.e. "main")
\param psCompileTarget: Pixel shader version the high level shader
\param psCompileTarget Pixel shader version the high level shader
shall be compiled to.
\param geometryShaderProgram: String containing the source of the
\param geometryShaderProgram String containing the source of the
geometry shader program. This can be 0 if no geometry shader shall be
used.
\param geometryShaderEntryPointName: Entry name of the function of the
\param geometryShaderEntryPointName Entry name of the function of the
geometryShaderProgram (p.e. "main")
\param gsCompileTarget: Geometry shader version the high level shader
\param gsCompileTarget Geometry shader version the high level shader
shall be compiled to.
\param inType Type of vertices passed to geometry shader
\param outType Type of vertices created by geometry shader
\param verticesOut Maximal number of vertices created by geometry
shader. If 0, maximal number supported is assumed.
\param callback: Pointer to an implementation of
\param callback Pointer to an implementation of
IShaderConstantSetCallBack in which you can set the needed vertex,
pixel, and geometry shader program constants. Set this to 0 if you
don't need this.
\param baseMaterial: Base material which renderstates will be used to
\param baseMaterial Base material which renderstates will be used to
shade the material.
\param userData: a user data int. This int can be set to any value and
\param userData a user data int. This int can be set to any value and
will be set as parameter in the callback method when calling
OnSetConstants(). In this way it is easily possible to use the same
callback method for multiple materials and distinguish between them
......@@ -93,14 +93,14 @@ public:
//! convenience function for use without geometry shaders
s32 addHighLevelShaderMaterial(
const c8* vertexShaderProgram,
const c8* vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
const c8* pixelShaderProgram = 0,
const c8* pixelShaderEntryPointName = "main",
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
IShaderConstantSetCallBack* callback = 0,
const c8* vertexShaderEntryPointName="main",
E_VERTEX_SHADER_TYPE vsCompileTarget=EVST_VS_1_1,
const c8* pixelShaderProgram=0,
const c8* pixelShaderEntryPointName="main",
E_PIXEL_SHADER_TYPE psCompileTarget=EPST_PS_1_1,
IShaderConstantSetCallBack* callback=0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0 )
s32 userData=0)
{
return addHighLevelShaderMaterial(
vertexShaderProgram, vertexShaderEntryPointName,
......@@ -111,39 +111,83 @@ public:
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, without geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1.
*/
s32 addHighLevelShaderMaterial(
const c8* vertexShaderProgram,
const c8* pixelShaderProgram=0,
IShaderConstantSetCallBack* callback=0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData=0)
{
return addHighLevelShaderMaterial(
vertexShaderProgram, "main",
EVST_VS_1_1, pixelShaderProgram,
"main", EPST_PS_1_1,
0, "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, with geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1 and geometry shader 4.0.
*/
s32 addHighLevelShaderMaterial(
const c8* vertexShaderProgram,
const c8* pixelShaderProgram = 0,
const c8* geometryShaderProgram = 0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0 )
{
return addHighLevelShaderMaterial(
vertexShaderProgram, "main",
EVST_VS_1_1, pixelShaderProgram,
"main", EPST_PS_1_1,
geometryShaderProgram, "main", EGST_GS_4_0,
inType, outType, verticesOut,
callback, baseMaterial, userData);
}
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
/** \param vertexShaderProgramFileName: Text file containing the source
/** \param vertexShaderProgramFileName Text file containing the source
of the vertex shader program. Set to empty string if no vertex shader
shall be created.
\param vertexShaderEntryPointName: Name of the entry function of the
\param vertexShaderEntryPointName Name of the entry function of the
vertexShaderProgram (p.e. "main")
\param vsCompileTarget: Vertex shader version the high level shader
\param vsCompileTarget Vertex shader version the high level shader
shall be compiled to.
\param pixelShaderProgramFileName: Text file containing the source of
\param pixelShaderProgramFileName Text file containing the source of
the pixel shader program. Set to empty string if no pixel shader shall
be created.
\param pixelShaderEntryPointName: Entry name of the function of the
\param pixelShaderEntryPointName Entry name of the function of the
pixelShaderProgram (p.e. "main")
\param psCompileTarget: Pixel shader version the high level shader
\param psCompileTarget Pixel shader version the high level shader
shall be compiled to.
\param geometryShaderProgramFileName: Name of the source of
\param geometryShaderProgramFileName Name of the source of
the geometry shader program. Set to empty string if no geometry shader
shall be created.
\param geometryShaderEntryPointName: Entry name of the function of the
\param geometryShaderEntryPointName Entry name of the function of the
geometryShaderProgram (p.e. "main")
\param gsCompileTarget: Geometry shader version the high level shader
\param gsCompileTarget Geometry shader version the high level shader
shall be compiled to.
\param inType Type of vertices passed to geometry shader
\param outType Type of vertices created by geometry shader
\param verticesOut Maximal number of vertices created by geometry
shader. If 0, maximal number supported is assumed.
\param callback: Pointer to an implementation of
\param callback Pointer to an implementation of
IShaderConstantSetCallBack in which you can set the needed vertex,
pixel, and geometry shader program constants. Set this to 0 if you
don't need this.
\param baseMaterial: Base material which renderstates will be used to
\param baseMaterial Base material which renderstates will be used to
shade the material.
\param userData: a user data int. This int can be set to any value and
\param userData a user data int. This int can be set to any value and
will be set as parameter in the callback method when calling
OnSetConstants(). In this way it is easily possible to use the same
callback method for multiple materials and distinguish between them
......@@ -191,37 +235,81 @@ public:
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, without geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1.
*/
s32 addHighLevelShaderMaterialFromFiles(
const io::path& vertexShaderProgramFileName,
const io::path& pixelShaderProgramFileName = "",
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0 )
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgramFileName, "main",
EVST_VS_1_1, pixelShaderProgramFileName,
"main", EPST_PS_1_1,
"", "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, with geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1 and geometry shader 4.0.
*/
s32 addHighLevelShaderMaterialFromFiles(
const io::path& vertexShaderProgramFileName,
const io::path& pixelShaderProgramFileName = "",
const io::path& geometryShaderProgramFileName = "",
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0 )
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgramFileName, "main",
EVST_VS_1_1, pixelShaderProgramFileName,
"main", EPST_PS_1_1,
geometryShaderProgramFileName, "main", EGST_GS_4_0,
inType, outType, verticesOut,
callback, baseMaterial, userData);
}
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
/** \param vertexShaderProgram: Text file handle containing the source
/** \param vertexShaderProgram Text file handle containing the source
of the vertex shader program. Set to 0 if no vertex shader shall be
created.
\param vertexShaderEntryPointName: Name of the entry function of the
\param vertexShaderEntryPointName Name of the entry function of the
vertexShaderProgram
\param vsCompileTarget: Vertex shader version the high level shader
\param vsCompileTarget Vertex shader version the high level shader
shall be compiled to.
\param pixelShaderProgram: Text file handle containing the source of
\param pixelShaderProgram Text file handle containing the source of
the pixel shader program. Set to 0 if no pixel shader shall be created.
\param pixelShaderEntryPointName: Entry name of the function of the
\param pixelShaderEntryPointName Entry name of the function of the
pixelShaderProgram (p.e. "main")
\param psCompileTarget: Pixel shader version the high level shader
\param psCompileTarget Pixel shader version the high level shader
shall be compiled to.
\param geometryShaderProgram: Text file handle containing the source of
\param geometryShaderProgram Text file handle containing the source of
the geometry shader program. Set to 0 if no geometry shader shall be
created.
\param geometryShaderEntryPointName: Entry name of the function of the
\param geometryShaderEntryPointName Entry name of the function of the
geometryShaderProgram (p.e. "main")
\param gsCompileTarget: Geometry shader version the high level shader
\param gsCompileTarget Geometry shader version the high level shader
shall be compiled to.
\param inType Type of vertices passed to geometry shader
\param outType Type of vertices created by geometry shader
\param verticesOut Maximal number of vertices created by geometry
shader. If 0, maximal number supported is assumed.
\param callback: Pointer to an implementation of
\param callback Pointer to an implementation of
IShaderConstantSetCallBack in which you can set the needed vertex and
pixel shader program constants. Set this to 0 if you don't need this.
\param baseMaterial: Base material which renderstates will be used to
\param baseMaterial Base material which renderstates will be used to
shade the material.
\param userData: a user data int. This int can be set to any value and
\param userData a user data int. This int can be set to any value and
will be set as parameter in the callback method when calling
OnSetConstants(). In this way it is easily possible to use the same
callback method for multiple materials and distinguish between them
......@@ -277,7 +365,7 @@ public:
The material is added to the VideoDriver like with
IVideoDriver::addMaterialRenderer() and can be used like it had been
added with that method.
\param vertexShaderProgram: String containing the source of the vertex
\param vertexShaderProgram String containing the source of the vertex
shader program. This can be 0 if no vertex program shall be used.
For DX8 programs, the will always input registers look like this: v0:
......@@ -286,14 +374,14 @@ public:
For DX9 programs, you can manually set the registers using the dcl_
statements.
\param pixelShaderProgram: String containing the source of the pixel
\param pixelShaderProgram String containing the source of the pixel
shader program. This can be 0 if you don't want to use a pixel shader.
\param callback: Pointer to an implementation of
\param callback Pointer to an implementation of
IShaderConstantSetCallBack in which you can set the needed vertex and
pixel shader program constants. Set this to 0 if you don't need this.
\param baseMaterial: Base material which renderstates will be used to
\param baseMaterial Base material which renderstates will be used to
shade the material.
\param userData: a user data int. This int can be set to any value and
\param userData a user data int. This int can be set to any value and
will be set as parameter in the callback method when calling
OnSetConstants(). In this way it is easily possible to use the same
callback method for multiple materials and distinguish between them
......@@ -310,14 +398,14 @@ public:
s32 userData = 0) = 0;
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
/** \param vertexShaderProgram: Text file containing the source of the
/** \param vertexShaderProgram Text file containing the source of the
vertex shader program. Set to 0 if no shader shall be created.
\param pixelShaderProgram: Text file containing the source of the pixel
\param pixelShaderProgram Text file containing the source of the pixel
shader program. Set to 0 if no shader shall be created.
\param callback: Pointer to an IShaderConstantSetCallback object to
\param callback Pointer to an IShaderConstantSetCallback object to
which the OnSetConstants function is called.
\param baseMaterial: baseMaterial
\param userData: a user data int. This int can be set to any value and
\param baseMaterial baseMaterial
\param userData a user data int. This int can be set to any value and
will be set as parameter in the callback method when calling
OnSetConstants(). In this way it is easily possible to use the same
callback method for multiple materials and distinguish between them
......@@ -334,15 +422,15 @@ public:
s32 userData = 0) = 0;
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
/** \param vertexShaderProgramFileName: Text file name containing the
/** \param vertexShaderProgramFileName Text file name containing the
source of the vertex shader program. Set to 0 if no shader shall be
created.
\param pixelShaderProgramFileName: Text file name containing the source
\param pixelShaderProgramFileName Text file name containing the source
of the pixel shader program. Set to 0 if no shader shall be created.
\param callback: Pointer to an IShaderConstantSetCallback object on
\param callback Pointer to an IShaderConstantSetCallback object on
which the OnSetConstants function is called.
\param baseMaterial: baseMaterial
\param userData: a user data int. This int can be set to any value and
\param baseMaterial baseMaterial
\param userData a user data int. This int can be set to any value and
will be set as parameter in the callback method when calling
OnSetConstants(). In this way it is easily possible to use the same
callback method for multiple materials and distinguish between them
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment