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 // cube
// front // front
pVertices[0] = 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); pVertices[1] = Vertex(0.5f, 0.5f, -0.5f, 0, 255, 0);
pVertices[2] = Vertex(0.5f, -0.5f, -0.5f); pVertices[2] = Vertex(0.5f, -0.5f, -0.5f, 0, 0, 255);
pVertices[3] = Vertex(-0.5f, -0.5f, -0.5f); pVertices[3] = Vertex(-0.5f, -0.5f, -0.5f, 255, 0, 255);
// back // back
pVertices[4] = 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); pVertices[5] = Vertex(-0.5f, 0.5f, 0.5f, 0, 255, 255);
pVertices[6] = Vertex(-0.5f, -0.5f, 0.5f); pVertices[6] = Vertex(-0.5f, -0.5f, 0.5f, 0, 0, 0);
pVertices[7] = Vertex(0.5f, -0.5f, 0.5f); pVertices[7] = Vertex(0.5f, -0.5f, 0.5f, 200, 200, 200);
hr = _pVertexBuffer->Unlock(); hr = _pVertexBuffer->Unlock();
CheckFailed(hr, 320); CheckFailed(hr, 320);
+6 -3
View File
@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <d3d9.h> #include <d3d9.h>
#define FVF D3DFVF_XYZ #define FVF D3DFVF_XYZ | D3DFVF_DIFFUSE
struct Vertex struct Vertex
{ {
@@ -9,6 +9,9 @@ struct Vertex
FLOAT y; FLOAT y;
FLOAT z; FLOAT z;
Vertex() : x(0.0f), y(0.0f), z(0.0f) {} D3DCOLOR color;
Vertex(FLOAT _x, FLOAT _y, FLOAT _z) : x(_x), y(_y), z(_z) {}
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 // set render states
d3d.getDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); d3d.getDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
d3d.getDevice()->SetRenderState(D3DRS_LIGHTING, FALSE);
// 3. create a mesh // 3. create a mesh
Mesh mesh = {}; Mesh mesh = {};