Use CSmartPtr for vertex program
This commit is contained in:
parent
14026e6f08
commit
680f260803
10 changed files with 77 additions and 61 deletions
|
@ -86,6 +86,9 @@ struct CGPUProgramFeatures
|
||||||
ModelViewProjectionTranspose = 0x00000400,
|
ModelViewProjectionTranspose = 0x00000400,
|
||||||
ModelViewProjectionInverseTranspose = 0x00000800,
|
ModelViewProjectionInverseTranspose = 0x00000800,
|
||||||
|
|
||||||
|
// Fog
|
||||||
|
Fog = 0x00001000,
|
||||||
|
|
||||||
//
|
//
|
||||||
// Rough example, modify as necessary.
|
// Rough example, modify as necessary.
|
||||||
//
|
//
|
||||||
|
@ -144,6 +147,8 @@ struct CGPUProgramIndices
|
||||||
uint ModelViewProjectionTranspose;
|
uint ModelViewProjectionTranspose;
|
||||||
uint ModelViewProjectionInverseTranspose;
|
uint ModelViewProjectionInverseTranspose;
|
||||||
|
|
||||||
|
uint Fog;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Rough example, modify as necessary.
|
// Rough example, modify as necessary.
|
||||||
//
|
//
|
||||||
|
|
|
@ -84,7 +84,7 @@ private:
|
||||||
bool _IsPointLight;
|
bool _IsPointLight;
|
||||||
//
|
//
|
||||||
enum { NumVp = 8};
|
enum { NumVp = 8};
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgram[NumVp];
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgram[NumVp];
|
||||||
};
|
};
|
||||||
|
|
||||||
} // NL3D
|
} // NL3D
|
||||||
|
|
|
@ -112,7 +112,7 @@ private:
|
||||||
/** The 16 versions: Specular or not (0 or 2), + normalize normal or not (0 or 1).
|
/** The 16 versions: Specular or not (0 or 2), + normalize normal or not (0 or 1).
|
||||||
* All multiplied by 4, because support from 0 to 3 pointLights activated. (0.., 4.., 8.., 12..)
|
* All multiplied by 4, because support from 0 to 3 pointLights activated. (0.., 4.., 8.., 12..)
|
||||||
*/
|
*/
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgram[NumVp];
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgram[NumVp];
|
||||||
|
|
||||||
// WindTree Time for this mesh param setup. Stored in mesh because same for all instances.
|
// WindTree Time for this mesh param setup. Stored in mesh because same for all instances.
|
||||||
float _CurrentTime[HrcDepth];
|
float _CurrentTime[HrcDepth];
|
||||||
|
|
|
@ -247,17 +247,17 @@ private:
|
||||||
static bool _GridSizeTouched;
|
static bool _GridSizeTouched;
|
||||||
|
|
||||||
//
|
//
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgramBump1;
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgramBump1;
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgramBump2;
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgramBump2;
|
||||||
//
|
//
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgramBump1Diffuse;
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgramBump1Diffuse;
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgramBump2Diffuse;
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgramBump2Diffuse;
|
||||||
//
|
//
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgramNoBump;
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgramNoBump;
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgramNoBumpDiffuse;
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgramNoBumpDiffuse;
|
||||||
//
|
//
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgramNoWave;
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgramNoWave;
|
||||||
static std::auto_ptr<CVertexProgram> _VertexProgramNoWaveDiffuse;
|
static NLMISC::CSmartPtr<CVertexProgram> _VertexProgramNoWaveDiffuse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -415,7 +415,7 @@ void CDriverGL::setUniformParams(TProgram program, const CGPUProgramParams ¶
|
||||||
{
|
{
|
||||||
const std::string &name = params.getNameByOffset(offset);
|
const std::string &name = params.getNameByOffset(offset);
|
||||||
nlassert(!name.empty() /* missing both parameter name and index, code error */);
|
nlassert(!name.empty() /* missing both parameter name and index, code error */);
|
||||||
uint index = prog->getUniformIndex(name);
|
uint index = prog->getUniformIndex(name.c_str());
|
||||||
nlassert(index != ~0 /* invalid parameter name */);
|
nlassert(index != ~0 /* invalid parameter name */);
|
||||||
params.map(index, name);
|
params.map(index, name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,112 +84,121 @@ void IGPUProgram::buildInfo(CSource *source)
|
||||||
|
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelView)
|
if (features.DriverFlags & CGPUProgramFeatures::ModelView)
|
||||||
{
|
{
|
||||||
m_Indices.ModelView = getUniformIndex("nlModelView");
|
m_Indices.ModelView = getUniformIndex("modelView");
|
||||||
if (m_Indices.ModelView == ~0)
|
if (m_Indices.ModelView == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlModelView' in gpu program '%s', ModelView disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'modelView' in gpu program '%s', ModelView disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ModelView;
|
features.DriverFlags &= ~CGPUProgramFeatures::ModelView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewInverse)
|
if (features.DriverFlags & CGPUProgramFeatures::ModelViewInverse)
|
||||||
{
|
{
|
||||||
m_Indices.ModelViewInverse = getUniformIndex("nlModelViewInverse");
|
m_Indices.ModelViewInverse = getUniformIndex("modelViewInverse");
|
||||||
if (m_Indices.ModelViewInverse == ~0)
|
if (m_Indices.ModelViewInverse == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlModelViewInverse' in gpu program '%s', ModelViewInverse disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'modelViewInverse' in gpu program '%s', ModelViewInverse disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewInverse;
|
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewInverse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewTranspose)
|
if (features.DriverFlags & CGPUProgramFeatures::ModelViewTranspose)
|
||||||
{
|
{
|
||||||
m_Indices.ModelViewTranspose = getUniformIndex("nlModelViewTranspose");
|
m_Indices.ModelViewTranspose = getUniformIndex("modelViewTranspose");
|
||||||
if (m_Indices.ModelViewTranspose == ~0)
|
if (m_Indices.ModelViewTranspose == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlModelViewTranspose' in gpu program '%s', ModelViewTranspose disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'modelViewTranspose' in gpu program '%s', ModelViewTranspose disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewTranspose;
|
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewTranspose;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewInverseTranspose)
|
if (features.DriverFlags & CGPUProgramFeatures::ModelViewInverseTranspose)
|
||||||
{
|
{
|
||||||
m_Indices.ModelViewInverseTranspose = getUniformIndex("nlModelViewInverseTranspose");
|
m_Indices.ModelViewInverseTranspose = getUniformIndex("modelViewInverseTranspose");
|
||||||
if (m_Indices.ModelViewInverseTranspose == ~0)
|
if (m_Indices.ModelViewInverseTranspose == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlModelViewInverseTranspose' in gpu program '%s', ModelViewInverseTranspose disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'modelViewInverseTranspose' in gpu program '%s', ModelViewInverseTranspose disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewInverseTranspose;
|
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewInverseTranspose;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::Projection)
|
if (features.DriverFlags & CGPUProgramFeatures::Projection)
|
||||||
{
|
{
|
||||||
m_Indices.Projection = getUniformIndex("nlProjection");
|
m_Indices.Projection = getUniformIndex("projection");
|
||||||
if (m_Indices.Projection == ~0)
|
if (m_Indices.Projection == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlProjection' in gpu program '%s', Projection disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'projection' in gpu program '%s', Projection disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::Projection;
|
features.DriverFlags &= ~CGPUProgramFeatures::Projection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ProjectionInverse)
|
if (features.DriverFlags & CGPUProgramFeatures::ProjectionInverse)
|
||||||
{
|
{
|
||||||
m_Indices.ProjectionInverse = getUniformIndex("nlProjectionInverse");
|
m_Indices.ProjectionInverse = getUniformIndex("projectionInverse");
|
||||||
if (m_Indices.ProjectionInverse == ~0)
|
if (m_Indices.ProjectionInverse == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlProjectionInverse' in gpu program '%s', ProjectionInverse disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'projectionInverse' in gpu program '%s', ProjectionInverse disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ProjectionInverse;
|
features.DriverFlags &= ~CGPUProgramFeatures::ProjectionInverse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ProjectionTranspose)
|
if (features.DriverFlags & CGPUProgramFeatures::ProjectionTranspose)
|
||||||
{
|
{
|
||||||
m_Indices.ProjectionTranspose = getUniformIndex("nlProjectionTranspose");
|
m_Indices.ProjectionTranspose = getUniformIndex("projectionTranspose");
|
||||||
if (m_Indices.ProjectionTranspose == ~0)
|
if (m_Indices.ProjectionTranspose == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlProjectionTranspose' in gpu program '%s', ProjectionTranspose disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'projectionTranspose' in gpu program '%s', ProjectionTranspose disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ProjectionTranspose;
|
features.DriverFlags &= ~CGPUProgramFeatures::ProjectionTranspose;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ProjectionInverseTranspose)
|
if (features.DriverFlags & CGPUProgramFeatures::ProjectionInverseTranspose)
|
||||||
{
|
{
|
||||||
m_Indices.ProjectionInverseTranspose = getUniformIndex("nlProjectionInverseTranspose");
|
m_Indices.ProjectionInverseTranspose = getUniformIndex("projectionInverseTranspose");
|
||||||
if (m_Indices.ProjectionInverseTranspose == ~0)
|
if (m_Indices.ProjectionInverseTranspose == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlProjectionInverseTranspose' in gpu program '%s', ProjectionInverseTranspose disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'projectionInverseTranspose' in gpu program '%s', ProjectionInverseTranspose disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ProjectionInverseTranspose;
|
features.DriverFlags &= ~CGPUProgramFeatures::ProjectionInverseTranspose;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjection)
|
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjection)
|
||||||
{
|
{
|
||||||
m_Indices.ModelViewProjection = getUniformIndex("nlModelViewProjection");
|
m_Indices.ModelViewProjection = getUniformIndex("modelViewProjection");
|
||||||
if (m_Indices.ModelViewProjection == ~0)
|
if (m_Indices.ModelViewProjection == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlModelViewProjection' in gpu program '%s', ModelViewProjection disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'modelViewProjection' in gpu program '%s', ModelViewProjection disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewProjection;
|
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewProjection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjectionInverse)
|
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjectionInverse)
|
||||||
{
|
{
|
||||||
m_Indices.ModelViewProjectionInverse = getUniformIndex("nlModelViewProjectionInverse");
|
m_Indices.ModelViewProjectionInverse = getUniformIndex("modelViewProjectionInverse");
|
||||||
if (m_Indices.ModelViewProjectionInverse == ~0)
|
if (m_Indices.ModelViewProjectionInverse == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlModelViewProjectionInverse' in gpu program '%s', ModelViewProjectionInverse disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'modelViewProjectionInverse' in gpu program '%s', ModelViewProjectionInverse disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewProjectionInverse;
|
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewProjectionInverse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjectionTranspose)
|
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjectionTranspose)
|
||||||
{
|
{
|
||||||
m_Indices.ModelViewProjectionTranspose = getUniformIndex("nlModelViewProjectionTranspose");
|
m_Indices.ModelViewProjectionTranspose = getUniformIndex("modelViewProjectionTranspose");
|
||||||
if (m_Indices.ModelViewProjectionTranspose == ~0)
|
if (m_Indices.ModelViewProjectionTranspose == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlModelViewProjectionTranspose' in gpu program '%s', ModelViewProjectionTranspose disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'modelViewProjectionTranspose' in gpu program '%s', ModelViewProjectionTranspose disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewProjectionTranspose;
|
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewProjectionTranspose;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjectionInverseTranspose)
|
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjectionInverseTranspose)
|
||||||
{
|
{
|
||||||
m_Indices.ModelViewProjectionInverseTranspose = getUniformIndex("nlModelViewProjectionInverseTranspose");
|
m_Indices.ModelViewProjectionInverseTranspose = getUniformIndex("modelViewProjectionInverseTranspose");
|
||||||
if (m_Indices.ModelViewProjectionInverseTranspose == ~0)
|
if (m_Indices.ModelViewProjectionInverseTranspose == ~0)
|
||||||
{
|
{
|
||||||
nlwarning("Missing 'nlModelViewProjectionInverseTranspose' in gpu program '%s', ModelViewProjectionInverseTranspose disabled", source->DisplayName.c_str());
|
nlwarning("Missing 'modelViewProjectionInverseTranspose' in gpu program '%s', ModelViewProjectionInverseTranspose disabled", source->DisplayName.c_str());
|
||||||
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewProjectionInverseTranspose;
|
features.DriverFlags &= ~CGPUProgramFeatures::ModelViewProjectionInverseTranspose;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (features.DriverFlags & CGPUProgramFeatures::Fog)
|
||||||
|
{
|
||||||
|
m_Indices.Fog = getUniformIndex("fog");
|
||||||
|
if (m_Indices.Fog == ~0)
|
||||||
|
{
|
||||||
|
nlwarning("Missing 'fog' in gpu program '%s', Fog disabled", source->DisplayName.c_str());
|
||||||
|
features.DriverFlags &= ~CGPUProgramFeatures::Fog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Rough example, modify as necessary.
|
// Rough example, modify as necessary.
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
namespace NL3D
|
namespace NL3D
|
||||||
{
|
{
|
||||||
std::auto_ptr<CVertexProgram> CMeshVPPerPixelLight::_VertexProgram[NumVp];
|
NLMISC::CSmartPtr<CVertexProgram> CMeshVPPerPixelLight::_VertexProgram[NumVp];
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Light VP fragment constants start at 24
|
// Light VP fragment constants start at 24
|
||||||
|
@ -414,7 +414,7 @@ void CMeshVPPerPixelLight::initInstance(CMeshBaseInstance *mbi)
|
||||||
nlassert(0);
|
nlassert(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
_VertexProgram[vp]= std::auto_ptr<CVertexProgram>(new CVertexProgram(vpCode.c_str()));
|
_VertexProgram[vp] = new CVertexProgram(vpCode.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -521,7 +521,7 @@ void CMeshVPPerPixelLight::enable(bool enabled, IDriver *drv)
|
||||||
| (SpecularLighting ? 2 : 0)
|
| (SpecularLighting ? 2 : 0)
|
||||||
| (_IsPointLight ? 1 : 0);
|
| (_IsPointLight ? 1 : 0);
|
||||||
//
|
//
|
||||||
drv->activeVertexProgram(_VertexProgram[idVP].get());
|
drv->activeVertexProgram(_VertexProgram[idVP]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,7 @@ static const uint VPLightConstantStart= 24;
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
std::auto_ptr<CVertexProgram> CMeshVPWindTree::_VertexProgram[CMeshVPWindTree::NumVp];
|
NLMISC::CSmartPtr<CVertexProgram> CMeshVPWindTree::_VertexProgram[CMeshVPWindTree::NumVp];
|
||||||
|
|
||||||
static const char* WindTreeVPCodeWave=
|
static const char* WindTreeVPCodeWave=
|
||||||
"!!VP1.0 \n\
|
"!!VP1.0 \n\
|
||||||
|
@ -157,7 +157,7 @@ void CMeshVPWindTree::initInstance(CMeshBaseInstance *mbi)
|
||||||
vpCode= string(WindTreeVPCodeWave)
|
vpCode= string(WindTreeVPCodeWave)
|
||||||
+ CRenderTrav::getLightVPFragment(numPls, VPLightConstantStart, specular, normalize)
|
+ CRenderTrav::getLightVPFragment(numPls, VPLightConstantStart, specular, normalize)
|
||||||
+ WindTreeVPCodeEnd;
|
+ WindTreeVPCodeEnd;
|
||||||
_VertexProgram[i]= std::auto_ptr<CVertexProgram>(new CVertexProgram(vpCode.c_str()));
|
_VertexProgram[i] = new CVertexProgram(vpCode.c_str());
|
||||||
// TODO_VP_GLSL
|
// TODO_VP_GLSL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *m
|
||||||
idVP= numPls*4 + idVP;
|
idVP= numPls*4 + idVP;
|
||||||
|
|
||||||
// activate VP.
|
// activate VP.
|
||||||
driver->activeVertexProgram(_VertexProgram[idVP].get());
|
driver->activeVertexProgram(_VertexProgram[idVP]);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -383,7 +383,7 @@ void CMeshVPWindTree::beginMBRMesh(IDriver *driver, CScene *scene)
|
||||||
_LastMBRIdVP= 0;
|
_LastMBRIdVP= 0;
|
||||||
|
|
||||||
// activate VP.
|
// activate VP.
|
||||||
driver->activeVertexProgram(_VertexProgram[_LastMBRIdVP].get());
|
driver->activeVertexProgram(_VertexProgram[_LastMBRIdVP]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -407,7 +407,7 @@ void CMeshVPWindTree::beginMBRInstance(IDriver *driver, CScene *scene, CMeshBase
|
||||||
if( idVP!=_LastMBRIdVP )
|
if( idVP!=_LastMBRIdVP )
|
||||||
{
|
{
|
||||||
_LastMBRIdVP= idVP;
|
_LastMBRIdVP= idVP;
|
||||||
driver->activeVertexProgram(_VertexProgram[_LastMBRIdVP].get());
|
driver->activeVertexProgram(_VertexProgram[_LastMBRIdVP]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -908,6 +908,10 @@ void CWaterModel::setupMaterialNVertexShader(IDriver *drv, CWaterShape *shape, c
|
||||||
//=========================//
|
//=========================//
|
||||||
// setup Water material //
|
// setup Water material //
|
||||||
//=========================//
|
//=========================//
|
||||||
|
shape->initVertexProgram();
|
||||||
|
CVertexProgram *program = shape->_ColorMap ? CWaterShape::_VertexProgramNoWaveDiffuse : CWaterShape::_VertexProgramNoWave;
|
||||||
|
drv->activeVertexProgram(program);
|
||||||
|
// TODO_VP_MATERIAL
|
||||||
CWaterModel::_WaterMat.setTexture(0, shape->_BumpMap[0]);
|
CWaterModel::_WaterMat.setTexture(0, shape->_BumpMap[0]);
|
||||||
CWaterModel::_WaterMat.setTexture(1, shape->_BumpMap[1]);
|
CWaterModel::_WaterMat.setTexture(1, shape->_BumpMap[1]);
|
||||||
CWaterModel::_WaterMat.setTexture(3, shape->_ColorMap);
|
CWaterModel::_WaterMat.setTexture(3, shape->_ColorMap);
|
||||||
|
@ -969,8 +973,6 @@ void CWaterModel::setupMaterialNVertexShader(IDriver *drv, CWaterShape *shape, c
|
||||||
cst[10].set(0.5f, 0.5f, 0.f, 1.f); // used to scale reflected ray into the envmap
|
cst[10].set(0.5f, 0.5f, 0.f, 1.f); // used to scale reflected ray into the envmap
|
||||||
/// set all our constants in one call
|
/// set all our constants in one call
|
||||||
drv->setConstant(cstOffset, sizeof(cst) / sizeof(cst[0]) - cstOffset, (float *) &cst[cstOffset]);
|
drv->setConstant(cstOffset, sizeof(cst) / sizeof(cst[0]) - cstOffset, (float *) &cst[cstOffset]);
|
||||||
shape->initVertexProgram();
|
|
||||||
drv->activeVertexProgram(shape->_ColorMap ? CWaterShape::_VertexProgramNoWaveDiffuse.get() : CWaterShape::_VertexProgramNoWave.get());
|
|
||||||
drv->setConstantFog(4);
|
drv->setConstantFog(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,15 +188,15 @@ uint32 CWaterShape::_XGridBorder = 4;
|
||||||
uint32 CWaterShape::_YGridBorder = 4;
|
uint32 CWaterShape::_YGridBorder = 4;
|
||||||
uint32 CWaterShape::_MaxGridSize;
|
uint32 CWaterShape::_MaxGridSize;
|
||||||
bool CWaterShape::_GridSizeTouched = true;
|
bool CWaterShape::_GridSizeTouched = true;
|
||||||
std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramBump1;
|
NLMISC::CSmartPtr<CVertexProgram> CWaterShape::_VertexProgramBump1;
|
||||||
std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramBump2;
|
NLMISC::CSmartPtr<CVertexProgram> CWaterShape::_VertexProgramBump2;
|
||||||
std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramBump1Diffuse;
|
NLMISC::CSmartPtr<CVertexProgram> CWaterShape::_VertexProgramBump1Diffuse;
|
||||||
std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramBump2Diffuse;
|
NLMISC::CSmartPtr<CVertexProgram> CWaterShape::_VertexProgramBump2Diffuse;
|
||||||
std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramNoBump;
|
NLMISC::CSmartPtr<CVertexProgram> CWaterShape::_VertexProgramNoBump;
|
||||||
std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramNoBumpDiffuse;
|
NLMISC::CSmartPtr<CVertexProgram> CWaterShape::_VertexProgramNoBumpDiffuse;
|
||||||
// water with no waves
|
// water with no waves
|
||||||
std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramNoWave;
|
NLMISC::CSmartPtr<CVertexProgram> CWaterShape::_VertexProgramNoWave;
|
||||||
std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramNoWaveDiffuse;
|
NLMISC::CSmartPtr<CVertexProgram> CWaterShape::_VertexProgramNoWaveDiffuse;
|
||||||
|
|
||||||
|
|
||||||
/** Build a vertex program for water depending on requirements
|
/** Build a vertex program for water depending on requirements
|
||||||
|
@ -322,17 +322,17 @@ void CWaterShape::initVertexProgram()
|
||||||
if (!created)
|
if (!created)
|
||||||
{
|
{
|
||||||
// waves
|
// waves
|
||||||
_VertexProgramBump1 = std::auto_ptr<CVertexProgram>(BuildWaterVP(false, true, false));
|
_VertexProgramBump1 = BuildWaterVP(false, true, false);
|
||||||
_VertexProgramBump2 = std::auto_ptr<CVertexProgram>(BuildWaterVP(false, true, true));
|
_VertexProgramBump2 = BuildWaterVP(false, true, true);
|
||||||
|
|
||||||
_VertexProgramBump1Diffuse = std::auto_ptr<CVertexProgram>(BuildWaterVP(true, true, false));
|
_VertexProgramBump1Diffuse = BuildWaterVP(true, true, false);
|
||||||
_VertexProgramBump2Diffuse = std::auto_ptr<CVertexProgram>(BuildWaterVP(true, true, true));
|
_VertexProgramBump2Diffuse = BuildWaterVP(true, true, true);
|
||||||
|
|
||||||
_VertexProgramNoBump = std::auto_ptr<CVertexProgram>(BuildWaterVP(false, false, false));
|
_VertexProgramNoBump = BuildWaterVP(false, false, false);
|
||||||
_VertexProgramNoBumpDiffuse = std::auto_ptr<CVertexProgram>(BuildWaterVP(true, false, false));
|
_VertexProgramNoBumpDiffuse = BuildWaterVP(true, false, false);
|
||||||
// no waves
|
// no waves
|
||||||
_VertexProgramNoWave.reset(new CVertexProgram(WaterVPNoWave)); // TODO_VP_GLSL
|
_VertexProgramNoWave = new CVertexProgram(WaterVPNoWave); // TODO_VP_GLSL
|
||||||
_VertexProgramNoWaveDiffuse.reset(new CVertexProgram(WaterVPNoWaveDiffuse)); // TODO_VP_GLSL
|
_VertexProgramNoWaveDiffuse = new CVertexProgram(WaterVPNoWaveDiffuse); // TODO_VP_GLSL
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue