Rename 'Tex' to 'TEX' for consistency

This commit is contained in:
Jonas Kulla 2013-09-06 12:26:41 +02:00
parent ba3b904f34
commit b151a22f6e
13 changed files with 128 additions and 128 deletions

View File

@ -42,7 +42,7 @@
struct BitmapPrivate struct BitmapPrivate
{ {
TexFBO tex; TEXFBO tex;
/* 'setPixel()' calls are cached and executed /* 'setPixel()' calls are cached and executed
* in batches on 'flush()' */ * in batches on 'flush()' */
@ -57,8 +57,8 @@ struct BitmapPrivate
void bindTextureWithMatrix() void bindTextureWithMatrix()
{ {
Tex::bind(tex.tex); TEX::bind(tex.tex);
Tex::bindMatrix(tex.width, tex.height); TEX::bindMatrix(tex.width, tex.height);
} }
void bindFBO() void bindFBO()
@ -88,7 +88,7 @@ struct BitmapPrivate
if (pointArray.count() == 0) if (pointArray.count() == 0)
return; return;
Tex::unbind(); TEX::unbind();
bindFBO(); bindFBO();
pushSetViewport(); pushSetViewport();
glState.blendMode.pushSet(BlendNone); glState.blendMode.pushSet(BlendNone);
@ -139,7 +139,7 @@ Bitmap::Bitmap(const char *filename)
if (!imgSurf) if (!imgSurf)
throw Exception(Exception::SDLError, "SDL: %s", SDL_GetError()); throw Exception(Exception::SDLError, "SDL: %s", SDL_GetError());
TexFBO tex; TEXFBO tex;
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888); p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
@ -148,8 +148,8 @@ Bitmap::Bitmap(const char *filename)
p = new BitmapPrivate; p = new BitmapPrivate;
p->tex = tex; p->tex = tex;
Tex::bind(p->tex.tex); TEX::bind(p->tex.tex);
Tex::uploadImage(p->tex.width, p->tex.height, imgSurf->pixels, GL_RGBA); TEX::uploadImage(p->tex.width, p->tex.height, imgSurf->pixels, GL_RGBA);
SDL_FreeSurface(imgSurf); SDL_FreeSurface(imgSurf);
} }
@ -159,7 +159,7 @@ Bitmap::Bitmap(int width, int height)
if (width <= 0 || height <= 0) if (width <= 0 || height <= 0)
throw Exception(Exception::RGSSError, "failed to create bitmap"); throw Exception(Exception::RGSSError, "failed to create bitmap");
TexFBO tex = gState->texPool().request(width, height); TEXFBO tex = gState->texPool().request(width, height);
p = new BitmapPrivate; p = new BitmapPrivate;
p->tex = tex; p->tex = tex;
@ -237,7 +237,7 @@ void Bitmap::stretchBlt(const IntRect &destRect,
float normOpacity = (float) opacity / 255.0f; float normOpacity = (float) opacity / 255.0f;
TexFBO &gpTex = gState->gpTexFBO(destRect.w, destRect.h); TEXFBO &gpTex = gState->gpTexFBO(destRect.w, destRect.h);
FBO::bind(gpTex.fbo, FBO::Draw); FBO::bind(gpTex.fbo, FBO::Draw);
FBO::bind(p->tex.fbo, FBO::Read); FBO::bind(p->tex.fbo, FBO::Read);
@ -322,7 +322,7 @@ void Bitmap::gradientFillRect(const IntRect &rect,
quad.setPosRect(rect); quad.setPosRect(rect);
Tex::unbind(); TEX::unbind();
p->bindFBO(); p->bindFBO();
p->pushSetViewport(); p->pushSetViewport();
@ -401,7 +401,7 @@ void Bitmap::hueChange(int hue)
flush(); flush();
TexFBO newTex = gState->texPool().request(width(), height()); TEXFBO newTex = gState->texPool().request(width(), height());
FloatRect texRect(rect()); FloatRect texRect(rect());
@ -419,7 +419,7 @@ void Bitmap::hueChange(int hue)
shader.setInputTexture(p->tex.tex); shader.setInputTexture(p->tex.tex);
FBO::bind(newTex.fbo); FBO::bind(newTex.fbo);
Tex::bindMatrix(width(), height()); TEX::bindMatrix(width(), height());
p->pushSetViewport(); p->pushSetViewport();
p->blitQuad(quad); p->blitQuad(quad);
@ -500,7 +500,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
{ {
/* Aquire a partial copy of the destination /* Aquire a partial copy of the destination
* buffer we're about to render to */ * buffer we're about to render to */
TexFBO &gpTex2 = gState->gpTexFBO(posRect.w, posRect.h); TEXFBO &gpTex2 = gState->gpTexFBO(posRect.w, posRect.h);
FBO::bind(gpTex2.fbo, FBO::Draw); FBO::bind(gpTex2.fbo, FBO::Draw);
FBO::bind(p->tex.fbo, FBO::Read); FBO::bind(p->tex.fbo, FBO::Read);
@ -519,8 +519,8 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
} }
gState->bindTex(); gState->bindTex();
Tex::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA); TEX::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA);
Tex::setSmooth(true); TEX::setSmooth(true);
Quad &quad = gState->gpQuad(); Quad &quad = gState->gpQuad();
quad.setTexRect(FloatRect(0, 0, txtSurf->w, txtSurf->h)); quad.setTexRect(FloatRect(0, 0, txtSurf->w, txtSurf->h));
@ -563,7 +563,7 @@ void Bitmap::flush() const
p->flushPoints(); p->flushPoints();
} }
TexFBO &Bitmap::getGLTypes() TEXFBO &Bitmap::getGLTypes()
{ {
return p->tex; return p->tex;
} }

View File

@ -29,7 +29,7 @@
#include "sigc++/signal.h" #include "sigc++/signal.h"
class Font; class Font;
struct TexFBO; struct TEXFBO;
struct BitmapPrivate; struct BitmapPrivate;
// FIXME make this class use proper RGSS classes again // FIXME make this class use proper RGSS classes again
@ -102,7 +102,7 @@ public:
/* <internal> */ /* <internal> */
void flush() const; void flush() const;
TexFBO &getGLTypes(); TEXFBO &getGLTypes();
void bindTexWithMatrix(); void bindTexWithMatrix();
sigc::signal<void> modified; sigc::signal<void> modified;

View File

@ -46,7 +46,7 @@ struct ID \
} \ } \
}; };
namespace Tex namespace TEX
{ {
DEF_GL_ID DEF_GL_ID
@ -190,7 +190,7 @@ namespace FBO
bind(ID(0), mode); bind(ID(0), mode);
} }
inline void setTarget(Tex::ID target, unsigned colorAttach = 0) inline void setTarget(TEX::ID target, unsigned colorAttach = 0)
{ {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + colorAttach, GL_TEXTURE_2D, target.gl, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + colorAttach, GL_TEXTURE_2D, target.gl, 0);
} }
@ -303,48 +303,48 @@ struct GenericBO
typedef struct GenericBO<GL_ARRAY_BUFFER> VBO; typedef struct GenericBO<GL_ARRAY_BUFFER> VBO;
typedef struct GenericBO<GL_ELEMENT_ARRAY_BUFFER> IBO; typedef struct GenericBO<GL_ELEMENT_ARRAY_BUFFER> IBO;
struct TexFBO struct TEXFBO
{ {
Tex::ID tex; TEX::ID tex;
FBO::ID fbo; FBO::ID fbo;
int width, height; int width, height;
TexFBO() TEXFBO()
: tex(0), fbo(0), width(0), height(0) : tex(0), fbo(0), width(0), height(0)
{} {}
bool operator==(const TexFBO &other) const bool operator==(const TEXFBO &other) const
{ {
return (tex == other.tex) && (fbo == other.fbo); return (tex == other.tex) && (fbo == other.fbo);
} }
static inline void init(TexFBO &obj) static inline void init(TEXFBO &obj)
{ {
obj.tex = Tex::gen(); obj.tex = TEX::gen();
obj.fbo = FBO::gen(); obj.fbo = FBO::gen();
Tex::bind(obj.tex); TEX::bind(obj.tex);
Tex::setRepeat(false); TEX::setRepeat(false);
Tex::setSmooth(false); TEX::setSmooth(false);
} }
static inline void allocEmpty(TexFBO &obj, int width, int height) static inline void allocEmpty(TEXFBO &obj, int width, int height)
{ {
Tex::bind(obj.tex); TEX::bind(obj.tex);
Tex::allocEmpty(width, height); TEX::allocEmpty(width, height);
obj.width = width; obj.width = width;
obj.height = height; obj.height = height;
} }
static inline void linkFBO(TexFBO &obj) static inline void linkFBO(TEXFBO &obj)
{ {
FBO::bind(obj.fbo); FBO::bind(obj.fbo);
FBO::setTarget(obj.tex); FBO::setTarget(obj.tex);
} }
static inline void fini(TexFBO &obj) static inline void fini(TEXFBO &obj)
{ {
FBO::del(obj.fbo); FBO::del(obj.fbo);
Tex::del(obj.tex); TEX::del(obj.tex);
} }
}; };

