invisible

view src/tesquad.cc @ 23:b50ad2711f5f

fixed fov aspect projection et c, added shaders todo: segmentation
author Eleni Maria Stea <eleni@mutantstargoat.com>
date Sat, 16 Nov 2013 23:29:15 +0200
parents f756fc9fdd3e
children
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 glPushAttrib(GL_ENABLE_BIT);
7 glDisable(GL_DEPTH_TEST);
8 glDisable(GL_LIGHTING);
10 if(ortho) {
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 }
45 glPopAttrib();
46 }