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

Last change on this file since 806 was 806, checked in by sam, 10 years ago

debug: add a slightly more complex vertex buffer test 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    glBindBuffer(GL_ARRAY_BUFFER, 0);
128    glUseProgram(0);
129
130    /* Prepare our quad coordinates */
131    vec2i const layout(4, 3);
132    data->step = vec2(2.0f, -2.0f) / (3 * layout + vec2i(1));
133    data->orig = vec2(-1.0f, 1.0f) + data->step;
134    data->aa = data->orig;
135    data->bb = data->orig + 2.0f * data->step;
136
137    /* Generate a few random numbers */
138    float f1 = 0.5f + 0.5f * sinf(0.00034f * data->time);
139    float f2 = 0.5f + 0.5f * sinf(0.00053f * data->time + 1.0f);
140    float f3 = 0.5f + 0.5f * sinf(0.00072f * data->time + 4.0f);
141    float f4 = 0.5f + 0.5f * sinf(0.00091f * data->time + 8.0f);
142
143    GLfloat const colors[] = { f1, f2, f3, f4, f2, f1, f3, f1, f4,
144                               f3, f1, f4, f4, f3, f2, f1, f2, f3 };
145    GLfloat const texcoords[] = { f1, f3, f3, f2, f2, f4,
146                                  f2, f4, f4, f1, f1, f3 };
147
148#if defined HAVE_GLBEGIN || defined USE_GLEW
149    /*
150     * Test #1: simple glBegin code
151     * Renders an orange square.
152     */
153    glColor3f(0.8f, 0.5f, 0.2f);
154    glBegin(GL_TRIANGLES);
155        glVertex3f(data->aa.x, data->bb.y, 0.0f);
156        glVertex3f(data->bb.x, data->bb.y, 0.0f);
157        glVertex3f(data->bb.x, data->aa.y, 0.0f);
158
159        glVertex3f(data->bb.x, data->aa.y, 0.0f);
160        glVertex3f(data->aa.x, data->aa.y, 0.0f);
161        glVertex3f(data->aa.x, data->bb.y, 0.0f);
162    glEnd();
163
164    Advance();
165
166    /*
167     * Test #2: glBegin + per-vertex coloring
168     * Renders a multicolored square with varying colors.
169     */
170    glBegin(GL_TRIANGLES);
171        glColor3f(f1, f2, f3);
172        glVertex3f(data->aa.x, data->bb.y, 0.0f);
173        glColor3f(f4, f2, f1);
174        glVertex3f(data->bb.x, data->bb.y, 0.0f);
175        glColor3f(f3, f1, f4);
176        glVertex3f(data->bb.x, data->aa.y, 0.0f);
177
178        glVertex3f(data->bb.x, data->aa.y, 0.0f);
179        glColor3f(f4, f3, f2);
180        glVertex3f(data->aa.x, data->aa.y, 0.0f);
181        glColor3f(f1, f2, f3);
182        glVertex3f(data->aa.x, data->bb.y, 0.0f);
183    glEnd();
184
185    Advance();
186
187    /*
188     * Test #3: glBegin + texture
189     * Renders an animated black-and-white distorted checkerboard.
190     */
191    glEnable(GL_TEXTURE_2D);
192    glBindTexture(GL_TEXTURE_2D, data->texture[0]);
193    glColor3f(1.0f, 1.0f, 1.0f);
194    glBegin(GL_TRIANGLES);
195        glTexCoord2f(f1, f3);
196        glVertex3f(data->aa.x, data->bb.y, 0.0f);
197        glTexCoord2f(f3, f2);
198        glVertex3f(data->bb.x, data->bb.y, 0.0f);
199        glTexCoord2f(f2, f4);
200        glVertex3f(data->bb.x, data->aa.y, 0.0f);
201
202        glTexCoord2f(f2, f4);
203        glVertex3f(data->bb.x, data->aa.y, 0.0f);
204        glTexCoord2f(f4, f1);
205        glVertex3f(data->aa.x, data->aa.y, 0.0f);
206        glTexCoord2f(f1, f3);
207        glVertex3f(data->aa.x, data->bb.y, 0.0f);
208    glEnd();
209    glDisable(GL_TEXTURE_2D);
210
211    Advance();
212
213    /*
214     * Test #4: glBegin + color in fragment shader
215     * Renders a static, coloured and tiled pattern.
216     */
217    if (!data->shader[0])
218        data->shader[0] = Shader::Create(
219            "#version 110\n"
220            "void main()"
221            "{"
222            "    gl_Position = gl_Vertex;"
223            "}",
224
225            "#version 110\n"
226            "void main()"
227            "{"
228            "    float dx = mod(gl_FragCoord.x * gl_FragCoord.y, 2.0);"
229            "    float dy = mod(gl_FragCoord.x * 0.125, 1.0);"
230            "    float dz = mod(gl_FragCoord.y * 0.125, 1.0);"
231            "    gl_FragColor = vec4(dx, dy, dz, 1.0);"
232            "}");
233    data->shader[0]->Bind();
234    glColor3f(0.0f, 1.0f, 1.0f);
235    glBegin(GL_TRIANGLES);
236        glVertex3f(data->aa.x, data->bb.y, 0.0f);
237        glVertex3f(data->bb.x, data->bb.y, 0.0f);
238        glVertex3f(data->bb.x, data->aa.y, 0.0f);
239
240        glVertex3f(data->bb.x, data->aa.y, 0.0f);
241        glVertex3f(data->aa.x, data->aa.y, 0.0f);
242        glVertex3f(data->aa.x, data->bb.y, 0.0f);
243    glEnd();
244    glUseProgram(0);
245
246    Advance();
247
248    /*
249     * Test #5: glBegin + pass color from vertex shader to fragment shader
250     * Renders a multicolored square with varying colors.
251     */
252    if (!data->shader[1])
253        data->shader[1] = Shader::Create(
254            "#version 110\n"
255            "varying vec4 pass_Color;"
256            "void main()"
257            "{"
258            "    float r = gl_MultiTexCoord0.x;"
259            "    float g = gl_MultiTexCoord0.y;"
260            "    pass_Color = vec4(1.0 - r, 1.0 - g, r, 1.0);"
261            "    gl_Position = gl_Vertex;"
262            "}",
263
264            "#version 110\n"
265            "varying vec4 pass_Color;"
266            "void main()"
267            "{"
268            "    gl_FragColor = pass_Color;"
269            "}");
270    data->shader[1]->Bind();
271    glColor3f(0.0f, 1.0f, 1.0f);
272    glBegin(GL_TRIANGLES);
273        glTexCoord2f(f1, f3);
274        glVertex3f(data->aa.x, data->bb.y, 0.0f);
275        glTexCoord2f(f3, f2);
276        glVertex3f(data->bb.x, data->bb.y, 0.0f);
277        glTexCoord2f(f2, f4);
278        glVertex3f(data->bb.x, data->aa.y, 0.0f);
279
280        glTexCoord2f(f2, f4);
281        glVertex3f(data->bb.x, data->aa.y, 0.0f);
282        glTexCoord2f(f4, f1);
283        glVertex3f(data->aa.x, data->aa.y, 0.0f);
284        glTexCoord2f(f1, f3);
285        glVertex3f(data->aa.x, data->bb.y, 0.0f);
286    glEnd();
287    glUseProgram(0);
288
289    Advance();
290
291    /*
292     * Test #6: glBegin + apply texture in fragment shader
293     * Renders an animated black-and-white distorted checkerboard with a
294     * zoom ratio twice the one in test #3.
295     */
296    if (!data->shader[2])
297        data->shader[2] = Shader::Create(
298            "#version 110\n"
299            "void main()"
300            "{"
301            "    gl_TexCoord[0] = gl_MultiTexCoord0;"
302            "    gl_Position = gl_Vertex;"
303            "}",
304
305            "#version 110\n"
306            "uniform sampler2D tex;"
307            "void main()"
308            "{"
309            "    gl_FragColor = texture2D(tex, gl_TexCoord[0].xy * 0.25);"
310            "}");
311    data->shader[2]->Bind();
312    glColor3f(0.0f, 1.0f, 1.0f);
313    glEnable(GL_TEXTURE_2D);
314    glBindTexture(GL_TEXTURE_2D, data->texture[0]);
315    glBegin(GL_TRIANGLES);
316        glTexCoord2f(f1, f3);
317        glVertex3f(data->aa.x, data->bb.y, 0.0f);
318        glTexCoord2f(f3, f2);
319        glVertex3f(data->bb.x, data->bb.y, 0.0f);
320        glTexCoord2f(f2, f4);
321        glVertex3f(data->bb.x, data->aa.y, 0.0f);
322
323        glTexCoord2f(f2, f4);
324        glVertex3f(data->bb.x, data->aa.y, 0.0f);
325        glTexCoord2f(f4, f1);
326        glVertex3f(data->aa.x, data->aa.y, 0.0f);
327        glTexCoord2f(f1, f3);
328        glVertex3f(data->aa.x, data->bb.y, 0.0f);
329    glEnd();
330    glUseProgram(0);
331    glDisable(GL_TEXTURE_2D);
332
333    Advance();
334#endif
335
336    /*
337     * Test #7: vertex buffer + per-vertex coloring
338     * Renders a multicolored square with varying colors.
339     */
340    GLfloat const vertices1[] = { data->aa.x, data->bb.y, 0.0f,
341                                  data->bb.x, data->bb.y, 0.0f,
342                                  data->bb.x, data->aa.y, 0.0f,
343                                  data->bb.x, data->aa.y, 0.0f,
344                                  data->aa.x, data->aa.y, 0.0f,
345                                  data->aa.x, data->bb.y, 0.0f };
346
347    glEnableClientState(GL_COLOR_ARRAY);
348    glEnableClientState(GL_VERTEX_ARRAY);
349
350    glColorPointer(3, GL_FLOAT, 0, colors);
351    glVertexPointer(3, GL_FLOAT, 0, vertices1);
352    glDrawArrays(GL_TRIANGLES, 0, 6);
353
354    glDisableClientState(GL_VERTEX_ARRAY);
355    glDisableClientState(GL_COLOR_ARRAY);
356
357    Advance();
358
359    /*
360     * Test #8: vertex buffer + per-vertex coloring + texture
361     * Renders a multicolored square with varying colors multiplied with an
362     * animated distorted checkerboard.
363     */
364    GLfloat const vertices2[] = { data->aa.x, data->bb.y, 0.0f,
365                                  data->bb.x, data->bb.y, 0.0f,
366                                  data->bb.x, data->aa.y, 0.0f,
367                                  data->bb.x, data->aa.y, 0.0f,
368                                  data->aa.x, data->aa.y, 0.0f,
369                                  data->aa.x, data->bb.y, 0.0f };
370
371    glEnable(GL_TEXTURE_2D);
372    glBindTexture(GL_TEXTURE_2D, data->texture[0]);
373    glEnableClientState(GL_COLOR_ARRAY);
374    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
375    glEnableClientState(GL_VERTEX_ARRAY);
376
377    glColorPointer(3, GL_FLOAT, 0, colors);
378    glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
379    glVertexPointer(3, GL_FLOAT, 0, vertices2);
380    glDrawArrays(GL_TRIANGLES, 0, 6);
381
382    glDisableClientState(GL_VERTEX_ARRAY);
383    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
384    glDisableClientState(GL_COLOR_ARRAY);
385    glDisable(GL_TEXTURE_2D);
386
387    Advance();
388
389    /*
390     * Test #9: vertex buffer + texture & color in 1.10 fragment shader
391     * Renders a multicolored square with varying colors xored with an
392     * animated distorted checkerboard.
393     */
394    if (!data->shader[3])
395        data->shader[3] = Shader::Create(
396            "#version 110\n"
397            "varying vec4 pass_Color;"
398            "void main()"
399            "{"
400            "    gl_TexCoord[0] = gl_MultiTexCoord0;"
401            "    pass_Color = gl_Color;"
402            "    gl_Position = gl_Vertex;"
403            "}",
404
405            "#version 110\n"
406            "varying vec4 pass_Color;"
407            "uniform sampler2D tex;"
408            "void main()"
409            "{"
410            "    vec4 tmp = texture2D(tex, gl_TexCoord[0].xy * 0.25);"
411            "    gl_FragColor = vec4(abs(tmp.xyz - pass_Color.xyz), 1.0);"
412            "}");
413
414    data->shader[3]->Bind();
415    GLfloat const vertices3[] = { data->aa.x, data->bb.y, 0.0f,
416                                  data->bb.x, data->bb.y, 0.0f,
417                                  data->bb.x, data->aa.y, 0.0f,
418                                  data->bb.x, data->aa.y, 0.0f,
419                                  data->aa.x, data->aa.y, 0.0f,
420                                  data->aa.x, data->bb.y, 0.0f };
421
422    glEnableClientState(GL_VERTEX_ARRAY);
423    glEnableClientState(GL_COLOR_ARRAY);
424    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
425
426    glVertexPointer(3, GL_FLOAT, 0, vertices3);
427    glColorPointer(3, GL_FLOAT, 0, colors);
428    glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
429    glDrawArrays(GL_TRIANGLES, 0, 6);
430
431    glDisableClientState(GL_VERTEX_ARRAY);
432    glDisableClientState(GL_COLOR_ARRAY);
433    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
434    glUseProgram(0);
435
436    Advance();
437
438    /*
439     * Test #10: vertex buffer + texture & color in 1.20 fragment shader
440     * Renders a multicolored square with varying colors xored with an
441     * animated distorted checkerboard.
442     */
443    if (!data->shader[4])
444    {
445        data->shader[4] = Shader::Create(
446            "#version 120\n"
447            "attribute vec3 in_Vertex;"
448            "attribute vec3 in_Color;"
449            "attribute vec2 in_MultiTexCoord0;"
450            "varying vec4 pass_Color;"
451            "void main()"
452            "{"
453            "    gl_TexCoord[0] = vec4(in_MultiTexCoord0, 0.0, 0.0);"
454            "    pass_Color = vec4(in_Color, 1.0);"
455            "    gl_Position = vec4(in_Vertex, 1.0);"
456            "}",
457
458            "#version 120\n"
459            "varying vec4 pass_Color;"
460            "uniform sampler2D tex;"
461            "void main()"
462            "{"
463            "    vec4 tmp = texture2D(tex, gl_TexCoord[0].xy * 0.25);"
464            "    gl_FragColor = vec4(abs(tmp.xyz - pass_Color.xyz), 1.0);"
465            "}");
466        data->attr[0] = data->shader[4]->GetAttribLocation("in_Vertex");
467        data->attr[1] = data->shader[4]->GetAttribLocation("in_Color");
468        data->attr[2] = data->shader[4]->GetAttribLocation("in_MultiTexCoord0");
469    }
470    data->shader[4]->Bind();
471    GLfloat const vertices4[] = { data->aa.x, data->bb.y, 0.0f,
472                                  data->bb.x, data->bb.y, 0.0f,
473                                  data->bb.x, data->aa.y, 0.0f,
474                                  data->bb.x, data->aa.y, 0.0f,
475                                  data->aa.x, data->aa.y, 0.0f,
476                                  data->aa.x, data->bb.y, 0.0f };
477
478    glBindVertexArray(data->array[0]);
479
480    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[0]);
481    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices4), vertices4,
482                 GL_DYNAMIC_DRAW);
483    glVertexAttribPointer(data->attr[0], 3, GL_FLOAT, GL_FALSE, 0, 0);
484    glEnableVertexAttribArray(data->attr[0]);
485
486    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[1]);
487    glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors,
488                 GL_DYNAMIC_DRAW);
489    glVertexAttribPointer(data->attr[1], 3, GL_FLOAT, GL_FALSE, 0, 0);
490    glEnableVertexAttribArray(data->attr[1]);
491
492    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[2]);
493    glBufferData(GL_ARRAY_BUFFER, sizeof(texcoords), texcoords,
494                 GL_DYNAMIC_DRAW);
495    glVertexAttribPointer(data->attr[2], 2, GL_FLOAT, GL_FALSE, 0, 0);
496    glEnableVertexAttribArray(data->attr[2]);
497
498    glDrawArrays(GL_TRIANGLES, 0, 6);
499    glBindVertexArray(0);
500
501    glDisableVertexAttribArray(data->attr[0]);
502    glDisableVertexAttribArray(data->attr[1]);
503    glDisableVertexAttribArray(data->attr[2]);
504    glUseProgram(0);
505
506    Advance();
507
508    /*
509     * Test #11: vertex buffer + texture & color in 1.30 fragment shader
510     * Renders a multicolored square with varying colors xored with an
511     * animated distorted checkerboard.
512     */
513    if (!data->shader[5])
514    {
515        data->shader[5] = Shader::Create(
516            "#version 130\n"
517            "in vec3 in_Vertex;"
518            "in vec3 in_Color;"
519            "in vec2 in_MultiTexCoord0;"
520            "out vec4 pass_Color;"
521            "void main()"
522            "{"
523            "    gl_TexCoord[0] = vec4(in_MultiTexCoord0, 0.0, 0.0);"
524            "    pass_Color = vec4(in_Color, 1.0);"
525            "    gl_Position = vec4(in_Vertex, 1.0);"
526            "}",
527
528            "#version 130\n"
529            "in vec4 pass_Color;"
530            "uniform sampler2D tex;"
531            "void main()"
532            "{"
533            "    vec4 tmp = texture2D(tex, gl_TexCoord[0].xy * 0.25);"
534            "    gl_FragColor = vec4(abs(tmp.xyz - pass_Color.xyz), 1.0);"
535            "}");
536        data->attr[3] = data->shader[4]->GetAttribLocation("in_Vertex");
537        data->attr[4] = data->shader[4]->GetAttribLocation("in_Color");
538        data->attr[5] = data->shader[4]->GetAttribLocation("in_MultiTexCoord0");
539    }
540    data->shader[5]->Bind();
541    GLfloat const vertices5[] = { data->aa.x, data->bb.y, 0.0f,
542                                  data->bb.x, data->bb.y, 0.0f,
543                                  data->bb.x, data->aa.y, 0.0f,
544                                  data->bb.x, data->aa.y, 0.0f,
545                                  data->aa.x, data->aa.y, 0.0f,
546                                  data->aa.x, data->bb.y, 0.0f };
547
548    glBindVertexArray(data->array[1]);
549
550    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[3]);
551    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices5), vertices5,
552                 GL_DYNAMIC_DRAW);
553    glVertexAttribPointer(data->attr[3], 3, GL_FLOAT, GL_FALSE, 0, 0);
554    glEnableVertexAttribArray(data->attr[3]);
555
556    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[4]);
557    glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors,
558                 GL_DYNAMIC_DRAW);
559    glVertexAttribPointer(data->attr[4], 3, GL_FLOAT, GL_FALSE, 0, 0);
560    glEnableVertexAttribArray(data->attr[4]);
561
562    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[5]);
563    glBufferData(GL_ARRAY_BUFFER, sizeof(texcoords), texcoords,
564                 GL_DYNAMIC_DRAW);
565    glVertexAttribPointer(data->attr[5], 2, GL_FLOAT, GL_FALSE, 0, 0);
566    glEnableVertexAttribArray(data->attr[5]);
567
568    glDrawArrays(GL_TRIANGLES, 0, 6);
569    glBindVertexArray(0);
570
571    glDisableVertexAttribArray(data->attr[3]);
572    glDisableVertexAttribArray(data->attr[4]);
573    glDisableVertexAttribArray(data->attr[5]);
574    glUseProgram(0);
575
576    Advance();
577}
578
579void DebugQuad::Advance()
580{
581    data->aa.x += 3.0f * data->step.x;
582    data->bb.x += 3.0f * data->step.x;
583    if (data->bb.x > 1.0f)
584    {
585        data->aa.x = data->orig.x;
586        data->bb.x = data->orig.x + 2.0f * data->step.x;
587        data->aa.y += 3.0f * data->step.y;
588        data->bb.y += 3.0f * data->step.y;
589    }
590}
591
592DebugQuad::~DebugQuad()
593{
594    delete data;
595}
596
597} /* namespace lol */
598
Note: See TracBrowser for help on using the repository browser.