refactor screen_width/height
This commit is contained in:
parent
18cecc8d38
commit
7fe2ab720f
|
@ -39,8 +39,6 @@
|
|||
#include "hw/mem/mem_watch.h"
|
||||
#include "network/net_handshake.h"
|
||||
|
||||
extern int screen_width, screen_height;
|
||||
|
||||
std::atomic<bool> loading_canceled;
|
||||
settings_t settings;
|
||||
|
||||
|
@ -672,40 +670,11 @@ void loadGameSpecificSettings()
|
|||
config::Settings::instance().load(true);
|
||||
}
|
||||
|
||||
void dc_resize_renderer()
|
||||
{
|
||||
if (renderer == nullptr)
|
||||
return;
|
||||
float hres;
|
||||
int vres = config::RenderResolution;
|
||||
if (config::Widescreen && !config::Rotate90)
|
||||
{
|
||||
if (config::SuperWidescreen)
|
||||
hres = (float)config::RenderResolution * screen_width / screen_height ;
|
||||
else
|
||||
hres = config::RenderResolution * 16.f / 9.f;
|
||||
|
||||
}
|
||||
else if (config::Rotate90)
|
||||
{
|
||||
vres = vres * config::ScreenStretching / 100;
|
||||
hres = config::RenderResolution * 4.f / 3.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
hres = config::RenderResolution * 4.f * config::ScreenStretching / 3.f / 100.f;
|
||||
}
|
||||
if (!config::Rotate90)
|
||||
hres = std::roundf(hres / 2.f) * 2.f;
|
||||
DEBUG_LOG(RENDERER, "dc_resize_renderer: %d x %d", (int)hres, vres);
|
||||
renderer->Resize((int)hres, vres);
|
||||
}
|
||||
|
||||
void dc_resume()
|
||||
{
|
||||
SetMemoryHandlers();
|
||||
settings.aica.NoBatch = config::ForceWindowsCE || config::DSPEnabled || config::GGPOEnable;
|
||||
dc_resize_renderer();
|
||||
rend_resize_renderer();
|
||||
|
||||
EventManager::event(Event::Resume);
|
||||
if (!emuThread.thread.joinable())
|
||||
|
|
|
@ -50,7 +50,6 @@ bool dc_is_load_done();
|
|||
void dc_cancel_load();
|
||||
void dc_get_load_status();
|
||||
bool dc_is_running();
|
||||
void dc_resize_renderer();
|
||||
std::string dc_get_last_error();
|
||||
void dc_set_network_state(bool online);
|
||||
|
||||
|
|
|
@ -506,3 +506,31 @@ void rend_deserialize(void **data, unsigned int *total_size, serialize_version_e
|
|||
REICAST_US(fb_watch_addr_end);
|
||||
}
|
||||
}
|
||||
|
||||
void rend_resize_renderer()
|
||||
{
|
||||
if (renderer == nullptr)
|
||||
return;
|
||||
float hres;
|
||||
int vres = config::RenderResolution;
|
||||
if (config::Widescreen && !config::Rotate90)
|
||||
{
|
||||
if (config::SuperWidescreen)
|
||||
hres = (float)config::RenderResolution * settings.display.width / settings.display.height;
|
||||
else
|
||||
hres = config::RenderResolution * 16.f / 9.f;
|
||||
}
|
||||
else if (config::Rotate90)
|
||||
{
|
||||
vres = vres * config::ScreenStretching / 100;
|
||||
hres = config::RenderResolution * 4.f / 3.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
hres = config::RenderResolution * 4.f * config::ScreenStretching / 3.f / 100.f;
|
||||
}
|
||||
if (!config::Rotate90)
|
||||
hres = std::roundf(hres / 2.f) * 2.f;
|
||||
DEBUG_LOG(RENDERER, "rend_resize_renderer: %d x %d", (int)hres, vres);
|
||||
renderer->Resize((int)hres, vres);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ void rend_start_rollback();
|
|||
void rend_allow_rollback();
|
||||
void rend_serialize(void **data, unsigned int *total_size);
|
||||
void rend_deserialize(void **data, unsigned int *total_size, serialize_version_enum version);
|
||||
void rend_resize_renderer();
|
||||
|
||||
///////
|
||||
extern TA_context* _pvrrc;
|
||||
|
|
|
@ -1151,7 +1151,7 @@ void D3DRenderer::renderFramebuffer()
|
|||
device->ColorFill(backbuffer, 0, D3DCOLOR_ARGB(255, VO_BORDER_COL.Red, VO_BORDER_COL.Green, VO_BORDER_COL.Blue));
|
||||
int fx = 0;
|
||||
int sx = 0;
|
||||
float screenAR = (float)screen_width / screen_height;
|
||||
float screenAR = (float)settings.display.width / settings.display.height;
|
||||
int fbwidth = width;
|
||||
int fbheight = height;
|
||||
if (config::Rotate90)
|
||||
|
@ -1160,16 +1160,16 @@ void D3DRenderer::renderFramebuffer()
|
|||
if (renderAR > screenAR)
|
||||
fx = (int)roundf((fbwidth - screenAR * fbheight) / 2.f);
|
||||
else
|
||||
sx = (int)roundf((screen_width - renderAR * screen_height) / 2.f);
|
||||
sx = (int)roundf((settings.display.width - renderAR * settings.display.height) / 2.f);
|
||||
|
||||
if (!config::Rotate90)
|
||||
{
|
||||
RECT rs { 0, 0, (long)width, (long)height };
|
||||
RECT rd { 0, 0, screen_width, screen_height };
|
||||
RECT rd { 0, 0, settings.display.width, settings.display.height };
|
||||
if (sx != 0)
|
||||
{
|
||||
rd.left = sx;
|
||||
rd.right = screen_width - sx;
|
||||
rd.right = settings.display.width - sx;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1190,7 +1190,7 @@ void D3DRenderer::renderFramebuffer()
|
|||
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
glm::mat4 identity = glm::identity<glm::mat4>();
|
||||
glm::mat4 projection = glm::translate(glm::vec3(-1.f / screen_width, 1.f / screen_height, 0))
|
||||
glm::mat4 projection = glm::translate(glm::vec3(-1.f / settings.display.width, 1.f / settings.display.height, 0))
|
||||
* glm::rotate((float)M_PI_2, glm::vec3(0, 0, 1));
|
||||
|
||||
device->SetTransform(D3DTS_WORLD, (const D3DMATRIX *)&identity[0][0]);
|
||||
|
@ -1200,9 +1200,9 @@ void D3DRenderer::renderFramebuffer()
|
|||
device->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1);
|
||||
D3DVIEWPORT9 viewport;
|
||||
viewport.X = sx;
|
||||
viewport.Y = fx * screen_width / height;
|
||||
viewport.Width = screen_width - sx * 2;
|
||||
viewport.Height = screen_height - 2 * fx * screen_width / height;
|
||||
viewport.Y = fx * settings.display.width / height;
|
||||
viewport.Width = settings.display.width - sx * 2;
|
||||
viewport.Height = settings.display.height - 2 * fx * settings.display.width / height;
|
||||
viewport.MinZ = 0;
|
||||
viewport.MaxZ = 1;
|
||||
verifyWin(device->SetViewport(&viewport));
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "emulator.h"
|
||||
|
||||
DXContext theDXContext;
|
||||
extern int screen_width, screen_height; // FIXME
|
||||
|
||||
bool DXContext::Init(bool keepCurrentWindow)
|
||||
{
|
||||
|
@ -98,7 +97,7 @@ void DXContext::Present()
|
|||
{
|
||||
renderer = new D3DRenderer();
|
||||
renderer->Init();
|
||||
dc_resize_renderer();
|
||||
rend_resize_renderer();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -122,11 +121,11 @@ void DXContext::EndImGuiFrame()
|
|||
if (overlayOnly)
|
||||
{
|
||||
if (crosshairsNeeded() || config::FloatVMUs)
|
||||
overlay.draw(screen_width, screen_height, config::FloatVMUs, true);
|
||||
overlay.draw(settings.display.width, settings.display.height, config::FloatVMUs, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
overlay.draw(screen_width, screen_height, true, false);
|
||||
overlay.draw(settings.display.width, settings.display.height, true, false);
|
||||
}
|
||||
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
||||
pDevice->EndScene();
|
||||
|
@ -139,9 +138,9 @@ void DXContext::resize()
|
|||
return;
|
||||
RECT rect;
|
||||
GetClientRect(hWnd, &rect);
|
||||
d3dpp.BackBufferWidth = screen_width = rect.right;
|
||||
d3dpp.BackBufferHeight = screen_height = rect.bottom;
|
||||
if (screen_width == 0 || screen_height == 0)
|
||||
d3dpp.BackBufferWidth = settings.display.width = rect.right;
|
||||
d3dpp.BackBufferHeight = settings.display.height = rect.bottom;
|
||||
if (settings.display.width == 0 || settings.display.height == 0)
|
||||
// window minimized
|
||||
return;
|
||||
resetDevice();
|
||||
|
|
|
@ -66,9 +66,6 @@ const u32 SrcBlendGL[] =
|
|||
GL_ONE_MINUS_DST_ALPHA
|
||||
};
|
||||
|
||||
extern int screen_width;
|
||||
extern int screen_height;
|
||||
|
||||
PipelineShader* CurrentShader;
|
||||
u32 gcflip;
|
||||
|
||||
|
@ -686,7 +683,7 @@ bool render_output_framebuffer()
|
|||
glcache.Disable(GL_SCISSOR_TEST);
|
||||
int fx = 0;
|
||||
int sx = 0;
|
||||
float screenAR = (float)screen_width / screen_height;
|
||||
float screenAR = (float)settings.display.width / settings.display.height;
|
||||
int fbwidth = gl.ofbo.width;
|
||||
int fbheight = gl.ofbo.height;
|
||||
if (config::Rotate90)
|
||||
|
@ -695,16 +692,16 @@ bool render_output_framebuffer()
|
|||
if (renderAR > screenAR)
|
||||
fx = (int)roundf((fbwidth - screenAR * fbheight) / 2.f);
|
||||
else
|
||||
sx = (int)roundf((screen_width - renderAR * screen_height) / 2.f);
|
||||
sx = (int)roundf((settings.display.width - renderAR * settings.display.height) / 2.f);
|
||||
|
||||
if (gl.gl_major < 3 || config::Rotate90)
|
||||
{
|
||||
if (gl.ofbo.tex == 0)
|
||||
return false;
|
||||
if (sx != 0)
|
||||
glViewport(sx, 0, screen_width - sx * 2, screen_height);
|
||||
glViewport(sx, 0, settings.display.width - sx * 2, settings.display.height);
|
||||
else
|
||||
glViewport(-fx, 0, screen_width + fx * 2, screen_height);
|
||||
glViewport(-fx, 0, settings.display.width + fx * 2, settings.display.height);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, gl.ofbo.origFbo);
|
||||
glcache.ClearColor(VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
@ -720,7 +717,7 @@ bool render_output_framebuffer()
|
|||
glcache.ClearColor(VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glBlitFramebuffer(fx, 0, gl.ofbo.width - fx, gl.ofbo.height,
|
||||
sx, 0, screen_width - sx, screen_height,
|
||||
sx, 0, settings.display.width - sx, settings.display.height,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, gl.ofbo.origFbo);
|
||||
#endif
|
||||
|
|
|
@ -324,8 +324,6 @@ void main()
|
|||
GLCache glcache;
|
||||
gl_ctx gl;
|
||||
|
||||
int screen_width;
|
||||
int screen_height;
|
||||
GLuint fogTextureId;
|
||||
GLuint paletteTextureId;
|
||||
|
||||
|
@ -1014,14 +1012,14 @@ void OSD_DRAW(bool clear_screen)
|
|||
if (gl.OSD_SHADER.osd_tex != 0)
|
||||
{
|
||||
glcache.Disable(GL_SCISSOR_TEST);
|
||||
glViewport(0, 0, screen_width, screen_height);
|
||||
glViewport(0, 0, settings.display.width, settings.display.height);
|
||||
|
||||
if (clear_screen)
|
||||
{
|
||||
glcache.ClearColor(0.7f, 0.7f, 0.7f, 1.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
render_output_framebuffer();
|
||||
glViewport(0, 0, screen_width, screen_height);
|
||||
glViewport(0, 0, settings.display.width, settings.display.height);
|
||||
}
|
||||
|
||||
#ifndef GLES2
|
||||
|
@ -1036,12 +1034,12 @@ void OSD_DRAW(bool clear_screen)
|
|||
verify(glIsProgram(gl.OSD_SHADER.program));
|
||||
glcache.UseProgram(gl.OSD_SHADER.program);
|
||||
|
||||
float scale_h = screen_height / 480.f;
|
||||
float offs_x = (screen_width - scale_h * 640.f) / 2.f;
|
||||
float scale_h = settings.display.height / 480.f;
|
||||
float offs_x = (settings.display.width - scale_h * 640.f) / 2.f;
|
||||
float scale[4];
|
||||
scale[0] = 2.f / (screen_width / scale_h);
|
||||
scale[0] = 2.f / (settings.display.width / scale_h);
|
||||
scale[1]= -2.f / 480.f;
|
||||
scale[2]= 1.f - 2.f * offs_x / screen_width;
|
||||
scale[2]= 1.f - 2.f * offs_x / settings.display.width;
|
||||
scale[3]= -1.f;
|
||||
glUniform4fv(gl.OSD_SHADER.scale, 1, scale);
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ void gui_init()
|
|||
|
||||
// TODO Linux, iOS, ...
|
||||
#endif
|
||||
INFO_LOG(RENDERER, "Screen DPI is %d, size %d x %d. Scaling by %.2f", screen_dpi, screen_width, screen_height, scaling);
|
||||
INFO_LOG(RENDERER, "Screen DPI is %d, size %d x %d. Scaling by %.2f", screen_dpi, settings.display.width, settings.display.height, scaling);
|
||||
|
||||
EventManager::listen(Event::Resume, emuEventCallback);
|
||||
EventManager::listen(Event::Start, emuEventCallback);
|
||||
|
@ -304,8 +304,8 @@ static void ImGui_Impl_NewFrame()
|
|||
else if (config::RendererType.isDirectX())
|
||||
ImGui_ImplDX9_NewFrame();
|
||||
#endif
|
||||
ImGui::GetIO().DisplaySize.x = screen_width;
|
||||
ImGui::GetIO().DisplaySize.y = screen_height;
|
||||
ImGui::GetIO().DisplaySize.x = settings.display.width;
|
||||
ImGui::GetIO().DisplaySize.y = settings.display.height;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
|
@ -324,7 +324,7 @@ static void ImGui_Impl_NewFrame()
|
|||
if (kb_key[port][i] != 0)
|
||||
io.KeysDown[kb_key[port][i]] = true;
|
||||
}
|
||||
if (mouseX < 0 || mouseX >= screen_width || mouseY < 0 || mouseY >= screen_height)
|
||||
if (mouseX < 0 || mouseX >= settings.display.width || mouseY < 0 || mouseY >= settings.display.height)
|
||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
else
|
||||
io.MousePos = ImVec2(mouseX, mouseY);
|
||||
|
@ -2407,7 +2407,7 @@ void gui_display_osd()
|
|||
displayCrosshairs();
|
||||
if (config::FloatVMUs)
|
||||
display_vmus();
|
||||
// gui_plot_render_time(screen_width, screen_height);
|
||||
// gui_plot_render_time(settings.display.width, settings.display.height);
|
||||
if (ggpo::active() && config::NetworkStats)
|
||||
ggpo::displayStats();
|
||||
|
||||
|
@ -2534,10 +2534,10 @@ std::pair<float, float> getCrosshairPosition(int playerNum)
|
|||
fx = t;
|
||||
std::swap(width, height);
|
||||
}
|
||||
float scale = height / screen_height;
|
||||
float scale = height / settings.display.height;
|
||||
fy /= scale;
|
||||
scale /= config::ScreenStretching / 100.f;
|
||||
fx = fx / scale + (screen_width - width / scale) / 2.f;
|
||||
fx = fx / scale + (settings.display.width - width / scale) / 2.f;
|
||||
|
||||
return std::make_pair(fx, fy);
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
#include "dx9/dxcontext.h"
|
||||
#include "gui.h"
|
||||
|
||||
extern int screen_width, screen_height;
|
||||
|
||||
typedef void (*StringCallback)(bool cancelled, std::string selection);
|
||||
|
||||
void select_file_popup(const char *prompt, StringCallback callback,
|
||||
|
|
|
@ -70,7 +70,7 @@ bool mainui_rend_frame()
|
|||
void mainui_init()
|
||||
{
|
||||
rend_init_renderer();
|
||||
dc_resize_renderer();
|
||||
rend_resize_renderer();
|
||||
}
|
||||
|
||||
void mainui_term()
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
extern int screen_width, screen_height;
|
||||
|
||||
// Dreamcast:
|
||||
// +Y is down
|
||||
// Open GL:
|
||||
|
@ -82,7 +80,7 @@ public:
|
|||
constexpr int rttFlipY = System == COORD_DIRECTX ? -1 : 1;
|
||||
constexpr int framebufferFlipY = System == COORD_DIRECTX ? -1 : 1;
|
||||
|
||||
renderViewport = { width == 0 ? screen_width : width, height == 0 ? screen_height : height };
|
||||
renderViewport = { width == 0 ? settings.display.width : width, height == 0 ? settings.display.height : height };
|
||||
this->renderingContext = renderingContext;
|
||||
|
||||
GetFramebufferScaling(false, scale_x, scale_y);
|
||||
|
|
|
@ -1029,7 +1029,7 @@ void VulkanContext::DoSwapAutomation()
|
|||
u8* img = (u8*)device->mapMemory(*deviceMemory, 0, VK_WHOLE_SIZE);
|
||||
img += subresourceLayout.offset;
|
||||
|
||||
u8 *end = img + screen_width * screen_height * 4;
|
||||
u8 *end = img + settings.display.width * settings.display.height * 4;
|
||||
if (!supportsBlit && colorFormat == vk::Format::eB8G8R8A8Unorm)
|
||||
{
|
||||
for (u8 *p = img; p < end; p += 4)
|
||||
|
@ -1045,7 +1045,7 @@ void VulkanContext::DoSwapAutomation()
|
|||
for (u8 *p = img; p < end; p += 4)
|
||||
p[3] = 0xff;
|
||||
}
|
||||
dump_screenshot(img, screen_width, screen_height, true, subresourceLayout.rowPitch, false);
|
||||
dump_screenshot(img, settings.display.width, settings.display.height, true, subresourceLayout.rowPitch, false);
|
||||
|
||||
device->unmapMemory(*deviceMemory);
|
||||
}
|
||||
|
@ -1089,10 +1089,10 @@ void VulkanContext::SetWindowSize(u32 width, u32 height)
|
|||
// In this case, the context becomes invalid but we keep the previous
|
||||
// dimensions to not confuse the renderer and imgui
|
||||
if (width != 0)
|
||||
screen_width = width;
|
||||
settings.display.width = width;
|
||||
|
||||
if (height != 0)
|
||||
screen_height = height;
|
||||
settings.display.height = height;
|
||||
|
||||
SetResized();
|
||||
}
|
||||
|
|
|
@ -47,8 +47,6 @@ public:
|
|||
#include "rend/TexCache.h"
|
||||
#include "overlay.h"
|
||||
|
||||
extern int screen_width, screen_height;
|
||||
|
||||
struct ImDrawData;
|
||||
void ImGui_ImplVulkan_RenderDrawData(ImDrawData *draw_data);
|
||||
static vk::Format findDepthFormat(vk::PhysicalDevice physicalDevice);
|
||||
|
@ -80,7 +78,7 @@ public:
|
|||
vk::RenderPass GetRenderPass() const { return *renderPass; }
|
||||
vk::CommandBuffer GetCurrentCommandBuffer() const { return *commandBuffers[GetCurrentImageIndex()]; }
|
||||
vk::DescriptorPool GetDescriptorPool() const { return *descriptorPool; }
|
||||
vk::Extent2D GetViewPort() const { return { (u32)screen_width, (u32)screen_height }; }
|
||||
vk::Extent2D GetViewPort() const { return { (u32)settings.display.width, (u32)settings.display.height }; }
|
||||
size_t GetSwapChainSize() const { return imageViews.size(); }
|
||||
int GetCurrentImageIndex() const { return currentImage; }
|
||||
void WaitIdle() const;
|
||||
|
|
|
@ -190,13 +190,13 @@ public:
|
|||
GetContext()->BeginRenderPass();
|
||||
GetContext()->PresentLastFrame();
|
||||
}
|
||||
const float dc2s_scale_h = screen_height / 480.0f;
|
||||
const float sidebarWidth = (screen_width - dc2s_scale_h * 640.0f) / 2;
|
||||
const float dc2s_scale_h = settings.display.height / 480.0f;
|
||||
const float sidebarWidth = (settings.display.width - dc2s_scale_h * 640.0f) / 2;
|
||||
|
||||
std::vector<OSDVertex> osdVertices = GetOSDVertices();
|
||||
const float x1 = 2.0f / (screen_width / dc2s_scale_h);
|
||||
const float x1 = 2.0f / (settings.display.width / dc2s_scale_h);
|
||||
const float y1 = 2.0f / 480;
|
||||
const float x2 = 1 - 2 * sidebarWidth / screen_width;
|
||||
const float x2 = 1 - 2 * sidebarWidth / settings.display.width;
|
||||
const float y2 = 1;
|
||||
for (OSDVertex& vtx : osdVertices)
|
||||
{
|
||||
|
@ -208,9 +208,9 @@ public:
|
|||
cmdBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, osdPipeline.GetPipeline());
|
||||
|
||||
osdPipeline.BindDescriptorSets(cmdBuffer);
|
||||
const vk::Viewport viewport(0, 0, (float)screen_width, (float)screen_height, 0, 1.f);
|
||||
const vk::Viewport viewport(0, 0, (float)settings.display.width, (float)settings.display.height, 0, 1.f);
|
||||
cmdBuffer.setViewport(0, 1, &viewport);
|
||||
const vk::Rect2D scissor({ 0, 0 }, { (u32)screen_width, (u32)screen_height });
|
||||
const vk::Rect2D scissor({ 0, 0 }, { (u32)settings.display.width, (u32)settings.display.height });
|
||||
cmdBuffer.setScissor(0, 1, &scissor);
|
||||
osdBuffer->upload(osdVertices.size() * sizeof(OSDVertex), osdVertices.data());
|
||||
const vk::DeviceSize zero = 0;
|
||||
|
|
|
@ -511,8 +511,8 @@ bool sdl_recreate_window(u32 flags)
|
|||
ERROR_LOG(COMMON, "Window creation failed: %s", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
screen_width = window_width * hdpiScaling;
|
||||
screen_height = window_height * hdpiScaling;
|
||||
settings.display.width = window_width * hdpiScaling;
|
||||
settings.display.height = window_height * hdpiScaling;
|
||||
|
||||
#if !defined(GLES) && !defined(_WIN32) && !defined(__SWITCH__)
|
||||
// Set the window icon
|
||||
|
|
|
@ -331,6 +331,11 @@ struct settings_t
|
|||
u32 flash_size;
|
||||
} platform;
|
||||
|
||||
struct {
|
||||
int width = 640;
|
||||
int height = 480;
|
||||
} display;
|
||||
|
||||
struct
|
||||
{
|
||||
bool disable_nvmem;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#define CALLBACK
|
||||
#endif
|
||||
|
||||
extern int screen_width, screen_height;
|
||||
HWND getNativeHwnd();
|
||||
|
||||
namespace rawinput {
|
||||
|
@ -206,7 +205,7 @@ RawMouse::RawMouse(int maple_port, const std::string& name, const std::string& u
|
|||
std::replace(this->_unique_id.begin(), this->_unique_id.end(), ']', '_');
|
||||
loadMapping();
|
||||
|
||||
setAbsPos(screen_width / 2, screen_height / 2, screen_width, screen_height);
|
||||
setAbsPos(settings.display.width / 2, settings.display.height / 2, settings.display.width, settings.display.height);
|
||||
}
|
||||
|
||||
void RawMouse::buttonInput(Button button, u16 flags, u16 downFlag, u16 upFlag)
|
||||
|
@ -225,7 +224,7 @@ void RawMouse::updateState(RAWMOUSE* state)
|
|||
|
||||
POINT pt { long(state->lLastX / 65535.0f * width), long(state->lLastY / 65535.0f * height) };
|
||||
ScreenToClient(getNativeHwnd(), &pt);
|
||||
setAbsPos(pt.x, pt.y, screen_width, screen_height);
|
||||
setAbsPos(pt.x, pt.y, settings.display.width, settings.display.height);
|
||||
}
|
||||
else if (state->lLastX != 0 || state->lLastY != 0)
|
||||
setRelPos(state->lLastX, state->lLastY);
|
||||
|
|
|
@ -252,7 +252,6 @@ static int window_x, window_y;
|
|||
// Width and height of the window
|
||||
#define DEFAULT_WINDOW_WIDTH 1280
|
||||
#define DEFAULT_WINDOW_HEIGHT 720
|
||||
extern int screen_width, screen_height;
|
||||
static bool window_maximized = false;
|
||||
|
||||
static void centerMouse()
|
||||
|
@ -314,8 +313,8 @@ static LRESULT CALLBACK WndProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM
|
|||
return 1;
|
||||
|
||||
case WM_SIZE:
|
||||
screen_width = LOWORD(lParam);
|
||||
screen_height = HIWORD(lParam);
|
||||
settings.display.width = LOWORD(lParam);
|
||||
settings.display.height = HIWORD(lParam);
|
||||
window_maximized = (wParam & SIZE_MAXIMIZED) != 0;
|
||||
#ifdef USE_VULKAN
|
||||
theVulkanContext.SetResized();
|
||||
|
@ -366,7 +365,7 @@ static LRESULT CALLBACK WndProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM
|
|||
{
|
||||
int xPos = GET_X_LPARAM(lParam);
|
||||
int yPos = GET_Y_LPARAM(lParam);
|
||||
mouse->setAbsPos(xPos, yPos, screen_width, screen_height);
|
||||
mouse->setAbsPos(xPos, yPos, settings.display.width, settings.display.height);
|
||||
|
||||
if (wParam & MK_LBUTTON)
|
||||
mouse->setButton(Button::LEFT_BUTTON, true);
|
||||
|
@ -460,14 +459,14 @@ void CreateMainWindow()
|
|||
MessageBox(0, "Failed to register the window class", "Error", MB_OK | MB_ICONEXCLAMATION);
|
||||
else
|
||||
windowClassRegistered = true;
|
||||
screen_width = cfgLoadInt("window", "width", DEFAULT_WINDOW_WIDTH);
|
||||
screen_height = cfgLoadInt("window", "height", DEFAULT_WINDOW_HEIGHT);
|
||||
settings.display.width = cfgLoadInt("window", "width", DEFAULT_WINDOW_WIDTH);
|
||||
settings.display.height = cfgLoadInt("window", "height", DEFAULT_WINDOW_HEIGHT);
|
||||
window_maximized = cfgLoadBool("window", "maximized", false);
|
||||
}
|
||||
|
||||
// Create the eglWindow
|
||||
RECT sRect;
|
||||
SetRect(&sRect, 0, 0, screen_width, screen_height);
|
||||
SetRect(&sRect, 0, 0, settings.display.width, settings.display.height);
|
||||
AdjustWindowRectEx(&sRect, WS_OVERLAPPEDWINDOW, false, 0);
|
||||
|
||||
hWnd = CreateWindow(WINDOW_CLASS, VER_EMUNAME, WS_VISIBLE | WS_OVERLAPPEDWINDOW | (window_maximized ? WS_MAXIMIZE : 0),
|
||||
|
@ -769,10 +768,10 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
TermRenderApi();
|
||||
destroyMainWindow();
|
||||
cfgSaveBool("window", "maximized", window_maximized);
|
||||
if (!window_maximized && screen_width != 0 && screen_height != 0)
|
||||
if (!window_maximized && settings.display.width != 0 && settings.display.height != 0)
|
||||
{
|
||||
cfgSaveInt("window", "width", screen_width);
|
||||
cfgSaveInt("window", "height", screen_height);
|
||||
cfgSaveInt("window", "width", settings.display.width);
|
||||
cfgSaveInt("window", "height", settings.display.height);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -169,8 +169,8 @@ bool EGLGraphicsContext::Init()
|
|||
eglQuerySurface(display, surface, EGL_HEIGHT, &h);
|
||||
NOTICE_LOG(RENDERER, "eglQuerySurface: %d - %d", w, h);
|
||||
|
||||
screen_width = w;
|
||||
screen_height = h;
|
||||
settings.display.width = w;
|
||||
settings.display.height = h;
|
||||
|
||||
#ifdef TARGET_PANDORA
|
||||
fbdev = open("/dev/fb0", O_RDONLY);
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
#include "types.h"
|
||||
|
||||
void do_swap_automation();
|
||||
// FIXME
|
||||
extern int screen_width, screen_height;
|
||||
|
||||
class GLGraphicsContext
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ bool SDLGLGraphicsContext::Init()
|
|||
}
|
||||
SDL_GL_MakeCurrent(window, NULL);
|
||||
|
||||
SDL_GL_GetDrawableSize(window, &screen_width, &screen_height);
|
||||
SDL_GL_GetDrawableSize(window, &settings.display.width, &settings.display.height);
|
||||
|
||||
float ddpi, hdpi, vdpi;
|
||||
if (!SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(window), &ddpi, &hdpi, &vdpi))
|
||||
|
@ -129,9 +129,9 @@ void SDLGLGraphicsContext::Swap()
|
|||
SDL_GL_SwapWindow(window);
|
||||
|
||||
// Check if drawable has been resized
|
||||
SDL_GL_GetDrawableSize(window, &screen_width, &screen_height);
|
||||
SDL_GL_GetDrawableSize(window, &settings.display.width, &settings.display.height);
|
||||
#ifdef __SWITCH__
|
||||
float newScaling = screen_height == 720 ? 1.5f : 1.0f;
|
||||
float newScaling = settings.display.height == 720 ? 1.5f : 1.0f;
|
||||
if (newScaling != scaling)
|
||||
{
|
||||
// Restart the UI to take the new scaling factor into account
|
||||
|
|
|
@ -111,8 +111,8 @@ bool WGLGraphicsContext::Init()
|
|||
|
||||
RECT r;
|
||||
GetClientRect(ourWindow, &r);
|
||||
screen_width = r.right - r.left;
|
||||
screen_height = r.bottom - r.top;
|
||||
settings.display.width = r.right - r.left;
|
||||
settings.display.height = r.bottom - r.top;
|
||||
|
||||
if (rv)
|
||||
PostInit();
|
||||
|
|
|
@ -81,7 +81,7 @@ bool XGLGraphicsContext::Init()
|
|||
Window win;
|
||||
int temp;
|
||||
unsigned int tempu;
|
||||
XGetGeometry(display, window, &win, &temp, &temp, (u32 *)&screen_width, (u32 *)&screen_height, &tempu, &tempu);
|
||||
XGetGeometry(display, window, &win, &temp, &temp, (u32 *)&settings.display.width, (u32 *)&settings.display.height, &tempu, &tempu);
|
||||
|
||||
#ifndef TEST_AUTOMATION
|
||||
swapOnVSync = config::VSync;
|
||||
|
@ -173,7 +173,7 @@ void XGLGraphicsContext::Swap()
|
|||
Window win;
|
||||
int temp;
|
||||
unsigned int tempu;
|
||||
XGetGeometry(display, window, &win, &temp, &temp, (u32 *)&screen_width, (u32 *)&screen_height, &tempu, &tempu);
|
||||
XGetGeometry(display, window, &win, &temp, &temp, (u32 *)&settings.display.width, (u32 *)&settings.display.height, &tempu, &tempu);
|
||||
}
|
||||
|
||||
void XGLGraphicsContext::Term()
|
||||
|
|
|
@ -85,8 +85,6 @@ extern "C" JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_screenDpi(
|
|||
screen_dpi = screenDpi;
|
||||
}
|
||||
|
||||
extern int screen_width,screen_height;
|
||||
|
||||
std::shared_ptr<AndroidMouse> mouse;
|
||||
|
||||
float vjoy_pos[15][8];
|
||||
|
@ -348,8 +346,8 @@ extern "C" JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendinitNa
|
|||
}
|
||||
else
|
||||
{
|
||||
screen_width = width;
|
||||
screen_height = height;
|
||||
settings.display.width = width;
|
||||
settings.display.height = height;
|
||||
mainui_reinit();
|
||||
}
|
||||
}
|
||||
|
@ -579,7 +577,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_periph_InputDevi
|
|||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_mouseEvent(JNIEnv *env, jobject obj, jint xpos, jint ypos, jint buttons)
|
||||
{
|
||||
mouse->setAbsPos(xpos, ypos, screen_width, screen_height);
|
||||
mouse->setAbsPos(xpos, ypos, settings.display.width, settings.display.height);
|
||||
mouse->setButton(Mouse::LEFT_BUTTON, (buttons & 1) != 0);
|
||||
mouse->setButton(Mouse::RIGHT_BUTTON, (buttons & 2) != 0);
|
||||
mouse->setButton(Mouse::MIDDLE_BUTTON, (buttons & 4) != 0);
|
||||
|
|
|
@ -66,7 +66,6 @@ void common_linux_setup();
|
|||
|
||||
@end
|
||||
|
||||
extern int screen_width,screen_height;
|
||||
extern int screen_dpi;
|
||||
|
||||
@implementation FlycastViewController
|
||||
|
@ -180,10 +179,10 @@ extern int screen_dpi;
|
|||
self.iCadeReader.active = YES;
|
||||
// TODO iCade handlers
|
||||
|
||||
screen_width = roundf([[UIScreen mainScreen] nativeBounds].size.width);
|
||||
screen_height = roundf([[UIScreen mainScreen] nativeBounds].size.height);
|
||||
if (screen_width < screen_height)
|
||||
std::swap(screen_width, screen_height);
|
||||
settings.display.width = roundf([[UIScreen mainScreen] nativeBounds].size.width);
|
||||
settings.display.height = roundf([[UIScreen mainScreen] nativeBounds].size.height);
|
||||
if (settings.display.width < settings.display.height)
|
||||
std::swap(settings.display.width, settings.display.height);
|
||||
float scale = 1;
|
||||
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
|
||||
scale = [[UIScreen mainScreen] scale];
|
||||
|
|
|
@ -113,7 +113,6 @@ void emu_dc_resume()
|
|||
dc_resume();
|
||||
}
|
||||
|
||||
extern int screen_width,screen_height;
|
||||
extern bool rend_framePending();
|
||||
|
||||
bool emu_frame_pending()
|
||||
|
@ -138,8 +137,8 @@ bool emu_vsync_enabled()
|
|||
|
||||
bool emu_single_frame(int w, int h)
|
||||
{
|
||||
screen_width = w;
|
||||
screen_height = h;
|
||||
settings.display.width = w;
|
||||
settings.display.height = h;
|
||||
|
||||
//For DelayFrameSwapping: use while loop to call multple mainui_rend_frame() until rend_swap_frame(u32 fb_r_sof1)
|
||||
int counter = 0;
|
||||
|
@ -236,8 +235,8 @@ void emu_gles_init(int width, int height)
|
|||
displayResolution.height = CGDisplayPixelsHigh(displayID);
|
||||
scaling = displayNativeSize.width / displayResolution.width;
|
||||
|
||||
screen_width = width;
|
||||
screen_height = height;
|
||||
settings.display.width = width;
|
||||
settings.display.height = height;
|
||||
|
||||
InitRenderApi();
|
||||
mainui_init();
|
||||
|
|
|
@ -549,7 +549,7 @@ static void update_variables(bool first_startup)
|
|||
if (!first_startup && previous_renderer != config::RendererType) {
|
||||
rend_term_renderer();
|
||||
rend_init_renderer();
|
||||
dc_resize_renderer();
|
||||
rend_resize_renderer();
|
||||
}
|
||||
|
||||
if (first_startup)
|
||||
|
@ -803,14 +803,14 @@ static void update_variables(bool first_startup)
|
|||
retro_system_av_info avinfo;
|
||||
setAVInfo(avinfo);
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &avinfo);
|
||||
dc_resize_renderer();
|
||||
rend_resize_renderer();
|
||||
}
|
||||
else if (prevFramebufferWidth != framebufferWidth || prevFramebufferHeight != framebufferHeight || geometryChanged)
|
||||
{
|
||||
retro_game_geometry geometry;
|
||||
setGameGeometry(geometry);
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry);
|
||||
dc_resize_renderer();
|
||||
rend_resize_renderer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -928,7 +928,7 @@ static void context_reset()
|
|||
rend_term_renderer();
|
||||
theGLContext.Init();
|
||||
rend_init_renderer();
|
||||
dc_resize_renderer();
|
||||
rend_resize_renderer();
|
||||
}
|
||||
|
||||
static void context_destroy()
|
||||
|
@ -1383,7 +1383,7 @@ static void retro_vk_context_reset()
|
|||
theVulkanContext.Init((retro_hw_render_interface_vulkan *)vulkan);
|
||||
rend_term_renderer();
|
||||
rend_init_renderer();
|
||||
dc_resize_renderer();
|
||||
rend_resize_renderer();
|
||||
}
|
||||
|
||||
static void retro_vk_context_destroy()
|
||||
|
|
Loading…
Reference in New Issue