From 006f701fecf405f8d0b0743c346c047a4c74be4e Mon Sep 17 00:00:00 2001
From: Jonas Kulla <Nyocurio@gmail.com>
Date: Sun, 23 Apr 2017 14:32:11 +0200
Subject: [PATCH] Config: Add "enableBlitting" entry to toggle
 GL_EXT_framebuffer_blit

---
 mkxp.conf.sample | 9 +++++++++
 src/config.cpp   | 1 +
 src/config.h     | 1 +
 src/main.cpp     | 3 +++
 4 files changed, 14 insertions(+)

diff --git a/mkxp.conf.sample b/mkxp.conf.sample
index 0062451..500dcc6 100644
--- a/mkxp.conf.sample
+++ b/mkxp.conf.sample
@@ -124,6 +124,15 @@
 # subImageFix=false
 
 
+# Enable framebuffer blitting if the driver is
+# capable of it. Some drivers carry buggy
+# implementations of this functionality, so
+# disabling it can be used as a workaround
+# (default: enabled)
+#
+# enableBlitting=true
+
+
 # Limit the maximum size (width, height) of
 # most textures mkxp will create (exceptions are
 # rendering backbuffers and similar).
diff --git a/src/config.cpp b/src/config.cpp
index 0fab180..33d8160 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -166,6 +166,7 @@ void Config::read(int argc, char *argv[])
 	PO_DESC(syncToRefreshrate, bool, false) \
 	PO_DESC(solidFonts, bool, false) \
 	PO_DESC(subImageFix, bool, false) \
+	PO_DESC(enableBlitting, bool, true) \
 	PO_DESC(maxTextureSize, int, 0) \
 	PO_DESC(gameFolder, std::string, ".") \
 	PO_DESC(anyAltToggleFS, bool, false) \
diff --git a/src/config.h b/src/config.h
index f6dc2c4..d2d4650 100644
--- a/src/config.h
+++ b/src/config.h
@@ -49,6 +49,7 @@ struct Config
 	bool solidFonts;
 
 	bool subImageFix;
+	bool enableBlitting;
 	int maxTextureSize;
 
 	std::string gameFolder;
diff --git a/src/main.cpp b/src/main.cpp
index a87ae48..1a3fc4e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -102,6 +102,9 @@ int rgssThreadFun(void *userdata)
 		return 0;
 	}
 
+	if (!conf.enableBlitting)
+		gl.BlitFramebuffer = 0;
+
 	gl.ClearColor(0, 0, 0, 1);
 	gl.Clear(GL_COLOR_BUFFER_BIT);
 	SDL_GL_SwapWindow(win);