修订版 | 1bbf27697af0ed46858686aef19ba4de00b9f677 (tree) |
---|---|
时间 | 2011-06-10 07:00:00 |
作者 | Jarmonik |
Commiter | Jarmonik |
D3D9Client: engine cover animation issue is fixed
Would be good idea to run some test to be sure that nothing else gone broken.
I didn't notice anything in my usual set of tests.
@@ -3,7 +3,7 @@ | ||
3 | 3 | PlanetAnisoMode = 2 |
4 | 4 | PlanetMipmapMode = 1 |
5 | 5 | PlanetMipmapBias = 0 |
6 | -DebugLvl = 2 | |
6 | +DebugLvl = 1 | |
7 | 7 | VCNearPlane = 0.02 |
8 | 8 | LightSourcesInUse = 12 |
9 | 9 | MemAllocLogic = 0 |
@@ -11,3 +11,4 @@ | ||
11 | 11 | NearClipPlaneMode = 0 |
12 | 12 | InSurfaceBlit = font1tex.dds Cockpit\hud.dds DG\dg_panel.dds Cockpit\hud_red.dds Cockpit\hud_blue.dds Cockpit\hud_yellow.dds |
13 | 13 | NVPerfHUD = 0 |
14 | +RejectRTDC = 0 |
@@ -14,7 +14,6 @@ | ||
14 | 14 | MinFilter = POINT; |
15 | 15 | MagFilter = POINT; |
16 | 16 | MipFilter = None; |
17 | - MaxAnisotropy = 2; | |
18 | 17 | AddressU = CLAMP; |
19 | 18 | AddressV = CLAMP; |
20 | 19 | }; |
@@ -128,7 +128,7 @@ | ||
128 | 128 | { |
129 | 129 | Texture = <gTex0>; |
130 | 130 | MinFilter = ANISOTROPIC; |
131 | - MagFilter = LINEAR; | |
131 | + MagFilter = POINT; | |
132 | 132 | MipFilter = LINEAR; |
133 | 133 | MaxAnisotropy = 4; |
134 | 134 | MipMapLODBias = 0; |
@@ -158,7 +158,7 @@ | ||
158 | 158 | AddressV = CLAMP; |
159 | 159 | }; |
160 | 160 | |
161 | -sampler Panel0S = sampler_state // Sampler for mesh based panels. Must be compatible with Non-power of two conditional | |
161 | +sampler Panel0S = sampler_state // Sampler for mesh based panels, Panel MFDs. Must be compatible with Non-power of two conditional due to MFD screens. | |
162 | 162 | { |
163 | 163 | Texture = <gTex0>; |
164 | 164 | MinFilter = NONE; |
@@ -168,6 +168,18 @@ | ||
168 | 168 | AddressV = CLAMP; |
169 | 169 | }; |
170 | 170 | |
171 | +sampler SimpleS = sampler_state // Sampler used for SimpleTech. (Star, VC HUD) | |
172 | +{ | |
173 | + Texture = <gTex0>; | |
174 | + MinFilter = ANISOTROPIC; | |
175 | + MagFilter = LINEAR; | |
176 | + MipFilter = LINEAR; | |
177 | + MaxAnisotropy = 4; | |
178 | + MipMapLODBias = 0; | |
179 | + AddressU = WRAP; | |
180 | + AddressV = WRAP; | |
181 | +}; | |
182 | + | |
171 | 183 | |
172 | 184 | sampler Tile0S = sampler_state // Base tile sampler |
173 | 185 | { |
@@ -453,15 +465,15 @@ | ||
453 | 465 | } |
454 | 466 | |
455 | 467 | |
456 | - | |
457 | 468 | float4 SimpleTechPS(SimpleVS frg) : COLOR |
458 | 469 | { |
459 | - return tex2D(Tex0S, frg.tex0); | |
470 | + return tex2D(SimpleS, frg.tex0); | |
460 | 471 | } |
461 | 472 | |
473 | + | |
462 | 474 | float4 PanelTechPS(SimpleVS frg) : COLOR |
463 | 475 | { |
464 | - return tex2D(Panel0S, frg.tex0*gMix); | |
476 | + return tex2D(Panel0S, frg.tex0); | |
465 | 477 | } |
466 | 478 | |
467 | 479 |
@@ -560,6 +572,23 @@ | ||
560 | 572 | AlphaBlendEnable = true; |
561 | 573 | BlendOp = Add; |
562 | 574 | SrcBlend = SrcAlpha; |
575 | + DestBlend = One; | |
576 | + ZEnable = false; | |
577 | + ZWriteEnable = false; | |
578 | + } | |
579 | +} | |
580 | + | |
581 | +technique PanelTechB | |
582 | +{ | |
583 | + pass P0 | |
584 | + { | |
585 | + vertexShader = compile vs_3_0 SimpleTechVS(); | |
586 | + pixelShader = compile ps_3_0 PanelTechPS(); | |
587 | + | |
588 | + AlphaBlendEnable = true; | |
589 | + BlendOp = Add; | |
590 | + SrcBlend = SrcAlpha; | |
591 | + DestBlend = InvSrcAlpha; | |
563 | 592 | ZEnable = false; |
564 | 593 | ZWriteEnable = false; |
565 | 594 | } |
@@ -1,5 +0,0 @@ | ||
1 | -D3D9Client Change Log | |
2 | - | |
3 | -RC2 | |
4 | -- Shadow position bug fixed | |
5 | -- MFD and Multisampling conflict fixed from old style panels. |
@@ -95,7 +95,7 @@ | ||
95 | 95 | { |
96 | 96 | pFramework = NULL; |
97 | 97 | pd3dDevice = NULL; |
98 | - p2DPanelVB = NULL; | |
98 | + //p2DPanelVB = NULL; | |
99 | 99 | vtab = NULL; |
100 | 100 | cfg = new D3D9Config(); // Create the parameter manager |
101 | 101 | uEnableLog = cfg->DebugLvl; |
@@ -205,8 +205,8 @@ | ||
205 | 205 | meshmgr = new MeshManager(this); |
206 | 206 | texmgr = new TextureManager(this); |
207 | 207 | |
208 | - pDefRTGSurf = new D3D9ClientSurface(pd3dDevice, this); | |
209 | - pDefRTGSurf->MakeRenderingTexture(16,16); | |
208 | + //pDefRTGSurf = new D3D9ClientSurface(pd3dDevice, this); | |
209 | + //pDefRTGSurf->MakeRenderingTexture(16,16); | |
210 | 210 | |
211 | 211 | pDefaultTex = SURFACE(clbkLoadTexture("Null.dds")); |
212 | 212 |
@@ -217,10 +217,13 @@ | ||
217 | 217 | D3D9PadPen::D3D9TechInit(pd3dDevice); |
218 | 218 | D3D9PadBrush::D3D9TechInit(pd3dDevice); |
219 | 219 | D3D9Text::D3D9TechInit(pd3dDevice); |
220 | + | |
221 | + //ShowDefaultSplash(); // Warning D3D9ClientSurface is not yet fully initialized here | |
222 | + SplashScreen(); | |
220 | 223 | |
221 | - ShowDefaultSplash(); | |
222 | - SplashScreen(); | |
223 | - | |
224 | + D3D9ClientSurface::D3D9TechInit(pd3dDevice); | |
225 | + D3D9Effect::D3D9TechInit(pd3dDevice); | |
226 | + | |
224 | 227 | // Device-specific initialisations |
225 | 228 | |
226 | 229 | TileManager::GlobalInit(this); |
@@ -233,10 +236,8 @@ | ||
233 | 236 | vObject::GlobalInit(this); |
234 | 237 | vVessel::GlobalInit(this); |
235 | 238 | |
236 | - FX = D3D9Effect::D3D9TechInit(pd3dDevice); | |
237 | 239 | Scene::D3D9TechInit(pd3dDevice); |
238 | - D3D9ClientSurface::D3D9TechInit(pd3dDevice); | |
239 | - | |
240 | + | |
240 | 241 | // Create scene instance |
241 | 242 | scene = new Scene(this, viewW, viewH); |
242 | 243 |
@@ -1017,9 +1018,10 @@ | ||
1017 | 1018 | HDC D3D9Client::clbkGetSurfaceDC(SURFHANDLE surf) |
1018 | 1019 | { |
1019 | 1020 | _TRACER; |
1021 | + LogOk("DC Acquired..."); | |
1020 | 1022 | if (surf==NULL) surf = pFramework->GetBackBufferHandle(); |
1021 | 1023 | HDC hDC = SURFACE(surf)->GetDC(); |
1022 | - if (hDC==NULL) LogErr("clbkGetSurfaceDC(0x%X) failed",surf); | |
1024 | + //if (hDC==NULL) LogErr("clbkGetSurfaceDC(0x%X) failed",surf); | |
1023 | 1025 | return hDC; |
1024 | 1026 | } |
1025 | 1027 |
@@ -1027,10 +1029,11 @@ | ||
1027 | 1029 | |
1028 | 1030 | void D3D9Client::clbkReleaseSurfaceDC(SURFHANDLE surf, HDC hDC) |
1029 | 1031 | { |
1030 | - _TRACER; | |
1031 | 1032 | if (hDC==NULL) { LogErr("D3D9Client::clbkReleaseSurfaceDC() Input hDC is NULL"); return; } |
1032 | 1033 | if (surf==NULL) surf = pFramework->GetBackBufferHandle(); |
1033 | - SURFACE(surf)->ReleaseDC(hDC); | |
1034 | + SURFACE(surf)->ReleaseDC(hDC); | |
1035 | + LogOk("...DC Released"); | |
1036 | + //if (SURFACE(surf)->GetWidth()==290) LogAlw("MFD rendering completed"); | |
1034 | 1037 | } |
1035 | 1038 | |
1036 | 1039 | // ======================================================================= |
@@ -1099,11 +1102,33 @@ | ||
1099 | 1102 | |
1100 | 1103 | void D3D9Client::SplashScreen() |
1101 | 1104 | { |
1102 | - HDC hDC = GetDC(hRenderWnd); | |
1105 | + LPDIRECT3DSURFACE9 pBackBuffer = pFramework->GetBackBuffer(); | |
1106 | + | |
1107 | + DWORD Width = pFramework->GetRenderWidth(); | |
1108 | + DWORD Height = pFramework->GetRenderHeight(); | |
1109 | + HINSTANCE hInst = oapiGetOrbiterInstance(); | |
1110 | + SURFHANDLE hScaled = oapiCreateSurface(Width, Height); | |
1111 | + | |
1112 | + HBITMAP hBM = LoadBitmap(hInst, MAKEINTRESOURCE(273)); | |
1113 | + BITMAP bm; | |
1114 | + | |
1115 | + GetObject(hBM, sizeof(BITMAP), &bm); | |
1116 | + | |
1117 | + HDC hSrc = CreateCompatibleDC(NULL); | |
1118 | + HDC hDC = SURFACE(hScaled)->GetDCHard(); | |
1119 | + | |
1120 | + HGDIOBJ hOld = SelectObject(hSrc, hBM); | |
1121 | + | |
1122 | + StretchBlt(hDC, 0, 0, Width, Height, hSrc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); | |
1123 | + | |
1124 | + SelectObject(hSrc, hOld); | |
1125 | + DeleteDC(hSrc); | |
1126 | + DeleteObject(hBM); | |
1103 | 1127 | |
1104 | 1128 | LOGFONTA fnt; memset((void *)&fnt, 0, sizeof(LOGFONT)); |
1129 | + | |
1105 | 1130 | fnt.lfHeight = 18; |
1106 | - fnt.lfWeight = 500; | |
1131 | + fnt.lfWeight = 700; | |
1107 | 1132 | fnt.lfCharSet = ANSI_CHARSET; |
1108 | 1133 | fnt.lfOutPrecision = OUT_DEFAULT_PRECIS; |
1109 | 1134 | fnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; |
@@ -1116,13 +1141,33 @@ | ||
1116 | 1141 | HFONT hO = (HFONT)SelectObject(hDC, hF); |
1117 | 1142 | SetTextColor(hDC, 0xC08080); |
1118 | 1143 | SetBkMode(hDC,TRANSPARENT); |
1119 | - char data[128]; | |
1120 | - sprintf_s(data,128,"D3D9Client RC22 Build [%s]",__DATE__); | |
1121 | - TextOut(hDC,viewW*1018/1600, viewH*705/875 + 2*18, data, strlen(data)); | |
1122 | 1144 | |
1145 | + char *months[]={"???","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","???"}; | |
1146 | + | |
1147 | + DWORD d = oapiGetOrbiterVersion(); | |
1148 | + DWORD y = d/10000; d-=y*10000; | |
1149 | + DWORD m = d/100; d-=m*100; | |
1150 | + if (m>12) m=0; | |
1151 | + | |
1152 | + char dataA[128]; | |
1153 | + sprintf_s(dataA,128,"D3D9Client RC23 Build [%s]",__DATE__); | |
1154 | + char dataB[128]; | |
1155 | + sprintf_s(dataB,128,"Build %s %u 20%u [%u]", months[m], d, y, oapiGetOrbiterVersion()); | |
1156 | + | |
1157 | + int xc = Width*814/bm.bmWidth; | |
1158 | + int yc = Height*544/bm.bmHeight; | |
1159 | + | |
1160 | + TextOut(hDC, xc, yc + 0*20, "ORBITER Space Flight Simulator",30); | |
1161 | + TextOut(hDC, xc, yc + 1*20, dataB, strlen(dataB)); | |
1162 | + TextOut(hDC, xc, yc + 2*20, dataA, strlen(dataA)); | |
1163 | + | |
1123 | 1164 | SelectObject(hDC, hO); |
1124 | 1165 | DeleteObject(hF); |
1125 | - ReleaseDC(hRenderWnd, hDC); | |
1166 | + | |
1167 | + SURFACE(hScaled)->ReleaseDC(hDC); | |
1168 | + | |
1169 | + clbkBlt(NULL, 0, 0, hScaled); | |
1170 | + clbkDisplayFrame(); | |
1126 | 1171 | } |
1127 | 1172 | |
1128 | 1173 | #pragma region Drawing_(Sketchpad)_Interface |
@@ -1142,21 +1187,22 @@ | ||
1142 | 1187 | return new D3D9Pad(surf); |
1143 | 1188 | } |
1144 | 1189 | } |
1145 | - | |
1146 | - /* | |
1147 | - if (SURFACE(surf)->IsBackBuffer()) { | |
1148 | - bSkpGDI=false; | |
1149 | - if (bScene==false) pd3dDevice->BeginScene(); | |
1150 | - return new D3D9Pad(surf); | |
1151 | - }*/ | |
1190 | + else { | |
1191 | + if (SURFACE(surf)->IsRenderTarget()) { | |
1192 | + | |
1193 | + //LogErr("[INFO] Sketchpad is used for RenderTargetSurface Size=(%ux%u)",SURFACE(surf)->GetWidth(), SURFACE(surf)->GetHeight()); | |
1194 | + //bSkpGDI=false; | |
1195 | + //if (bScene==false) pd3dDevice->BeginScene(); | |
1196 | + //return new D3D9Pad(surf); | |
1197 | + } | |
1198 | + } | |
1152 | 1199 | |
1153 | 1200 | bSkpGDI = true; |
1154 | - return new GDIPad(surf, SURFACE(surf)->GetDC()); | |
1201 | + return new GDIPad(surf, clbkGetSurfaceDC(surf)); | |
1155 | 1202 | } |
1156 | 1203 | |
1157 | 1204 | void D3D9Client::clbkReleaseSketchpad(oapi::Sketchpad *sp) |
1158 | 1205 | { |
1159 | - _TRACER; | |
1160 | 1206 | if (bSkpGDI) { |
1161 | 1207 | GDIPad *gdip = (GDIPad*)sp; |
1162 | 1208 | HDC hDC = gdip->GetDC(); |
@@ -1173,37 +1219,31 @@ | ||
1173 | 1219 | |
1174 | 1220 | Font *D3D9Client::clbkCreateFont(int height, bool prop, const char *face, Font::Style style, int orientation) const |
1175 | 1221 | { |
1176 | - _TRACER; | |
1177 | 1222 | return new D3D9PadFont(height, prop, face, style, orientation); |
1178 | 1223 | } |
1179 | 1224 | |
1180 | 1225 | void D3D9Client::clbkReleaseFont(Font *font) const |
1181 | 1226 | { |
1182 | - _TRACER; | |
1183 | 1227 | delete ((D3D9PadFont*)font); |
1184 | 1228 | } |
1185 | 1229 | |
1186 | 1230 | Pen *D3D9Client::clbkCreatePen(int style, int width, DWORD col) const |
1187 | 1231 | { |
1188 | - _TRACER; | |
1189 | 1232 | return new D3D9PadPen(style, width, col); |
1190 | 1233 | } |
1191 | 1234 | |
1192 | 1235 | void D3D9Client::clbkReleasePen(Pen *pen) const |
1193 | 1236 | { |
1194 | - _TRACER; | |
1195 | 1237 | delete ((D3D9PadPen*)pen); |
1196 | 1238 | } |
1197 | 1239 | |
1198 | 1240 | Brush *D3D9Client::clbkCreateBrush(DWORD col) const |
1199 | 1241 | { |
1200 | - _TRACER; | |
1201 | 1242 | return new D3D9PadBrush(col); |
1202 | 1243 | } |
1203 | 1244 | |
1204 | 1245 | void D3D9Client::clbkReleaseBrush(Brush *brush) const |
1205 | 1246 | { |
1206 | - _TRACER; | |
1207 | 1247 | delete ((D3D9PadBrush*)brush); |
1208 | 1248 | } |
1209 | 1249 |
@@ -555,7 +555,6 @@ | ||
555 | 555 | public: |
556 | 556 | |
557 | 557 | D3D9Config *cfg; // configuration manager |
558 | - ID3DXEffect *FX; | |
559 | 558 | |
560 | 559 | private: |
561 | 560 |
@@ -563,9 +562,9 @@ | ||
563 | 562 | |
564 | 563 | LPDIRECT3D9 pD3D; |
565 | 564 | LPDIRECT3DDEVICE9 pd3dDevice; |
566 | - LPDIRECT3DVERTEXBUFFER9 p2DPanelVB; | |
565 | + //LPDIRECT3DVERTEXBUFFER9 p2DPanelVB; | |
567 | 566 | LPD3D9CLIENTSURFACE pDefaultTex; |
568 | - LPD3D9CLIENTSURFACE pDefRTGSurf; | |
567 | + //LPD3D9CLIENTSURFACE pDefRTGSurf; | |
569 | 568 | LPD3D9CLIENTSURFACE pScatterTest; |
570 | 569 | |
571 | 570 | CD3DFramework9* pFramework; |
@@ -18,6 +18,7 @@ | ||
18 | 18 | int D3D9Config::def_DisableDriverManagement = 0; |
19 | 19 | int D3D9Config::def_NearClipPlane = 0; |
20 | 20 | int D3D9Config::def_NVPerfHUD = 0; |
21 | +int D3D9Config::def_RejectRTDC = 0; | |
21 | 22 | |
22 | 23 | |
23 | 24 | // ============================================================== |
@@ -46,6 +47,7 @@ | ||
46 | 47 | MemoryLogic = def_MemoryLogic; |
47 | 48 | NearClipPlane = def_NearClipPlane; |
48 | 49 | NVPerfHUD = def_NVPerfHUD; |
50 | + RejectRTDC = def_RejectRTDC; | |
49 | 51 | |
50 | 52 | DisableDriverManagement = def_DisableDriverManagement; |
51 | 53 |
@@ -74,6 +76,7 @@ | ||
74 | 76 | if (oapiReadItem_int (hFile, "DisableDrvMgm", i)) DisableDriverManagement = i; |
75 | 77 | if (oapiReadItem_int (hFile, "NearClipPlaneMode", i)) NearClipPlane = i; |
76 | 78 | if (oapiReadItem_int (hFile, "NVPerfHUD", i)) NVPerfHUD = i; |
79 | + if (oapiReadItem_int (hFile, "RejectRTDC", i)) RejectRTDC = i; | |
77 | 80 | |
78 | 81 | oapiReadItem_string (hFile, "InSurfaceBlit", InSurface); |
79 | 82 |
@@ -98,6 +101,7 @@ | ||
98 | 101 | oapiWriteItem_int (hFile, "NearClipPlaneMode", NearClipPlane); |
99 | 102 | oapiWriteItem_string (hFile, "InSurfaceBlit", InSurface); |
100 | 103 | oapiWriteItem_int (hFile, "NVPerfHUD", NVPerfHUD); |
104 | + oapiWriteItem_int (hFile, "RejectRTDC", RejectRTDC); | |
101 | 105 | |
102 | 106 | oapiCloseFile (hFile, FILE_OUT); |
103 | 107 | } |
\ No newline at end of file |
@@ -19,6 +19,7 @@ | ||
19 | 19 | int DisableDriverManagement; |
20 | 20 | int MemoryLogic; |
21 | 21 | int NearClipPlane; |
22 | + int RejectRTDC; | |
22 | 23 | double PlanetMipmapBias; // LOD bias (-1=sharp ... +1=smooth) |
23 | 24 | double VCNearPlane; |
24 | 25 | int DebugLvl; |
@@ -42,6 +43,7 @@ | ||
42 | 43 | static int def_MemoryLogic; |
43 | 44 | static int def_DisableDriverManagement; |
44 | 45 | static int def_NVPerfHUD; |
46 | + static int def_RejectRTDC; | |
45 | 47 | }; |
46 | 48 | |
47 | 49 | #endif // !__D3D9CONFIG_H |
@@ -13,6 +13,7 @@ | ||
13 | 13 | ID3DXEffect * D3D9Effect::FX = 0; |
14 | 14 | |
15 | 15 | D3DXHANDLE D3D9Effect::ePanelTech = 0; // Used to draw a new style 2D panel like stock delta-glider |
16 | +D3DXHANDLE D3D9Effect::ePanelTechB = 0; // Used to draw a new style 2D panel like stock delta-glider | |
16 | 17 | D3DXHANDLE D3D9Effect::eVesselTech = 0; // Vessel exterior, surface bases. |
17 | 18 | D3DXHANDLE D3D9Effect::eBuildingTech = 0; |
18 | 19 | D3DXHANDLE D3D9Effect::eSimple = 0; |
@@ -138,6 +139,7 @@ | ||
138 | 139 | eSpotTech = FX->GetTechniqueByName("SpotTech"); |
139 | 140 | eShadowTech = FX->GetTechniqueByName("ShadowTech"); |
140 | 141 | ePanelTech = FX->GetTechniqueByName("PanelTech"); |
142 | + ePanelTechB = FX->GetTechniqueByName("PanelTechB"); | |
141 | 143 | eCloudTech = FX->GetTechniqueByName("PlanetCloudTech"); |
142 | 144 | eCloudShadow = FX->GetTechniqueByName("PlanetCloudShadowTech"); |
143 | 145 | eSkyDomeTech = FX->GetTechniqueByName("SkyDomeTech"); |
@@ -35,6 +35,7 @@ | ||
35 | 35 | static D3DXHANDLE eExhaust; |
36 | 36 | static D3DXHANDLE eSpotTech; |
37 | 37 | static D3DXHANDLE ePanelTech; |
38 | + static D3DXHANDLE ePanelTechB; | |
38 | 39 | static D3DXHANDLE eBaseTile; |
39 | 40 | static D3DXHANDLE eRingTech; |
40 | 41 | static D3DXHANDLE eShadowTech; |
@@ -182,6 +182,7 @@ | ||
182 | 182 | LogAlw("MaxStreamStride........: %u",caps.MaxStreamStride); |
183 | 183 | LogAlw("MaxVertexBlendMatrices.: %u",caps.MaxVertexBlendMatrices); |
184 | 184 | LogAlw("MaxVShaderInstrExecuted: %u",caps.MaxVShaderInstructionsExecuted); |
185 | + LogAlw("MaxPointSize...........: %f",caps.MaxPointSize); | |
185 | 186 | LogAlw("VertexShaderVersion....: 0x%hX",(caps.VertexShaderVersion&0xFFFF)); |
186 | 187 | LogAlw("PixelShaderVersion.....: 0x%hX",(caps.PixelShaderVersion&0xFFFF)); |
187 | 188 | LogAlw("NumSimultaneousRTs.....: %u",caps.NumSimultaneousRTs); |
@@ -247,6 +248,16 @@ | ||
247 | 248 | if (bIsFullscreen) hr = CreateFullscreenMode(); |
248 | 249 | else hr = CreateWindowedMode(); |
249 | 250 | |
251 | + D3DVIEWPORT9 vp; | |
252 | + vp.X = 0; | |
253 | + vp.Y = 0; | |
254 | + vp.Width = dwRenderWidth; | |
255 | + vp.Height = dwRenderHeight; | |
256 | + vp.MinZ = 0.0f; | |
257 | + vp.MaxZ = 1.0f; | |
258 | + | |
259 | + pd3dDevice->SetViewport(&vp); | |
260 | + | |
250 | 261 | if (FAILED(hr)) { |
251 | 262 | LogErr("[Device Initialization Failed]"); |
252 | 263 | oapiWriteLog("D3D9Client:FAIL: [Device Initialization Failed]"); |
@@ -21,6 +21,7 @@ | ||
21 | 21 | |
22 | 22 | int nfcache = 0; |
23 | 23 | |
24 | +oapi::Font *deffont = NULL; | |
24 | 25 | |
25 | 26 | // ====================================================================== |
26 | 27 | // class GDIPad |
@@ -30,6 +31,8 @@ | ||
30 | 31 | { |
31 | 32 | _TRACE; |
32 | 33 | |
34 | + LogOk("Creating D3D9 SketchPad..."); | |
35 | + | |
33 | 36 | cfont = NULL; |
34 | 37 | cpen = NULL; |
35 | 38 | cbrush = NULL; |
@@ -43,31 +46,36 @@ | ||
43 | 46 | halign = TA_LEFT; |
44 | 47 | valign = TA_TOP; |
45 | 48 | |
49 | + textcolor = D3DXCOLOR(0,1,0,1); | |
50 | + pencolor = D3DXCOLOR(0,1,0,1); | |
51 | + brushcolor = D3DXCOLOR(0,1,0,1); | |
52 | + bkcolor = D3DXCOLOR(0,0,0,1); | |
53 | + | |
46 | 54 | D3DXMatrixOrthoOffCenterLH(&mVP, 0.0f, (float)pTgt->GetWidth(), (float)pTgt->GetHeight(), 0.0f, 0.0f, 10.0f); |
55 | + | |
56 | + HR(FX->SetMatrix(eVP, &mVP)); | |
47 | 57 | |
48 | 58 | if (pTgt->IsBackBuffer()==false) { |
49 | - LogAlw("Creating a D3D9_Sketchpad for rendering target surface 0x%X",s); | |
59 | + LogErr("Creating a D3D9_Sketchpad for rendering target surface 0x%X",s); | |
50 | 60 | if (pTgt->BindGPU()==false) { |
51 | 61 | pTgt=NULL; |
52 | 62 | LogErr("D3D9Pad creation failed"); |
53 | 63 | return; |
54 | 64 | } |
55 | 65 | } |
56 | - //else LogAlw("Creating a D3D9_Sketchpad for BackBuffer 0x%X",s); | |
57 | 66 | |
58 | - deffont = new D3D9PadFont(18,true,"fixed"); | |
59 | - cfont = (oapi::Font *)deffont; | |
67 | + if (deffont==NULL) deffont = (oapi::Font*) new D3D9PadFont(18, true, "fixed"); | |
60 | 68 | |
61 | - HR(FX->SetMatrix(eVP, &mVP)); | |
69 | + cfont = deffont; | |
62 | 70 | } |
63 | 71 | |
64 | 72 | |
65 | 73 | D3D9Pad::~D3D9Pad () |
66 | 74 | { |
67 | 75 | _TRACE; |
68 | - delete deffont; | |
69 | 76 | if (pTgt) if (pTgt->IsBackBuffer()==false) pTgt->ReleaseGPU(); |
70 | 77 | pTgt = NULL; |
78 | + LogOk("...D3D9 SketchPad Released"); | |
71 | 79 | } |
72 | 80 | |
73 | 81 |
@@ -75,7 +83,8 @@ | ||
75 | 83 | { |
76 | 84 | _TRACE; |
77 | 85 | Font *pfont = cfont; |
78 | - cfont = font; | |
86 | + if (font) cfont = font; | |
87 | + else cfont = deffont; | |
79 | 88 | return pfont; |
80 | 89 | } |
81 | 90 |
@@ -118,6 +127,7 @@ | ||
118 | 127 | D3DXCOLOR prev = textcolor; |
119 | 128 | textcolor = D3DXCOLOR(col); |
120 | 129 | D3DXCOLORSWAP(&textcolor); |
130 | + D3DXCOLORSWAP(&prev); | |
121 | 131 | return prev; |
122 | 132 | } |
123 | 133 |
@@ -126,6 +136,7 @@ | ||
126 | 136 | D3DXCOLOR prev = bkcolor; |
127 | 137 | bkcolor = D3DXCOLOR(col); |
128 | 138 | D3DXCOLORSWAP(&bkcolor); |
139 | + D3DXCOLORSWAP(&prev); | |
129 | 140 | return prev; |
130 | 141 | } |
131 | 142 |
@@ -192,20 +203,22 @@ | ||
192 | 203 | void D3D9Pad::LineTo (int x, int y) |
193 | 204 | { |
194 | 205 | if (cpen==NULL) return; |
195 | - D3DXVECTOR4 line(float(cx), float(cy), float(origx+x), float(origy+y)); | |
196 | - Lines(&line, 1); | |
206 | + D3DXVECTOR3 pts[2]; | |
207 | + pts[0] = D3DXVECTOR3(float(cx), float(cy), 0.5f); | |
208 | + pts[1] = D3DXVECTOR3(float(origx+x), float(origy+y), 0.5f); | |
209 | + Lines(pts, 1); | |
197 | 210 | cx=origx+x; cy=origy+y; |
198 | 211 | } |
199 | 212 | |
200 | 213 | void D3D9Pad::Line (int x0, int y0, int x1, int y1) |
201 | 214 | { |
202 | 215 | if (cpen==NULL) return; |
203 | - | |
204 | 216 | x0+=origx; y0+=origy; |
205 | 217 | x1+=origx; y1+=origy; |
206 | - | |
207 | - D3DXVECTOR4 line = D3DXVECTOR4( float(x0), float(y0), float(x1), float(y1) ); | |
208 | - Lines(&line, 1); | |
218 | + D3DXVECTOR3 pts[2]; | |
219 | + pts[0] = D3DXVECTOR3(float(x0), float(y0), 0.5f); | |
220 | + pts[1] = D3DXVECTOR3(float(x1), float(y1), 0.5f); | |
221 | + Lines(pts, 1); | |
209 | 222 | cx = x1; cy = y1; |
210 | 223 | } |
211 | 224 |
@@ -235,25 +248,19 @@ | ||
235 | 248 | { |
236 | 249 | if (cpen==NULL) return; |
237 | 250 | LogErr("D3D9SketchPad: Polyline not implemented"); |
251 | + /* | |
252 | + D3DXVECTOR3 *pVert = new D3DXVECTOR3[(npt-1)*2]; | |
253 | + | |
254 | + for (int i=0;i<npt;i++) { | |
255 | + pVert[i].x = pt[i].x, pVert[i].y = pt[i].y, pVert[i].z = 0.5f; | |
256 | + } | |
257 | + */ | |
238 | 258 | } |
239 | 259 | |
240 | 260 | // ----------------------------------------------------------------------------------------------- |
241 | 261 | // |
242 | -void D3D9Pad::Lines(D3DXVECTOR4 *lines, int count) | |
262 | +void D3D9Pad::Lines(D3DXVECTOR3 *pVert, int count) | |
243 | 263 | { |
244 | - D3DXVECTOR3 *pVert = new D3DXVECTOR3[count*2]; | |
245 | - | |
246 | - for (int i=0,z=0;i<count;i++) { | |
247 | - pVert[z].x = lines[i].x; | |
248 | - pVert[z].y = lines[i].y; | |
249 | - pVert[z].z = 0.5f; | |
250 | - z++; | |
251 | - pVert[z].x = lines[i].z; | |
252 | - pVert[z].y = lines[i].w; | |
253 | - pVert[z].z = 0.5f; | |
254 | - z++; | |
255 | - } | |
256 | - | |
257 | 264 | UINT numPasses=0; |
258 | 265 | HR(pDev->SetVertexDeclaration(pPositionDecl)); |
259 | 266 | HR(FX->SetTechnique(eLine)); |
@@ -263,7 +270,6 @@ | ||
263 | 270 | HR(pDev->DrawPrimitiveUP(D3DPT_LINELIST, count, pVert, sizeof(D3DXVECTOR3))); |
264 | 271 | HR(FX->EndPass()); |
265 | 272 | HR(FX->End()); |
266 | - delete []pVert; | |
267 | 273 | } |
268 | 274 | |
269 | 275 | // ----------------------------------------------------------------------------------------------- |
@@ -291,8 +297,7 @@ | ||
291 | 297 | FX->SetValue(eColor, &pencolor, sizeof(D3DXCOLOR)); |
292 | 298 | FX->CommitChanges(); |
293 | 299 | if (w<24 && h<24) pDev->DrawPrimitive(D3DPT_LINESTRIP, 1, 15); |
294 | - else pDev->DrawPrimitive(D3DPT_LINESTRIP, 1, 63); | |
295 | - | |
300 | + else pDev->DrawPrimitive(D3DPT_LINESTRIP, 1, 63); | |
296 | 301 | } |
297 | 302 | FX->EndPass(); |
298 | 303 | FX->End(); |
@@ -311,10 +316,11 @@ | ||
311 | 316 | {-1.0f,-1.0f,0.5f} |
312 | 317 | }; |
313 | 318 | |
319 | + | |
314 | 320 | D3DXVECTOR4 data(x, y, w*0.5f, h*0.5f); |
315 | 321 | UINT numPasses=0; |
316 | 322 | pDev->SetVertexDeclaration(pPositionDecl); |
317 | - pDev->SetStreamSource(0, pRect, 0, sizeof(D3DXVECTOR3)); | |
323 | + //pDev->SetStreamSource(0, pRect, 0, sizeof(D3DXVECTOR3)); | |
318 | 324 | FX->SetValue(eData, &data, sizeof(D3DXVECTOR4)); |
319 | 325 | FX->SetTechnique(eDraw); |
320 | 326 | FX->SetValue(eColor, &brushcolor, sizeof(D3DXCOLOR)); |
@@ -338,6 +344,9 @@ | ||
338 | 344 | // |
339 | 345 | void D3D9Pad::GlobalExit() |
340 | 346 | { |
347 | + if (deffont) delete deffont; | |
348 | + deffont = NULL; | |
349 | + | |
341 | 350 | for (int i=0;i<nfcache;i++) { |
342 | 351 | if (fcache[i].pFont) delete fcache[i].pFont; |
343 | 352 | if (fcache[i].hFont) DeleteObject(fcache[i].hFont); |
@@ -391,6 +400,7 @@ | ||
391 | 400 | |
392 | 401 | // Initialize Rectangles ------------------------------------------------------------------------- |
393 | 402 | // |
403 | + /* | |
394 | 404 | if (pRect->Lock(0,0,(void **)&pVert,0)==S_OK) { |
395 | 405 | pVert[0].x=-1.0f; pVert[0].y=-1.0f; pVert[0].z=0.5f; |
396 | 406 | pVert[1].x=+1.0f; pVert[1].y=-1.0f; pVert[1].z=0.5f; |
@@ -398,7 +408,7 @@ | ||
398 | 408 | pVert[3].x=-1.0f; pVert[3].y=+1.0f; pVert[3].z=0.5f; |
399 | 409 | pVert[4].x=-1.0f; pVert[4].y=-1.0f; pVert[4].z=0.5f; |
400 | 410 | pRect->Unlock(); |
401 | - } | |
411 | + }*/ | |
402 | 412 | |
403 | 413 | // Initialize Techniques ------------------------------------------------------------------------- |
404 | 414 | // |
@@ -500,8 +510,6 @@ | ||
500 | 510 | if (orientation==0) hFont = fcache[i].hFont; |
501 | 511 | } |
502 | 512 | |
503 | - //if (pFont && hFont) return; // Both fonts found from cache | |
504 | - | |
505 | 513 | int weight = (style & BOLD ? FW_BOLD : FW_NORMAL); |
506 | 514 | DWORD italic = (style & ITALIC ? TRUE : FALSE); |
507 | 515 | DWORD underline = (style & UNDERLINE ? TRUE : FALSE); |
@@ -543,7 +551,7 @@ | ||
543 | 551 | pFont->SetTextScale(1.0f); |
544 | 552 | pFont->Init(&fnt, 255); |
545 | 553 | |
546 | - if (orientation) pFont->SetRotation(float(orientation)*0.1f); | |
554 | + if (orientation) pFont->SetRotation(float(orientation)*0.00174532f); | |
547 | 555 | else pFont->SetRotation(0.0f); |
548 | 556 | |
549 | 557 | // Fill the cache -------------------------------- |
@@ -14,6 +14,8 @@ | ||
14 | 14 | * \brief The GDIPad class defines the context for 2-D drawing using |
15 | 15 | * Windows GDI calls. |
16 | 16 | */ |
17 | + | |
18 | + | |
17 | 19 | class D3D9Pad: public oapi::Sketchpad { |
18 | 20 | |
19 | 21 | public: |
@@ -55,7 +57,7 @@ | ||
55 | 57 | |
56 | 58 | void Ellipse2(float x, float y, float w, float h); |
57 | 59 | void Rectangle2(float l, float t, float r, float b); |
58 | - void Lines(D3DXVECTOR4 *lines, int count); | |
60 | + void Lines(D3DXVECTOR3 *lines, int count); | |
59 | 61 | |
60 | 62 | D3DXMATRIX mVP; |
61 | 63 |
@@ -68,14 +70,14 @@ | ||
68 | 70 | mutable D3DXCOLOR brushcolor; |
69 | 71 | mutable D3DXCOLOR bkcolor; |
70 | 72 | |
71 | - class D3D9PadFont *deffont; | |
72 | - | |
73 | 73 | DWORD bkmode; |
74 | 74 | DWORD halign, valign; |
75 | 75 | int origx, origy, cx, cy; |
76 | 76 | |
77 | 77 | D3D9ClientSurface *pTgt; |
78 | 78 | |
79 | + //static oapi::Font *deffont; //Won't work for some reason | |
80 | + | |
79 | 81 | static LPDIRECT3DDEVICE9 pDev; |
80 | 82 | static LPDIRECT3DVERTEXBUFFER9 pCircleLow; |
81 | 83 | static LPDIRECT3DVERTEXBUFFER9 pCircleHigh; |
@@ -15,35 +15,46 @@ | ||
15 | 15 | D3DXHANDLE D3D9ClientSurface::eTex0 = 0; |
16 | 16 | |
17 | 17 | |
18 | +bool bX = false; | |
19 | + | |
18 | 20 | // ----------------------------------------------------------------------------------------------- |
19 | 21 | // |
20 | 22 | HRESULT D3D9ClientSurface::GPUCopyRect(D3D9ClientSurface *src, LPRECT s, LPRECT t) |
21 | 23 | { |
24 | + // ATTENTION: Must use texture address mode CLAMP | |
25 | + | |
22 | 26 | //if (this!=hCurrentTgt) { |
23 | 27 | // hCurrentTgt = this; |
24 | 28 | D3DXMATRIX mVP; |
25 | - D3DXMatrixOrthoOffCenterRH(&mVP, 0.0f, (float)desc.Width, (float)desc.Height, 0.0f, -10.0f, 10.0f); | |
29 | + D3DXMatrixOrthoOffCenterLH(&mVP, 0.0f, (float)desc.Width, (float)desc.Height, 0.0f, 0.0f, 1.0f); | |
26 | 30 | HR(FX->SetMatrix(eVP, &mVP)); |
27 | 31 | //} |
28 | - | |
29 | - float w = 1.0f/(float)src->desc.Width; | |
30 | - float h = 1.0f/(float)src->desc.Height; | |
32 | + | |
33 | + float w = 1.0f / float(src->desc.Width); | |
34 | + float h = 1.0f / float(src->desc.Height); | |
31 | 35 | float qw = w*0.5f; |
32 | 36 | float qh = h*0.5f; |
33 | 37 | float lwq = s->left*w+qw; |
34 | - float rwq = s->right*w-qw; | |
35 | 38 | float thq = s->top*h+qh; |
36 | - float bhq = s->bottom*h-qh; | |
39 | + float rwq = s->right*w+qw; | |
40 | + float bhq = s->bottom*h+qh; | |
37 | 41 | |
38 | 42 | SMVERTEX Vertex[4] = { |
39 | - {(float)t->left, (float)t->top, 0, lwq, thq}, | |
40 | - {(float)t->left, (float)t->bottom, 0, lwq, bhq}, | |
41 | - {(float)t->right, (float)t->bottom, 0, rwq, bhq}, | |
42 | - {(float)t->right, (float)t->top, 0, rwq, thq} | |
43 | + {float(t->left), float(t->top), 0, lwq, thq}, | |
44 | + {float(t->left), float(t->bottom), 0, lwq, bhq}, | |
45 | + {float(t->right), float(t->bottom), 0, rwq, bhq}, | |
46 | + {float(t->right), float(t->top), 0, rwq, thq} | |
43 | 47 | }; |
44 | 48 | |
45 | - WORD Index[6] = {0,2,1,0,3,2}; | |
46 | - | |
49 | + static WORD Index[6] = {0,2,1,0,3,2}; | |
50 | + | |
51 | + //LogErr("GPU 0x%X (%s) (%d,%d,%d,%d) (%d,%d) (%d,%d)", this, name, t->left, t->top, t->right, t->bottom, s->left, s->right, src->desc.Width, src->desc.Height); | |
52 | + | |
53 | + /*if (src->desc.Width==1920 && bX==false && oapiGetSimTime()>10.0) { | |
54 | + D3DXSaveTextureToFile("Image.bmp",D3DXIFF_BMP, src->pTex, NULL); | |
55 | + bX = true; | |
56 | + }*/ | |
57 | + | |
47 | 58 | UINT numPasses = 0; |
48 | 59 | |
49 | 60 | HR(pDevice->SetVertexDeclaration(pPosTexDecl)); |
@@ -102,6 +113,7 @@ | ||
102 | 113 | bDCOpen = false; |
103 | 114 | bCopy = false; |
104 | 115 | bNoGDI = false; |
116 | + bDispWrn = true; | |
105 | 117 | pDevice = NULL; |
106 | 118 | Creation = 0; |
107 | 119 | wfact = 1.0f; |
@@ -139,7 +151,6 @@ | ||
139 | 151 | bool D3D9ClientSurface::BindGPU() |
140 | 152 | { |
141 | 153 | |
142 | - | |
143 | 154 | if (pRTS==NULL) if (D3DXCreateRenderToSurface(pDevice, desc.Width, desc.Height, desc.Format, false, D3DFMT_UNKNOWN, &pRTS)!=S_OK) { |
144 | 155 | pRTS=NULL; |
145 | 156 | LogErr("D3D9ClientSurface::BindGPU() Failed"); |
@@ -337,6 +348,16 @@ | ||
337 | 348 | |
338 | 349 | // ----------------------------------------------------------------------------------------------- |
339 | 350 | // |
351 | +bool D3D9ClientSurface::IsPowerOfTwo() const | |
352 | +{ | |
353 | + DWORD w = desc.Width, h = desc.Height; | |
354 | + for (int i=0;i<14;i++) if ((w&1)==0) w=w>>1; else { if (w!=1) return false; else break; } | |
355 | + for (int i=0;i<14;i++) if ((h&1)==0) h=h>>1; else { if (h!=1) return false; else break; } | |
356 | + return true; | |
357 | +} | |
358 | + | |
359 | +// ----------------------------------------------------------------------------------------------- | |
360 | +// | |
340 | 361 | void D3D9ClientSurface::ConvertToGDI() |
341 | 362 | { |
342 | 363 | if (pSurf && Creation==D3D9C_SURFACE && bNoGDI==false) { |
@@ -473,11 +494,12 @@ | ||
473 | 494 | } |
474 | 495 | |
475 | 496 | |
497 | + | |
476 | 498 | // ----------------------------------------------------------------------------------------------- |
477 | 499 | // |
478 | 500 | void D3D9ClientSurface::CopyRect(D3D9ClientSurface *src, LPRECT s, LPRECT t, UINT ck) |
479 | 501 | { |
480 | - //_TRACER; | |
502 | + _TRACER; | |
481 | 503 | bCopy = true; |
482 | 504 | bool bRestart = true; |
483 | 505 |
@@ -487,8 +509,23 @@ | ||
487 | 509 | DWORD TgtHeight = t->bottom - t->top; |
488 | 510 | |
489 | 511 | if (Width==0 || Height==0 || TgtWidth==0 || TgtHeight==0) return; |
490 | - if (s->right > (long)src->desc.Width || s->bottom > (long)src->desc.Height) return; | |
491 | - if (t->right > (long)desc.Width || t->bottom > (long)desc.Height) return; | |
512 | + //if (s->right > (long)src->desc.Width || s->bottom > (long)src->desc.Height) return; | |
513 | + | |
514 | + if (t->left > (long)desc.Width || t->top > (long)desc.Height) return; | |
515 | + if (t->right < 0 || t->bottom < 0) return; | |
516 | + | |
517 | + //bool bGPU = false; | |
518 | + //if (t->left<0 || t->top<0) bGPU = true; | |
519 | + //if (t->right>(long)desc.Width || t->bottom>(long)desc.Height) bGPU = true; | |
520 | + | |
521 | + /* | |
522 | + if (Width==TgtWidth && Height==TgtHeight) { | |
523 | + if (t->left<0) { Width -= abs(t->left), s->left += abs(t->left), t->left=0; } | |
524 | + if (t->top<0) { Height -= abs(t->top), s->top += abs(t->top), t->top=0; } | |
525 | + TgtWidth=Width; | |
526 | + TgtHeight=Height; | |
527 | + }*/ | |
528 | + | |
492 | 529 | |
493 | 530 | |
494 | 531 | // Do some failure tests ------------------------------------------------------ |
@@ -502,7 +539,6 @@ | ||
502 | 539 | |
503 | 540 | // Special ------------------------------ |
504 | 541 | // |
505 | - | |
506 | 542 | if (src->desc.Format == D3DFMT_R32F) { |
507 | 543 | LogErr("PrintScatter"); |
508 | 544 | GPUCopyRect(src, s, t); |
@@ -515,6 +551,8 @@ | ||
515 | 551 | return; |
516 | 552 | } |
517 | 553 | |
554 | + | |
555 | + | |
518 | 556 | if (FX) { |
519 | 557 | |
520 | 558 | // Special Handler for colorkeyed blitting ===================================================================================== |
@@ -524,7 +562,10 @@ | ||
524 | 562 | |
525 | 563 | if (Purpose&D3D9P_BACKBUF) { |
526 | 564 | if (src->pTex==NULL) src->ConvertToRenderTargetTexture(); |
527 | - if (src->pTex) if (GPUCopyRect(src, s, t)==S_OK) goto exit_ok; | |
565 | + if (src->pTex) if (GPUCopyRect(src, s, t)==S_OK) { | |
566 | + LogOk("GPU ColorKey Blitting 0x%X (%s) -> 0x%X (%s) (%u,%u)", src, src->name, this, name, Width, Height); | |
567 | + goto exit_ok; | |
568 | + } | |
528 | 569 | LogWrn("Invalid Source Surface in ColorKeyed Blit"); |
529 | 570 | } |
530 | 571 | else { |
@@ -559,13 +600,15 @@ | ||
559 | 600 | mViewPort.Y = 0; |
560 | 601 | mViewPort.Width = desc.Width; |
561 | 602 | mViewPort.Height = desc.Height; |
562 | - mViewPort.MinZ = -10.0f; | |
563 | - mViewPort.MaxZ = 10.0f; | |
603 | + mViewPort.MinZ = 0.0f; | |
604 | + mViewPort.MaxZ = 1.0f; | |
564 | 605 | |
565 | 606 | HR(pRTS->BeginScene(pTgtSurf, &mViewPort)); |
566 | 607 | GPUCopyRect(src, s, t); |
567 | 608 | HR(pRTS->EndScene(D3DX_FILTER_NONE)); |
568 | 609 | |
610 | + LogOk("GPU ColorKey_2 Blitting 0x%X (%s) -> 0x%X (%s) (%u,%u)", src, src->name, this, name, Width, Height); | |
611 | + | |
569 | 612 | if (pTgtSurf) pTgtSurf->Release(); |
570 | 613 | goto exit_ok; |
571 | 614 | } |
@@ -576,8 +619,11 @@ | ||
576 | 619 | // Use GPU to blit textures ===================================================================================== |
577 | 620 | // |
578 | 621 | if (Purpose&D3D9P_BACKBUF) { |
579 | - if (src->pTex && src->desc.Pool==D3DPOOL_DEFAULT && desc.Format!=src->desc.Format) { | |
580 | - if (GPUCopyRect(src,s,t)==S_OK) goto exit_ok; | |
622 | + if ((src->pTex && src->desc.Pool==D3DPOOL_DEFAULT && desc.Format!=src->desc.Format)) { | |
623 | + if (GPUCopyRect(src,s,t)==S_OK) { | |
624 | + LogOk("GPU ColorKey_3 Blitting 0x%X (%s) -> 0x%X (%s) (%u,%u)", src, src->name, this, name, Width, Height); | |
625 | + goto exit_ok; | |
626 | + } | |
581 | 627 | } |
582 | 628 | } |
583 | 629 | } |
@@ -627,16 +673,23 @@ | ||
627 | 673 | else pSrc = src->pSurf; |
628 | 674 | |
629 | 675 | if (pDevice->UpdateSurface(pSrc,s,pTgt,&p)==S_OK) { |
676 | + LogOk("UpdateSurface 0x%X (%s) -> 0x%X (%s) (%u,%u)", src, src->name, this, name, Width, Height); | |
630 | 677 | if (pTex) pTgt->Release(); |
631 | 678 | if (src->pTex) pSrc->Release(); |
632 | 679 | goto exit_ok; |
633 | 680 | } |
634 | 681 | else { |
682 | + // This code section is required by 2DPanel MFDs when a 4x AA is enabled. | |
683 | + // | |
635 | 684 | if (Purpose&D3D9P_BACKBUF) { |
636 | 685 | src->ConvertToDynamicTexture(); |
637 | - if (GPUCopyRect(src,s,t)==S_OK) goto exit_ok; | |
686 | + if (GPUCopyRect(src,s,t)==S_OK) { | |
687 | + LogOk("GPU ColorKey_4 Blitting 0x%X (%s) -> 0x%X (%s) (%u,%u)", src, src->name, this, name, Width, Height); | |
688 | + goto exit_ok; | |
689 | + } | |
638 | 690 | } |
639 | 691 | } |
692 | + | |
640 | 693 | LogErr("UpdateSurface Failed"); |
641 | 694 | if (pTex) pTgt->Release(); |
642 | 695 | if (src->pTex) pSrc->Release(); |
@@ -668,6 +721,7 @@ | ||
668 | 721 | else pSrc = src->pSurf; |
669 | 722 | |
670 | 723 | if (pDevice->StretchRect(pSrc, s, pTgt, t, D3DTEXF_POINT)==S_OK) { |
724 | + LogOk("StretchRect 0x%X (%s) -> 0x%X (%s) (%u,%u)", src, src->name, this, name, Width, Height); | |
671 | 725 | if (pTex) pTgt->Release(); |
672 | 726 | if (src->pTex) pSrc->Release(); |
673 | 727 | goto exit_ok; |
@@ -693,7 +747,8 @@ | ||
693 | 747 | HDC hSrc = src->GetDC(); |
694 | 748 | HDC hTgt = GetDC(); |
695 | 749 | if (hSrc && hTgt) { |
696 | - StretchBlt(hTgt, t->left, t->top, TgtWidth, TgtHeight, hSrc, s->left, s->top, Width, Height, SRCCOPY); | |
750 | + StretchBlt(hTgt, t->left, t->top, TgtWidth, TgtHeight, hSrc, s->left, s->top, Width, Height, SRCCOPY); | |
751 | + LogOk("GDI BLIT 0x%X (%s) -> 0x%X (%s) (%u,%u)", src, src->name, this, name, Width, Height); | |
697 | 752 | ReleaseDC(hTgt); |
698 | 753 | src->ReleaseDC(hSrc); |
699 | 754 | goto exit_ok; |
@@ -715,7 +770,7 @@ | ||
715 | 770 | } |
716 | 771 | |
717 | 772 | if (Type==D3D9S_PLAIN && desc.Pool==D3DPOOL_SYSTEMMEM && src->desc.Pool==D3DPOOL_DEFAULT) { |
718 | - src->ConvertToGDI(); | |
773 | + src->ConvertToGDI(); | |
719 | 774 | if (bRestart) { bRestart=false; goto restart_blit; } |
720 | 775 | } |
721 | 776 |
@@ -724,13 +779,12 @@ | ||
724 | 779 | if (bRestart) { bRestart=false; goto restart_blit; } |
725 | 780 | } |
726 | 781 | |
727 | - | |
728 | 782 | error_report: |
729 | 783 | |
730 | 784 | _SETLOG(5); |
731 | 785 | LogErr("D3D9ClientSurface::CopyRect() Failed"); |
732 | - LogMsg("Source Rect (%u,%u,%u,%u) (w=%u,h=%u) HANDLE=0x%X (%s)",s->left,s->top,s->right,s->bottom, abs(s->left-s->right), abs(s->top-s->bottom), src, src->name); | |
733 | - LogMsg("Target Rect (%u,%u,%u,%u) (w=%u,h=%u) HANDLE=0x%X (%s)",t->left,t->top,t->right,t->bottom, abs(t->left-t->right), abs(t->top-t->bottom), this, name); | |
786 | + LogMsg("Source Rect (%d,%d,%d,%d) (w=%u,h=%u) HANDLE=0x%X (%s)",s->left,s->top,s->right,s->bottom, abs(s->left-s->right), abs(s->top-s->bottom), src, src->name); | |
787 | + LogMsg("Target Rect (%d,%d,%d,%d) (w=%u,h=%u) HANDLE=0x%X (%s)",t->left,t->top,t->right,t->bottom, abs(t->left-t->right), abs(t->top-t->bottom), this, name); | |
734 | 788 | LogSpecs("Target"); |
735 | 789 | src->LogSpecs("Source"); |
736 | 790 | _POPLOG; |
@@ -744,6 +798,8 @@ | ||
744 | 798 | // |
745 | 799 | bool D3D9ClientSurface::Fill(LPRECT rect, DWORD c) |
746 | 800 | { |
801 | + _TRACER; | |
802 | + | |
747 | 803 | LPDIRECT3DSURFACE9 pTgt = pSurf; |
748 | 804 | DWORD color = 0; |
749 | 805 | LPRECT r; |
@@ -758,7 +814,7 @@ | ||
758 | 814 | |
759 | 815 | bCopy = true; |
760 | 816 | HDC hDC = GetDC(); |
761 | - if (hDC) { | |
817 | + if (hDC) { | |
762 | 818 | color = RGB((c>>16)&0xFF, (c>>8)&0xFF, c&0xFF); |
763 | 819 | HBRUSH hBrush = CreateSolidBrush((COLORREF)color); |
764 | 820 | HGDIOBJ hOld = SelectObject(hDC, hBrush); |
@@ -768,6 +824,7 @@ | ||
768 | 824 | ReleaseDC(hDC); |
769 | 825 | bCopy = false; |
770 | 826 | if (pTex) pTgt->Release(); |
827 | + LogOk("GDI Fill 0x%X (%s) (%u,%u)", this, name, (r->right-r->left), (r->bottom-r->top)); | |
771 | 828 | return true; |
772 | 829 | } |
773 | 830 | else { |
@@ -786,6 +843,7 @@ | ||
786 | 843 | return false; |
787 | 844 | } |
788 | 845 | if (pTex) pTgt->Release(); |
846 | + LogOk("ColorFill 0x%X (%s) (%u,%u)", this, name, (r->right-r->left), (r->bottom-r->top)); | |
789 | 847 | |
790 | 848 | } |
791 | 849 | return true; |
@@ -803,20 +861,27 @@ | ||
803 | 861 | LogErr("DC is already open"); LogSpecs("Surface"); |
804 | 862 | goto exit_failed; |
805 | 863 | } |
864 | + | |
865 | + //LogSpecs("Surface"); | |
806 | 866 | |
807 | 867 | bDCOpen = true; |
808 | 868 | HDC hDC = NULL; |
809 | 869 | |
810 | - | |
811 | 870 | if (Purpose&D3D9P_BACKBUF) { |
812 | - //LogErr("Acquiring DC for BackBuffer"); | |
813 | 871 | if (pSurf->GetDC(&hDC)==S_OK) return hDC; |
814 | 872 | goto exit_failed; |
815 | 873 | } |
816 | 874 | |
817 | 875 | if (Type==D3D9S_RTGTTEX || pRTS) { // Oh Shit... Acquiring a DC for rendering target surface |
876 | + | |
877 | + if (gc->Cfg()->RejectRTDC) { | |
878 | + bDCOpen = false; | |
879 | + return NULL; | |
880 | + } | |
881 | + | |
882 | + if (bDispWrn) LogWrn("Highly inefficient oapiGetDC() call for render target surface 0x%X (%s) (%dx%d)",this,name,desc.Width,desc.Height); | |
883 | + | |
818 | 884 | Purpose|=D3D9P_TGTGDI; |
819 | - //LogWrn("Doing inefficient GDI drawing into a surface 0x%X (%u,%u)",this,desc.Width,desc.Height); | |
820 | 885 | LPDIRECT3DSURFACE9 pRTgt=NULL; |
821 | 886 | HR(pTex->GetSurfaceLevel(0, &pRTgt)); |
822 | 887 | HR(pDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pTemp, NULL)); |
@@ -827,7 +892,9 @@ | ||
827 | 892 | } |
828 | 893 | |
829 | 894 | if (Type==D3D9S_DUAL) { LogErr("Dual Texture in GetDC()"); LogSpecs("Surface"); goto exit_failed; } |
830 | - if (Type==D3D9S_PLAIN && Creation==D3D9C_SURFACE && desc.Pool==D3DPOOL_DEFAULT && bNoGDI==false && desc.Height==desc.Width) ConvertToGDI(); | |
895 | + //if (Type==D3D9S_PLAIN && Creation==D3D9C_SURFACE && desc.Pool==D3DPOOL_DEFAULT && bNoGDI==false && desc.Height==desc.Width) ConvertToGDI(); | |
896 | + if (Type==D3D9S_PLAIN && Creation==D3D9C_SURFACE && desc.Pool==D3DPOOL_DEFAULT && bNoGDI==false) ConvertToGDI(); // THIS IS VITAL | |
897 | + //if (Type==D3D9S_PLAIN && Creation==D3D9C_SURFACE && desc.Pool==D3DPOOL_DEFAULT && bNoGDI==false) ConvertToDynamicTexture(); | |
831 | 898 | |
832 | 899 | if (pSurf) if (pSurf->GetDC(&hDC)==S_OK) return hDC; |
833 | 900 | if (pTex) if (pTex->GetSurfaceLevel(0, &src)==S_OK) if (src->GetDC(&hDC)==S_OK) { return hDC; } |
@@ -843,9 +910,36 @@ | ||
843 | 910 | |
844 | 911 | // ----------------------------------------------------------------------------------------------- |
845 | 912 | // |
913 | +HDC D3D9ClientSurface::GetDCHard() | |
914 | +{ | |
915 | + IDirect3DSurface9 *src=NULL; | |
916 | + | |
917 | + if (bDCOpen) { | |
918 | + LogErr("DC is already open"); LogSpecs("Surface"); | |
919 | + goto exit_failed; | |
920 | + } | |
921 | + | |
922 | + bDCOpen = true; | |
923 | + HDC hDC = NULL; | |
924 | + | |
925 | + if (pSurf) if (pSurf->GetDC(&hDC)==S_OK) return hDC; | |
926 | + if (pTex) if (pTex->GetSurfaceLevel(0, &src)==S_OK) if (src->GetDC(&hDC)==S_OK) { return hDC; } | |
927 | + | |
928 | +exit_failed: | |
929 | + | |
930 | + LogErr("D3D9ClientSurface: GetDCHard() Failed"); | |
931 | + LogSpecs("Surface"); | |
932 | + | |
933 | + bDCOpen=false; | |
934 | + return NULL; | |
935 | +} | |
936 | + | |
937 | + | |
938 | +// ----------------------------------------------------------------------------------------------- | |
939 | +// | |
846 | 940 | void D3D9ClientSurface::ReleaseDC(HDC hDC) |
847 | 941 | { |
848 | - _TRACE; | |
942 | + | |
849 | 943 | LPDIRECT3DSURFACE9 src; |
850 | 944 | |
851 | 945 | if (bDCOpen==false) { |
@@ -855,7 +949,11 @@ | ||
855 | 949 | } |
856 | 950 | else bDCOpen = false; |
857 | 951 | |
858 | - | |
952 | + if (Type==D3D9S_RTGTTEX && bDispWrn) { | |
953 | + LogWrn("...Highly inefficient GDI drawing completed."); | |
954 | + if (gc->Cfg()->DebugLvl < 3) bDispWrn=false; | |
955 | + } | |
956 | + | |
859 | 957 | if (Purpose&D3D9P_BACKBUF) { |
860 | 958 | //LogErr("Releasing Backbuffer DC"); |
861 | 959 | HR(pSurf->ReleaseDC(hDC)); |
@@ -982,6 +1080,7 @@ | ||
982 | 1080 | // |
983 | 1081 | void D3D9ClientSurface::SetColorKey(DWORD ck) |
984 | 1082 | { |
1083 | + if (ck==0) ck=0xFF000000; | |
985 | 1084 | ColorKey = ck; |
986 | 1085 | ClrKey = D3DXCOLOR(ColorKey); |
987 | 1086 | } |
@@ -73,6 +73,7 @@ | ||
73 | 73 | bool IsTexture() const { return ((Type==D3D9S_TEXTURE) || (Type==D3D9S_DYNAMIC)); } |
74 | 74 | bool IsPlainSurface() const { return (Type==D3D9S_PLAIN); } |
75 | 75 | bool IsRenderTarget() const { return (Type==D3D9S_TARGET); } |
76 | + bool IsPowerOfTwo() const; | |
76 | 77 | |
77 | 78 | LPDIRECT3DTEXTURE9 GetTexture(); |
78 | 79 | LPDIRECT3DDEVICE9 GetDevice() { return pDevice; } |
@@ -87,7 +88,8 @@ | ||
87 | 88 | void ConvertToDynamicTexture(); |
88 | 89 | void ConvertToRenderTargetTexture(); |
89 | 90 | |
90 | - HDC GetDC(); | |
91 | + HDC GetDC(); | |
92 | + HDC GetDCHard(); | |
91 | 93 | void ReleaseDC(HDC); |
92 | 94 | |
93 | 95 | void MakeBackBuffer(LPDIRECT3DSURFACE9); |
@@ -119,6 +121,7 @@ | ||
119 | 121 | bool bDCOpen; //DC is Open. This is TRUE between GetDC() and ReleaseDC() calls. |
120 | 122 | bool bCopy; |
121 | 123 | bool bNoGDI; |
124 | + bool bDispWrn; | |
122 | 125 | DWORD Refs; |
123 | 126 | DWORD Type; |
124 | 127 | int Initial; |
@@ -238,15 +238,15 @@ | ||
238 | 238 | { |
239 | 239 | // Calculate quaternion |
240 | 240 | angle *= 0.5f; |
241 | - D3DVALUE w = cosf(angle), sina = sinf(angle); | |
242 | - D3DVALUE x = sina * axis.x; | |
243 | - D3DVALUE y = sina * axis.y; | |
244 | - D3DVALUE z = sina * axis.z; | |
241 | + float w = cosf(angle), sina = sinf(angle); | |
242 | + float x = sina * axis.x; | |
243 | + float y = sina * axis.y; | |
244 | + float z = sina * axis.z; | |
245 | 245 | |
246 | 246 | // Rotation matrix |
247 | - D3DVALUE xx = x*x, yy = y*y, zz = z*z; | |
248 | - D3DVALUE xy = x*y, xz = x*z, yz = y*z; | |
249 | - D3DVALUE wx = w*x, wy = w*y, wz = w*z; | |
247 | + float xx = x*x, yy = y*y, zz = z*z; | |
248 | + float xy = x*y, xz = x*z, yz = y*z; | |
249 | + float wx = w*x, wy = w*y, wz = w*z; | |
250 | 250 | |
251 | 251 | rot->_11 = 1 - 2 * (yy+zz); |
252 | 252 | rot->_12 = 2 * (xy+wz); |
@@ -12,54 +12,44 @@ | ||
12 | 12 | #include <d3dx9.h> |
13 | 13 | |
14 | 14 | |
15 | -#define D3DVALUE float | |
16 | - | |
17 | 15 | extern char dbgline_jn[1024]; |
18 | 16 | |
17 | +/* | |
19 | 18 | #if defined(DEBUG) | defined(_DEBUG) |
20 | - #ifndef _TRACE | |
21 | - #define _TRACE \ | |
22 | - { \ | |
23 | - LogMsg("%s Line:%d %s",__FILE__,__LINE__,__FUNCTION__); \ | |
24 | - } | |
25 | - #endif | |
26 | - | |
27 | -#else | |
28 | - #ifndef _TRACE | |
29 | - #define _TRACE | |
30 | - #endif | |
31 | -#endif | |
32 | - | |
33 | -#if defined(DEBUG) | defined(_DEBUG) | |
34 | - #ifndef _TRACER | |
35 | - #define _TRACER { QueryPerformanceCounter((LARGE_INTEGER*)&qpcRef); LogMsg("[TRACE] %s Line:%d %s",__FILE__,__LINE__,__FUNCTION__); } | |
36 | - #endif | |
19 | +#ifndef _TRACE | |
20 | +#define _TRACE { LogMsg("%s Line:%d %s",__FILE__,__LINE__,__FUNCTION__); } | |
21 | +#endif | |
37 | 22 | |
38 | -#else | |
39 | - #ifndef _TRACER | |
40 | - #define _TRACER QueryPerformanceCounter((LARGE_INTEGER*)&qpcRef); | |
41 | - #endif | |
42 | -#endif | |
23 | +#ifndef _TRACER | |
24 | +#define _TRACER { QueryPerformanceCounter((LARGE_INTEGER*)&qpcRef); LogMsg("[TRACE] %s Line:%d %s",__FILE__,__LINE__,__FUNCTION__); } | |
25 | +#endif | |
43 | 26 | |
44 | -#if defined(DEBUG) | defined(_DEBUG) | |
45 | - #ifndef HR | |
46 | - #define HR(x) \ | |
47 | - { \ | |
48 | - HRESULT hr = x; \ | |
49 | - if(FAILED(hr)) \ | |
50 | - { \ | |
51 | - sprintf_s(dbgline_jn,1024,"%s Line:%d Error:%d %s",__FILE__,__LINE__,hr,(#x)); \ | |
52 | - LogErr("%s",dbgline_jn); \ | |
53 | - MessageBoxA(NULL, dbgline_jn, "D3DX9 Error:",MB_OK); \ | |
54 | - } \ | |
55 | - } | |
56 | - #endif | |
27 | +#ifndef HR | |
28 | +#define HR(x) \ | |
29 | +{ \ | |
30 | + HRESULT hr = x; \ | |
31 | + if(FAILED(hr)) \ | |
32 | + { \ | |
33 | + sprintf_s(dbgline_jn,1024,"%s Line:%d Error:%d %s",__FILE__,__LINE__,hr,(#x)); \ | |
34 | + LogErr("%s",dbgline_jn); \ | |
35 | + MessageBoxA(NULL, dbgline_jn, "D3DX9 Error:",MB_OK); \ | |
36 | + } \ | |
37 | +} | |
38 | +#endif | |
39 | +*/ | |
57 | 40 | |
58 | -#else | |
59 | - #ifndef HR | |
60 | - #define HR(x) x; | |
61 | - #endif | |
62 | -#endif | |
41 | +#ifndef _TRACE | |
42 | +#define _TRACE | |
43 | +#endif | |
44 | + | |
45 | +#ifndef _TRACER | |
46 | +#define _TRACER QueryPerformanceCounter((LARGE_INTEGER*)&qpcRef); | |
47 | +#endif | |
48 | + | |
49 | +#ifndef HR | |
50 | +#define HR(x) x; | |
51 | +#endif | |
52 | + | |
63 | 53 | |
64 | 54 | #define SURFACE(x) ((class D3D9ClientSurface *)x) |
65 | 55 |
@@ -220,30 +210,30 @@ | ||
220 | 210 | // Vertex formats |
221 | 211 | // ------------------------------------------------------------------------------------ |
222 | 212 | |
223 | -struct VECTOR2D { D3DVALUE x, y; }; | |
213 | +struct VECTOR2D { float x, y; }; | |
224 | 214 | |
225 | -struct VERTEX_XYZ { D3DVALUE x, y, z; }; // transformed vertex | |
226 | -struct VERTEX_XYZH { D3DVALUE x, y, z, h; }; // untransformed vertex | |
227 | -struct VERTEX_XYZC { D3DVALUE x, y, z; D3DCOLOR col; }; // untransformed vertex with single colour component | |
228 | -struct VERTEX_XYZHC { D3DVALUE x, y, z, h; D3DCOLOR col; }; // transformed vertex with single colour component | |
215 | +struct VERTEX_XYZ { float x, y, z; }; // transformed vertex | |
216 | +struct VERTEX_XYZH { float x, y, z, h; }; // untransformed vertex | |
217 | +struct VERTEX_XYZC { float x, y, z; D3DCOLOR col; }; // untransformed vertex with single colour component | |
218 | +struct VERTEX_XYZHC { float x, y, z, h; D3DCOLOR col; }; // transformed vertex with single colour component | |
229 | 219 | |
230 | 220 | |
231 | 221 | |
232 | 222 | // untransformed lit vertex with texture coordinates |
233 | 223 | struct VERTEX_XYZ_TEX { |
234 | - D3DVALUE x, y, z; | |
235 | - D3DVALUE tu, tv; | |
224 | + float x, y, z; | |
225 | + float tu, tv; | |
236 | 226 | }; |
237 | 227 | #define FVF_XYZ_TEX ( D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0) ) |
238 | 228 | |
239 | 229 | // untransformed unlit vertex with two sets of texture coordinates |
240 | 230 | struct VERTEX_2TEX { |
241 | - D3DVALUE x, y, z, nx, ny, nz; | |
242 | - D3DVALUE tu0, tv0, tu1, tv1; | |
231 | + float x, y, z, nx, ny, nz; | |
232 | + float tu0, tv0, tu1, tv1; | |
243 | 233 | inline VERTEX_2TEX() {} |
244 | 234 | //VERTEX_2TEX () |
245 | 235 | //{ x = y = z = nx = ny = nz = tu0 = tv0 = tu1 = tv1 = 0.0f; } |
246 | - inline VERTEX_2TEX (D3DVECTOR p, D3DVECTOR n, D3DVALUE u0, D3DVALUE v0, D3DVALUE u1, D3DVALUE v1) | |
236 | + inline VERTEX_2TEX (D3DVECTOR p, D3DVECTOR n, float u0, float v0, float u1, float v1) | |
247 | 237 | { x = p.x, y = p.y, z = p.z, nx = n.x, ny = n.y, nz = n.z; |
248 | 238 | tu0 = u0, tv0 = v0, tu1 = u1, tv1 = v1; } |
249 | 239 | }; |
@@ -251,17 +241,17 @@ | ||
251 | 241 | |
252 | 242 | // transformed lit vertex with 1 colour definition and one set of texture coordinates |
253 | 243 | struct VERTEX_TL1TEX { |
254 | - D3DVALUE x, y, z, rhw; | |
244 | + float x, y, z, rhw; | |
255 | 245 | D3DCOLOR col; |
256 | - D3DVALUE tu, tv; | |
246 | + float tu, tv; | |
257 | 247 | }; |
258 | 248 | #define FVF_TL1TEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0) ) |
259 | 249 | |
260 | 250 | // transformed lit vertex with two sets of texture coordinates |
261 | 251 | struct VERTEX_TL2TEX { |
262 | - D3DVALUE x, y, z, rhw; | |
252 | + float x, y, z, rhw; | |
263 | 253 | D3DCOLOR diff, spec; |
264 | - D3DVALUE tu0, tv0, tu1, tv1; | |
254 | + float tu0, tv0, tu1, tv1; | |
265 | 255 | }; |
266 | 256 | #define FVF_TL2TEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2 | D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE2(1) ) |
267 | 257 |
@@ -15,6 +15,8 @@ | ||
15 | 15 | |
16 | 16 | GDIPad::GDIPad (SURFHANDLE s, HDC hdc): Sketchpad (s) |
17 | 17 | { |
18 | + LogOk("Creating GDI SketchPad..."); | |
19 | + | |
18 | 20 | hDC = hdc; |
19 | 21 | hFont0 = NULL; |
20 | 22 | cfont = NULL; |
@@ -38,6 +40,8 @@ | ||
38 | 40 | if (hFont0) SelectObject (hDC, hFont0); |
39 | 41 | if (cpen) SelectObject (hDC, GetStockObject (NULL_PEN)); |
40 | 42 | if (cbrush) SelectObject (hDC, GetStockObject (NULL_BRUSH)); |
43 | + | |
44 | + LogOk("...GDI SketchPad Released"); | |
41 | 45 | } |
42 | 46 | |
43 | 47 | Font *GDIPad::SetFont (Font *font) const |
@@ -210,7 +210,7 @@ | ||
210 | 210 | WORD HazeManager::Idx[HORIZON_NSEG*2+2]; |
211 | 211 | struct HazeManager::HVERTEX HazeManager::Vtx[HORIZON_NSEG*2]; |
212 | 212 | DWORD HazeManager::nIdx = HORIZON_NSEG*2+2; |
213 | -D3DVALUE HazeManager::CosP[HORIZON_NSEG]; | |
214 | -D3DVALUE HazeManager::SinP[HORIZON_NSEG]; | |
213 | +float HazeManager::CosP[HORIZON_NSEG]; | |
214 | +float HazeManager::SinP[HORIZON_NSEG]; | |
215 | 215 | |
216 | 216 | LPD3D9CLIENTSURFACE HazeManager::horizon = 0; |
@@ -45,9 +45,9 @@ | ||
45 | 45 | static WORD Idx[HORIZON_NSEG*2+2]; |
46 | 46 | static DWORD nIdx; |
47 | 47 | static struct HVERTEX { |
48 | - D3DVALUE x,y,z; | |
48 | + float x,y,z; | |
49 | 49 | DWORD dcol; |
50 | - D3DVALUE tu, tv; } Vtx[HORIZON_NSEG*2]; | |
50 | + float tu, tv; } Vtx[HORIZON_NSEG*2]; | |
51 | 51 | static float CosP[HORIZON_NSEG], SinP[HORIZON_NSEG]; |
52 | 52 | static LPD3D9CLIENTSURFACE horizon; |
53 | 53 | }; |
@@ -711,7 +711,7 @@ | ||
711 | 711 | if (vP.y-(r*hf) > (h*vP.z)) return; |
712 | 712 | if (vP.x-(r*wf) > (w*vP.z)) return; |
713 | 713 | |
714 | - D3DMATERIAL9 *mat, *old_mat=NULL; | |
714 | + D3DMATERIAL9 *mat, *old_mat = NULL; | |
715 | 715 | LPD3D9CLIENTSURFACE old_tex = NULL; |
716 | 716 | LPD3D9CLIENTSURFACE Diffuse = NULL; |
717 | 717 |
@@ -728,11 +728,11 @@ | ||
728 | 728 | const D3D9Light *pLights = gc->GetScene()->GetLights(); |
729 | 729 | |
730 | 730 | if (pLights && nLights>0) { |
731 | - HR(FX->SetValue(eLights, pLights, 12*sizeof(D3D9Light))); | |
732 | - HR(FX->SetInt(eLightCount, nLights)); | |
731 | + FX->SetValue(eLights, pLights, 12*sizeof(D3D9Light)); | |
732 | + FX->SetInt(eLightCount, nLights); | |
733 | 733 | } |
734 | 734 | else { |
735 | - HR(FX->SetInt(eLightCount, 0)); | |
735 | + FX->SetInt(eLightCount, 0); | |
736 | 736 | } |
737 | 737 | |
738 | 738 | SetupFog(NULL, NULL); |
@@ -1236,12 +1236,15 @@ | ||
1236 | 1236 | UINT numPasses = 0; |
1237 | 1237 | |
1238 | 1238 | if (alpha==1.0f) { |
1239 | - HR(FX->SetTechnique(eSimple)); | |
1239 | + if (pTex->IsPowerOfTwo()) FX->SetTechnique(eSimple); // Opaque | |
1240 | + else FX->SetTechnique(ePanelTechB); // Opaque | |
1240 | 1241 | } |
1241 | 1242 | else { |
1242 | - HR(FX->SetTechnique(ePanelTech)); | |
1243 | + HR(FX->SetTechnique(ePanelTech)); // Transparent | |
1243 | 1244 | } |
1244 | - HR(FX->SetFloat(eMix, scale)); | |
1245 | + | |
1246 | + //HR(FX->SetFloat(eMix, scale)); | |
1247 | + | |
1245 | 1248 | HR(FX->SetMatrix(eW, pW)); |
1246 | 1249 | HR(FX->SetMatrix(eVP, pVP)); |
1247 | 1250 | HR(FX->SetTexture(eTex0, pTex->GetTexture())); |
@@ -803,7 +803,7 @@ | ||
803 | 803 | //D3DXMatrixAffineTransformation(&T, 1.0f, &rf, &qr, NULL); |
804 | 804 | |
805 | 805 | D3DMAT_RotationFromAxis (ax, (float)ds*rot->angle, &T); |
806 | - D3DVALUE dx = D3DVAL(rot->ref.x), dy = D3DVAL(rot->ref.y), dz = D3DVAL(rot->ref.z); | |
806 | + float dx = D3DVAL(rot->ref.x), dy = D3DVAL(rot->ref.y), dz = D3DVAL(rot->ref.z); | |
807 | 807 | T._41 = dx - T._11*dx - T._21*dy - T._31*dz; |
808 | 808 | T._42 = dy - T._12*dx - T._22*dy - T._32*dz; |
809 | 809 | T._43 = dz - T._13*dx - T._23*dy - T._33*dz; |