- add GL to OpenGL specific postprocess classes to make it more clear which belongs to the generic hw interface and which belong to the OpenGL implementation

This commit is contained in:
Magnus Norddahl 2018-07-03 23:31:40 +02:00
parent 2128b99117
commit 092b2953ea
2 changed files with 53 additions and 53 deletions

View file

@ -104,21 +104,21 @@ void FGLRenderBuffers::ClearEyeBuffers()
mEyeFBs.Clear(); mEyeFBs.Clear();
} }
void FGLRenderBuffers::DeleteTexture(PPTexture &tex) void FGLRenderBuffers::DeleteTexture(PPGLTexture &tex)
{ {
if (tex.handle != 0) if (tex.handle != 0)
glDeleteTextures(1, &tex.handle); glDeleteTextures(1, &tex.handle);
tex.handle = 0; tex.handle = 0;
} }
void FGLRenderBuffers::DeleteRenderBuffer(PPRenderBuffer &buf) void FGLRenderBuffers::DeleteRenderBuffer(PPGLRenderBuffer &buf)
{ {
if (buf.handle != 0) if (buf.handle != 0)
glDeleteRenderbuffers(1, &buf.handle); glDeleteRenderbuffers(1, &buf.handle);
buf.handle = 0; buf.handle = 0;
} }
void FGLRenderBuffers::DeleteFrameBuffer(PPFrameBuffer &fb) void FGLRenderBuffers::DeleteFrameBuffer(PPGLFrameBuffer &fb)
{ {
if (fb.handle != 0) if (fb.handle != 0)
glDeleteFramebuffers(1, &fb.handle); glDeleteFramebuffers(1, &fb.handle);
@ -263,7 +263,7 @@ void FGLRenderBuffers::CreateEyeBuffers(int eye)
while (mEyeFBs.Size() <= unsigned(eye)) while (mEyeFBs.Size() <= unsigned(eye))
{ {
PPTexture texture = Create2DTexture("EyeTexture", GL_RGBA16F, mWidth, mHeight); PPGLTexture texture = Create2DTexture("EyeTexture", GL_RGBA16F, mWidth, mHeight);
mEyeTextures.Push(texture); mEyeTextures.Push(texture);
mEyeFBs.Push(CreateFrameBuffer("EyeFB", texture)); mEyeFBs.Push(CreateFrameBuffer("EyeFB", texture));
} }
@ -279,9 +279,9 @@ void FGLRenderBuffers::CreateEyeBuffers(int eye)
// //
//========================================================================== //==========================================================================
PPTexture FGLRenderBuffers::Create2DTexture(const char *name, GLuint format, int width, int height, const void *data) PPGLTexture FGLRenderBuffers::Create2DTexture(const char *name, GLuint format, int width, int height, const void *data)
{ {
PPTexture tex; PPGLTexture tex;
tex.Width = width; tex.Width = width;
tex.Height = height; tex.Height = height;
glGenTextures(1, &tex.handle); glGenTextures(1, &tex.handle);
@ -315,9 +315,9 @@ PPTexture FGLRenderBuffers::Create2DTexture(const char *name, GLuint format, int
return tex; return tex;
} }
PPTexture FGLRenderBuffers::Create2DMultisampleTexture(const char *name, GLuint format, int width, int height, int samples, bool fixedSampleLocations) PPGLTexture FGLRenderBuffers::Create2DMultisampleTexture(const char *name, GLuint format, int width, int height, int samples, bool fixedSampleLocations)
{ {
PPTexture tex; PPGLTexture tex;
tex.Width = width; tex.Width = width;
tex.Height = height; tex.Height = height;
glGenTextures(1, &tex.handle); glGenTextures(1, &tex.handle);
@ -334,9 +334,9 @@ PPTexture FGLRenderBuffers::Create2DMultisampleTexture(const char *name, GLuint
// //
//========================================================================== //==========================================================================
PPRenderBuffer FGLRenderBuffers::CreateRenderBuffer(const char *name, GLuint format, int width, int height) PPGLRenderBuffer FGLRenderBuffers::CreateRenderBuffer(const char *name, GLuint format, int width, int height)
{ {
PPRenderBuffer buf; PPGLRenderBuffer buf;
glGenRenderbuffers(1, &buf.handle); glGenRenderbuffers(1, &buf.handle);
glBindRenderbuffer(GL_RENDERBUFFER, buf.handle); glBindRenderbuffer(GL_RENDERBUFFER, buf.handle);
FGLDebug::LabelObject(GL_RENDERBUFFER, buf.handle, name); FGLDebug::LabelObject(GL_RENDERBUFFER, buf.handle, name);
@ -344,12 +344,12 @@ PPRenderBuffer FGLRenderBuffers::CreateRenderBuffer(const char *name, GLuint for
return buf; return buf;
} }
PPRenderBuffer FGLRenderBuffers::CreateRenderBuffer(const char *name, GLuint format, int width, int height, int samples) PPGLRenderBuffer FGLRenderBuffers::CreateRenderBuffer(const char *name, GLuint format, int width, int height, int samples)
{ {
if (samples <= 1) if (samples <= 1)
return CreateRenderBuffer(name, format, width, height); return CreateRenderBuffer(name, format, width, height);
PPRenderBuffer buf; PPGLRenderBuffer buf;
glGenRenderbuffers(1, &buf.handle); glGenRenderbuffers(1, &buf.handle);
glBindRenderbuffer(GL_RENDERBUFFER, buf.handle); glBindRenderbuffer(GL_RENDERBUFFER, buf.handle);
FGLDebug::LabelObject(GL_RENDERBUFFER, buf.handle, name); FGLDebug::LabelObject(GL_RENDERBUFFER, buf.handle, name);
@ -363,9 +363,9 @@ PPRenderBuffer FGLRenderBuffers::CreateRenderBuffer(const char *name, GLuint for
// //
//========================================================================== //==========================================================================
PPFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPTexture colorbuffer) PPGLFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPGLTexture colorbuffer)
{ {
PPFrameBuffer fb; PPGLFrameBuffer fb;
glGenFramebuffers(1, &fb.handle); glGenFramebuffers(1, &fb.handle);
glBindFramebuffer(GL_FRAMEBUFFER, fb.handle); glBindFramebuffer(GL_FRAMEBUFFER, fb.handle);
FGLDebug::LabelObject(GL_FRAMEBUFFER, fb.handle, name); FGLDebug::LabelObject(GL_FRAMEBUFFER, fb.handle, name);
@ -375,9 +375,9 @@ PPFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPTexture co
return fb; return fb;
} }
PPFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPTexture colorbuffer, PPRenderBuffer depthstencil) PPGLFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPGLTexture colorbuffer, PPGLRenderBuffer depthstencil)
{ {
PPFrameBuffer fb; PPGLFrameBuffer fb;
glGenFramebuffers(1, &fb.handle); glGenFramebuffers(1, &fb.handle);
glBindFramebuffer(GL_FRAMEBUFFER, fb.handle); glBindFramebuffer(GL_FRAMEBUFFER, fb.handle);
FGLDebug::LabelObject(GL_FRAMEBUFFER, fb.handle, name); FGLDebug::LabelObject(GL_FRAMEBUFFER, fb.handle, name);
@ -388,9 +388,9 @@ PPFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPTexture co
return fb; return fb;
} }
PPFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPRenderBuffer colorbuffer, PPRenderBuffer depthstencil) PPGLFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPGLRenderBuffer colorbuffer, PPGLRenderBuffer depthstencil)
{ {
PPFrameBuffer fb; PPGLFrameBuffer fb;
glGenFramebuffers(1, &fb.handle); glGenFramebuffers(1, &fb.handle);
glBindFramebuffer(GL_FRAMEBUFFER, fb.handle); glBindFramebuffer(GL_FRAMEBUFFER, fb.handle);
FGLDebug::LabelObject(GL_FRAMEBUFFER, fb.handle, name); FGLDebug::LabelObject(GL_FRAMEBUFFER, fb.handle, name);
@ -401,9 +401,9 @@ PPFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPRenderBuff
return fb; return fb;
} }
PPFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPTexture colorbuffer0, PPTexture colorbuffer1, PPTexture colorbuffer2, PPTexture depthstencil, bool multisample) PPGLFrameBuffer FGLRenderBuffers::CreateFrameBuffer(const char *name, PPGLTexture colorbuffer0, PPGLTexture colorbuffer1, PPGLTexture colorbuffer2, PPGLTexture depthstencil, bool multisample)
{ {
PPFrameBuffer fb; PPGLFrameBuffer fb;
glGenFramebuffers(1, &fb.handle); glGenFramebuffers(1, &fb.handle);
glBindFramebuffer(GL_FRAMEBUFFER, fb.handle); glBindFramebuffer(GL_FRAMEBUFFER, fb.handle);
FGLDebug::LabelObject(GL_FRAMEBUFFER, fb.handle, name); FGLDebug::LabelObject(GL_FRAMEBUFFER, fb.handle, name);

View file

@ -4,7 +4,7 @@
#include "gl/shaders/gl_shader.h" #include "gl/shaders/gl_shader.h"
#include "hwrenderer/postprocessing/hw_postprocess.h" #include "hwrenderer/postprocessing/hw_postprocess.h"
class PPTexture class PPGLTexture
{ {
public: public:
void Bind(int index, int filter = GL_NEAREST, int wrap = GL_CLAMP_TO_EDGE) void Bind(int index, int filter = GL_NEAREST, int wrap = GL_CLAMP_TO_EDGE)
@ -28,7 +28,7 @@ private:
friend class FGLRenderBuffers; friend class FGLRenderBuffers;
}; };
class PPFrameBuffer class PPGLFrameBuffer
{ {
public: public:
void Bind() void Bind()
@ -44,7 +44,7 @@ private:
friend class FGLRenderBuffers; friend class FGLRenderBuffers;
}; };
class PPRenderBuffer class PPGLRenderBuffer
{ {
private: private:
GLuint handle = 0; GLuint handle = 0;
@ -68,8 +68,8 @@ public:
void CompileEffectShaders(); void CompileEffectShaders();
void RenderEffect(const FString &name); void RenderEffect(const FString &name);
TMap<PPTextureName, PPTexture> GLTextures; TMap<PPTextureName, PPGLTexture> GLTextures;
TMap<PPTextureName, PPFrameBuffer> GLTextureFBs; TMap<PPTextureName, PPGLFrameBuffer> GLTextureFBs;
TMap<PPShaderName, std::shared_ptr<FShaderProgram>> GLShaders; TMap<PPShaderName, std::shared_ptr<FShaderProgram>> GLShaders;
void BindSceneFB(bool sceneData); void BindSceneFB(bool sceneData);
@ -84,7 +84,7 @@ public:
void BindNextFB(); void BindNextFB();
void NextTexture(); void NextTexture();
PPFrameBuffer GetCurrentFB() const { return mPipelineFB[mCurrentPipelineTexture]; } PPGLFrameBuffer GetCurrentFB() const { return mPipelineFB[mCurrentPipelineTexture]; }
void BindOutputFB(); void BindOutputFB();
@ -111,19 +111,19 @@ private:
void CreateEyeBuffers(int eye); void CreateEyeBuffers(int eye);
void CreateShadowMap(); void CreateShadowMap();
PPTexture Create2DTexture(const char *name, GLuint format, int width, int height, const void *data = nullptr); PPGLTexture Create2DTexture(const char *name, GLuint format, int width, int height, const void *data = nullptr);
PPTexture Create2DMultisampleTexture(const char *name, GLuint format, int width, int height, int samples, bool fixedSampleLocations); PPGLTexture Create2DMultisampleTexture(const char *name, GLuint format, int width, int height, int samples, bool fixedSampleLocations);
PPRenderBuffer CreateRenderBuffer(const char *name, GLuint format, int width, int height); PPGLRenderBuffer CreateRenderBuffer(const char *name, GLuint format, int width, int height);
PPRenderBuffer CreateRenderBuffer(const char *name, GLuint format, int width, int height, int samples); PPGLRenderBuffer CreateRenderBuffer(const char *name, GLuint format, int width, int height, int samples);
PPFrameBuffer CreateFrameBuffer(const char *name, PPTexture colorbuffer); PPGLFrameBuffer CreateFrameBuffer(const char *name, PPGLTexture colorbuffer);
PPFrameBuffer CreateFrameBuffer(const char *name, PPTexture colorbuffer, PPRenderBuffer depthstencil); PPGLFrameBuffer CreateFrameBuffer(const char *name, PPGLTexture colorbuffer, PPGLRenderBuffer depthstencil);
PPFrameBuffer CreateFrameBuffer(const char *name, PPRenderBuffer colorbuffer, PPRenderBuffer depthstencil); PPGLFrameBuffer CreateFrameBuffer(const char *name, PPGLRenderBuffer colorbuffer, PPGLRenderBuffer depthstencil);
PPFrameBuffer CreateFrameBuffer(const char *name, PPTexture colorbuffer0, PPTexture colorbuffer1, PPTexture colorbuffer2, PPTexture depthstencil, bool multisample); PPGLFrameBuffer CreateFrameBuffer(const char *name, PPGLTexture colorbuffer0, PPGLTexture colorbuffer1, PPGLTexture colorbuffer2, PPGLTexture depthstencil, bool multisample);
bool CheckFrameBufferCompleteness(); bool CheckFrameBufferCompleteness();
void ClearFrameBuffer(bool stencil, bool depth); void ClearFrameBuffer(bool stencil, bool depth);
void DeleteTexture(PPTexture &handle); void DeleteTexture(PPGLTexture &handle);
void DeleteRenderBuffer(PPRenderBuffer &handle); void DeleteRenderBuffer(PPGLRenderBuffer &handle);
void DeleteFrameBuffer(PPFrameBuffer &handle); void DeleteFrameBuffer(PPGLFrameBuffer &handle);
int mWidth = 0; int mWidth = 0;
int mHeight = 0; int mHeight = 0;
@ -136,29 +136,29 @@ private:
int mCurrentPipelineTexture = 0; int mCurrentPipelineTexture = 0;
// Buffers for the scene // Buffers for the scene
PPTexture mSceneMultisampleTex; PPGLTexture mSceneMultisampleTex;
PPTexture mSceneDepthStencilTex; PPGLTexture mSceneDepthStencilTex;
PPTexture mSceneFogTex; PPGLTexture mSceneFogTex;
PPTexture mSceneNormalTex; PPGLTexture mSceneNormalTex;
PPRenderBuffer mSceneMultisampleBuf; PPGLRenderBuffer mSceneMultisampleBuf;
PPRenderBuffer mSceneDepthStencilBuf; PPGLRenderBuffer mSceneDepthStencilBuf;
PPRenderBuffer mSceneFogBuf; PPGLRenderBuffer mSceneFogBuf;
PPRenderBuffer mSceneNormalBuf; PPGLRenderBuffer mSceneNormalBuf;
PPFrameBuffer mSceneFB; PPGLFrameBuffer mSceneFB;
PPFrameBuffer mSceneDataFB; PPGLFrameBuffer mSceneDataFB;
bool mSceneUsesTextures = false; bool mSceneUsesTextures = false;
// Effect/HUD buffers // Effect/HUD buffers
PPTexture mPipelineTexture[NumPipelineTextures]; PPGLTexture mPipelineTexture[NumPipelineTextures];
PPFrameBuffer mPipelineFB[NumPipelineTextures]; PPGLFrameBuffer mPipelineFB[NumPipelineTextures];
// Eye buffers // Eye buffers
TArray<PPTexture> mEyeTextures; TArray<PPGLTexture> mEyeTextures;
TArray<PPFrameBuffer> mEyeFBs; TArray<PPGLFrameBuffer> mEyeFBs;
// Shadow map texture // Shadow map texture
PPTexture mShadowMapTexture; PPGLTexture mShadowMapTexture;
PPFrameBuffer mShadowMapFB; PPGLFrameBuffer mShadowMapFB;
int mCurrentShadowMapSize = 0; int mCurrentShadowMapSize = 0;
static bool FailedCreate; static bool FailedCreate;