2013-06-23 07:49:34 +00:00
|
|
|
#ifndef __GL_RENDERER_H
|
|
|
|
#define __GL_RENDERER_H
|
|
|
|
|
|
|
|
#include "r_defs.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "vectors.h"
|
|
|
|
#include "r_renderer.h"
|
2017-11-25 12:51:09 +00:00
|
|
|
#include "r_data/matrix.h"
|
2017-03-01 03:05:54 +00:00
|
|
|
#include "gl/dynlights/gl_shadowmap.h"
|
2018-01-06 04:11:12 +00:00
|
|
|
#include <functional>
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2018-04-25 19:02:50 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(disable:4244)
|
|
|
|
#endif
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
struct particle_t;
|
|
|
|
class FCanvasTexture;
|
|
|
|
class FFlatVertexBuffer;
|
2014-06-13 23:24:28 +00:00
|
|
|
class FSkyVertexBuffer;
|
2013-06-23 07:49:34 +00:00
|
|
|
class OpenGLFrameBuffer;
|
|
|
|
struct FDrawInfo;
|
|
|
|
class FShaderManager;
|
|
|
|
class GLPortal;
|
2014-08-01 18:59:39 +00:00
|
|
|
class FLightBuffer;
|
2014-08-22 21:50:38 +00:00
|
|
|
class FSamplerManager;
|
2016-06-17 15:21:42 +00:00
|
|
|
class DPSprite;
|
2016-07-26 19:27:02 +00:00
|
|
|
class FGLRenderBuffers;
|
2016-08-29 11:10:22 +00:00
|
|
|
class FLinearDepthShader;
|
2016-09-02 03:45:00 +00:00
|
|
|
class FDepthBlurShader;
|
2016-08-29 11:10:22 +00:00
|
|
|
class FSSAOShader;
|
2016-09-02 03:45:00 +00:00
|
|
|
class FSSAOCombineShader;
|
2016-07-27 19:50:30 +00:00
|
|
|
class FBloomExtractShader;
|
|
|
|
class FBloomCombineShader;
|
2016-09-18 13:57:22 +00:00
|
|
|
class FExposureExtractShader;
|
|
|
|
class FExposureAverageShader;
|
|
|
|
class FExposureCombineShader;
|
2016-07-27 19:50:30 +00:00
|
|
|
class FBlurShader;
|
2016-07-28 22:36:43 +00:00
|
|
|
class FTonemapShader;
|
2016-09-01 15:14:51 +00:00
|
|
|
class FColormapShader;
|
2016-08-02 15:32:21 +00:00
|
|
|
class FLensShader;
|
2016-09-25 09:25:01 +00:00
|
|
|
class FFXAALumaShader;
|
|
|
|
class FFXAAShader;
|
2016-07-26 19:27:02 +00:00
|
|
|
class FPresentShader;
|
2016-10-09 17:05:50 +00:00
|
|
|
class FPresent3DCheckerShader;
|
|
|
|
class FPresent3DColumnShader;
|
2016-10-02 16:24:37 +00:00
|
|
|
class FPresent3DRowShader;
|
2018-03-27 19:44:58 +00:00
|
|
|
class FGL2DDrawer;
|
2016-08-23 07:18:18 +00:00
|
|
|
class FHardwareTexture;
|
2017-03-01 02:33:53 +00:00
|
|
|
class FShadowMapShader;
|
2017-07-06 03:36:01 +00:00
|
|
|
class FCustomPostProcessShaders;
|
2018-01-06 04:11:12 +00:00
|
|
|
class GLSceneDrawer;
|
2018-04-05 21:08:09 +00:00
|
|
|
class SWSceneDrawer;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-03-21 01:57:02 +00:00
|
|
|
inline float DEG2RAD(float deg)
|
|
|
|
{
|
|
|
|
return deg * float(M_PI / 180.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float RAD2DEG(float deg)
|
|
|
|
{
|
|
|
|
return deg * float(180. / M_PI);
|
|
|
|
}
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
struct GL_IRECT
|
|
|
|
{
|
|
|
|
int left,top;
|
|
|
|
int width,height;
|
|
|
|
|
|
|
|
|
|
|
|
void Offset(int xofs,int yofs)
|
|
|
|
{
|
|
|
|
left+=xofs;
|
|
|
|
top+=yofs;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-18 10:14:20 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
DM_MAINVIEW,
|
|
|
|
DM_OFFSCREEN,
|
2017-03-11 16:20:06 +00:00
|
|
|
DM_PORTAL,
|
|
|
|
DM_SKYPORTAL
|
2016-06-18 10:14:20 +00:00
|
|
|
};
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2018-04-08 10:11:51 +00:00
|
|
|
|
|
|
|
// Helper baggage to draw the paletted software renderer output on old hardware.
|
|
|
|
// This must be here because the 2D drawer needs to access it, not the scene drawer.
|
|
|
|
class LegacyShader;
|
|
|
|
struct LegacyShaderContainer
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NUM_SHADERS = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
LegacyShader *Shaders[NUM_SHADERS];
|
|
|
|
|
|
|
|
LegacyShader* CreatePixelShader(const FString& vertexsrc, const FString& fragmentsrc, const FString &defines);
|
|
|
|
LegacyShaderContainer();
|
|
|
|
~LegacyShaderContainer();
|
|
|
|
bool LoadShaders();
|
|
|
|
void BindShader(int num, const float *p1, const float *p2);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
class FGLRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
OpenGLFrameBuffer *framebuffer;
|
2016-04-28 23:48:06 +00:00
|
|
|
GLPortal *mClipPortal;
|
2013-06-23 07:49:34 +00:00
|
|
|
GLPortal *mCurrentPortal;
|
|
|
|
int mMirrorCount;
|
|
|
|
int mPlaneMirrorCount;
|
|
|
|
int mLightCount;
|
|
|
|
float mCurrentFoV;
|
|
|
|
AActor *mViewActor;
|
|
|
|
FShaderManager *mShaderManager;
|
2014-08-22 21:50:38 +00:00
|
|
|
FSamplerManager *mSamplerManager;
|
2013-06-23 07:49:34 +00:00
|
|
|
int gl_spriteindex;
|
|
|
|
unsigned int mFBID;
|
2016-04-26 14:26:34 +00:00
|
|
|
unsigned int mVAOID;
|
2016-04-30 13:29:22 +00:00
|
|
|
int mOldFBID;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-07-26 19:27:02 +00:00
|
|
|
FGLRenderBuffers *mBuffers;
|
2016-08-29 11:10:22 +00:00
|
|
|
FLinearDepthShader *mLinearDepthShader;
|
|
|
|
FSSAOShader *mSSAOShader;
|
2016-09-02 03:45:00 +00:00
|
|
|
FDepthBlurShader *mDepthBlurShader;
|
|
|
|
FSSAOCombineShader *mSSAOCombineShader;
|
2016-07-27 19:50:30 +00:00
|
|
|
FBloomExtractShader *mBloomExtractShader;
|
|
|
|
FBloomCombineShader *mBloomCombineShader;
|
2016-09-18 13:57:22 +00:00
|
|
|
FExposureExtractShader *mExposureExtractShader;
|
|
|
|
FExposureAverageShader *mExposureAverageShader;
|
|
|
|
FExposureCombineShader *mExposureCombineShader;
|
2016-07-27 19:50:30 +00:00
|
|
|
FBlurShader *mBlurShader;
|
2016-07-28 22:36:43 +00:00
|
|
|
FTonemapShader *mTonemapShader;
|
2016-09-01 15:14:51 +00:00
|
|
|
FColormapShader *mColormapShader;
|
2016-08-23 07:18:18 +00:00
|
|
|
FHardwareTexture *mTonemapPalette;
|
2016-08-02 15:32:21 +00:00
|
|
|
FLensShader *mLensShader;
|
2016-09-25 09:25:01 +00:00
|
|
|
FFXAALumaShader *mFXAALumaShader;
|
|
|
|
FFXAAShader *mFXAAShader;
|
2016-07-26 19:27:02 +00:00
|
|
|
FPresentShader *mPresentShader;
|
2016-10-09 17:05:50 +00:00
|
|
|
FPresent3DCheckerShader *mPresent3dCheckerShader;
|
|
|
|
FPresent3DColumnShader *mPresent3dColumnShader;
|
2016-10-02 16:24:37 +00:00
|
|
|
FPresent3DRowShader *mPresent3dRowShader;
|
2017-03-01 02:33:53 +00:00
|
|
|
FShadowMapShader *mShadowMapShader;
|
2017-07-06 03:36:01 +00:00
|
|
|
FCustomPostProcessShaders *mCustomPostProcessShaders;
|
2016-07-26 19:27:02 +00:00
|
|
|
|
2017-03-01 03:05:54 +00:00
|
|
|
FShadowMap mShadowMap;
|
2016-07-26 19:27:02 +00:00
|
|
|
|
2018-02-15 16:56:04 +00:00
|
|
|
FTextureID glLight;
|
|
|
|
FTextureID glPart2;
|
|
|
|
FTextureID glPart;
|
|
|
|
FTextureID mirrorTexture;
|
2014-07-15 18:49:21 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
float mSky1Pos, mSky2Pos;
|
|
|
|
|
|
|
|
FRotator mAngles;
|
|
|
|
FVector2 mViewVector;
|
|
|
|
|
|
|
|
FFlatVertexBuffer *mVBO;
|
2014-06-13 23:24:28 +00:00
|
|
|
FSkyVertexBuffer *mSkyVBO;
|
2014-08-01 18:59:39 +00:00
|
|
|
FLightBuffer *mLights;
|
2018-04-05 21:08:09 +00:00
|
|
|
SWSceneDrawer *swdrawer = nullptr;
|
2018-04-08 10:11:51 +00:00
|
|
|
LegacyShaderContainer *legacyShaders = nullptr;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-07-31 11:23:49 +00:00
|
|
|
GL_IRECT mScreenViewport;
|
2016-08-12 05:28:29 +00:00
|
|
|
GL_IRECT mSceneViewport;
|
|
|
|
GL_IRECT mOutputLetterbox;
|
2016-07-28 22:36:43 +00:00
|
|
|
bool mDrawingScene2D = false;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-08-21 23:52:51 +00:00
|
|
|
float mSceneClearColor[3];
|
|
|
|
|
2017-07-09 17:01:34 +00:00
|
|
|
float mGlobVis = 0.0f;
|
|
|
|
|
2013-08-18 13:41:52 +00:00
|
|
|
FGLRenderer(OpenGLFrameBuffer *fb);
|
2013-06-23 07:49:34 +00:00
|
|
|
~FGLRenderer() ;
|
|
|
|
|
2016-08-12 05:28:29 +00:00
|
|
|
void SetOutputViewport(GL_IRECT *bounds);
|
|
|
|
int ScreenToWindowX(int x);
|
|
|
|
int ScreenToWindowY(int y);
|
|
|
|
|
2016-08-08 12:24:48 +00:00
|
|
|
void Initialize(int width, int height);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
void Begin2D();
|
|
|
|
void ClearBorders();
|
|
|
|
|
|
|
|
void FlushTextures();
|
|
|
|
void SetupLevel();
|
2018-04-08 06:03:46 +00:00
|
|
|
void ResetSWScene();
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-08-08 14:06:02 +00:00
|
|
|
void RenderScreenQuad();
|
2018-01-06 04:11:12 +00:00
|
|
|
void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D);
|
2016-08-29 11:10:22 +00:00
|
|
|
void AmbientOccludeScene();
|
2016-09-18 13:57:22 +00:00
|
|
|
void UpdateCameraExposure();
|
2017-03-12 20:57:39 +00:00
|
|
|
void BloomScene(int fixedcm);
|
2016-07-28 22:36:43 +00:00
|
|
|
void TonemapScene();
|
2017-03-12 20:57:39 +00:00
|
|
|
void ColormapScene(int fixedcm);
|
2016-11-28 01:32:57 +00:00
|
|
|
void CreateTonemapPalette();
|
2016-08-25 17:58:50 +00:00
|
|
|
void ClearTonemapPalette();
|
2016-08-02 15:32:21 +00:00
|
|
|
void LensDistortScene();
|
2016-09-25 09:25:01 +00:00
|
|
|
void ApplyFXAA();
|
2017-03-14 23:11:13 +00:00
|
|
|
void BlurScene(float gameinfobluramount);
|
2016-07-31 14:56:41 +00:00
|
|
|
void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma);
|
2016-09-08 17:02:13 +00:00
|
|
|
void DrawPresentTexture(const GL_IRECT &box, bool applyGamma);
|
2016-09-07 19:52:43 +00:00
|
|
|
void Flush();
|
2018-02-15 17:40:23 +00:00
|
|
|
void GetSpecialTextures();
|
2018-03-28 19:38:00 +00:00
|
|
|
void Draw2D(F2DDrawer *data);
|
2018-04-03 22:21:25 +00:00
|
|
|
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
|
|
|
|
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
|
|
|
|
void RenderView(player_t *player);
|
2018-04-07 08:53:20 +00:00
|
|
|
void DrawBlend(sector_t * viewsector, bool FixedColormap, bool docolormap, bool in2d = false);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool StartOffscreen();
|
|
|
|
void EndOffscreen();
|
|
|
|
|
|
|
|
void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
|
|
|
|
double originx, double originy, double scalex, double scaley,
|
2017-03-15 15:47:42 +00:00
|
|
|
DAngle rotation, const FColormap &colormap, PalEntry flatcolor, int lightlevel, int bottomclip);
|
2016-08-29 11:10:22 +00:00
|
|
|
|
2017-03-09 18:31:45 +00:00
|
|
|
int PTM_BestColor (const uint32_t *pal_in, int r, int g, int b, int first, int num);
|
2016-09-09 07:31:30 +00:00
|
|
|
|
2016-08-29 11:10:22 +00:00
|
|
|
static float GetZNear() { return 5.f; }
|
|
|
|
static float GetZFar() { return 65536.f; }
|
2013-06-23 07:49:34 +00:00
|
|
|
};
|
|
|
|
|
2018-04-23 20:18:13 +00:00
|
|
|
#include "hwrenderer/scene/hw_fakeflat.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
struct TexFilter_s
|
|
|
|
{
|
|
|
|
int minfilter;
|
|
|
|
int magfilter;
|
|
|
|
bool mipmapping;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
extern FGLRenderer *GLRenderer;
|
|
|
|
|
2018-04-24 08:30:26 +00:00
|
|
|
#endif
|