shithub: cstory

Download patch

ref: cec5fdb231de1a6f87a00795e6e3c93fcf4f28ad
parent: 17911753a6d21d11a47c813c3505d3016010ff6f
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Nov 4 17:17:18 EST 2020

3DS: Add vsync

Fixes screen-tearing in CSE2EX

...I should really figure out whether to enable vsync on other
platforms or not. I'm not even sure if the original DirectDraw
renderer used vsync - I swear I've never seen tearing in it before.

--- a/src/Backends/Rendering/3DS.cpp
+++ b/src/Backends/Rendering/3DS.cpp
@@ -181,10 +181,10 @@
 
 void RenderBackend_DrawScreen(void)
 {
+	EndRendering();
+
 	EnableAlpha(false);
 
-	BeginRendering();
-
 	const float texture_left = 0.0f;
 	const float texture_top = 0.0f;
 	const float texture_right = (float)framebuffer_surface_width / framebuffer_surface->texture.width;
@@ -202,6 +202,8 @@
 	image.tex = &framebuffer_surface->texture;
 	image.subtex = &subtexture;
 
+	C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
+
 	C2D_TargetClear(screen_render_target, C2D_Color32(0, 0, 0, 0xFF));
 
 	SelectRenderTarget(screen_render_target);
@@ -208,7 +210,7 @@
 
 	C2D_DrawImageAt(image, (400 - framebuffer_surface_width) / 2, (240 - framebuffer_surface_height) / 2, 0.0f);
 
-	EndRendering();
+	C3D_FrameEnd(0);
 }
 
 RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height, bool render_target)