Hello there,
I'm trying to build a class that is responsible for loading and managing a vertex shader.
The idea is to have a separate class for managing the constant buffer (the data a vertex shader needs.)
This class looks like this:
dxman_cbuffer.h
#pragma once
#include "dxman_common.h"
#include <D3D11.h>
template <typename Buffer>
class ConstantBuffer
{
private:
ID3D11Buffer *_buffer;
const Buffer *_content;
public:
HRESULT Init(ID3D11Device* dev, Buffer* initialData);
void Exit();
ID3D11Buffer* GetBuffer() const;
HRESULT SetBufferData (ID3D11DeviceContext* devcon, Buffer *content);
const Buffer* GetBufferData() const;
};
The problem occours in this class:
ColorShader.h
#pragma once
#include "common.h"
#include "dxman_shader.h"
#include "dxman_cbuffer.h"
class VSColor : public IVertexShader
{
private:
struct SMatrixBuffer
{
XMMATRIX worldViewProj;
};
ConstantBuffer<SMatrixBuffer> _cbPerObject;
public:
virtual HRESULT Init (ID3D11Device *dev); //Loads the shader & creates the constant buffer
virtual void Exit(); //Releases all resources
virtual void Activate (ID3D11DeviceContext* devcon); //Sets the shader and the constant buffer to the Vertex Shader stage
virtual HRESULT UpdateMatrixBuffer (ID3D11DeviceContext *devcon, XMMATRIX &worldViewProj); //Updates the buffer data
};
Since the template class ConstantBuffer<SMatrixBuffer> is never declared, the linker can't find any symbols. The problem is that I can't just write ConstantBuffer<SMatrixBuffer> in dxman_cbuffer.cpp (where the ConstantBuffer class is) since SMatrixBuffer is declared as private in another class. (And I want to keep both files separated!)