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"
|
2015-10-31 00:51:35 +00:00
|
|
|
#include "gl/data/gl_matrix.h"
|
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-07-27 19:50:30 +00:00
|
|
|
class FBloomExtractShader;
|
|
|
|
class FBloomCombineShader;
|
|
|
|
class FBlurShader;
|
2016-07-28 22:36:43 +00:00
|
|
|
class FTonemapShader;
|
2016-08-02 15:32:21 +00:00
|
|
|
class FLensShader;
|
2016-07-26 19:27:02 +00:00
|
|
|
class FPresentShader;
|
2016-08-08 10:13:09 +00:00
|
|
|
class F2DDrawer;
|
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
|
|
|
enum SectorRenderFlags
|
|
|
|
{
|
|
|
|
// This is used to avoid creating too many drawinfos
|
|
|
|
SSRF_RENDERFLOOR = 1,
|
|
|
|
SSRF_RENDERCEILING = 2,
|
|
|
|
SSRF_RENDER3DPLANES = 4,
|
|
|
|
SSRF_RENDERALL = 7,
|
|
|
|
SSRF_PROCESSED = 8,
|
|
|
|
SSRF_SEEN = 16,
|
|
|
|
};
|
|
|
|
|
|
|
|
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,
|
|
|
|
DM_PORTAL
|
|
|
|
};
|
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-07-27 19:50:30 +00:00
|
|
|
FBloomExtractShader *mBloomExtractShader;
|
|
|
|
FBloomCombineShader *mBloomCombineShader;
|
|
|
|
FBlurShader *mBlurShader;
|
2016-07-28 22:36:43 +00:00
|
|
|
FTonemapShader *mTonemapShader;
|
2016-08-02 15:32:21 +00:00
|
|
|
FLensShader *mLensShader;
|
2016-07-26 19:27:02 +00:00
|
|
|
FPresentShader *mPresentShader;
|
|
|
|
|
2016-04-26 19:31:24 +00:00
|
|
|
FTexture *gllight;
|
2013-06-23 07:49:34 +00:00
|
|
|
FTexture *glpart2;
|
|
|
|
FTexture *glpart;
|
|
|
|
FTexture *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;
|
2016-08-08 10:13:09 +00:00
|
|
|
F2DDrawer *m2DDrawer;
|
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;
|
|
|
|
float mCameraExposure = 1.0f;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-08-21 23:52:51 +00:00
|
|
|
float mSceneClearColor[3];
|
|
|
|
|
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);
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
angle_t FrustumAngle();
|
|
|
|
void SetViewArea();
|
2016-07-31 14:23:21 +00:00
|
|
|
void Set3DViewport(bool mainview);
|
2016-07-26 19:27:02 +00:00
|
|
|
void Reset3DViewport();
|
2013-06-23 07:49:34 +00:00
|
|
|
sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
|
|
|
void RenderView(player_t *player);
|
2016-04-02 21:17:16 +00:00
|
|
|
void SetViewAngle(DAngle viewangle);
|
|
|
|
void SetupView(float viewx, float viewy, float viewz, DAngle viewangle, bool mirror, bool planemirror);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-08-08 12:24:48 +00:00
|
|
|
void Initialize(int width, int height);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
void CreateScene();
|
2016-04-27 22:58:44 +00:00
|
|
|
void RenderMultipassStuff();
|
2013-06-23 07:49:34 +00:00
|
|
|
void RenderScene(int recursion);
|
|
|
|
void RenderTranslucent();
|
2016-06-18 10:14:20 +00:00
|
|
|
void DrawScene(int drawmode);
|
2013-06-23 07:49:34 +00:00
|
|
|
void DrawBlend(sector_t * viewsector);
|
|
|
|
|
2016-06-17 15:21:42 +00:00
|
|
|
void DrawPSprite (player_t * player,DPSprite *psp,float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture);
|
2013-06-23 07:49:34 +00:00
|
|
|
void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep);
|
|
|
|
void DrawTargeterSprites();
|
|
|
|
|
|
|
|
void Begin2D();
|
|
|
|
void ClearBorders();
|
|
|
|
|
|
|
|
void ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector);
|
2016-04-18 21:52:15 +00:00
|
|
|
void ProcessSprite(AActor *thing, sector_t *sector, bool thruportal);
|
2013-06-23 07:49:34 +00:00
|
|
|
void ProcessParticle(particle_t *part, sector_t *sector);
|
|
|
|
void ProcessSector(sector_t *fakesector);
|
|
|
|
void FlushTextures();
|
|
|
|
unsigned char *GetTextureBuffer(FTexture *tex, int &w, int &h);
|
|
|
|
void SetupLevel();
|
|
|
|
|
2016-08-08 14:06:02 +00:00
|
|
|
void RenderScreenQuad();
|
2013-06-23 07:49:34 +00:00
|
|
|
void SetFixedColormap (player_t *player);
|
|
|
|
void WriteSavePic (player_t *player, FILE *file, int width, int height);
|
|
|
|
void EndDrawScene(sector_t * viewsector);
|
2016-07-27 19:50:30 +00:00
|
|
|
void BloomScene();
|
2016-07-28 22:36:43 +00:00
|
|
|
void TonemapScene();
|
2016-08-02 15:32:21 +00:00
|
|
|
void LensDistortScene();
|
2016-07-31 14:56:41 +00:00
|
|
|
void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma);
|
|
|
|
void Flush() { CopyToBackbuffer(nullptr, true); }
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
void SetProjection(float fov, float ratio, float fovratio);
|
2015-10-31 11:46:36 +00:00
|
|
|
void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes
|
2016-04-02 21:17:16 +00:00
|
|
|
void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror);
|
2013-06-23 07:49:34 +00:00
|
|
|
void ProcessScene(bool toscreen = false);
|
|
|
|
|
|
|
|
bool StartOffscreen();
|
|
|
|
void EndOffscreen();
|
|
|
|
|
2016-08-08 10:13:09 +00:00
|
|
|
void StartSimplePolys();
|
|
|
|
void FinishSimplePolys();
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
|
|
|
|
double originx, double originy, double scalex, double scaley,
|
2016-03-24 15:40:15 +00:00
|
|
|
DAngle rotation, FDynamicColormap *colormap, int lightlevel);
|
2013-06-23 07:49:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Global functions. Make them members of GLRenderer later?
|
|
|
|
void gl_RenderBSPNode (void *node);
|
|
|
|
bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector);
|
|
|
|
void gl_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
area_normal,
|
|
|
|
area_below,
|
|
|
|
area_above,
|
|
|
|
area_default
|
|
|
|
} area_t;
|
|
|
|
|
|
|
|
extern area_t in_area;
|
|
|
|
|
|
|
|
|
|
|
|
sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
|
|
|
|
inline sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, bool back)
|
|
|
|
{
|
|
|
|
return gl_FakeFlat(sec, dest, in_area, back);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TexFilter_s
|
|
|
|
{
|
|
|
|
int minfilter;
|
|
|
|
int magfilter;
|
|
|
|
bool mipmapping;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
extern FGLRenderer *GLRenderer;
|
|
|
|
|
|
|
|
#endif
|