Commit ab9158a5 authored by Administrator's avatar Administrator
Browse files

fixed VertexBuffer link error

DO NOT use template programming in VertexBuffer
parent cb004c2c
......@@ -159,6 +159,7 @@
<ClInclude Include="Bindable.h" />
<ClInclude Include="Drawable.h" />
<ClInclude Include="Graphics.h" />
<ClInclude Include="Structs.h" />
<ClInclude Include="Timer.h" />
<ClInclude Include="Triangle.h" />
<ClInclude Include="VertexBuffer.h" />
......
#pragma once
struct StructVertex
{
struct
{
float x;
float y;
float z;
} pos;
};
\ No newline at end of file
......@@ -10,25 +10,14 @@ Triangle::Triangle(Graphics& gfx, float** position, float r, float g, float b)
b(b),
position(position)
{
struct Vertex
{
struct
{
float x;
float y;
float z;
} pos;
};
const std::vector<Vertex> vertices =
const std::vector<StructVertex> vertices =
{
{ position[0][0], position[0][1], position[0][2] },
{ position[1][0], position[1][1], position[1][2] },
{ position[2][0], position[2][1], position[2][2] }
};
//VertexBuffer vb(gfx, vertices);
//AddBind(std::make_unique<VertexBuffer>(gfx, vertices));
AddBind(std::make_unique<VertexBuffer>(gfx, vertices));
/*
......
#pragma once
#include "VertexBuffer.h"
template<class V>
VertexBuffer::VertexBuffer(Graphics& gfx, const std::vector<V>& vertices)
//template<class V>
VertexBuffer::VertexBuffer(Graphics& gfx, const std::vector<StructVertex>& vertices)
:
stride(sizeof(V))
stride(sizeof(StructVertex))
{
D3D11_BUFFER_DESC bd = {};
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.Usage = D3D11_USAGE_DEFAULT;
bd.CPUAccessFlags = 0u;
bd.MiscFlags = 0u;
bd.ByteWidth = UINT(sizeof(V) * vertices.size());
bd.StructureByteStride = sizeof(V);
bd.ByteWidth = UINT(sizeof(StructVertex) * vertices.size());
bd.StructureByteStride = sizeof(StructVertex);
D3D11_SUBRESOURCE_DATA sd = {};
sd.pSysMem = vertices.data();
GetDevice(gfx)->CreateBuffer(&bd, &sd, &pVertexBuffer);
......
......@@ -3,12 +3,12 @@
#include <wrl.h>
#include <d3d11.h>
#include <vector>
#include "Structs.h"
class VertexBuffer : public Bindable
{
public:
template<class V>
VertexBuffer(Graphics& gfx, const std::vector<V>& vertices);
VertexBuffer(Graphics& gfx, const std::vector<StructVertex>& vertices);
void Bind(Graphics& gfx) noexcept override;
protected:
......
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