[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/liblines Lines.cxx
From: |
Matti Katila |
Subject: |
[Gzz-commits] gzz/gfx/liblines Lines.cxx |
Date: |
Tue, 10 Dec 2002 15:40:19 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Matti Katila <address@hidden> 02/12/10 15:40:19
Modified files:
gfx/liblines : Lines.cxx
Log message:
Fixed texture oords calculating.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/liblines/Lines.cxx.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
Patches:
Index: gzz/gfx/liblines/Lines.cxx
diff -u gzz/gfx/liblines/Lines.cxx:1.14 gzz/gfx/liblines/Lines.cxx:1.15
--- gzz/gfx/liblines/Lines.cxx:1.14 Tue Nov 5 14:00:16 2002
+++ gzz/gfx/liblines/Lines.cxx Tue Dec 10 15:40:19 2002
@@ -44,7 +44,7 @@
if (level != 0) size /= 2;
for (int i=0; i<size; i++) {
- line_image[i] = 0.2;
+ line_image[i] = 0;
}
int steps = size / 8;
@@ -57,10 +57,11 @@
}
} else {
switch(size) {
- case 4: line_image[1] = 1;
- line_image[2] = 1; break;
- case 2: line_image[1] = 1; break;
- case 1: line_image[0] = 1; break;
+ case 4: line_image[1] = 0.5;
+ line_image[2] = 0.5; break;
+ case 2: line_image[0] = 0.25;
+ line_image[1] = 0.25; break;
+ case 1: line_image[0] = 0.125; break;
}
}
@@ -84,6 +85,34 @@
}
+ /* How texture clipping is count?
+ * ------------------------------
+ * line...
+ * +-----+---+-------+---+-----+
+ * | |whi| |whi| |
+ * |clamp|te | black |te | clamp
+ * | | | | | |
+ * +-----+---+-------+---+-----+
+ * 0 t0 3/8 5/8 t1 1
+ *
+ * |< >| ¦< >|
+ * 2 pixels 2 pixels
+ *
+ * |<width>|
+ *
+ *-----------------------------------
+ *
+ * t0 = 1 - t1
+ *
+ *
+ * 5/8 - 3/8 t1 - 10
+ * --------- = ---------
+ * w 2 + w + 2
+ *
+ *
+ * t0 = 0.5 - (4+w)/8w
+ */
+
void Lines::draw(ZPt a, ZPt b) {
if (dbg) cout << linewidth;
if (dbg) cout <<" x: "<< a.x << ", "<< b.x
@@ -103,30 +132,30 @@
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- float lp2 = 1 + linewidth/2;
- float texcoord = 0.5;
- texcoord *= 1/lp2;
+ // lp2 > 1
+ float total_width = 2 + linewidth/2;
ZPt l = (a-b).cw90().normalized();
- l.x *= lp2; l.y *= lp2;
+ l.x *= total_width;
+ l.y *= total_width;
- float t0 = 0.5 - texcoord;
- float t1 = 0.5 + texcoord;
+ float t0 = 0.5 - ( (4+linewidth) / (8*linewidth) );
+ float t1 = 1 - t0;
if (dbg) cout <<"t1: " << t1 <<" t0 :" << t0 << endl;
glBegin(GL_QUADS);
- glTexCoord2f(t0, t1);
+ glTexCoord2f(t0, 1);
glVertex3f(a.x + l.x, a.y + l.y, a.z);
- glTexCoord2f(t1, t1);
+ glTexCoord2f(t1, 1);
glVertex3f(a.x - l.x, a.y - l.y, a.z);
- glTexCoord2f(t1, t0);
+ glTexCoord2f(t1, 0);
glVertex3f(b.x - l.x, b.y - l.y, b.z);
- glTexCoord2f(t0, t0);
+ glTexCoord2f(t0, 0);
glVertex3f(b.x + l.x, b.y + l.y, b.z);
glEnd();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx/liblines Lines.cxx,
Matti Katila <=