mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 23:32:02 +00:00
Fixed compilation of OS X with native backend
TODO: check Linux build
This commit is contained in:
parent
de6f13f0b4
commit
3816b46938
3 changed files with 100 additions and 34 deletions
|
@ -86,9 +86,6 @@ template <typename T>
|
|||
inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); }
|
||||
#define _access(a,b) access(a,b)
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LoadMenu
|
||||
|
|
|
@ -373,16 +373,7 @@ private:
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
struct CapabilityChecker
|
||||
{
|
||||
CapabilityChecker();
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class CocoaOpenGLFrameBuffer : public OpenGLFrameBuffer, private CapabilityChecker, private NonCopyable
|
||||
class CocoaOpenGLFrameBuffer : public OpenGLFrameBuffer, private NonCopyable
|
||||
{
|
||||
typedef OpenGLFrameBuffer Super;
|
||||
|
||||
|
@ -1164,12 +1155,14 @@ SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool
|
|||
, m_lock(-1)
|
||||
, m_isUpdatePending(false)
|
||||
, 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()
|
||||
: 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)
|
||||
: m_ID(0)
|
||||
, m_oldID(0)
|
||||
, m_texture(width, height, false, false, true, true)
|
||||
, m_texture(width, height, true)
|
||||
{
|
||||
glGenFramebuffersEXT(1, &m_ID);
|
||||
|
||||
|
@ -1439,20 +1432,6 @@ 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)
|
||||
: OpenGLFrameBuffer(hMonitor, width, height, bits, refreshHz, fullscreen)
|
||||
, m_renderTarget(width, height)
|
||||
|
@ -1525,8 +1504,8 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget()
|
|||
{
|
||||
m_renderTarget.Unbind();
|
||||
|
||||
m_renderTarget.GetColorTexture().Bind(0, 0);
|
||||
m_gammaTexture.Bind(1, 0);
|
||||
m_renderTarget.GetColorTexture().Bind(0, 0, 0);
|
||||
m_gammaTexture.Bind(1, 0, 0);
|
||||
|
||||
if (rbOpts.dirty)
|
||||
{
|
||||
|
@ -1540,7 +1519,7 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget()
|
|||
|
||||
glViewport(rbOpts.shiftX, rbOpts.shiftY, rbOpts.width, rbOpts.height);
|
||||
|
||||
m_gammaProgram.Bind(0.0f);
|
||||
m_gammaProgram.Bind();
|
||||
BoundTextureDraw2D(Width, Height);
|
||||
|
||||
glViewport(0, 0, Width, Height);
|
||||
|
@ -1550,7 +1529,7 @@ void CocoaOpenGLFrameBuffer::DrawRenderTarget()
|
|||
void CocoaOpenGLFrameBuffer::SetSmoothPicture(const bool smooth)
|
||||
{
|
||||
FHardwareTexture& texture = m_renderTarget.GetColorTexture();
|
||||
texture.Bind(0, 0);
|
||||
texture.Bind(0, 0, 0);
|
||||
BoundTextureSetFilter(GL_TEXTURE_2D, smooth ? GL_LINEAR : GL_NEAREST);
|
||||
}
|
||||
|
||||
|
|
90
src/posix/cocoa/sdlglvideo.h
Normal file
90
src/posix/cocoa/sdlglvideo.h
Normal 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
|
Loading…
Reference in a new issue