mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Remove global g_xres and x_yres
Some checks are pending
Some checks are pending
Instead query g_VideoMode where needed. As both g_xres and g_yres aren't global anymore remove static from UpdateRenderer. While at it use more desicriptive names: GetXRes -> GetWindowWidth, GetYRes -> GetWindowHeight. This reduces the amount of variables tracking width and height by one each. Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
b588b62304
commit
99bbc24265
17 changed files with 50 additions and 63 deletions
|
|
@ -32,6 +32,7 @@
|
||||||
#include "ps/Game.h"
|
#include "ps/Game.h"
|
||||||
#include "ps/Globals.h"
|
#include "ps/Globals.h"
|
||||||
#include "ps/Hotkey.h"
|
#include "ps/Hotkey.h"
|
||||||
|
#include "ps/VideoMode.h"
|
||||||
#include "ps/World.h"
|
#include "ps/World.h"
|
||||||
#include "renderer/Renderer.h"
|
#include "renderer/Renderer.h"
|
||||||
#include "renderer/SceneRenderer.h"
|
#include "renderer/SceneRenderer.h"
|
||||||
|
|
@ -47,8 +48,6 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
extern int g_xres, g_yres;
|
|
||||||
|
|
||||||
// Maximum distance outside the edge of the map that the camera's
|
// Maximum distance outside the edge of the map that the camera's
|
||||||
// focus point can be moved
|
// focus point can be moved
|
||||||
static const float CAMERA_EDGE_MARGIN = 2.0f * TERRAIN_TILE_SIZE;
|
static const float CAMERA_EDGE_MARGIN = 2.0f * TERRAIN_TILE_SIZE;
|
||||||
|
|
@ -105,8 +104,8 @@ CCameraController::CCameraController(CCamera& camera)
|
||||||
SViewPort vp;
|
SViewPort vp;
|
||||||
vp.m_X = 0;
|
vp.m_X = 0;
|
||||||
vp.m_Y = 0;
|
vp.m_Y = 0;
|
||||||
vp.m_Width = g_xres;
|
vp.m_Width = g_VideoMode.GetWindowWidth();
|
||||||
vp.m_Height = g_yres;
|
vp.m_Height = g_VideoMode.GetWindowHeight();
|
||||||
m_Camera.SetViewPort(vp);
|
m_Camera.SetViewPort(vp);
|
||||||
|
|
||||||
SetCameraProjection();
|
SetCameraProjection();
|
||||||
|
|
@ -206,12 +205,12 @@ void CCameraController::Update(const float deltaRealTime)
|
||||||
|
|
||||||
if (g_mouse_active && m_ViewScrollMouseDetectDistance > 0)
|
if (g_mouse_active && m_ViewScrollMouseDetectDistance > 0)
|
||||||
{
|
{
|
||||||
if (g_mouse_x >= g_xres - m_ViewScrollMouseDetectDistance && g_mouse_x < g_xres)
|
if (g_mouse_x >= g_VideoMode.GetWindowWidth() - m_ViewScrollMouseDetectDistance && g_mouse_x < g_VideoMode.GetWindowWidth())
|
||||||
moveRightward += m_ViewScrollSpeed * deltaRealTime;
|
moveRightward += m_ViewScrollSpeed * deltaRealTime;
|
||||||
else if (g_mouse_x < m_ViewScrollMouseDetectDistance && g_mouse_x >= 0)
|
else if (g_mouse_x < m_ViewScrollMouseDetectDistance && g_mouse_x >= 0)
|
||||||
moveRightward -= m_ViewScrollSpeed * deltaRealTime;
|
moveRightward -= m_ViewScrollSpeed * deltaRealTime;
|
||||||
|
|
||||||
if (g_mouse_y >= g_yres - m_ViewScrollMouseDetectDistance && g_mouse_y < g_yres)
|
if (g_mouse_y >= g_VideoMode.GetWindowHeight() - m_ViewScrollMouseDetectDistance && g_mouse_y < g_VideoMode.GetWindowHeight())
|
||||||
moveForward -= m_ViewScrollSpeed * deltaRealTime;
|
moveForward -= m_ViewScrollSpeed * deltaRealTime;
|
||||||
else if (g_mouse_y < m_ViewScrollMouseDetectDistance && g_mouse_y >= 0)
|
else if (g_mouse_y < m_ViewScrollMouseDetectDistance && g_mouse_y >= 0)
|
||||||
moveForward += m_ViewScrollSpeed * deltaRealTime;
|
moveForward += m_ViewScrollSpeed * deltaRealTime;
|
||||||
|
|
|
||||||
|
|
@ -461,7 +461,7 @@ IGUIObject* CGUI::FindObjectUnderMouse()
|
||||||
|
|
||||||
CSize2D CGUI::GetWindowSize() const
|
CSize2D CGUI::GetWindowSize() const
|
||||||
{
|
{
|
||||||
return CSize2D{static_cast<float>(g_xres) / g_VideoMode.GetScale(), static_cast<float>(g_yres) / g_VideoMode.GetScale() };
|
return CSize2D{static_cast<float>(g_VideoMode.GetWindowWidth()) / g_VideoMode.GetScale(), static_cast<float>(g_VideoMode.GetWindowHeight()) / g_VideoMode.GetScale() };
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGUI::SendFocusMessage(EGUIMessageType msgType)
|
void CGUI::SendFocusMessage(EGUIMessageType msgType)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2025 Wildfire Games.
|
/* Copyright (C) 2026 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
|
|
@ -34,8 +34,6 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
extern int g_xres, g_yres;
|
|
||||||
|
|
||||||
// TODO Gee: CRect => CPoint ?
|
// TODO Gee: CRect => CPoint ?
|
||||||
void SGenerateTextImage::SetupSpriteCall(
|
void SGenerateTextImage::SetupSpriteCall(
|
||||||
const bool left, CGUIText::SSpriteCall& spriteCall, const float width, const float y,
|
const bool left, CGUIText::SSpriteCall& spriteCall, const float width, const float y,
|
||||||
|
|
|
||||||
|
|
@ -152,13 +152,13 @@ void CConsole::Init()
|
||||||
m_HistoryFile = L"config/console.txt";
|
m_HistoryFile = L"config/console.txt";
|
||||||
LoadHistory();
|
LoadHistory();
|
||||||
|
|
||||||
UpdateScreenSize(g_xres, g_yres);
|
UpdateScreenSize(g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight());
|
||||||
|
|
||||||
// Calculate and store the line spacing.
|
// Calculate and store the line spacing.
|
||||||
const CFontMetrics font{CStrIntern(m_consoleFont)};
|
const CFontMetrics font{CStrIntern(m_consoleFont)};
|
||||||
m_FontHeight = font.GetHeight();
|
m_FontHeight = font.GetHeight();
|
||||||
m_FontWidth = font.GetCharacterWidth(L'C');
|
m_FontWidth = font.GetCharacterWidth(L'C');
|
||||||
m_CharsPerPage = static_cast<size_t>(g_xres / m_FontWidth);
|
m_CharsPerPage = static_cast<size_t>(g_VideoMode.GetWindowWidth() / m_FontWidth);
|
||||||
// Fonts constains two dimensions: the full height, and the cap height.
|
// Fonts constains two dimensions: the full height, and the cap height.
|
||||||
// We are adding some offset to move the text up a bit, so it looks better in the console.
|
// We are adding some offset to move the text up a bit, so it looks better in the console.
|
||||||
m_FontOffset = font.GetCapHeight() / 2.f;
|
m_FontOffset = font.GetCapHeight() / 2.f;
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,6 @@
|
||||||
// (these variables are documented in the header.)
|
// (these variables are documented in the header.)
|
||||||
bool g_PauseOnFocusLoss = false;
|
bool g_PauseOnFocusLoss = false;
|
||||||
|
|
||||||
int g_xres, g_yres;
|
|
||||||
|
|
||||||
bool g_Quickstart = false;
|
bool g_Quickstart = false;
|
||||||
bool g_DisableAudio = false;
|
bool g_DisableAudio = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2025 Wildfire Games.
|
/* Copyright (C) 2026 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
|
|
@ -21,8 +21,6 @@
|
||||||
// flag to pause the game on window focus loss
|
// flag to pause the game on window focus loss
|
||||||
extern bool g_PauseOnFocusLoss;
|
extern bool g_PauseOnFocusLoss;
|
||||||
|
|
||||||
extern int g_xres, g_yres;
|
|
||||||
|
|
||||||
extern bool g_Quickstart;
|
extern bool g_Quickstart;
|
||||||
extern bool g_DisableAudio;
|
extern bool g_DisableAudio;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ void WriteSystemInfo(Renderer::Backend::IDevice* device, const utsname& un)
|
||||||
// graphics
|
// graphics
|
||||||
fprintf(f, "Video Card : %s\n", device->GetName().c_str());
|
fprintf(f, "Video Card : %s\n", device->GetName().c_str());
|
||||||
fprintf(f, "Video Driver : %s\n", device->GetDriverInformation().c_str());
|
fprintf(f, "Video Driver : %s\n", device->GetDriverInformation().c_str());
|
||||||
fprintf(f, "Video Mode : %dx%d:%d\n", g_VideoMode.GetXRes(), g_VideoMode.GetYRes(), g_VideoMode.GetBPP());
|
fprintf(f, "Video Mode : %dx%d:%d\n", g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight(), g_VideoMode.GetBPP());
|
||||||
|
|
||||||
#if CONFIG2_AUDIO
|
#if CONFIG2_AUDIO
|
||||||
if (g_SoundManager)
|
if (g_SoundManager)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "lib/timer.h"
|
#include "lib/timer.h"
|
||||||
#include "maths/Matrix3D.h"
|
#include "maths/Matrix3D.h"
|
||||||
#include "ps/Game.h"
|
#include "ps/Game.h"
|
||||||
|
#include "ps/VideoMode.h"
|
||||||
|
|
||||||
#include <SDL_events.h>
|
#include <SDL_events.h>
|
||||||
#include <SDL_mouse.h>
|
#include <SDL_mouse.h>
|
||||||
|
|
@ -39,8 +40,6 @@
|
||||||
// Same with right-click for finger 1.
|
// Same with right-click for finger 1.
|
||||||
#define EMULATE_FINGERS_WITH_MOUSE 0
|
#define EMULATE_FINGERS_WITH_MOUSE 0
|
||||||
|
|
||||||
extern int g_xres, g_yres;
|
|
||||||
|
|
||||||
// NOTE: All this code is currently just a basic prototype for testing;
|
// NOTE: All this code is currently just a basic prototype for testing;
|
||||||
// it might need significant redesigning for proper usage.
|
// it might need significant redesigning for proper usage.
|
||||||
|
|
||||||
|
|
@ -279,11 +278,11 @@ Input::Reaction CTouchInput::HandleEvent(const SDL_Event& ev)
|
||||||
ev.tfinger.x, ev.tfinger.y, ev.tfinger.dx, ev.tfinger.dy, ev.tfinger.pressure);
|
ev.tfinger.x, ev.tfinger.y, ev.tfinger.dx, ev.tfinger.dy, ev.tfinger.pressure);
|
||||||
|
|
||||||
if (ev.type == SDL_FINGERDOWN)
|
if (ev.type == SDL_FINGERDOWN)
|
||||||
OnFingerDown(ev.tfinger.fingerId, g_xres * ev.tfinger.x, g_yres * ev.tfinger.y);
|
OnFingerDown(ev.tfinger.fingerId, g_VideoMode.GetWindowWidth() * ev.tfinger.x, g_VideoMode.GetWindowHeight() * ev.tfinger.y);
|
||||||
else if (ev.type == SDL_FINGERUP)
|
else if (ev.type == SDL_FINGERUP)
|
||||||
OnFingerUp(ev.tfinger.fingerId, g_xres * ev.tfinger.x, g_yres * ev.tfinger.y);
|
OnFingerUp(ev.tfinger.fingerId, g_VideoMode.GetWindowWidth() * ev.tfinger.x, g_VideoMode.GetWindowHeight() * ev.tfinger.y);
|
||||||
else if (ev.type == SDL_FINGERMOTION)
|
else if (ev.type == SDL_FINGERMOTION)
|
||||||
OnFingerMotion(ev.tfinger.fingerId, g_xres * ev.tfinger.x, g_yres * ev.tfinger.y);
|
OnFingerMotion(ev.tfinger.fingerId, g_VideoMode.GetWindowWidth() * ev.tfinger.x, g_VideoMode.GetWindowHeight() * ev.tfinger.y);
|
||||||
return Input::Reaction::HANDLED;
|
return Input::Reaction::HANDLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -550,9 +550,6 @@ bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen)
|
||||||
|
|
||||||
m_IsFullscreen = fullscreen;
|
m_IsFullscreen = fullscreen;
|
||||||
|
|
||||||
g_xres = m_CurrentW;
|
|
||||||
g_yres = m_CurrentH;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -733,9 +730,9 @@ void CVideoMode::RecreateSwapChain()
|
||||||
if (m_BackendDevice)
|
if (m_BackendDevice)
|
||||||
{
|
{
|
||||||
char nameBuffer[64];
|
char nameBuffer[64];
|
||||||
snprintf(nameBuffer, std::size(nameBuffer), "SwapChain: %dx%d", g_xres, g_yres);
|
snprintf(nameBuffer, std::size(nameBuffer), "SwapChain: %dx%d", m_CurrentW, m_CurrentH);
|
||||||
m_SwapChain = m_BackendDevice->CreateSwapChain(
|
m_SwapChain = m_BackendDevice->CreateSwapChain(
|
||||||
nameBuffer, m_Window, g_xres, g_yres, m_ConfigVSync, std::move(m_SwapChain));
|
nameBuffer, m_Window, m_CurrentW, m_CurrentH, m_ConfigVSync, std::move(m_SwapChain));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -876,8 +873,8 @@ void CVideoMode::UpdateRenderer(int w, int h)
|
||||||
if (w < 2) w = 2; // avoid GL errors caused by invalid sizes
|
if (w < 2) w = 2; // avoid GL errors caused by invalid sizes
|
||||||
if (h < 2) h = 2;
|
if (h < 2) h = 2;
|
||||||
|
|
||||||
g_xres = w;
|
m_CurrentW = w;
|
||||||
g_yres = h;
|
m_CurrentH = h;
|
||||||
|
|
||||||
SViewPort vp = { 0, 0, w, h };
|
SViewPort vp = { 0, 0, w, h };
|
||||||
|
|
||||||
|
|
@ -915,13 +912,13 @@ int CVideoMode::GetBestBPP()
|
||||||
return 32;
|
return 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CVideoMode::GetXRes() const
|
int CVideoMode::GetWindowWidth() const
|
||||||
{
|
{
|
||||||
ENSURE(m_IsInitialised);
|
ENSURE(m_IsInitialised);
|
||||||
return m_CurrentW;
|
return m_CurrentW;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CVideoMode::GetYRes() const
|
int CVideoMode::GetWindowHeight() const
|
||||||
{
|
{
|
||||||
ENSURE(m_IsInitialised);
|
ENSURE(m_IsInitialised);
|
||||||
return m_CurrentH;
|
return m_CurrentH;
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,10 @@ public:
|
||||||
* This should be called after the GL context has been resized.
|
* This should be called after the GL context has been resized.
|
||||||
* This can also be used when the GL context is managed externally, not via SDL.
|
* This can also be used when the GL context is managed externally, not via SDL.
|
||||||
*/
|
*/
|
||||||
static void UpdateRenderer(int w, int h);
|
void UpdateRenderer(int windowWidth, int windowHeight);
|
||||||
|
|
||||||
int GetXRes() const;
|
int GetWindowWidth() const;
|
||||||
int GetYRes() const;
|
int GetWindowHeight() const;
|
||||||
int GetBPP() const;
|
int GetBPP() const;
|
||||||
|
|
||||||
bool IsVSyncEnabled() const;
|
bool IsVSyncEnabled() const;
|
||||||
|
|
|
||||||
|
|
@ -447,7 +447,7 @@ CRenderer::CRenderer(Renderer::Backend::IDevice* device)
|
||||||
// Create terrain related stuff.
|
// Create terrain related stuff.
|
||||||
new CTerrainTextureManager(device);
|
new CTerrainTextureManager(device);
|
||||||
|
|
||||||
Open(g_xres, g_yres);
|
Open(g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight());
|
||||||
|
|
||||||
// Setup lighting environment. Since the Renderer accesses the
|
// Setup lighting environment. Since the Renderer accesses the
|
||||||
// lighting environment through a pointer, this has to be done before
|
// lighting environment through a pointer, this has to be done before
|
||||||
|
|
@ -697,7 +697,7 @@ void CRenderer::RenderFrameImpl(
|
||||||
|
|
||||||
void CRenderer::RenderFrame2D(const bool renderGUI, const bool renderLogger)
|
void CRenderer::RenderFrame2D(const bool renderGUI, const bool renderLogger)
|
||||||
{
|
{
|
||||||
CCanvas2D canvas(g_xres, g_yres, g_VideoMode.GetScale(), m->deviceCommandContext.get());
|
CCanvas2D canvas(g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight(), g_VideoMode.GetScale(), m->deviceCommandContext.get());
|
||||||
|
|
||||||
m->sceneRenderer.RenderTextOverlays(canvas);
|
m->sceneRenderer.RenderTextOverlays(canvas);
|
||||||
|
|
||||||
|
|
@ -745,7 +745,7 @@ void CRenderer::RenderScreenShot(const bool needsPresent)
|
||||||
VfsPath filename;
|
VfsPath filename;
|
||||||
vfs::NextNumberedFilename(g_VFS, filenameFormat, g_NextScreenShotNumber, filename);
|
vfs::NextNumberedFilename(g_VFS, filenameFormat, g_NextScreenShotNumber, filename);
|
||||||
|
|
||||||
const size_t width = static_cast<size_t>(g_xres), height = static_cast<size_t>(g_yres);
|
const size_t width = static_cast<size_t>(g_VideoMode.GetWindowWidth()), height = static_cast<size_t>(g_VideoMode.GetWindowHeight());
|
||||||
const size_t bpp = 24;
|
const size_t bpp = 24;
|
||||||
|
|
||||||
const size_t img_size = width * height * bpp / 8;
|
const size_t img_size = width * height * bpp / 8;
|
||||||
|
|
@ -804,12 +804,12 @@ void CRenderer::RenderBigScreenShot(const bool needsPresent)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_xres < tileWidth && g_yres < tileHeight)
|
if (g_VideoMode.GetWindowWidth() < tileWidth && g_VideoMode.GetWindowHeight() < tileHeight)
|
||||||
{
|
{
|
||||||
LOGWARNING(
|
LOGWARNING(
|
||||||
"The window size is too small for a big screenshot, increase the"
|
"The window size is too small for a big screenshot, increase the"
|
||||||
" window size %dx%d or decrease the tile size %dx%d",
|
" window size %dx%d or decrease the tile size %dx%d",
|
||||||
g_xres, g_yres, tileWidth, tileHeight);
|
g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight(), tileWidth, tileHeight);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -897,8 +897,8 @@ void CRenderer::RenderBigScreenShot(const bool needsPresent)
|
||||||
|
|
||||||
// Restore the viewport settings
|
// Restore the viewport settings
|
||||||
{
|
{
|
||||||
g_Renderer.Resize(g_xres, g_yres);
|
g_Renderer.Resize(g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight());
|
||||||
SViewPort vp = { 0, 0, g_xres, g_yres };
|
SViewPort vp = { 0, 0, g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight() };
|
||||||
g_Game->GetView()->SetViewport(vp);
|
g_Game->GetView()->SetViewport(vp);
|
||||||
g_Game->GetView()->SetCamera(oldCamera);
|
g_Game->GetView()->SetCamera(oldCamera);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
#include "ps/CStrIntern.h"
|
#include "ps/CStrIntern.h"
|
||||||
#include "ps/CStrInternStatic.h"
|
#include "ps/CStrInternStatic.h"
|
||||||
#include "ps/Profile.h"
|
#include "ps/Profile.h"
|
||||||
|
#include "ps/VideoMode.h"
|
||||||
#include "renderer/DebugRenderer.h"
|
#include "renderer/DebugRenderer.h"
|
||||||
#include "renderer/Renderer.h"
|
#include "renderer/Renderer.h"
|
||||||
#include "renderer/Scene.h"
|
#include "renderer/Scene.h"
|
||||||
|
|
@ -53,8 +54,6 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
extern int g_xres, g_yres;
|
|
||||||
|
|
||||||
// For debugging
|
// For debugging
|
||||||
static const bool g_DisablePreciseIntersections = false;
|
static const bool g_DisablePreciseIntersections = false;
|
||||||
|
|
||||||
|
|
@ -258,9 +257,9 @@ void SilhouetteRenderer::ComputeSubmissions(const CCamera& camera)
|
||||||
#if 0
|
#if 0
|
||||||
// For debugging ray-patch intersections - casts a ton of rays and draws
|
// For debugging ray-patch intersections - casts a ton of rays and draws
|
||||||
// a sphere where they intersect
|
// a sphere where they intersect
|
||||||
for (int y = 0; y < g_yres; y += 8)
|
for (int y = 0; y < g_VideoMode.GetWindowHeight(); y += 8)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < g_xres; x += 8)
|
for (int x = 0; x < g_VideoMode.GetWindowWidth(); x += 8)
|
||||||
{
|
{
|
||||||
SOverlaySphere sphere;
|
SOverlaySphere sphere;
|
||||||
sphere.m_Color = CColor(1, 0, 0, 1);
|
sphere.m_Color = CColor(1, 0, 0, 1);
|
||||||
|
|
@ -483,7 +482,7 @@ void SilhouetteRenderer::RenderDebugOverlays(
|
||||||
CMatrix3D m;
|
CMatrix3D m;
|
||||||
m.SetIdentity();
|
m.SetIdentity();
|
||||||
m.Scale(1.0f, -1.f, 1.0f);
|
m.Scale(1.0f, -1.f, 1.0f);
|
||||||
m.Translate(0.0f, (float)g_yres, -1000.0f);
|
m.Translate(0.0f, static_cast<float>(g_VideoMode.GetWindowHeight()), -1000.0f);
|
||||||
|
|
||||||
CMatrix3D proj;
|
CMatrix3D proj;
|
||||||
proj.SetOrtho(0.f, g_MaxCoord, 0.f, g_MaxCoord, -1.f, 1000.f);
|
proj.SetOrtho(0.f, g_MaxCoord, 0.f, g_MaxCoord, -1.f, 1000.f);
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include "ps/Game.h"
|
#include "ps/Game.h"
|
||||||
#include "ps/GameSetup/Config.h"
|
#include "ps/GameSetup/Config.h"
|
||||||
#include "ps/Pyrogenesis.h"
|
#include "ps/Pyrogenesis.h"
|
||||||
|
#include "ps/VideoMode.h"
|
||||||
#include "scriptinterface/FunctionWrapper.h"
|
#include "scriptinterface/FunctionWrapper.h"
|
||||||
#include "scriptinterface/Object.h"
|
#include "scriptinterface/Object.h"
|
||||||
#include "scriptinterface/Request.h"
|
#include "scriptinterface/Request.h"
|
||||||
|
|
@ -118,12 +119,12 @@ std::vector<entity_id_t> PickPlayerEntitiesInRect(int x0, int y0, int x1, int y1
|
||||||
|
|
||||||
std::vector<entity_id_t> PickPlayerEntitiesOnScreen(int player)
|
std::vector<entity_id_t> PickPlayerEntitiesOnScreen(int player)
|
||||||
{
|
{
|
||||||
return EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres, player, false);
|
return EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), 0, 0, g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight(), player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<entity_id_t> PickNonGaiaEntitiesOnScreen()
|
std::vector<entity_id_t> PickNonGaiaEntitiesOnScreen()
|
||||||
{
|
{
|
||||||
return EntitySelection::PickNonGaiaEntitiesInRect(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres, false);
|
return EntitySelection::PickNonGaiaEntitiesInRect(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), 0, 0, g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<entity_id_t> GetEntitiesWithStaticObstructionOnScreen()
|
std::vector<entity_id_t> GetEntitiesWithStaticObstructionOnScreen()
|
||||||
|
|
@ -136,7 +137,9 @@ std::vector<entity_id_t> GetEntitiesWithStaticObstructionOnScreen()
|
||||||
return cmpObstruction->GetObstructionType() == ICmpObstruction::STATIC;
|
return cmpObstruction->GetObstructionType() == ICmpObstruction::STATIC;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return EntitySelection::GetEntitiesWithComponentInRect<StaticObstructionFilter>(*g_Game->GetSimulation2(), IID_Obstruction, g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres);
|
return EntitySelection::GetEntitiesWithComponentInRect<StaticObstructionFilter>(*g_Game->GetSimulation2(),
|
||||||
|
IID_Obstruction, g_Game->GetView()->GetCamera(), 0, 0,
|
||||||
|
g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(const Script::Interface& scriptInterface, entity_pos_t x, entity_pos_t z)
|
JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(const Script::Interface& scriptInterface, entity_pos_t x, entity_pos_t z)
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,6 @@
|
||||||
|
|
||||||
class CTerrainTextureEntry;
|
class CTerrainTextureEntry;
|
||||||
|
|
||||||
extern int g_xres, g_yres;
|
|
||||||
|
|
||||||
struct ActorViewerImpl : public Scene
|
struct ActorViewerImpl : public Scene
|
||||||
{
|
{
|
||||||
NONCOPYABLE(ActorViewerImpl);
|
NONCOPYABLE(ActorViewerImpl);
|
||||||
|
|
@ -578,7 +576,7 @@ void ActorViewer::Render()
|
||||||
sceneRenderer.RenderSceneOverlays(deviceCommandContext);
|
sceneRenderer.RenderSceneOverlays(deviceCommandContext);
|
||||||
|
|
||||||
{
|
{
|
||||||
CCanvas2D canvas(g_xres, g_yres, g_VideoMode.GetScale(), deviceCommandContext);
|
CCanvas2D canvas(g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight(), g_VideoMode.GetScale(), deviceCommandContext);
|
||||||
g_Logger->Render(canvas);
|
g_Logger->Render(canvas);
|
||||||
g_ProfileViewer.RenderProfile(canvas);
|
g_ProfileViewer.RenderProfile(canvas);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ MESSAGEHANDLER(SetCanvas)
|
||||||
{
|
{
|
||||||
// Need to set the canvas size before possibly doing any rendering,
|
// Need to set the canvas size before possibly doing any rendering,
|
||||||
// else we'll get GL errors when trying to render to 0x0
|
// else we'll get GL errors when trying to render to 0x0
|
||||||
CVideoMode::UpdateRenderer(msg->width, msg->height);
|
g_VideoMode.UpdateRenderer(msg->width, msg->height);
|
||||||
|
|
||||||
g_AtlasGameLoop->glCanvas = msg->canvas;
|
g_AtlasGameLoop->glCanvas = msg->canvas;
|
||||||
Atlas_GLSetCurrent(const_cast<void*>(g_AtlasGameLoop->glCanvas));
|
Atlas_GLSetCurrent(const_cast<void*>(g_AtlasGameLoop->glCanvas));
|
||||||
|
|
@ -224,7 +224,7 @@ MESSAGEHANDLER(SetCanvas)
|
||||||
|
|
||||||
MESSAGEHANDLER(ResizeScreen)
|
MESSAGEHANDLER(ResizeScreen)
|
||||||
{
|
{
|
||||||
CVideoMode::UpdateRenderer(msg->width, msg->height);
|
g_VideoMode.UpdateRenderer(msg->width, msg->height);
|
||||||
|
|
||||||
#if OS_MACOSX
|
#if OS_MACOSX
|
||||||
// OS X seems to require this to update the GL canvas
|
// OS X seems to require this to update the GL canvas
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,8 @@ MESSAGEHANDLER(GuiMouseButtonEvent)
|
||||||
ev.button.clicks = msg->clicks;
|
ev.button.clicks = msg->clicks;
|
||||||
float x, y;
|
float x, y;
|
||||||
msg->pos->GetScreenSpace(x, y);
|
msg->pos->GetScreenSpace(x, y);
|
||||||
ev.button.x = static_cast<u16>(Clamp<int>(x, 0, g_xres));
|
ev.button.x = static_cast<u16>(Clamp<int>(x, 0, g_VideoMode.GetWindowWidth()));
|
||||||
ev.button.y = static_cast<u16>(Clamp<int>(y, 0, g_yres));
|
ev.button.y = static_cast<u16>(Clamp<int>(y, 0, g_VideoMode.GetWindowHeight()));
|
||||||
g_VideoMode.m_InputManager.DispatchEvent(ev);
|
g_VideoMode.m_InputManager.DispatchEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,8 +136,8 @@ MESSAGEHANDLER(GuiMouseMotionEvent)
|
||||||
ev.type = SDL_MOUSEMOTION;
|
ev.type = SDL_MOUSEMOTION;
|
||||||
float x, y;
|
float x, y;
|
||||||
msg->pos->GetScreenSpace(x, y);
|
msg->pos->GetScreenSpace(x, y);
|
||||||
ev.motion.x = static_cast<u16>(Clamp<int>(x, 0, g_xres));
|
ev.motion.x = static_cast<u16>(Clamp<int>(x, 0, g_VideoMode.GetWindowWidth()));
|
||||||
ev.motion.y = static_cast<u16>(Clamp<int>(y, 0, g_yres));
|
ev.motion.y = static_cast<u16>(Clamp<int>(y, 0, g_VideoMode.GetWindowHeight()));
|
||||||
g_VideoMode.m_InputManager.DispatchEvent(ev);
|
g_VideoMode.m_InputManager.DispatchEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,6 @@
|
||||||
|
|
||||||
extern void (*Atlas_GLSwapBuffers)(void* context);
|
extern void (*Atlas_GLSwapBuffers)(void* context);
|
||||||
|
|
||||||
extern int g_xres, g_yres;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void AtlasView::SetParam(const std::wstring& /*name*/, bool /*value*/)
|
void AtlasView::SetParam(const std::wstring& /*name*/, bool /*value*/)
|
||||||
|
|
@ -93,7 +91,7 @@ void AtlasViewActor::Update(float realFrameLength)
|
||||||
|
|
||||||
void AtlasViewActor::Render()
|
void AtlasViewActor::Render()
|
||||||
{
|
{
|
||||||
SViewPort vp = { 0, 0, g_xres, g_yres };
|
SViewPort vp = { 0, 0, g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight() };
|
||||||
CCamera camera{GetCamera()};
|
CCamera camera{GetCamera()};
|
||||||
camera.SetViewPort(vp);
|
camera.SetViewPort(vp);
|
||||||
camera.SetPerspectiveProjection(2.f, 512.f, DEGTORAD(20.f));
|
camera.SetPerspectiveProjection(2.f, 512.f, DEGTORAD(20.f));
|
||||||
|
|
@ -246,7 +244,7 @@ void AtlasViewGame::Render()
|
||||||
if (!swapChain || !swapChain->IsValid() || !swapChain->AcquireNextBackbuffer())
|
if (!swapChain || !swapChain->IsValid() || !swapChain->AcquireNextBackbuffer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SViewPort vp = { 0, 0, g_xres, g_yres };
|
SViewPort vp = { 0, 0, g_VideoMode.GetWindowWidth(), g_VideoMode.GetWindowHeight() };
|
||||||
CCamera camera{GetCamera()};
|
CCamera camera{GetCamera()};
|
||||||
camera.SetViewPort(vp);
|
camera.SetViewPort(vp);
|
||||||
camera.SetProjectionFromCamera(g_Game->GetView()->GetCamera());
|
camera.SetProjectionFromCamera(g_Game->GetView()->GetCamera());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue