comparison pytouhou/ui/opengl/shaders/eosd.py @ 557:0f2af7552462

Don’t hardcode GLSL version in our shaders, instead make them dependent on GL version.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 30 May 2014 16:40:36 +0200
parents 5e3e0b09a531
children 1be60813f7cb
comparison
equal deleted inserted replaced
556:c34b23e29d16 557:0f2af7552462
17 17
18 18
19 class GameShader(Shader): 19 class GameShader(Shader):
20 def __init__(self): 20 def __init__(self):
21 Shader.__init__(self, [''' 21 Shader.__init__(self, ['''
22 #version 120
23
24 attribute vec3 in_position; 22 attribute vec3 in_position;
25 attribute vec2 in_texcoord; 23 attribute vec2 in_texcoord;
26 attribute vec4 in_color; 24 attribute vec4 in_color;
27 25
28 uniform mat4 mvp; 26 uniform mat4 mvp;
35 gl_Position = mvp * vec4(in_position, 1.0); 33 gl_Position = mvp * vec4(in_position, 1.0);
36 texcoord = in_texcoord; 34 texcoord = in_texcoord;
37 color = in_color; 35 color = in_color;
38 } 36 }
39 '''], [''' 37 '''], ['''
40 #version 120
41
42 varying vec2 texcoord; 38 varying vec2 texcoord;
43 varying vec4 color; 39 varying vec4 color;
44 40
45 uniform sampler2D color_map; 41 uniform sampler2D color_map;
46 42
52 48
53 49
54 class BackgroundShader(Shader): 50 class BackgroundShader(Shader):
55 def __init__(self): 51 def __init__(self):
56 Shader.__init__(self, [''' 52 Shader.__init__(self, ['''
57 #version 120
58
59 attribute vec3 in_position; 53 attribute vec3 in_position;
60 attribute vec2 in_texcoord; 54 attribute vec2 in_texcoord;
61 attribute vec4 in_color; 55 attribute vec4 in_color;
62 56
63 uniform mat4 mvp; 57 uniform mat4 mvp;
70 gl_Position = mvp * vec4(in_position, 1.0); 64 gl_Position = mvp * vec4(in_position, 1.0);
71 texcoord = in_texcoord; 65 texcoord = in_texcoord;
72 color = in_color; 66 color = in_color;
73 } 67 }
74 '''], [''' 68 '''], ['''
75 #version 120
76
77 varying vec2 texcoord; 69 varying vec2 texcoord;
78 varying vec4 color; 70 varying vec4 color;
79 71
80 uniform sampler2D color_map; 72 uniform sampler2D color_map;
81 uniform float fog_scale; 73 uniform float fog_scale;
93 85
94 86
95 class PassthroughShader(Shader): 87 class PassthroughShader(Shader):
96 def __init__(self): 88 def __init__(self):
97 Shader.__init__(self, [''' 89 Shader.__init__(self, ['''
98 #version 120
99
100 attribute vec2 in_position; 90 attribute vec2 in_position;
101 attribute vec2 in_texcoord; 91 attribute vec2 in_texcoord;
102 92
103 uniform mat4 mvp; 93 uniform mat4 mvp;
104 94
108 { 98 {
109 gl_Position = mvp * vec4(in_position, 0.0, 1.0); 99 gl_Position = mvp * vec4(in_position, 0.0, 1.0);
110 texcoord = in_texcoord; 100 texcoord = in_texcoord;
111 } 101 }
112 '''], [''' 102 '''], ['''
113 #version 120
114
115 varying vec2 texcoord; 103 varying vec2 texcoord;
116 104
117 uniform sampler2D color_map; 105 uniform sampler2D color_map;
118 106
119 void main() 107 void main()