gallium: a lot more complete implementation of stream output
[mesa.git] / src / gallium / auxiliary / draw / draw_pt_elts.c
index 02fb6d9f41db8c4191fdf3730f3d0c33c80b8961..88f4d9f495ac306aa0f0e1ae9138d1b9362c2dcb 100644 (file)
@@ -30,8 +30,8 @@
   *   Keith Whitwell <keith@tungstengraphics.com>
   */
 
-#include "draw/draw_private.h"
 #include "draw/draw_pt.h"
+#include "draw/draw_private.h"
 
 /* Neat get_elt func that also works for varrays drawing by encoding
  * the start value into a pointer.  
@@ -54,16 +54,17 @@ static unsigned elt_ubyte( const void *elts, unsigned idx )
 
 static unsigned elt_vert( const void *elts, unsigned idx )
 {
-   return (const ubyte *)elts - (const ubyte *)NULL + idx;
+   /* unsigned index is packed in the pointer */
+   return (unsigned)(uintptr_t)elts + idx;
 }
 
 pt_elt_func draw_pt_elt_func( struct draw_context *draw )
 {
-   switch (draw->user.eltSize) {
-   case 0: return elt_vert;
-   case 1: return elt_ubyte;
-   case 2: return elt_ushort; 
-   case 4: return elt_uint;
+   switch (draw->pt.user.eltSize) {
+   case 0: return &elt_vert;
+   case 1: return &elt_ubyte;
+   case 2: return &elt_ushort; 
+   case 4: return &elt_uint;
    default: return NULL;
    }
 }     
@@ -71,9 +72,9 @@ pt_elt_func draw_pt_elt_func( struct draw_context *draw )
 const void *draw_pt_elt_ptr( struct draw_context *draw,
                              unsigned start )
 {
-   const char *elts = draw->user.elts;
+   const char *elts = draw->pt.user.elts;
 
-   switch (draw->user.eltSize) {
+   switch (draw->pt.user.eltSize) {
    case 0: 
       return (const void *)(((const ubyte *)NULL) + start);
    case 1: