comparison pytouhou/ui/shaders/eosd.py @ 394:346614f788f1

Replace gl{Vertex,TexCoord,Color}Pointer with the more modern glVertexAttribPointer.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 06 Feb 2013 20:57:16 +0100
parents 74471afbac37
children 3ce4065840e9
comparison
equal deleted inserted replaced
393:9e2cbb2c2c64 394:346614f788f1
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 22 #version 120
23 23
24 attribute vec3 in_position;
25 attribute vec2 in_texcoord;
26 attribute vec4 in_color;
27
24 uniform mat4 mvp; 28 uniform mat4 mvp;
29
30 varying vec2 texcoord;
31 varying vec4 color;
25 32
26 void main() 33 void main()
27 { 34 {
28 gl_Position = mvp * gl_Vertex; 35 gl_Position = mvp * vec4(in_position, 1.0);
29 gl_FrontColor = gl_Color; 36 texcoord = in_texcoord;
30 gl_TexCoord[0] = gl_MultiTexCoord0; 37 color = in_color;
31 } 38 }
32 '''], [ ''' 39 '''], ['''
33 #version 120 40 #version 120
41
42 varying vec2 texcoord;
43 varying vec4 color;
34 44
35 uniform sampler2D color_map; 45 uniform sampler2D color_map;
36 46
37 void main() 47 void main()
38 { 48 {
39 gl_FragColor = texture2D(color_map, gl_TexCoord[0].st) * gl_Color; 49 gl_FragColor = texture2D(color_map, texcoord) * color;
40 } 50 }
41 ''']) 51 '''])
42 52
43 53
44 class BackgroundShader(Shader): 54 class BackgroundShader(Shader):
45 def __init__(self): 55 def __init__(self):
46 Shader.__init__(self, [''' 56 Shader.__init__(self, ['''
47 #version 120 57 #version 120
48 58
59 attribute vec3 in_position;
60 attribute vec2 in_texcoord;
61 attribute vec4 in_color;
62
49 uniform mat4 model_view; 63 uniform mat4 model_view;
50 uniform mat4 projection; 64 uniform mat4 projection;
51 65
66 varying vec2 texcoord;
67 varying vec4 color;
52 varying float fog_density; 68 varying float fog_density;
53 69
54 void main() 70 void main()
55 { 71 {
56 gl_Position = model_view * gl_Vertex; 72 vec4 position = model_view * vec4(in_position, 1.0);
57 gl_FrontColor = gl_Color; 73 texcoord = in_texcoord;
58 gl_TexCoord[0] = gl_MultiTexCoord0; 74 color = in_color;
59 75
60 float fog_position = -gl_Position.z / gl_Position.w; 76 float fog_position = -position.z / position.w;
61 fog_density = clamp((gl_Fog.end - fog_position) * gl_Fog.scale, 0.0f, 1.0f); 77 fog_density = clamp((gl_Fog.end - fog_position) * gl_Fog.scale, 0.0f, 1.0f);
62 78
63 gl_Position = projection * gl_Position; 79 gl_Position = projection * position;
64 } 80 }
65 '''], [ ''' 81 '''], ['''
66 #version 120 82 #version 120
83
84 varying vec2 texcoord;
85 varying vec4 color;
86 varying float fog_density;
67 87
68 uniform sampler2D color_map; 88 uniform sampler2D color_map;
69 89
70 varying float fog_density;
71
72 void main() 90 void main()
73 { 91 {
74 vec4 color = texture2D(color_map, gl_TexCoord[0].st) * gl_Color; 92 vec4 temp_color = texture2D(color_map, texcoord) * color;
75 gl_FragColor = mix(gl_Fog.color, color, fog_density); 93 gl_FragColor = mix(gl_Fog.color, temp_color, fog_density);
76 gl_FragColor.w = color.w; 94 gl_FragColor.a = temp_color.a;
77 } 95 }
78 ''']) 96 '''])