GFX Class Reference

#include <gfx.h>

Collaboration diagram for GFX:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GFX ()
 ~GFX ()
void init ()
 initialize SDL_VIDEO, OpenGL, fps counter and create window
void clean ()
 code at GFX shutdown
SDL_Surface * getScreen ()
void set3DOpenGL ()
 Switch OpenGL rendering to 3D mode. Is used when rendering game world.
void set2DOpenGL ()
 Switch OpenGL rendering to 2D mode. It is usefull for menu and ingame GUI.
int getWidth ()
 Get width of screen or -1 if unknown.
int getHeight ()
 Get height of screen or -1 if unknown.
bool checkExtension (const char *extensionName)
 Checks for OpenGL extension given by extensionName.
void swap_buffers (void)
 swaps OpenGL buffers.
int getFps (void)
 actual fps ratio
void resetFps (void)
 resets the fps counter

Private Member Functions

void initOpenGL ()
 OpenGL initialization code.
void prefetchOpenGLExtensions (void)
 Gets extension names.
void loadVideoSettings (void)
 Loads settings from settings-file (or uses default values if not found).

Private Attributes

SDL_Surface * mScreen
bool mGLMode3D
VideoSettings mVS
 current video settings
THashedStrings mOpenGLExtensions
 list of OpenGL extensions
Fps fps
 frames-per-second counter

Classes

struct  VideoSettings

Detailed Description

Definition at line 17 of file gfx.h.


Constructor & Destructor Documentation

GFX::GFX  ) 
 

Definition at line 17 of file gfx.cpp.

GFX::~GFX  ) 
 

Definition at line 22 of file gfx.cpp.


Member Function Documentation

bool GFX::checkExtension const char *  extensionName  ) 
 

Checks for OpenGL extension given by extensionName.

Returns:
true if extension is available, false otherwise.
Note:
The method prefetchOpenGLExtensions() has to be called before checkExtension. It is called in the initOpenGL() call.

Definition at line 214 of file gfx.cpp.

References mOpenGLExtensions.

Referenced by TextureManager::TextureManager().

void GFX::clean  ) 
 

code at GFX shutdown

Releases textures from TextureManager. If there still exist referenced textures, those becomes zombie.

See also:
TextureManager::erase()

Definition at line 118 of file gfx.cpp.

References Singleton< T >::getPtr(), and TIN.

Referenced by ApplicationClient::clean().

Here is the call graph for this function:

int GFX::getFps void   )  [inline]
 

actual fps ratio

Returns:
fps ratio

Definition at line 87 of file gfx.h.

References fps, and Fps::get().

Here is the call graph for this function:

int GFX::getHeight  ) 
 

Get height of screen or -1 if unknown.

Definition at line 207 of file gfx.cpp.

References GFX::VideoSettings::height, and mVS.

Referenced by GameClient::getCamera(), and TerrainGeoMipMap::TerrainBlock::getViewHRes().

SDL_Surface * GFX::getScreen  ) 
 

Returns:
Surface that represents screen. May be NULL.

Definition at line 148 of file gfx.cpp.

References mScreen.

int GFX::getWidth  ) 
 

Get width of screen or -1 if unknown.

Definition at line 200 of file gfx.cpp.

References mVS, and GFX::VideoSettings::width.

Referenced by Console::addConsoleMessage(), and GameClient::getCamera().

void GFX::init  ) 
 

initialize SDL_VIDEO, OpenGL, fps counter and create window

Definition at line 53 of file gfx.cpp.

References GFX::VideoSettings::attrs, GFX::VideoSettings::bpp, GFX::VideoSettings::height, initOpenGL(), loadVideoSettings(), LOGE, LOGI, mGLMode3D, mScreen, mVS, resetFps(), GFX::VideoSettings::SDL_flags, set3DOpenGL(), TIN, and GFX::VideoSettings::width.

Referenced by ApplicationClient::init().

Here is the call graph for this function:

void GFX::initOpenGL  )  [private]
 

OpenGL initialization code.

Definition at line 126 of file gfx.cpp.

References GFX::VideoSettings::height, mVS, prefetchOpenGLExtensions(), TIN, and GFX::VideoSettings::width.

Referenced by init().

Here is the call graph for this function:

void GFX::loadVideoSettings void   )  [private]
 

Loads settings from settings-file (or uses default values if not found).

Definition at line 27 of file gfx.cpp.

References GFX::VideoSettings::bpp, g_settings, Settings::getInt(), Settings::getString(), GFX::VideoSettings::height, Settings::isTrue(), mVS, GFX::VideoSettings::SDL_flags, TIN, and GFX::VideoSettings::width.

Referenced by init().

Here is the call graph for this function:

void GFX::prefetchOpenGLExtensions void   )  [private]
 

Gets extension names.

Note:
This have to be done before checkExtension calls.

Definition at line 96 of file gfx.cpp.

References LOGI, mOpenGLExtensions, and TIN.

Referenced by initOpenGL().

void GFX::resetFps void   ) 
 

resets the fps counter

Definition at line 229 of file gfx.cpp.

References fps, TimeManager::getTicks(), and Fps::init().

Referenced by TaskRender::init(), and init().

Here is the call graph for this function:

void GFX::set2DOpenGL  ) 
 

Switch OpenGL rendering to 2D mode. It is usefull for menu and ingame GUI.

Definition at line 177 of file gfx.cpp.

References GFX::VideoSettings::height, mGLMode3D, mVS, TIN, and GFX::VideoSettings::width.

Referenced by Messages::render(), Console::render(), and Layer::setView().

void GFX::set3DOpenGL  ) 
 

Switch OpenGL rendering to 3D mode. Is used when rendering game world.

Definition at line 154 of file gfx.cpp.

References GFX::VideoSettings::height, mGLMode3D, mVS, TIN, and GFX::VideoSettings::width.

Referenced by init(), and TaskRender::updateBegin().

void GFX::swap_buffers void   ) 
 

swaps OpenGL buffers.

This should be called after rendering, when we want to switch front and back buffers. You would preffer calling GFX::swap_buffers rather than SDL_GL_SwapBuffers and vice versa, because this counts frames and updates fps counter. Fps counter could be updated somewhere else, but this is sufficient.

Definition at line 220 of file gfx.cpp.

References fps, TimeManager::getTicks(), Fps::onFrameRendered(), and Fps::update().

Referenced by TaskRender::updateEnd().

Here is the call graph for this function:


Member Data Documentation

Fps GFX::fps [private]
 

frames-per-second counter

Definition at line 139 of file gfx.h.

Referenced by getFps(), resetFps(), and swap_buffers().

bool GFX::mGLMode3D [private]
 

Determines in what state the OpenGL is. 2D or 3D. It is used in set2DOpenGL() and set3DOpenGL() to not waist OpenGL commands.

Definition at line 120 of file gfx.h.

Referenced by init(), set2DOpenGL(), and set3DOpenGL().

THashedStrings GFX::mOpenGLExtensions [private]
 

list of OpenGL extensions

Definition at line 138 of file gfx.h.

Referenced by checkExtension(), and prefetchOpenGLExtensions().

SDL_Surface* GFX::mScreen [private]
 

Definition at line 113 of file gfx.h.

Referenced by getScreen(), and init().

struct VideoSettings GFX::mVS [private]
 

current video settings

Definition at line 137 of file gfx.h.

Referenced by getHeight(), getWidth(), init(), initOpenGL(), loadVideoSettings(), set2DOpenGL(), and set3DOpenGL().


The documentation for this class was generated from the following files:
Generated on Wed Apr 12 14:16:48 2006 for bjs by  doxygen 1.4.5