invisible

annotate 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
rev   line source
eleni@19 1 #include <GL/gl.h>
eleni@19 2 #include "tesquad.h"
eleni@19 3
eleni@19 4 void draw_tess_quad(float x, float y, float w, float h, int usub, int vsub, bool ortho)
eleni@19 5 {
eleni@19 6 if(ortho) {
eleni@19 7 glPushAttrib(GL_ENABLE_BIT);
eleni@19 8 glDisable(GL_DEPTH_TEST);
eleni@19 9 glDisable(GL_LIGHTING);
eleni@19 10
eleni@19 11 glMatrixMode(GL_PROJECTION);
eleni@19 12 glPushMatrix();
eleni@19 13 glLoadIdentity();
eleni@19 14 }
eleni@19 15
eleni@19 16 float du = 1.0 / usub;
eleni@19 17 float dv = 1.0 / vsub;
eleni@19 18
eleni@19 19 float dx = du * w;
eleni@19 20 float dy = dv * h;
eleni@19 21
eleni@19 22 glBegin(GL_QUADS);
eleni@19 23 for (int i=0; i<vsub; i++) {
eleni@19 24 for (int j=0; j<usub; j++) {
eleni@19 25 float u = j * du;
eleni@19 26 float v = 1.0 - i * dv;
eleni@19 27 float sx = x + j * dx;
eleni@19 28 float sy = y + i * dy;
eleni@19 29
eleni@19 30 glTexCoord2f(u, v);
eleni@19 31 glVertex2f(sx, sy);
eleni@19 32 glTexCoord2f(u + du, v);
eleni@19 33 glVertex2f(sx + dx, sy);
eleni@19 34 glTexCoord2f(u + du, v - dv);
eleni@19 35 glVertex2f(sx + dx, sy + dy);
eleni@19 36 glTexCoord2f(u, v - dv);
eleni@19 37 glVertex2f(sx, sy + dy);
eleni@19 38 }
eleni@19 39 }
eleni@19 40 glEnd();
eleni@19 41
eleni@19 42 if(ortho) {
eleni@19 43 glPopMatrix();
eleni@19 44 glPopAttrib();
eleni@19 45 }
eleni@19 46 }