View File

@ -76,10 +76,10 @@ struct GlobalStatePrivate
Font *defaultFont; Font *defaultFont;
Tex::ID globalTex; TEX::ID globalTex;
int globalTexW, globalTexH; int globalTexW, globalTexH;
TexFBO gpTexFBO; TEXFBO gpTexFBO;
Quad gpQuad; Quad gpQuad;
@ -114,22 +114,22 @@ struct GlobalStatePrivate
globalTexW = 128; globalTexW = 128;
globalTexH = 64; globalTexH = 64;
globalTex = Tex::gen(); globalTex = TEX::gen();
Tex::bind(globalTex); TEX::bind(globalTex);
Tex::setRepeat(false); TEX::setRepeat(false);
Tex::setSmooth(false); TEX::setSmooth(false);
Tex::allocEmpty(globalTexW, globalTexH); TEX::allocEmpty(globalTexW, globalTexH);
TexFBO::init(gpTexFBO); TEXFBO::init(gpTexFBO);
/* Reuse starting values */ /* Reuse starting values */
TexFBO::allocEmpty(gpTexFBO, globalTexW, globalTexH); TEXFBO::allocEmpty(gpTexFBO, globalTexW, globalTexH);
TexFBO::linkFBO(gpTexFBO); TEXFBO::linkFBO(gpTexFBO);
} }
~GlobalStatePrivate() ~GlobalStatePrivate()
{ {
Tex::del(globalTex); TEX::del(globalTex);
TexFBO::fini(gpTexFBO); TEXFBO::fini(gpTexFBO);
} }
}; };
@ -202,9 +202,9 @@ void GlobalState::bindQuadIBO()
void GlobalState::bindTex() void GlobalState::bindTex()
{ {
Tex::bind(p->globalTex); TEX::bind(p->globalTex);
Tex::allocEmpty(p->globalTexW, p->globalTexH); TEX::allocEmpty(p->globalTexW, p->globalTexH);
Tex::bindMatrix(p->globalTexW, p->globalTexH); TEX::bindMatrix(p->globalTexW, p->globalTexH);
} }
void GlobalState::ensureTexSize(int minW, int minH, Vec2 &currentSizeOut) void GlobalState::ensureTexSize(int minW, int minH, Vec2 &currentSizeOut)
@ -218,7 +218,7 @@ void GlobalState::ensureTexSize(int minW, int minH, Vec2 &currentSizeOut)
currentSizeOut = Vec2(p->globalTexW, p->globalTexH); currentSizeOut = Vec2(p->globalTexW, p->globalTexH);
} }
TexFBO &GlobalState::gpTexFBO(int minW, int minH) TEXFBO &GlobalState::gpTexFBO(int minW, int minH)
{ {
bool needResize = false; bool needResize = false;
@ -236,8 +236,8 @@ TexFBO &GlobalState::gpTexFBO(int minW, int minH)
if (needResize) if (needResize)
{ {
Tex::bind(p->gpTexFBO.tex); TEX::bind(p->gpTexFBO.tex);
Tex::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height); TEX::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height);
} }
return p->gpTexFBO; return p->gpTexFBO;

