invisible
diff src/tesquad.cc @ 19:f756fc9fdd3e
quick backup
author | Eleni Maria Stea <eleni@mutantstargoat.com> |
---|---|
date | Sun, 10 Nov 2013 14:02:36 +0200 |
parents | |
children | b50ad2711f5f |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/tesquad.cc Sun Nov 10 14:02:36 2013 +0200 1.3 @@ -0,0 +1,46 @@ 1.4 +#include <GL/gl.h> 1.5 +#include "tesquad.h" 1.6 + 1.7 +void draw_tess_quad(float x, float y, float w, float h, int usub, int vsub, bool ortho) 1.8 +{ 1.9 + if(ortho) { 1.10 + glPushAttrib(GL_ENABLE_BIT); 1.11 + glDisable(GL_DEPTH_TEST); 1.12 + glDisable(GL_LIGHTING); 1.13 + 1.14 + glMatrixMode(GL_PROJECTION); 1.15 + glPushMatrix(); 1.16 + glLoadIdentity(); 1.17 + } 1.18 + 1.19 + float du = 1.0 / usub; 1.20 + float dv = 1.0 / vsub; 1.21 + 1.22 + float dx = du * w; 1.23 + float dy = dv * h; 1.24 + 1.25 + glBegin(GL_QUADS); 1.26 + for (int i=0; i<vsub; i++) { 1.27 + for (int j=0; j<usub; j++) { 1.28 + float u = j * du; 1.29 + float v = 1.0 - i * dv; 1.30 + float sx = x + j * dx; 1.31 + float sy = y + i * dy; 1.32 + 1.33 + glTexCoord2f(u, v); 1.34 + glVertex2f(sx, sy); 1.35 + glTexCoord2f(u + du, v); 1.36 + glVertex2f(sx + dx, sy); 1.37 + glTexCoord2f(u + du, v - dv); 1.38 + glVertex2f(sx + dx, sy + dy); 1.39 + glTexCoord2f(u, v - dv); 1.40 + glVertex2f(sx, sy + dy); 1.41 + } 1.42 + } 1.43 + glEnd(); 1.44 + 1.45 + if(ortho) { 1.46 + glPopMatrix(); 1.47 + glPopAttrib(); 1.48 + } 1.49 +}