1
0
forked from 0ad/0ad
0ad/source/lib/sysdep/gfx.cpp
janwas 0bb0df5b2c # new year's cleanup (reduce dependencies, clean up headers)
- remove headers always included from PCH
- nommgr.h is only included ifdef REDEFINED_NEW (allows leaving out the
mmgr stuff)
- in lib/*.cpp, moved the corresponding include file to right behind the
PCH (catches headers that aren't compilable by themselves)
- byte_order no longer depends on SDL
- add debug_level (another means of filtering debug output; needed for
thesis)
- split posix stuff up into subdirs (lib/posix and sysdep/win/wposix).
makes including only some of the modules (e.g. sockets, time) much
easier.

This was SVN commit r4728.
2007-01-01 21:25:47 +00:00

67 lines
2.0 KiB
C++

/**
* =========================================================================
* File : gfx.cpp
* Project : 0 A.D.
* Description : graphics card detection.
*
* @author Jan.Wassenberg@stud.uni-karlsruhe.de
* =========================================================================
*/
/*
* Copyright (c) 2004-2005 Jan Wassenberg
*
* Redistribution and/or modification are also permitted under the
* terms of the GNU General Public License as published by the
* Free Software Foundation (version 2 or later, at your option).
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "precompiled.h"
#include "gfx.h"
#include "lib/lib.h"
#include "lib/sdl.h"
char gfx_card[GFX_CARD_LEN] = "";
char gfx_drv_ver[GFX_DRV_VER_LEN] = "";
int gfx_mem = -1; // [MiB]; approximate
extern LibError ogl_get_gfx_info();
// detect graphics card and set the above information.
void gfx_detect()
{
// TODO: add sizeof(FB)?
gfx_mem = (SDL_GetVideoInfo()->video_mem) / 1048576; // [MiB]
// try platform-specific version: they return more
// detailed information, and don't require OpenGL to be ready.
#if OS_WIN
extern LibError win_get_gfx_info();
if(win_get_gfx_info() < 0)
#endif
{
// the OpenGL version should always work, unless OpenGL isn't ready for use,
// or we were called between glBegin and glEnd.
ogl_get_gfx_info();
}
// remove crap from vendor names. (don't dare touch the model name -
// it's too risky, there are too many different strings)
#define SHORTEN(what, chars_to_keep)\
if(!strncmp(gfx_card, what, ARRAY_SIZE(what)-1))\
memmove(gfx_card+chars_to_keep, gfx_card+ARRAY_SIZE(what)-1, strlen(gfx_card)-(ARRAY_SIZE(what)-1)+1);
SHORTEN("ATI Technologies Inc.", 3);
SHORTEN("NVIDIA Corporation", 6);
SHORTEN("S3 Graphics", 2); // returned by EnumDisplayDevices
SHORTEN("S3 Graphics, Incorporated", 2); // returned by GL_VENDOR
#undef SHORTEN
}