View File

@ -32,7 +32,7 @@ struct RGSSThreadData;
struct GlobalIBO; struct GlobalIBO;
struct mrb_state; struct mrb_state;
struct SDL_Window; struct SDL_Window;
struct TexFBO; struct TEXFBO;
struct Quad; struct Quad;
class Scene; class Scene;
@ -100,7 +100,7 @@ struct GlobalState
void bindTex(); void bindTex();
void ensureTexSize(int minW, int minH, Vec2 &currentSizeOut); void ensureTexSize(int minW, int minH, Vec2 &currentSizeOut);
TexFBO &gpTexFBO(int minW, int minH); TEXFBO &gpTexFBO(int minW, int minH);
Quad &gpQuad(); Quad &gpQuad();

View File

@ -216,7 +216,7 @@ struct CPUTimer
struct PingPong struct PingPong
{ {
TexFBO rt[2]; TEXFBO rt[2];
unsigned srcInd, dstInd; unsigned srcInd, dstInd;
int screenW, screenH; int screenW, screenH;
@ -226,9 +226,9 @@ struct PingPong
{ {
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
TexFBO::init(rt[i]); TEXFBO::init(rt[i]);
TexFBO::allocEmpty(rt[i], screenW, screenH); TEXFBO::allocEmpty(rt[i], screenW, screenH);
TexFBO::linkFBO(rt[i]); TEXFBO::linkFBO(rt[i]);
glClearColor(0, 0, 0, 1); glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
@ -237,7 +237,7 @@ struct PingPong
~PingPong() ~PingPong()
{ {
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
TexFBO::fini(rt[i]); TEXFBO::fini(rt[i]);
} }
/* Binds FBO of last good buffer for reading */ /* Binds FBO of last good buffer for reading */
@ -253,8 +253,8 @@ struct PingPong
screenH = height; screenH = height;
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
Tex::bind(rt[i].tex); TEX::bind(rt[i].tex);
Tex::allocEmpty(width, height); TEX::allocEmpty(width, height);
} }
} }
@ -268,8 +268,8 @@ struct PingPong
swapIndices(); swapIndices();
/* Discard dest buffer */ /* Discard dest buffer */
Tex::bind(rt[dstInd].tex); TEX::bind(rt[dstInd].tex);
Tex::allocEmpty(screenW, screenH); TEX::allocEmpty(screenW, screenH);
bind(); bind();
} }
@ -288,7 +288,7 @@ struct PingPong
private: private:
void bind() void bind()
{ {
Tex::bindWithMatrix(rt[srcInd].tex, screenW, screenH, true); TEX::bindWithMatrix(rt[srcInd].tex, screenW, screenH, true);
FBO::bind(rt[srcInd].fbo, FBO::Read); FBO::bind(rt[srcInd].fbo, FBO::Read);
FBO::bind(rt[dstInd].fbo, FBO::Draw); FBO::bind(rt[dstInd].fbo, FBO::Draw);
} }
@ -352,7 +352,7 @@ public:
glState.blendMode.pushSet(BlendNone); glState.blendMode.pushSet(BlendNone);
Tex::bindMatrix(geometry.rect.w, geometry.rect.h); TEX::bindMatrix(geometry.rect.w, geometry.rect.h);
screenQuad.draw(); screenQuad.draw();
glState.blendMode.pop(); glState.blendMode.pop();
@ -466,8 +466,8 @@ struct GraphicsPrivate
CPUTimer cpuTimer; CPUTimer cpuTimer;
bool frozen; bool frozen;
TexFBO frozenScene; TEXFBO frozenScene;
TexFBO currentScene; TEXFBO currentScene;
Quad screenQuad; Quad screenQuad;
RBOFBO transBuffer; RBOFBO transBuffer;
@ -483,13 +483,13 @@ struct GraphicsPrivate
cpuTimer(frameRate), cpuTimer(frameRate),
frozen(false) frozen(false)
{ {
TexFBO::init(frozenScene); TEXFBO::init(frozenScene);
TexFBO::allocEmpty(frozenScene, scRes.x, scRes.y); TEXFBO::allocEmpty(frozenScene, scRes.x, scRes.y);
TexFBO::linkFBO(frozenScene); TEXFBO::linkFBO(frozenScene);
TexFBO::init(currentScene); TEXFBO::init(currentScene);
TexFBO::allocEmpty(currentScene, scRes.x, scRes.y); TEXFBO::allocEmpty(currentScene, scRes.x, scRes.y);
TexFBO::linkFBO(currentScene); TEXFBO::linkFBO(currentScene);
FloatRect screenRect(0, 0, scRes.x, scRes.y); FloatRect screenRect(0, 0, scRes.x, scRes.y);
screenQuad.setTexPosRect(screenRect, screenRect); screenQuad.setTexPosRect(screenRect, screenRect);
@ -501,8 +501,8 @@ struct GraphicsPrivate
~GraphicsPrivate() ~GraphicsPrivate()
{ {
TexFBO::fini(frozenScene); TEXFBO::fini(frozenScene);
TexFBO::fini(currentScene); TEXFBO::fini(currentScene);
RBOFBO::fini(transBuffer); RBOFBO::fini(transBuffer);
} }
@ -700,7 +700,7 @@ void Graphics::transition(int duration,
shader.setCurrentScene(p->currentScene.tex); shader.setCurrentScene(p->currentScene.tex);
} }
Tex::bindMatrix(p->scRes.x, p->scRes.y); TEX::bindMatrix(p->scRes.x, p->scRes.y);
glState.blendMode.pushSet(BlendNone); glState.blendMode.pushSet(BlendNone);
@ -784,10 +784,10 @@ void Graphics::resizeScreen(int width, int height)
p->screen.setResolution(width, height); p->screen.setResolution(width, height);
Tex::bind(p->frozenScene.tex); TEX::bind(p->frozenScene.tex);
Tex::allocEmpty(width, height); TEX::allocEmpty(width, height);
Tex::bind(p->currentScene.tex); TEX::bind(p->currentScene.tex);
Tex::allocEmpty(width, height); TEX::allocEmpty(width, height);
FloatRect screenRect(0, 0, width, height); FloatRect screenRect(0, 0, width, height);
p->screenQuad.setTexPosRect(screenRect, screenRect); p->screenQuad.setTexPosRect(screenRect, screenRect);

View File

@ -187,11 +187,11 @@ void Plane::draw()
p->bitmap->flush(); p->bitmap->flush();
p->bitmap->bindTexWithMatrix(); p->bitmap->bindTexWithMatrix();
Tex::setRepeat(true); TEX::setRepeat(true);
p->quad.draw(); p->quad.draw();
Tex::setRepeat(false); TEX::setRepeat(false);
FragShader::unbind(); FragShader::unbind();
} }

