mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-16 09:21:43 +00:00
Moved render buffer options definition to own header file
This is needed for GZDoom
This commit is contained in:
parent
f8dfdbd4a4
commit
2649b4c26a
2 changed files with 65 additions and 28 deletions
|
@ -63,6 +63,7 @@
|
||||||
#include "textures.h"
|
#include "textures.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "i_rbopts.h"
|
||||||
|
|
||||||
#undef Class
|
#undef Class
|
||||||
|
|
||||||
|
@ -92,6 +93,7 @@
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
RenderBufferOptions rbOpts;
|
||||||
|
|
||||||
CVAR(Bool, use_mouse, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
CVAR(Bool, use_mouse, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
CVAR(Bool, m_noprescale, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
CVAR(Bool, m_noprescale, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
|
@ -123,20 +125,6 @@ void I_ShutdownJoysticks();
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
struct FrameBufferParameters
|
|
||||||
{
|
|
||||||
float pixelScale;
|
|
||||||
|
|
||||||
float shiftX;
|
|
||||||
float shiftY;
|
|
||||||
|
|
||||||
float width;
|
|
||||||
float height;
|
|
||||||
};
|
|
||||||
|
|
||||||
FrameBufferParameters s_frameBufferParameters;
|
|
||||||
|
|
||||||
|
|
||||||
const int ARGC_MAX = 64;
|
const int ARGC_MAX = 64;
|
||||||
|
|
||||||
int s_argc;
|
int s_argc;
|
||||||
|
@ -619,8 +607,8 @@ void NSEventToGameMousePosition(NSEvent* inEvent, event_t* outEvent)
|
||||||
|
|
||||||
const CGFloat frameHeight = GetRealContentViewSize(window).height;
|
const CGFloat frameHeight = GetRealContentViewSize(window).height;
|
||||||
|
|
||||||
const CGFloat posX = ( viewPos.x - s_frameBufferParameters.shiftX) / s_frameBufferParameters.pixelScale;
|
const CGFloat posX = ( viewPos.x - rbOpts.shiftX) / rbOpts.pixelScale;
|
||||||
const CGFloat posY = (frameHeight - viewPos.y - s_frameBufferParameters.shiftY) / s_frameBufferParameters.pixelScale;
|
const CGFloat posY = (frameHeight - viewPos.y - rbOpts.shiftY) / rbOpts.pixelScale;
|
||||||
|
|
||||||
outEvent->data1 = static_cast< int >(posX);
|
outEvent->data1 = static_cast< int >(posX);
|
||||||
outEvent->data2 = static_cast< int >(posY);
|
outEvent->data2 = static_cast< int >(posY);
|
||||||
|
@ -1091,13 +1079,13 @@ static ApplicationDelegate* s_applicationDelegate;
|
||||||
const float pixelScaleFactorX = displayWidth / static_cast< float >(width );
|
const float pixelScaleFactorX = displayWidth / static_cast< float >(width );
|
||||||
const float pixelScaleFactorY = displayHeight / static_cast< float >(height);
|
const float pixelScaleFactorY = displayHeight / static_cast< float >(height);
|
||||||
|
|
||||||
s_frameBufferParameters.pixelScale = std::min(pixelScaleFactorX, pixelScaleFactorY);
|
rbOpts.pixelScale = std::min(pixelScaleFactorX, pixelScaleFactorY);
|
||||||
|
|
||||||
s_frameBufferParameters.width = width * s_frameBufferParameters.pixelScale;
|
rbOpts.width = width * rbOpts.pixelScale;
|
||||||
s_frameBufferParameters.height = height * s_frameBufferParameters.pixelScale;
|
rbOpts.height = height * rbOpts.pixelScale;
|
||||||
|
|
||||||
s_frameBufferParameters.shiftX = (displayWidth - s_frameBufferParameters.width ) / 2.0f;
|
rbOpts.shiftX = (displayWidth - rbOpts.width ) / 2.0f;
|
||||||
s_frameBufferParameters.shiftY = (displayHeight - s_frameBufferParameters.height) / 2.0f;
|
rbOpts.shiftY = (displayHeight - rbOpts.height) / 2.0f;
|
||||||
|
|
||||||
[m_window setLevel:NSMainMenuWindowLevel + 1];
|
[m_window setLevel:NSMainMenuWindowLevel + 1];
|
||||||
[m_window setStyleMask:NSBorderlessWindowMask];
|
[m_window setStyleMask:NSBorderlessWindowMask];
|
||||||
|
@ -1108,13 +1096,13 @@ static ApplicationDelegate* s_applicationDelegate;
|
||||||
|
|
||||||
- (void)windowedWithWidth:(int)width height:(int)height
|
- (void)windowedWithWidth:(int)width height:(int)height
|
||||||
{
|
{
|
||||||
s_frameBufferParameters.pixelScale = 1.0f;
|
rbOpts.pixelScale = 1.0f;
|
||||||
|
|
||||||
s_frameBufferParameters.width = static_cast< float >(width );
|
rbOpts.width = static_cast< float >(width );
|
||||||
s_frameBufferParameters.height = static_cast< float >(height);
|
rbOpts.height = static_cast< float >(height);
|
||||||
|
|
||||||
s_frameBufferParameters.shiftX = 0.0f;
|
rbOpts.shiftX = 0.0f;
|
||||||
s_frameBufferParameters.shiftY = 0.0f;
|
rbOpts.shiftY = 0.0f;
|
||||||
|
|
||||||
const NSSize windowPixelSize = NSMakeSize(width, height);
|
const NSSize windowPixelSize = NSMakeSize(width, height);
|
||||||
const NSSize windowSize = IsHiDPISupported()
|
const NSSize windowSize = IsHiDPISupported()
|
||||||
|
@ -1580,8 +1568,7 @@ static void ResetSoftwareViewport()
|
||||||
glViewport(0, 0, viewport[0], viewport[1]);
|
glViewport(0, 0, viewport[0], viewport[1]);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
glViewport(s_frameBufferParameters.shiftX, s_frameBufferParameters.shiftY,
|
glViewport(rbOpts.shiftX, rbOpts.shiftY, rbOpts.width, rbOpts.height);
|
||||||
s_frameBufferParameters.width, s_frameBufferParameters.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_WM_ToggleFullScreen(SDL_Surface* surface)
|
int SDL_WM_ToggleFullScreen(SDL_Surface* surface)
|
||||||
|
|
50
src/cocoa/i_rbopts.h
Normal file
50
src/cocoa/i_rbopts.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
** i_rbopts.h
|
||||||
|
**
|
||||||
|
**---------------------------------------------------------------------------
|
||||||
|
** Copyright 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.
|
||||||
|
**---------------------------------------------------------------------------
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_COCOA_I_RBOPTS_H_INCLUDED
|
||||||
|
#define SRC_COCOA_I_RBOPTS_H_INCLUDED
|
||||||
|
|
||||||
|
struct RenderBufferOptions
|
||||||
|
{
|
||||||
|
float pixelScale;
|
||||||
|
|
||||||
|
float shiftX;
|
||||||
|
float shiftY;
|
||||||
|
|
||||||
|
float width;
|
||||||
|
float height;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern RenderBufferOptions rbOpts;
|
||||||
|
|
||||||
|
#endif // SRC_COCOA_I_RBOPTS_H_INCLUDED
|
Loading…
Reference in a new issue