diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 55ea7b871..2338c998f 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -110,23 +110,22 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, double x, double y, int tag { va_list tags; va_start(tags, tags_first); - DrawTextureV(img, x, y, tags_first, tags); + DrawParms parms; + + if (!ParseDrawTextureTags(img, x, y, tags_first, tags, &parms, false)) + { + return; + } + DrawTextureParms(img, x, y, parms); } -void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) +void DCanvas::DrawTextureParms(FTexture *img, double x, double y, DrawParms &parms) { #ifndef NO_SWRENDER FTexture::Span unmaskedSpan[2]; const FTexture::Span **spanptr, *spans; static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; - DrawParms parms; - - if (!ParseDrawTextureTags(img, x, y, tag, tags, &parms, false)) - { - return; - } - if (parms.masked) { spanptr = &spans; @@ -171,6 +170,10 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32 BYTE *destorgsave = dc_destorg; dc_destorg = screen->GetBuffer(); + if (dc_destorg == NULL) + { + I_FatalError("Attempt to write to buffer of hardware canvas"); + } double x0 = parms.x - parms.left * parms.destwidth / parms.texwidth; double y0 = parms.y - parms.top * parms.destheight / parms.texheight; @@ -327,7 +330,7 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32 #endif } -bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag, va_list tags, DrawParms *parms, bool hw) const +bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag, va_list tags, DrawParms *parms, bool fortext) const { INTBOOL boolval; int intval; diff --git a/src/v_video.h b/src/v_video.h index 533adb52e..dbb4f5589 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -138,6 +138,40 @@ struct FRemapTable; class player_t; typedef uint32 angle_t; +struct DrawParms +{ + double x, y; + double texwidth; + double texheight; + double destwidth; + double destheight; + double virtWidth; + double virtHeight; + double windowleft; + double windowright; + int dclip; + int uclip; + int lclip; + int rclip; + double top; + double left; + float Alpha; + uint32 fillcolor; + FRemapTable *remap; + const BYTE *translation; + uint32 colorOverlay; + INTBOOL alphaChannel; + INTBOOL flipX; + fixed_t shadowAlpha; + int shadowColor; + INTBOOL keepratio; + INTBOOL masked; + INTBOOL bilinear; + FRenderStyle style; + struct FSpecialColormap *specialcolormap; + struct FColormapStyle *colormapstyle; +}; + // // VIDEO // @@ -223,40 +257,6 @@ public: void DrawTextV (FFont *font, int normalcolor, int x, int y, const char *string, va_list tags); void STACK_ARGS DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, ...); - struct DrawParms - { - double x, y; - double texwidth; - double texheight; - double destwidth; - double destheight; - double virtWidth; - double virtHeight; - double windowleft; - double windowright; - int dclip; - int uclip; - int lclip; - int rclip; - double top; - double left; - float Alpha; - uint32 fillcolor; - FRemapTable *remap; - const BYTE *translation; - uint32 colorOverlay; - INTBOOL alphaChannel; - INTBOOL flipX; - fixed_t shadowAlpha; - int shadowColor; - INTBOOL keepratio; - INTBOOL masked; - INTBOOL bilinear; - FRenderStyle style; - struct FSpecialColormap *specialcolormap; - struct FColormapStyle *colormapstyle; - }; - protected: BYTE *Buffer; int Width; @@ -265,8 +265,9 @@ protected: int LockCount; bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const; - virtual void STACK_ARGS DrawTextureV (FTexture *img, double x, double y, uint32 tag, va_list tags); - bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool hw) const; + void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete; + virtual void DrawTextureParms(FTexture *img, double x, double y, DrawParms &parms); + bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool fortext) const; DCanvas() {} diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 7ec394d52..c0a0dca57 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -2762,17 +2762,14 @@ void D3DFB::DrawPixel(int x, int y, int palcolor, uint32 color) // //========================================================================== -void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, double x, double y, uint32 tags_first, va_list tags) +void D3DFB::DrawTextureParms (FTexture *img, double x, double y, DrawParms &parms) { if (In2D < 2) { - Super::DrawTextureV(img, x, y, tags_first, tags); + Super::DrawTextureParms(img, x, y, parms); return; } - - DrawParms parms; - - if (!InScene || !ParseDrawTextureTags(img, x, y, tags_first, tags, &parms, true)) + if (!InScene) { return; } diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index f8fcd1fba..ac2ad33a6 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -257,7 +257,7 @@ public: void DrawBlendingRect (); FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping); FNativePalette *CreatePalette (FRemapTable *remap); - void STACK_ARGS DrawTextureV (FTexture *img, double x, double y, uint32 tag, va_list tags); + void DrawTextureParms (FTexture *img, double x, double y, DrawParms &parms); void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color); void Dim (PalEntry color, float amount, int x1, int y1, int w, int h); void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin); @@ -370,7 +370,7 @@ private: void DrawPackedTextures(int packnum); void DrawLetterbox(); void Draw3DPart(bool copy3d); - bool SetStyle(D3DTex *tex, DCanvas::DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1, BufferedTris &quad); + bool SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1, BufferedTris &quad); static D3DBLEND GetStyleAlpha(int type); static void SetColorOverlay(DWORD color, float alpha, D3DCOLOR &color0, D3DCOLOR &color1); void DoWindowedGamma();