Mercurial > mm7
comparison Render.h @ 2462:1d04e48651d4
Render split into interface and realization, added Direct3D 11
author | a.parshin |
---|---|
date | Tue, 12 Aug 2014 21:34:18 +0300 |
parents | 2d3c3d1dff0c |
children | 0f17a30149ec |
comparison
equal
deleted
inserted
replaced
2461:ff7f4995aa25 | 2462:1d04e48651d4 |
---|---|
7 #include "OSWindow.h" | 7 #include "OSWindow.h" |
8 #include "RenderStruct.h" | 8 #include "RenderStruct.h" |
9 | 9 |
10 #include "VectorTypes.h" | 10 #include "VectorTypes.h" |
11 | 11 |
12 struct Render | 12 #include "IRender.h" |
13 | |
14 struct Render: public IRender | |
13 { | 15 { |
14 Render(); | 16 Render(); |
15 ~Render(); | 17 virtual ~Render(); |
16 | 18 |
17 static Render *Create() {return new Render;} | 19 static Render *Create() {return new Render;} |
18 | 20 |
19 bool Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting); | 21 virtual bool Initialize(OSWindow *window); |
20 | 22 |
21 | 23 virtual void ClearBlack(); |
22 void ClearBlack(); | 24 virtual void PresentBlackScreen(); |
23 void PresentBlackScreen(); | 25 |
24 | 26 virtual void SaveWinnersCertificate(const char *a1); |
25 void SaveWinnersCertificate(const char *a1); | 27 virtual void ClearTarget(unsigned int uColor); |
26 void ClearTarget(unsigned int uColor); | 28 virtual void Present(); |
27 void Present(); | 29 |
28 | 30 virtual void _49FD3A_fullscreen(); |
29 void _49FD3A_fullscreen(); | 31 virtual bool InitializeFullscreen(); |
30 bool InitializeFullscreen(); | 32 |
31 | 33 virtual void CreateZBuffer(); |
32 void CreateZBuffer(); | 34 virtual void Release(); |
33 void Release(); | 35 |
34 | 36 virtual bool SwitchToWindow(); |
35 bool SwitchToWindow(); | 37 virtual void RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor); |
36 void RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor); | 38 virtual void ClearZBuffer(int a2, int a3); |
37 void ClearZBuffer(int a2, int a3); | 39 virtual void SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW); |
38 void SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW); | 40 virtual bool LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags); |
39 bool LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags); | 41 virtual void GetTargetPixelFormat(DDPIXELFORMAT *pOut); |
40 void GetTargetPixelFormat(DDPIXELFORMAT *pOut); | 42 virtual void LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow); |
41 void LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow); | 43 virtual void UnlockBackBuffer(); |
42 void UnlockBackBuffer(); | 44 virtual void LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow); |
43 void LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow); | 45 virtual void UnlockFrontBuffer(); |
44 void UnlockFrontBuffer(); | 46 virtual void RestoreFrontBuffer(); |
45 void RestoreFrontBuffer(); | 47 virtual void RestoreBackBuffer(); |
46 void RestoreBackBuffer(); | 48 virtual void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags); |
47 void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags); | 49 virtual void BltBackToFontFast(int a2, int a3, RECT *a4); |
48 void BltBackToFontFast(int a2, int a3, RECT *a4); | 50 virtual void BeginSceneD3D(); |
49 void BeginSceneD3D(); | 51 |
50 | 52 virtual unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6); |
51 unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6); | 53 |
52 | 54 virtual void DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture); |
53 void DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture); | 55 virtual void DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders); |
54 void DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders); | 56 virtual void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, struct Texture *pTex, int uPackedID, unsigned int uColor, int a8); |
55 void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, struct Texture *pTex, int uPackedID, unsigned int uColor, int a8); | 57 |
56 | 58 virtual void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); |
57 void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); | 59 virtual void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); |
58 void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); | 60 |
59 | 61 virtual void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); |
60 void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | 62 virtual void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level); |
61 void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level); | 63 virtual void _4A4CC9_AddSomeBillboard(struct stru6_stru1_indoor_sw_billboard *a1, int diffuse); |
62 void _4A4CC9_AddSomeBillboard(struct stru6_stru1_indoor_sw_billboard *a1, int diffuse); | 64 virtual void TransformBillboardsAndSetPalettesODM(); |
63 void TransformBillboardsAndSetPalettesODM(); | 65 virtual void DrawBillboardList_BLV(); |
64 void DrawBillboardList_BLV(); | 66 |
65 | 67 virtual void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9); |
66 void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9); | 68 virtual bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture); |
67 bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture); | 69 virtual bool MoveSpriteToDevice(Sprite *pSprite); |
68 bool MoveSpriteToDevice(Sprite *pSprite); | 70 |
69 | 71 virtual void BeginScene(); |
70 void BeginScene(); | 72 virtual void EndScene(); |
71 void EndScene(); | 73 virtual void ScreenFade(unsigned int color, float t); |
72 void ScreenFade(unsigned int color, float t); | 74 |
73 | 75 virtual void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW); |
74 void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW); | 76 virtual void ResetTextureClipRect(); |
75 void ResetTextureClipRect(); | 77 virtual void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4); |
76 void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4); | 78 virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture); |
77 void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture); | 79 virtual void DrawTextureIndexed(unsigned int uX, unsigned int uY, struct Texture *a4); |
78 void DrawTextureIndexed(unsigned int uX, unsigned int uY, struct Texture *a4); | 80 |
79 | 81 virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5); |
80 void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5); | 82 virtual void DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal); |
81 void DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal); | 83 virtual void DrawTextureTransparent(unsigned int uX, unsigned int uY, struct Texture *pTexture); |
82 void DrawTextureTransparent(unsigned int uX, unsigned int uY, struct Texture *pTexture); | 84 virtual void DrawAura(unsigned int a2, unsigned int a3, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8); |
83 void DrawAura(unsigned int a2, unsigned int a3, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8); | 85 virtual void _4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8); |
84 void _4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8); | 86 |
85 | 87 virtual void DrawTransparentRedShade(unsigned int a2, unsigned int a3, struct Texture *a4); |
86 void DrawTransparentRedShade(unsigned int a2, unsigned int a3, struct Texture *a4); | 88 virtual void DrawTransparentGreenShade(signed int a2, signed int a3, struct Texture *pTexture); |
87 void DrawTransparentGreenShade(signed int a2, signed int a3, struct Texture *pTexture); | 89 virtual void DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices); |
88 void DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices); | 90 |
89 | 91 virtual void DrawMasked(signed int a2, signed int a3, struct Texture *pTexture, unsigned __int16 mask); |
90 void DrawMasked(signed int a2, signed int a3, struct Texture *pTexture, unsigned __int16 mask); | 92 virtual void GetLeather(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height); |
91 void GetLeather(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height); | 93 |
92 | 94 virtual void DrawTextPalette(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8); |
93 void DrawTextPalette(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8); | 95 virtual 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); |
94 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); | 96 |
95 | 97 virtual void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16); |
96 void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16); | 98 virtual void _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7); |
97 void _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7); | 99 virtual void DrawTranslucent(unsigned int a2, unsigned int a3, struct Texture *a4); |
98 void DrawTranslucent(unsigned int a2, unsigned int a3, struct Texture *a4); | 100 |
99 | 101 virtual void DrawBuildingsD3D(); |
100 void DrawBuildingsD3D(); | |
101 //struct BSPModel *DrawBuildingsSW(); | 102 //struct BSPModel *DrawBuildingsSW(); |
102 //int OnOutdoorRedrawSW(); | 103 //int OnOutdoorRedrawSW(); |
103 | 104 |
104 void DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID); | 105 virtual void DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID); |
105 void DrawOutdoorSkyD3D(); | 106 virtual void DrawOutdoorSkyD3D(); |
106 //int DrawSkySW(struct Span *a1, Polygon *a2, int a3); | 107 //int DrawSkySW(struct Span *a1, Polygon *a2, int a3); |
107 void DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture); | 108 virtual void DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture); |
108 void DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture); | 109 virtual void DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture); |
109 | 110 |
110 void PrepareDecorationsRenderList_ODM(); | 111 virtual void PrepareDecorationsRenderList_ODM(); |
111 void DrawSpriteObjects_ODM(); | 112 virtual void DrawSpriteObjects_ODM(); |
112 | 113 |
113 //float DrawBezierTerrain(); | 114 //float DrawBezierTerrain(); |
114 void RenderTerrainD3D(); | 115 virtual void RenderTerrainD3D(); |
115 void DrawTerrainD3D(int a1, int edx0, int a3, int unk4); | |
116 //void DrawTerrainSW(int a1, int a2, int a3, int a4); | 116 //void DrawTerrainSW(int a1, int a2, int a3, int a4); |
117 | 117 |
118 //void ExecOutdoorDrawSW(); | 118 //void ExecOutdoorDrawSW(); |
119 void ChangeBetweenWinFullscreenModes(); | 119 virtual void ChangeBetweenWinFullscreenModes(); |
120 bool AreRenderSurfacesOk(); | 120 virtual bool AreRenderSurfacesOk(); |
121 bool IsGammaSupported(); | 121 virtual bool IsGammaSupported(); |
122 | 122 |
123 void SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height); | 123 virtual void SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height); |
124 void PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size); | 124 virtual void PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size); |
125 void SavePCXScreenshot(); | 125 virtual void SavePCXScreenshot(); |
126 | 126 |
127 int _46À6ÀÑ_GetActorsInViewport(int pDepth); | 127 virtual int _46À6ÀÑ_GetActorsInViewport(int pDepth); |
128 | 128 |
129 void BeginLightmaps(); | 129 virtual void BeginLightmaps(); |
130 void EndLightmaps(); | 130 virtual void EndLightmaps(); |
131 void BeginLightmaps2(); | 131 virtual void BeginLightmaps2(); |
132 void EndLightmaps2(); | 132 virtual void EndLightmaps2(); |
133 bool DrawLightmap(struct Lightmap *pLightmap, struct Vec3_float_ *pColorMult, float z_bias); | 133 virtual bool DrawLightmap(struct Lightmap *pLightmap, struct Vec3_float_ *pColorMult, float z_bias); |
134 | 134 |
135 void BeginDecals(); | 135 virtual void BeginDecals(); |
136 void EndDecals(); | 136 virtual void EndDecals(); |
137 void DrawDecal(struct Decal *pDecal, float z_bias); | 137 virtual void DrawDecal(struct Decal *pDecal, float z_bias); |
138 | 138 |
139 void do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff); | 139 virtual void do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff); |
140 void DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices); | 140 virtual void DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices); |
141 | 141 |
142 void DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture); | 142 virtual void DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture); |
143 | 143 |
144 void am_Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3); | 144 virtual void am_Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3); |
145 void am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode); | 145 virtual void am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode); |
146 | 146 |
147 public: | 147 public:/* |
148 int *pActiveZBuffer; | 148 int *pActiveZBuffer; |
149 IDirectDraw4 *pDirectDraw4; | 149 IDirectDraw4 *pDirectDraw4; |
150 IDirectDrawSurface4 *pFrontBuffer4; | 150 IDirectDrawSurface4 *pFrontBuffer4; |
151 IDirectDrawSurface4 *pBackBuffer4; | 151 IDirectDrawSurface4 *pBackBuffer4; |
152 void *pTargetSurface; | 152 void *pTargetSurface; |
159 int hd_water_current_frame; | 159 int hd_water_current_frame; |
160 int hd_water_tile_id; | 160 int hd_water_tile_id; |
161 void (*pBeforePresentFunction)(); | 161 void (*pBeforePresentFunction)(); |
162 uint32_t bFogEnabled; | 162 uint32_t bFogEnabled; |
163 RenderBillboardD3D pBillboardRenderListD3D[1000]; | 163 RenderBillboardD3D pBillboardRenderListD3D[1000]; |
164 unsigned int uNumBillboardsToDraw; | 164 unsigned int uNumBillboardsToDraw;*/ |
165 | 165 |
166 inline void WritePixel16(int x, int y, unsigned __int16 color) | 166 virtual void WritePixel16(int x, int y, unsigned __int16 color) |
167 { | 167 { |
168 if (ddpfPrimarySuface.dwRGBBitCount == 32) | 168 if (ddpfPrimarySuface.dwRGBBitCount == 32) |
169 { | 169 { |
170 auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch; | 170 auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch; |
171 *p = Color32(color); | 171 *p = Color32(color); |
176 *p = color; | 176 *p = color; |
177 } | 177 } |
178 else __debugbreak(); | 178 else __debugbreak(); |
179 } | 179 } |
180 | 180 |
181 inline unsigned __int16 ReadPixel16(int x, int y) | 181 virtual unsigned __int16 ReadPixel16(int x, int y) |
182 { | 182 { |
183 if (ddpfPrimarySuface.dwRGBBitCount == 32) | 183 if (ddpfPrimarySuface.dwRGBBitCount == 32) |
184 { | 184 { |
185 auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch; | 185 auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch; |
186 return Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | 186 return Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); |
191 return *p; | 191 return *p; |
192 } | 192 } |
193 else __debugbreak(); | 193 else __debugbreak(); |
194 } | 194 } |
195 | 195 |
196 inline void ToggleTint() {bTinting = !bTinting;} | 196 virtual void ToggleTint() {bTinting = !bTinting;} |
197 inline void ToggleColoredLights() {bUseColoredLights = !bUseColoredLights;} | 197 virtual void ToggleColoredLights() {bUseColoredLights = !bUseColoredLights;} |
198 | 198 |
199 inline unsigned int GetRenderWidth() {return window->GetWidth();} | 199 virtual unsigned int GetRenderWidth() {return window->GetWidth();} |
200 inline unsigned int GetRenderHeight() {return window->GetHeight();} | 200 virtual unsigned int GetRenderHeight() {return window->GetHeight();} |
201 | 201 |
202 inline void Sub01() | 202 virtual void Sub01() |
203 { | 203 { |
204 if (pRenderD3D && !bWindowMode) | 204 if (pRenderD3D && !bWindowMode) |
205 _49FD3A_fullscreen(); | 205 _49FD3A_fullscreen(); |
206 } | 206 } |
207 | 207 |