Mercurial > mm7
annotate Render.h @ 2436:ed1e4cff79a2
fixed uninitialized memory access in SpriteFrameTable::FromFile
author | Grumpy7 |
---|---|
date | Wed, 23 Jul 2014 22:24:53 +0200 |
parents | 2d3c3d1dff0c |
children | 1d04e48651d4 |
rev | line source |
---|---|
0 | 1 #pragma once |
1512 | 2 |
3 #include <cstdint> | |
4 #include <cstdio> | |
0 | 5 |
6 #include "lib\legacy_dx\d3d.h" | |
1802 | 7 #include "OSWindow.h" |
2410 | 8 #include "RenderStruct.h" |
0 | 9 |
10 #include "VectorTypes.h" | |
11 | |
12 struct Render | |
13 { | |
14 Render(); | |
15 ~Render(); | |
16 | |
17 static Render *Create() {return new Render;} | |
18 | |
2069 | 19 bool Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting); |
0 | 20 |
21 | |
22 void ClearBlack(); | |
23 void PresentBlackScreen(); | |
2404 | 24 |
2069 | 25 void SaveWinnersCertificate(const char *a1); |
0 | 26 void ClearTarget(unsigned int uColor); |
27 void Present(); | |
2404 | 28 |
2154 | 29 void _49FD3A_fullscreen(); |
2404 | 30 bool InitializeFullscreen(); |
31 | |
0 | 32 void CreateZBuffer(); |
33 void Release(); | |
2404 | 34 |
1802 | 35 bool SwitchToWindow(); |
2102 | 36 void RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor); |
0 | 37 void ClearZBuffer(int a2, int a3); |
709 | 38 void SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW); |
0 | 39 bool LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags); |
40 void GetTargetPixelFormat(DDPIXELFORMAT *pOut); | |
41 void LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow); | |
42 void UnlockBackBuffer(); | |
43 void LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow); | |
44 void UnlockFrontBuffer(); | |
45 void RestoreFrontBuffer(); | |
2152 | 46 void RestoreBackBuffer(); |
0 | 47 void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags); |
48 void BltBackToFontFast(int a2, int a3, RECT *a4); | |
49 void BeginSceneD3D(); | |
2404 | 50 |
349 | 51 unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6); |
2404 | 52 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
53 void DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture); |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
54 void DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders); |
1262 | 55 void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, struct Texture *pTex, int uPackedID, unsigned int uColor, int a8); |
2404 | 56 |
0 | 57 void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); |
58 void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); | |
2404 | 59 |
60 void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
717 | 61 void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level); |
2404 | 62 void _4A4CC9_AddSomeBillboard(struct stru6_stru1_indoor_sw_billboard *a1, int diffuse); |
63 void TransformBillboardsAndSetPalettesODM(); | |
64 void DrawBillboardList_BLV(); | |
65 | |
0 | 66 void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9); |
67 bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture); | |
670 | 68 bool MoveSpriteToDevice(Sprite *pSprite); |
2404 | 69 |
0 | 70 void BeginScene(); |
71 void EndScene(); | |
2155 | 72 void ScreenFade(unsigned int color, float t); |
2404 | 73 |
727 | 74 void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW); |
75 void ResetTextureClipRect(); | |
0 | 76 void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4); |
1675 | 77 void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture); |
1262 | 78 void DrawTextureIndexed(unsigned int uX, unsigned int uY, struct Texture *a4); |
2404 | 79 |
1262 | 80 void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5); |
81 void DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal); | |
82 void DrawTextureTransparent(unsigned int uX, unsigned int uY, struct Texture *pTexture); | |
1455 | 83 void DrawAura(unsigned int a2, unsigned int a3, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8); |
1262 | 84 void _4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8); |
2404 | 85 |
1262 | 86 void DrawTransparentRedShade(unsigned int a2, unsigned int a3, struct Texture *a4); |
87 void DrawTransparentGreenShade(signed int a2, signed int a3, struct Texture *pTexture); | |
2404 | 88 void DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices); |
89 | |
2069 | 90 void DrawMasked(signed int a2, signed int a3, struct Texture *pTexture, unsigned __int16 mask); |
1496 | 91 void GetLeather(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height); |
2404 | 92 |
1268 | 93 void DrawTextPalette(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8); |
0 | 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); |
2404 | 95 |
0 | 96 void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16); |
2069 | 97 void _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7); |
2155 | 98 void DrawTranslucent(unsigned int a2, unsigned int a3, struct Texture *a4); |
2404 | 99 |
1787 | 100 void DrawBuildingsD3D(); |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
101 //struct BSPModel *DrawBuildingsSW(); |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
102 //int OnOutdoorRedrawSW(); |
2404 | 103 |
104 void DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID); | |
1923 | 105 void DrawOutdoorSkyD3D(); |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
106 //int DrawSkySW(struct Span *a1, Polygon *a2, int a3); |
2404 | 107 void DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture); |
108 void DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture); | |
109 | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
110 void PrepareDecorationsRenderList_ODM(); |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
430
diff
changeset
|
111 void DrawSpriteObjects_ODM(); |
2404 | 112 |
113 //float DrawBezierTerrain(); | |
86 | 114 void RenderTerrainD3D(); |
2322 | 115 void DrawTerrainD3D(int a1, int edx0, int a3, int unk4); |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
116 //void DrawTerrainSW(int a1, int a2, int a3, int a4); |
2404 | 117 |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
118 //void ExecOutdoorDrawSW(); |
0 | 119 void ChangeBetweenWinFullscreenModes(); |
2154 | 120 bool AreRenderSurfacesOk(); |
121 bool IsGammaSupported(); | |
2404 | 122 |
2154 | 123 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); | |
2404 | 125 void SavePCXScreenshot(); |
126 | |
2182 | 127 int _46À6ÀÑ_GetActorsInViewport(int pDepth); |
2404 | 128 |
2155 | 129 void BeginLightmaps(); |
130 void EndLightmaps(); | |
131 void BeginLightmaps2(); | |
132 void EndLightmaps2(); | |
133 bool DrawLightmap(struct Lightmap *pLightmap, struct Vec3_float_ *pColorMult, float z_bias); | |
134 | |
135 void BeginDecals(); | |
136 void EndDecals(); | |
137 void DrawDecal(struct Decal *pDecal, float z_bias); | |
138 | |
139 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); | |
2404 | 141 |
2155 | 142 void DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture); |
0 | 143 |
2154 | 144 void am_Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3); |
145 void am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode); | |
2153 | 146 |
2402 | 147 public: |
148 int *pActiveZBuffer; | |
149 IDirectDraw4 *pDirectDraw4; | |
150 IDirectDrawSurface4 *pFrontBuffer4; | |
151 IDirectDrawSurface4 *pBackBuffer4; | |
152 void *pTargetSurface; | |
153 unsigned int uTargetSurfacePitch; | |
154 unsigned int bUseColoredLights; | |
155 unsigned int bTinting; | |
156 unsigned int bUsingSpecular; | |
157 uint32_t uFogColor; | |
158 unsigned int pHDWaterBitmapIDs[7]; | |
159 int hd_water_current_frame; | |
160 int hd_water_tile_id; | |
161 void (*pBeforePresentFunction)(); | |
162 uint32_t bFogEnabled; | |
163 RenderBillboardD3D pBillboardRenderListD3D[1000]; | |
164 unsigned int uNumBillboardsToDraw; | |
2155 | 165 |
2402 | 166 inline void WritePixel16(int x, int y, unsigned __int16 color) |
167 { | |
168 if (ddpfPrimarySuface.dwRGBBitCount == 32) | |
169 { | |
170 auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch; | |
171 *p = Color32(color); | |
172 } | |
173 else if (ddpfPrimarySuface.dwRGBBitCount == 16) | |
174 { | |
175 auto p = (unsigned __int16 *)pTargetSurface + x + y * uTargetSurfacePitch; | |
176 *p = color; | |
177 } | |
178 else __debugbreak(); | |
179 } | |
2155 | 180 |
2402 | 181 inline unsigned __int16 ReadPixel16(int x, int y) |
182 { | |
183 if (ddpfPrimarySuface.dwRGBBitCount == 32) | |
184 { | |
185 auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch; | |
186 return Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); | |
187 } | |
188 else if (ddpfPrimarySuface.dwRGBBitCount == 16) | |
189 { | |
190 auto p = (unsigned __int16 *)pTargetSurface + x + y * uTargetSurfacePitch; | |
191 return *p; | |
192 } | |
193 else __debugbreak(); | |
194 } | |
195 | |
196 inline void ToggleTint() {bTinting = !bTinting;} | |
197 inline void ToggleColoredLights() {bUseColoredLights = !bUseColoredLights;} | |
198 | |
199 inline unsigned int GetRenderWidth() {return window->GetWidth();} | |
200 inline unsigned int GetRenderHeight() {return window->GetHeight();} | |
201 | |
202 inline void Sub01() | |
203 { | |
204 if (pRenderD3D && !bWindowMode) | |
205 _49FD3A_fullscreen(); | |
206 } | |
207 | |
208 friend void Present_NoColorKey(); | |
2069 | 209 |
2153 | 210 protected: |
2402 | 211 unsigned int uDesiredDirect3DDevice; |
212 int raster_clip_x; | |
213 int raster_clip_y; // clipping rect for raster ops | |
214 int raster_clip_z; // like RasterLine2D for (mini)map | |
215 int raster_clip_w; | |
216 int *pDefaultZBuffer; | |
217 OSWindow *window; | |
218 unsigned int bWindowMode; | |
219 RenderD3D *pRenderD3D; | |
220 DDPIXELFORMAT ddpfPrimarySuface; | |
221 unsigned int uTargetRBits; | |
222 unsigned int uTargetGBits; | |
223 unsigned int uTargetBBits; | |
224 unsigned int uTargetRMask; | |
225 unsigned int uTargetGMask; | |
226 unsigned int uTargetBMask; | |
227 unsigned int uNumSceneBegins; | |
228 unsigned __int32 *pTargetSurface_unaligned; | |
229 unsigned int uClipY; | |
230 unsigned int uClipX; | |
231 unsigned int uClipW; | |
232 unsigned int uClipZ; | |
233 unsigned int bClip; | |
234 unsigned int uNumD3DSceneBegins; | |
235 int using_software_screen_buffer; | |
236 RenderHWLContainer pD3DBitmaps; | |
237 RenderHWLContainer pD3DSprites; | |
238 unsigned int bRequiredTextureStagesAvailable; | |
239 unsigned int uLevelOfDetail; | |
240 unsigned int uMaxDeviceTextureDim; | |
241 unsigned int uMinDeviceTextureDim; | |
242 | |
2154 | 243 void DoRenderBillboards_D3D(); |
244 void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); | |
2404 | 245 void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard); |
246 unsigned int Billboard_ProbablyAddToListAndSortByZOrder(float z); | |
247 unsigned int GetParentBillboardID(unsigned int uBillboardID); | |
248 unsigned int GetBillboardDrawListSize(); | |
249 | |
2154 | 250 void DrawBorderTiles(struct Polygon *poly); |
2404 | 251 |
2154 | 252 unsigned short *MakeScreenshot(signed int width, signed int height); |
253 bool CheckTextureStages(); | |
2155 | 254 void ParseTargetPixelFormat(); |
2404 | 255 |
2155 | 256 void CreateDirectDraw(); |
257 void SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen); | |
258 void SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP); | |
259 void CreateFrontBuffer(); | |
260 void CreateBackBuffer(); | |
261 void CreateDirectDrawPrimarySurface(); | |
262 void CreateClipper(HWND a2); | |
2404 | 263 |
2155 | 264 void PackPCXpicture(unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size); |
265 void SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height); | |
2153 | 266 |
1802 | 267 //int windowed_mode_width; |
268 //int windowed_mode_height; | |
0 | 269 }; |