2021-03-09 23:51:28 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @file display.h
|
|
|
|
* Display for graphics. This is the game window, distinct from the runtime console.
|
|
|
|
*/
|
|
|
|
|
2021-08-09 19:16:39 -04:00
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
2022-06-16 22:46:12 -04:00
|
|
|
#include "common/util/Assert.h"
|
|
|
|
#include "gfx.h"
|
|
|
|
|
2021-08-09 19:16:39 -04:00
|
|
|
// a GfxDisplay class is equivalent to a window that displays stuff. This holds an actual internal
|
|
|
|
// window pointer used by whichever renderer. It also contains functions for setting and
|
|
|
|
// retrieving certain window parameters.
|
2022-06-16 22:46:12 -04:00
|
|
|
// Maybe this is better implemented as an abstract class and renderers would have overrides?
|
2021-08-09 19:16:39 -04:00
|
|
|
class GfxDisplay {
|
|
|
|
const char* m_title;
|
|
|
|
|
2021-12-30 18:48:37 -05:00
|
|
|
// NOT actual size! just backups
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
|
|
|
// same here
|
|
|
|
int m_xpos;
|
|
|
|
int m_ypos;
|
|
|
|
|
2022-06-16 22:46:12 -04:00
|
|
|
GfxDisplayMode m_fullscreen_target_mode = GfxDisplayMode::Windowed;
|
|
|
|
GfxDisplayMode m_last_fullscreen_mode;
|
2021-12-30 18:48:37 -05:00
|
|
|
int m_fullscreen_screen;
|
|
|
|
int m_fullscreen_target_screen;
|
2022-06-17 19:39:33 -04:00
|
|
|
bool m_imgui_visible;
|
2021-12-30 18:48:37 -05:00
|
|
|
|
2022-06-16 22:46:12 -04:00
|
|
|
protected:
|
|
|
|
bool m_main;
|
|
|
|
|
2021-08-09 19:16:39 -04:00
|
|
|
public:
|
2022-06-16 22:46:12 -04:00
|
|
|
virtual ~GfxDisplay() {}
|
|
|
|
|
2022-06-18 15:07:40 -04:00
|
|
|
virtual void* get_window() const = 0;
|
|
|
|
virtual void set_size(int w, int h) = 0;
|
|
|
|
virtual void update_fullscreen(GfxDisplayMode mode, int screen) = 0;
|
|
|
|
virtual void get_scale(float* x, float* y) = 0;
|
|
|
|
virtual void get_screen_size(int vmode_idx, s32* w, s32* h, s32* c) = 0;
|
|
|
|
virtual void get_position(int* x, int* y) = 0;
|
|
|
|
virtual void get_size(int* w, int* h) = 0;
|
|
|
|
virtual GfxDisplayMode get_fullscreen() = 0;
|
|
|
|
virtual void render() = 0;
|
2022-06-21 19:21:51 -04:00
|
|
|
virtual void set_lock(bool lock) = 0;
|
2022-06-16 22:46:12 -04:00
|
|
|
bool is_active() const { return get_window() != nullptr; }
|
2021-08-09 19:16:39 -04:00
|
|
|
void set_title(const char* title);
|
2021-08-13 20:06:16 -04:00
|
|
|
const char* title() const { return m_title; }
|
2021-08-09 19:16:39 -04:00
|
|
|
|
2022-06-16 22:46:12 -04:00
|
|
|
bool fullscreen_pending() { return get_fullscreen() != m_fullscreen_target_mode; }
|
2021-12-30 18:48:37 -05:00
|
|
|
void fullscreen_flush() {
|
2022-06-16 22:46:12 -04:00
|
|
|
update_fullscreen(m_fullscreen_target_mode, m_fullscreen_target_screen);
|
|
|
|
// TODO no
|
2021-12-30 18:48:37 -05:00
|
|
|
m_fullscreen_screen = m_fullscreen_target_screen;
|
|
|
|
}
|
2022-06-16 22:46:12 -04:00
|
|
|
void set_fullscreen(GfxDisplayMode mode, int screen) {
|
2021-12-30 18:48:37 -05:00
|
|
|
m_fullscreen_target_mode = mode;
|
|
|
|
m_fullscreen_target_screen = screen;
|
|
|
|
}
|
2022-06-16 22:46:12 -04:00
|
|
|
void update_last_fullscreen_mode() { m_last_fullscreen_mode = get_fullscreen(); }
|
|
|
|
GfxDisplayMode last_fullscreen_mode() const { return m_last_fullscreen_mode; }
|
2022-04-11 18:38:54 -04:00
|
|
|
int fullscreen_screen() const { return m_fullscreen_screen; }
|
2022-06-17 19:39:33 -04:00
|
|
|
void set_imgui_visible(bool visible) { m_imgui_visible = visible; }
|
|
|
|
bool is_imgui_visible() const { return m_imgui_visible; }
|
2022-06-16 22:46:12 -04:00
|
|
|
bool windowed() { return get_fullscreen() == GfxDisplayMode::Windowed; }
|
2021-12-30 18:48:37 -05:00
|
|
|
void backup_params();
|
2022-06-16 22:46:12 -04:00
|
|
|
int width_backup() const { return m_width; }
|
|
|
|
int height_backup() const { return m_height; }
|
|
|
|
int xpos_backup() const { return m_xpos; }
|
|
|
|
int ypos_backup() const { return m_ypos; }
|
2021-12-30 18:48:37 -05:00
|
|
|
|
|
|
|
int width();
|
|
|
|
int height();
|
2021-08-09 19:16:39 -04:00
|
|
|
};
|
2021-03-09 23:51:28 -05:00
|
|
|
|
|
|
|
namespace Display {
|
|
|
|
|
2021-08-09 19:16:39 -04:00
|
|
|
// a list of displays. the first one is the "main" display, all others are spectator-like extra
|
|
|
|
// views.
|
|
|
|
extern std::vector<std::shared_ptr<GfxDisplay>> g_displays;
|
2021-03-09 23:51:28 -05:00
|
|
|
|
2021-08-09 19:16:39 -04:00
|
|
|
int InitMainDisplay(int width, int height, const char* title, GfxSettings& settings);
|
|
|
|
void KillDisplay(std::shared_ptr<GfxDisplay> display);
|
2021-08-13 20:06:16 -04:00
|
|
|
void KillMainDisplay();
|
2021-03-09 23:51:28 -05:00
|
|
|
|
2021-08-09 19:16:39 -04:00
|
|
|
std::shared_ptr<GfxDisplay> GetMainDisplay();
|
2021-03-09 23:51:28 -05:00
|
|
|
|
2021-08-09 19:16:39 -04:00
|
|
|
} // namespace Display
|