Ensure line numbers reported by the GLSL compiler are correct

This commit is contained in:
Kovid Goyal 2017-08-29 12:45:52 +05:30
parent db40445572
commit a44e3a3a50
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 7 additions and 1 deletions

View File

@ -36,6 +36,7 @@ class BordersProgram(ShaderProgram):
def __init__(self): def __init__(self):
ShaderProgram.__init__( ShaderProgram.__init__(
self, '''\ self, '''\
#version GLSL_VERSION
uniform vec3 colors[3]; uniform vec3 colors[3];
in vec3 rect; in vec3 rect;
out vec3 color; out vec3 color;
@ -45,6 +46,7 @@ void main() {
color = colors[uint(rect[2])]; color = colors[uint(rect[2])];
} }
''', '''\ ''', '''\
#version GLSL_VERSION
in vec3 color; in vec3 color;
out vec4 final_color; out vec4 final_color;

View File

@ -1,3 +1,4 @@
#version GLSL_VERSION
uniform sampler2DArray sprites; uniform sampler2DArray sprites;
in vec3 sprite_pos; in vec3 sprite_pos;
in vec3 underline_pos; in vec3 underline_pos;

View File

@ -1,3 +1,4 @@
#version GLSL_VERSION
uniform uvec2 dimensions; // xnum, ynum uniform uvec2 dimensions; // xnum, ynum
uniform vec4 steps; // xstart, ystart, dx, dy uniform vec4 steps; // xstart, ystart, dx, dy
uniform vec2 sprite_layout; // dx, dy uniform vec2 sprite_layout; // dx, dy

View File

@ -1,3 +1,4 @@
#version GLSL_VERSION
uniform vec4 color; uniform vec4 color;
out vec4 final_color; out vec4 final_color;

View File

@ -1,3 +1,4 @@
#version GLSL_VERSION
uniform vec2 xpos; uniform vec2 xpos;
uniform vec2 ypos; uniform vec2 ypos;

View File

@ -310,7 +310,7 @@ class ShaderProgram: # {{{
def add_shader(self, source: str, shader_type: int) -> int: def add_shader(self, source: str, shader_type: int) -> int:
' Compile a shader and return its id, or raise an exception if compilation fails ' ' Compile a shader and return its id, or raise an exception if compilation fails '
shader_id = glCreateShader(shader_type) shader_id = glCreateShader(shader_type)
source = '#version {}\n{}'.format(VERSION, source) source = source.replace('GLSL_VERSION', str(VERSION), 1)
try: try:
glShaderSource(shader_id, source) glShaderSource(shader_id, source)
glCompileShader(shader_id) glCompileShader(shader_id)