Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added different rendering options for when game window is not focused #631

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lang/Czech.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ FORCE_4BY3 = "Vždy 4:3"
PRELOAD_TEXTURES = "Načíst textury předem"
VSYNC = "VSync"
UNCAPPED_FRAMERATE = "Neomezené FPS"
RENDER_WHEN_UNFOCUSED = "Vykreslovat i když není aktivní"
RENDER_EVERYTHING = "Vše"
RENDER_HUD_AND_UI = "HUD a UI"
RENDER_NOTHING = "Nic"
FRAME_LIMIT = "FPS Limit"
FAST = "Optimalizované"
ACCURATE = "Přesné"
Expand Down
4 changes: 4 additions & 0 deletions lang/Dutch.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ FORCE_4BY3 = "Forceer 4:3"
PRELOAD_TEXTURES = "Textures Voorladen"
VSYNC = "VSync"
UNCAPPED_FRAMERATE = "Ongelimiteerde Framerate"
RENDER_WHEN_UNFOCUSED = "Renderen als niet gefocust"
RENDER_EVERYTHING = "Alles"
RENDER_HUD_AND_UI = "HUD en UI"
RENDER_NOTHING = "Niets"
FRAME_LIMIT = "Frame limiet"
FAST = "Snel"
ACCURATE = "Accuraat"
Expand Down
4 changes: 4 additions & 0 deletions lang/English.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ FORCE_4BY3 = "Force 4:3"
PRELOAD_TEXTURES = "Preload Textures"
VSYNC = "VSync"
UNCAPPED_FRAMERATE = "Uncapped Framerate"
RENDER_WHEN_UNFOCUSED = "Render When Unfocused"
RENDER_EVERYTHING = "Everything"
RENDER_HUD_AND_UI = "HUD and UI"
RENDER_NOTHING = "Nothing"
FRAME_LIMIT = "Frame Limit"
FAST = "Fast"
ACCURATE = "Accurate"
Expand Down
4 changes: 4 additions & 0 deletions lang/French.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ FORCE_4BY3 = "Forcer l'affichage 4:3"
PRELOAD_TEXTURES = "Textures Préchargées"
VSYNC = "VSync"
UNCAPPED_FRAMERATE = "FPS Illimités"
RENDER_WHEN_UNFOCUSED = "Rendre quand non focalisé"
RENDER_EVERYTHING = "Tout"
RENDER_HUD_AND_UI = "HUD et UI"
RENDER_NOTHING = "Rien"
FRAME_LIMIT = "Limite de FPS"
FAST = "Rapide"
ACCURATE = "Précis"
Expand Down
4 changes: 4 additions & 0 deletions lang/German.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ FORCE_4BY3 = "Erzwinge 4:3"
PRELOAD_TEXTURES = "Texturen vorladen"
VSYNC = "VSync"
UNCAPPED_FRAMERATE = "Unbegrenzte Bildrate"
RENDER_WHEN_UNFOCUSED = "Rendern wenn nicht fokussiert"
RENDER_EVERYTHING = "Alles"
RENDER_HUD_AND_UI = "HUD und UI"
RENDER_NOTHING = "Nichts"
FRAME_LIMIT = "Bildrate-Limit"
FAST = "Schnell"
ACCURATE = "Präzise"
Expand Down
4 changes: 4 additions & 0 deletions lang/Italian.ini
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ FORCE_4BY3 = "Force 4:3"
PRELOAD_TEXTURES = "Precarica Textures"
VSYNC = "VSync"
UNCAPPED_FRAMERATE = "Fotogrammi Illimitati"
RENDER_WHEN_UNFOCUSED = "Renderizza quando non a fuoco"
RENDER_EVERYTHING = "Tutto"
RENDER_HUD_AND_UI = "HUD e UI"
RENDER_NOTHING = "Niente"
FRAME_LIMIT = "Limite Fotogrammi"
FAST = "Veloce"
ACCURATE = "Accurata"
Expand Down
4 changes: 4 additions & 0 deletions lang/Japanese.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ FORCE_4BY3 = "画面比を4:3に強制"
PRELOAD_TEXTURES = "テクスチャを事前に読み込む"
VSYNC = "垂直同期(VSYNC)を有効にする"
UNCAPPED_FRAMERATE = "FPSを制限しない"
RENDER_WHEN_UNFOCUSED = "フォーカスが外れたときに描画"
RENDER_EVERYTHING = "すべて"
RENDER_HUD_AND_UI = "HUDとUI"
RENDER_NOTHING = "なし"
FRAME_LIMIT = "FPSの制限"
FAST = "速い"
ACCURATE = "正確"
Expand Down
4 changes: 4 additions & 0 deletions lang/Polish.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ FORCE_4BY3 = "Wymuś proporcję 4:3"
PRELOAD_TEXTURES = "Załaduj Wstępnie Tekstury"
VSYNC = "Synchronizacja Pionowa"
UNCAPPED_FRAMERATE = "Nieograniczona Liczba Klatek"
RENDER_WHEN_UNFOCUSED = "Renderuj gdy nieaktywne"
RENDER_EVERYTHING = "Wszystko"
RENDER_HUD_AND_UI = "HUD i UI"
RENDER_NOTHING = "Nic"
FRAME_LIMIT = "Limit Klatek na Sekundę"
FAST = "Szybka"
ACCURATE = "Dokładna"
Expand Down
4 changes: 4 additions & 0 deletions lang/Portuguese.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ FORCE_4BY3 = "Forçar 4:3"
PRELOAD_TEXTURES = "Pré-carregar texturas"
VSYNC = "Sincronização vertical"
UNCAPPED_FRAMERATE = "FPS ilimitado"
RENDER_WHEN_UNFOCUSED = "Renderizar quando não estiver focado"
RENDER_EVERYTHING = "Tudo"
RENDER_HUD_AND_UI = "HUD e UI"
RENDER_NOTHING = "Nada"
FRAME_LIMIT = "Limite de FPS"
FAST = "Rápida"
ACCURATE = "Precisa"
Expand Down
4 changes: 4 additions & 0 deletions lang/Russian.ini
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ FORCE_4BY3 = "Экран 4:3"
PRELOAD_TEXTURES = "Предварительная загрузка текстур"
VSYNC = "Вертикальная синхронизация"
UNCAPPED_FRAMERATE = "Неограниченная частота кадров"
RENDER_WHEN_UNFOCUSED = "Отрисовывать если не активно"
RENDER_EVERYTHING = "Всё"
RENDER_HUD_AND_UI = "HUD и UI"
RENDER_NOTHING = "Ничего"
FRAME_LIMIT = "Лимит кадров"
FAST = "Быстро"
ACCURATE = "Точно"
Expand Down
4 changes: 4 additions & 0 deletions lang/Spanish.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ FORCE_4BY3 = "Forzar 4:3"
PRELOAD_TEXTURES = "Precargar texturas"
VSYNC = "Sincronización vertical"
UNCAPPED_FRAMERATE = "FPS sin límite"
RENDER_WHEN_UNFOCUSED = "Renderizar cuando no está enfocado"
RENDER_EVERYTHING = "Todo"
RENDER_HUD_AND_UI = "HUD y UI"
RENDER_NOTHING = "Nada"
FRAME_LIMIT = "Límite de FPS"
FAST = "Rápida"
ACCURATE = "Precisa"
Expand Down
7 changes: 5 additions & 2 deletions src/game/area.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "pc/djui/djui.h"
#include "pc/djui/djui_panel_pause.h"
#include "pc/nametags.h"
#include "pc/pc_main.h"

