Basic 3D graphics for the MBED application-shield on-board LCD (initial/incomplete).

Dependents:   co657_lcdplay

Revision:
9:db4ec6f7d8b2
Parent:
8:55ee7af49f47
diff -r 55ee7af49f47 -r db4ec6f7d8b2 g3d_render.cpp
--- a/g3d_render.cpp	Sat Nov 28 01:40:16 2015 +0000
+++ b/g3d_render.cpp	Sun Nov 29 00:03:41 2015 +0000
@@ -667,6 +667,14 @@
         int16_t z1 = edge->zend[0];
         int32_t zval = (z0 << 16) | 0x8000;    /* half-way.. */
         
+        if (xp >= DISPLAY_WIDTH) {
+            /* off right-hand edge */
+            return;
+        } else if (xp < 0) {
+            /* off left-hand edge */
+            return;
+        }
+        
         if ((y0 == y1) || ((y0 + ys) == y1)) {
             /* one or two point, since we're narrow, just y0 */
             if (z0 <= ZBUFFER (xp, y0)) {
@@ -701,7 +709,11 @@
         int16_t z1 = edge->zend[x];
         
         int32_t zval = (z0 << 16) | 0x8000;     /* half-way.. */
-        
+
+        if ((xp >= DISPLAY_WIDTH) || (xp < 0)) {
+            continue;
+        }
+
         if (y0 == y1) {
             /* point, but we don't plot assuming it belongs to the adjoining polygon */
         } else if ((y0 + ys) == y1) {