Torque3D/Engine/source/materials/shaderMaterialParameters.h
marauder2k7 2b295fb7f0 rest of virtuals removed
virtuals removed and replaced with override where necessary on the rest of the code base, clang-tidy to the rescue.
2024-03-18 18:40:22 +00:00

101 lines
4.5 KiB
C++

//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _SHADERMATERIALPARAMETERS_H_
#define _SHADERMATERIALPARAMETERS_H_
#ifndef _MATERIALPARAMETERS_H_
#include "materials/materialParameters.h"
#endif
#ifndef _GFXSHADER_H_
#include "gfx/gfxShader.h"
#endif
class ShaderMaterialParameterHandle : public MaterialParameterHandle
{
friend class ShaderMaterialParameters;
public:
virtual ~ShaderMaterialParameterHandle();
ShaderMaterialParameterHandle(const String& name);
ShaderMaterialParameterHandle(const String& name, Vector<GFXShader*>& shaders);
const String& getName() const override { return mName; }
S32 getSamplerRegister( U32 pass ) const override;
// NOTE: We always return true here instead of querying the
// children... often there is only one element, so lets just
// hit the loop once on the set.
bool isValid() const override { return true; };
protected:
Vector< GFXShaderConstHandle* > mHandles;
String mName;
};
// This is the union of all of the shaders contained in a material
class ShaderMaterialParameters : public MaterialParameters
{
public:
ShaderMaterialParameters();
virtual ~ShaderMaterialParameters();
void setBuffers(Vector<GFXShaderConstDesc>& constDesc, Vector<GFXShaderConstBufferRef>& buffers);
GFXShaderConstBuffer* getBuffer(U32 i) { return mBuffers[i]; }
///
/// MaterialParameter interface
///
/// Returns the material parameter handle for name.
void set(MaterialParameterHandle* handle, const F32 f) override;
void set(MaterialParameterHandle* handle, const Point2F& fv) override;
void set(MaterialParameterHandle* handle, const Point3F& fv) override;
void set(MaterialParameterHandle* handle, const Point4F& fv) override;
virtual void set(MaterialParameterHandle* handle, const PlaneF& fv);
void set(MaterialParameterHandle* handle, const LinearColorF& fv) override;
void set(MaterialParameterHandle* handle, const S32 f) override;
void set(MaterialParameterHandle* handle, const Point2I& fv) override;
void set(MaterialParameterHandle* handle, const Point3I& fv) override;
void set(MaterialParameterHandle* handle, const Point4I& fv) override;
void set(MaterialParameterHandle* handle, const AlignedArray<F32>& fv) override;
void set(MaterialParameterHandle* handle, const AlignedArray<Point2F>& fv) override;
void set(MaterialParameterHandle* handle, const AlignedArray<Point3F>& fv) override;
void set(MaterialParameterHandle* handle, const AlignedArray<Point4F>& fv) override;
void set(MaterialParameterHandle* handle, const AlignedArray<S32>& fv) override;
void set(MaterialParameterHandle* handle, const AlignedArray<Point2I>& fv) override;
void set(MaterialParameterHandle* handle, const AlignedArray<Point3I>& fv) override;
void set(MaterialParameterHandle* handle, const AlignedArray<Point4I>& fv) override;
void set(MaterialParameterHandle* handle, const MatrixF& mat, const GFXShaderConstType matrixType = GFXSCT_Float4x4) override;
void set(MaterialParameterHandle* handle, const MatrixF* mat, const U32 arraySize, const GFXShaderConstType matrixType = GFXSCT_Float4x4) override;
U32 getAlignmentValue(const GFXShaderConstType constType) override;
private:
Vector<GFXShaderConstBufferRef> mBuffers;
void releaseBuffers();
};
#endif