@@ -144,18 +144,13 @@ class LegacyQuad( object ):
144
144
vertex_shader = textwrap .dedent ( """
145
145
#version 120
146
146
147
- // input
148
- attribute vec2 in_uv;
149
-
150
- // shared
151
- varying vec2 ex_uv;
152
-
153
147
void main(void)
154
148
{
155
149
// apply projection and model view matrix to vertex
156
150
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
157
151
158
- ex_uv = in_uv;
152
+ // select the texture coordinate to use
153
+ gl_TexCoord[0] = gl_MultiTexCoord0;
159
154
}
160
155
""" )
161
156
@@ -165,13 +160,10 @@ class LegacyQuad( object ):
165
160
// input
166
161
uniform sampler2D in_diffuse_texture;
167
162
168
- // shared
169
- varying vec2 ex_uv;
170
-
171
163
void main(void)
172
164
{
173
165
// set colour of each fragment
174
- gl_FragColor = texture2D( in_diffuse_texture, ex_uv ); ;
166
+ gl_FragColor = texture2D( in_diffuse_texture, gl_TexCoord[0].st ) ;
175
167
}
176
168
""" )
177
169
@@ -183,6 +175,8 @@ def __init__( self ):
183
175
184
176
self .use_shaders = True
185
177
178
+ GL .glEnable (GL .GL_TEXTURE_2D )
179
+
186
180
# create our shader
187
181
self .shader = ShaderProgram (
188
182
VertexShader ( self .vertex_shader ),
@@ -200,22 +194,21 @@ def __init__( self ):
200
194
self .buffer_attributes [ 'position' ] = VertexAttribute .from_dtype (
201
195
self .buffer ,
202
196
vertices .dtype ,
203
- 'position' ,
204
- location = self .shader .attributes [ 'in_position' ]
197
+ 'position'
205
198
)
206
199
207
200
self .buffer_attributes [ 'uv' ] = TextureCoordAttribute .from_dtype (
208
201
self .buffer ,
209
202
vertices .dtype ,
210
- 'texture_coord' ,
211
- location = self .shader .attributes [ 'in_uv' ]
203
+ 'texture_coord'
212
204
)
213
205
214
206
def draw ( self ):
215
207
global vertices
216
208
217
209
if self .use_shaders :
218
210
self .shader .bind ()
211
+ self .shader .uniforms [ 'in_diffuse_texture' ].value = 0
219
212
220
213
self .buffer_attributes .push_attributes ()
221
214
0 commit comments