summaryrefslogtreecommitdiff
path: root/src/video/opengl.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-01-16 16:43:04 +0100
committerMichael Lutz <michi@icosahedron.de>2021-02-22 22:16:07 +0100
commitef478ade649add1ab1706370ff53bcb0c32798d1 (patch)
treebf39b20030319377edec1b654fe4e8c7ba4594a3 /src/video/opengl.h
parentaf4d32357cc4cea6878c61c366378477e62915d0 (diff)
downloadopenttd-ef478ade649add1ab1706370ff53bcb0c32798d1.tar.xz
Add: [Win32] Video driver that uses OpenGL to transfer the video buffer to the screen.
Diffstat (limited to 'src/video/opengl.h')
-rw-r--r--src/video/opengl.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/video/opengl.h b/src/video/opengl.h
new file mode 100644
index 000000000..9db1be5f5
--- /dev/null
+++ b/src/video/opengl.h
@@ -0,0 +1,49 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file opengl.h OpenGL video driver support. */
+
+#ifndef VIDEO_OPENGL_H
+#define VIDEO_OPENGL_H
+
+#include "../core/alloc_type.hpp"
+
+/** Platform-independent back-end singleton class for OpenGL video drivers. */
+class OpenGLBackend : public ZeroedMemoryAllocator {
+private:
+ static OpenGLBackend *instance; ///< Singleton instance pointer.
+
+ void *vid_buffer; ///< Pointer to the memory used for the video driver to draw to.
+ GLuint vid_texture; ///< Texture handle for the video buffer texture.
+
+ OpenGLBackend();
+ ~OpenGLBackend();
+
+ const char *Init();
+
+public:
+ /** Get singleton instance of this class. */
+ static inline OpenGLBackend *Get()
+ {
+ return OpenGLBackend::instance;
+ }
+ static const char *Create();
+ static void Destroy();
+
+ bool Resize(int w, int h, bool force = false);
+ void Paint();
+
+ /**
+ * Get a pointer to the memory for the video driver to draw to.
+ * @return Pointer to draw on.
+ */
+ void *GetVideoBuffer() { return this->vid_buffer; }
+};
+
+#endif /* VIDEO_OPENGL_H */