Commit 1d2a0a8eb394034b838f759678b2dca74d0de52e
authorMichel Pollet <buserror@gmail.com>
Fri, 15 Jun 2012 08:17:07 +0000 (09:17 +0100)
committerMichel Pollet <buserror@gmail.com>
Fri, 15 Jun 2012 08:17:07 +0000 (09:17 +0100)
Make sure the light pseudo geometries are always
at the top of the list

Signed-off-by: Michel Pollet <buserror@gmail.com>
2 files changed:
examples/shared/libc3/src/c3context.c
examples/shared/libc3/src/c3context.h

index af8e901901845e3fd9b84f1fa405e398f3d3c30b..e77122cfcbae981977ebb9d1718b2fc48fd37ab1 100644 (file)
@@ -22,6 +22,7 @@
 #include <math.h>
 #include "c3context.h"
 #include "c3object.h"
+#include "c3light.h"
 #include "c3driver_context.h"
 
 c3context_p
@@ -45,6 +46,7 @@ c3context_init(
                        .type = C3_CONTEXT_VIEW_EYE,
                        .size = c3vec2f(w, h),
                        .dirty = 1,
+                       .index = c->views.count,
        };
        c3cam_init(&v.cam);
        c3context_view_array_add(&c->views, v);
@@ -95,6 +97,10 @@ _c3_z_sorter(
                d1 -= 100000.0;
        if (g2->mat.color.n[3] < 1)
                d2 -= 100000.0;
+       if (g1->type.type == C3_LIGHT_TYPE)
+               d1 = -200000 + (int)(((c3light_p)g1)->light_id);
+       if (g2->type.type == C3_LIGHT_TYPE)
+               d2 = -200000 + (int)(((c3light_p)g2)->light_id);
 
        return d1 < d2 ? 1 : d1 > d2 ? -1 : 0;
 }
@@ -158,3 +164,4 @@ c3context_draw(
                c3geometry_draw(g);
        }
 }
+
index aac6be8e8325978b6f9cdff3ec9a19cf31b80df6..3bce667c86ec4f5c0c80e18de004ed4bb00ff8a7 100644 (file)
 #include "c3camera.h"
 
 enum {
-       C3_CONTEXT_VIEW_EYE = 0,
+       C3_CONTEXT_VIEW_NONE = 0,
+       C3_CONTEXT_VIEW_EYE,
        C3_CONTEXT_VIEW_LIGHT
 };
 
 typedef struct c3context_view_t {
-       int                     type : 4,       // C3_CONTEXT_VIEW_EYE...
-                               dirty : 1;
-       c3vec2          size;                                   // in pixels. for fbo/textures/window
+       int                     type : 4,                       // C3_CONTEXT_VIEW_EYE...
+                               dirty : 1,
+                               index : 4;                      // index in context array
+       c3apiobject_t   bid;                    // buffer id (fbo, texture...)
+       c3vec2          size;                           // in pixels. for fbo/textures/window
        c3cam_t         cam;
-       c3mat4          projection;                             // projection matrix
+       c3mat4          projection;                     // projection matrix
 
        c3geometry_array_t      projected;
        struct {