Commit 1fa7e87f authored by cutealien's avatar cutealien

NVidia CG support removed due to lack of maintenance.

Note, I would have liked to get it compiling again a last time, but it was referring to a class which didn't exists, so I didn't know what to make of that.
NVidia has also stopped supporting this by the way.
No changes for MacOSX project files, so those still might have to be fixed.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5046 dfc29bdd-3216-0410-991c-e03cc46cb475
parent d07ee3de
--------------------------
Changes in 1.9 (not yet released)
-TA burningvideo:
- NVidia CG support removed in svn revision 5045 due to lack of maintenance. NVidia has also stopped supporting this.
- TA burningvideo:
enabled triangle fan again so that skybox works.[need more testmeshes if other trianglefan than skybox doesn't work]
correct vc2013 project files for x64,static lib
correct alphablend vs add [was broken]
- Add a new core::rect constructor which takes a dimension parameter and set's left-top to 0.
- mtl (obj) format reader and write now regards texture scaling and translation. (thx @thanhle for noticing and patch proposal).
- Added Visual Studio 2013 project files.
......
/** Example 010 Shaders
This tutorial shows how to use shaders for D3D8, D3D9, OpenGL, and Cg with the
This tutorial shows how to use shaders for D3D8, D3D9, and OpenGL with the
engine and how to create new material types with them. It also shows how to
disable the generation of mipmaps at texture loading, and how to use text scene
nodes.
This tutorial does not explain how shaders work. I would recommend to read the
D3D, OpenGL, or Cg documentation, to search a tutorial, or to read a book about
D3D or OpenGL, documentation, to search a tutorial, or to read a book about
this.
At first, we need to include all headers and do the stuff we always do, like in
......@@ -42,7 +42,6 @@ the variable name as parameter instead of the register index.
IrrlichtDevice* device = 0;
bool UseHighLevelShaders = false;
bool UseCgShaders = false;
class MyShaderCallBack : public video::IShaderConstantSetCallBack
{
......@@ -169,10 +168,6 @@ int main()
if (i == 'y')
{
UseHighLevelShaders = true;
printf("Please press 'y' if you want to use Cg shaders.\n");
std::cin >> i;
if (i == 'y')
UseCgShaders = true;
}
}
......@@ -212,7 +207,6 @@ int main()
case video::EDT_DIRECT3D9:
if (UseHighLevelShaders)
{
// Cg can also handle this syntax
psFileName = "../../media/d3d9.hlsl";
vsFileName = psFileName; // both shaders are in the same file
}
......@@ -226,17 +220,8 @@ int main()
case video::EDT_OPENGL:
if (UseHighLevelShaders)
{
if (!UseCgShaders)
{
psFileName = "../../media/opengl.frag";
vsFileName = "../../media/opengl.vert";
}
else
{
// Use HLSL syntax for Cg
psFileName = "../../media/d3d9.hlsl";
vsFileName = psFileName; // both shaders are in the same file
}
psFileName = "../../media/opengl.frag";
vsFileName = "../../media/opengl.vert";
}
else
{
......@@ -314,12 +299,10 @@ int main()
if (UseHighLevelShaders)
{
// Choose the desired shader type. Default is the native
// shader type for the driver, for Cg pass the special
// enum value EGSL_CG
const video::E_GPU_SHADING_LANGUAGE shadingLanguage =
UseCgShaders ? video::EGSL_CG:video::EGSL_DEFAULT;
// shader type for the driver
const video::E_GPU_SHADING_LANGUAGE shadingLanguage = video::EGSL_DEFAULT;
// create material from high level shaders (hlsl, glsl or cg)
// create material from high level shaders (hlsl, glsl)
newMaterialType1 = gpu->addHighLevelShaderMaterialFromFiles(
vsFileName, "vertexMain", video::EVST_VS_1_1,
......
......@@ -324,15 +324,6 @@ to provide the user with the proper DLL. That's why it's disabled by default. */
#undef _IRR_D3D_USE_LEGACY_HLSL_COMPILER
#endif
//! Define _IRR_COMPILE_WITH_CG_ to enable Cg Shading Language support
//#define _IRR_COMPILE_WITH_CG_
#ifdef NO_IRR_COMPILE_WITH_CG_
#undef _IRR_COMPILE_WITH_CG_
#endif
#if !defined(_IRR_COMPILE_WITH_OPENGL_) && !defined(_IRR_COMPILE_WITH_DIRECT3D_9_)
#undef _IRR_COMPILE_WITH_CG_
#endif
//! Define _IRR_USE_NVIDIA_PERFHUD_ to opt-in to using the nVidia PerHUD tool
/** Enable, by opting-in, to use the nVidia PerfHUD performance analysis driver
tool <http://developer.nvidia.com/object/nvperfhud_home.html>. */
......
// Copyright (C) 2012 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_CG_
#include "CCgMaterialRenderer.h"
namespace irr
{
namespace video
{
CCgUniform::CCgUniform(const CGparameter& parameter, bool global) : Parameter(parameter), Type(CG_UNKNOWN_TYPE)
{
Name = cgGetParameterName(Parameter);
if(global)
Space = CG_GLOBAL;
else
Space = CG_PROGRAM;
}
CCgUniform::~CCgUniform()
{
}
const core::stringc& CCgUniform::getName() const
{
return Name;
}
const CGparameter& CCgUniform::getParameter() const
{
return Parameter;
}
CGenum CCgUniform::getSpace() const
{
return Space;
}
CGtype CCgUniform::getType() const
{
return Type;
}
CCgUniform1f::CCgUniform1f(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_FLOAT;
}
void CCgUniform1f::update(const void* data, const SMaterial& material) const
{
f32* Data = (f32*)data;
cgSetParameter1f(Parameter, *Data);
}
CCgUniform2f::CCgUniform2f(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_FLOAT2;
}
void CCgUniform2f::update(const void* data, const SMaterial& material) const
{
f32* Data = (f32*)data;
cgSetParameter2f(Parameter, *Data, *(Data+1));
}
CCgUniform3f::CCgUniform3f(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_FLOAT3;
}
void CCgUniform3f::update(const void* data, const SMaterial& material) const
{
f32* Data = (f32*)data;
cgSetParameter3f(Parameter, *Data, *(Data+1), *(Data+2));
}
CCgUniform4f::CCgUniform4f(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_FLOAT4;
}
void CCgUniform4f::update(const void* data, const SMaterial& material) const
{
f32* Data = (f32*)data;
cgSetParameter4f(Parameter, *Data, *(Data+1), *(Data+2), *(Data+3));
}
CCgUniform1i::CCgUniform1i(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_INT;
}
void CCgUniform1i::update(const void* data, const SMaterial& material) const
{
s32* Data = (s32*)data;
cgSetParameter1i(Parameter, *Data);
}
CCgUniform2i::CCgUniform2i(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_INT2;
}
void CCgUniform2i::update(const void* data, const SMaterial& material) const
{
s32* Data = (s32*)data;
cgSetParameter2i(Parameter, *Data, *(Data+1));
}
CCgUniform3i::CCgUniform3i(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_INT3;
}
void CCgUniform3i::update(const void* data, const SMaterial& material) const
{
s32* Data = (s32*)data;
cgSetParameter3i(Parameter, *Data, *(Data+1), *(Data+2));
}
CCgUniform4i::CCgUniform4i(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_INT4;
}
void CCgUniform4i::update(const void* data, const SMaterial& material) const
{
s32* Data = (s32*)data;
cgSetParameter4i(Parameter, *Data, *(Data+1), *(Data+2), *(Data+3));
}
CCgUniform4x4f::CCgUniform4x4f(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_FLOAT4x4;
}
void CCgUniform4x4f::update(const void* data, const SMaterial& material) const
{
f32* Data = (f32*)data;
cgSetMatrixParameterfr(Parameter, Data);
}
CCgUniformSampler2D::CCgUniformSampler2D(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_SAMPLER2D;
}
void CCgUniformSampler2D::update(const void* data, const SMaterial& material) const
{
}
CCgMaterialRenderer::CCgMaterialRenderer(IShaderConstantSetCallBack* callback, s32 userData) :
CallBack(callback), UserData(userData),
VertexProgram(0), FragmentProgram(0), GeometryProgram(0), VertexProfile(CG_PROFILE_UNKNOWN), FragmentProfile(CG_PROFILE_UNKNOWN), GeometryProfile(CG_PROFILE_UNKNOWN),
Material(IdentityMaterial), Error(CG_NO_ERROR)
{
#ifdef _DEBUG
setDebugName("CCgMaterialRenderer");
#endif
if(CallBack)
CallBack->grab();
}
CCgMaterialRenderer::~CCgMaterialRenderer()
{
if(CallBack)
CallBack->drop();
for(unsigned int i = 0; i < UniformInfo.size(); ++i)
delete UniformInfo[i];
UniformInfo.clear();
}
s32 CCgMaterialRenderer::getVertexShaderConstantID(const c8* name)
{
return getPixelShaderConstantID(name);
}
s32 CCgMaterialRenderer::getPixelShaderConstantID(const c8* name)
{
for(u32 i = 0; i < UniformInfo.size(); ++i)
{
if(UniformInfo[i]->getName() == name)
return i;
}
return -1;
}
void CCgMaterialRenderer::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{
os::Printer::log("Cannot set constant, please use high level shader call instead.", ELL_WARNING);
}
void CCgMaterialRenderer::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{
os::Printer::log("Cannot set constant, please use high level shader call instead.", ELL_WARNING);
}
bool CCgMaterialRenderer::setVertexShaderConstant(s32 index, const f32* floats, int count)
{
return setPixelShaderConstant(index, floats, count);
}
bool CCgMaterialRenderer::setVertexShaderConstant(s32 index, const s32* ints, int count)
{
return setPixelShaderConstant(index, ints, count);
}
bool CCgMaterialRenderer::setPixelShaderConstant(s32 index, const f32* floats, int count)
{
if(index < 0)
return false;
UniformInfo[index]->update(floats, Material);
return true;
}
bool CCgMaterialRenderer::setPixelShaderConstant(s32 index, const s32* ints, int count)
{
if(index < 0)
return false;
UniformInfo[index]->update(ints, Material);
return true;
}
void CCgMaterialRenderer::getUniformList()
{
for(unsigned int i = 0; i < UniformInfo.size(); ++i)
delete UniformInfo[i];
UniformInfo.clear();
for(unsigned int i = 0; i < 2; ++i)
{
CGenum Space = CG_GLOBAL;
bool IsGlobal = 1;
if(i == 1)
{
Space = CG_PROGRAM;
IsGlobal = 0;
}
for(unsigned int j = 0; j < 3; ++j)
{
CGprogram* Program = 0;
switch(j)
{
case 0:
Program = &VertexProgram;
break;
case 1:
Program = &FragmentProgram;
break;
case 2:
Program = &GeometryProgram;
break;
}
if(*Program)
{
CGparameter Parameter = cgGetFirstParameter(*Program, Space);
while(Parameter)
{
if(cgGetParameterVariability(Parameter) == CG_UNIFORM && cgGetParameterDirection(Parameter) == CG_IN)
{
CCgUniform* Uniform = 0;
CGtype Type = cgGetParameterType(Parameter);
switch(Type)
{
case CG_FLOAT:
case CG_FLOAT1:
Uniform = new CCgUniform1f(Parameter, IsGlobal);
break;
case CG_FLOAT2:
Uniform = new CCgUniform2f(Parameter, IsGlobal);
break;
case CG_FLOAT3:
Uniform = new CCgUniform3f(Parameter, IsGlobal);
break;
case CG_FLOAT4:
Uniform = new CCgUniform4f(Parameter, IsGlobal);
break;
case CG_INT:
case CG_INT1:
Uniform = new CCgUniform1i(Parameter, IsGlobal);
break;
case CG_INT2:
Uniform = new CCgUniform2i(Parameter, IsGlobal);
break;
case CG_INT3:
Uniform = new CCgUniform3i(Parameter, IsGlobal);
break;
case CG_INT4:
Uniform = new CCgUniform4i(Parameter, IsGlobal);
break;
case CG_FLOAT4x4:
Uniform = new CCgUniform4x4f(Parameter, IsGlobal);
break;
case CG_SAMPLER2D:
Uniform = new CCgUniformSampler2D(Parameter, IsGlobal);
break;
}
if(Uniform)
UniformInfo.push_back(Uniform);
}
Parameter = cgGetNextParameter(Parameter);
}
}
}
}
}
}
}
#endif
// Copyright (C) 2012 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_CG_MATERIAL_RENDERER_H_INCLUDED__
#define __C_CG_MATERIAL_RENDERER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_CG_
#include "IMaterialRenderer.h"
#include "IMaterialRendererServices.h"
#include "IShaderConstantSetCallBack.h"
#include "IGPUProgrammingServices.h"
#include "irrArray.h"
#include "irrString.h"
#include "IVideoDriver.h"
#include "os.h"
#include "Cg/cg.h"
#ifdef _MSC_VER
#pragma comment(lib, "cg.lib")
#endif
namespace irr
{
namespace video
{
class CCgUniform
{
public:
CCgUniform(const CGparameter& parameter, bool global);
virtual ~CCgUniform();
const core::stringc& getName() const;
const CGparameter& getParameter() const;
CGenum getSpace() const;
CGtype getType() const;
virtual void update(const void* data, const SMaterial& material) const = 0;
protected:
core::stringc Name;
CGparameter Parameter;
CGenum Space;
CGtype Type;
};
class CCgUniform1f : public CCgUniform
{
public:
CCgUniform1f(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgUniform2f : public CCgUniform
{
public:
CCgUniform2f(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgUniform3f : public CCgUniform
{
public:
CCgUniform3f(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgUniform4f : public CCgUniform
{
public:
CCgUniform4f(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgUniform1i : public CCgUniform
{
public:
CCgUniform1i(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgUniform2i : public CCgUniform
{
public:
CCgUniform2i(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgUniform3i : public CCgUniform
{
public:
CCgUniform3i(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgUniform4i : public CCgUniform
{
public:
CCgUniform4i(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgUniform4x4f : public CCgUniform
{
public:
CCgUniform4x4f(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgUniformSampler2D : public CCgUniform
{
public:
CCgUniformSampler2D(const CGparameter& parameter, bool global);
virtual void update(const void* data, const SMaterial& material) const _IRR_OVERRIDE_;
};
class CCgMaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices
{
public:
CCgMaterialRenderer(IShaderConstantSetCallBack* callback = 0, s32 userData = 0);
virtual ~CCgMaterialRenderer();
virtual bool isTransparent() const = 0;
virtual s32 getVertexShaderConstantID(const c8* name) _IRR_OVERRIDE_;
virtual s32 getPixelShaderConstantID(const c8* name) _IRR_OVERRIDE_;
virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) _IRR_OVERRIDE_;
virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) _IRR_OVERRIDE_;
virtual bool setVertexShaderConstant(s32 index, const f32* floats, int count) _IRR_OVERRIDE_;
virtual bool setVertexShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
virtual bool setPixelShaderConstant(s32 index, const f32* floats, int count) _IRR_OVERRIDE_;
virtual bool setPixelShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
protected:
void getUniformList();
IShaderConstantSetCallBack* CallBack;
s32 UserData;
core::array<CCgUniform*> UniformInfo;
CGprogram VertexProgram;
CGprogram FragmentProgram;
CGprogram GeometryProgram;
CGprofile VertexProfile;
CGprofile FragmentProfile;
CGprofile GeometryProfile;
SMaterial Material;
CGerror Error;
};
}
}
#endif
#endif
// Copyright (C) 2012-2012 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#if defined(_IRR_COMPILE_WITH_DIRECT3D_9_) && defined(_IRR_COMPILE_WITH_CG_)
#include "CD3D9CgMaterialRenderer.h"
#include "CD3D9Driver.h"
#include "CD3D9Texture.h"
namespace irr
{
namespace video
{
CD3D9CgUniformSampler2D::CD3D9CgUniformSampler2D(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_SAMPLER2D;
}
void CD3D9CgUniformSampler2D::update(const void* data, const SMaterial& material) const
{
s32* Data = (s32*)data;
s32 LayerID = *Data;
if (material.TextureLayer[LayerID].Texture)
{
IDirect3DBaseTexture9* Texture = reinterpret_cast<irr::video::CD3D9Texture*>(material.TextureLayer[LayerID].Texture)->getDX9Texture();
cgD3D9SetTextureParameter(Parameter, Texture);
}
}
CD3D9CgMaterialRenderer::CD3D9CgMaterialRenderer(CD3D9Driver* driver, s32& materialType,
const c8* vertexProgram, const c8* vertexEntry, E_VERTEX_SHADER_TYPE vertexProfile,
const c8* fragmentProgram, const c8* fragmentEntry, E_PIXEL_SHADER_TYPE fragmentProfile,
const c8* geometryProgram, const c8* geometryEntry, E_GEOMETRY_SHADER_TYPE geometryProfile,
scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, u32 vertices,
IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData) :
BaseMaterial(baseMaterial), Driver(driver), CCgMaterialRenderer(callback, userData)
{
#ifdef _DEBUG
setDebugName("CD3D9CgMaterialRenderer");
#endif
if(BaseMaterial)
BaseMaterial->grab();
init(materialType, vertexProgram, vertexEntry, vertexProfile, fragmentProgram, fragmentEntry, fragmentProfile,
geometryProgram, geometryEntry, geometryProfile, inType, outType, vertices);
}
CD3D9CgMaterialRenderer::~CD3D9CgMaterialRenderer()
{
if(BaseMaterial)
BaseMaterial->drop();
if (VertexProgram)
{
cgD3D9UnloadProgram(VertexProgram);
cgDestroyProgram(VertexProgram);
}
if (FragmentProgram)
{
cgD3D9UnloadProgram(FragmentProgram);
cgDestroyProgram(FragmentProgram);
}
}
bool CD3D9CgMaterialRenderer::isTransparent() const
{
return BaseMaterial ? BaseMaterial->isTransparent() : false;
}
void CD3D9CgMaterialRenderer::OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services)
{
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (VertexProgram)
cgD3D9BindProgram(VertexProgram);
if (FragmentProgram)
cgD3D9BindProgram(FragmentProgram);
}
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (BaseMaterial)
BaseMaterial->OnSetMaterial(material, lastMaterial, resetAllRenderstates, this);
if (CallBack)
CallBack->OnSetMaterial(material);
Material = material;
}
bool CD3D9CgMaterialRenderer::OnRender(IMaterialRendererServices* services, E_VERTEX_TYPE vtxtype)
{
if (CallBack && (VertexProgram || FragmentProgram || GeometryProgram))
CallBack->OnSetConstants(this, UserData);
return true;
}
void CD3D9CgMaterialRenderer::OnUnsetMaterial()
{
if (VertexProgram)
cgD3D9UnbindProgram(VertexProgram);
if (FragmentProgram)
cgD3D9UnbindProgram(FragmentProgram);
/*if (GeometryProgram)
cgD3D9UnbindProgram(GeometryProgram);*/
if (BaseMaterial)
BaseMaterial->OnUnsetMaterial();
Material = IdentityMaterial;
}
void CD3D9CgMaterialRenderer::setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
IVideoDriver* CD3D9CgMaterialRenderer::getVideoDriver()
{
return Driver;
}
void CD3D9CgMaterialRenderer::init(s32& materialType,
const c8* vertexProgram, const c8* vertexEntry, E_VERTEX_SHADER_TYPE vertexProfile,
const c8* fragmentProgram, const c8* fragmentEntry, E_PIXEL_SHADER_TYPE fragmentProfile,
const c8* geometryProgram, const c8* geometryEntry, E_GEOMETRY_SHADER_TYPE geometryProfile,
scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, u32 vertices)
{
bool Status = true;
CGerror Error = CG_NO_ERROR;
materialType = -1;
// TODO: add profile selection
if (vertexProgram)
{
VertexProfile = cgD3D9GetLatestVertexProfile();
if (VertexProfile)
VertexProgram = cgCreateProgram(Driver->getCgContext(), CG_SOURCE, vertexProgram, VertexProfile, vertexEntry, 0);
if (!VertexProgram)
{
Error = cgGetError();
os::Printer::log("Cg vertex program failed to compile:", ELL_ERROR);
os::Printer::log(cgGetLastListing(Driver->getCgContext()), ELL_ERROR);
Status = false;
}
else
cgD3D9LoadProgram(VertexProgram, 0, 0);
}
if (fragmentProgram)
{
FragmentProfile = cgD3D9GetLatestPixelProfile();
if (FragmentProfile)
FragmentProgram = cgCreateProgram(Driver->getCgContext(), CG_SOURCE, fragmentProgram, FragmentProfile, fragmentEntry, 0);
if (!FragmentProgram)
{
Error = cgGetError();
os::Printer::log("Cg fragment program failed to compile:", ELL_ERROR);
os::Printer::log(cgGetLastListing(Driver->getCgContext()), ELL_ERROR);
Status = false;
}
else
cgD3D9LoadProgram(FragmentProgram, 0, 0);
}
/*if (geometryProgram)
{
GeometryProfile = cgD3D9GetLatestGeometryProfile();
if (GeometryProfile)
GeometryProgram = cgCreateProgram(Driver->getCgContext(), CG_SOURCE, geometryProgram, GeometryProfile, geometryEntry, 0);
if (!GeometryProgram)
{
Error = cgGetError();
os::Printer::log("Cg geometry program failed to compile:", ELL_ERROR);
os::Printer::log(cgGetLastListing(Driver->getCgContext()), ELL_ERROR);
Status = false;
}
else
cgD3D9LoadProgram(GeometryProgram, 0, 0);
}*/
getUniformList();
// create D3D9 specifics sampler uniforms.
for(unsigned int i = 0; i < UniformInfo.size(); ++i)
{
if (UniformInfo[i]->getType() == CG_SAMPLER2D)
{
bool IsGlobal = true;
if (UniformInfo[i]->getSpace() == CG_PROGRAM)
IsGlobal = false;
CCgUniform* Uniform = new CD3D9CgUniformSampler2D(UniformInfo[i]->getParameter(), IsGlobal);
delete UniformInfo[i];
UniformInfo[i] = Uniform;
}
}
if (Status)
materialType = Driver->addMaterialRenderer(this);
}
}
}
#endif
// Copyright (C) 2012-2012 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_DIRECT3D_9_CG_MATERIAL_RENDERER_H_INCLUDED__
#define __C_DIRECT3D_9_CG_MATERIAL_RENDERER_H_INCLUDED__
#include "IrrCompileConfig.h"
#if defined(_IRR_COMPILE_WITH_DIRECT3D_9_) && defined(_IRR_COMPILE_WITH_CG_)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include "CCgMaterialRenderer.h"
#include "Cg/cgD3D9.h"
#ifdef _MSC_VER
#pragma comment(lib, "cgD3D9.lib")
#endif
namespace irr
{
namespace video
{
class CD3D9Driver;
class IShaderConstantSetCallBack;
class CD3D9CgUniformSampler2D : public CCgUniform
{
public:
CD3D9CgUniformSampler2D(const CGparameter& parameter, bool global);
void update(const void* data, const SMaterial& material) const;
};
class CD3D9CgMaterialRenderer : public CCgMaterialRenderer
{
public:
CD3D9CgMaterialRenderer(CD3D9Driver* driver, s32& materialType,
const c8* vertexProgram = 0, const c8* vertexEntry = "main",
E_VERTEX_SHADER_TYPE vertexProfile = video::EVST_VS_1_1,
const c8* fragmentProgram = 0, const c8* fragmentEntry = "main",
E_PIXEL_SHADER_TYPE fragmentProfile = video::EPST_PS_1_1,
const c8* geometryProgram = 0, const c8* geometryEntry = "main",
E_GEOMETRY_SHADER_TYPE geometryProfile = video::EGST_GS_4_0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 vertices = 0, IShaderConstantSetCallBack* callback = 0,
IMaterialRenderer* baseMaterial = 0, s32 userData = 0);
virtual ~CD3D9CgMaterialRenderer();
virtual bool isTransparent() const _IRR_OVERRIDE_;
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_;
virtual bool OnRender(IMaterialRendererServices* services, E_VERTEX_TYPE vtxtype) _IRR_OVERRIDE_;
virtual void OnUnsetMaterial() _IRR_OVERRIDE_;
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates) _IRR_OVERRIDE_;
virtual IVideoDriver* getVideoDriver() _IRR_OVERRIDE_;
protected:
void init(s32& materialType,
const c8* vertexProgram = 0, const c8* vertexEntry = "main",
E_VERTEX_SHADER_TYPE vertexProfile = video::EVST_VS_1_1,
const c8* fragmentProgram = 0, const c8* fragmentEntry = "main",
E_PIXEL_SHADER_TYPE fragmentProfile = video::EPST_PS_1_1,
const c8* geometryProgram = 0, const c8* geometryEntry = "main",
E_GEOMETRY_SHADER_TYPE geometryProfile = video::EGST_GS_4_0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 vertices = 0);
IMaterialRenderer* BaseMaterial;
CD3D9Driver* Driver;
};
}
}
#endif
#endif
......@@ -15,7 +15,6 @@
#include "CD3D9NormalMapRenderer.h"
#include "CD3D9ParallaxMapRenderer.h"
#include "CD3D9HLSLMaterialRenderer.h"
#include "CD3D9CgMaterialRenderer.h"
#include "SIrrCreationParameters.h"
namespace irr
......@@ -67,10 +66,6 @@ CD3D9Driver::CD3D9Driver(const SIrrlichtCreationParameters& params, io::IFileSys
core::matrix4 mat;
UnitMatrixD3D9 = *(D3DMATRIX*)((void*)mat.pointer());
#ifdef _IRR_COMPILE_WITH_CG_
CgContext = 0;
#endif
// init direct 3d is done in the factory function
}
......@@ -97,15 +92,6 @@ CD3D9Driver::~CD3D9Driver()
if (pID3D)
pID3D->Release();
#ifdef _IRR_COMPILE_WITH_CG_
cgD3D9SetDevice(0);
if(CgContext)
{
cgDestroyContext(CgContext);
}
#endif
}
......@@ -503,11 +489,6 @@ bool CD3D9Driver::initDriver(HWND hwnd, bool pureSoftware)
}
ColorFormat = getColorFormatFromD3DFormat(D3DColorFormat);
#ifdef _IRR_COMPILE_WITH_CG_
CgContext = cgCreateContext();
cgD3D9SetDevice(pID3DDevice);
#endif
// so far so good.
return true;
}
......@@ -3234,23 +3215,7 @@ s32 CD3D9Driver::addHighLevelShaderMaterial(
{
s32 nr = -1;
#ifdef _IRR_COMPILE_WITH_CG_
if(shadingLang == EGSL_CG)
{
CD3D9CgMaterialRenderer* r = new CD3D9CgMaterialRenderer(
this, nr,
vertexShaderProgram, vertexShaderEntryPointName, vsCompileTarget,
pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget,
geometryShaderProgram, geometryShaderEntryPointName, gsCompileTarget,
inType, outType, verticesOut,
callback,getMaterialRenderer(baseMaterial), userData);
r->drop();
}
else
#endif
{
CD3D9HLSLMaterialRenderer* r = new CD3D9HLSLMaterialRenderer(
CD3D9HLSLMaterialRenderer* r = new CD3D9HLSLMaterialRenderer(
pID3DDevice, this, nr,
vertexShaderProgram,
vertexShaderEntryPointName,
......@@ -3262,8 +3227,7 @@ s32 CD3D9Driver::addHighLevelShaderMaterial(
getMaterialRenderer(baseMaterial),
userData);
r->drop();
}
r->drop();
return nr;
}
......@@ -3663,14 +3627,6 @@ CD3D9CallBridge* CD3D9Driver::getBridgeCalls() const
return BridgeCalls;
}
#ifdef _IRR_COMPILE_WITH_CG_
const CGcontext& CD3D9Driver::getCgContext()
{
return CgContext;
}
#endif
CD3D9CallBridge::CD3D9CallBridge(IDirect3DDevice9* p, CD3D9Driver* driver) : pID3DDevice(p),
BlendOperation(D3DBLENDOP_ADD), BlendSourceRGB(D3DBLEND_ONE), BlendDestinationRGB(D3DBLEND_ZERO),
BlendSourceAlpha(D3DBLEND_ONE), BlendDestinationAlpha(D3DBLEND_ZERO), Blend(false), BlendSeparate(false)
......
......@@ -22,11 +22,6 @@
#endif
#include <d3d9.h>
#ifdef _IRR_COMPILE_WITH_CG_
#include "Cg/cg.h"
#include "Cg/cgD3D9.h"
#endif
namespace irr
{
namespace video
......@@ -342,11 +337,6 @@ namespace video
//! Get bridge calls.
CD3D9CallBridge* getBridgeCalls() const;
//! Get Cg context
#ifdef _IRR_COMPILE_WITH_CG_
const CGcontext& getCgContext();
#endif
private:
//! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates.
......@@ -492,10 +482,6 @@ namespace video
bool DriverWasReset;
bool OcclusionQuerySupport;
bool AlphaToCoverageSupport;
#ifdef _IRR_COMPILE_WITH_CG_
CGcontext CgContext;
#endif
};
//! This bridge between Irlicht pseudo D3D8 calls
......
// Copyright (C) 2012-2012 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#if defined(_IRR_COMPILE_WITH_OPENGL_) && defined(_IRR_COMPILE_WITH_CG_)
#include "COpenGLCgMaterialRenderer.h"
#include "COpenGLDriver.h"
#include "COpenGLTexture.h"
#include "COpenGLMaterialRenderer.h"
namespace irr
{
namespace video
{
COpenGLCgUniformSampler2D::COpenGLCgUniformSampler2D(const CGparameter& parameter, bool global) : CCgUniform(parameter, global)
{
Type = CG_SAMPLER2D;
}
void COpenGLCgUniformSampler2D::update(const void* data, const SMaterial& material) const
{
s32* Data = (s32*)data;
s32 LayerID = *Data;
if (material.TextureLayer[LayerID].Texture)
{
int TextureID = reinterpret_cast<COpenGLTexture*>(material.TextureLayer[LayerID].Texture)->getOpenGLTextureName();
cgGLSetTextureParameter(Parameter, TextureID);
cgGLEnableTextureParameter(Parameter);
}
}
COpenGLCgMaterialRenderer::COpenGLCgMaterialRenderer(COpenGLDriver* driver, s32& materialType,
const c8* vertexProgram, const c8* vertexEntry, E_VERTEX_SHADER_TYPE vertexProfile,
const c8* fragmentProgram, const c8* fragmentEntry, E_PIXEL_SHADER_TYPE fragmentProfile,
const c8* geometryProgram, const c8* geometryEntry, E_GEOMETRY_SHADER_TYPE geometryProfile,
scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, u32 vertices,
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) :
BaseMaterial(0), Driver(driver), CCgMaterialRenderer(callback, userData)
{
#ifdef _DEBUG
setDebugName("COpenGLCgMaterialRenderer");
#endif
if (baseMaterial == EMT_ONETEXTURE_BLEND || baseMaterial == EMT_TRANSPARENT_ADD_COLOR || baseMaterial == EMT_TRANSPARENT_VERTEX_ALPHA ||
baseMaterial == EMT_TRANSPARENT_ALPHA_CHANNEL || baseMaterial == EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
{
BaseMaterial = static_cast<COpenGLMaterialRenderer*>(Driver->getMaterialRenderer(baseMaterial));
}
if (BaseMaterial)
BaseMaterial->grab();
init(materialType, vertexProgram, vertexEntry, vertexProfile, fragmentProgram, fragmentEntry, fragmentProfile,
geometryProgram, geometryEntry, geometryProfile, inType, outType, vertices);
}
COpenGLCgMaterialRenderer::~COpenGLCgMaterialRenderer()
{
if(BaseMaterial)
BaseMaterial->drop();
if (VertexProgram)
{
cgGLUnloadProgram(VertexProgram);
cgDestroyProgram(VertexProgram);
}
if (FragmentProgram)
{
cgGLUnloadProgram(FragmentProgram);
cgDestroyProgram(FragmentProgram);
}
if (GeometryProgram)
{
cgGLUnloadProgram(GeometryProgram);
cgDestroyProgram(GeometryProgram);
}
}
bool COpenGLCgMaterialRenderer::isTransparent() const
{
return BaseMaterial ? BaseMaterial->isTransparent() : false;
}
void COpenGLCgMaterialRenderer::OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services)
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_ENABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE_TO_DISABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (VertexProgram)
{
cgGLEnableProfile(VertexProfile);
cgGLBindProgram(VertexProgram);
}
if (FragmentProgram)
{
cgGLEnableProfile(FragmentProfile);
cgGLBindProgram(FragmentProgram);
}
if (GeometryProgram)
{
cgGLEnableProfile(GeometryProfile);
cgGLBindProgram(GeometryProgram);
}
}
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (BaseMaterial)
BaseMaterial->OnSetBaseMaterial(material);
if (CallBack)
CallBack->OnSetMaterial(material);
Material = material;
}
bool COpenGLCgMaterialRenderer::OnRender(IMaterialRendererServices* services, E_VERTEX_TYPE vtxtype)
{
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false);
if (CallBack && (VertexProgram || FragmentProgram || GeometryProgram))
CallBack->OnSetConstants(this, UserData);
return true;
}
void COpenGLCgMaterialRenderer::OnUnsetMaterial()
{
if (VertexProgram)
{
cgGLUnbindProgram(VertexProfile);
cgGLDisableProfile(VertexProfile);
}
if (FragmentProgram)
{
cgGLUnbindProgram(FragmentProfile);
cgGLDisableProfile(FragmentProfile);
}
if (GeometryProgram)
{
cgGLUnbindProgram(GeometryProfile);
cgGLDisableProfile(GeometryProfile);
}
if (BaseMaterial)
BaseMaterial->OnUnsetBaseMaterial();
Material = IdentityMaterial;
}
void COpenGLCgMaterialRenderer::setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
IVideoDriver* COpenGLCgMaterialRenderer::getVideoDriver()
{
return Driver;
}
void COpenGLCgMaterialRenderer::init(s32& materialType,
const c8* vertexProgram, const c8* vertexEntry, E_VERTEX_SHADER_TYPE vertexProfile,
const c8* fragmentProgram, const c8* fragmentEntry, E_PIXEL_SHADER_TYPE fragmentProfile,
const c8* geometryProgram, const c8* geometryEntry, E_GEOMETRY_SHADER_TYPE geometryProfile,
scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, u32 vertices)
{
bool shaderStatus = true;
CGerror Error = CG_NO_ERROR;
materialType = -1;
// TODO: add profile selection
if (vertexProgram)
{
VertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX);
if (VertexProfile)
VertexProgram = cgCreateProgram(Driver->getCgContext(), CG_SOURCE, vertexProgram, VertexProfile, vertexEntry, 0);
if (!VertexProgram)
{
Error = cgGetError();
os::Printer::log("Cg vertex program failed to compile:", ELL_ERROR);
os::Printer::log(cgGetLastListing(Driver->getCgContext()), ELL_ERROR);
shaderStatus = false;
}
else
cgGLLoadProgram(VertexProgram);
}
if (fragmentProgram)
{
FragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
if (FragmentProfile)
FragmentProgram = cgCreateProgram(Driver->getCgContext(), CG_SOURCE, fragmentProgram, FragmentProfile, fragmentEntry, 0);
if (!FragmentProgram)
{
Error = cgGetError();
os::Printer::log("Cg fragment program failed to compile:", ELL_ERROR);
os::Printer::log(cgGetLastListing(Driver->getCgContext()), ELL_ERROR);
shaderStatus = false;
}
else
cgGLLoadProgram(FragmentProgram);
}
if (geometryProgram)
{
GeometryProfile = cgGLGetLatestProfile(CG_GL_GEOMETRY);
if (GeometryProfile)
GeometryProgram = cgCreateProgram(Driver->getCgContext(), CG_SOURCE, geometryProgram, GeometryProfile, geometryEntry, 0);
if (!GeometryProgram)
{
Error = cgGetError();
os::Printer::log("Cg geometry program failed to compile:", ELL_ERROR);
os::Printer::log(cgGetLastListing(Driver->getCgContext()), ELL_ERROR);
shaderStatus = false;
}
else
cgGLLoadProgram(GeometryProgram);
}
getUniformList();
// create OpenGL specifics sampler uniforms.
for (unsigned int i = 0; i < UniformInfo.size(); ++i)
{
if (UniformInfo[i]->getType() == CG_SAMPLER2D)
{
bool IsGlobal = true;
if (UniformInfo[i]->getSpace() == CG_PROGRAM)
IsGlobal = false;
CCgUniform* Uniform = new COpenGLCgUniformSampler2D(UniformInfo[i]->getParameter(), IsGlobal);
delete UniformInfo[i];
UniformInfo[i] = Uniform;
}
}
if (shaderStatus)
materialType = Driver->addMaterialRenderer(this);
}
}
}
#endif
// Copyright (C) 2012-2012 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_OPENGL_CG_MATERIAL_RENDERER_H_INCLUDED__
#define __C_OPENGL_CG_MATERIAL_RENDERER_H_INCLUDED__
#include "IrrCompileConfig.h"
#if defined(_IRR_COMPILE_WITH_OPENGL_) && defined(_IRR_COMPILE_WITH_CG_)
#ifdef _IRR_WINDOWS_API_
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <GL/gl.h>
#include "glext.h"
#else
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1
#else
#define GL_GLEXT_PROTOTYPES 1
#endif
#if defined(_IRR_OSX_PLATFORM_)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h"
#endif
#endif
#include "CCgMaterialRenderer.h"
#include "Cg/cgGL.h"
#ifdef _MSC_VER
#pragma comment(lib, "cgGL.lib")
#endif
namespace irr
{
namespace video
{
class COpenGLDriver;
class COpenGLMaterialRenderer;
class IShaderConstantSetCallBack;
class COpenGLCgUniformSampler2D : public CCgUniform
{
public:
COpenGLCgUniformSampler2D(const CGparameter& parameter, bool global);
void update(const void* data, const SMaterial& material) const;
};
class COpenGLCgMaterialRenderer : public CCgMaterialRenderer
{
public:
COpenGLCgMaterialRenderer(COpenGLDriver* driver, s32& materialType,
const c8* vertexProgram = 0, const c8* vertexEntry = "main",
E_VERTEX_SHADER_TYPE vertexProfile = video::EVST_VS_1_1,
const c8* fragmentProgram = 0, const c8* fragmentEntry = "main",
E_PIXEL_SHADER_TYPE fragmentProfile = video::EPST_PS_1_1,
const c8* geometryProgram = 0, const c8* geometryEntry = "main",
E_GEOMETRY_SHADER_TYPE geometryProfile = video::EGST_GS_4_0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 vertices = 0, IShaderConstantSetCallBack* callback = 0,
E_MATERIAL_TYPE baseMaterial = EMT_SOLID, s32 userData = 0);
virtual ~COpenGLCgMaterialRenderer();
virtual bool isTransparent() const _IRR_OVERRIDE_;
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_;
virtual bool OnRender(IMaterialRendererServices* services, E_VERTEX_TYPE vtxtype) _IRR_OVERRIDE_;
virtual void OnUnsetMaterial() _IRR_OVERRIDE_;
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates) _IRR_OVERRIDE_;
virtual IVideoDriver* getVideoDriver() _IRR_OVERRIDE_;
protected:
void init(s32& materialType,
const c8* vertexProgram = 0, const c8* vertexEntry = "main",
E_VERTEX_SHADER_TYPE vertexProfile = video::EVST_VS_1_1,
const c8* fragmentProgram = 0, const c8* fragmentEntry = "main",
E_PIXEL_SHADER_TYPE fragmentProfile = video::EPST_PS_1_1,
const c8* geometryProgram = 0, const c8* geometryEntry = "main",
E_GEOMETRY_SHADER_TYPE geometryProfile = video::EGST_GS_4_0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 vertices = 0);
COpenGLMaterialRenderer* BaseMaterial;
COpenGLDriver* Driver;
};
}
}
#endif
#endif
......@@ -12,7 +12,6 @@
#include "COpenGLMaterialRenderer.h"
#include "COpenGLShaderMaterialRenderer.h"
#include "COpenGLSLMaterialRenderer.h"
#include "COpenGLCgMaterialRenderer.h"
#include "COpenGLNormalMapRenderer.h"
#include "COpenGLParallaxMapRenderer.h"
#include "os.h"
......@@ -60,10 +59,6 @@ COpenGLDriver::COpenGLDriver(const irr::SIrrlichtCreationParameters& params,
#ifdef _DEBUG
setDebugName("COpenGLDriver");
#endif
#ifdef _IRR_COMPILE_WITH_CG_
CgContext = 0;
#endif
}
......@@ -498,10 +493,6 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
setDebugName("COpenGLDriver");
#endif
#ifdef _IRR_COMPILE_WITH_CG_
CgContext = 0;
#endif
genericDriverInit();
}
......@@ -525,10 +516,6 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
#ifdef _DEBUG
setDebugName("COpenGLDriver");
#endif
#ifdef _IRR_COMPILE_WITH_CG_
CgContext = 0;
#endif
}
......@@ -620,10 +607,6 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
setDebugName("COpenGLDriver");
#endif
#ifdef _IRR_COMPILE_WITH_CG_
CgContext = 0;
#endif
genericDriverInit();
}
......@@ -633,11 +616,6 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
//! destructor
COpenGLDriver::~COpenGLDriver()
{
#ifdef _IRR_COMPILE_WITH_CG_
if (CgContext)
cgDestroyContext(CgContext);
#endif
RequestedLights.clear();
deleteMaterialRenders();
......@@ -786,10 +764,6 @@ bool COpenGLDriver::genericDriverInit()
// This fixes problems with intermediate changes to the material during texture load.
ResetRenderStates = true;
#ifdef _IRR_COMPILE_WITH_CG_
CgContext = cgCreateContext();
#endif
return true;
}
......@@ -4218,23 +4192,7 @@ s32 COpenGLDriver::addHighLevelShaderMaterial(
{
s32 nr = -1;
#ifdef _IRR_COMPILE_WITH_CG_
if (shadingLang == EGSL_CG)
{
COpenGLCgMaterialRenderer* r = new COpenGLCgMaterialRenderer(
this, nr,
vertexShaderProgram, vertexShaderEntryPointName, vsCompileTarget,
pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget,
geometryShaderProgram, geometryShaderEntryPointName, gsCompileTarget,
inType, outType, verticesOut,
callback,baseMaterial, userData);
r->drop();
}
else
#endif
{
COpenGLSLMaterialRenderer* r = new COpenGLSLMaterialRenderer(
COpenGLSLMaterialRenderer* r = new COpenGLSLMaterialRenderer(
this, nr,
vertexShaderProgram, vertexShaderEntryPointName, vsCompileTarget,
pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget,
......@@ -4242,8 +4200,7 @@ s32 COpenGLDriver::addHighLevelShaderMaterial(
inType, outType, verticesOut,
callback,baseMaterial, userData);
r->drop();
}
r->drop();
return nr;
}
......@@ -4955,13 +4912,6 @@ COpenGLCallBridge* COpenGLDriver::getBridgeCalls() const
return BridgeCalls;
}
#ifdef _IRR_COMPILE_WITH_CG_
const CGcontext& COpenGLDriver::getCgContext()
{
return CgContext;
}
#endif
COpenGLCallBridge::COpenGLCallBridge(COpenGLDriver* driver) : Driver(driver),
AlphaMode(GL_ALWAYS), AlphaRef(0.0f), AlphaTest(false),
ClientStateVertex(false), ClientStateNormal(false), ClientStateColor(false), ClientStateTexCoord0(false),
......
......@@ -24,10 +24,6 @@ namespace irr
// also includes the OpenGL stuff
#include "COpenGLExtensionHandler.h"
#ifdef _IRR_COMPILE_WITH_CG_
#include "Cg/cg.h"
#endif
namespace irr
{
......@@ -431,11 +427,6 @@ namespace video
//! Get bridge calls.
COpenGLCallBridge* getBridgeCalls() const;
//! Get Cg context
#ifdef _IRR_COMPILE_WITH_CG_
const CGcontext& getCgContext();
#endif
private:
//! clears the zbuffer and color buffer
......@@ -631,9 +622,6 @@ namespace video
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
CIrrDeviceSDL *SDLDevice;
#endif
#ifdef _IRR_COMPILE_WITH_CG_
CGcontext CgContext;
#endif
E_DEVICE_TYPE DeviceType;
};
......
......@@ -625,8 +625,6 @@
<Unit filename="CCSMLoader.h" />
<Unit filename="CCameraSceneNode.cpp" />
<Unit filename="CCameraSceneNode.h" />
<Unit filename="CCgMaterialRenderer.cpp" />
<Unit filename="CCgMaterialRenderer.h" />
<Unit filename="CColladaFileLoader.cpp" />
<Unit filename="CColladaFileLoader.h" />
<Unit filename="CColladaMeshWriter.cpp" />
......@@ -646,8 +644,6 @@
<Unit filename="CD3D8ShaderMaterialRenderer.h" />
<Unit filename="CD3D8Texture.cpp" />
<Unit filename="CD3D8Texture.h" />
<Unit filename="CD3D9CgMaterialRenderer.cpp" />
<Unit filename="CD3D9CgMaterialRenderer.h" />
<Unit filename="CD3D9Driver.cpp" />
<Unit filename="CD3D9Driver.h" />
<Unit filename="CD3D9HLSLMaterialRenderer.cpp" />
......@@ -842,8 +838,6 @@
<Unit filename="COctreeTriangleSelector.h" />
<Unit filename="COgreMeshFileLoader.cpp" />
<Unit filename="COgreMeshFileLoader.h" />
<Unit filename="COpenGLCgMaterialRenderer.cpp" />
<Unit filename="COpenGLCgMaterialRenderer.h" />
<Unit filename="COpenGLDriver.cpp" />
<Unit filename="COpenGLDriver.h" />
<Unit filename="COpenGLExtensionHandler.cpp" />
......
......@@ -993,14 +993,11 @@
<ClInclude Include="..\..\include\IGUIToolbar.h" />
<ClInclude Include="..\..\include\IGUITreeView.h" />
<ClInclude Include="..\..\include\IGUIWindow.h" />
<ClInclude Include="CCgMaterialRenderer.h" />
<ClInclude Include="CD3D9CgMaterialRenderer.h" />
<ClInclude Include="CDefaultSceneNodeAnimatorFactory.h" />
<ClInclude Include="CDefaultSceneNodeFactory.h" />
<ClInclude Include="CGeometryCreator.h" />
<ClInclude Include="CMeshCache.h" />
<ClInclude Include="CMeshManipulator.h" />
<ClInclude Include="COpenGLCgMaterialRenderer.h" />
<ClInclude Include="CProfiler.h" />
<ClInclude Include="CSceneManager.h" />
<ClInclude Include="Octree.h" />
......@@ -1247,14 +1244,11 @@
<None Include="..\..\readme.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CCgMaterialRenderer.cpp" />
<ClCompile Include="CD3D9CgMaterialRenderer.cpp" />
<ClCompile Include="CDefaultSceneNodeAnimatorFactory.cpp" />
<ClCompile Include="CDefaultSceneNodeFactory.cpp" />
<ClCompile Include="CGeometryCreator.cpp" />
<ClCompile Include="CMeshCache.cpp" />
<ClCompile Include="CMeshManipulator.cpp" />
<ClCompile Include="COpenGLCgMaterialRenderer.cpp" />
<ClCompile Include="CSceneManager.cpp" />
<ClCompile Include="C3DSMeshFileLoader.cpp" />
<ClCompile Include="CSMFMeshFileLoader.cpp" />
......
......@@ -1315,15 +1315,6 @@
<ClInclude Include="..\..\include\EMaterialFlags.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="CD3D9CgMaterialRenderer.h">
<Filter>Irrlicht\video\Direct3D9</Filter>
</ClInclude>
<ClInclude Include="COpenGLCgMaterialRenderer.h">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClInclude>
<ClInclude Include="CCgMaterialRenderer.h">
<Filter>Irrlicht\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SSharedMeshBuffer.h">
<Filter>include\scene</Filter>
</ClInclude>
......@@ -2270,15 +2261,6 @@
<ClCompile Include="CSMFMeshFileLoader.cpp">
<Filter>Irrlicht\scene\loaders</Filter>
</ClCompile>
<ClCompile Include="CD3D9CgMaterialRenderer.cpp">
<Filter>Irrlicht\video\Direct3D9</Filter>
</ClCompile>
<ClCompile Include="COpenGLCgMaterialRenderer.cpp">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClCompile>
<ClCompile Include="CCgMaterialRenderer.cpp">
<Filter>Irrlicht\video</Filter>
</ClCompile>
<ClCompile Include="leakHunter.cpp">
<Filter>Irrlicht\irr</Filter>
</ClCompile>
......
......@@ -1000,14 +1000,11 @@
<ClInclude Include="..\..\include\IGUIToolbar.h" />
<ClInclude Include="..\..\include\IGUITreeView.h" />
<ClInclude Include="..\..\include\IGUIWindow.h" />
<ClInclude Include="CCgMaterialRenderer.h" />
<ClInclude Include="CD3D9CgMaterialRenderer.h" />
<ClInclude Include="CDefaultSceneNodeAnimatorFactory.h" />
<ClInclude Include="CDefaultSceneNodeFactory.h" />
<ClInclude Include="CGeometryCreator.h" />
<ClInclude Include="CMeshCache.h" />
<ClInclude Include="CMeshManipulator.h" />
<ClInclude Include="COpenGLCgMaterialRenderer.h" />
<ClInclude Include="CSceneManager.h" />
<ClInclude Include="Octree.h" />
<ClInclude Include="CSMFMeshFileLoader.h" />
......@@ -1254,14 +1251,11 @@
<None Include="..\..\readme.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CCgMaterialRenderer.cpp" />
<ClCompile Include="CD3D9CgMaterialRenderer.cpp" />
<ClCompile Include="CDefaultSceneNodeAnimatorFactory.cpp" />
<ClCompile Include="CDefaultSceneNodeFactory.cpp" />
<ClCompile Include="CGeometryCreator.cpp" />
<ClCompile Include="CMeshCache.cpp" />
<ClCompile Include="CMeshManipulator.cpp" />
<ClCompile Include="COpenGLCgMaterialRenderer.cpp" />
<ClCompile Include="CSceneManager.cpp" />
<ClCompile Include="C3DSMeshFileLoader.cpp" />
<ClCompile Include="CSMFMeshFileLoader.cpp" />
......
......@@ -1324,9 +1324,6 @@
<ClInclude Include="..\..\include\EMaterialFlags.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="CD3D9CgMaterialRenderer.h">
<Filter>Irrlicht\video\Direct3D9</Filter>
</ClInclude>
<ClInclude Include="COpenGLCgMaterialRenderer.h">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClInclude>
......@@ -2273,9 +2270,6 @@
<ClCompile Include="CSMFMeshFileLoader.cpp">
<Filter>Irrlicht\scene\loaders</Filter>
</ClCompile>
<ClCompile Include="CD3D9CgMaterialRenderer.cpp">
<Filter>Irrlicht\video\Direct3D9</Filter>
</ClCompile>
<ClCompile Include="COpenGLCgMaterialRenderer.cpp">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClCompile>
......
......@@ -1000,14 +1000,11 @@
<ClInclude Include="..\..\include\IGUIToolbar.h" />
<ClInclude Include="..\..\include\IGUITreeView.h" />
<ClInclude Include="..\..\include\IGUIWindow.h" />
<ClInclude Include="CCgMaterialRenderer.h" />
<ClInclude Include="CD3D9CgMaterialRenderer.h" />
<ClInclude Include="CDefaultSceneNodeAnimatorFactory.h" />
<ClInclude Include="CDefaultSceneNodeFactory.h" />
<ClInclude Include="CGeometryCreator.h" />
<ClInclude Include="CMeshCache.h" />
<ClInclude Include="CMeshManipulator.h" />
<ClInclude Include="COpenGLCgMaterialRenderer.h" />
<ClInclude Include="CSceneManager.h" />
<ClInclude Include="Octree.h" />
<ClInclude Include="CSMFMeshFileLoader.h" />
......@@ -1254,14 +1251,11 @@
<None Include="..\..\readme.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CCgMaterialRenderer.cpp" />
<ClCompile Include="CD3D9CgMaterialRenderer.cpp" />
<ClCompile Include="CDefaultSceneNodeAnimatorFactory.cpp" />
<ClCompile Include="CDefaultSceneNodeFactory.cpp" />
<ClCompile Include="CGeometryCreator.cpp" />
<ClCompile Include="CMeshCache.cpp" />
<ClCompile Include="CMeshManipulator.cpp" />
<ClCompile Include="COpenGLCgMaterialRenderer.cpp" />
<ClCompile Include="CSceneManager.cpp" />
<ClCompile Include="C3DSMeshFileLoader.cpp" />
<ClCompile Include="CSMFMeshFileLoader.cpp" />
......
......@@ -1324,15 +1324,6 @@
<ClInclude Include="..\..\include\EMaterialFlags.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="CD3D9CgMaterialRenderer.h">
<Filter>Irrlicht\video\Direct3D9</Filter>
</ClInclude>
<ClInclude Include="COpenGLCgMaterialRenderer.h">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClInclude>
<ClInclude Include="CCgMaterialRenderer.h">
<Filter>Irrlicht\video</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\changes.txt">
......@@ -2273,15 +2264,6 @@
<ClCompile Include="CSMFMeshFileLoader.cpp">
<Filter>Irrlicht\scene\loaders</Filter>
</ClCompile>
<ClCompile Include="CD3D9CgMaterialRenderer.cpp">
<Filter>Irrlicht\video\Direct3D9</Filter>
</ClCompile>
<ClCompile Include="COpenGLCgMaterialRenderer.cpp">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClCompile>
<ClCompile Include="CCgMaterialRenderer.cpp">
<Filter>Irrlicht\video</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Irrlicht.rc" />
......
......@@ -1491,14 +1491,6 @@
<Filter
Name="video impl"
>
<File
RelativePath="CCgMaterialRenderer.cpp"
>
</File>
<File
RelativePath="CCgMaterialRenderer.h"
>
</File>
<File
RelativePath="CVideoModeList.cpp"
>
......@@ -1594,14 +1586,6 @@
<Filter
Name="OpenGL"
>
<File
RelativePath=".\COpenGLCgMaterialRenderer.cpp"
>
</File>
<File
RelativePath=".\COpenGLCgMaterialRenderer.h"
>
</File>
<File
RelativePath=".\COpenGLDriver.cpp"
>
......@@ -1902,14 +1886,6 @@
<Filter
Name="Direct3D9"
>
<File
RelativePath="CD3D9CgMaterialRenderer.cpp"
>
</File>
<File
RelativePath="CD3D9CgMaterialRenderer.h"
>
</File>
<File
RelativePath=".\CD3D9Driver.cpp"
>
......
......@@ -2080,14 +2080,6 @@
<Filter
Name="video"
>
<File
RelativePath="CCgMaterialRenderer.cpp"
>
</File>
<File
RelativePath="CCgMaterialRenderer.h"
>
</File>
<File
RelativePath="CVideoModeList.cpp"
>
......@@ -2183,14 +2175,6 @@
<Filter
Name="OpenGL"
>
<File
RelativePath=".\COpenGLCgMaterialRenderer.cpp"
>
</File>
<File
RelativePath=".\COpenGLCgMaterialRenderer.h"
>
</File>
<File
RelativePath="COpenGLDriver.cpp"
>
......@@ -2499,14 +2483,6 @@
<Filter
Name="Direct3D9"
>
<File
RelativePath="CD3D9CgMaterialRenderer.cpp"
>
</File>
<File
RelativePath="CD3D9CgMaterialRenderer.h"
>
</File>
<File
RelativePath="CD3D9Driver.cpp"
>
......
......@@ -38,7 +38,7 @@ IRRMESHOBJ = $(IRRMESHLOADER) $(IRRMESHWRITER) \
IRROBJ = CBillboardSceneNode.o CCameraSceneNode.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CMeshManipulator.o CMetaTriangleSelector.o COctreeSceneNode.o COctreeTriangleSelector.o CSceneCollisionManager.o CSceneManager.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CVolumeLightSceneNode.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o CSceneLoaderIrr.o
IRRPARTICLEOBJ = CParticleAnimatedMeshSceneNodeEmitter.o CParticleBoxEmitter.o CParticleCylinderEmitter.o CParticleMeshEmitter.o CParticlePointEmitter.o CParticleRingEmitter.o CParticleSphereEmitter.o CParticleAttractionAffector.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticleRotationAffector.o CParticleSystemSceneNode.o CParticleScaleAffector.o
IRRANIMOBJ = CSceneNodeAnimatorCameraFPS.o CSceneNodeAnimatorCameraMaya.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o
IRRDRVROBJ = CNullDriver.o CCgMaterialRenderer.o COpenGLCgMaterialRenderer.o COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o
IRRDRVROBJ = CNullDriver.o COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o
IRRIMAGEOBJ = CColorConverter.o CImage.o CImageLoaderBMP.o CImageLoaderDDS.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderTGA.o CImageLoaderPPM.o CImageLoaderWAL.o CImageLoaderRGB.o \
CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o
IRRVIDEOOBJ = CVideoModeList.o CFPSCounter.o $(IRRDRVROBJ) $(IRRIMAGEOBJ)
......
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