class DGlobal | .h |
constructor | DGlobal() |
destructor | ~DGlobal() |
FilterN2S | cstring FilterN2S(int n) Convert OpenGL filter to string |
FilterS2N | int FilterS2N(cstring s) |
class DPrefs | .h |
constructor | DPrefs() Default preferences |
destructor | ~DPrefs() |
Reset | void Reset() Set default preferences |
UseMipMapping | bool UseMipMapping() Returns TRUE if prefs wants to use mipmapping |
class DTexturePool | .h |
constructor | DTexturePool() |
destructor | ~DTexturePool() |
Add | bool Add(cstring name,DTexture *texture) |
Find | DTexture *Find(cstring name) |
Flat functions |
if | if(t)cntHits++; else cntMiss++; qdbg(" hits: %d, misses: %d\n",cntHits,cntMiss); #endif return t; } |
/*
* DGlobal - application-wide structures and settings
* 10-01-01: Created!
* NOTES:
* (C) MarketGraph/RvG
*/
#include <d3/d3.h>
#pragma hdrstop
#include <d3/global.h>
#include <qlib/debug.h>
DEBUG_ENABLE
/*********
* Global *
*********/
DGlobal::DGlobal()
{
texturePool=new DTexturePool();
}
DGlobal::~DGlobal()
{
delete texturePool;
}
cstring DGlobal::FilterN2S(int n)
// Convert OpenGL filter to string
{
switch(n)
{
case GL_LINEAR : return "GL_LINEAR";
case GL_NEAREST: return "GL_NEAREST";
case GL_LINEAR_MIPMAP_NEAREST : return "GL_LINEAR_MIPMAP_NEAREST";
case GL_LINEAR_MIPMAP_LINEAR : return "GL_LINEAR_MIPMAP_LINEAR";
case GL_NEAREST_MIPMAP_NEAREST: return "GL_NEAREST_MIPMAP_NEAREST";
case GL_NEAREST_MIPMAP_LINEAR : return "GL_NEAREST_MIPMAP_LINEAR";
default: qwarn("DGlobal::FilterN2S(%d) unknown",n);
return "???";
}
}
int DGlobal::FilterS2N(cstring s)
{
if(!strcmp(s,"GL_LINEAR"))return GL_LINEAR;
if(!strcmp(s,"GL_NEAREST"))return GL_NEAREST;
if(!strcmp(s,"GL_LINEAR_MIPMAP_NEAREST"))return GL_LINEAR_MIPMAP_NEAREST;
if(!strcmp(s,"GL_LINEAR_MIPMAP_LINEAR"))return GL_LINEAR_MIPMAP_LINEAR;
if(!strcmp(s,"GL_NEAREST_MIPMAP_NEAREST"))return GL_NEAREST_MIPMAP_NEAREST;
if(!strcmp(s,"GL_NEAREST_MIPMAP_LINEAR"))return GL_NEAREST_MIPMAP_LINEAR;
qwarn("DGlobal::FilterS2N(%s) unknown",s);
return GL_NEAREST;
}
/**************
* Preferences *
**************/
DPrefs::DPrefs()
// Default preferences
{
Reset();
}
DPrefs::~DPrefs()
{
}
void DPrefs::Reset()
// Set default preferences
{
minFilter=GL_LINEAR;
maxFilter=GL_LINEAR;
wrapS=wrapT=wrapP=wrapQ=DTexture::CLAMP;
// Default env mode is replace, which means no lighting.
// To use lighting, use DTexture::MODULATE for example.
envMode=DTexture::REPLACE;
flags=0;
}
bool DPrefs::UseMipMapping()
// Returns TRUE if prefs wants to use mipmapping
{
switch(minFilter)
{
case GL_LINEAR_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_LINEAR:
case GL_NEAREST_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
return TRUE;
}
return FALSE;
}
/***************
* DTexturePool *
***************/
DTexturePool::DTexturePool()
{
//map<string,DTexture*> pool;
}
DTexturePool::~DTexturePool()
{
}
bool DTexturePool::Add(cstring name,DTexture *texture)
{
//qdbg("DTexturePool:Add(%s,%p)\n",name,texture);
pool[(string)name]=texture;
return TRUE;
}
DTexture *DTexturePool::Find(cstring name)
{
DTexture *t;
t=pool[(string)name];
#ifdef OBS
static int cntMiss,cntHits;
qdbg("DTexturePool:Find(%s)=%p\n",name,t);
if(t)cntHits++; else cntMiss++;
qdbg(" hits: %d, misses: %d\n",cntHits,cntMiss);
#endif
return t;
}