parent
aa8a6122ce
commit
31c6f0db92
|
@ -7,11 +7,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <d3d11_1.h>
|
#include <d3d11_1.h>
|
||||||
#include <DirectXMath.h>
|
#include <DirectXMath.h>
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
|
|
||||||
#include "SafeRelease.hpp"
|
#include "SafeRelease.hpp"
|
||||||
|
@ -26,16 +24,16 @@ struct Texture {
|
||||||
string path;
|
string path;
|
||||||
ID3D11ShaderResourceView *texture;
|
ID3D11ShaderResourceView *texture;
|
||||||
|
|
||||||
inline void Release() {
|
void Release() {
|
||||||
SafeRelease(texture);
|
SafeRelease(texture);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Mesh {
|
class Mesh {
|
||||||
public:
|
public:
|
||||||
vector<VERTEX> vertices;
|
std::vector<VERTEX> vertices;
|
||||||
vector<UINT> indices;
|
std::vector<UINT> indices;
|
||||||
vector<Texture> textures;
|
std::vector<Texture> textures;
|
||||||
ID3D11Device *dev;
|
ID3D11Device *dev;
|
||||||
|
|
||||||
Mesh(ID3D11Device *dev, const vector<VERTEX>& vertices, const vector<UINT>& indices, const vector<Texture>& textures) :
|
Mesh(ID3D11Device *dev, const vector<VERTEX>& vertices, const vector<UINT>& indices, const vector<Texture>& textures) :
|
||||||
|
@ -44,13 +42,11 @@ public:
|
||||||
textures(textures),
|
textures(textures),
|
||||||
dev(dev),
|
dev(dev),
|
||||||
VertexBuffer(nullptr),
|
VertexBuffer(nullptr),
|
||||||
IndexBuffer(nullptr)
|
IndexBuffer(nullptr) {
|
||||||
{
|
|
||||||
this->setupMesh(this->dev);
|
this->setupMesh(this->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw(ID3D11DeviceContext *devcon)
|
void Draw(ID3D11DeviceContext *devcon) {
|
||||||
{
|
|
||||||
UINT stride = sizeof(VERTEX);
|
UINT stride = sizeof(VERTEX);
|
||||||
UINT offset = 0;
|
UINT offset = 0;
|
||||||
|
|
||||||
|
@ -62,19 +58,17 @@ public:
|
||||||
devcon->DrawIndexed(static_cast<UINT>(indices.size()), 0, 0);
|
devcon->DrawIndexed(static_cast<UINT>(indices.size()), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close()
|
void Close() {
|
||||||
{
|
|
||||||
SafeRelease(VertexBuffer);
|
SafeRelease(VertexBuffer);
|
||||||
SafeRelease(IndexBuffer);
|
SafeRelease(IndexBuffer);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
/* Render data */
|
// Render data
|
||||||
ID3D11Buffer *VertexBuffer, *IndexBuffer;
|
ID3D11Buffer *VertexBuffer, *IndexBuffer;
|
||||||
|
|
||||||
/* Functions */
|
// Functions
|
||||||
// Initializes all the buffer objects/arrays
|
// Initializes all the buffer objects/arrays
|
||||||
void setupMesh(ID3D11Device *dev)
|
void setupMesh(ID3D11Device *dev) {
|
||||||
{
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
D3D11_BUFFER_DESC vbd;
|
D3D11_BUFFER_DESC vbd;
|
||||||
|
|
Loading…
Reference in New Issue