GLFX::EffectManager Class Reference

#include <glfx.h>

Inheritance diagram for GLFX::EffectManager:

GLFX::EffectManager_DevIL GLFX::EffectManager_FreeImage List of all members.

Detailed Description

You can override this class to allow custom texture/file loading from within shader files. For now texture loading is completly disabled. External shader files will be searched from the current directory.
You have to call Initalize() initalize before use and Finzalize() before destruction.

Public Types

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 ()
IEffectLoadFX (const char *name)
Impl::EffectPool * GetEffectPool ()
void MessageFormat (long level, const char *fmt,...)
IFramebufferCreateFramebuffer (long width, long height, long depthBits, long stencilBits)
void CheckGLErrors (const char *location=0)
Impl::FontPool * GetFontPool ()
IFontLoadFont (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)
IVertexBufferCreateVertexBuffer (VertexComponent *format, unsigned long size, GLenum usage, unsigned long pool)
IIndexBufferCreateIndexBuffer (GLenum type, unsigned long size, GLenum usage, unsigned long pool)
IMeshCreateMesh (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)

Member Enumeration Documentation

anonymous enum

Vertex/index buffer memory pool.

POOL_SOFTWARE  Software buffer.
POOL_HARDWARE_VBO  Hardware buffer using ARB_vertex_buffer_object.
POOL_HARDWARE  Default hardware buffer pool.

anonymous enum

Log levels used by message methods.

LOG_DEBUG  Debug log level.
LOG_INFO  Informative log level.
LOG_NOTICE  General purpose information log level.
LOG_WARN  Warning log level.
LOG_ERROR  Error log level.

Member Function Documentation

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.
true if ok

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  ) 

Load effect (.glfx) from file.

Each IEffect object has to be deleted with call to Release().

name file name of the GLfx effect
IEffect interface to the effect or 0 if failed

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.

pointer to IEffectPool

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
IFRamebuffer reference or 0 on error

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.

IFontPool pointer

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 (  ) 

Returns the recently computed FPS - you have to call UpdateFPS() at each frame.


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.

name texture file name
OpenGL texture object identifier

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_*)
IVertexBuffer pointer or 0 if failed

IIndexBuffer* GLFX::EffectManager::CreateIndexBuffer ( GLenum  type,
unsigned long  size,
GLenum  usage,
unsigned long  pool 

Create index buffer.

size number of indices
usage GL_{STREAM|STATIC|DYNAMIC}_{DRAW|READ|COPY}, 0 -- default usage
pool memory pool (POOL_*)
IIndexBuffer pointer or 0 if failed

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
true if successful

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
true if successful

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:
	    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
true if successful

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.
non-relative file name

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
internal file handle, EffectManager will only use it to call ReadFile() and CloseFile()

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
number of bytes read

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.

true if end-of-file reached; false otherwise.

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
0 if successful

virtual long GLFX::EffectManager::TellFile ( void *  file  )  [virtual]

Gets the current position of a file pointer.

the current file position, -1 on error

The documentation for this class was generated from the following file: Logo