]> Dogcows Code - chaz/openbox/commitdiff
rectangle and diagonal grads yay
authorDerek Foreman <manmower@gmail.com>
Sun, 25 May 2003 02:46:35 +0000 (02:46 +0000)
committerDerek Foreman <manmower@gmail.com>
Sun, 25 May 2003 02:46:35 +0000 (02:46 +0000)
gl > *

render/gradient.c
render/test.c

index 3a963406c33b0385165cac42fbdd3cdea7173c8b..aedd3bbe8d29eed24f8cfc690f197344601ce6a4 100644 (file)
@@ -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");
index dcd646cfbe010a2cbf4c8ca254e8646cbf6e9ce7..2170a34104d0594d41b9f2d019cb5da7d819a595 100644 (file)
@@ -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;
This page took 0.026664 seconds and 4 git commands to generate.