1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-30 08:24:05 +00:00

Use a 640x640 bounding box for screen coordinates.

A smaller bounding box allows rendering in higher resolutions. It should be made bigger if geometry is clipped.
This commit is contained in:
s2s 2021-05-09 19:31:00 +02:00 committed by Sergey Lipskiy
parent 7abf593da3
commit acfb569dea
5 changed files with 22 additions and 9 deletions

View File

@ -1,3 +1,4 @@
#include <iomanip> // for setprecision
#include <assert.h>
#include <Log.h>
#include <Config.h>
@ -7,6 +8,7 @@
#include "glsl_CombinerProgramImpl.h"
#include "glsl_CombinerProgramBuilder.h"
#include "glsl_CombinerProgramUniformFactory.h"
#include "GraphicsDrawer.h"
using namespace glsl;
@ -268,6 +270,9 @@ public:
m_part = ss.str();
}
m_part += "uniform lowp vec2 uVertexOffset; \n";
std::stringstream ss;
ss << "const lowp float screenSizeDims = " << std::setprecision(1) << std::fixed << SCREEN_SIZE_DIM << ";" << std::endl;
m_part += ss.str();
}
};
@ -513,8 +518,9 @@ public:
m_part = " gl_Position.z /= 8.0; \n";
}
m_part +=
" gl_Position.xy += uVertexOffset * vec2(gl_Position.w); \n"
" gl_Position.zw *= vec2(1024.0); \n"
" gl_Position.xy += uVertexOffset * vec2(gl_Position.w); \n"
" gl_Position.xy -= vec2(0.5*screenSizeDims) * gl_Position.ww; \n"
" gl_Position.xy /= vec2(0.5*screenSizeDims); \n"
"} \n"
;
}

View File

@ -20,7 +20,7 @@ namespace glsl {
bool _saveCombinerKeys(const graphics::Combiners & _combiners) const;
bool _loadFromCombinerKeys(graphics::Combiners & _combiners);
const u32 m_formatVersion = 0x34U;
const u32 m_formatVersion = 0x35U;
const u32 m_keysFormatVersion = 0x05;
const opengl::GLInfo & m_glinfo;
opengl::CachedUseProgram * m_useProgram;

View File

@ -253,10 +253,10 @@ void GraphicsDrawer::_updateViewport(const FrameBuffer* _pBuffer, const f32 scal
} else {
scaleX = scaleY = scale;
}
X = roundup(-1024.0f, scaleX);
Y = roundup(-1024.0f, scaleY);
WIDTH = roundup(2048.0f, scaleX);
HEIGHT = roundup(2048.0f, scaleY);
X = 0;
Y = 0;
WIDTH = roundup(SCREEN_SIZE_DIM, scaleX);
HEIGHT = roundup(SCREEN_SIZE_DIM, scaleY);
gfxContext.setViewport(X, Y, WIDTH, HEIGHT);
gSP.changed |= CHANGED_VIEWPORT;
}

View File

@ -20,6 +20,8 @@ struct FrameBuffer;
#define VERTBUFF_SIZE 256U
#define ELEMBUFF_SIZE 1024U
constexpr f32 SCREEN_SIZE_DIM = 640.0f;
enum class DrawingState
{
Non,

View File

@ -380,8 +380,13 @@ bool TexrectDrawer::draw()
const float t0 = m_lry / (float)m_pTexture->height;// +0.5f / (float)m_pTexture->height;
const float s1 = m_lrx / (float)m_pTexture->width;
const float t1 = m_uly / (float)m_pTexture->height;
const float W = 1024.0f;
const float Z = m_Z * 1024.0f;
const float W = 1.0f;
const float Z = m_Z;
constexpr float halfScreenSizeDims = SCREEN_SIZE_DIM * 0.5f;
m_ulx = (m_ulx - halfScreenSizeDims) / halfScreenSizeDims;
m_uly = (m_uly - halfScreenSizeDims) / halfScreenSizeDims;
m_lrx = (m_lrx - halfScreenSizeDims) / halfScreenSizeDims;
m_lry = (m_lry - halfScreenSizeDims) / halfScreenSizeDims;
drawer._updateViewport(m_pBuffer);