From: Derek Foreman Date: Sun, 25 May 2003 02:46:35 +0000 (+0000) Subject: rectangle and diagonal grads yay X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=d6652d0a90bd6c93084b0b9e6cf36123e0ec15d1;p=chaz%2Fopenbox rectangle and diagonal grads yay gl > * --- diff --git a/render/gradient.c b/render/gradient.c index 3a963406..aedd3bbe 100644 --- a/render/gradient.c +++ b/render/gradient.c @@ -529,6 +529,7 @@ void render_gl_gradient(Surface *sf, int x, int y, int w, int h) { float pr,pg,pb; float sr, sg, sb; + float ar, ag, ab; pr = (float)sf->data.planar.primary->r/255.0; pg = (float)sf->data.planar.primary->g/255.0; @@ -551,7 +552,7 @@ void render_gl_gradient(Surface *sf, int x, int y, int w, int h) glVertex3i(x, y, 0); glEnd(); return; - case Background_Vertical: + case Background_Horizontal: glBegin(GL_TRIANGLES); glColor3f(pr, pg, pb); glVertex3i(x, y, 0); @@ -565,7 +566,7 @@ void render_gl_gradient(Surface *sf, int x, int y, int w, int h) glVertex3i(x, y, 0); glEnd(); break; - case Background_Horizontal: + case Background_Vertical: glBegin(GL_TRIANGLES); glColor3f(pr, pg, pb); glVertex3i(x, y, 0); @@ -580,19 +581,78 @@ void render_gl_gradient(Surface *sf, int x, int y, int w, int h) glEnd(); break; case Background_Diagonal: -printf("diagonal\n"); + ar = (pr + sr) / 2.0; + ag = (pg + sg) / 2.0; + ab = (pb + sb) / 2.0; + glBegin(GL_TRIANGLES); + glColor3f(ar, ag, ab); + glVertex3i(x, y, 0); + glColor3f(pr, pg, pb); + glVertex3i(x+w, y, 0); + glColor3f(ar, ag, ab); + glVertex3i(x+w, y+h, 0); + + glColor3f(ar, ag, ab); + glVertex3i(x+w, y+h, 0); + glColor3f(sr, sg, sb); + glVertex3i(x, y+h, 0); + glColor3f(ar, ag, ab); + glVertex3i(x, y, 0); + glEnd(); break; case Background_CrossDiagonal: -printf("crossdiagonal\n"); + ar = (pr + sr) / 2.0; + ag = (pg + sg) / 2.0; + ab = (pb + sb) / 2.0; + glBegin(GL_TRIANGLES); + glColor3f(pr, pg, pb); + glVertex3i(x, y, 0); + glColor3f(ar, ag, ab); + glVertex3i(x+w, y, 0); + glColor3f(sr, sg, sb); + glVertex3i(x+w, y+h, 0); + + glColor3f(sr, sg, sb); + glVertex3i(x+w, y+h, 0); + glColor3f(ar, ag, ab); + glVertex3i(x, y+h, 0); + glColor3f(pr, pg, pb); + glVertex3i(x, y, 0); + glEnd(); break; case Background_Pyramid: printf("pyramid\n"); break; case Background_PipeCross: -printf("pipecross\n"); break; case Background_Rectangle: -printf("rect\n"); + glBegin(GL_TRIANGLES); + glColor3f(pr, pg, pb); + glVertex3i(x, y, 0); + glColor3f(sr, sg, sb); + glVertex3i(x+w/2, y+h/2, 0); + glColor3f(pr, pg, pb); + glVertex3i(x, y+h, 0); + + glVertex3i(x, y+h, 0); + glColor3f(sr, sg, sb); + glVertex3i(x+w/2, y+h/2, 0); + glColor3f(pr, pg, pb); + glVertex3i(x+w, y+h, 0); + + glVertex3i(x+w, y+h, 0); + glColor3f(sr, sg, sb); + glVertex3i(x+w/2, y+h/2, 0); + glColor3f(pr, pg, pb); + glVertex3i(x+w, y, 0); + + glVertex3i(x+w, y, 0); + glColor3f(sr, sg, sb); + glVertex3i(x+w/2, y+h/2, 0); + glColor3f(pr, pg, pb); + glVertex3i(x, y, 0); + + glEnd(); break; default: g_message("unhandled gradient"); diff --git a/render/test.c b/render/test.c index dcd646cf..2170a341 100644 --- a/render/test.c +++ b/render/test.c @@ -51,9 +51,9 @@ int main() render_startup(); look = appearance_new(Surface_Planar, 0); - look->surface.data.planar.grad = Background_Horizontal; - look->surface.data.planar.secondary = color_new(0xFF, 0xFF, 0xFF); - look->surface.data.planar.primary = color_parse("Black"); + look->surface.data.planar.grad = Background_Rectangle; + look->surface.data.planar.secondary = color_parse("Yellow"); + look->surface.data.planar.primary = color_parse("Blue"); look->surface.data.planar.interlaced = FALSE; look->area.x = 0; look->area.y = 0;