Index: dxgltest/Tests3D.cpp |
— | — | @@ -54,6 +54,84 @@ |
55 | 55 | 18,17,19, 20,21,22, 22,21,23 };
|
56 | 56 | static D3DLIGHT7 lights[8];
|
57 | 57 |
|
| 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 | +
|
58 | 136 | LRESULT CALLBACK D3DWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
59 | 137 | {
|
60 | 138 | bool paintwnd = true;
|
— | — | @@ -556,14 +634,11 @@ |
557 | 635 | case 2:
|
558 | 636 | MakeCube3D(points,normals,vertices);
|
559 | 637 | ZeroMemory(&material,sizeof(D3DMATERIAL7));
|
560 | | - material.ambient.r = 1.0f;
|
561 | | - material.ambient.g = 1.0f;
|
562 | | - material.ambient.b = 1.0f;
|
563 | 638 | material.diffuse.r = 1.0f;
|
564 | 639 | material.diffuse.g = 1.0f;
|
565 | 640 | material.diffuse.b = 1.0f;
|
566 | 641 | error = d3d7dev->SetMaterial(&material);
|
567 | | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
|
| 642 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, TRUE);
|
568 | 643 | error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xffffffff);
|
569 | 644 | mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
570 | 645 | mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
— | — | @@ -581,6 +656,7 @@ |
582 | 657 | matProj._43 = -1.0f;
|
583 | 658 | matProj._44 = 0.0f;
|
584 | 659 | error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_PROJECTION,&matProj);
|
| 660 | + texshaderstate = defaulttexshaderstate;
|
585 | 661 | break;
|
586 | 662 | default:
|
587 | 663 | break;
|
— | — | @@ -728,6 +804,7 @@ |
729 | 805 | error = d3d7dev->SetViewport(&vp);
|
730 | 806 | error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE);
|
731 | 807 | InitTest3D(2);
|
| 808 | +
|
732 | 809 | ::width = ddsd.dwWidth;
|
733 | 810 | ::height = ddsd.dwHeight;
|
734 | 811 | StartTimer(hWnd,WM_APP,60);
|