add vertex color
add time calculation
This commit is contained in:
+8
-8
@@ -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
@@ -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)) {}
|
||||
};
|
||||
@@ -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 = {};
|
||||
|
||||
Reference in New Issue
Block a user