gzdoom-gles/src/gl/renderer/gl_renderer.h

243 lines
5.5 KiB
C
Raw Normal View History

#ifndef __GL_RENDERER_H
#define __GL_RENDERER_H
#include "r_defs.h"
#include "v_video.h"
#include "vectors.h"
#include "r_renderer.h"
#include "r_data/matrix.h"
#include "gl/dynlights/gl_shadowmap.h"
2018-01-06 04:11:12 +00:00
#include <functional>
#ifdef _MSC_VER
#pragma warning(disable:4244)
#endif
struct particle_t;
class FCanvasTexture;
class FFlatVertexBuffer;
class FSkyVertexBuffer;
class OpenGLFrameBuffer;
struct FDrawInfo;
class FShaderManager;
class GLPortal;
class FLightBuffer;
class FSamplerManager;
class DPSprite;
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;
class FExposureExtractShader;
class FExposureAverageShader;
class FExposureCombineShader;
2016-07-27 19:50:30 +00:00
class FBlurShader;
class FTonemapShader;
class FColormapShader;
2016-08-02 15:32:21 +00:00
class FLensShader;
class FFXAALumaShader;
class FFXAAShader;
class FPresentShader;
class FPresent3DCheckerShader;
class FPresent3DColumnShader;
class FPresent3DRowShader;
class FGL2DDrawer;
2016-08-23 07:18:18 +00:00
class FHardwareTexture;
2017-03-01 02:33:53 +00:00
class FShadowMapShader;
class FCustomPostProcessShaders;
2018-01-06 04:11:12 +00:00
class GLSceneDrawer;
class SWSceneDrawer;
inline float DEG2RAD(float deg)
{
return deg * float(M_PI / 180.0);
}
inline float RAD2DEG(float deg)
{
return deg * float(180. / M_PI);
}
struct GL_IRECT
{
int left,top;
int width,height;
void Offset(int xofs,int yofs)
{
left+=xofs;
top+=yofs;
}
};
enum
{
DM_MAINVIEW,
DM_OFFSCREEN,
DM_PORTAL,
DM_SKYPORTAL
};
// 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);
};
class FGLRenderer
{
public:
OpenGLFrameBuffer *framebuffer;
GLPortal *mClipPortal;
GLPortal *mCurrentPortal;
int mMirrorCount;
int mPlaneMirrorCount;
int mLightCount;
float mCurrentFoV;
AActor *mViewActor;
FShaderManager *mShaderManager;
FSamplerManager *mSamplerManager;
int gl_spriteindex;
unsigned int mFBID;
unsigned int mVAOID;
int mOldFBID;
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;
FExposureExtractShader *mExposureExtractShader;
FExposureAverageShader *mExposureAverageShader;
FExposureCombineShader *mExposureCombineShader;
2016-07-27 19:50:30 +00:00
FBlurShader *mBlurShader;
FTonemapShader *mTonemapShader;
FColormapShader *mColormapShader;
2016-08-23 07:18:18 +00:00
FHardwareTexture *mTonemapPalette;
2016-08-02 15:32:21 +00:00
FLensShader *mLensShader;
FFXAALumaShader *mFXAALumaShader;
FFXAAShader *mFXAAShader;
FPresentShader *mPresentShader;
FPresent3DCheckerShader *mPresent3dCheckerShader;
FPresent3DColumnShader *mPresent3dColumnShader;
FPresent3DRowShader *mPresent3dRowShader;
2017-03-01 02:33:53 +00:00
FShadowMapShader *mShadowMapShader;
FCustomPostProcessShaders *mCustomPostProcessShaders;
FShadowMap mShadowMap;
FTextureID glLight;
FTextureID glPart2;
FTextureID glPart;
FTextureID mirrorTexture;
float mSky1Pos, mSky2Pos;
FRotator mAngles;
FVector2 mViewVector;
FFlatVertexBuffer *mVBO;
FSkyVertexBuffer *mSkyVBO;
FLightBuffer *mLights;
SWSceneDrawer *swdrawer = nullptr;
LegacyShaderContainer *legacyShaders = nullptr;
GL_IRECT mScreenViewport;
GL_IRECT mSceneViewport;
GL_IRECT mOutputLetterbox;
bool mDrawingScene2D = false;
2016-08-21 23:52:51 +00:00
float mSceneClearColor[3];
float mGlobVis = 0.0f;
FGLRenderer(OpenGLFrameBuffer *fb);
~FGLRenderer() ;
void SetOutputViewport(GL_IRECT *bounds);
int ScreenToWindowX(int x);
int ScreenToWindowY(int y);
void Initialize(int width, int height);
void Begin2D();
void ClearBorders();
void FlushTextures();
void SetupLevel();
void ResetSWScene();
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();
void UpdateCameraExposure();
void BloomScene(int fixedcm);
void TonemapScene();
void ColormapScene(int fixedcm);
void CreateTonemapPalette();
void ClearTonemapPalette();
2016-08-02 15:32:21 +00:00
void LensDistortScene();
void ApplyFXAA();
void BlurScene(float gameinfobluramount);
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();
void Draw2D(F2DDrawer *data);
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV);
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
void RenderView(player_t *player);
void DrawBlend(sector_t * viewsector, bool FixedColormap, bool docolormap, bool in2d = false);
bool StartOffscreen();
void EndOffscreen();
void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
double originx, double originy, double scalex, double scaley,
DAngle rotation, const FColormap &colormap, PalEntry flatcolor, int lightlevel, int bottomclip);
2016-08-29 11:10:22 +00:00
int PTM_BestColor (const uint32_t *pal_in, int r, int g, int b, int first, int num);
2016-08-29 11:10:22 +00:00
static float GetZNear() { return 5.f; }
static float GetZFar() { return 65536.f; }
};
#include "hwrenderer/scene/hw_fakeflat.h"
struct TexFilter_s
{
int minfilter;
int magfilter;
bool mipmapping;
} ;
extern FGLRenderer *GLRenderer;
#endif