screen stretching always in final horiz direction. lightgun coords fix
gl: strech direct fb texture based on stretching and rotation Fix lighgun coords when stretching and/or rotating Dimension render size based on stretching and rotation vk: lightgun crosshair disappears near 0-edge -> scissoring x and y must be >= 0 always stretch horizontally even when rotating
This commit is contained in:
parent
685dcd1c8a
commit
06be0d927b
|
@ -1384,7 +1384,7 @@ maple_device* maple_Create(MapleDeviceType type)
|
|||
static void screenToNative(int& x, int& y, int width, int height)
|
||||
{
|
||||
float fx, fy;
|
||||
if ((float)width / height >= 640.f / 480.f)
|
||||
if (!config::Rotate90)
|
||||
{
|
||||
float scale = 480.f / height;
|
||||
fy = y * scale;
|
||||
|
@ -1416,7 +1416,7 @@ void SetMousePosition(int x, int y, int width, int height, u32 mouseId)
|
|||
{
|
||||
int t = y;
|
||||
y = x;
|
||||
x = height - t;
|
||||
x = height - 1 - t;
|
||||
std::swap(width, height);
|
||||
}
|
||||
screenToNative(x, y, width, height);
|
||||
|
|
|
@ -728,11 +728,21 @@ void dc_resume()
|
|||
SetMemoryHandlers();
|
||||
settings.aica.NoBatch = config::ForceWindowsCE || config::DSPEnabled;
|
||||
int hres;
|
||||
if ((config::Widescreen || cheatManager.isActive()) && !config::Rotate90)
|
||||
int vres = config::RenderResolution;
|
||||
if (config::Widescreen && !config::Rotate90)
|
||||
{
|
||||
hres = config::RenderResolution * 16 / 9;
|
||||
else
|
||||
}
|
||||
else if (config::Rotate90)
|
||||
{
|
||||
vres = vres * config::ScreenStretching / 100;
|
||||
hres = config::RenderResolution * 4 / 3;
|
||||
renderer->Resize(hres, config::RenderResolution);
|
||||
}
|
||||
else
|
||||
{
|
||||
hres = config::RenderResolution * 4 * config::ScreenStretching / 3 / 100;
|
||||
}
|
||||
renderer->Resize(hres, vres);
|
||||
|
||||
EventManager::event(Event::Resume);
|
||||
if (!emu_thread.thread.joinable())
|
||||
|
|
|
@ -637,7 +637,12 @@ void DrawStrips()
|
|||
|
||||
void DrawFramebuffer()
|
||||
{
|
||||
int sx = (int)roundf((gl.ofbo.width - 4.f / 3.f * gl.ofbo.height) / 2.f);
|
||||
float aspectRatio = 4.f / 3.f;
|
||||
if (config::Rotate90)
|
||||
aspectRatio /= config::ScreenStretching / 100.f;
|
||||
else
|
||||
aspectRatio *= config::ScreenStretching / 100.f;
|
||||
int sx = (int)roundf((gl.ofbo.width - aspectRatio * gl.ofbo.height) / 2.f);
|
||||
glViewport(sx, 0, gl.ofbo.width - sx * 2, gl.ofbo.height);
|
||||
drawQuad(fbTextureId, false, true);
|
||||
glcache.DeleteTextures(1, &fbTextureId);
|
||||
|
|
|
@ -2187,29 +2187,21 @@ std::pair<float, float> getCrosshairPosition(int playerNum)
|
|||
{
|
||||
float fx = mo_x_abs[playerNum];
|
||||
float fy = mo_y_abs[playerNum];
|
||||
int width = screen_width;
|
||||
int height = screen_height;
|
||||
float width = 640.f;
|
||||
float height = 480.f;
|
||||
|
||||
if (config::Rotate90)
|
||||
{
|
||||
float t = fy;
|
||||
fy = width - fx;
|
||||
fy = 639.f - fx;
|
||||
fx = t;
|
||||
std::swap(width, height);
|
||||
}
|
||||
if ((float)width / height >= 640.f / 480.f)
|
||||
{
|
||||
float scale = 480.f / height;
|
||||
fy /= scale;
|
||||
scale *= config::ScreenStretching / 100.f;
|
||||
fx = fx / scale + (width - 640.f / scale) / 2.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float scale = 640.f / width;
|
||||
fx /= scale;
|
||||
scale *= config::ScreenStretching / 100.f;
|
||||
fy = fy / scale + (height - 480.f / scale) / 2.f;
|
||||
}
|
||||
float scale = height / screen_height;
|
||||
fy /= scale;
|
||||
scale /= config::ScreenStretching / 100.f;
|
||||
fx = fx / scale + (screen_width - width / scale) / 2.f;
|
||||
|
||||
return std::make_pair(fx, fy);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,11 +137,22 @@ public:
|
|||
float y_coef;
|
||||
glm::mat4 trans_rot;
|
||||
|
||||
float dc2s_scale_h = renderViewport.y / 480.0f;
|
||||
if (config::Rotate90)
|
||||
{
|
||||
float dc2s_scale_h = renderViewport.x / 640.0f;
|
||||
|
||||
sidebarWidth = (renderViewport.x - dc2s_scale_h * 640.0f * screen_stretching) / 2;
|
||||
x_coef = 2.0f / (renderViewport.x / dc2s_scale_h * scale_x) * screen_stretching;
|
||||
y_coef = 2.0f / dcViewport.y * (invertY ? -1 : 1);
|
||||
sidebarWidth = 0;
|
||||
y_coef = 2.0f / (renderViewport.y / dc2s_scale_h * scale_y) * screen_stretching * (invertY ? -1 : 1);
|
||||
x_coef = 2.0f / dcViewport.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
float dc2s_scale_h = renderViewport.y / 480.0f;
|
||||
|
||||
sidebarWidth = (renderViewport.x - dc2s_scale_h * 640.0f * screen_stretching) / 2;
|
||||
x_coef = 2.0f / (renderViewport.x / dc2s_scale_h * scale_x) * screen_stretching;
|
||||
y_coef = 2.0f / dcViewport.y * (invertY ? -1 : 1);
|
||||
}
|
||||
trans_rot = glm::translate(glm::vec3(-1 + 2 * sidebarWidth / renderViewport.x, invertY ? 1 : -1, 0));
|
||||
|
||||
normalMatrix = trans_rot
|
||||
|
|
|
@ -69,7 +69,6 @@ const std::vector<vk::UniqueCommandBuffer>* VulkanOverlay::Prepare(vk::CommandPo
|
|||
{
|
||||
const u32* texData = getCrosshairTextureData();
|
||||
xhairTexture = createTexture(commandPool, 16, 16, (u8*)texData);
|
||||
// delete [] texData;
|
||||
}
|
||||
|
||||
return &commandBuffers[context->GetCurrentImageIndex()];
|
||||
|
@ -141,7 +140,8 @@ void VulkanOverlay::Draw(vk::Extent2D viewport, float scaling, bool vmu, bool cr
|
|||
y -= XHAIR_HEIGHT / 2;
|
||||
vk::Viewport viewport(x, y, XHAIR_WIDTH, XHAIR_HEIGHT);
|
||||
commandBuffer.setViewport(0, 1, &viewport);
|
||||
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(x, y), vk::Extent2D(XHAIR_WIDTH, XHAIR_HEIGHT)));
|
||||
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(std::max(0.f, x), std::max(0.f, y)),
|
||||
vk::Extent2D(XHAIR_WIDTH, XHAIR_HEIGHT)));
|
||||
u32 color = config::CrosshairColor[i];
|
||||
float xhairColor[4] {
|
||||
(color & 0xff) / 255.f,
|
||||
|
|
Loading…
Reference in New Issue