#include <glfx.h>
Inheritance diagram for GLFX::EffectManager:
Public Types | |
enum | { POOL_SOFTWARE = 0, POOL_HARDWARE_VBO = 1, POOL_HARDWARE = POOL_HARDWARE_VBO } |
enum | { LOG_DEBUG = 1000, LOG_INFO = 1200, LOG_NOTICE = 1500, LOG_WARN = 1700, LOG_ERROR = 2000 } |
Public Member Functions | |
bool | Initialize (bool currentStateDefault) |
void | Finalize () |
IEffect * | LoadFX (const char *name) |
Impl::EffectPool * | GetEffectPool () |
void | MessageFormat (long level, const char *fmt,...) |
IFramebuffer * | CreateFramebuffer (long width, long height, long depthBits, long stencilBits) |
void | CheckGLErrors (const char *location=0) |
Impl::FontPool * | GetFontPool () |
IFont * | LoadFont (const char *name, unsigned long fontSize) |
void | UpdateFPS () |
float | GetFPS () |
GLuint | LoadTexture (GLenum target, const char *name) |
void | DeleteTexture (GLuint texture) |
void | ReloadTextures () |
void | IncrTexRefCount (GLuint texture) |
IVertexBuffer * | CreateVertexBuffer (VertexComponent *format, unsigned long size, GLenum usage, unsigned long pool) |
IIndexBuffer * | CreateIndexBuffer (GLenum type, unsigned long size, GLenum usage, unsigned long pool) |
IMesh * | CreateMesh (unsigned long numVert, unsigned long numIndex, unsigned long numGroup, GLenum primitiveType, VertexComponent *format, GLenum indexType, GLenum vertexUsage, GLenum indexUsage, unsigned long vertexPool, unsigned long indexPool) |
bool | RegisterSceneLoader (ISceneLoader *sceneLoader) |
bool | LoadScene (const char *fileName, ISceneBuilder *sceneBuilder) |
void | LogGLInfo () |
virtual bool | FillTextureData (GLenum target, const char *name) |
virtual const char * | MakeAbsolutePath (const char *file, const char *referer) |
virtual void | Message (long level, const char *message) |
virtual void * | OpenFile (const char *name, bool writeFile) |
virtual long | ReadFile (void *file, void *buffer, long bytes) |
virtual void | CloseFile (void *file) |
virtual bool | Eof (void *file) |
virtual long | SeekFile (void *file, long offset, long origin) |
virtual long | TellFile (void *file) |
anonymous enum |
anonymous enum |
bool GLFX::EffectManager::Initialize | ( | bool | currentStateDefault | ) |
Initialized effect manager.
This method has to be called prior to use of any effects.
currentStateDefault | if set current OpenGL state will be used as default thus anything that was enabled/set prior to this call will be the default setting. If currentStateDefault is false OpenGL defaults will be used. |
void GLFX::EffectManager::Finalize | ( | ) |
Deinitializes EffectManager.
This method has to be called before object destruction and befor OpenGL termination.
IEffect* GLFX::EffectManager::LoadFX | ( | const char * | name | ) |
Impl::EffectPool* GLFX::EffectManager::GetEffectPool | ( | ) |
Returns pointer to internal IEffectPool implementation.
This method shouldn't be used, unless you're absolutely sure what you are doing.
void GLFX::EffectManager::MessageFormat | ( | long | level, | |
const char * | fmt, | |||
... | ||||
) |
Write a formatted message.
level | message level | |
fmt | formated message |
IFramebuffer* GLFX::EffectManager::CreateFramebuffer | ( | long | width, | |
long | height, | |||
long | depthBits, | |||
long | stencilBits | |||
) |
Creates a framebuffer interface object.
Note that IFramebuffer object has to be deleted with call to Release().
width | width of the framebuffer | |
height | height of the framebuffer | |
depthBits | number of bits in depth buffer | |
stencilBits | number of bits in stencil buffer |
void GLFX::EffectManager::CheckGLErrors | ( | const char * | location = 0 |
) | [inline] |
Check if there are any OpenGL errors, writes output message.
location | description of program location where the error has been detected |
Impl::FontPool* GLFX::EffectManager::GetFontPool | ( | ) |
Returns pointer to internal IFontPool implementation.
IFont* GLFX::EffectManager::LoadFont | ( | const char * | name, | |
unsigned long | fontSize | |||
) |
Loads a font from true-type font file.
Refer to freetype2 documentation for list of supported formats, as this library internaly uses freetype2.
name | font file, if 0 a default font is loaded | |
fontSize | font size in pixels |
void GLFX::EffectManager::UpdateFPS | ( | ) |
Call this method at the end of each frame to compute FPS.
float GLFX::EffectManager::GetFPS | ( | ) |
GLuint GLFX::EffectManager::LoadTexture | ( | GLenum | target, | |
const char * | name | |||
) |
This method is called load a texture.
Textures loaded with this method are managed (reference counted), so you have to call DeleteTexture in order to delete it. This method uses FillTextureData to load texture data.
target | type of texture (GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP) | |
name | texture file name |
void GLFX::EffectManager::DeleteTexture | ( | GLuint | texture | ) |
Decrease texture reference count, and if it is 0 this method deletes this texture.
texture | OpenGL texture object |
void GLFX::EffectManager::ReloadTextures | ( | ) |
Reload all textures.
void GLFX::EffectManager::IncrTexRefCount | ( | GLuint | texture | ) |
Increase texture reference count.
texture | OpenGL texture |
IVertexBuffer* GLFX::EffectManager::CreateVertexBuffer | ( | VertexComponent * | format, | |
unsigned long | size, | |||
GLenum | usage, | |||
unsigned long | pool | |||
) |
Create vertex buffer.
format | array of VertexComponent. Last element must have size equal to 0 | |
size | number of vertices | |
usage | GL_{STREAM|STATIC|DYNAMIC}_{DRAW|READ|COPY}, 0 -- default usage. | |
pool | memory pool (POOL_*) |
IIndexBuffer* GLFX::EffectManager::CreateIndexBuffer | ( | GLenum | type, | |
unsigned long | size, | |||
GLenum | usage, | |||
unsigned long | pool | |||
) |
Create index buffer.
type | on of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT | |
size | number of indices | |
usage | GL_{STREAM|STATIC|DYNAMIC}_{DRAW|READ|COPY}, 0 -- default usage | |
pool | memory pool (POOL_*) |
IMesh* GLFX::EffectManager::CreateMesh | ( | unsigned long | numVert, | |
unsigned long | numIndex, | |||
unsigned long | numGroup, | |||
GLenum | primitiveType, | |||
VertexComponent * | format, | |||
GLenum | indexType, | |||
GLenum | vertexUsage, | |||
GLenum | indexUsage, | |||
unsigned long | vertexPool, | |||
unsigned long | indexPool | |||
) |
Create mesh.
bool GLFX::EffectManager::RegisterSceneLoader | ( | ISceneLoader * | sceneLoader | ) |
Register a scene loader.
sceneLoader | implementation of ISceneLoader |
bool GLFX::EffectManager::LoadScene | ( | const char * | fileName, | |
ISceneBuilder * | sceneBuilder | |||
) |
Load a scene from file using specified ISceneBuilder.
fileName | name of scene file | |
sceneBuilder | ISceneBuilder implementation |
void GLFX::EffectManager::LogGLInfo | ( | ) |
Writes OpenGL information to log.
virtual bool GLFX::EffectManager::FillTextureData | ( | GLenum | target, | |
const char * | name | |||
) | [virtual] |
This method is called by EffectManager to fill the currently bound OpenGL texture.
Texture data may be loaded using e.g. glTexImage2D. Currently it does not load any texture files, you have to derive this class to allow texture loading. However it tries to match cube map name with file and recursivly call itself to load all faces. If the extension of this file is .cubemap than it parses the file.
.cubemap file grammar (using C++ style //
comments):
cubemap: faces faces: face+ face: face_name file face_name: "posx" | "px" | "posy" | "py" | "posz" | "pz" |"negx" | "nx" | "negy" | "ny" | "negz" | "nz" file: <ident> | <string> <ident> any character sequence ending with new line or a white character <string> any character sequence enclosed with ""Sample .cubemap file:
terrain.cubemap posx "terrain_px.jpg" negx "terrain_nx.jpg" posy "terrain_py.jpg" negy "terrain_ny.jpg" posz "terrain_pz.jpg" negz "terrain_nz.jpg"
target | texture target | |
name | texture name |
Reimplemented in GLFX::EffectManager_FreeImage, and GLFX::EffectManager_DevIL.
virtual const char* GLFX::EffectManager::MakeAbsolutePath | ( | const char * | file, | |
const char * | referer | |||
) | [virtual] |
Returns a non-relative path to file.
If the file name is relative than it is relative to the referer. The default implementation just returns the file name.
file | file name | |
referer | name of the file which refers to the file. |
virtual void GLFX::EffectManager::Message | ( | long | level, | |
const char * | message | |||
) | [virtual] |
This method is called by EffectManager to print a message, usualy a compiler warning.
This method just prints message to the standard output.
level | message level | |
message | message text |
virtual void* GLFX::EffectManager::OpenFile | ( | const char * | name, | |
bool | writeFile | |||
) | [virtual] |
This method is called by EffectManager to access a file.
It should open the file in read-only mode and return a handle to it, which may then be used in subsequent ReadFile() and CloseFile() calls.
name | file name | |
writeFile | if true open a file for writing, currently unsupported |
virtual long GLFX::EffectManager::ReadFile | ( | void * | file, | |
void * | buffer, | |||
long | bytes | |||
) | [virtual] |
This method is used by EffectManager to read data from a file opened with OpenFile().
file | file handle | |
buffer | data buffer to which data will be copied | |
bytes | number of bytes to read from the file |
virtual void GLFX::EffectManager::CloseFile | ( | void * | file | ) | [virtual] |
This method is used by EffectManager to close a file opened/ with call to OpenFile().
file | file handle |
virtual bool GLFX::EffectManager::Eof | ( | void * | file | ) | [virtual] |
This method checks if end-of-file has been reached.
virtual long GLFX::EffectManager::SeekFile | ( | void * | file, | |
long | offset, | |||
long | origin | |||
) | [virtual] |
Moves the file pointer to a specified location.
file | file handle | |
offset | number of bytes from origin | |
origin | initial position, may be SEEK_CUR, SEEK_END, SEEK_SET |
virtual long GLFX::EffectManager::TellFile | ( | void * | file | ) | [virtual] |
Gets the current position of a file pointer.