View File

@ -85,7 +85,7 @@ void FragShader::setVec4Uniform(GLint location, const Vec4 &vec)
glUniform4f(location, vec.x, vec.y, vec.z, vec.w); glUniform4f(location, vec.x, vec.y, vec.z, vec.w);
} }
void FragShader::setTexUniform(GLint location, unsigned unitIndex, Tex::ID texture) void FragShader::setTexUniform(GLint location, unsigned unitIndex, TEX::ID texture)
{ {
GLenum texUnit = GL_TEXTURE0 + unitIndex; GLenum texUnit = GL_TEXTURE0 + unitIndex;
@ -108,17 +108,17 @@ TransShader::TransShader()
GET_U(vague); GET_U(vague);
} }
void TransShader::setCurrentScene(Tex::ID tex) void TransShader::setCurrentScene(TEX::ID tex)
{ {
setTexUniform(u_currentScene, 0, tex); setTexUniform(u_currentScene, 0, tex);
} }
void TransShader::setFrozenScene(Tex::ID tex) void TransShader::setFrozenScene(TEX::ID tex)
{ {
setTexUniform(u_frozenScene, 1, tex); setTexUniform(u_frozenScene, 1, tex);
} }
void TransShader::setTransMap(Tex::ID tex) void TransShader::setTransMap(TEX::ID tex)
{ {
setTexUniform(u_transMap, 2, tex); setTexUniform(u_transMap, 2, tex);
} }
@ -144,12 +144,12 @@ SimpleTransShader::SimpleTransShader()
GET_U(prog); GET_U(prog);
} }
void SimpleTransShader::setCurrentScene(Tex::ID tex) void SimpleTransShader::setCurrentScene(TEX::ID tex)
{ {
setTexUniform(u_currentScene, 0, tex); setTexUniform(u_currentScene, 0, tex);
} }
void SimpleTransShader::setFrozenScene(Tex::ID tex) void SimpleTransShader::setFrozenScene(TEX::ID tex)
{ {
setTexUniform(u_frozenScene, 1, tex); setTexUniform(u_frozenScene, 1, tex);
} }
@ -232,7 +232,7 @@ void HueShader::setHueAdjust(float value)
glUniform1f(u_hueAdjust, value); glUniform1f(u_hueAdjust, value);
} }
void HueShader::setInputTexture(Tex::ID tex) void HueShader::setInputTexture(TEX::ID tex)
{ {
setTexUniform(u_inputTexture, 0, tex); setTexUniform(u_inputTexture, 0, tex);
} }
@ -254,7 +254,7 @@ void BltShader::setSource()
glUniform1i(u_source, 0); glUniform1i(u_source, 0);
} }
void BltShader::setDestination(const Tex::ID value) void BltShader::setDestination(const TEX::ID value)
{ {
setTexUniform(u_destination, 1, value); setTexUniform(u_destination, 1, value);
} }

