stw_pixelformat.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2008 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 #include "pipe/p_debug.h"
00029 #include "stw_pixelformat.h"
00030 
00031 #define MAX_PIXELFORMATS   16
00032 
00033 static struct pixelformat_info pixelformats[MAX_PIXELFORMATS];
00034 static uint pixelformat_count = 0;
00035 static uint pixelformat_extended_count = 0;
00036 
00037 static void
00038 add_standard_pixelformats(
00039    struct pixelformat_info **ppf,
00040    uint flags )
00041 {
00042    struct pixelformat_info *pf = *ppf;
00043    struct pixelformat_color_info color24 = { 8, 0, 8, 8, 8, 16 };
00044    struct pixelformat_alpha_info alpha8 = { 8, 24 };
00045    struct pixelformat_alpha_info noalpha = { 0, 0 };
00046    struct pixelformat_depth_info depth24s8 = { 24, 8 };
00047    struct pixelformat_depth_info depth16 = { 16, 0 };
00048 
00049    pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
00050    pf->color = color24;
00051    pf->alpha = alpha8;
00052    pf->depth = depth16;
00053    pf++;
00054 
00055    pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
00056    pf->color = color24;
00057    pf->alpha = alpha8;
00058    pf->depth = depth24s8;
00059    pf++;
00060 
00061    pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
00062    pf->color = color24;
00063    pf->alpha = noalpha;
00064    pf->depth = depth16;
00065    pf++;
00066 
00067    pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
00068    pf->color = color24;
00069    pf->alpha = noalpha;
00070    pf->depth = depth24s8;
00071    pf++;
00072 
00073    pf->flags = flags;
00074    pf->color = color24;
00075    pf->alpha = noalpha;
00076    pf->depth = depth16;
00077    pf++;
00078 
00079    pf->flags = flags;
00080    pf->color = color24;
00081    pf->alpha = noalpha;
00082    pf->depth = depth24s8;
00083    pf++;
00084 
00085    *ppf = pf;
00086 }
00087 
00088 void
00089 pixelformat_init( void )
00090 {
00091    struct pixelformat_info *pf = pixelformats;
00092 
00093    add_standard_pixelformats( &pf, 0 );
00094    pixelformat_count = pf - pixelformats;
00095 
00096    add_standard_pixelformats( &pf, PF_FLAG_MULTISAMPLED );
00097    pixelformat_extended_count = pf - pixelformats;
00098 
00099    assert( pixelformat_extended_count <= MAX_PIXELFORMATS );
00100 }
00101 
00102 uint
00103 pixelformat_get_count( void )
00104 {
00105    return pixelformat_count;
00106 }
00107 
00108 uint
00109 pixelformat_get_extended_count( void )
00110 {
00111    return pixelformat_extended_count;
00112 }
00113 
00114 const struct pixelformat_info *
00115 pixelformat_get_info( uint index )
00116 {
00117    assert( index < pixelformat_extended_count );
00118 
00119    return &pixelformats[index];
00120 }

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