source: trunk/src/debug/quad.cpp @ 809

Last change on this file since 809 was 809, checked in by sam, 9 years ago

debug: reset texture unit in the GL quad.

  • Property svn:keywords set to Id
File size: 19.1 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cmath>
16#include <cstdio>
17
18#include "core.h"
19#include "lolgl.h"
20#include "loldebug.h"
21
22using namespace std;
23
24namespace lol
25{
26
27/*
28 * DebugQuad implementation class
29 */
30
31static int const NUM_ARRAYS = 2;
32static int const NUM_BUFFERS = 6;
33static int const NUM_ATTRS = 6;
34static int const NUM_SHADERS = 6;
35static int const NUM_TEXTURES = 1;
36
37static int const TEX_SIZE = 32;
38
39class DebugQuadData
40{
41    friend class DebugQuad;
42
43private:
44    vec2 orig, step, aa, bb;
45
46    int initialised;
47    float time;
48    GLuint array[NUM_ARRAYS];
49    GLuint buffer[NUM_BUFFERS];
50    Shader *shader[NUM_SHADERS];
51    GLuint attr[NUM_ATTRS];
52    GLuint texture[NUM_TEXTURES];
53    uint8_t image[1][TEX_SIZE * TEX_SIZE * 4];
54};
55
56/*
57 * Public DebugQuad class
58 */
59
60DebugQuad::DebugQuad()
61  : data(new DebugQuadData())
62{
63    data->initialised = 0;
64    data->time = RandF(10000.0f);
65
66    drawgroup = DRAWGROUP_HUD;
67}
68
69void DebugQuad::TickGame(float deltams)
70{
71    Entity::TickGame(deltams);
72
73    data->time += deltams;
74}
75
76void DebugQuad::TickDraw(float deltams)
77{
78    Entity::TickDraw(deltams);
79
80    if (!data->initialised && !IsDestroying())
81    {
82        glGenVertexArrays(NUM_ARRAYS, data->array);
83        glGenBuffers(NUM_BUFFERS, data->buffer);
84        glGenTextures(NUM_TEXTURES, data->texture);
85        for (int i = 0; i < NUM_SHADERS; i++)
86            data->shader[i] = NULL;
87
88        /* Checkerboard texture */
89        glEnable(GL_TEXTURE_2D);
90        glBindTexture(GL_TEXTURE_2D, data->texture[0]);
91        for (int j = 0; j < TEX_SIZE; j++)
92            for (int i = 0; i < TEX_SIZE; i++)
93            {
94                uint8_t wb = (((i / 2) ^ (j / 2)) & 1) * 0xff;
95                data->image[0][(j * TEX_SIZE + i) * 4 + 0] = wb;
96                data->image[0][(j * TEX_SIZE + i) * 4 + 1] = wb;
97                data->image[0][(j * TEX_SIZE + i) * 4 + 2] = wb;
98                data->image[0][(j * TEX_SIZE + i) * 4 + 3] = 0xff;
99            }
100        /* Use GL_RGBA instead of 4 for the internal format (Android) */
101        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0,
102                     GL_RGBA, GL_UNSIGNED_BYTE, data->image[0]);
103        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
104        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
105
106        data->initialised = 1;
107    }
108    else if (data->initialised && IsDestroying())
109    {
110        glDeleteVertexArrays(NUM_ARRAYS, data->array);
111        glDeleteBuffers(NUM_BUFFERS, data->buffer);
112        glDeleteTextures(NUM_TEXTURES, data->texture);
113
114        for (int i = 0; i < NUM_SHADERS; i++)
115            if (data->shader[i])
116                Shader::Destroy(data->shader[i]);
117
118        data->initialised = 0;
119    }
120
121    /* Reset GL states to something reasonably safe */
122    glMatrixMode(GL_PROJECTION);
123    glLoadIdentity();
124    glMatrixMode(GL_MODELVIEW);
125    glLoadIdentity();
126    glDisable(GL_TEXTURE_2D);
127    glClientActiveTexture(GL_TEXTURE0);
128    glBindBuffer(GL_ARRAY_BUFFER, 0);
129    glUseProgram(0);
130
131    /* Prepare our quad coordinates */
132    vec2i const layout(4, 3);
133    data->step = vec2(2.0f, -2.0f) / (3 * layout + vec2i(1));
134    data->orig = vec2(-1.0f, 1.0f) + data->step;
135    data->aa = data->orig;
136    data->bb = data->orig + 2.0f * data->step;
137
138    /* Generate a few random numbers */
139    float f1 = 0.5f + 0.5f * sinf(0.00034f * data->time);
140    float f2 = 0.5f + 0.5f * sinf(0.00053f * data->time + 1.0f);
141    float f3 = 0.5f + 0.5f * sinf(0.00072f * data->time + 4.0f);
142    float f4 = 0.5f + 0.5f * sinf(0.00091f * data->time + 8.0f);
143
144    GLfloat const colors[] = { f1, f2, f3, f4, f2, f1, f3, f1, f4,
145                               f3, f1, f4, f4, f3, f2, f1, f2, f3 };
146    GLfloat const texcoords[] = { f1, f3, f3, f2, f2, f4,
147                                  f2, f4, f4, f1, f1, f3 };
148
149#if defined HAVE_GLBEGIN || defined USE_GLEW
150    /*
151     * Test #1: simple glBegin code
152     * Renders an orange square.
153     */
154    glColor3f(0.8f, 0.5f, 0.2f);
155    glBegin(GL_TRIANGLES);
156        glVertex3f(data->aa.x, data->bb.y, 0.0f);
157        glVertex3f(data->bb.x, data->bb.y, 0.0f);
158        glVertex3f(data->bb.x, data->aa.y, 0.0f);
159
160        glVertex3f(data->bb.x, data->aa.y, 0.0f);
161        glVertex3f(data->aa.x, data->aa.y, 0.0f);
162        glVertex3f(data->aa.x, data->bb.y, 0.0f);
163    glEnd();
164
165    Advance();
166
167    /*
168     * Test #2: glBegin + per-vertex coloring
169     * Renders a multicolored square with varying colors.
170     */
171    glBegin(GL_TRIANGLES);
172        glColor3f(f1, f2, f3);
173        glVertex3f(data->aa.x, data->bb.y, 0.0f);
174        glColor3f(f4, f2, f1);
175        glVertex3f(data->bb.x, data->bb.y, 0.0f);
176        glColor3f(f3, f1, f4);
177        glVertex3f(data->bb.x, data->aa.y, 0.0f);
178
179        glVertex3f(data->bb.x, data->aa.y, 0.0f);
180        glColor3f(f4, f3, f2);
181        glVertex3f(data->aa.x, data->aa.y, 0.0f);
182        glColor3f(f1, f2, f3);
183        glVertex3f(data->aa.x, data->bb.y, 0.0f);
184    glEnd();
185
186    Advance();
187
188    /*
189     * Test #3: glBegin + texture
190     * Renders an animated black-and-white distorted checkerboard.
191     */
192    glEnable(GL_TEXTURE_2D);
193    glBindTexture(GL_TEXTURE_2D, data->texture[0]);
194    glColor3f(1.0f, 1.0f, 1.0f);
195    glBegin(GL_TRIANGLES);
196        glTexCoord2f(f1, f3);
197        glVertex3f(data->aa.x, data->bb.y, 0.0f);
198        glTexCoord2f(f3, f2);
199        glVertex3f(data->bb.x, data->bb.y, 0.0f);
200        glTexCoord2f(f2, f4);
201        glVertex3f(data->bb.x, data->aa.y, 0.0f);
202
203        glTexCoord2f(f2, f4);
204        glVertex3f(data->bb.x, data->aa.y, 0.0f);
205        glTexCoord2f(f4, f1);
206        glVertex3f(data->aa.x, data->aa.y, 0.0f);
207        glTexCoord2f(f1, f3);
208        glVertex3f(data->aa.x, data->bb.y, 0.0f);
209    glEnd();
210    glDisable(GL_TEXTURE_2D);
211
212    Advance();
213
214    /*
215     * Test #4: glBegin + color in fragment shader
216     * Renders a static, coloured and tiled pattern.
217     */
218    if (!data->shader[0])
219        data->shader[0] = Shader::Create(
220            "#version 110\n"
221            "void main()"
222            "{"
223            "    gl_Position = gl_Vertex;"
224            "}",
225
226            "#version 110\n"
227            "void main()"
228            "{"
229            "    float dx = mod(gl_FragCoord.x * gl_FragCoord.y, 2.0);"
230            "    float dy = mod(gl_FragCoord.x * 0.125, 1.0);"
231            "    float dz = mod(gl_FragCoord.y * 0.125, 1.0);"
232            "    gl_FragColor = vec4(dx, dy, dz, 1.0);"
233            "}");
234    data->shader[0]->Bind();
235    glColor3f(0.0f, 1.0f, 1.0f);
236    glBegin(GL_TRIANGLES);
237        glVertex3f(data->aa.x, data->bb.y, 0.0f);
238        glVertex3f(data->bb.x, data->bb.y, 0.0f);
239        glVertex3f(data->bb.x, data->aa.y, 0.0f);
240
241        glVertex3f(data->bb.x, data->aa.y, 0.0f);
242        glVertex3f(data->aa.x, data->aa.y, 0.0f);
243        glVertex3f(data->aa.x, data->bb.y, 0.0f);
244    glEnd();
245    glUseProgram(0);
246
247    Advance();
248
249    /*
250     * Test #5: glBegin + pass color from vertex shader to fragment shader
251     * Renders a multicolored square with varying colors.
252     */
253    if (!data->shader[1])
254        data->shader[1] = Shader::Create(
255            "#version 110\n"
256            "varying vec4 pass_Color;"
257            "void main()"
258            "{"
259            "    float r = gl_MultiTexCoord0.x;"
260            "    float g = gl_MultiTexCoord0.y;"
261            "    pass_Color = vec4(1.0 - r, 1.0 - g, r, 1.0);"
262            "    gl_Position = gl_Vertex;"
263            "}",
264
265            "#version 110\n"
266            "varying vec4 pass_Color;"
267            "void main()"
268            "{"
269            "    gl_FragColor = pass_Color;"
270            "}");
271    data->shader[1]->Bind();
272    glColor3f(0.0f, 1.0f, 1.0f);
273    glBegin(GL_TRIANGLES);
274        glTexCoord2f(f1, f3);
275        glVertex3f(data->aa.x, data->bb.y, 0.0f);
276        glTexCoord2f(f3, f2);
277        glVertex3f(data->bb.x, data->bb.y, 0.0f);
278        glTexCoord2f(f2, f4);
279        glVertex3f(data->bb.x, data->aa.y, 0.0f);
280
281        glTexCoord2f(f2, f4);
282        glVertex3f(data->bb.x, data->aa.y, 0.0f);
283        glTexCoord2f(f4, f1);
284        glVertex3f(data->aa.x, data->aa.y, 0.0f);
285        glTexCoord2f(f1, f3);
286        glVertex3f(data->aa.x, data->bb.y, 0.0f);
287    glEnd();
288    glUseProgram(0);
289
290    Advance();
291
292    /*
293     * Test #6: glBegin + apply texture in fragment shader
294     * Renders an animated black-and-white distorted checkerboard with a
295     * zoom ratio twice the one in test #3.
296     */
297    if (!data->shader[2])
298        data->shader[2] = Shader::Create(
299            "#version 110\n"
300            "void main()"
301            "{"
302            "    gl_TexCoord[0] = gl_MultiTexCoord0;"
303            "    gl_Position = gl_Vertex;"
304            "}",
305
306            "#version 110\n"
307            "uniform sampler2D tex;"
308            "void main()"
309            "{"
310            "    gl_FragColor = texture2D(tex, gl_TexCoord[0].xy * 0.25);"
311            "}");
312    data->shader[2]->Bind();
313    glColor3f(0.0f, 1.0f, 1.0f);
314    glEnable(GL_TEXTURE_2D);
315    glBindTexture(GL_TEXTURE_2D, data->texture[0]);
316    glBegin(GL_TRIANGLES);
317        glTexCoord2f(f1, f3);
318        glVertex3f(data->aa.x, data->bb.y, 0.0f);
319        glTexCoord2f(f3, f2);
320        glVertex3f(data->bb.x, data->bb.y, 0.0f);
321        glTexCoord2f(f2, f4);
322        glVertex3f(data->bb.x, data->aa.y, 0.0f);
323
324        glTexCoord2f(f2, f4);
325        glVertex3f(data->bb.x, data->aa.y, 0.0f);
326        glTexCoord2f(f4, f1);
327        glVertex3f(data->aa.x, data->aa.y, 0.0f);
328        glTexCoord2f(f1, f3);
329        glVertex3f(data->aa.x, data->bb.y, 0.0f);
330    glEnd();
331    glUseProgram(0);
332    glDisable(GL_TEXTURE_2D);
333
334    Advance();
335#endif
336
337    /*
338     * Test #7: vertex buffer + per-vertex coloring
339     * Renders a multicolored square with varying colors.
340     */
341    GLfloat const vertices1[] = { data->aa.x, data->bb.y, 0.0f,
342                                  data->bb.x, data->bb.y, 0.0f,
343                                  data->bb.x, data->aa.y, 0.0f,
344                                  data->bb.x, data->aa.y, 0.0f,
345                                  data->aa.x, data->aa.y, 0.0f,
346                                  data->aa.x, data->bb.y, 0.0f };
347
348    glEnableClientState(GL_COLOR_ARRAY);
349    glEnableClientState(GL_VERTEX_ARRAY);
350
351    glColorPointer(3, GL_FLOAT, 0, colors);
352    glVertexPointer(3, GL_FLOAT, 0, vertices1);
353    glDrawArrays(GL_TRIANGLES, 0, 6);
354
355    glDisableClientState(GL_VERTEX_ARRAY);
356    glDisableClientState(GL_COLOR_ARRAY);
357
358    Advance();
359
360    /*
361     * Test #8: vertex buffer + per-vertex coloring + texture
362     * Renders a multicolored square with varying colors multiplied with an
363     * animated distorted checkerboard.
364     */
365    GLfloat const vertices2[] = { data->aa.x, data->bb.y, 0.0f,
366                                  data->bb.x, data->bb.y, 0.0f,
367                                  data->bb.x, data->aa.y, 0.0f,
368                                  data->bb.x, data->aa.y, 0.0f,
369                                  data->aa.x, data->aa.y, 0.0f,
370                                  data->aa.x, data->bb.y, 0.0f };
371
372    glEnable(GL_TEXTURE_2D);
373    glBindTexture(GL_TEXTURE_2D, data->texture[0]);
374    glEnableClientState(GL_COLOR_ARRAY);
375    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
376    glEnableClientState(GL_VERTEX_ARRAY);
377
378    glColorPointer(3, GL_FLOAT, 0, colors);
379    glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
380    glVertexPointer(3, GL_FLOAT, 0, vertices2);
381    glDrawArrays(GL_TRIANGLES, 0, 6);
382
383    glDisableClientState(GL_VERTEX_ARRAY);
384    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
385    glDisableClientState(GL_COLOR_ARRAY);
386    glDisable(GL_TEXTURE_2D);
387
388    Advance();
389
390    /*
391     * Test #9: vertex buffer + texture & color in 1.10 fragment shader
392     * Renders a multicolored square with varying colors xored with an
393     * animated distorted checkerboard.
394     */
395    if (!data->shader[3])
396        data->shader[3] = Shader::Create(
397            "#version 110\n"
398            "varying vec4 pass_Color;"
399            "void main()"
400            "{"
401            "    gl_TexCoord[0] = gl_MultiTexCoord0;"
402            "    pass_Color = gl_Color;"
403            "    gl_Position = gl_Vertex;"
404            "}",
405
406            "#version 110\n"
407            "varying vec4 pass_Color;"
408            "uniform sampler2D tex;"
409            "void main()"
410            "{"
411            "    vec4 tmp = texture2D(tex, gl_TexCoord[0].xy * 0.25);"
412            "    gl_FragColor = vec4(abs(tmp.xyz - pass_Color.xyz), 1.0);"
413            "}");
414
415    data->shader[3]->Bind();
416    GLfloat const vertices3[] = { data->aa.x, data->bb.y, 0.0f,
417                                  data->bb.x, data->bb.y, 0.0f,
418                                  data->bb.x, data->aa.y, 0.0f,
419                                  data->bb.x, data->aa.y, 0.0f,
420                                  data->aa.x, data->aa.y, 0.0f,
421                                  data->aa.x, data->bb.y, 0.0f };
422
423    glEnableClientState(GL_VERTEX_ARRAY);
424    glEnableClientState(GL_COLOR_ARRAY);
425    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
426
427    glVertexPointer(3, GL_FLOAT, 0, vertices3);
428    glColorPointer(3, GL_FLOAT, 0, colors);
429    glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
430    glDrawArrays(GL_TRIANGLES, 0, 6);
431
432    glDisableClientState(GL_VERTEX_ARRAY);
433    glDisableClientState(GL_COLOR_ARRAY);
434    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
435    glUseProgram(0);
436
437    Advance();
438
439    /*
440     * Test #10: vertex buffer + texture & color in 1.20 fragment shader
441     * Renders a multicolored square with varying colors xored with an
442     * animated distorted checkerboard.
443     */
444    if (!data->shader[4])
445    {
446        data->shader[4] = Shader::Create(
447            "#version 120\n"
448            "attribute vec3 in_Vertex;"
449            "attribute vec3 in_Color;"
450            "attribute vec2 in_MultiTexCoord0;"
451            "varying vec4 pass_Color;"
452            "void main()"
453            "{"
454            "    gl_TexCoord[0] = vec4(in_MultiTexCoord0, 0.0, 0.0);"
455            "    pass_Color = vec4(in_Color, 1.0);"
456            "    gl_Position = vec4(in_Vertex, 1.0);"
457            "}",
458
459            "#version 120\n"
460            "varying vec4 pass_Color;"
461            "uniform sampler2D tex;"
462            "void main()"
463            "{"
464            "    vec4 tmp = texture2D(tex, gl_TexCoord[0].xy * 0.25);"
465            "    gl_FragColor = vec4(abs(tmp.xyz - pass_Color.xyz), 1.0);"
466            "}");
467        data->attr[0] = data->shader[4]->GetAttribLocation("in_Vertex");
468        data->attr[1] = data->shader[4]->GetAttribLocation("in_Color");
469        data->attr[2] = data->shader[4]->GetAttribLocation("in_MultiTexCoord0");
470    }
471    data->shader[4]->Bind();
472    GLfloat const vertices4[] = { data->aa.x, data->bb.y, 0.0f,
473                                  data->bb.x, data->bb.y, 0.0f,
474                                  data->bb.x, data->aa.y, 0.0f,
475                                  data->bb.x, data->aa.y, 0.0f,
476                                  data->aa.x, data->aa.y, 0.0f,
477                                  data->aa.x, data->bb.y, 0.0f };
478
479    glBindVertexArray(data->array[0]);
480
481    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[0]);
482    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices4), vertices4,
483                 GL_DYNAMIC_DRAW);
484    glVertexAttribPointer(data->attr[0], 3, GL_FLOAT, GL_FALSE, 0, 0);
485    glEnableVertexAttribArray(data->attr[0]);
486
487    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[1]);
488    glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors,
489                 GL_DYNAMIC_DRAW);
490    glVertexAttribPointer(data->attr[1], 3, GL_FLOAT, GL_FALSE, 0, 0);
491    glEnableVertexAttribArray(data->attr[1]);
492
493    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[2]);
494    glBufferData(GL_ARRAY_BUFFER, sizeof(texcoords), texcoords,
495                 GL_DYNAMIC_DRAW);
496    glVertexAttribPointer(data->attr[2], 2, GL_FLOAT, GL_FALSE, 0, 0);
497    glEnableVertexAttribArray(data->attr[2]);
498
499    glDrawArrays(GL_TRIANGLES, 0, 6);
500    glBindVertexArray(0);
501
502    glDisableVertexAttribArray(data->attr[0]);
503    glDisableVertexAttribArray(data->attr[1]);
504    glDisableVertexAttribArray(data->attr[2]);
505    glUseProgram(0);
506
507    Advance();
508
509    /*
510     * Test #11: vertex buffer + texture & color in 1.30 fragment shader
511     * Renders a multicolored square with varying colors xored with an
512     * animated distorted checkerboard.
513     */
514    if (!data->shader[5])
515    {
516        data->shader[5] = Shader::Create(
517            "#version 130\n"
518            "in vec3 in_Vertex;"
519            "in vec3 in_Color;"
520            "in vec2 in_MultiTexCoord0;"
521            "out vec4 pass_Color;"
522            "void main()"
523            "{"
524            "    gl_TexCoord[0] = vec4(in_MultiTexCoord0, 0.0, 0.0);"
525            "    pass_Color = vec4(in_Color, 1.0);"
526            "    gl_Position = vec4(in_Vertex, 1.0);"
527            "}",
528
529            "#version 130\n"
530            "in vec4 pass_Color;"
531            "uniform sampler2D tex;"
532            "void main()"
533            "{"
534            "    vec4 tmp = texture2D(tex, gl_TexCoord[0].xy * 0.25);"
535            "    gl_FragColor = vec4(abs(tmp.xyz - pass_Color.xyz), 1.0);"
536            "}");
537        data->attr[3] = data->shader[4]->GetAttribLocation("in_Vertex");
538        data->attr[4] = data->shader[4]->GetAttribLocation("in_Color");
539        data->attr[5] = data->shader[4]->GetAttribLocation("in_MultiTexCoord0");
540    }
541    data->shader[5]->Bind();
542    GLfloat const vertices5[] = { data->aa.x, data->bb.y, 0.0f,
543                                  data->bb.x, data->bb.y, 0.0f,
544                                  data->bb.x, data->aa.y, 0.0f,
545                                  data->bb.x, data->aa.y, 0.0f,
546                                  data->aa.x, data->aa.y, 0.0f,
547                                  data->aa.x, data->bb.y, 0.0f };
548
549    glBindVertexArray(data->array[1]);
550
551    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[3]);
552    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices5), vertices5,
553                 GL_DYNAMIC_DRAW);
554    glVertexAttribPointer(data->attr[3], 3, GL_FLOAT, GL_FALSE, 0, 0);
555    glEnableVertexAttribArray(data->attr[3]);
556
557    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[4]);
558    glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors,
559                 GL_DYNAMIC_DRAW);
560    glVertexAttribPointer(data->attr[4], 3, GL_FLOAT, GL_FALSE, 0, 0);
561    glEnableVertexAttribArray(data->attr[4]);
562
563    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[5]);
564    glBufferData(GL_ARRAY_BUFFER, sizeof(texcoords), texcoords,
565                 GL_DYNAMIC_DRAW);
566    glVertexAttribPointer(data->attr[5], 2, GL_FLOAT, GL_FALSE, 0, 0);
567    glEnableVertexAttribArray(data->attr[5]);
568
569    glDrawArrays(GL_TRIANGLES, 0, 6);
570    glBindVertexArray(0);
571
572    glDisableVertexAttribArray(data->attr[3]);
573    glDisableVertexAttribArray(data->attr[4]);
574    glDisableVertexAttribArray(data->attr[5]);
575    glUseProgram(0);
576
577    Advance();
578}
579
580void DebugQuad::Advance()
581{
582    data->aa.x += 3.0f * data->step.x;
583    data->bb.x += 3.0f * data->step.x;
584    if (data->bb.x > 1.0f)
585    {
586        data->aa.x = data->orig.x;
587        data->bb.x = data->orig.x + 2.0f * data->step.x;
588        data->aa.y += 3.0f * data->step.y;
589        data->bb.y += 3.0f * data->step.y;
590    }
591}
592
593DebugQuad::~DebugQuad()
594{
595    delete data;
596}
597
598} /* namespace lol */
599
Note: See TracBrowser for help on using the repository browser.