2416
|
1 /*#pragma once
|
2402
|
2 #define WIN32_LEAN_AND_MEAN
|
|
3
|
2409
|
4 #include "OSWindow.h"
|
|
5 #include <cstdint>
|
|
6 #include <cstdio>
|
|
7
|
|
8 //#include "lib\legacy_dx\d3d.h"
|
|
9
|
|
10 #include "VectorTypes.h"
|
2402
|
11
|
|
12 #include <d3d11.h>
|
2410
|
13 #include "RenderStruct.h"
|
2402
|
14 #pragma comment(lib, "d3d11.lib")
|
|
15
|
|
16 class D3D11
|
|
17 {
|
|
18 HINSTANCE g_hInst;
|
|
19 HWND g_hWnd;
|
2410
|
20 D3D_DRIVER_TYPE g_driverType; //Этот параметр указывает, производить вычисления в видеокарте или в центральном процессоре.
|
|
21 D3D_FEATURE_LEVEL g_featureLevel; //параметр, указывающий, какую версию DirectX поддерживает наша видеокарта.
|
|
22 ID3D11Device* g_pd3dDevice; //устройство d3d11
|
|
23 ID3D11DeviceContext* g_pImmediateContext;// контекст устройства
|
|
24 IDXGISwapChain* g_pSwapChain; // цепочка обмена
|
2402
|
25 ID3D11RenderTargetView* g_pRenderTargetView;
|
|
26
|
|
27
|
|
28 public:
|
|
29
|
2410
|
30 int *pActiveZBuffer;
|
|
31 //IDirectDraw4 *pDirectDraw4;
|
|
32 //IDirectDrawSurface4 *pFrontBuffer4;
|
|
33 //IDirectDrawSurface4 *pBackBuffer4;
|
|
34 ID3D11Texture2D* pBackBuffer;
|
|
35 void *pTargetSurface;
|
|
36 unsigned int uTargetSurfacePitch;
|
|
37 unsigned int bUseColoredLights;
|
|
38 unsigned int bTinting;
|
|
39 unsigned int bUsingSpecular;
|
|
40 uint32_t uFogColor;
|
|
41 unsigned int pHDWaterBitmapIDs[7];
|
|
42 int hd_water_current_frame;
|
|
43 int hd_water_tile_id;
|
|
44 void (*pBeforePresentFunction)();
|
|
45 uint32_t bFogEnabled;
|
|
46 RenderBillboardD3D pBillboardRenderListD3D[1000];
|
|
47 unsigned int uNumBillboardsToDraw;
|
|
48
|
2402
|
49 D3D11():
|
|
50 g_hInst(NULL), g_hWnd(NULL), g_driverType(D3D_DRIVER_TYPE_NULL), g_featureLevel(D3D_FEATURE_LEVEL_11_0),
|
|
51 g_pd3dDevice(NULL), g_pImmediateContext(NULL), g_pSwapChain(NULL), g_pRenderTargetView(NULL){}
|
|
52
|
|
53 HRESULT InitDevice(); // Инициализация устройств DirectX
|
|
54 void CleanupDevice(); // Удаление созданнных устройств DirectX
|
2409
|
55 //void Render(); // Функция рисования
|
2410
|
56
|
2409
|
57 bool Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting);
|
|
58
|
|
59
|
|
60 void ClearBlack();
|
|
61 void PresentBlackScreen();
|
|
62
|
|
63 void SaveWinnersCertificate(const char *a1);
|
|
64 void ClearTarget(unsigned int uColor);
|
|
65 void Present();
|
|
66
|
|
67 void _49FD3A_fullscreen();
|
|
68 bool InitializeFullscreen();
|
|
69
|
|
70 void CreateZBuffer();
|
|
71 void Release();
|
|
72
|
|
73 bool SwitchToWindow();
|
|
74 void RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor);
|
|
75 void ClearZBuffer(int a2, int a3);
|
|
76 void SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
|
|
77 bool LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags);
|
|
78 void GetTargetPixelFormat(DDPIXELFORMAT *pOut);
|
|
79 void LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow);
|
|
80
|
|
81 void UnlockBackBuffer();
|
|
82 void RestoreBackBuffer();
|
|
83
|
|
84 void LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow);
|
|
85 void UnlockFrontBuffer();
|
|
86 void RestoreFrontBuffer();
|
|
87
|
|
88 void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags);
|
|
89 void BltBackToFontFast(int a2, int a3, RECT *a4);
|
|
90 void BeginSceneD3D();
|
|
91
|
|
92 unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6);
|
|
93
|
|
94 void DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture);
|
|
95 void DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders);
|
|
96 void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, struct Texture *pTex, int uPackedID, unsigned int uColor, int a8);
|
|
97
|
|
98 void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle);
|
|
99 void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle);
|
|
100
|
|
101 void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
|
|
102 void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level);
|
|
103 void _4A4CC9_AddSomeBillboard(struct stru6_stru1_indoor_sw_billboard *a1, int diffuse);
|
|
104 void TransformBillboardsAndSetPalettesODM();
|
|
105 void DrawBillboardList_BLV();
|
|
106
|
|
107 void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9);
|
|
108 bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture);
|
|
109 bool MoveSpriteToDevice(Sprite *pSprite);
|
|
110
|
|
111 void BeginScene();
|
|
112 void EndScene();
|
|
113 void ScreenFade(unsigned int color, float t);
|
|
114
|
|
115 void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
|
|
116 void ResetTextureClipRect();
|
|
117 void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4);
|
|
118 void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture);
|
|
119 void DrawTextureIndexed(unsigned int uX, unsigned int uY, struct Texture *a4);
|
|
120
|
|
121 void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5);
|
|
122 void DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal);
|
|
123 void DrawTextureTransparent(unsigned int uX, unsigned int uY, struct Texture *pTexture);
|
|
124 void DrawAura(unsigned int a2, unsigned int a3, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8);
|
|
125 void _4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8);
|
|
126
|
|
127 void DrawTransparentRedShade(unsigned int a2, unsigned int a3, struct Texture *a4);
|
|
128 void DrawTransparentGreenShade(signed int a2, signed int a3, struct Texture *pTexture);
|
|
129 void DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices);
|
|
130
|
|
131 void DrawMasked(signed int a2, signed int a3, struct Texture *pTexture, unsigned __int16 mask);
|
|
132 void GetLeather(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height);
|
|
133
|
|
134 void DrawTextPalette(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8);
|
|
135 void DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor);
|
|
136
|
|
137 void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16);
|
|
138 void _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7);
|
|
139 void DrawTranslucent(unsigned int a2, unsigned int a3, struct Texture *a4);
|
|
140
|
|
141 void DrawBuildingsD3D();
|
|
142 //struct BSPModel *DrawBuildingsSW();
|
|
143 //int OnOutdoorRedrawSW();
|
|
144
|
|
145 void DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID);
|
|
146 void DrawOutdoorSkyD3D();
|
|
147 //int DrawSkySW(struct Span *a1, Polygon *a2, int a3);
|
|
148 void DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture);
|
|
149 void DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture);
|
|
150
|
|
151 void PrepareDecorationsRenderList_ODM();
|
|
152 void DrawSpriteObjects_ODM();
|
|
153
|
|
154 //float DrawBezierTerrain();
|
|
155 void RenderTerrainD3D();
|
|
156 void DrawTerrainD3D(int a1, int edx0, int a3, int unk4);
|
|
157 //void DrawTerrainSW(int a1, int a2, int a3, int a4);
|
|
158
|
|
159 //void ExecOutdoorDrawSW();
|
|
160 void ChangeBetweenWinFullscreenModes();
|
|
161 bool AreRenderSurfacesOk();
|
|
162 bool IsGammaSupported();
|
|
163
|
|
164 void SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height);
|
|
165 void PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size);
|
|
166 void SavePCXScreenshot();
|
|
167
|
|
168 int _46А6АС_GetActorsInViewport(int pDepth);
|
|
169
|
|
170 void BeginLightmaps();
|
|
171 void EndLightmaps();
|
|
172 void BeginLightmaps2();
|
|
173 void EndLightmaps2();
|
|
174 bool DrawLightmap(struct Lightmap *pLightmap, struct Vec3_float_ *pColorMult, float z_bias);
|
|
175
|
|
176 void BeginDecals();
|
|
177 void EndDecals();
|
|
178 void DrawDecal(struct Decal *pDecal, float z_bias);
|
|
179
|
|
180 void do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff);
|
|
181 void DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices);
|
|
182
|
|
183 void DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture);
|
|
184
|
|
185 void am_Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3);
|
|
186 void am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode);
|
2410
|
187
|
|
188 inline void ToggleTint() {bTinting = !bTinting;}
|
|
189 inline void ToggleColoredLights() {bUseColoredLights = !bUseColoredLights;}
|
|
190
|
|
191 inline unsigned int GetRenderWidth() {return window->GetWidth();}
|
|
192 inline unsigned int GetRenderHeight() {return window->GetHeight();}
|
|
193
|
|
194
|
|
195 friend void Present_NoColorKey();
|
|
196
|
2402
|
197 };
|
2416
|
198 */ |