View File

@ -38,7 +38,7 @@ protected:
void initFromFile(const char *filename); void initFromFile(const char *filename);
void setVec4Uniform(GLint location, const Vec4 &vec); void setVec4Uniform(GLint location, const Vec4 &vec);
void setTexUniform(GLint location, unsigned unitIndex, Tex::ID texture); void setTexUniform(GLint location, unsigned unitIndex, TEX::ID texture);
GLuint shader; GLuint shader;
GLuint program; GLuint program;
@ -49,9 +49,9 @@ class TransShader : public FragShader
public: public:
TransShader(); TransShader();
void setCurrentScene(Tex::ID tex); void setCurrentScene(TEX::ID tex);
void setFrozenScene(Tex::ID tex); void setFrozenScene(TEX::ID tex);
void setTransMap(Tex::ID tex); void setTransMap(TEX::ID tex);
void setProg(float value); void setProg(float value);
void setVague(float value); void setVague(float value);
@ -64,8 +64,8 @@ class SimpleTransShader : public FragShader
public: public:
SimpleTransShader(); SimpleTransShader();
void setCurrentScene(Tex::ID tex); void setCurrentScene(TEX::ID tex);
void setFrozenScene(Tex::ID tex); void setFrozenScene(TEX::ID tex);
void setProg(float value); void setProg(float value);
private: private:
@ -95,7 +95,7 @@ public:
HueShader(); HueShader();
void setHueAdjust(float value); void setHueAdjust(float value);
void setInputTexture(Tex::ID tex); void setInputTexture(TEX::ID tex);
private: private:
GLint u_hueAdjust, u_inputTexture; GLint u_hueAdjust, u_inputTexture;
@ -108,7 +108,7 @@ public:
BltShader(); BltShader();
void setSource(); void setSource();
void setDestination(const Tex::ID value); void setDestination(const TEX::ID value);
void setDestCoorF(const Vec2 &value); void setDestCoorF(const Vec2 &value);
void setSubRect(const FloatRect &value); void setSubRect(const FloatRect &value);
void setOpacity(float value); void setOpacity(float value);

