mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
a7eee4fdc9
* fix typo * more typo * shorten discord rpc text * allow expanding enums after the fact (untested) * make `game_text` work similar to subtitles * update progress decomp * update some types + `do-not-decompile` in bitfield * fixes and fall back to original progress code * update `progress` decomp with new enums * update config files * fix enums and debug menu * always allocate (but not use) a lot of particles * small rework to display mode options * revert resolution/aspect-ratio symbol mess * begin the override stuff * make `progress-draw` more readable * more fixes * codacy good boy points * first step overriding code * finish progress overrides, game options menu fully functional! * minor fixes * Update game.gp * Update sparticle-launcher.gc * clang * change camera controls text * oops * some cleanup * derp * nice job * implement menu scrolling lol * make scrollable menus less cramped, fix arrows * make some carousell things i guess * add msaa carousell to test * oops * Update progress-pc.gc * make `pc-get-screen-size` (untested) * resolution menu * input fixes * return when selecting resolution * scroll fixes * Update progress-pc.gc * add "fit to screen" button * bug * complete resolutions menu * aspect ratio menu * subtitles language * subtitle speaker * final adjustments * ref test * fix tests * fix ref! * reduce redundancy a bit * fix mem leaks? * save settings on progress exit * fix init reorder * remove unused code * rename goal project-like files to the project extension * sha display toggle * aspect ratio settings fixes * dont store text db's in compiler * properly save+load native aspect stuff
124 lines
4 KiB
C++
124 lines
4 KiB
C++
#pragma once
|
|
|
|
/*!
|
|
* @file gfx.h
|
|
* Graphics component for the runtime. Abstraction layer for the main graphics routines.
|
|
*/
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
#include "common/common_types.h"
|
|
#include "game/kernel/kboot.h"
|
|
#include "game/system/newpad.h"
|
|
|
|
// forward declarations
|
|
struct GfxSettings;
|
|
class GfxDisplay;
|
|
|
|
// enum for rendering pipeline
|
|
enum class GfxPipeline { Invalid = 0, OpenGL };
|
|
|
|
// module for the different rendering pipelines
|
|
struct GfxRendererModule {
|
|
std::function<int(GfxSettings&)> init;
|
|
std::function<std::shared_ptr<GfxDisplay>(int w, int h, const char* title, GfxSettings& settings)>
|
|
make_main_display;
|
|
std::function<void(GfxDisplay*)> kill_display;
|
|
std::function<void(GfxDisplay*)> render_display;
|
|
std::function<void(GfxDisplay*, int*, int*)> display_position;
|
|
std::function<void(GfxDisplay*, int*, int*)> display_size;
|
|
std::function<void(GfxDisplay*, int, int)> display_set_size;
|
|
std::function<void(GfxDisplay*, float*, float*)> display_scale;
|
|
std::function<void(GfxDisplay*, int, int)> set_fullscreen;
|
|
std::function<void(GfxDisplay*, int, int, s32*, s32*, s32*)> screen_size;
|
|
std::function<void()> exit;
|
|
std::function<u32()> vsync;
|
|
std::function<u32()> sync_path;
|
|
std::function<void(const void*, u32)> send_chain;
|
|
std::function<void(const u8*, int, u32)> texture_upload_now;
|
|
std::function<void(u32, u32, u32)> texture_relocate;
|
|
std::function<void()> poll_events;
|
|
std::function<void(const std::vector<std::string>&)> set_levels;
|
|
std::function<void(float)> set_pmode_alp;
|
|
GfxPipeline pipeline;
|
|
const char* name;
|
|
};
|
|
|
|
// store settings related to the gfx systems
|
|
struct GfxSettings {
|
|
// current version of the settings. this should be set up so that newer versions are always higher
|
|
// than older versions
|
|
// increment this whenever you change this struct.
|
|
// there's probably a smarter way to do this (automatically deduce size etc.)
|
|
static constexpr u64 CURRENT_VERSION = 0x0000'0000'0004'0001;
|
|
|
|
u64 version; // the version of this settings struct. MUST ALWAYS BE THE FIRST THING!
|
|
|
|
Pad::MappingInfo pad_mapping_info; // button mapping
|
|
Pad::MappingInfo pad_mapping_info_backup; // button mapping backup (see newpad.h)
|
|
|
|
int vsync; // (temp) number of screen update per frame
|
|
bool debug; // graphics debugging
|
|
|
|
GfxPipeline renderer = GfxPipeline::Invalid; // which rendering pipeline to use.
|
|
};
|
|
|
|
// runtime settings
|
|
struct GfxGlobalSettings {
|
|
// note: this is actually the size of the display that ISN'T letterboxed
|
|
// the excess space is what will be letterboxed away.
|
|
int lbox_w;
|
|
int lbox_h;
|
|
|
|
// current renderer
|
|
const GfxRendererModule* renderer;
|
|
|
|
// lod settings, used by bucket renderers
|
|
int lod_tfrag = 0;
|
|
int lod_tie = 0;
|
|
};
|
|
|
|
namespace Gfx {
|
|
|
|
extern GfxGlobalSettings g_global_settings;
|
|
extern GfxSettings g_settings;
|
|
// extern const std::vector<const GfxRendererModule*> renderers;
|
|
|
|
const GfxRendererModule* GetRenderer(GfxPipeline pipeline);
|
|
const GfxRendererModule* GetCurrentRenderer();
|
|
|
|
enum DisplayMode { Windowed = 0, Fullscreen = 1, Borderless = 2 };
|
|
|
|
u32 Init();
|
|
void Loop(std::function<bool()> f);
|
|
u32 Exit();
|
|
|
|
u32 vsync();
|
|
u32 sync_path();
|
|
void send_chain(const void* data, u32 offset);
|
|
void texture_upload_now(const u8* tpage, int mode, u32 s7_ptr);
|
|
void texture_relocate(u32 destination, u32 source, u32 format);
|
|
void set_levels(const std::vector<std::string>& levels);
|
|
void poll_events();
|
|
u64 get_window_width();
|
|
u64 get_window_height();
|
|
void set_window_size(u64 w, u64 h);
|
|
void get_window_scale(float* x, float* y);
|
|
int get_fullscreen();
|
|
void get_screen_size(s64 vmode_idx, s32* w, s32* h, s32* c);
|
|
void set_letterbox(int w, int h);
|
|
void set_fullscreen(DisplayMode mode, int screen);
|
|
void input_mode_set(u32 enable);
|
|
void input_mode_save();
|
|
s64 get_mapped_button(s64 pad, s64 button);
|
|
|
|
int PadIsPressed(Pad::Button button, int port);
|
|
int PadAnalogValue(Pad::Analog analog, int port);
|
|
|
|
// matching enum in kernel-defs.gc !!
|
|
enum class RendererTreeType { NONE = 0, TFRAG3 = 1, TIE3 = 2, INVALID };
|
|
void SetLod(RendererTreeType tree, int lod);
|
|
|
|
} // namespace Gfx
|