mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
Allow altering graphics viewport (unfinished)
This commit is contained in:
parent
029a59a836
commit
31d13ba41e
62
src/Game.c
62
src/Game.c
@ -603,7 +603,38 @@ void Game_TakeScreenshot(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void Game_RenderFrame(double delta) {
|
||||
static CC_INLINE void Game_DrawFrame(double delta, float t) {
|
||||
UpdateViewMatrix();
|
||||
|
||||
if (!Gui_GetBlocksWorld()) {
|
||||
Camera.Active->GetPickedBlock(Entities.CurPlayer, &Game_SelectedPos); /* TODO: only pick when necessary */
|
||||
Camera_KeyLookUpdate(delta);
|
||||
InputHandler_Tick();
|
||||
|
||||
if (Game_Anaglyph3D) {
|
||||
Render3D_Anaglyph(delta, t);
|
||||
} else {
|
||||
Render3DFrame(delta, t);
|
||||
}
|
||||
} else {
|
||||
RayTracer_SetInvalid(&Game_SelectedPos);
|
||||
}
|
||||
|
||||
Gfx_Begin2D(Game.Width, Game.Height);
|
||||
Gui_RenderGui(delta);
|
||||
OnscreenKeyboard_Draw3D();
|
||||
/* TODO find a better solution than this */
|
||||
#ifdef CC_BUILD_3DS
|
||||
if (Game_Anaglyph3D) {
|
||||
extern void Gfx_SetTopRight(void);
|
||||
Gfx_SetTopRight();
|
||||
Gui_RenderGui(delta);
|
||||
}
|
||||
#endif
|
||||
Gfx_End2D();
|
||||
}
|
||||
|
||||
static CC_INLINE void Game_RenderFrame(double delta) {
|
||||
struct ScheduledTask entTask;
|
||||
float t;
|
||||
|
||||
@ -644,39 +675,12 @@ static void Game_RenderFrame(double delta) {
|
||||
Camera.CurrentPos = Camera.Active->GetPosition(&LocalPlayer_Instance, t);
|
||||
/* NOTE: EnvRenderer_UpdateFog also also sets clear color */
|
||||
EnvRenderer_UpdateFog();
|
||||
UpdateViewMatrix();
|
||||
AudioBackend_Tick();
|
||||
|
||||
/* TODO: Not calling Gfx_EndFrame doesn't work with Direct3D9 */
|
||||
if (Window_Main.Inactive) return;
|
||||
Gfx_ClearBuffers(GFX_BUFFER_COLOR | GFX_BUFFER_DEPTH);
|
||||
|
||||
if (!Gui_GetBlocksWorld()) {
|
||||
Camera.Active->GetPickedBlock(Entities.CurPlayer, &Game_SelectedPos); /* TODO: only pick when necessary */
|
||||
Camera_KeyLookUpdate(delta);
|
||||
InputHandler_Tick();
|
||||
|
||||
if (Game_Anaglyph3D) {
|
||||
Render3D_Anaglyph(delta, t);
|
||||
} else {
|
||||
Render3DFrame(delta, t);
|
||||
}
|
||||
} else {
|
||||
RayTracer_SetInvalid(&Game_SelectedPos);
|
||||
}
|
||||
|
||||
Gfx_Begin2D(Game.Width, Game.Height);
|
||||
Gui_RenderGui(delta);
|
||||
OnscreenKeyboard_Draw3D();
|
||||
/* TODO find a better solution than this */
|
||||
#ifdef CC_BUILD_3DS
|
||||
if (Game_Anaglyph3D) {
|
||||
extern void Gfx_SetTopRight(void);
|
||||
Gfx_SetTopRight();
|
||||
Gui_RenderGui(delta);
|
||||
}
|
||||
#endif
|
||||
Gfx_End2D();
|
||||
Game_DrawFrame(delta, t);
|
||||
|
||||
if (Game_ScreenshotRequested) Game_TakeScreenshot();
|
||||
Gfx_EndFrame();
|
||||
|
@ -246,14 +246,16 @@ void Gfx_EndFrame(void);
|
||||
/* Sets whether to synchronise with monitor refresh to avoid tearing, and maximum frame rate */
|
||||
/* NOTE: VSync setting may be unsupported or just ignored */
|
||||
void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMillis);
|
||||
/* Updates state when the window's dimensions have changed */
|
||||
/* NOTE: This may require recreating the context depending on the backend */
|
||||
void Gfx_OnWindowResize(void);
|
||||
/* Gets information about the user's GPU and current backend state */
|
||||
/* Backend state may include depth buffer bits, free memory, etc */
|
||||
/* NOTE: Each line is separated by \n */
|
||||
void Gfx_GetApiInfo(cc_string* info);
|
||||
|
||||
/* Updates state when the window's dimensions have changed */
|
||||
/* NOTE: This may require recreating the context depending on the backend */
|
||||
void Gfx_OnWindowResize(void);
|
||||
void Gfx_UpdateViewport(void);
|
||||
|
||||
enum Screen3DS { TOP_SCREEN, BOTTOM_SCREEN };
|
||||
#ifdef CC_BUILD_DUALSCREEN
|
||||
/* Selects which screen on the 3DS to render to */
|
||||
|
@ -575,6 +575,8 @@ void Gfx_EndFrame(void) {
|
||||
|
||||
void Gfx_OnWindowResize(void) { }
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------------Buffers--------------------------------------------------------*
|
||||
|
@ -1176,6 +1176,10 @@ void Gfx_OnWindowResize(void) {
|
||||
RS_UpdateViewport();
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) {
|
||||
RS_UpdateViewport();
|
||||
}
|
||||
|
||||
static void InitPipeline(void) {
|
||||
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-graphics-pipeline
|
||||
IA_Init();
|
||||
|
@ -886,4 +886,6 @@ void Gfx_OnWindowResize(void) {
|
||||
/* Only resize when necessary */
|
||||
UpdateSwapchain(" (resizing window)");
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
#endif
|
||||
|
@ -557,4 +557,6 @@ void Gfx_EndFrame(void) {
|
||||
void Gfx_OnWindowResize(void) {
|
||||
glViewport(0, 0, Game.Width, Game.Height);
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
#endif
|
||||
|
@ -312,6 +312,8 @@ void Gfx_EndFrame(void) {
|
||||
|
||||
void Gfx_OnWindowResize(void) { }
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
cc_bool Gfx_WarnIfNecessary(void) { return false; }
|
||||
|
||||
|
||||
|
@ -79,6 +79,8 @@ void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
||||
|
||||
void Gfx_OnWindowResize(void) { }
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
|
||||
void Gfx_BeginFrame(void) {
|
||||
surface_t* disp = display_get();
|
||||
|
@ -66,6 +66,8 @@ void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
||||
void Gfx_OnWindowResize(void) {
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
void Gfx_BeginFrame(void) {
|
||||
}
|
||||
|
||||
|
@ -727,6 +727,8 @@ void Gfx_OnWindowResize(void) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
void Gfx_GetApiInfo(cc_string* info) {
|
||||
String_AppendConst(info, "-- Using PS1 --\n");
|
||||
PrintMaxTextureInfo(info);
|
||||
|
@ -671,6 +671,8 @@ void Gfx_OnWindowResize(void) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
void Gfx_GetApiInfo(cc_string* info) {
|
||||
String_AppendConst(info, "-- Using PS2 --\n");
|
||||
PrintMaxTextureInfo(info);
|
||||
|
@ -476,6 +476,8 @@ void Gfx_OnWindowResize(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Index buffers-----------------------------------------------------*
|
||||
|
@ -283,6 +283,8 @@ void Gfx_EndFrame(void) {
|
||||
|
||||
void Gfx_OnWindowResize(void) { }
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
|
||||
static cc_uint8* gfx_vertices;
|
||||
static int gfx_fields;
|
||||
|
@ -811,6 +811,8 @@ void Gfx_EndFrame(void) {
|
||||
|
||||
void Gfx_OnWindowResize(void) { }
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*--------------------------------------------------------GPU Buffers------------------------------------------------------*
|
||||
|
@ -435,6 +435,8 @@ void Gfx_OnWindowResize(void) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
void Gfx_GetApiInfo(cc_string* info) {
|
||||
String_AppendConst(info, "-- Using Saturn --\n");
|
||||
PrintMaxTextureInfo(info);
|
||||
|
@ -491,6 +491,8 @@ void Gfx_OnWindowResize(void) {
|
||||
colorBuffer = fb_bmp.scan0;
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
void Gfx_GetApiInfo(cc_string* info) {
|
||||
int pointerSize = sizeof(void*) * 8;
|
||||
String_Format1(info, "-- Using software (%i bit) --\n", &pointerSize);
|
||||
|
@ -458,6 +458,9 @@ void Gfx_GetApiInfo(cc_string* info) {
|
||||
void Gfx_OnWindowResize(void) {
|
||||
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
void Gfx_3DS_SetRenderScreen1(enum Screen3DS screen) {
|
||||
GX2ContextState* tv_state = WHBGfxGetTVContextState();
|
||||
GX2ContextState* drc_state = WHBGfxGetDRCContextState(); // TODO
|
||||
|
@ -535,6 +535,8 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f
|
||||
|
||||
void Gfx_OnWindowResize(void) { }
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
|
||||
static struct Matrix _view, _proj, _mvp;
|
||||
|
||||
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
||||
|
@ -402,4 +402,6 @@ void Gfx_GetApiInfo(cc_string* info) {
|
||||
void Gfx_OnWindowResize(void) {
|
||||
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) { }
|
||||
#endif
|
||||
|
@ -325,7 +325,7 @@ void Gfx_EndFrame(void) {
|
||||
}
|
||||
|
||||
void Gfx_OnWindowResize(void) {
|
||||
glViewport(Gfx.ViewportX, Gfx.ViewportY, Gfx.ViewportWidth, Gfx.ViewportHeight);
|
||||
Gfx_UpdateViewport();
|
||||
/* With cocoa backend, in some cases [NSOpenGLContext update] will actually */
|
||||
/* call glViewport with the size of the window framebuffer */
|
||||
/* https://github.com/glfw/glfw/issues/80 */
|
||||
@ -335,3 +335,7 @@ void Gfx_OnWindowResize(void) {
|
||||
/* https://github.com/ClassiCube/ClassiCube/issues/888 */
|
||||
GLContext_Update();
|
||||
}
|
||||
|
||||
void Gfx_UpdateViewport(void) {
|
||||
glViewport(Gfx.ViewportX, Gfx.ViewportY, Gfx.ViewportWidth, Gfx.ViewportHeight);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user