View File

@ -33,7 +33,7 @@
#include <QDebug> #include <QDebug>
typedef QPair<uint16_t, uint16_t> Size; typedef QPair<uint16_t, uint16_t> Size;
typedef QQueue<TexFBO> ObjList; typedef QQueue<TEXFBO> ObjList;
static uint32_t byteCount(Size &s) static uint32_t byteCount(Size &s)
{ {
@ -42,8 +42,8 @@ static uint32_t byteCount(Size &s)
struct CacheObject struct CacheObject
{ {
TexFBO obj; TEXFBO obj;
QLinkedList<TexFBO>::iterator prioIter; QLinkedList<TEXFBO>::iterator prioIter;
bool operator==(const CacheObject &o) bool operator==(const CacheObject &o)
{ {
@ -59,7 +59,7 @@ struct TexPoolPrivate
QHash<Size, CObjList> poolHash; QHash<Size, CObjList> poolHash;
/* Contains all cached TexFBOs, sorted by release time */ /* Contains all cached TexFBOs, sorted by release time */
QLinkedList<TexFBO> priorityQueue; QLinkedList<TEXFBO> priorityQueue;
/* Maximal allowed cache memory */ /* Maximal allowed cache memory */
const uint32_t maxMemSize; const uint32_t maxMemSize;
@ -90,8 +90,8 @@ TexPool::~TexPool()
{ {
while (!p->priorityQueue.isEmpty()) while (!p->priorityQueue.isEmpty())
{ {
TexFBO obj = p->priorityQueue.takeFirst(); TEXFBO obj = p->priorityQueue.takeFirst();
TexFBO::fini(obj); TEXFBO::fini(obj);
--p->objCount; --p->objCount;
} }
@ -100,7 +100,7 @@ TexPool::~TexPool()
delete p; delete p;
} }
TexFBO TexPool::request(int width, int height) TEXFBO TexPool::request(int width, int height)
{ {
CacheObject cobj; CacheObject cobj;
Size size(width, height); Size size(width, height);
@ -131,20 +131,20 @@ TexFBO TexPool::request(int width, int height)
QByteArray::number(width), QByteArray::number(height)); QByteArray::number(width), QByteArray::number(height));
/* Nope, create it instead */ /* Nope, create it instead */
TexFBO::init(cobj.obj); TEXFBO::init(cobj.obj);
TexFBO::allocEmpty(cobj.obj, width, height); TEXFBO::allocEmpty(cobj.obj, width, height);
TexFBO::linkFBO(cobj.obj); TEXFBO::linkFBO(cobj.obj);
// qDebug() << "TexPool: <?-> (" << width << height << ")"; // qDebug() << "TexPool: <?-> (" << width << height << ")";
return cobj.obj; return cobj.obj;
} }
void TexPool::release(TexFBO &obj) void TexPool::release(TEXFBO &obj)
{ {
if (obj.tex == Tex::ID(0) || obj.fbo == FBO::ID(0)) if (obj.tex == TEX::ID(0) || obj.fbo == FBO::ID(0))
{ {
TexFBO::fini(obj); TEXFBO::fini(obj);
return; return;
} }
@ -152,7 +152,7 @@ void TexPool::release(TexFBO &obj)
{ {
/* If we're disabled, delete without caching */ /* If we're disabled, delete without caching */
// qDebug() << "TexPool: <!#> (" << obj.width << obj.height << ")"; // qDebug() << "TexPool: <!#> (" << obj.width << obj.height << ")";
TexFBO::fini(obj); TEXFBO::fini(obj);
return; return;
} }
@ -179,7 +179,7 @@ void TexPool::release(TexFBO &obj)
bucket.removeOne(last); bucket.removeOne(last);
p->priorityQueue.removeLast(); p->priorityQueue.removeLast();
TexFBO::fini(last.obj); TEXFBO::fini(last.obj);
uint32_t removedMem = byteCount(removedSize); uint32_t removedMem = byteCount(removedSize);
newMemSize -= removedMem; newMemSize -= removedMem;

View File

@ -32,8 +32,8 @@ public:
TexPool(uint32_t maxMemSize = 20000000 /* 20 MB */); TexPool(uint32_t maxMemSize = 20000000 /* 20 MB */);
~TexPool(); ~TexPool();
TexFBO request(int width, int height); TEXFBO request(int width, int height);
void release(TexFBO &obj); void release(TEXFBO &obj);
void disable(); void disable();

View File

@ -194,7 +194,7 @@ struct TilemapPrivate
/* Tile atlas */ /* Tile atlas */
struct { struct {
TexFBO gl; TEXFBO gl;
bool animated; bool animated;
int frameH; int frameH;
int width; int width;
@ -711,8 +711,8 @@ struct TilemapPrivate
void bindAtlasWithMatrix() void bindAtlasWithMatrix()
{ {
Tex::bind(atlas.gl.tex); TEX::bind(atlas.gl.tex);
Tex::bindMatrix(atlas.animated ? atlasFrameW * 4 : atlasFrameW, atlas.frameH, TEX::bindMatrix(atlas.animated ? atlasFrameW * 4 : atlasFrameW, atlas.frameH,
atlas.frameIdx * atlasFrameW); atlas.frameIdx * atlasFrameW);
} }

View File

@ -196,7 +196,7 @@ struct WindowPrivate
ColorQuadArray baseQuadArray; ColorQuadArray baseQuadArray;
/* Used when opacity < 255 */ /* Used when opacity < 255 */
TexFBO baseTex; TEXFBO baseTex;
bool useBaseTex; bool useBaseTex;
QuadChunk backgroundVert; QuadChunk backgroundVert;
@ -414,9 +414,9 @@ struct WindowPrivate
void redrawBaseTex() void redrawBaseTex()
{ {
/* Discard old buffer */ /* Discard old buffer */
Tex::bind(baseTex.tex); TEX::bind(baseTex.tex);
Tex::allocEmpty(baseTex.width, baseTex.height); TEX::allocEmpty(baseTex.width, baseTex.height);
Tex::unbind(); TEX::unbind();
FBO::bind(baseTex.fbo); FBO::bind(baseTex.fbo);
glState.pushSetViewport(baseTex.width, baseTex.height); glState.pushSetViewport(baseTex.width, baseTex.height);
@ -428,7 +428,7 @@ struct WindowPrivate
/* Repaint base */ /* Repaint base */
windowskin->flush(); windowskin->flush();
windowskin->bindTexWithMatrix(); windowskin->bindTexWithMatrix();
Tex::setSmooth(true); TEX::setSmooth(true);
glState.pushSetViewport(baseTex.width, baseTex.height); glState.pushSetViewport(baseTex.width, baseTex.height);
/* We need to blit the background without blending, /* We need to blit the background without blending,
@ -445,7 +445,7 @@ struct WindowPrivate
glState.blendMode.pop(); glState.blendMode.pop();
glState.popViewport(); glState.popViewport();
Tex::setSmooth(false); TEX::setSmooth(false);
glState.clearColor.pop(); glState.clearColor.pop();
glState.popViewport(); glState.popViewport();
@ -555,18 +555,18 @@ struct WindowPrivate
if (useBaseTex) if (useBaseTex)
{ {
Tex::bindWithMatrix(baseTex.tex, baseTex.width, baseTex.height); TEX::bindWithMatrix(baseTex.tex, baseTex.width, baseTex.height);
baseTexQuad.draw(); baseTexQuad.draw();
} }
else else
{ {
windowskin->flush(); windowskin->flush();
windowskin->bindTexWithMatrix(); windowskin->bindTexWithMatrix();
Tex::setSmooth(true); TEX::setSmooth(true);
baseQuadArray.draw(); baseQuadArray.draw();
Tex::setSmooth(false); TEX::setSmooth(false);
} }
glPopMatrix(); glPopMatrix();