Update Mesh.h

Apply code style.
pull/3053/head
Kim Kulling 2020-03-07 12:19:55 +01:00 committed by GitHub
parent aa8a6122ce
commit 31c6f0db92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 59 additions and 65 deletions

View File

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