add vertex color

add time calculation
This commit is contained in:
2025-11-12 13:49:37 +01:00
parent 589d0933f4
commit 6470789977
3 changed files with 15 additions and 11 deletions
+8 -8
View File
@@ -130,16 +130,16 @@ UINT Mesh::createVertexBuffer(IDirect3DDevice9* pD3DDevice)
// cube
// front
pVertices[0] = Vertex(-0.5f, 0.5f, -0.5f);
pVertices[1] = Vertex(0.5f, 0.5f, -0.5f);
pVertices[2] = Vertex(0.5f, -0.5f, -0.5f);
pVertices[3] = Vertex(-0.5f, -0.5f, -0.5f);
pVertices[0] = Vertex(-0.5f, 0.5f, -0.5f, 255, 0, 0);
pVertices[1] = Vertex(0.5f, 0.5f, -0.5f, 0, 255, 0);
pVertices[2] = Vertex(0.5f, -0.5f, -0.5f, 0, 0, 255);
pVertices[3] = Vertex(-0.5f, -0.5f, -0.5f, 255, 0, 255);
// back
pVertices[4] = Vertex(0.5f, 0.5f, 0.5f);
pVertices[5] = Vertex(-0.5f, 0.5f, 0.5f);
pVertices[6] = Vertex(-0.5f, -0.5f, 0.5f);
pVertices[7] = Vertex(0.5f, -0.5f, 0.5f);
pVertices[4] = Vertex(0.5f, 0.5f, 0.5f, 255, 255, 0);
pVertices[5] = Vertex(-0.5f, 0.5f, 0.5f, 0, 255, 255);
pVertices[6] = Vertex(-0.5f, -0.5f, 0.5f, 0, 0, 0);
pVertices[7] = Vertex(0.5f, -0.5f, 0.5f, 200, 200, 200);
hr = _pVertexBuffer->Unlock();
CheckFailed(hr, 320);
+6 -3
View File
@@ -1,7 +1,7 @@
#pragma once
#include <d3d9.h>
#define FVF D3DFVF_XYZ
#define FVF D3DFVF_XYZ | D3DFVF_DIFFUSE
struct Vertex
{
@@ -9,6 +9,9 @@ struct Vertex
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) {}
D3DCOLOR color;
Vertex() : x(0.0f), y(0.0f), z(0.0f), color(0xFFFFFFFF) {}
Vertex(FLOAT _x, FLOAT _y, FLOAT _z) : x(_x), y(_y), z(_z), color(0xFFFFFFFF) {}
Vertex(FLOAT _x, FLOAT _y, FLOAT _z, UINT r, UINT g, UINT b) : x(_x), y(_y), z(_z), color(D3DCOLOR_XRGB(r, g, b)) {}
};
+1
View File
@@ -34,6 +34,7 @@ int WINAPI WinMain(
// set render states
d3d.getDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
d3d.getDevice()->SetRenderState(D3DRS_LIGHTING, FALSE);
// 3. create a mesh
Mesh mesh = {};