File diff r26496:c0ec897dfa4c → r26497:5a0a2e4c3e8b
src/table/opengl_shader.h
Show inline comments
 
/* $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_shader.h OpenGL shader programs. */
 

	
 
/** Vertex shader that positions a sprite on screen.. */
 
static const char *_vertex_shader_sprite[] = {
 
	"#version 110\n",
 
	"uniform vec4 sprite;",
 
	"uniform vec2 screen;",
 
	"attribute vec2 position, colour_uv;",
 
	"varying vec2 colour_tex_uv;",
 
	"void main() {",
 
	"  vec2 size = sprite.zw / screen.xy;",
 
	"  vec2 offset = ((2.0 * sprite.xy + sprite.zw) / screen.xy - 1.0) * vec2(1.0, -1.0);",
 
	"  colour_tex_uv = colour_uv;",
 
	"  gl_Position = vec4(position * size + offset, 0.0, 1.0);",
 
	"}",
 
};