mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- cleaned up the video scale mode code a bit, in order to increase future flexibility.
This commit is contained in:
parent
f1a6ef9cc8
commit
30087f7cd7
9 changed files with 118 additions and 55 deletions
|
@ -944,6 +944,7 @@ set (PCH_SOURCES
|
|||
portal.cpp
|
||||
r_utility.cpp
|
||||
r_sky.cpp
|
||||
r_videoscale.cpp
|
||||
s_advsound.cpp
|
||||
s_environment.cpp
|
||||
s_playlist.cpp
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#include "gl/shaders/gl_postprocessshader.h"
|
||||
#include "gl/renderer/gl_2ddrawer.h"
|
||||
#include "gl/stereo3d/gl_stereo3d.h"
|
||||
#include "r_videoscale.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -153,8 +154,6 @@ EXTERN_CVAR(Float, vid_contrast)
|
|||
EXTERN_CVAR(Float, vid_saturation)
|
||||
EXTERN_CVAR(Int, gl_satformula)
|
||||
|
||||
bool ViewportLinearScale();
|
||||
|
||||
void FGLRenderer::RenderScreenQuad()
|
||||
{
|
||||
mVBO->BindVBO();
|
||||
|
|
|
@ -78,6 +78,8 @@ EXTERN_CVAR(Int, vid_scalemode)
|
|||
|
||||
CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE);
|
||||
|
||||
bool ViewportIsScaled43();
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Renderer interface
|
||||
|
@ -283,7 +285,7 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds)
|
|||
int screenWidth = framebuffer->GetWidth();
|
||||
int screenHeight = framebuffer->GetHeight();
|
||||
float scaleX, scaleY;
|
||||
if (vid_scalemode == 1 || vid_scalemode == 2)
|
||||
if (ViewportIsScaled43())
|
||||
{
|
||||
scaleX = MIN(clientWidth / (float)screenWidth, clientHeight / (screenHeight * 1.2f));
|
||||
scaleY = scaleX * 1.2f;
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "gl/gl_functions.h"
|
||||
#include "gl/renderer/gl_2ddrawer.h"
|
||||
#include "gl_debug.h"
|
||||
#include "r_videoscale.h"
|
||||
|
||||
EXTERN_CVAR (Float, vid_brightness)
|
||||
EXTERN_CVAR (Float, vid_contrast)
|
||||
|
@ -64,8 +65,6 @@ FGLRenderer *GLRenderer;
|
|||
void gl_LoadExtensions();
|
||||
void gl_PrintStartupLog();
|
||||
void gl_SetupMenu();
|
||||
int ViewportScaledWidth(int width);
|
||||
int ViewportScaledHeight(int height);
|
||||
|
||||
CUSTOM_CVAR(Int, vid_hwgamma, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include "gl/utility/gl_templates.h"
|
||||
#include "gl/gl_functions.h"
|
||||
#include "gl_debug.h"
|
||||
#include "r_videoscale.h"
|
||||
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
|
||||
|
@ -93,9 +94,6 @@ EXTERN_CVAR(Bool, vid_vsync)
|
|||
EXTERN_CVAR(Float, transsouls)
|
||||
EXTERN_CVAR(Int, vid_refreshrate)
|
||||
EXTERN_CVAR(Bool, gl_legacy_mode)
|
||||
EXTERN_CVAR(Int, vid_scalemode)
|
||||
|
||||
bool ViewportLinearScale();
|
||||
|
||||
#ifdef WIN32
|
||||
extern cycle_t BlitCycles;
|
||||
|
@ -104,9 +102,6 @@ extern cycle_t BlitCycles;
|
|||
void gl_LoadExtensions();
|
||||
void gl_PrintStartupLog();
|
||||
|
||||
int ViewportScaledWidth(int width);
|
||||
int ViewportScaledHeight(int height);
|
||||
|
||||
#ifndef WIN32
|
||||
// This has to be in this file because system headers conflict Doom headers
|
||||
DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool bgra, bool fullscreen)
|
||||
|
@ -729,7 +724,7 @@ void OpenGLSWFrameBuffer::Present()
|
|||
glViewport(0, 0, clientWidth, clientHeight);
|
||||
|
||||
float scaleX, scaleY;
|
||||
if (vid_scalemode == 1 || vid_scalemode == 2)
|
||||
if (ViewportIsScaled43())
|
||||
{
|
||||
scaleX = MIN(clientWidth / (float)Width, clientHeight / (Height * 1.2f));
|
||||
scaleY = scaleX * 1.2f;
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "sbar.h"
|
||||
#include "hardware.h"
|
||||
#include "vm.h"
|
||||
#include "r_videoscale.h"
|
||||
|
||||
/*=======================================
|
||||
*
|
||||
|
@ -123,46 +124,6 @@ CUSTOM_CVAR (Bool, vid_tft, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR (Int, vid_scalemode, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0 || self > 5)
|
||||
{
|
||||
self = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewportLinearScale()
|
||||
{
|
||||
return vid_scalemode == 4 || vid_scalemode == 5;
|
||||
}
|
||||
|
||||
int ViewportScaledWidth(int width)
|
||||
{
|
||||
switch (vid_scalemode)
|
||||
{
|
||||
default:
|
||||
case 0: return width;
|
||||
case 1: return 320;
|
||||
case 2: return 640;
|
||||
case 3: return (int)roundf(width * 0.5f);
|
||||
case 4: return (int)roundf(width * 0.75f);
|
||||
case 5: return width * 2;
|
||||
}
|
||||
}
|
||||
|
||||
int ViewportScaledHeight(int height)
|
||||
{
|
||||
switch (vid_scalemode)
|
||||
{
|
||||
default:
|
||||
case 0: return height;
|
||||
case 1: return 200;
|
||||
case 2: return 400;
|
||||
case 3: return (int)roundf(height * 0.5f);
|
||||
case 4: return (int)roundf(height * 0.75f);
|
||||
case 5: return height * 2;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
|
77
src/r_videoscale.cpp
Normal file
77
src/r_videoscale.cpp
Normal file
|
@ -0,0 +1,77 @@
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 2017 Magnus Norddahl
|
||||
// Copyright(C) 2017 Rachael Alexanderson
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "c_dispatch.h"
|
||||
#include "c_cvars.h"
|
||||
|
||||
CUSTOM_CVAR (Int, vid_scalemode, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0 || self > 5)
|
||||
{
|
||||
self = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewportLinearScale()
|
||||
{
|
||||
return vid_scalemode == 4 || vid_scalemode == 5;
|
||||
}
|
||||
|
||||
int ViewportScaledWidth(int width)
|
||||
{
|
||||
switch (vid_scalemode)
|
||||
{
|
||||
default:
|
||||
case 0: return width;
|
||||
case 1: return 320;
|
||||
case 2: return 640;
|
||||
case 3: return (int)roundf(width * 0.5f);
|
||||
case 4: return (int)roundf(width * 0.75f);
|
||||
case 5: return width * 2;
|
||||
}
|
||||
}
|
||||
|
||||
int ViewportScaledHeight(int height)
|
||||
{
|
||||
switch (vid_scalemode)
|
||||
{
|
||||
default:
|
||||
case 0: return height;
|
||||
case 1: return 200;
|
||||
case 2: return 400;
|
||||
case 3: return (int)roundf(height * 0.5f);
|
||||
case 4: return (int)roundf(height * 0.75f);
|
||||
case 5: return height * 2;
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewportIsScaled43()
|
||||
{
|
||||
switch (vid_scalemode)
|
||||
{
|
||||
default: return false;
|
||||
case 1:
|
||||
case 2: return true;
|
||||
}
|
||||
}
|
||||
|
31
src/r_videoscale.h
Normal file
31
src/r_videoscale.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 2017 Magnus Norddahl
|
||||
// Copyright(C) 2017 Rachael Alexanderson
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#ifndef __VIDEOSCALE_H__
|
||||
#define __VIDEOSCALE_H__
|
||||
EXTERN_CVAR (Int, vid_scalemode)
|
||||
bool ViewportLinearScale();
|
||||
int ViewportScaledWidth(int width);
|
||||
int ViewportScaledHeight(int height);
|
||||
bool ViewportIsScaled43();
|
||||
#endif //__VIDEOSCALE_H__
|
|
@ -83,14 +83,12 @@
|
|||
#include "menu/menu.h"
|
||||
#include "r_data/voxels.h"
|
||||
#include "vm.h"
|
||||
#include "r_videoscale.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_blendmethod)
|
||||
|
||||
int active_con_scale();
|
||||
|
||||
int ViewportScaledWidth(int width);
|
||||
int ViewportScaledHeight(int height);
|
||||
|
||||
FRenderer *Renderer;
|
||||
|
||||
EXTERN_CVAR (Bool, swtruecolor)
|
||||
|
|
Loading…
Reference in a new issue