2016-03-01 15:47:10 +00:00
|
|
|
/*
|
|
|
|
** v_video.h
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 1998-2008 Randy Heit
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __V_VIDEO_H__
|
|
|
|
#define __V_VIDEO_H__
|
|
|
|
|
2018-10-21 06:14:48 +00:00
|
|
|
#include <functional>
|
2016-03-01 15:47:10 +00:00
|
|
|
#include "doomtype.h"
|
2016-03-10 21:36:28 +00:00
|
|
|
#include "vectors.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "dobject.h"
|
|
|
|
#include "r_data/renderstyle.h"
|
|
|
|
#include "c_cvars.h"
|
2018-03-28 14:40:09 +00:00
|
|
|
#include "v_colortables.h"
|
|
|
|
#include "v_2ddrawer.h"
|
2018-10-28 22:32:13 +00:00
|
|
|
#include "hwrenderer/dynlights/hw_shadowmap.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-05-05 09:20:37 +00:00
|
|
|
struct sector_t;
|
2018-06-13 20:08:55 +00:00
|
|
|
class IShaderProgram;
|
2018-08-28 13:11:35 +00:00
|
|
|
class FTexture;
|
2018-10-24 22:49:39 +00:00
|
|
|
struct FPortalSceneState;
|
2018-10-27 19:31:27 +00:00
|
|
|
class FSkyVertexBuffer;
|
2018-10-27 08:26:51 +00:00
|
|
|
class IIndexBuffer;
|
|
|
|
class IVertexBuffer;
|
2018-10-28 10:54:26 +00:00
|
|
|
class IDataBuffer;
|
2018-10-28 12:56:24 +00:00
|
|
|
class FFlatVertexBuffer;
|
|
|
|
class GLViewpointBuffer;
|
2018-10-28 14:22:48 +00:00
|
|
|
class FLightBuffer;
|
2018-10-28 18:39:31 +00:00
|
|
|
struct HWDrawInfo;
|
2018-05-05 09:20:37 +00:00
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
enum EHWCaps
|
|
|
|
{
|
|
|
|
// [BB] Added texture compression flags.
|
|
|
|
RFL_TEXTURE_COMPRESSION = 1,
|
|
|
|
RFL_TEXTURE_COMPRESSION_S3TC = 2,
|
|
|
|
|
|
|
|
RFL_SHADER_STORAGE_BUFFER = 4,
|
|
|
|
RFL_BUFFER_STORAGE = 8,
|
|
|
|
|
|
|
|
RFL_NO_CLIP_PLANES = 32,
|
|
|
|
|
|
|
|
RFL_INVALIDATE_BUFFER = 64,
|
|
|
|
RFL_DEBUG = 128,
|
|
|
|
};
|
|
|
|
|
2018-10-21 06:14:48 +00:00
|
|
|
|
2018-05-12 15:23:56 +00:00
|
|
|
struct IntRect
|
|
|
|
{
|
|
|
|
int left, top;
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
|
|
|
|
void Offset(int xofs, int yofs)
|
|
|
|
{
|
|
|
|
left += xofs;
|
|
|
|
top += yofs;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
extern int CleanWidth, CleanHeight, CleanXfac, CleanYfac;
|
|
|
|
extern int CleanWidth_1, CleanHeight_1, CleanXfac_1, CleanYfac_1;
|
2018-06-17 14:19:14 +00:00
|
|
|
extern int DisplayWidth, DisplayHeight;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-12 11:04:36 +00:00
|
|
|
void V_UpdateModeSize (int width, int height);
|
|
|
|
void V_OutputResized (int width, int height);
|
2016-03-01 15:47:10 +00:00
|
|
|
void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *cx1=NULL, int *cx2=NULL);
|
|
|
|
|
2018-04-07 21:30:28 +00:00
|
|
|
EXTERN_CVAR(Int, vid_rendermode)
|
2018-07-28 08:05:16 +00:00
|
|
|
EXTERN_CVAR(Bool, fullscreen)
|
|
|
|
EXTERN_CVAR(Int, win_x)
|
|
|
|
EXTERN_CVAR(Int, win_y)
|
|
|
|
EXTERN_CVAR(Int, win_w)
|
|
|
|
EXTERN_CVAR(Int, win_h)
|
2018-07-28 08:27:41 +00:00
|
|
|
EXTERN_CVAR(Bool, win_maximized)
|
2018-07-28 08:05:16 +00:00
|
|
|
|
2018-04-07 21:30:28 +00:00
|
|
|
|
|
|
|
inline bool V_IsHardwareRenderer()
|
|
|
|
{
|
|
|
|
return vid_rendermode == 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool V_IsSoftwareRenderer()
|
|
|
|
{
|
|
|
|
return vid_rendermode < 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool V_IsPolyRenderer()
|
|
|
|
{
|
|
|
|
return vid_rendermode == 2 || vid_rendermode == 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool V_IsTrueColor()
|
|
|
|
{
|
2018-05-05 09:20:37 +00:00
|
|
|
return vid_rendermode == 1 || vid_rendermode == 3 || vid_rendermode == 4;
|
2018-04-07 21:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
class FTexture;
|
2017-03-15 15:47:42 +00:00
|
|
|
struct FColormap;
|
2018-04-03 22:21:25 +00:00
|
|
|
class FileWriter;
|
2018-03-24 07:40:24 +00:00
|
|
|
enum FTextureFormat : uint32_t;
|
2018-04-24 22:07:46 +00:00
|
|
|
class FModelRenderer;
|
2018-06-13 13:53:56 +00:00
|
|
|
struct SamplerUniform;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// TagItem definitions for DrawTexture. As far as I know, tag lists
|
|
|
|
// originated on the Amiga.
|
|
|
|
//
|
|
|
|
// Think of TagItems as an array of the following structure:
|
|
|
|
//
|
|
|
|
// struct TagItem {
|
2017-03-09 19:19:55 +00:00
|
|
|
// uint32_t ti_Tag;
|
|
|
|
// uint32_t ti_Data;
|
2016-03-01 15:47:10 +00:00
|
|
|
// };
|
|
|
|
|
|
|
|
#define TAG_DONE (0) /* Used to indicate the end of the Tag list */
|
|
|
|
#define TAG_END (0) /* Ditto */
|
|
|
|
/* list pointed to in ti_Data */
|
|
|
|
|
2017-03-09 19:19:55 +00:00
|
|
|
#define TAG_USER ((uint32_t)(1u<<30))
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
DTA_Base = TAG_USER + 5000,
|
|
|
|
DTA_DestWidth, // width of area to draw to
|
|
|
|
DTA_DestHeight, // height of area to draw to
|
|
|
|
DTA_Alpha, // alpha value for translucency
|
2018-03-29 21:21:25 +00:00
|
|
|
DTA_FillColor, // color to stencil onto the destination
|
2017-02-04 23:17:29 +00:00
|
|
|
DTA_TranslationIndex, // translation table to recolor the source
|
2016-03-01 15:47:10 +00:00
|
|
|
DTA_AlphaChannel, // bool: the source is an alpha channel; used with DTA_FillColor
|
|
|
|
DTA_Clean, // bool: scale texture size and position by CleanXfac and CleanYfac
|
|
|
|
DTA_320x200, // bool: scale texture size and position to fit on a virtual 320x200 screen
|
|
|
|
DTA_Bottom320x200, // bool: same as DTA_320x200 but centers virtual screen on bottom for 1280x1024 targets
|
|
|
|
DTA_CleanNoMove, // bool: like DTA_Clean but does not reposition output position
|
|
|
|
DTA_CleanNoMove_1, // bool: like DTA_CleanNoMove, but uses Clean[XY]fac_1 instead
|
|
|
|
DTA_FlipX, // bool: flip image horizontally //FIXME: Does not work with DTA_Window(Left|Right)
|
|
|
|
DTA_ShadowColor, // color of shadow
|
|
|
|
DTA_ShadowAlpha, // alpha of shadow
|
|
|
|
DTA_Shadow, // set shadow color and alphas to defaults
|
|
|
|
DTA_VirtualWidth, // pretend the canvas is this wide
|
|
|
|
DTA_VirtualHeight, // pretend the canvas is this tall
|
|
|
|
DTA_TopOffset, // override texture's top offset
|
|
|
|
DTA_LeftOffset, // override texture's left offset
|
|
|
|
DTA_CenterOffset, // bool: override texture's left and top offsets and set them for the texture's middle
|
|
|
|
DTA_CenterBottomOffset,// bool: override texture's left and top offsets and set them for the texture's bottom middle
|
|
|
|
DTA_WindowLeft, // don't draw anything left of this column (on source, not dest)
|
|
|
|
DTA_WindowRight, // don't draw anything at or to the right of this column (on source, not dest)
|
|
|
|
DTA_ClipTop, // don't draw anything above this row (on dest, not source)
|
|
|
|
DTA_ClipBottom, // don't draw anything at or below this row (on dest, not source)
|
|
|
|
DTA_ClipLeft, // don't draw anything to the left of this column (on dest, not source)
|
|
|
|
DTA_ClipRight, // don't draw anything at or to the right of this column (on dest, not source)
|
|
|
|
DTA_Masked, // true(default)=use masks from texture, false=ignore masks
|
|
|
|
DTA_HUDRules, // use fullscreen HUD rules to position and size textures
|
2016-04-09 18:47:54 +00:00
|
|
|
DTA_HUDRulesC, // only used internally for marking HUD_HorizCenter
|
2016-03-01 15:47:10 +00:00
|
|
|
DTA_KeepRatio, // doesn't adjust screen size for DTA_Virtual* if the aspect ratio is not 4:3
|
|
|
|
DTA_RenderStyle, // same as render style for actors
|
2017-03-09 19:19:55 +00:00
|
|
|
DTA_ColorOverlay, // uint32_t: ARGB to overlay on top of image; limited to black for software
|
2016-03-01 15:47:10 +00:00
|
|
|
DTA_BilinearFilter, // bool: apply bilinear filtering to the image
|
2018-03-29 14:21:21 +00:00
|
|
|
DTA_SpecialColormap,// pointer to FSpecialColormapParameters
|
|
|
|
DTA_Desaturate, // explicit desaturation factor (does not do anything in Legacy OpenGL)
|
2016-03-01 15:47:10 +00:00
|
|
|
DTA_Fullscreen, // Draw image fullscreen (same as DTA_VirtualWidth/Height with graphics size.)
|
|
|
|
|
|
|
|
// floating point duplicates of some of the above:
|
|
|
|
DTA_DestWidthF,
|
|
|
|
DTA_DestHeightF,
|
|
|
|
DTA_TopOffsetF,
|
|
|
|
DTA_LeftOffsetF,
|
|
|
|
DTA_VirtualWidthF,
|
|
|
|
DTA_VirtualHeightF,
|
|
|
|
DTA_WindowLeftF,
|
|
|
|
DTA_WindowRightF,
|
|
|
|
|
|
|
|
// For DrawText calls:
|
|
|
|
DTA_TextLen, // stop after this many characters, even if \0 not hit
|
|
|
|
DTA_CellX, // horizontal size of character cell
|
|
|
|
DTA_CellY, // vertical size of character cell
|
2017-03-29 19:22:05 +00:00
|
|
|
|
|
|
|
// New additions.
|
|
|
|
DTA_Color,
|
2018-03-28 14:40:09 +00:00
|
|
|
DTA_FlipY, // bool: flip image vertically
|
|
|
|
DTA_SrcX, // specify a source rectangle (this supersedes the poorly implemented DTA_WindowLeft/Right
|
|
|
|
DTA_SrcY,
|
|
|
|
DTA_SrcWidth,
|
2018-07-14 20:58:24 +00:00
|
|
|
DTA_SrcHeight,
|
|
|
|
DTA_LegacyRenderStyle, // takes an old-style STYLE_* constant instead of an FRenderStyle
|
2018-08-28 13:11:35 +00:00
|
|
|
DTA_Burn, // activates the burn shader for this element
|
2018-03-28 14:40:09 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
HUD_Normal,
|
|
|
|
HUD_HorizCenter
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FFont;
|
|
|
|
struct FRemapTable;
|
|
|
|
class player_t;
|
2017-03-09 18:31:45 +00:00
|
|
|
typedef uint32_t angle_t;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-04-09 10:55:12 +00:00
|
|
|
struct DrawParms
|
|
|
|
{
|
|
|
|
double x, y;
|
|
|
|
double texwidth;
|
|
|
|
double texheight;
|
|
|
|
double destwidth;
|
|
|
|
double destheight;
|
|
|
|
double virtWidth;
|
|
|
|
double virtHeight;
|
|
|
|
double windowleft;
|
|
|
|
double windowright;
|
2016-04-09 18:47:54 +00:00
|
|
|
int cleanmode;
|
2016-04-09 10:55:12 +00:00
|
|
|
int dclip;
|
|
|
|
int uclip;
|
|
|
|
int lclip;
|
|
|
|
int rclip;
|
|
|
|
double top;
|
|
|
|
double left;
|
|
|
|
float Alpha;
|
2018-03-28 14:40:09 +00:00
|
|
|
PalEntry fillcolor;
|
2016-04-09 10:55:12 +00:00
|
|
|
FRemapTable *remap;
|
2018-03-28 14:40:09 +00:00
|
|
|
PalEntry colorOverlay;
|
2017-03-29 19:22:05 +00:00
|
|
|
PalEntry color;
|
2016-04-09 10:55:12 +00:00
|
|
|
INTBOOL alphaChannel;
|
|
|
|
INTBOOL flipX;
|
2018-03-28 14:40:09 +00:00
|
|
|
INTBOOL flipY;
|
2017-02-25 18:10:49 +00:00
|
|
|
//float shadowAlpha;
|
2016-04-09 10:55:12 +00:00
|
|
|
int shadowColor;
|
|
|
|
INTBOOL keepratio;
|
|
|
|
INTBOOL masked;
|
|
|
|
INTBOOL bilinear;
|
|
|
|
FRenderStyle style;
|
|
|
|
struct FSpecialColormap *specialcolormap;
|
2018-03-29 14:21:21 +00:00
|
|
|
int desaturate;
|
2016-04-09 18:47:54 +00:00
|
|
|
int scalex, scaley;
|
|
|
|
int cellx, celly;
|
|
|
|
int maxstrlen;
|
|
|
|
bool fortext;
|
|
|
|
bool virtBottom;
|
2018-03-28 14:40:09 +00:00
|
|
|
double srcx, srcy;
|
|
|
|
double srcwidth, srcheight;
|
2018-08-28 13:11:35 +00:00
|
|
|
bool burn;
|
2016-04-09 10:55:12 +00:00
|
|
|
};
|
|
|
|
|
2017-02-05 20:54:09 +00:00
|
|
|
struct Va_List
|
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
};
|
|
|
|
|
2017-02-04 21:09:49 +00:00
|
|
|
struct VMVa_List
|
|
|
|
{
|
|
|
|
VMValue *args;
|
|
|
|
int curindex;
|
|
|
|
int numargs;
|
|
|
|
};
|
2016-03-01 15:47:10 +00:00
|
|
|
//
|
|
|
|
// VIDEO
|
|
|
|
//
|
|
|
|
// [RH] Made screens more implementation-independant:
|
|
|
|
//
|
2017-04-14 08:48:18 +00:00
|
|
|
class DCanvas
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-05-31 07:36:18 +00:00
|
|
|
DCanvas (int width, int height, bool bgra);
|
2016-03-01 15:47:10 +00:00
|
|
|
virtual ~DCanvas ();
|
|
|
|
|
|
|
|
// Member variable access
|
2018-03-27 11:50:31 +00:00
|
|
|
inline uint8_t *GetPixels () const { return PixelBuffer; }
|
2016-03-01 15:47:10 +00:00
|
|
|
inline int GetWidth () const { return Width; }
|
|
|
|
inline int GetHeight () const { return Height; }
|
|
|
|
inline int GetPitch () const { return Pitch; }
|
2016-05-31 07:36:18 +00:00
|
|
|
inline bool IsBgra() const { return Bgra; }
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-04-07 17:56:54 +00:00
|
|
|
// Note: pitch here is in pixels, not bytes.
|
2018-03-27 18:02:44 +00:00
|
|
|
bool SetBuffer(int width, int height, int pitch, uint8_t *buffer)
|
|
|
|
{
|
2018-04-05 21:08:09 +00:00
|
|
|
assert(buffer);
|
|
|
|
Width = width;
|
|
|
|
Height = height;
|
|
|
|
Pitch = pitch;
|
|
|
|
PixelBuffer = buffer;
|
|
|
|
return true;
|
2018-03-27 18:02:44 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
protected:
|
2018-03-27 11:50:31 +00:00
|
|
|
uint8_t *PixelBuffer;
|
2016-03-01 15:47:10 +00:00
|
|
|
int Width;
|
|
|
|
int Height;
|
|
|
|
int Pitch;
|
2016-05-31 07:36:18 +00:00
|
|
|
bool Bgra;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A canvas in system memory.
|
|
|
|
|
|
|
|
class DSimpleCanvas : public DCanvas
|
|
|
|
{
|
2017-04-14 08:48:18 +00:00
|
|
|
typedef DCanvas Super;
|
2016-03-01 15:47:10 +00:00
|
|
|
public:
|
2016-05-31 07:36:18 +00:00
|
|
|
DSimpleCanvas (int width, int height, bool bgra);
|
2016-03-01 15:47:10 +00:00
|
|
|
~DSimpleCanvas ();
|
2016-09-12 11:04:36 +00:00
|
|
|
void Resize(int width, int height);
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-31 22:59:49 +00:00
|
|
|
class FUniquePalette;
|
2018-04-24 21:06:34 +00:00
|
|
|
class IHardwareTexture;
|
2018-04-24 18:41:52 +00:00
|
|
|
class FTexture;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// A canvas that represents the actual display. The video code is responsible
|
|
|
|
// for actually implementing this. Built on top of SimpleCanvas, because it
|
|
|
|
// needs a system memory buffer when buffered output is enabled.
|
|
|
|
|
2018-03-27 12:14:46 +00:00
|
|
|
class DFrameBuffer
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2017-04-14 08:48:18 +00:00
|
|
|
typedef DSimpleCanvas Super;
|
2018-03-26 21:16:27 +00:00
|
|
|
protected:
|
2018-03-28 19:38:00 +00:00
|
|
|
|
2018-03-26 21:16:27 +00:00
|
|
|
void DrawTextureV(FTexture *img, double x, double y, uint32_t tag, va_list tags) = delete;
|
2018-03-28 14:40:09 +00:00
|
|
|
void DrawTextureParms(FTexture *img, DrawParms &parms);
|
2018-03-26 21:16:27 +00:00
|
|
|
|
|
|
|
template<class T>
|
|
|
|
bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext) const;
|
|
|
|
void DrawTextCommon(FFont *font, int normalcolor, double x, double y, const char *string, DrawParms &parms);
|
2018-04-29 11:45:53 +00:00
|
|
|
void BuildGammaTable(uint16_t *gt);
|
2018-03-26 21:16:27 +00:00
|
|
|
|
2018-03-28 19:38:00 +00:00
|
|
|
F2DDrawer m2DDrawer;
|
2018-06-17 14:19:14 +00:00
|
|
|
private:
|
2018-03-27 12:14:46 +00:00
|
|
|
int Width = 0;
|
|
|
|
int Height = 0;
|
2018-06-17 14:19:14 +00:00
|
|
|
protected:
|
2018-03-27 12:14:46 +00:00
|
|
|
int clipleft = 0, cliptop = 0, clipwidth = -1, clipheight = -1;
|
2018-03-26 21:16:27 +00:00
|
|
|
|
2018-05-16 20:10:24 +00:00
|
|
|
PalEntry Flash; // Only needed to support some cruft in the interface that only makes sense for the software renderer
|
|
|
|
PalEntry SourcePalette[256]; // This is where unpaletted textures get their palette from
|
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
public:
|
2018-10-28 12:18:13 +00:00
|
|
|
// Hardware render state that needs to be exposed to the API independent part of the renderer. For ease of access this is stored in the base class.
|
|
|
|
int hwcaps = 0; // Capability flags
|
|
|
|
float glslversion = 0; // This is here so that the differences between old OpenGL and new OpenGL/Vulkan can be handled by platform independent code.
|
|
|
|
int instack[2] = { 0,0 }; // this is globally maintained state for portal recursion avoidance.
|
|
|
|
int stencilValue = 0; // Global stencil test value
|
|
|
|
bool enable_quadbuffered = false; // Quad-buffered stereo available?
|
|
|
|
unsigned int uniformblockalignment = 256; // Hardware dependent uniform buffer alignment.
|
2018-10-28 14:04:57 +00:00
|
|
|
unsigned int maxuniformblock = 65536;
|
|
|
|
const char *gl_vendorstring; // On OpenGL (not Vulkan) we have to account for some issues with Intel.
|
2018-10-28 12:18:13 +00:00
|
|
|
FPortalSceneState *mPortalState; // global portal state.
|
2018-10-28 12:56:24 +00:00
|
|
|
FSkyVertexBuffer *mSkyData = nullptr; // the sky vertex buffer
|
|
|
|
FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data
|
|
|
|
GLViewpointBuffer *mViewpoints = nullptr; // Viewpoint render data.
|
2018-10-28 14:22:48 +00:00
|
|
|
FLightBuffer *mLights = nullptr; // Dynamic lights
|
2018-10-28 22:32:13 +00:00
|
|
|
IShadowMap mShadowMap;
|
2018-04-26 22:22:00 +00:00
|
|
|
|
2018-05-12 15:23:56 +00:00
|
|
|
IntRect mScreenViewport;
|
|
|
|
IntRect mSceneViewport;
|
|
|
|
IntRect mOutputLetterbox;
|
2018-10-29 08:34:30 +00:00
|
|
|
float mSceneClearColor[4];
|
|
|
|
|
2018-05-12 15:23:56 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
public:
|
2018-06-17 14:19:14 +00:00
|
|
|
DFrameBuffer (int width=1, int height=1);
|
2018-10-24 22:49:39 +00:00
|
|
|
virtual ~DFrameBuffer();
|
2018-10-20 10:55:25 +00:00
|
|
|
virtual void InitializeState() = 0; // For stuff that needs 'screen' set.
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-06-17 14:19:14 +00:00
|
|
|
void SetSize(int width, int height);
|
|
|
|
void SetVirtualSize(int width, int height)
|
|
|
|
{
|
|
|
|
Width = width;
|
|
|
|
Height = height;
|
|
|
|
}
|
2018-03-27 12:14:46 +00:00
|
|
|
inline int GetWidth() const { return Width; }
|
|
|
|
inline int GetHeight() const { return Height; }
|
|
|
|
|
2018-06-17 10:23:29 +00:00
|
|
|
FVector2 SceneScale() const
|
|
|
|
{
|
|
|
|
return { mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height };
|
|
|
|
}
|
|
|
|
|
|
|
|
FVector2 SceneOffset() const
|
|
|
|
{
|
|
|
|
return { mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height };
|
|
|
|
}
|
|
|
|
|
2018-04-08 08:52:10 +00:00
|
|
|
// Make the surface visible.
|
2018-10-28 12:56:24 +00:00
|
|
|
virtual void Update ();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Return a pointer to 256 palette entries that can be written to.
|
2018-05-16 20:10:24 +00:00
|
|
|
PalEntry *GetPalette ();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Stores the palette with flash blended in into 256 dwords
|
2018-05-16 20:10:24 +00:00
|
|
|
void GetFlashedPalette (PalEntry palette[256]);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Mark the palette as changed. It will be updated on the next Update().
|
2018-05-16 20:10:24 +00:00
|
|
|
virtual void UpdatePalette() {}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Sets the gamma level. Returns false if the hardware does not support
|
|
|
|
// gamma changing. (Always true for now, since palettes can always be
|
|
|
|
// gamma adjusted.)
|
2018-04-29 11:45:53 +00:00
|
|
|
virtual void SetGamma() {}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Sets a color flash. RGB is the color, and amount is 0-256, with 256
|
|
|
|
// being all flash and 0 being no flash. Returns false if the hardware
|
|
|
|
// does not support this. (Always true for now, since palettes can always
|
|
|
|
// be flashed.)
|
2018-05-16 20:10:24 +00:00
|
|
|
bool SetFlash (PalEntry rgb, int amount);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Converse of SetFlash
|
2018-05-16 20:10:24 +00:00
|
|
|
void GetFlash (PalEntry &rgb, int &amount);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Returns true if running fullscreen.
|
|
|
|
virtual bool IsFullscreen () = 0;
|
2018-06-17 20:09:25 +00:00
|
|
|
virtual void ToggleFullscreen(bool yes) {}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Changes the vsync setting, if supported by the device.
|
|
|
|
virtual void SetVSync (bool vsync);
|
|
|
|
|
2018-04-08 06:03:46 +00:00
|
|
|
// Delete any resources that need to be deleted after restarting with a different IWAD
|
|
|
|
virtual void CleanForRestart() {}
|
2018-04-08 10:11:51 +00:00
|
|
|
virtual void SetTextureFilterMode() {}
|
2018-04-24 21:06:34 +00:00
|
|
|
virtual IHardwareTexture *CreateHardwareTexture(FTexture *tex) { return nullptr; }
|
2018-07-14 11:05:49 +00:00
|
|
|
virtual void PrecacheMaterial(FMaterial *mat, int translation) {}
|
2018-04-24 22:07:46 +00:00
|
|
|
virtual FModelRenderer *CreateModelRenderer(int mli) { return nullptr; }
|
2018-04-24 21:06:34 +00:00
|
|
|
virtual void UnbindTexUnit(int no) {}
|
2018-04-25 19:02:50 +00:00
|
|
|
virtual void TextureFilterChanged() {}
|
2018-04-29 18:15:19 +00:00
|
|
|
virtual void BeginFrame() {}
|
2018-07-21 19:32:02 +00:00
|
|
|
virtual void SetWindowSize(int w, int h) {}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-05-12 15:23:56 +00:00
|
|
|
virtual int GetClientWidth() = 0;
|
|
|
|
virtual int GetClientHeight() = 0;
|
2018-05-17 22:22:57 +00:00
|
|
|
virtual void BlurScene(float amount) {}
|
2018-06-12 08:58:32 +00:00
|
|
|
|
|
|
|
// Interface to hardware rendering resources
|
2018-06-13 20:08:55 +00:00
|
|
|
virtual IShaderProgram *CreateShaderProgram() { return nullptr; }
|
2018-10-27 08:26:51 +00:00
|
|
|
virtual IVertexBuffer *CreateVertexBuffer() { return nullptr; }
|
|
|
|
virtual IIndexBuffer *CreateIndexBuffer() { return nullptr; }
|
2018-10-28 10:54:26 +00:00
|
|
|
virtual IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo) { return nullptr; }
|
2018-10-20 10:55:25 +00:00
|
|
|
bool BuffersArePersistent() { return !!(hwcaps & RFL_BUFFER_STORAGE); }
|
2018-05-12 15:23:56 +00:00
|
|
|
|
2018-08-28 10:58:57 +00:00
|
|
|
// Begin/End 2D drawing operations.
|
|
|
|
void Begin2D() { isIn2D = true; }
|
2017-04-01 10:59:58 +00:00
|
|
|
void End2D() { isIn2D = false; }
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-08-28 10:58:57 +00:00
|
|
|
void End2DAndUpdate()
|
|
|
|
{
|
|
|
|
DrawRateStuff();
|
|
|
|
End2D();
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-28 22:45:53 +00:00
|
|
|
// Returns true if Begin2D has been called and 2D drawing is now active
|
2017-04-01 10:59:58 +00:00
|
|
|
bool HasBegun2D() { return isIn2D; }
|
2017-03-28 22:45:53 +00:00
|
|
|
|
2018-08-28 20:58:21 +00:00
|
|
|
// This is overridable in case Vulkan does it differently.
|
|
|
|
virtual bool RenderTextureIsFlipped() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Report a game restart
|
2018-05-16 20:10:24 +00:00
|
|
|
void InitPalette();
|
2018-10-29 08:34:30 +00:00
|
|
|
void SetClearColor(int color);
|
2018-04-03 20:50:47 +00:00
|
|
|
virtual uint32_t GetCaps();
|
2018-04-03 22:21:25 +00:00
|
|
|
virtual void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
|
2018-04-05 21:08:09 +00:00
|
|
|
virtual void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
|
2018-05-05 09:20:37 +00:00
|
|
|
virtual sector_t *RenderView(player_t *player) { return nullptr; }
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Screen wiping
|
2018-08-28 13:11:35 +00:00
|
|
|
virtual FTexture *WipeStartScreen();
|
|
|
|
virtual FTexture *WipeEndScreen();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-08-04 12:58:55 +00:00
|
|
|
virtual void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) { if (afterBloomDrawEndScene2D) afterBloomDrawEndScene2D(); }
|
|
|
|
|
2018-05-16 20:10:24 +00:00
|
|
|
void ScaleCoordsFromWindow(int16_t &x, int16_t &y);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2017-11-16 01:33:08 +00:00
|
|
|
uint64_t GetLastFPS() const { return LastCount; }
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-03-26 21:16:27 +00:00
|
|
|
// 2D Texture drawing
|
|
|
|
void ClearClipRect() { clipleft = cliptop = 0; clipwidth = clipheight = -1; }
|
|
|
|
void SetClipRect(int x, int y, int w, int h);
|
|
|
|
void GetClipRect(int *x, int *y, int *w, int *h);
|
|
|
|
|
2018-03-28 14:40:09 +00:00
|
|
|
virtual void Draw2D() {}
|
|
|
|
void Clear2D() { m2DDrawer.Clear(); }
|
2018-03-26 21:16:27 +00:00
|
|
|
|
|
|
|
// Dim part of the canvas
|
2018-04-07 08:53:20 +00:00
|
|
|
void Dim(PalEntry color, float amount, int x1, int y1, int w, int h, FRenderStyle *style = nullptr);
|
|
|
|
void DoDim(PalEntry color, float amount, int x1, int y1, int w, int h, FRenderStyle *style = nullptr);
|
2018-05-05 09:20:37 +00:00
|
|
|
void DrawBlend(sector_t * viewsector);
|
2018-03-26 21:16:27 +00:00
|
|
|
|
|
|
|
// Fill an area with a texture
|
2018-03-28 14:40:09 +00:00
|
|
|
void FlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin = false);
|
2018-03-26 21:16:27 +00:00
|
|
|
|
|
|
|
// Fill a simple polygon with a texture
|
2018-03-28 14:40:09 +00:00
|
|
|
void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
|
2018-03-26 21:16:27 +00:00
|
|
|
double originx, double originy, double scalex, double scaley, DAngle rotation,
|
|
|
|
const FColormap &colormap, PalEntry flatcolor, int lightlevel, int bottomclip);
|
|
|
|
|
|
|
|
// Set an area to a specified color
|
2018-03-28 14:40:09 +00:00
|
|
|
void Clear(int left, int top, int right, int bottom, int palcolor, uint32_t color);
|
2018-03-26 21:16:27 +00:00
|
|
|
|
|
|
|
// Draws a line
|
2018-09-26 16:59:22 +00:00
|
|
|
void DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32_t realcolor, uint8_t alpha = 255);
|
2018-03-26 21:16:27 +00:00
|
|
|
|
2018-08-30 15:49:10 +00:00
|
|
|
// Draws a line with thickness
|
2018-09-26 16:59:22 +00:00
|
|
|
void DrawThickLine(int x0, int y0, int x1, int y1, double thickness, uint32_t realcolor, uint8_t alpha = 255);
|
2018-08-30 15:49:10 +00:00
|
|
|
|
2018-03-26 21:16:27 +00:00
|
|
|
// Draws a single pixel
|
2018-03-28 14:40:09 +00:00
|
|
|
void DrawPixel(int x, int y, int palcolor, uint32_t rgbcolor);
|
|
|
|
|
2018-03-26 21:16:27 +00:00
|
|
|
|
|
|
|
bool SetTextureParms(DrawParms *parms, FTexture *img, double x, double y) const;
|
|
|
|
void DrawTexture(FTexture *img, double x, double y, int tags, ...);
|
|
|
|
void DrawTexture(FTexture *img, double x, double y, VMVa_List &);
|
2018-06-07 18:58:31 +00:00
|
|
|
void DrawShape(FTexture *img, DShape2D *shape, int tags, ...);
|
|
|
|
void DrawShape(FTexture *img, DShape2D *shape, VMVa_List &);
|
2018-03-26 21:16:27 +00:00
|
|
|
void FillBorder(FTexture *img); // Fills the border around a 4:3 part of the screen on non-4:3 displays
|
|
|
|
void VirtualToRealCoords(double &x, double &y, double &w, double &h, double vwidth, double vheight, bool vbottom = false, bool handleaspect = true) const;
|
|
|
|
|
|
|
|
// Code that uses these (i.e. SBARINFO) should probably be evaluated for using doubles all around instead.
|
|
|
|
void VirtualToRealCoordsInt(int &x, int &y, int &w, int &h, int vwidth, int vheight, bool vbottom = false, bool handleaspect = true) const;
|
|
|
|
|
|
|
|
// Text drawing functions -----------------------------------------------
|
|
|
|
|
|
|
|
#ifdef DrawText
|
|
|
|
#undef DrawText // See WinUser.h for the definition of DrawText as a macro
|
|
|
|
#endif
|
|
|
|
// 2D Text drawing
|
|
|
|
void DrawText(FFont *font, int normalcolor, double x, double y, const char *string, int tag_first, ...);
|
|
|
|
void DrawText(FFont *font, int normalcolor, double x, double y, const char *string, VMVa_List &args);
|
|
|
|
void DrawChar(FFont *font, int normalcolor, double x, double y, int character, int tag_first, ...);
|
|
|
|
void DrawChar(FFont *font, int normalcolor, double x, double y, int character, VMVa_List &args);
|
|
|
|
|
|
|
|
void DrawFrame(int left, int top, int width, int height);
|
|
|
|
void DrawBorder(int x1, int y1, int x2, int y2);
|
|
|
|
void DrawViewBorder();
|
|
|
|
void RefreshViewBorder();
|
|
|
|
|
2018-03-27 08:34:21 +00:00
|
|
|
// Calculate gamma table
|
|
|
|
void CalcGamma(float gamma, uint8_t gammalookup[256]);
|
|
|
|
|
2018-06-03 11:59:40 +00:00
|
|
|
virtual void SetViewportRects(IntRect *bounds);
|
2018-05-12 15:23:56 +00:00
|
|
|
int ScreenToWindowX(int x);
|
|
|
|
int ScreenToWindowY(int y);
|
|
|
|
|
2018-03-27 08:34:21 +00:00
|
|
|
|
|
|
|
// Retrieves a buffer containing image data for a screenshot.
|
|
|
|
// Hint: Pitch can be negative for upside-down images, in which case buffer
|
|
|
|
// points to the last row in the buffer, which will be the first row output.
|
|
|
|
virtual void GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type, float &gamma) {}
|
|
|
|
|
2018-06-24 08:47:42 +00:00
|
|
|
static float GetZNear() { return 5.f; }
|
|
|
|
static float GetZFar() { return 65536.f; }
|
|
|
|
|
2016-09-14 21:38:11 +00:00
|
|
|
// The original size of the framebuffer as selected in the video menu.
|
2017-11-14 20:52:54 +00:00
|
|
|
uint64_t FrameTime = 0;
|
2016-09-14 21:38:11 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
protected:
|
|
|
|
void DrawRateStuff ();
|
|
|
|
|
|
|
|
private:
|
2018-06-17 14:19:14 +00:00
|
|
|
|
|
|
|
uint64_t LastMS = 0, LastSec = 0, FrameCount = 0, LastCount = 0, LastTic = 0;
|
|
|
|
|
2017-04-01 10:59:58 +00:00
|
|
|
bool isIn2D = false;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// This is the screen updated by I_FinishUpdate.
|
|
|
|
extern DFrameBuffer *screen;
|
|
|
|
|
|
|
|
#define SCREENWIDTH (screen->GetWidth ())
|
|
|
|
#define SCREENHEIGHT (screen->GetHeight ())
|
|
|
|
#define SCREENPITCH (screen->GetPitch ())
|
|
|
|
|
|
|
|
EXTERN_CVAR (Float, Gamma)
|
|
|
|
|
|
|
|
|
|
|
|
// Allocates buffer screens, call before R_Init.
|
|
|
|
void V_Init (bool restart);
|
|
|
|
|
|
|
|
// Initializes graphics mode for the first time.
|
|
|
|
void V_Init2 ();
|
|
|
|
|
|
|
|
void V_Shutdown ();
|
|
|
|
|
2016-12-03 15:27:53 +00:00
|
|
|
class FScanner;
|
2017-04-12 23:12:04 +00:00
|
|
|
struct FScriptPosition;
|
2016-03-01 15:47:10 +00:00
|
|
|
// Returns the closest color to the one desired. String
|
|
|
|
// should be of the form "rr gg bb".
|
2017-03-09 19:19:55 +00:00
|
|
|
int V_GetColorFromString (const uint32_t *palette, const char *colorstring, FScriptPosition *sc = nullptr);
|
2016-03-01 15:47:10 +00:00
|
|
|
// Scans through the X11R6RGB lump for a matching color
|
|
|
|
// and returns a color string suitable for V_GetColorFromString.
|
2016-12-03 15:27:53 +00:00
|
|
|
FString V_GetColorStringByName (const char *name, FScriptPosition *sc = nullptr);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Tries to get color by name, then by string
|
2017-03-09 19:19:55 +00:00
|
|
|
int V_GetColor (const uint32_t *palette, const char *str, FScriptPosition *sc = nullptr);
|
|
|
|
int V_GetColor(const uint32_t *palette, FScanner &sc);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
int CheckRatio (int width, int height, int *trueratio=NULL);
|
|
|
|
static inline int CheckRatio (double width, double height) { return CheckRatio(int(width), int(height)); }
|
2016-09-12 13:51:50 +00:00
|
|
|
inline bool IsRatioWidescreen(int ratio) { return (ratio & 3) != 0; }
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-12 11:59:01 +00:00
|
|
|
float ActiveRatio (int width, int height, float *trueratio = NULL);
|
|
|
|
static inline double ActiveRatio (double width, double height) { return ActiveRatio(int(width), int(height)); }
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-12 12:37:10 +00:00
|
|
|
int AspectBaseWidth(float aspect);
|
|
|
|
int AspectBaseHeight(float aspect);
|
2016-09-13 09:46:05 +00:00
|
|
|
double AspectPspriteOffset(float aspect);
|
2016-09-12 12:37:10 +00:00
|
|
|
int AspectMultiplier(float aspect);
|
2016-09-13 21:26:30 +00:00
|
|
|
bool AspectTallerThanWide(float aspect);
|
2017-05-13 21:39:54 +00:00
|
|
|
void ScaleWithAspect(int &w, int &h, int Width, int Height);
|
|
|
|
|
2017-03-30 00:16:23 +00:00
|
|
|
int GetUIScale(int altval);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-06 17:48:14 +00:00
|
|
|
EXTERN_CVAR(Int, uiscale);
|
2017-03-30 00:16:23 +00:00
|
|
|
EXTERN_CVAR(Int, con_scaletext);
|
|
|
|
EXTERN_CVAR(Int, con_scale);
|
|
|
|
|
|
|
|
inline int active_con_scaletext()
|
|
|
|
{
|
|
|
|
return GetUIScale(con_scaletext);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int active_con_scale()
|
|
|
|
{
|
|
|
|
return GetUIScale(con_scale);
|
|
|
|
}
|
|
|
|
|
2016-09-06 17:48:14 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
#endif // __V_VIDEO_H__
|