add mesh creation (WIP)
This commit is contained in:
@@ -194,6 +194,7 @@
|
|||||||
<ClInclude Include="Mesh.h" />
|
<ClInclude Include="Mesh.h" />
|
||||||
<ClInclude Include="Time.h" />
|
<ClInclude Include="Time.h" />
|
||||||
<ClInclude Include="Utilities.h" />
|
<ClInclude Include="Utilities.h" />
|
||||||
|
<ClInclude Include="Vertex.h" />
|
||||||
<ClInclude Include="Window.h" />
|
<ClInclude Include="Window.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -68,5 +68,8 @@
|
|||||||
<ClInclude Include="Window.h">
|
<ClInclude Include="Window.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Vertex.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
#include "Vertex.h"
|
||||||
|
|
||||||
UINT Mesh::init(IDirect3DDevice9* pD3DDevice)
|
UINT Mesh::init(IDirect3DDevice9* pD3DDevice)
|
||||||
{
|
{
|
||||||
@@ -30,6 +31,21 @@ void Mesh::deInit()
|
|||||||
|
|
||||||
UINT Mesh::createVertexBuffer(IDirect3DDevice9* pD3DDevice)
|
UINT Mesh::createVertexBuffer(IDirect3DDevice9* pD3DDevice)
|
||||||
{
|
{
|
||||||
|
// 1. define mesh structure
|
||||||
|
_vertexCount = 3;
|
||||||
|
_vertexStride = sizeof(Vertex);
|
||||||
|
|
||||||
|
// 2. create vertex buffer WITHOUT data
|
||||||
|
HRESULT hr = pD3DDevice->CreateVertexBuffer(
|
||||||
|
_vertexCount * _vertexStride, // vertex buffer byte length
|
||||||
|
D3DUSAGE_WRITEONLY, // vertex buffer access mode
|
||||||
|
FVF, // FVF - Flexible Vertex Format
|
||||||
|
D3DPOOL_MANAGED, // video memory management
|
||||||
|
&_pVertexBuffer,
|
||||||
|
nullptr // not used anymore
|
||||||
|
);
|
||||||
|
|
||||||
|
// 3. fill vertex buffer with data
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <d3d9.h>
|
||||||
|
|
||||||
|
#define FVF D3DFVF_XYZ
|
||||||
|
|
||||||
|
struct Vertex
|
||||||
|
{
|
||||||
|
FLOAT x;
|
||||||
|
FLOAT y;
|
||||||
|
FLOAT z;
|
||||||
|
|
||||||
|
Vertex() : x(0.0f), y(0.0f), z(0.0f) {}
|
||||||
|
Vertex(FLOAT _x, FLOAT _y, FLOAT _z) : x(_x), y(_y), z(_z) {}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user