Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

DisplayModeInfo.c

Go to the documentation of this file.
00001 /****************************************************************************************/
00002 /*  DisplayModeInfo.C                                                                   */
00003 /*                                                                                      */
00004 /*  Author:  Mike Sandige                                                               */
00005 /*  Description:  This is a simple container to hold information about available display*/
00006 /*                modes for the software driver.                                        */
00007 /*                                                                                      */
00008 /*  The contents of this file are subject to the Genesis3D Public License               */
00009 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00010 /*  compliance with the License. You may obtain a copy of the License at                */
00011 /*  http://www.genesis3d.com                                                            */
00012 /*                                                                                      */
00013 /*  Software distributed under the License is distributed on an "AS IS"                 */
00014 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00015 /*  the License for the specific language governing rights and limitations              */
00016 /*  under the License.                                                                  */
00017 /*                                                                                      */
00018 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00019 /*Genesis3D Version 1.1 released November 15, 1999                            */
00020 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */
00021 /*                                                                                      */
00022 /****************************************************************************************/
00023 #include <stdlib.h>
00024 #include <assert.h>
00025 #include "DisplayModeInfo.h"
00026 
00027 #ifdef GENESIS_VERSION_2
00028 #include "errorlog.h"
00029 #else
00030 #define geErrorLog_AddString(Error,xx,yy) 
00031 #endif
00032 
00033 
00034 #define DISPLAYMODES_MAX 16
00035 
00036 typedef struct DisplayModeInfo_Data
00037 {
00038         int             Width;
00039         int             Height;
00040         int             BitsPerPixel;
00041         uint32  Flags;
00042 }       DisplayModeInfo_Data;
00043 
00044 
00045 typedef struct DisplayModeInfo
00046 {
00047         DisplayModeInfo_Data     Mode[DISPLAYMODES_MAX];
00048         int                                              ModeCount;
00049 }       DisplayModeInfo;
00050 
00051 
00052 DisplayModeInfo *DisplayModeInfo_Create(void)
00053 {
00054         DisplayModeInfo *Info;
00055 
00056         Info = malloc(sizeof(*Info));
00057         if (Info == NULL)
00058                 {
00059                         geErrorLog_AddString(GE_ERR_MEMORY_RESOURCE,"DisplayModeInfo:  unable to get memory for object",NULL);
00060                         return NULL;
00061                 }
00062         Info-> ModeCount = 0;
00063         return Info;
00064 }
00065 
00066 void DisplayModeInfo_Destroy(DisplayModeInfo **Info)
00067 {
00068         assert ( Info != NULL );
00069         assert (*Info != NULL );
00070         free ( *Info );
00071         *Info = NULL;
00072 }
00073 
00074 int DisplayModeInfo_GetModeCount(DisplayModeInfo *Info)
00075 {
00076         assert( Info != NULL );
00077 
00078         return Info->ModeCount;
00079 }
00080 
00081 geBoolean DisplayModeInfo_AddEntry(DisplayModeInfo *Info, 
00082                                 int Width,
00083                                 int Height,
00084                                 int BitsPerPixel,
00085                                 uint32 Flags)
00086 {
00087         assert( Info != NULL );
00088 
00089         if (Info->ModeCount<DISPLAYMODES_MAX)
00090                 {
00091                         Info->Mode[Info->ModeCount].Width        = Width;
00092                         Info->Mode[Info->ModeCount].Height       = Height;
00093                         Info->Mode[Info->ModeCount].BitsPerPixel = BitsPerPixel;
00094                         Info->Mode[Info->ModeCount].Flags        = Flags;
00095                         Info->ModeCount++;
00096                         return GE_TRUE;
00097                 }
00098         else
00099                 {
00100                         geErrorLog_AddString(GE_ERR_INTERNAL_RESOURCE,"GE_DisplayModeInfo_AddEntry:Too many modes",NULL);
00101                         return GE_FALSE;
00102                 }
00103 }
00104 
00105 geBoolean DisplayModeInfo_GetNth(DisplayModeInfo *Info, int Nth,
00106                                 int *Width, 
00107                                 int *Height,
00108                                 int *BitsPerPixel,
00109                                 uint32 *Flags)
00110 {
00111         assert( Info != NULL );
00112         assert( Width        != NULL );
00113         assert( Height       != NULL );
00114         assert( BitsPerPixel != NULL );
00115         assert( Flags        != NULL );
00116         if ((Nth < 0) || (Nth > Info->ModeCount))
00117                 {
00118                         geErrorLog_AddString(GE_ERR_BAD_PARAMETER,"DisplayModeInfo_GetNth:  bad mode index",geErrorLog_IntToString(Nth));
00119                         return GE_FALSE;
00120                 }
00121 
00122         *Width        = Info->Mode[Nth].Width;
00123         *Height       = Info->Mode[Nth].Height;
00124         *BitsPerPixel = Info->Mode[Nth].BitsPerPixel;
00125         *Flags        = Info->Mode[Nth].Flags;
00126         return GE_TRUE;
00127 }
00128 

Generated on Tue Sep 30 12:35:38 2003 for GTestAndEngine by doxygen 1.3.2