draw_vertex.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00028 /*
00029  * Functions for specifying the post-transformation vertex layout.
00030  *
00031  * Author:
00032  *    Brian Paul
00033  *    Keith Whitwell
00034  */
00035 
00036 
00037 #include "draw/draw_private.h"
00038 #include "draw/draw_vertex.h"
00039 
00040 
00045 void
00046 draw_compute_vertex_size(struct vertex_info *vinfo)
00047 {
00048    uint i;
00049 
00050    vinfo->size = 0;
00051    for (i = 0; i < vinfo->num_attribs; i++) {
00052       switch (vinfo->attrib[i].emit) {
00053       case EMIT_OMIT:
00054          break;
00055       case EMIT_4UB:
00056          /* fall-through */
00057       case EMIT_1F_PSIZE:
00058          /* fall-through */
00059       case EMIT_1F:
00060          vinfo->size += 1;
00061          break;
00062       case EMIT_2F:
00063          vinfo->size += 2;
00064          break;
00065       case EMIT_3F:
00066          vinfo->size += 3;
00067          break;
00068       case EMIT_4F:
00069          vinfo->size += 4;
00070          break;
00071       default:
00072          assert(0);
00073       }
00074    }
00075 }
00076 
00077 
00078 void
00079 draw_dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data)
00080 {
00081    unsigned i, j;
00082 
00083    for (i = 0; i < vinfo->num_attribs; i++) {
00084       j = vinfo->attrib[i].src_index;
00085       switch (vinfo->attrib[i].emit) {
00086       case EMIT_OMIT:
00087          debug_printf("EMIT_OMIT:");
00088          break;
00089       case EMIT_1F:
00090          debug_printf("EMIT_1F:\t");
00091          debug_printf("%f ", *(float *)data); data += sizeof(float);
00092          break;
00093       case EMIT_1F_PSIZE:
00094          debug_printf("EMIT_1F_PSIZE:\t");
00095          debug_printf("%f ", *(float *)data); data += sizeof(float);
00096          break;
00097       case EMIT_2F:
00098          debug_printf("EMIT_2F:\t");
00099          debug_printf("%f ", *(float *)data); data += sizeof(float);
00100          debug_printf("%f ", *(float *)data); data += sizeof(float);
00101          break;
00102       case EMIT_3F:
00103          debug_printf("EMIT_3F:\t");
00104          debug_printf("%f ", *(float *)data); data += sizeof(float);
00105          debug_printf("%f ", *(float *)data); data += sizeof(float);
00106          debug_printf("%f ", *(float *)data); data += sizeof(float);
00107          data += sizeof(float);
00108          break;
00109       case EMIT_4F:
00110          debug_printf("EMIT_4F:\t");
00111          debug_printf("%f ", *(float *)data); data += sizeof(float);
00112          debug_printf("%f ", *(float *)data); data += sizeof(float);
00113          debug_printf("%f ", *(float *)data); data += sizeof(float);
00114          debug_printf("%f ", *(float *)data); data += sizeof(float);
00115          break;
00116       case EMIT_4UB:
00117          debug_printf("EMIT_4UB:\t");
00118          debug_printf("%u ", *data++);
00119          debug_printf("%u ", *data++);
00120          debug_printf("%u ", *data++);
00121          debug_printf("%u ", *data++);
00122          break;
00123       default:
00124          assert(0);
00125       }
00126       debug_printf("\n");
00127    }
00128    debug_printf("\n");
00129 }

Generated on Tue Sep 29 06:25:14 2009 for Gallium3D by  doxygen 1.5.4