From acf59f6b68a3bdd068b4eddccd06749c5b411189 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sat, 16 Jan 2021 16:43:20 +0100 Subject: Codechange: [OpenGL] Use shaders to display the video buffer on screen. --- src/table/CMakeLists.txt | 5 +++++ src/table/opengl_shader.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/table/opengl_shader.h (limited to 'src/table') diff --git a/src/table/CMakeLists.txt b/src/table/CMakeLists.txt index e63337b8a..bb2311cf1 100644 --- a/src/table/CMakeLists.txt +++ b/src/table/CMakeLists.txt @@ -85,3 +85,8 @@ add_files( unicode.h water_land.h ) + +add_files( + opengl_shader.h + CONDITION OPENGL_FOUND +) diff --git a/src/table/opengl_shader.h b/src/table/opengl_shader.h new file mode 100644 index 000000000..43b2ca512 --- /dev/null +++ b/src/table/opengl_shader.h @@ -0,0 +1,28 @@ +/* $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 . + */ + +/** @file opengl_shader.h OpenGL shader programs. */ + +/** Vertex shader that just passes colour and tex coords through. */ +static const char *_vertex_shader_direct[] = { + "#version 110\n", + "void main() {", + " gl_TexCoord[0] = gl_MultiTexCoord0;", + " gl_Position = gl_Vertex;", + "}", +}; + +/** Fragment shader that reads the fragment colour from a 32bpp texture. */ +static const char *_frag_shader_direct[] = { + "#version 110\n", + "uniform sampler2D colour_tex;", + "void main() {", + " gl_FragColor = texture2D(colour_tex, gl_TexCoord[0].st);", + "}", +}; -- cgit v1.2.3-54-g00ecf