This commit is contained in:
Christoph Oelckers 2018-09-08 12:10:34 +02:00
commit 3dcaa509ef
4 changed files with 15 additions and 16 deletions

View File

@ -41,6 +41,7 @@ GLViewpointBuffer::GLViewpointBuffer()
Allocate(); Allocate();
Clear(); Clear();
mLastMappedIndex = UINT_MAX; mLastMappedIndex = UINT_MAX;
mClipPlaneInfo.Push(0);
} }
GLViewpointBuffer::~GLViewpointBuffer() GLViewpointBuffer::~GLViewpointBuffer()
@ -121,10 +122,9 @@ int GLViewpointBuffer::Bind(unsigned int index)
glBindBufferRange(GL_UNIFORM_BUFFER, VIEWPOINT_BINDINGPOINT, mBufferId, index * mBlockAlign, mBlockAlign); glBindBufferRange(GL_UNIFORM_BUFFER, VIEWPOINT_BINDINGPOINT, mBufferId, index * mBlockAlign, mBlockAlign);
// Update the viewpoint-related clip plane setting. // Update the viewpoint-related clip plane setting.
auto *vp = (HWViewpointUniforms*)(((char*)mBufferPointer) + mUploadIndex * mBlockAlign);
if (!(gl.flags & RFL_NO_CLIP_PLANES)) if (!(gl.flags & RFL_NO_CLIP_PLANES))
{ {
if (index > 0 && (vp->mClipHeightDirection != 0.f || vp->mClipLine.X > -10000000.0f)) if (mClipPlaneInfo[index])
{ {
glEnable(GL_CLIP_DISTANCE0); glEnable(GL_CLIP_DISTANCE0);
} }
@ -163,6 +163,7 @@ int GLViewpointBuffer::SetViewpoint(HWViewpointUniforms *vp)
memcpy(((char*)mBufferPointer) + mUploadIndex * mBlockAlign, vp, sizeof(*vp)); memcpy(((char*)mBufferPointer) + mUploadIndex * mBlockAlign, vp, sizeof(*vp));
Unmap(); Unmap();
mClipPlaneInfo.Push(vp->mClipHeightDirection != 0.f || vp->mClipLine.X > -10000000.0f);
return Bind(mUploadIndex++); return Bind(mUploadIndex++);
} }
@ -170,5 +171,6 @@ void GLViewpointBuffer::Clear()
{ {
// Index 0 is reserved for the 2D projection. // Index 0 is reserved for the 2D projection.
mUploadIndex = 1; mUploadIndex = 1;
mClipPlaneInfo.Resize(1);
} }

View File

@ -12,6 +12,7 @@ class GLViewpointBuffer
unsigned int mLastMappedIndex; unsigned int mLastMappedIndex;
unsigned int mByteSize; unsigned int mByteSize;
void * mBufferPointer; void * mBufferPointer;
TArray<bool> mClipPlaneInfo;
unsigned int m2DWidth = ~0u, m2DHeight = ~0u; unsigned int m2DWidth = ~0u, m2DHeight = ~0u;

View File

@ -52,11 +52,7 @@ protected:
static const int MIN_WIDTH = 320; static const int MIN_WIDTH = 320;
static const int MIN_HEIGHT = 200; static const int MIN_HEIGHT = 200;
typedef DECLSPEC int SDLCALL (*SDL_GetWindowBordersSizePtr)(SDL_Window *, int *, int *, int *, int *);
SDL_GetWindowBordersSizePtr SDL_GetWindowBordersSize_;
void *sdl_lib;
}; };
#endif // __POSIX_SDL_GL_SYSFB_H__ #endif // __POSIX_SDL_GL_SYSFB_H__

View File

@ -35,6 +35,7 @@
#include "doomtype.h" #include "doomtype.h"
#include "i_module.h"
#include "i_system.h" #include "i_system.h"
#include "i_video.h" #include "i_video.h"
#include "m_argv.h" #include "m_argv.h"
@ -172,6 +173,11 @@ IVideo *gl_CreateVideo()
// FrameBuffer implementation ----------------------------------------------- // FrameBuffer implementation -----------------------------------------------
FModule sdl_lib("SDL2");
typedef int (*SDL_GetWindowBordersSizePtr)(SDL_Window *, int *, int *, int *, int *);
static TOptProc<sdl_lib, SDL_GetWindowBordersSizePtr> SDL_GetWindowBordersSize_("SDL_GetWindowBordersSize");
SystemGLFrameBuffer::SystemGLFrameBuffer (void *, bool fullscreen) SystemGLFrameBuffer::SystemGLFrameBuffer (void *, bool fullscreen)
: DFrameBuffer (vid_defwidth, vid_defheight) : DFrameBuffer (vid_defwidth, vid_defheight)
{ {
@ -180,10 +186,9 @@ SystemGLFrameBuffer::SystemGLFrameBuffer (void *, bool fullscreen)
// SDL_GetWindowBorderSize() is only available since 2.0.5, but because // SDL_GetWindowBorderSize() is only available since 2.0.5, but because
// GZDoom supports platforms with older SDL2 versions, this function // GZDoom supports platforms with older SDL2 versions, this function
// has to be dynamically loaded // has to be dynamically loaded
sdl_lib = SDL_LoadObject("libSDL2.so"); if (!sdl_lib.IsLoaded())
if (sdl_lib != nullptr)
{ {
SDL_GetWindowBordersSize_ = (SDL_GetWindowBordersSizePtr)SDL_LoadFunction(sdl_lib,"SDL_GetWindowBordersSize"); sdl_lib.Load({ "libSDL2.so", "libSDL2-2.0.so" });
} }
// NOTE: Core profiles were added with GL 3.2, so there's no sense trying // NOTE: Core profiles were added with GL 3.2, so there's no sense trying
@ -261,11 +266,6 @@ SystemGLFrameBuffer::SystemGLFrameBuffer (void *, bool fullscreen)
SystemGLFrameBuffer::~SystemGLFrameBuffer () SystemGLFrameBuffer::~SystemGLFrameBuffer ()
{ {
if (sdl_lib != nullptr)
{
SDL_UnloadObject(sdl_lib);
}
if (Screen) if (Screen)
{ {
ResetGammaTable(); ResetGammaTable();
@ -391,7 +391,7 @@ void SystemGLFrameBuffer::SetWindowSize(int w, int h)
void SystemGLFrameBuffer::GetWindowBordersSize(int &top, int &left) void SystemGLFrameBuffer::GetWindowBordersSize(int &top, int &left)
{ {
if (SDL_GetWindowBordersSize_ != nullptr) if (SDL_GetWindowBordersSize_)
{ {
SDL_GetWindowBordersSize_(Screen, &top, &left, nullptr, nullptr); SDL_GetWindowBordersSize_(Screen, &top, &left, nullptr, nullptr);
} }