DXGL r223 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r222‎ | r223 | r224 >
Date:00:49, 1 August 2012
Author:admin
Status:new
Tags:
Comment:
Create data structure for Texture Shader demo.
Modified paths:
  • /dxgltest/Tests3D.cpp (modified) (history)

Diff [purge]

Index: dxgltest/Tests3D.cpp
@@ -54,6 +54,84 @@
5555 18,17,19, 20,21,22, 22,21,23 };
5656 static D3DLIGHT7 lights[8];
5757
 58+typedef struct
 59+{
 60+ D3DTEXTUREOP colorop;
 61+ DWORD colorarg1;
 62+ DWORD colorarg2;
 63+ D3DTEXTUREOP alphaop;
 64+ DWORD alphaarg1;
 65+ DWORD alphaarg2;
 66+ DWORD texturetype;
 67+ TCHAR texturefile[MAX_PATH+1];
 68+ MultiDirectDrawSurface* texture;
 69+ BOOL colorkey;
 70+ DWORD keycolor;
 71+} TEXSTAGE;
 72+
 73+typedef struct
 74+{
 75+ int currentstage;
 76+ TEXSTAGE texstages[8];
 77+ DWORD diffuse;
 78+ DWORD specular;
 79+ DWORD factor;
 80+ D3DFOGMODE vertexfog;
 81+ D3DFOGMODE pixelfog;
 82+ FLOAT fogstart;
 83+ FLOAT fogend;
 84+ FLOAT fogdensity;
 85+ BOOL rangefog;
 86+ DWORD fogcolor;
 87+ BOOL alphatest;
 88+ BOOL alphastipple;
 89+ BOOL colorkey;
 90+ BOOL colorkeyblend;
 91+ D3DBLEND srcblend;
 92+ D3DBLEND destblend;
 93+ BYTE refalpha;
 94+ D3DCMPFUNC alphafunc;
 95+ D3DLINEPATTERN linepattern;
 96+ DWORD fillstippletype;
 97+ TCHAR fillstipplefile[MAX_PATH+1];
 98+ DWORD fillstipple[32];
 99+} TEXSHADERSTATE;
 100+
 101+static TEXSHADERSTATE texshaderstate;
 102+const TEXSHADERSTATE defaulttexshaderstate =
 103+{
 104+ 0,
 105+ {
 106+ {D3DTOP_MODULATE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_SELECTARG1,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
 107+ {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
 108+ {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
 109+ {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
 110+ {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
 111+ {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
 112+ {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
 113+ {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
 114+ },
 115+ 0xFFFFFFFF,
 116+ 0,
 117+ 0,
 118+ D3DFOG_NONE,
 119+ D3DFOG_NONE,
 120+ 0.0,
 121+ 1.0,
 122+ 1.0,
 123+ FALSE,
 124+ 0,
 125+ FALSE,
 126+ FALSE,
 127+ FALSE,
 128+ FALSE,
 129+ D3DBLEND_ONE,
 130+ D3DBLEND_ZERO,
 131+ 0,
 132+ D3DCMP_ALWAYS,
 133+ {0,0}
 134+};
 135+
58136 LRESULT CALLBACK D3DWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
59137 {
60138 bool paintwnd = true;
@@ -556,14 +634,11 @@
557635 case 2:
558636 MakeCube3D(points,normals,vertices);
559637 ZeroMemory(&material,sizeof(D3DMATERIAL7));
560 - material.ambient.r = 1.0f;
561 - material.ambient.g = 1.0f;
562 - material.ambient.b = 1.0f;
563638 material.diffuse.r = 1.0f;
564639 material.diffuse.g = 1.0f;
565640 material.diffuse.b = 1.0f;
566641 error = d3d7dev->SetMaterial(&material);
567 - error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
 642+ error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, TRUE);
568643 error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xffffffff);
569644 mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
570645 mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
@@ -581,6 +656,7 @@
582657 matProj._43 = -1.0f;
583658 matProj._44 = 0.0f;
584659 error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_PROJECTION,&matProj);
 660+ texshaderstate = defaulttexshaderstate;
585661 break;
586662 default:
587663 break;
@@ -728,6 +804,7 @@
729805 error = d3d7dev->SetViewport(&vp);
730806 error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE);
731807 InitTest3D(2);
 808+
732809 ::width = ddsd.dwWidth;
733810 ::height = ddsd.dwHeight;
734811 StartTimer(hWnd,WM_APP,60);