# Conflicts:
#	src/gl/system/gl_interface.cpp
This commit is contained in:
Christoph Oelckers 2016-04-30 17:09:57 +02:00
commit 8011958ebe
10 changed files with 1744 additions and 1596 deletions

View file

@ -122,6 +122,7 @@ void FGLRenderer::Initialize()
else mLights = NULL; else mLights = NULL;
gl_RenderState.SetVertexBuffer(mVBO); gl_RenderState.SetVertexBuffer(mVBO);
mFBID = 0; mFBID = 0;
mOldFBID = 0;
SetupLevel(); SetupLevel();
mShaderManager = new FShaderManager; mShaderManager = new FShaderManager;
@ -237,6 +238,7 @@ void FGLRenderer::FlushTextures()
bool FGLRenderer::StartOffscreen() bool FGLRenderer::StartOffscreen()
{ {
if (mFBID == 0) glGenFramebuffers(1, &mFBID); if (mFBID == 0) glGenFramebuffers(1, &mFBID);
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID);
glBindFramebuffer(GL_FRAMEBUFFER, mFBID); glBindFramebuffer(GL_FRAMEBUFFER, mFBID);
return true; return true;
} }
@ -249,7 +251,7 @@ bool FGLRenderer::StartOffscreen()
void FGLRenderer::EndOffscreen() void FGLRenderer::EndOffscreen()
{ {
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, mOldFBID);
} }
//=========================================================================== //===========================================================================

View file

@ -71,6 +71,7 @@ public:
int gl_spriteindex; int gl_spriteindex;
unsigned int mFBID; unsigned int mFBID;
unsigned int mVAOID; unsigned int mVAOID;
int mOldFBID;
FTexture *gllight; FTexture *gllight;
FTexture *glpart2; FTexture *glpart2;

View file

@ -75,6 +75,7 @@ void PatchCommon(FString &code)
void PatchVertShader(FString &code) void PatchVertShader(FString &code)
{ {
PatchCommon(code); PatchCommon(code);
code.Substitute("in vec", "attribute vec");
code.Substitute("out vec", "varying vec"); code.Substitute("out vec", "varying vec");
code.Substitute("gl_ClipDistance", "//"); code.Substitute("gl_ClipDistance", "//");
} }

View file

@ -0,0 +1,14 @@
-- List of OpenGL extensions for glLoadGen
-- Generation of gl_load.c and gl_load.h files:
-- > lua LoadGen.lua -style=pointer_c -spec=gl -version=3.3 -profile=compatibility -extfile=gl_extlist.txt load
APPLE_client_storage
ARB_buffer_storage
ARB_shader_storage_buffer_object
ARB_texture_compression
ARB_texture_rectangle
EXT_framebuffer_object
EXT_texture_compression_s3tc
EXT_texture_filter_anisotropic
EXT_texture_sRGB

View file

@ -130,12 +130,9 @@ void OpenGLFrameBuffer::InitializeState()
if (first) if (first)
{ {
first=false; first=false;
// [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated.
#ifdef _MSC_VER
gl_PrintStartupLog(); gl_PrintStartupLog();
#endif
} }
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f); glClearDepth(1.0f);
glDepthFunc(GL_LESS); glDepthFunc(GL_LESS);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -86,9 +86,6 @@ template <typename T>
inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); } inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); }
#define _access(a,b) access(a,b) #define _access(a,b) access(a,b)
#endif #endif
#ifndef _WIN32
#include <SDL.h>
#endif
#ifdef LoadMenu #ifdef LoadMenu

View file