struct SpawnInfo gPlayerSpawnInfos[MAX_PLAYERS];
struct Area gAreaData[MAX_AREAS];
Expand Down Expand Up @@ -437,8 +438,10 @@ void play_transition_after_delay(s16 transType, s16 time, u8 red, u8 green, u8 b
void render_game(void) {
dynos_update_gfx();
if (gCurrentArea != NULL && !gWarpTransition.pauseRendering) {
geo_process_root(gCurrentArea->unk04, D_8032CE74, D_8032CE78, gFBSetColor);

if (WAPI.has_focus() || configRenderWhenUnfocused == 0) {
geo_process_root(gCurrentArea->unk04, D_8032CE74, D_8032CE78, gFBSetColor);
}

gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_8032CF00));

gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH,
Expand Down
2 changes: 2 additions & 0 deletions src/pc/configfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ ConfigWindow configWindow = {
unsigned int configFiltering = 2; // 0 = Nearest, 1 = Bilinear, 2 = Trilinear
bool configShowFPS = false;
bool configUncappedFramerate = true;
unsigned int configRenderWhenUnfocused = 0; // 0 = Everything, 1 = HUD and UI, 2 = Nothing
unsigned int configFrameLimit = 60;
unsigned int configInterpolationMode = 1;
unsigned int configDrawDistance = 4;
Expand Down Expand Up @@ -205,6 +206,7 @@ static const struct ConfigOption options[] = {
{.name = "texture_filtering", .type = CONFIG_TYPE_UINT, .uintValue = &configFiltering},
{.name = "show_fps", .type = CONFIG_TYPE_BOOL, .boolValue = &configShowFPS},
{.name = "uncapped_framerate", .type = CONFIG_TYPE_BOOL, .boolValue = &configUncappedFramerate},
{.name = "render_when_unfocused", .type = CONFIG_TYPE_UINT, .uintValue = &configRenderWhenUnfocused},
{.name = "frame_limit", .type = CONFIG_TYPE_UINT, .uintValue = &configFrameLimit},
{.name = "interpolation_mode", .type = CONFIG_TYPE_UINT, .uintValue = &configInterpolationMode},
{.name = "coop_draw_distance", .type = CONFIG_TYPE_UINT, .uintValue = &configDrawDistance},
Expand Down
1 change: 1 addition & 0 deletions src/pc/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ extern ConfigWindow configWindow;
extern unsigned int configFiltering;
extern bool configShowFPS;
extern bool configUncappedFramerate;
extern unsigned int configRenderWhenUnfocused;
extern unsigned int configFrameLimit;
extern unsigned int configInterpolationMode;
extern unsigned int configDrawDistance;
Expand Down
4 changes: 3 additions & 1 deletion src/pc/djui/djui_panel_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ void djui_panel_display_create(struct DjuiBase* caller) {
djui_checkbox_create(body, DLANG(DISPLAY, SHOW_FPS), &configShowFPS, NULL);
djui_checkbox_create(body, DLANG(DISPLAY, VSYNC), &configWindow.vsync, djui_panel_display_apply);
djui_checkbox_create(body, DLANG(DISPLAY, UNCAPPED_FRAMERATE), &configUncappedFramerate, djui_panel_display_uncapped_change);

char* renderChoicesUnfocused[3] = { DLANG(DISPLAY, RENDER_EVERYTHING), DLANG(DISPLAY, RENDER_HUD_AND_UI), DLANG(DISPLAY, RENDER_NOTHING) };
djui_selectionbox_create(body, DLANG(DISPLAY, RENDER_WHEN_UNFOCUSED), renderChoicesUnfocused, 3, &configRenderWhenUnfocused, NULL);

struct DjuiRect* rect1 = djui_rect_container_create(body, 32);
{
if (configFrameLimit < 30) { configFrameLimit = 30; }
Expand Down
32 changes: 17 additions & 15 deletions src/pc/gfx/gfx_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1858,24 +1858,26 @@ void gfx_start_frame(void) {
}

void gfx_run(Gfx *commands) {
gfx_sp_reset();
if (WAPI.has_focus() || configRenderWhenUnfocused != 2) {
gfx_sp_reset();

//puts("New frame");
//puts("New frame");

if (!gfx_wapi->start_frame()) {
dropped_frame = true;
return;
}
dropped_frame = false;
if (!gfx_wapi->start_frame()) {
dropped_frame = true;
return;
}
dropped_frame = false;

//double t0 = gfx_wapi->get_time();
gfx_rapi->start_frame();
gfx_run_dl(commands);
gfx_flush();
//double t1 = gfx_wapi->get_time();
//printf("Process %f %f\n", t1, t1 - t0);
gfx_rapi->end_frame();
gfx_wapi->swap_buffers_begin();
//double t0 = gfx_wapi->get_time();
gfx_rapi->start_frame();
gfx_run_dl(commands);
gfx_flush();
//double t1 = gfx_wapi->get_time();
//printf("Process %f %f\n", t1, t1 - t0);
gfx_rapi->end_frame();
gfx_wapi->swap_buffers_begin();
}
}

void gfx_end_frame(void) {
Expand Down