DXGL r231 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r230‎ | r231 | r232 >
Date:23:11, 6 August 2012
Author:admin
Status:new
Tags:
Comment:
Use D3DLVERTEX for Texture Shader test.
Add D3DLVERTEX constructor to d3dtypes.h
Modified paths:
  • /ddraw/include/d3dtypes.h (modified) (history)
  • /dxgltest/Tests3D.cpp (modified) (history)

Diff [purge]

Index: ddraw/include/d3dtypes.h
@@ -280,6 +280,15 @@
281281 D3DVALUE tv;
282282 D3DVALUE dvTV;
283283 } DUMMYUNIONNAME7;
 284+#if defined(__cplusplus) && defined(D3D_OVERLOADS)
 285+public:
 286+ _D3DLVERTEX() {}
 287+ _D3DLVERTEX(const D3DVECTOR& v, DWORD _color, DWORD _specular, float _tu, float _tv) {
 288+ x = v.x; y = v.y; z = v.z;
 289+ color = _color; specular = _specular;
 290+ tu = _tu; tv = _tv;
 291+ }
 292+#endif
284293 } D3DLVERTEX, *LPD3DLVERTEX;
285294
286295 typedef struct _D3DVERTEX {
Index: dxgltest/Tests3D.cpp
@@ -49,6 +49,7 @@
5050 static D3DVECTOR points[256];
5151 static D3DVECTOR normals[256];
5252 static D3DVERTEX vertices[256];
 53+static D3DLVERTEX litvertices[256];
5354 static WORD mesh[256];
5455 static WORD cube_mesh[] = {0,1,2, 2,1,3, 4,5,6, 6,5,7, 8,9,10, 10,9,11, 12,13,14, 14,13,15, 16,17,18,
5556 18,17,19, 20,21,22, 22,21,23 };
@@ -450,7 +451,7 @@
451452 StopTimer();
452453 }
453454
454 -void MakeCube3D(D3DVECTOR *points, D3DVECTOR *normals, D3DVERTEX *vertices)
 455+void MakeCube3D()
455456 {
456457 points[0] = D3DVECTOR(-2.5f,-2.5f,-2.5f);
457458 points[1] = D3DVECTOR(-2.5f,2.5f,-2.5f);
@@ -490,6 +491,30 @@
491492 vertices[21] = D3DVERTEX(points[0],normals[5],0,0);
492493 vertices[22] = D3DVERTEX(points[4],normals[5],1,1);
493494 vertices[23] = D3DVERTEX(points[2],normals[5],1,0);
 495+ litvertices[0] = D3DLVERTEX(points[0],0xFFFFFFFF,0,0,1);
 496+ litvertices[1] = D3DLVERTEX(points[1],0xFFFFFFFF,0,0,0);
 497+ litvertices[2] = D3DLVERTEX(points[2],0xFFFFFFFF,0,1,1);
 498+ litvertices[3] = D3DLVERTEX(points[3],0xFFFFFFFF,0,1,0);
 499+ litvertices[4] = D3DLVERTEX(points[2],0xFFFFFFFF,0,0,1);
 500+ litvertices[5] = D3DLVERTEX(points[3],0xFFFFFFFF,0,0,0);
 501+ litvertices[6] = D3DLVERTEX(points[4],0xFFFFFFFF,0,1,1);
 502+ litvertices[7] = D3DLVERTEX(points[5],0xFFFFFFFF,0,1,0);
 503+ litvertices[8] = D3DLVERTEX(points[4],0xFFFFFFFF,0,0,1);
 504+ litvertices[9] = D3DLVERTEX(points[5],0xFFFFFFFF,0,0,0);
 505+ litvertices[10] = D3DLVERTEX(points[6],0xFFFFFFFF,0,1,1);
 506+ litvertices[11] = D3DLVERTEX(points[7],0xFFFFFFFF,0,1,0);
 507+ litvertices[12] = D3DLVERTEX(points[6],0xFFFFFFFF,0,0,1);
 508+ litvertices[13] = D3DLVERTEX(points[7],0xFFFFFFFF,0,0,0);
 509+ litvertices[14] = D3DLVERTEX(points[0],0xFFFFFFFF,0,1,1);
 510+ litvertices[15] = D3DLVERTEX(points[1],0xFFFFFFFF,0,1,0);
 511+ litvertices[16] = D3DLVERTEX(points[1],0xFFFFFFFF,0,0,1);
 512+ litvertices[17] = D3DLVERTEX(points[7],0xFFFFFFFF,0,0,0);
 513+ litvertices[18] = D3DLVERTEX(points[3],0xFFFFFFFF,0,1,1);
 514+ litvertices[19] = D3DLVERTEX(points[5],0xFFFFFFFF,0,1,0);
 515+ litvertices[20] = D3DLVERTEX(points[6],0xFFFFFFFF,0,0,1);
 516+ litvertices[21] = D3DLVERTEX(points[0],0xFFFFFFFF,0,0,0);
 517+ litvertices[22] = D3DLVERTEX(points[4],0xFFFFFFFF,0,1,1);
 518+ litvertices[23] = D3DLVERTEX(points[2],0xFFFFFFFF,0,1,0);
494519 }
495520
496521 DDPIXELFORMAT texformats[256];
@@ -550,7 +575,7 @@
551576 switch(test)
552577 {
553578 case 0:
554 - MakeCube3D(points,normals,vertices);
 579+ MakeCube3D();
555580 ZeroMemory(&material,sizeof(D3DMATERIAL7));
556581 material.ambient.r = 0.5f;
557582 material.ambient.g = 0.5f;
@@ -589,7 +614,7 @@
590615 error = d3d7dev->SetLight(0,&lights[0]);
591616 break;
592617 case 1:
593 - MakeCube3D(points,normals,vertices);
 618+ MakeCube3D();
594619 cleartexformats();
595620 d3d7dev->EnumTextureFormats(gettexformat,NULL);
596621 gentexture(fmt_rgba4444,&textures[0],256,256,0);
@@ -634,7 +659,7 @@
635660 error = d3d7dev->SetLight(0,&lights[0]);
636661 break;
637662 case 2:
638 - MakeCube3D(points,normals,vertices);
 663+ MakeCube3D();
639664 ZeroMemory(&material,sizeof(D3DMATERIAL7));
640665 material.ambient.r = 1.0f;
641666 material.ambient.g = 1.0f;
@@ -727,7 +752,7 @@
728753 mat._31 = (FLOAT)sin( (float)time );
729754 error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
730755 error = d3d7dev->BeginScene();
731 - error = d3d7dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_VERTEX,vertices,24,cube_mesh,36,0);
 756+ error = d3d7dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_LVERTEX,litvertices,24,cube_mesh,36,0);
732757 error = d3d7dev->EndScene();
733758 break;
734759 default: