Commit 2dc10511 authored by hybrid's avatar hybrid

Added a name parameter to render target textures just as for usual textures.

Exposed findTexture in IVideoDriver to check if a texture was already loaded.
Reordered some more OpenGL render state settings in the materials.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@783 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 9fc207d1
......@@ -196,7 +196,7 @@ namespace video
\return Returns a pointer to the created texture or 0 if the texture could not
be created. If you no longer need the image, you should call ITexture::drop().
See IUnknown::drop() for more information. */
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size) = 0;
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name = 0) = 0;
//! Removes a texture from the texture cache and deletes it, freeing lot of memory.
/** Please note that after calling this, the pointer to the ITexture
......@@ -788,6 +788,9 @@ namespace video
//! Returns an image created from the last rendered frame.
virtual IImage* createScreenShot() = 0;
//! looks if the image is already loaded
virtual video::ITexture* findTexture(const c8* filename) = 0;
};
} // end namespace video
......
......@@ -763,9 +763,9 @@ bool CD3D8Driver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer
}
//! Creates a render target texture.
ITexture* CD3D8Driver::createRenderTargetTexture(const core::dimension2d<s32>& size)
ITexture* CD3D8Driver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
{
return new CD3D8Texture(this, size, 0);
return new CD3D8Texture(this, size, name);
}
......
......@@ -175,7 +175,7 @@ namespace video
virtual IVideoDriver* getVideoDriver();
//! Creates a render target texture.
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size);
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
//! Clears the ZBuffer.
virtual void clearZBuffer();
......
......@@ -2045,9 +2045,9 @@ IVideoDriver* CD3D9Driver::getVideoDriver()
//! Creates a render target texture.
ITexture* CD3D9Driver::createRenderTargetTexture(const core::dimension2d<s32>& size)
ITexture* CD3D9Driver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
{
return new CD3D9Texture(this, size, 0);
return new CD3D9Texture(this, size, name);
}
......
......@@ -169,7 +169,7 @@ namespace video
virtual IVideoDriver* getVideoDriver();
//! Creates a render target texture.
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size);
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
//! Clears the ZBuffer.
virtual void clearZBuffer();
......
......@@ -1696,7 +1696,7 @@ s32 CNullDriver::addShaderMaterialFromFiles(const c8* vertexShaderProgramFileNam
}
//! Creates a render target texture.
ITexture* CNullDriver::createRenderTargetTexture(const core::dimension2d<s32>& size)
ITexture* CNullDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
{
return 0;
}
......
......@@ -248,7 +248,7 @@ namespace video
virtual void removeAllTextures();
//! Creates a render target texture.
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size);
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
//! Creates an 1bit alpha channel of the texture based of an color key.
virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color);
......@@ -398,14 +398,14 @@ namespace video
//! Fills an SMaterial structure from attributes.
virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes);
//! looks if the image is already loaded
virtual video::ITexture* findTexture(const c8* filename);
protected:
//! deletes all textures
void deleteAllTextures();
//! looks if the image is already loaded
video::ITexture* findTexture(const c8* filename);
//! opens the file and loads it into the surface
video::ITexture* loadTextureFromFile(io::IReadFile* file, const c8* hashName = 0);
......
......@@ -550,19 +550,19 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].Pos);
glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].Normal);
// texture coordinates
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].TCoords);
if (MultiTextureExtension)
{
extGlClientActiveTexture(GL_TEXTURE1_ARB);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].TCoords2);
extGlClientActiveTexture(GL_TEXTURE0_ARB);
}
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].TCoords);
break;
case EVT_TANGENTS:
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Pos);
glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Normal);
// texture coordinates
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].TCoords);
if (MultiTextureExtension)
{
extGlClientActiveTexture(GL_TEXTURE1_ARB);
......@@ -572,10 +572,7 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
extGlClientActiveTexture(GL_TEXTURE2_ARB);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Binormal);
extGlClientActiveTexture(GL_TEXTURE0_ARB);
}
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].TCoords);
break;
}
......@@ -615,9 +612,6 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
glFlush();
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
if (MultiTextureExtension)
{
if (vType==EVT_TANGENTS)
......@@ -625,13 +619,16 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
extGlClientActiveTexture(GL_TEXTURE2_ARB);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
if (vType!=EVT_STANDARD && MultiTextureExtension)
if (vType!=EVT_STANDARD)
{
extGlClientActiveTexture(GL_TEXTURE1_ARB);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
extGlClientActiveTexture(GL_TEXTURE0_ARB);
}
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
......@@ -2068,21 +2065,23 @@ IGPUProgrammingServices* COpenGLDriver::getGPUProgrammingServices()
return this;
}
ITexture* COpenGLDriver::createRenderTargetTexture(const core::dimension2d<s32>& size)
ITexture* COpenGLDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
{
//disable mip-mapping
bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
video::ITexture* rtt = 0;
if (name==0)
name="rt";
#if defined(GL_EXT_framebuffer_object)
// if driver supports FrameBufferObjects, use them
if (queryFeature(EVDF_FRAMEBUFFER_OBJECT))
rtt = new COpenGLTexture(size, PackedDepthStencilExtension, "rt", this);
rtt = new COpenGLTexture(size, PackedDepthStencilExtension, name, this);
else
#endif
{
rtt = addTexture(size, "rt");
rtt = addTexture(size, name);
if (rtt)
rtt->grab();
}
......
......@@ -96,20 +96,20 @@ namespace video
//! destructor
virtual ~COpenGLDriver();
//! presents the rendered scene on the screen, returns false if failed
virtual bool endScene( s32 windowId, core::rect<s32>* sourceRect=0 );
//! clears the zbuffer
virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color);
//! presents the rendered scene on the screen, returns false if failed
virtual bool endScene( s32 windowId, core::rect<s32>* sourceRect=0 );
//! sets transformation
virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
//! draws a vertex primitive list
void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
//! queries the features of the driver, returns true if feature is available
bool queryFeature(E_VIDEO_DRIVER_FEATURE feature)
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature)
{
return COpenGLExtensionHandler::queryFeature(feature);
}
......@@ -222,7 +222,7 @@ namespace video
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state);
//! Can be called by an IMaterialRenderer to make its work easier.
void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
bool resetAllRenderstates);
//! Sets a vertex shader constant.
......@@ -247,17 +247,17 @@ namespace video
//! Adds a new material renderer to the VideoDriver, using extGLGetObjectParameterivARB(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) pixel and/or
//! vertex shaders to render geometry.
s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData);
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
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_PIXEL_SHADER_TYPE psCompileTarget, IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial,
s32 userData);
//! Returns pointer to the IGPUProgrammingServices interface.
IGPUProgrammingServices* getGPUProgrammingServices();
virtual IGPUProgrammingServices* getGPUProgrammingServices();
//! Returns a pointer to the IVideoDriver interface. (Implementation for
//! IMaterialRendererServices)
......@@ -268,9 +268,9 @@ namespace video
//! call.
virtual u32 getMaximalPrimitiveCount();
ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size);
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer,
virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer,
bool clearZBuffer, SColor color);
//! Clears the ZBuffer.
......@@ -301,7 +301,7 @@ namespace video
void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel);
// returns the current size of the screen or rendertarget
core::dimension2d<s32> getCurrentRenderTargetSize();
virtual core::dimension2d<s32> getCurrentRenderTargetSize();
void createMaterialRenderers();
......
......@@ -46,6 +46,8 @@ public:
{
Driver->disableTextures(1);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
// thanks to Murphy, the following line removed some
......@@ -54,7 +56,6 @@ public:
glDisable(GL_ALPHA_TEST);
}
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
};
......@@ -72,7 +73,6 @@ public:
{
Driver->disableTextures(1);
Driver->setTexture(0, material.Textures[0]);
services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
// if (material.MaterialType != lastMaterial.MaterialType ||
......@@ -165,6 +165,7 @@ public:
Driver->setTexture(1, material.Textures[1]);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
......@@ -195,6 +196,8 @@ public:
{
Driver->disableTextures(1);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if ((material.MaterialType != lastMaterial.MaterialType) || resetAllRenderstates)
{
glDisable(GL_ALPHA_TEST);
......@@ -203,8 +206,6 @@ public:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_BLEND);
}
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
virtual void OnUnsetMaterial()
......@@ -233,6 +234,7 @@ public:
{
Driver->disableTextures(1);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
......@@ -250,7 +252,6 @@ public:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
}
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
glDepthMask(GL_FALSE);
}
......@@ -289,7 +290,6 @@ public:
{
Driver->disableTextures(1);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates
......@@ -343,7 +343,6 @@ public:
{
Driver->disableTextures(1);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -383,7 +382,6 @@ public:
Driver->disableTextures(2);
Driver->setTexture(1, material.Textures[1]);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -479,7 +477,6 @@ public:
Driver->disableTextures(2);
Driver->setTexture(1, material.Textures[1]);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -524,7 +521,6 @@ public:
{
Driver->disableTextures(1);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -573,7 +569,6 @@ public:
Driver->disableTextures(2);
Driver->setTexture(1, material.Textures[1]);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -644,7 +639,6 @@ public:
Driver->disableTextures(2);
Driver->setTexture(1, material.Textures[1]);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......
......@@ -3,7 +3,7 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
// This file was originally written by William Finlayson.
// I (Nikolaus Gebhardt) did some minor modifications and changes to it and integrated
// I (Nikolaus Gebhardt) did some minor modifications and changes to it and integrated
// it into Irrlicht. Thanks a lot to William for his work on this and that he gave me
// his permission to add it into Irrlicht using the zlib license.
......@@ -28,11 +28,11 @@ namespace video
//! Constructor
COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* driver,
COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* driver,
s32& outMaterialTypeNr, const c8* vertexShaderProgram,
const c8* vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const c8* pixelShaderProgram,
const c8* pixelShaderProgram,
const c8* pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
IShaderConstantSetCallBack* callback,
......@@ -52,7 +52,7 @@ COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* drive
CallBack->grab();
if (!Driver->queryFeature(EVDF_ARB_GLSL))
return;
return;
init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram);
}
......@@ -61,8 +61,8 @@ COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* drive
//! constructor only for use by derived classes who want to
//! create a fall back material for example.
COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(COpenGLDriver* driver,
IShaderConstantSetCallBack* callback,
IMaterialRenderer* baseMaterial, s32 userData)
IShaderConstantSetCallBack* callback,
IMaterialRenderer* baseMaterial, s32 userData)
: Driver(driver), CallBack(callback), BaseMaterial(baseMaterial),
Program(0), UserData(userData)
{
......@@ -92,32 +92,32 @@ COpenGLSLMaterialRenderer::~COpenGLSLMaterialRenderer()
BaseMaterial->drop();
}
void COpenGLSLMaterialRenderer::init(s32& outMaterialTypeNr,
const c8* vertexShaderProgram,
void COpenGLSLMaterialRenderer::init(s32& outMaterialTypeNr,
const c8* vertexShaderProgram,
const c8* pixelShaderProgram)
{
outMaterialTypeNr = -1;
if (!createProgram())
if (!createProgram())
return;
#if defined(GL_ARB_vertex_shader) && defined (GL_ARB_fragment_shader)
if (!createShader(GL_VERTEX_SHADER_ARB, vertexShaderProgram))
return;
if (!createShader(GL_FRAGMENT_SHADER_ARB, pixelShaderProgram))
if (!createShader(GL_FRAGMENT_SHADER_ARB, pixelShaderProgram))
return;
#endif
if (!linkProgram())
if (!linkProgram())
return;
// register myself as new material
outMaterialTypeNr = Driver->addMaterialRenderer(this);
}
bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service,
E_VERTEX_TYPE vtxtype)
bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service,
E_VERTEX_TYPE vtxtype)
{
// call callback to set shader constants
if (CallBack && (Program))
......@@ -128,9 +128,9 @@ bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service,
void COpenGLSLMaterialRenderer::OnSetMaterial(video::SMaterial& material,
const video::SMaterial& lastMaterial,
bool resetAllRenderstates,
video::IMaterialRendererServices* services)
const video::SMaterial& lastMaterial,
bool resetAllRenderstates,
video::IMaterialRendererServices* services)
{
Driver->setTexture(3, material.Textures[3]);
Driver->setTexture(2, material.Textures[2]);
......@@ -155,7 +155,7 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(video::SMaterial& material,
void COpenGLSLMaterialRenderer::OnUnsetMaterial()
{
Driver->extGlUseProgramObject(0);
if (BaseMaterial)
BaseMaterial->OnUnsetMaterial();
}
......@@ -163,7 +163,7 @@ void COpenGLSLMaterialRenderer::OnUnsetMaterial()
//! Returns if the material is transparent.
bool COpenGLSLMaterialRenderer::isTransparent()
{
return BaseMaterial ? BaseMaterial->isTransparent() : false;
return BaseMaterial ? BaseMaterial->isTransparent() : false;
}
bool COpenGLSLMaterialRenderer::createProgram()
......@@ -193,7 +193,7 @@ bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char* shad
GLsizei length;
#ifdef GL_ARB_shader_objects
Driver->extGlGetObjectParameteriv(shaderHandle,
GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength);
GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength);
#endif
GLcharARB *pInfoLog = new GLcharARB[maxLength];
Driver->extGlGetInfoLog(shaderHandle, maxLength, &length, pInfoLog);
......@@ -226,7 +226,7 @@ bool COpenGLSLMaterialRenderer::linkProgram()
GLsizei length;
#ifdef GL_ARB_shader_objects
Driver->extGlGetObjectParameteriv(Program,
GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength);
GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength);
#endif
GLcharARB *pInfoLog = new GLcharARB[maxLength];
Driver->extGlGetInfoLog(Program, maxLength, &length, pInfoLog);
......@@ -235,7 +235,7 @@ bool COpenGLSLMaterialRenderer::linkProgram()
return false;
}
// get uniforms information
int num = 0;
......@@ -254,7 +254,7 @@ bool COpenGLSLMaterialRenderer::linkProgram()
Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, &maxlen);
#endif
if (maxlen == 0)
if (maxlen == 0)
{
os::Printer::log("GLSL: failed to retrieve uniform information");
return false;
......@@ -284,79 +284,80 @@ bool COpenGLSLMaterialRenderer::linkProgram()
void COpenGLSLMaterialRenderer::setBasicRenderStates(const SMaterial& material,
const SMaterial& lastMaterial,
bool resetAllRenderstates)
void COpenGLSLMaterialRenderer::setBasicRenderStates(const SMaterial& material,
const SMaterial& lastMaterial,
bool resetAllRenderstates)
{
// forward
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
// forward
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
bool COpenGLSLMaterialRenderer::setVertexShaderConstant(const c8* name, const f32* floats, int count)
{
return setPixelShaderConstant(name, floats, count);
return setPixelShaderConstant(name, floats, count);
}
void COpenGLSLMaterialRenderer::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{
os::Printer::log("Cannot set constant, please use high level shader call instead.");
os::Printer::log("Cannot set constant, please use high level shader call instead.");
}
bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const f32* floats, int count)
{
int i = 0, num = (int)UniformInfo.size();
int i = 0, num = (int)UniformInfo.size();
for (; i < num; i++)
for (; i < num; i++)
{
if (UniformInfo[i].name == name)
if (UniformInfo[i].name == name)
break;
}
}
if (i == num) return false;
if (i == num)
return false;
#ifdef GL_ARB_shader_objects
switch (UniformInfo[i].type)
switch (UniformInfo[i].type)
{
case GL_FLOAT:
Driver->extGlUniform1fv(i, count, floats);
case GL_FLOAT:
Driver->extGlUniform1fv(i, count, floats);
break;
case GL_FLOAT_VEC2_ARB:
Driver->extGlUniform2fv(i, count/2, floats);
case GL_FLOAT_VEC2_ARB:
Driver->extGlUniform2fv(i, count/2, floats);
break;
case GL_FLOAT_VEC3_ARB:
Driver->extGlUniform3fv(i, count/3, floats);
case GL_FLOAT_VEC3_ARB:
Driver->extGlUniform3fv(i, count/3, floats);
break;
case GL_FLOAT_VEC4_ARB:
Driver->extGlUniform4fv(i, count/4, floats);
case GL_FLOAT_VEC4_ARB:
Driver->extGlUniform4fv(i, count/4, floats);
break;
case GL_FLOAT_MAT2_ARB:
Driver->extGlUniformMatrix2fv(i, count/4, false, floats);
case GL_FLOAT_MAT2_ARB:
Driver->extGlUniformMatrix2fv(i, count/4, false, floats);
break;
case GL_FLOAT_MAT3_ARB:
Driver->extGlUniformMatrix3fv(i, count/9, false, floats);
case GL_FLOAT_MAT3_ARB:
Driver->extGlUniformMatrix3fv(i, count/9, false, floats);
break;
case GL_FLOAT_MAT4_ARB:
Driver->extGlUniformMatrix4fv(i, count/16, false, floats);
case GL_FLOAT_MAT4_ARB:
Driver->extGlUniformMatrix4fv(i, count/16, false, floats);
break;
default:
default:
Driver->extGlUniform1iv(i, count, (GLint*)floats);
break;
}
}
#endif
return true;
return true;
}
void COpenGLSLMaterialRenderer::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{
os::Printer::log("Cannot set constant, use high level shader call.");
os::Printer::log("Cannot set constant, use high level shader call.");
}
IVideoDriver* COpenGLSLMaterialRenderer::getVideoDriver()
{
return Driver;
return Driver;
}
} // end namespace video
......
......@@ -818,10 +818,10 @@ const core::matrix4& CSoftwareDriver::getTransform(E_TRANSFORMATION_STATE state)
}
//! Creates a render target texture.
ITexture* CSoftwareDriver::createRenderTargetTexture(const core::dimension2d<s32>& size)
ITexture* CSoftwareDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
{
CImage* img = new CImage(video::ECF_A1R5G5B5, size);
ITexture* tex = new CSoftwareTexture(img, 0);
ITexture* tex = new CSoftwareTexture(img, name);
img->drop();
return tex;
}
......
......@@ -82,7 +82,7 @@ namespace video
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state);
//! Creates a render target texture.
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size);
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
//! Clears the ZBuffer.
virtual void clearZBuffer();
......
......@@ -1818,11 +1818,11 @@ const core::matrix4& CSoftwareDriver2::getTransform(E_TRANSFORMATION_STATE state
}
//! Creates a render target texture.
ITexture* CSoftwareDriver2::createRenderTargetTexture(const core::dimension2d<s32>& size)
ITexture* CSoftwareDriver2::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
{
CImage* img = new CImage(ECF_SOFTWARE2, size);
ITexture* tex = new CSoftwareTexture2(img, 0, false);
ITexture* tex = new CSoftwareTexture2(img, name, false);
img->drop();
return tex;
}
......
......@@ -98,7 +98,7 @@ namespace video
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state);
//! Creates a render target texture.
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size);
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
//! Clears the DepthBuffer.
virtual void clearZBuffer();
......
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