invisible
view src/tesquad.cc @ 21:53fe01a4e2f3
foo - backup
author | Eleni Maria Stea <eleni@mutantstargoat.com> |
---|---|
date | Sun, 10 Nov 2013 14:18:41 +0200 |
parents | |
children | b50ad2711f5f |
line source
1 #include <GL/gl.h>
2 #include "tesquad.h"
4 void draw_tess_quad(float x, float y, float w, float h, int usub, int vsub, bool ortho)
5 {
6 if(ortho) {
7 glPushAttrib(GL_ENABLE_BIT);
8 glDisable(GL_DEPTH_TEST);
9 glDisable(GL_LIGHTING);
11 glMatrixMode(GL_PROJECTION);
12 glPushMatrix();
13 glLoadIdentity();
14 }
16 float du = 1.0 / usub;
17 float dv = 1.0 / vsub;
19 float dx = du * w;
20 float dy = dv * h;
22 glBegin(GL_QUADS);
23 for (int i=0; i<vsub; i++) {
24 for (int j=0; j<usub; j++) {
25 float u = j * du;
26 float v = 1.0 - i * dv;
27 float sx = x + j * dx;
28 float sy = y + i * dy;
30 glTexCoord2f(u, v);
31 glVertex2f(sx, sy);
32 glTexCoord2f(u + du, v);
33 glVertex2f(sx + dx, sy);
34 glTexCoord2f(u + du, v - dv);
35 glVertex2f(sx + dx, sy + dy);
36 glTexCoord2f(u, v - dv);
37 glVertex2f(sx, sy + dy);
38 }
39 }
40 glEnd();
42 if(ortho) {
43 glPopMatrix();
44 glPopAttrib();
45 }
46 }