draw_pt_util.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   * Authors:
00030   *   Keith Whitwell <keith@tungstengraphics.com>
00031   */
00032 
00033 #include "draw/draw_context.h"
00034 #include "draw/draw_private.h"
00035 #include "draw/draw_pt.h"
00036 
00037 void draw_pt_split_prim(unsigned prim, unsigned *first, unsigned *incr)
00038 {
00039    switch (prim) {
00040    case PIPE_PRIM_POINTS:
00041       *first = 1;
00042       *incr = 1;
00043       break;
00044    case PIPE_PRIM_LINES:
00045       *first = 2;
00046       *incr = 2;
00047       break;
00048    case PIPE_PRIM_LINE_STRIP:
00049    case PIPE_PRIM_LINE_LOOP:
00050       *first = 2;
00051       *incr = 1;
00052       break;
00053    case PIPE_PRIM_TRIANGLES:
00054       *first = 3;
00055       *incr = 3;
00056       break;
00057    case PIPE_PRIM_TRIANGLE_STRIP:
00058    case PIPE_PRIM_TRIANGLE_FAN:
00059    case PIPE_PRIM_POLYGON:
00060       *first = 3;
00061       *incr = 1;
00062       break;
00063    case PIPE_PRIM_QUADS:
00064       *first = 4;
00065       *incr = 4;
00066       break;
00067    case PIPE_PRIM_QUAD_STRIP:
00068       *first = 4;
00069       *incr = 2;
00070       break;
00071    default:
00072       assert(0);
00073       *first = 0;
00074       *incr = 1;                /* set to one so that count % incr works */
00075       break;
00076    }
00077 }
00078 
00079 
00080 unsigned draw_pt_reduced_prim(unsigned prim)
00081 {
00082    switch (prim) {
00083    case PIPE_PRIM_POINTS:
00084       return PIPE_PRIM_POINTS;
00085    case PIPE_PRIM_LINES:
00086    case PIPE_PRIM_LINE_STRIP:
00087    case PIPE_PRIM_LINE_LOOP:
00088       return PIPE_PRIM_LINES;
00089    case PIPE_PRIM_TRIANGLES:
00090    case PIPE_PRIM_TRIANGLE_STRIP:
00091    case PIPE_PRIM_TRIANGLE_FAN:
00092    case PIPE_PRIM_POLYGON:
00093    case PIPE_PRIM_QUADS:
00094    case PIPE_PRIM_QUAD_STRIP:
00095       return PIPE_PRIM_TRIANGLES;
00096    default:
00097       assert(0);
00098       return PIPE_PRIM_POINTS;
00099    }
00100 }
00101 
00102 

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