@ -373,16 +373,7 @@ private:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
struct CapabilityChecker class CocoaOpenGLFrameBuffer : public OpenGLFrameBuffer, private NonCopyable
{
CapabilityChecker();
};
// ---------------------------------------------------------------------------
class CocoaOpenGLFrameBuffer : public OpenGLFrameBuffer, private CapabilityChecker, private NonCopyable
{ {
typedef OpenGLFrameBuffer Super; typedef OpenGLFrameBuffer Super;
@ -1164,12 +1155,14 @@ SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool
, m_lock(-1) , m_lock(-1)
, m_isUpdatePending(false) , m_isUpdatePending(false)
, m_supportsGamma(true) , m_supportsGamma(true)
, m_gammaTexture(GAMMA_TABLE_SIZE, 1, false, false, true, true) , m_gammaProgram("gamma_correction")
, m_gammaTexture(GAMMA_TABLE_SIZE, 1, true)
{ {
} }
SDLGLFB::SDLGLFB() SDLGLFB::SDLGLFB()
: m_gammaTexture(0, 0, false, false, false, false) : m_gammaProgram(nullptr)
, m_gammaTexture(0, 0, false)
{ {
} }
@ -1393,7 +1386,7 @@ bool BoundTextureSaveAsPNG(const GLenum target, const char* const path)
RenderTarget::RenderTarget(const GLsizei width, const GLsizei height) RenderTarget::RenderTarget(const GLsizei width, const GLsizei height)
: m_ID(0) : m_ID(0)
, m_oldID(0) , m_oldID(0)
, m_texture(width, height, false, false, true, true) , m_texture(width, height, true)
{ {
glGenFramebuffersEXT(1, &m_ID); glGenFramebuffersEXT(1, &m_ID);
@ -1439,26 +1432,12 @@ GLuint RenderTarget::GetBoundID()
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
CapabilityChecker::CapabilityChecker()
{
if (!(gl.flags & RFL_FRAMEBUFFER))
{
I_FatalError(
"The graphics hardware in your system does not support Frame Buffer Object (FBO).\n"
"It is required to run this version of " GAMENAME ".\n");
}
}
// ---------------------------------------------------------------------------
CocoaOpenGLFrameBuffer::CocoaOpenGLFrameBuffer(void* hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) CocoaOpenGLFrameBuffer::CocoaOpenGLFrameBuffer(void* hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen)
: OpenGLFrameBuffer(hMonitor, width, height, bits, refreshHz, fullscreen) : OpenGLFrameBuffer(hMonitor, width, height, bits, refreshHz, fullscreen)
, m_renderTarget(width, height) , m_renderTarget(width, height)
{ {
SetSmoothPicture(gl_smooth_rendered); SetSmoothPicture(gl_smooth_rendered);
/*
// Setup uniform samplers for gamma correction shader // Setup uniform samplers for gamma correction shader
m_gammaProgram.Load("GammaCorrection", "shaders/glsl/main.vp", m_gammaProgram.Load("GammaCorrection", "shaders/glsl/main.vp",
@ -1470,7 +1449,7 @@ CocoaOpenGLFrameBuffer::CocoaOpenGLFrameBuffer(void* hMonitor, int width, int he
glUniform1i(glGetUniformLocation(program, "backbuffer"), 0); glUniform1i(glGetUniformLocation(program, "backbuffer"), 0);
glUniform1i(glGetUniformLocation(program, "gammaTable"), 1); glUniform1i(glGetUniformLocation(program, "gammaTable"), 1);
glUseProgram(0); glUseProgram(0);
*/
// Fill render target with black color // Fill render target with black color
m_renderTarget.Bind(); m_renderTarget.Bind();
@ -1525,8 +1504,8 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget()
{ {
m_renderTarget.Unbind(); m_renderTarget.Unbind();
m_renderTarget.GetColorTexture().Bind(0, 0); m_renderTarget.GetColorTexture().Bind(0, 0, 0);
m_gammaTexture.Bind(1, 0); m_gammaTexture.Bind(1, 0, 0);
if (rbOpts.dirty) if (rbOpts.dirty)
{ {
@ -1540,7 +1519,7 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget()
glViewport(rbOpts.shiftX, rbOpts.shiftY, rbOpts.width, rbOpts.height); glViewport(rbOpts.shiftX, rbOpts.shiftY, rbOpts.width, rbOpts.height);
m_gammaProgram.Bind(0.0f); //m_gammaProgram.Bind();
BoundTextureDraw2D(Width, Height); BoundTextureDraw2D(Width, Height);
glViewport(0, 0, Width, Height); glViewport(0, 0, Width, Height);
@ -1550,7 +1529,7 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget()
void CocoaOpenGLFrameBuffer::SetSmoothPicture(const bool smooth) void CocoaOpenGLFrameBuffer::SetSmoothPicture(const bool smooth)
{ {
FHardwareTexture& texture = m_renderTarget.GetColorTexture(); FHardwareTexture& texture = m_renderTarget.GetColorTexture();
texture.Bind(0, 0); texture.Bind(0, 0, 0);
BoundTextureSetFilter(GL_TEXTURE_2D, smooth ? GL_LINEAR : GL_NEAREST); BoundTextureSetFilter(GL_TEXTURE_2D, smooth ? GL_LINEAR : GL_NEAREST);
} }

View file

@ -0,0 +1,90 @@
/*
** sdlglvideo.h
**
**---------------------------------------------------------------------------
** Copyright 2012-2014 Alexey Lysiuk
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
// IMPORTANT NOTE!
// This file was intentially named sdlglvideo.h but it has nothing with SDL
// The name was selected to avoid spreding of changes over the project
// The same applies to SDLGLFB class
// See gl/system/gl_framebuffer.h for details about its usage
#ifndef COCOA_SDLGLVIDEO_H_INCLUDED
#define COCOA_SDLGLVIDEO_H_INCLUDED
#include "v_video.h"
#include "gl/shaders/gl_shader.h"
#include "gl/textures/gl_hwtexture.h"
class SDLGLFB : public DFrameBuffer
{
public:
// This must have the same parameters as the Windows version, even if they are not used!
SDLGLFB(void *hMonitor, int width, int height, int, int, bool fullscreen);
~SDLGLFB();
virtual bool Lock(bool buffered = true);
virtual void Unlock();
virtual bool IsLocked();
virtual bool IsFullscreen();
virtual void SetVSync(bool vsync);
int GetTrueHeight() { return GetHeight(); }
protected:
int m_lock;
bool m_isUpdatePending;
bool m_supportsGamma;
FShader m_gammaProgram;
FHardwareTexture m_gammaTexture;
static const size_t GAMMA_TABLE_SIZE = 256;
uint32_t m_gammaTable[GAMMA_TABLE_SIZE];
SDLGLFB();
void InitializeState();
bool CanUpdate();
void SwapBuffers();
void SetGammaTable(WORD* table);
};
#endif // COCOA_SDLGLVIDEO_H_INCLUDED