forked from Mirrorlandia_minetest/irrlicht
Drop old shader material functions
I'm not sure what these actually are, but the situation is the same as the last commit.
This commit is contained in:
parent
92252f70d2
commit
e60921f0cb
@ -155,7 +155,7 @@ public:
|
|||||||
callback, baseMaterial, userData);
|
callback, baseMaterial, userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
|
//! Like addHighLevelShaderMaterial(), 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
|
of the vertex shader program. Set to empty string if no vertex shader
|
||||||
shall be created.
|
shall be created.
|
||||||
@ -279,7 +279,7 @@ public:
|
|||||||
callback, baseMaterial, userData);
|
callback, baseMaterial, userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
|
//! Like addHighLevelShaderMaterial(), 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
|
of the vertex shader program. Set to 0 if no vertex shader shall be
|
||||||
created.
|
created.
|
||||||
@ -356,95 +356,6 @@ public:
|
|||||||
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
|
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
|
||||||
callback, baseMaterial, userData);
|
callback, baseMaterial, userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Adds a new ASM shader material renderer to the VideoDriver
|
|
||||||
/** Note that it is a good idea to call IVideoDriver::queryFeature() in
|
|
||||||
advance to check if the IVideoDriver supports the vertex and/or pixel
|
|
||||||
shader version your are using.
|
|
||||||
|
|
||||||
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
|
|
||||||
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:
|
|
||||||
position, v1: normal, v2: color, v3: texture coordinates, v4: texture
|
|
||||||
coordinates 2 if available.
|
|
||||||
|
|
||||||
For DX9 programs, you can manually set the registers using the dcl_
|
|
||||||
statements.
|
|
||||||
\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
|
|
||||||
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
|
|
||||||
shade the material.
|
|
||||||
\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
|
|
||||||
during the call.
|
|
||||||
\return Returns the number of the material type which can be set in
|
|
||||||
SMaterial::MaterialType to use the renderer. -1 is returned if an
|
|
||||||
error occurred. -1 is returned for example if a vertex or pixel shader
|
|
||||||
program could not be compiled, the error strings are then printed out
|
|
||||||
into the error log, and can be caught with a custom event receiver. */
|
|
||||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0,
|
|
||||||
const c8* pixelShaderProgram = 0,
|
|
||||||
IShaderConstantSetCallBack* callback = 0,
|
|
||||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
|
||||||
s32 userData = 0) = 0;
|
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
|
|
||||||
/** \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
|
|
||||||
shader program. Set to 0 if no shader shall be created.
|
|
||||||
\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
|
|
||||||
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
|
|
||||||
during the call.
|
|
||||||
\return Returns the number of the material type which can be set in
|
|
||||||
SMaterial::MaterialType to use the renderer. -1 is returned if an
|
|
||||||
error occurred. -1 is returned for example if a vertex or pixel shader
|
|
||||||
program could not be compiled, the error strings are then printed out
|
|
||||||
into the error log, and can be caught with a custom event receiver. */
|
|
||||||
virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram,
|
|
||||||
io::IReadFile* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback = 0,
|
|
||||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
|
||||||
s32 userData = 0) = 0;
|
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
|
|
||||||
/** \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
|
|
||||||
of the pixel shader program. Set to 0 if no shader shall be created.
|
|
||||||
\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
|
|
||||||
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
|
|
||||||
during the call.
|
|
||||||
\return Returns the number of the material type which can be set in
|
|
||||||
SMaterial::MaterialType to use the renderer. -1 is returned if an
|
|
||||||
error occurred. -1 is returned for example if a vertex or pixel shader
|
|
||||||
program could not be compiled, the error strings are then printed out
|
|
||||||
into the error log, and can be caught with a custom event receiver. */
|
|
||||||
virtual s32 addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName,
|
|
||||||
const io::path& pixelShaderProgramFileName,
|
|
||||||
IShaderConstantSetCallBack* callback = 0,
|
|
||||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
|
||||||
s32 userData = 0) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,7 +355,6 @@ if(ENABLE_OPENGL)
|
|||||||
${IRRDRVROBJ}
|
${IRRDRVROBJ}
|
||||||
COpenGLCacheHandler.cpp
|
COpenGLCacheHandler.cpp
|
||||||
COpenGLDriver.cpp
|
COpenGLDriver.cpp
|
||||||
COpenGLShaderMaterialRenderer.cpp
|
|
||||||
COpenGLSLMaterialRenderer.cpp
|
COpenGLSLMaterialRenderer.cpp
|
||||||
COpenGLExtensionHandler.cpp
|
COpenGLExtensionHandler.cpp
|
||||||
)
|
)
|
||||||
|
@ -1642,8 +1642,6 @@ s32 CNullDriver::addHighLevelShaderMaterial(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
|
|
||||||
//! but tries to load the programs from files.
|
|
||||||
s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
||||||
const io::path& vertexShaderProgramFileName,
|
const io::path& vertexShaderProgramFileName,
|
||||||
const c8* vertexShaderEntryPointName,
|
const c8* vertexShaderEntryPointName,
|
||||||
@ -1714,8 +1712,6 @@ s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
|
|
||||||
//! but tries to load the programs from files.
|
|
||||||
s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
||||||
io::IReadFile* vertexShaderProgram,
|
io::IReadFile* vertexShaderProgram,
|
||||||
const c8* vertexShaderEntryPointName,
|
const c8* vertexShaderEntryPointName,
|
||||||
@ -1791,109 +1787,6 @@ s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
|
||||||
//! vertex shaders to render geometry.
|
|
||||||
s32 CNullDriver::addShaderMaterial(const c8* vertexShaderProgram,
|
|
||||||
const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback,
|
|
||||||
E_MATERIAL_TYPE baseMaterial,
|
|
||||||
s32 userData)
|
|
||||||
{
|
|
||||||
os::Printer::log("Shader materials not implemented yet in this driver, sorry.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
|
|
||||||
//! programs from files.
|
|
||||||
s32 CNullDriver::addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram,
|
|
||||||
io::IReadFile* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback,
|
|
||||||
E_MATERIAL_TYPE baseMaterial,
|
|
||||||
s32 userData)
|
|
||||||
{
|
|
||||||
c8* vs = 0;
|
|
||||||
c8* ps = 0;
|
|
||||||
|
|
||||||
if (vertexShaderProgram)
|
|
||||||
{
|
|
||||||
const long size = vertexShaderProgram->getSize();
|
|
||||||
if (size)
|
|
||||||
{
|
|
||||||
vs = new c8[size+1];
|
|
||||||
vertexShaderProgram->read(vs, size);
|
|
||||||
vs[size] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pixelShaderProgram)
|
|
||||||
{
|
|
||||||
const long size = pixelShaderProgram->getSize();
|
|
||||||
if (size)
|
|
||||||
{
|
|
||||||
ps = new c8[size+1];
|
|
||||||
pixelShaderProgram->read(ps, size);
|
|
||||||
ps[size] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 result = addShaderMaterial(vs, ps, callback, baseMaterial, userData);
|
|
||||||
|
|
||||||
delete [] vs;
|
|
||||||
delete [] ps;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
|
|
||||||
//! programs from files.
|
|
||||||
s32 CNullDriver::addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName,
|
|
||||||
const io::path& pixelShaderProgramFileName,
|
|
||||||
IShaderConstantSetCallBack* callback,
|
|
||||||
E_MATERIAL_TYPE baseMaterial,
|
|
||||||
s32 userData)
|
|
||||||
{
|
|
||||||
io::IReadFile* vsfile = 0;
|
|
||||||
io::IReadFile* psfile = 0;
|
|
||||||
|
|
||||||
if (vertexShaderProgramFileName.size())
|
|
||||||
{
|
|
||||||
vsfile = FileSystem->createAndOpenFile(vertexShaderProgramFileName);
|
|
||||||
if (!vsfile)
|
|
||||||
{
|
|
||||||
os::Printer::log("Could not open vertex shader program file",
|
|
||||||
vertexShaderProgramFileName, ELL_WARNING);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pixelShaderProgramFileName.size())
|
|
||||||
{
|
|
||||||
psfile = FileSystem->createAndOpenFile(pixelShaderProgramFileName);
|
|
||||||
if (!psfile)
|
|
||||||
{
|
|
||||||
os::Printer::log("Could not open pixel shader program file",
|
|
||||||
pixelShaderProgramFileName, ELL_WARNING);
|
|
||||||
if (vsfile)
|
|
||||||
vsfile->drop();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 result = addShaderMaterialFromFiles(vsfile, psfile, callback,
|
|
||||||
baseMaterial, userData);
|
|
||||||
|
|
||||||
if (psfile)
|
|
||||||
psfile->drop();
|
|
||||||
|
|
||||||
if (vsfile)
|
|
||||||
vsfile->drop();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Creates a render target texture.
|
//! Creates a render target texture.
|
||||||
ITexture* CNullDriver::addRenderTargetTexture(const core::dimension2d<u32>& size,
|
ITexture* CNullDriver::addRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||||
const io::path&name, const ECOLOR_FORMAT format)
|
const io::path&name, const ECOLOR_FORMAT format)
|
||||||
|
@ -464,30 +464,6 @@ namespace video
|
|||||||
//! Returns pointer to the IGPUProgrammingServices interface.
|
//! Returns pointer to the IGPUProgrammingServices interface.
|
||||||
IGPUProgrammingServices* getGPUProgrammingServices() override;
|
IGPUProgrammingServices* getGPUProgrammingServices() override;
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
|
||||||
//! vertex shaders to render geometry.
|
|
||||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0,
|
|
||||||
const c8* pixelShaderProgram = 0,
|
|
||||||
IShaderConstantSetCallBack* callback = 0,
|
|
||||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
|
||||||
s32 userData=0) override;
|
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
|
|
||||||
//! programs from files.
|
|
||||||
virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram = 0,
|
|
||||||
io::IReadFile* pixelShaderProgram = 0,
|
|
||||||
IShaderConstantSetCallBack* callback = 0,
|
|
||||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
|
||||||
s32 userData=0) override;
|
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
|
|
||||||
//! programs from files.
|
|
||||||
virtual s32 addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName,
|
|
||||||
const io::path& pixelShaderProgramFileName,
|
|
||||||
IShaderConstantSetCallBack* callback = 0,
|
|
||||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
|
||||||
s32 userData=0) override;
|
|
||||||
|
|
||||||
//! Returns pointer to material renderer or null
|
//! Returns pointer to material renderer or null
|
||||||
IMaterialRenderer* getMaterialRenderer(u32 idx) const override;
|
IMaterialRenderer* getMaterialRenderer(u32 idx) const override;
|
||||||
|
|
||||||
@ -497,8 +473,7 @@ namespace video
|
|||||||
//! Returns name of the material renderer
|
//! Returns name of the material renderer
|
||||||
const char* getMaterialRendererName(u32 idx) const override;
|
const char* getMaterialRendererName(u32 idx) const override;
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, based on a high level shading
|
//! Adds a new material renderer to the VideoDriver, based on a high level shading language.
|
||||||
//! language. Currently only HLSL in D3D9 is supported.
|
|
||||||
virtual s32 addHighLevelShaderMaterial(
|
virtual s32 addHighLevelShaderMaterial(
|
||||||
const c8* vertexShaderProgram,
|
const c8* vertexShaderProgram,
|
||||||
const c8* vertexShaderEntryPointName = 0,
|
const c8* vertexShaderEntryPointName = 0,
|
||||||
@ -516,8 +491,6 @@ namespace video
|
|||||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||||
s32 userData = 0) override;
|
s32 userData = 0) override;
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
|
|
||||||
//! but tries to load the programs from files.
|
|
||||||
virtual s32 addHighLevelShaderMaterialFromFiles(
|
virtual s32 addHighLevelShaderMaterialFromFiles(
|
||||||
const io::path& vertexShaderProgramFile,
|
const io::path& vertexShaderProgramFile,
|
||||||
const c8* vertexShaderEntryPointName = "main",
|
const c8* vertexShaderEntryPointName = "main",
|
||||||
@ -535,8 +508,6 @@ namespace video
|
|||||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||||
s32 userData = 0) override;
|
s32 userData = 0) override;
|
||||||
|
|
||||||
//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
|
|
||||||
//! but tries to load the programs from files.
|
|
||||||
virtual s32 addHighLevelShaderMaterialFromFiles(
|
virtual s32 addHighLevelShaderMaterialFromFiles(
|
||||||
io::IReadFile* vertexShaderProgram,
|
io::IReadFile* vertexShaderProgram,
|
||||||
const c8* vertexShaderEntryPointName = "main",
|
const c8* vertexShaderEntryPointName = "main",
|
||||||
|
@ -2102,18 +2102,6 @@ COGLES2Driver::~COGLES2Driver()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
|
||||||
//! vertex shaders to render geometry.
|
|
||||||
s32 COGLES2Driver::addShaderMaterial(const c8* vertexShaderProgram,
|
|
||||||
const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback,
|
|
||||||
E_MATERIAL_TYPE baseMaterial, s32 userData)
|
|
||||||
{
|
|
||||||
os::Printer::log("No shader support.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
||||||
s32 COGLES2Driver::addHighLevelShaderMaterial(
|
s32 COGLES2Driver::addHighLevelShaderMaterial(
|
||||||
const c8* vertexShaderProgram,
|
const c8* vertexShaderProgram,
|
||||||
|
@ -205,10 +205,6 @@ namespace video
|
|||||||
//! Uint interface for the above.
|
//! Uint interface for the above.
|
||||||
bool setPixelShaderConstant(s32 index, const u32* ints, int count) override;
|
bool setPixelShaderConstant(s32 index, const u32* ints, int count) override;
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver
|
|
||||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) override;
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver
|
//! Adds a new material renderer to the VideoDriver
|
||||||
virtual s32 addHighLevelShaderMaterial(
|
virtual s32 addHighLevelShaderMaterial(
|
||||||
const c8* vertexShaderProgram,
|
const c8* vertexShaderProgram,
|
||||||
|
@ -2374,17 +2374,6 @@ bool COGLES1Driver::setPixelShaderConstant(s32 index, const u32* ints, int count
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
|
||||||
//! vertex shaders to render geometry.
|
|
||||||
s32 COGLES1Driver::addShaderMaterial(const c8* vertexShaderProgram,
|
|
||||||
const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback,
|
|
||||||
E_MATERIAL_TYPE baseMaterial, s32 userData)
|
|
||||||
{
|
|
||||||
os::Printer::log("No shader support.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
||||||
s32 COGLES1Driver::addHighLevelShaderMaterial(
|
s32 COGLES1Driver::addHighLevelShaderMaterial(
|
||||||
|
@ -201,10 +201,6 @@ namespace video
|
|||||||
//! Uint interface for the above.
|
//! Uint interface for the above.
|
||||||
bool setPixelShaderConstant(s32 index, const u32* ints, int count) override;
|
bool setPixelShaderConstant(s32 index, const u32* ints, int count) override;
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver
|
|
||||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) override;
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver
|
//! Adds a new material renderer to the VideoDriver
|
||||||
virtual s32 addHighLevelShaderMaterial(const c8* vertexShaderProgram, const c8* vertexShaderEntryPointName,
|
virtual s32 addHighLevelShaderMaterial(const c8* vertexShaderProgram, const c8* vertexShaderEntryPointName,
|
||||||
E_VERTEX_SHADER_TYPE vsCompileTarget, const c8* pixelShaderProgram, const c8* pixelShaderEntryPointName,
|
E_VERTEX_SHADER_TYPE vsCompileTarget, const c8* pixelShaderProgram, const c8* pixelShaderEntryPointName,
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include "COpenGLCacheHandler.h"
|
#include "COpenGLCacheHandler.h"
|
||||||
#include "COpenGLMaterialRenderer.h"
|
#include "COpenGLMaterialRenderer.h"
|
||||||
#include "COpenGLShaderMaterialRenderer.h"
|
|
||||||
#include "COpenGLSLMaterialRenderer.h"
|
#include "COpenGLSLMaterialRenderer.h"
|
||||||
|
|
||||||
#include "COpenGLCoreTexture.h"
|
#include "COpenGLCoreTexture.h"
|
||||||
@ -3424,23 +3423,6 @@ bool COpenGLDriver::setPixelShaderConstant(s32 index, const u32* ints, int count
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
|
||||||
//! vertex shaders to render geometry.
|
|
||||||
s32 COpenGLDriver::addShaderMaterial(const c8* vertexShaderProgram,
|
|
||||||
const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback,
|
|
||||||
E_MATERIAL_TYPE baseMaterial, s32 userData)
|
|
||||||
{
|
|
||||||
s32 nr = -1;
|
|
||||||
COpenGLShaderMaterialRenderer* r = new COpenGLShaderMaterialRenderer(
|
|
||||||
this, nr, vertexShaderProgram, pixelShaderProgram,
|
|
||||||
callback, baseMaterial, userData);
|
|
||||||
|
|
||||||
r->drop();
|
|
||||||
return nr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
||||||
s32 COpenGLDriver::addHighLevelShaderMaterial(
|
s32 COpenGLDriver::addHighLevelShaderMaterial(
|
||||||
const c8* vertexShaderProgram,
|
const c8* vertexShaderProgram,
|
||||||
|
@ -281,12 +281,6 @@ namespace video
|
|||||||
//! Returns whether disabling was successful or not.
|
//! Returns whether disabling was successful or not.
|
||||||
bool disableTextures(u32 fromStage=0);
|
bool disableTextures(u32 fromStage=0);
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using
|
|
||||||
//! extGLGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status)
|
|
||||||
//! pixel and/or vertex shaders to render geometry.
|
|
||||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) override;
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
||||||
virtual s32 addHighLevelShaderMaterial(
|
virtual s32 addHighLevelShaderMaterial(
|
||||||
const c8* vertexShaderProgram,
|
const c8* vertexShaderProgram,
|
||||||
|
@ -1,403 +0,0 @@
|
|||||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
||||||
// This file is part of the "Irrlicht Engine".
|
|
||||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
||||||
|
|
||||||
#include "COpenGLShaderMaterialRenderer.h"
|
|
||||||
|
|
||||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
|
||||||
|
|
||||||
#include "IGPUProgrammingServices.h"
|
|
||||||
#include "IShaderConstantSetCallBack.h"
|
|
||||||
#include "IVideoDriver.h"
|
|
||||||
#include "os.h"
|
|
||||||
|
|
||||||
#include "COpenGLDriver.h"
|
|
||||||
#include "COpenGLCacheHandler.h"
|
|
||||||
#include "COpenGLMaterialRenderer.h"
|
|
||||||
|
|
||||||
namespace irr
|
|
||||||
{
|
|
||||||
namespace video
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
//! Constructor
|
|
||||||
COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(video::COpenGLDriver* driver,
|
|
||||||
s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData)
|
|
||||||
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), AlphaTest(false),
|
|
||||||
VertexShader(0), UserData(userData)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
setDebugName("COpenGLShaderMaterialRenderer");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PixelShader.set_used(4);
|
|
||||||
for (u32 i=0; i<4; ++i)
|
|
||||||
{
|
|
||||||
PixelShader[i]=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (baseMaterial)
|
|
||||||
{
|
|
||||||
case EMT_TRANSPARENT_VERTEX_ALPHA:
|
|
||||||
case EMT_TRANSPARENT_ALPHA_CHANNEL:
|
|
||||||
Alpha = true;
|
|
||||||
break;
|
|
||||||
case EMT_ONETEXTURE_BLEND:
|
|
||||||
Blending = true;
|
|
||||||
break;
|
|
||||||
case EMT_TRANSPARENT_ALPHA_CHANNEL_REF:
|
|
||||||
AlphaTest = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CallBack)
|
|
||||||
CallBack->grab();
|
|
||||||
|
|
||||||
init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, EVT_STANDARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! constructor only for use by derived classes who want to
|
|
||||||
//! create a fall back material for example.
|
|
||||||
COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
|
|
||||||
IShaderConstantSetCallBack* callback,
|
|
||||||
E_MATERIAL_TYPE baseMaterial, s32 userData)
|
|
||||||
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), AlphaTest(false),
|
|
||||||
VertexShader(0), UserData(userData)
|
|
||||||
{
|
|
||||||
PixelShader.set_used(4);
|
|
||||||
for (u32 i=0; i<4; ++i)
|
|
||||||
{
|
|
||||||
PixelShader[i]=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (baseMaterial)
|
|
||||||
{
|
|
||||||
case EMT_TRANSPARENT_VERTEX_ALPHA:
|
|
||||||
case EMT_TRANSPARENT_ALPHA_CHANNEL:
|
|
||||||
Alpha = true;
|
|
||||||
break;
|
|
||||||
case EMT_ONETEXTURE_BLEND:
|
|
||||||
Blending = true;
|
|
||||||
break;
|
|
||||||
case EMT_TRANSPARENT_ALPHA_CHANNEL_REF:
|
|
||||||
AlphaTest = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CallBack)
|
|
||||||
CallBack->grab();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Destructor
|
|
||||||
COpenGLShaderMaterialRenderer::~COpenGLShaderMaterialRenderer()
|
|
||||||
{
|
|
||||||
if (CallBack)
|
|
||||||
CallBack->drop();
|
|
||||||
|
|
||||||
if (VertexShader)
|
|
||||||
Driver->extGlDeletePrograms(1, &VertexShader);
|
|
||||||
|
|
||||||
for (u32 i=0; i<PixelShader.size(); ++i)
|
|
||||||
if (PixelShader[i])
|
|
||||||
Driver->extGlDeletePrograms(1, &PixelShader[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void COpenGLShaderMaterialRenderer::init(s32& outMaterialTypeNr,
|
|
||||||
const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
|
||||||
E_VERTEX_TYPE type)
|
|
||||||
{
|
|
||||||
outMaterialTypeNr = -1;
|
|
||||||
|
|
||||||
bool success;
|
|
||||||
|
|
||||||
// create vertex shader
|
|
||||||
success=createVertexShader(vertexShaderProgram);
|
|
||||||
|
|
||||||
// create pixel shader
|
|
||||||
if (!createPixelShader(pixelShaderProgram) || !success)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// register as a new material
|
|
||||||
outMaterialTypeNr = Driver->addMaterialRenderer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
|
|
||||||
{
|
|
||||||
// call callback to set shader constants
|
|
||||||
if (CallBack && (VertexShader || PixelShader[0]))
|
|
||||||
CallBack->OnSetConstants(service, UserData);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial,
|
|
||||||
bool resetAllRenderstates, video::IMaterialRendererServices* services)
|
|
||||||
{
|
|
||||||
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_ENABLE)
|
|
||||||
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE_TO_DISABLE);
|
|
||||||
else
|
|
||||||
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE);
|
|
||||||
|
|
||||||
COpenGLCacheHandler* cacheHandler = Driver->getCacheHandler();
|
|
||||||
|
|
||||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
|
||||||
{
|
|
||||||
if (VertexShader)
|
|
||||||
{
|
|
||||||
// set new vertex shader
|
|
||||||
#ifdef GL_ARB_vertex_program
|
|
||||||
Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader);
|
|
||||||
glEnable(GL_VERTEX_PROGRAM_ARB);
|
|
||||||
#elif defined(GL_NV_vertex_program)
|
|
||||||
Driver->extGlBindProgram(GL_VERTEX_PROGRAM_NV, VertexShader);
|
|
||||||
glEnable(GL_VERTEX_PROGRAM_NV);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// set new pixel shader
|
|
||||||
if (PixelShader[0])
|
|
||||||
{
|
|
||||||
GLuint nextShader=PixelShader[0];
|
|
||||||
if (material.FogEnable)
|
|
||||||
{
|
|
||||||
GLint curFogMode;
|
|
||||||
glGetIntegerv(GL_FOG_MODE, &curFogMode);
|
|
||||||
// if (Driver->LinearFog && PixelShader[1])
|
|
||||||
if (curFogMode==GL_LINEAR && PixelShader[1])
|
|
||||||
nextShader=PixelShader[1];
|
|
||||||
// else if (!Driver->LinearFog && PixelShader[2])
|
|
||||||
else if (curFogMode==GL_EXP && PixelShader[2])
|
|
||||||
nextShader=PixelShader[2];
|
|
||||||
else if (curFogMode==GL_EXP2 && PixelShader[3])
|
|
||||||
nextShader=PixelShader[3];
|
|
||||||
}
|
|
||||||
#ifdef GL_ARB_fragment_program
|
|
||||||
Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, nextShader);
|
|
||||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
|
||||||
#elif defined(GL_NV_fragment_program)
|
|
||||||
Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_NV, nextShader);
|
|
||||||
glEnable(GL_FRAGMENT_PROGRAM_NV);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
|
||||||
|
|
||||||
if (Alpha)
|
|
||||||
{
|
|
||||||
cacheHandler->setBlend(true);
|
|
||||||
cacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
else if (Blending)
|
|
||||||
{
|
|
||||||
E_BLEND_FACTOR srcRGBFact,dstRGBFact,srcAlphaFact,dstAlphaFact;
|
|
||||||
E_MODULATE_FUNC modulate;
|
|
||||||
u32 alphaSource;
|
|
||||||
unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulate, alphaSource, material.MaterialTypeParam);
|
|
||||||
|
|
||||||
if (Driver->queryFeature(EVDF_BLEND_SEPARATE))
|
|
||||||
{
|
|
||||||
cacheHandler->setBlendFuncSeparate(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact),
|
|
||||||
Driver->getGLBlend(srcAlphaFact), Driver->getGLBlend(dstAlphaFact));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cacheHandler->setBlendFunc(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact));
|
|
||||||
}
|
|
||||||
|
|
||||||
cacheHandler->setBlend(true);
|
|
||||||
}
|
|
||||||
else if (AlphaTest)
|
|
||||||
{
|
|
||||||
cacheHandler->setAlphaTest(true);
|
|
||||||
cacheHandler->setAlphaFunc(GL_GREATER, 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CallBack)
|
|
||||||
CallBack->OnSetMaterial(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void COpenGLShaderMaterialRenderer::OnUnsetMaterial()
|
|
||||||
{
|
|
||||||
// disable vertex shader
|
|
||||||
#ifdef GL_ARB_vertex_program
|
|
||||||
if (VertexShader)
|
|
||||||
glDisable(GL_VERTEX_PROGRAM_ARB);
|
|
||||||
#elif defined(GL_NV_vertex_program)
|
|
||||||
if (VertexShader)
|
|
||||||
glDisable(GL_VERTEX_PROGRAM_NV);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GL_ARB_fragment_program
|
|
||||||
if (PixelShader[0])
|
|
||||||
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
|
||||||
#elif defined(GL_NV_fragment_program)
|
|
||||||
if (PixelShader[0])
|
|
||||||
glDisable(GL_FRAGMENT_PROGRAM_NV);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
COpenGLCacheHandler* cacheHandler = Driver->getCacheHandler();
|
|
||||||
if (Alpha || Blending)
|
|
||||||
{
|
|
||||||
cacheHandler->setBlend(false);
|
|
||||||
}
|
|
||||||
else if (AlphaTest)
|
|
||||||
{
|
|
||||||
cacheHandler->setAlphaTest(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns if the material is transparent.
|
|
||||||
bool COpenGLShaderMaterialRenderer::isTransparent() const
|
|
||||||
{
|
|
||||||
return (Alpha || Blending);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// This method needs a properly cleaned error state before the checked instruction is called
|
|
||||||
bool COpenGLShaderMaterialRenderer::checkError(const irr::c8* type)
|
|
||||||
{
|
|
||||||
#if defined(GL_ARB_vertex_program) || defined(GL_NV_vertex_program) || defined(GL_ARB_fragment_program) || defined(GL_NV_fragment_program)
|
|
||||||
GLenum g = glGetError();
|
|
||||||
if (g == GL_NO_ERROR)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
core::stringc errString = type;
|
|
||||||
errString += " compilation failed";
|
|
||||||
|
|
||||||
errString += " at position ";
|
|
||||||
GLint errPos=-1;
|
|
||||||
#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
|
|
||||||
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos );
|
|
||||||
#else
|
|
||||||
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_NV, &errPos );
|
|
||||||
#endif
|
|
||||||
errString += core::stringc(s32(errPos));
|
|
||||||
errString += ":\n";
|
|
||||||
#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
|
|
||||||
errString += reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
|
||||||
#else
|
|
||||||
errString += reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_NV));
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
core::stringc errString("Shaders not supported.");
|
|
||||||
#endif
|
|
||||||
os::Printer::log(errString.c_str(), ELL_ERROR);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool COpenGLShaderMaterialRenderer::createPixelShader(const c8* pxsh)
|
|
||||||
{
|
|
||||||
if (!pxsh)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
const core::stringc inshdr(pxsh);
|
|
||||||
core::stringc shdr;
|
|
||||||
const s32 pos = inshdr.find("#_IRR_FOG_MODE_");
|
|
||||||
const u32 numShaders = (-1 != pos)?4:1;
|
|
||||||
|
|
||||||
for (u32 i=0; i<numShaders; ++i)
|
|
||||||
{
|
|
||||||
if (i==0)
|
|
||||||
{
|
|
||||||
shdr=inshdr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shdr = inshdr.subString(0, pos);
|
|
||||||
switch (i) {
|
|
||||||
case 1: shdr += "OPTION ARB_fog_linear;"; break;
|
|
||||||
case 2: shdr += "OPTION ARB_fog_exp;"; break;
|
|
||||||
case 3: shdr += "OPTION ARB_fog_exp2;"; break;
|
|
||||||
}
|
|
||||||
shdr += inshdr.subString(pos+16, inshdr.size()-pos-16);
|
|
||||||
}
|
|
||||||
Driver->extGlGenPrograms(1, &PixelShader[i]);
|
|
||||||
#ifdef GL_ARB_fragment_program
|
|
||||||
Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[i]);
|
|
||||||
#elif defined GL_NV_fragment_program
|
|
||||||
Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_NV, PixelShader[i]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// clear error buffer
|
|
||||||
while(glGetError() != GL_NO_ERROR)
|
|
||||||
{}
|
|
||||||
|
|
||||||
#ifdef GL_ARB_fragment_program
|
|
||||||
// compile
|
|
||||||
Driver->extGlProgramString(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
|
||||||
shdr.size(), shdr.c_str());
|
|
||||||
#elif defined GL_NV_fragment_program
|
|
||||||
Driver->extGlLoadProgram(GL_FRAGMENT_PROGRAM_NV, PixelShader[i],
|
|
||||||
shdr.size(), shdr.c_str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (checkError("Pixel shader"))
|
|
||||||
{
|
|
||||||
Driver->extGlDeletePrograms(1, &PixelShader[i]);
|
|
||||||
PixelShader[i]=0;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool COpenGLShaderMaterialRenderer::createVertexShader(const c8* vtxsh)
|
|
||||||
{
|
|
||||||
if (!vtxsh)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
Driver->extGlGenPrograms(1, &VertexShader);
|
|
||||||
#ifdef GL_ARB_vertex_program
|
|
||||||
Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader);
|
|
||||||
#elif defined GL_NV_vertex_program
|
|
||||||
Driver->extGlBindProgram(GL_VERTEX_PROGRAM_NV, VertexShader);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// clear error buffer
|
|
||||||
while(glGetError() != GL_NO_ERROR)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// compile
|
|
||||||
#ifdef GL_ARB_vertex_program
|
|
||||||
Driver->extGlProgramString(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
|
||||||
(GLsizei)strlen(vtxsh), vtxsh);
|
|
||||||
#elif defined GL_NV_vertex_program
|
|
||||||
Driver->extGlLoadProgram(GL_VERTEX_PROGRAM_NV, VertexShader,
|
|
||||||
(GLsizei)strlen(vtxsh), vtxsh);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (checkError("Vertex shader"))
|
|
||||||
{
|
|
||||||
Driver->extGlDeletePrograms(1, &VertexShader);
|
|
||||||
VertexShader=0;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace video
|
|
||||||
} // end namespace irr
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
|||||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
||||||
// This file is part of the "Irrlicht Engine".
|
|
||||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
|
||||||
|
|
||||||
#include "IMaterialRenderer.h"
|
|
||||||
|
|
||||||
#include "COpenGLCommon.h"
|
|
||||||
|
|
||||||
namespace irr
|
|
||||||
{
|
|
||||||
namespace video
|
|
||||||
{
|
|
||||||
|
|
||||||
class COpenGLDriver;
|
|
||||||
class IShaderConstantSetCallBack;
|
|
||||||
|
|
||||||
//! Class for using vertex and pixel shaders with OpenGL (asm not glsl!)
|
|
||||||
class COpenGLShaderMaterialRenderer : public IMaterialRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
//! Constructor
|
|
||||||
COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
|
|
||||||
s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData);
|
|
||||||
|
|
||||||
//! Destructor
|
|
||||||
virtual ~COpenGLShaderMaterialRenderer();
|
|
||||||
|
|
||||||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
|
||||||
bool resetAllRenderstates, IMaterialRendererServices* services) override;
|
|
||||||
|
|
||||||
bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) override;
|
|
||||||
|
|
||||||
void OnUnsetMaterial() override;
|
|
||||||
|
|
||||||
//! Returns if the material is transparent.
|
|
||||||
bool isTransparent() const override;
|
|
||||||
|
|
||||||
//! Access the callback provided by the users when creating shader materials
|
|
||||||
IShaderConstantSetCallBack* getShaderConstantSetCallBack() const override
|
|
||||||
{
|
|
||||||
return CallBack;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
//! constructor only for use by derived classes who want to
|
|
||||||
//! create a fall back material for example.
|
|
||||||
COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
|
|
||||||
IShaderConstantSetCallBack* callback,
|
|
||||||
E_MATERIAL_TYPE baseMaterial, s32 userData=0);
|
|
||||||
|
|
||||||
// must not be called more than once!
|
|
||||||
void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram,
|
|
||||||
const c8* pixelShaderProgram, E_VERTEX_TYPE type);
|
|
||||||
|
|
||||||
bool createPixelShader(const c8* pxsh);
|
|
||||||
bool createVertexShader(const c8* vtxsh);
|
|
||||||
bool checkError(const irr::c8* type);
|
|
||||||
|
|
||||||
COpenGLDriver* Driver;
|
|
||||||
IShaderConstantSetCallBack* CallBack;
|
|
||||||
|
|
||||||
// I didn't write this, but here's my understanding:
|
|
||||||
// Those flags seem to be exclusive so far (so could be an enum).
|
|
||||||
// Maybe the idea was to make them non-exclusive in future (basically having a shader-material)
|
|
||||||
// Actually currently there's not even any need to cache them (probably even slower than not doing so).
|
|
||||||
// They seem to be mostly for downward compatibility.
|
|
||||||
// I suppose the idea is to use SMaterial.BlendOperation + SMaterial.BlendFactor and a simple non-transparent type as base for more flexibility in the future.
|
|
||||||
// Note that SMaterial.BlendOperation + SMaterial.BlendFactor are in some drivers already evaluated before OnSetMaterial.
|
|
||||||
bool Alpha;
|
|
||||||
bool Blending;
|
|
||||||
bool AlphaTest;
|
|
||||||
|
|
||||||
GLuint VertexShader;
|
|
||||||
// We have 4 values here, [0] is the non-fog version, the other three are
|
|
||||||
// ARB_fog_linear, ARB_fog_exp, and ARB_fog_exp2 in that order
|
|
||||||
core::array<GLuint> PixelShader;
|
|
||||||
s32 UserData;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace video
|
|
||||||
} // end namespace irr
|
|
||||||
|
|
||||||
#endif
|
|
@ -1739,18 +1739,6 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
|
||||||
//! vertex shaders to render geometry.
|
|
||||||
s32 COpenGL3DriverBase::addShaderMaterial(const c8* vertexShaderProgram,
|
|
||||||
const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback,
|
|
||||||
E_MATERIAL_TYPE baseMaterial, s32 userData)
|
|
||||||
{
|
|
||||||
os::Printer::log("No shader support.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
||||||
s32 COpenGL3DriverBase::addHighLevelShaderMaterial(
|
s32 COpenGL3DriverBase::addHighLevelShaderMaterial(
|
||||||
const c8* vertexShaderProgram,
|
const c8* vertexShaderProgram,
|
||||||
|
@ -186,10 +186,6 @@ namespace video
|
|||||||
//! Uint interface for the above.
|
//! Uint interface for the above.
|
||||||
bool setPixelShaderConstant(s32 index, const u32* ints, int count) override;
|
bool setPixelShaderConstant(s32 index, const u32* ints, int count) override;
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver
|
|
||||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
|
||||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) override;
|
|
||||||
|
|
||||||
//! Adds a new material renderer to the VideoDriver
|
//! Adds a new material renderer to the VideoDriver
|
||||||
virtual s32 addHighLevelShaderMaterial(
|
virtual s32 addHighLevelShaderMaterial(
|
||||||
const c8* vertexShaderProgram,
|
const c8* vertexShaderProgram,
|
||||||
|
Loading…
Reference in New Issue
Block a user