Rename 'Tex' to 'TEX' for consistency
This commit is contained in:
		
							parent
							
								
									ba3b904f34
								
							
						
					
					
						commit
						b151a22f6e
					
				
					 13 changed files with 128 additions and 128 deletions
				
			
		| 
						 | 
				
			
			@ -42,7 +42,7 @@
 | 
			
		|||
 | 
			
		||||
struct BitmapPrivate
 | 
			
		||||
{
 | 
			
		||||
	TexFBO tex;
 | 
			
		||||
	TEXFBO tex;
 | 
			
		||||
 | 
			
		||||
	/* 'setPixel()' calls are cached and executed
 | 
			
		||||
	 * in batches on 'flush()' */
 | 
			
		||||
| 
						 | 
				
			
			@ -57,8 +57,8 @@ struct BitmapPrivate
 | 
			
		|||
 | 
			
		||||
	void bindTextureWithMatrix()
 | 
			
		||||
	{
 | 
			
		||||
		Tex::bind(tex.tex);
 | 
			
		||||
		Tex::bindMatrix(tex.width, tex.height);
 | 
			
		||||
		TEX::bind(tex.tex);
 | 
			
		||||
		TEX::bindMatrix(tex.width, tex.height);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void bindFBO()
 | 
			
		||||
| 
						 | 
				
			
			@ -88,7 +88,7 @@ struct BitmapPrivate
 | 
			
		|||
		if (pointArray.count() == 0)
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		Tex::unbind();
 | 
			
		||||
		TEX::unbind();
 | 
			
		||||
		bindFBO();
 | 
			
		||||
		pushSetViewport();
 | 
			
		||||
		glState.blendMode.pushSet(BlendNone);
 | 
			
		||||
| 
						 | 
				
			
			@ -139,7 +139,7 @@ Bitmap::Bitmap(const char *filename)
 | 
			
		|||
	if (!imgSurf)
 | 
			
		||||
		throw Exception(Exception::SDLError, "SDL: %s", SDL_GetError());
 | 
			
		||||
 | 
			
		||||
	TexFBO tex;
 | 
			
		||||
	TEXFBO tex;
 | 
			
		||||
 | 
			
		||||
	p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -148,8 +148,8 @@ Bitmap::Bitmap(const char *filename)
 | 
			
		|||
	p = new BitmapPrivate;
 | 
			
		||||
	p->tex = tex;
 | 
			
		||||
 | 
			
		||||
	Tex::bind(p->tex.tex);
 | 
			
		||||
	Tex::uploadImage(p->tex.width, p->tex.height, imgSurf->pixels, GL_RGBA);
 | 
			
		||||
	TEX::bind(p->tex.tex);
 | 
			
		||||
	TEX::uploadImage(p->tex.width, p->tex.height, imgSurf->pixels, GL_RGBA);
 | 
			
		||||
 | 
			
		||||
	SDL_FreeSurface(imgSurf);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +159,7 @@ Bitmap::Bitmap(int width, int height)
 | 
			
		|||
	if (width <= 0 || height <= 0)
 | 
			
		||||
		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->tex = tex;
 | 
			
		||||
| 
						 | 
				
			
			@ -237,7 +237,7 @@ void Bitmap::stretchBlt(const IntRect &destRect,
 | 
			
		|||
 | 
			
		||||
		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(p->tex.fbo, FBO::Read);
 | 
			
		||||
| 
						 | 
				
			
			@ -322,7 +322,7 @@ void Bitmap::gradientFillRect(const IntRect &rect,
 | 
			
		|||
 | 
			
		||||
	quad.setPosRect(rect);
 | 
			
		||||
 | 
			
		||||
	Tex::unbind();
 | 
			
		||||
	TEX::unbind();
 | 
			
		||||
	p->bindFBO();
 | 
			
		||||
	p->pushSetViewport();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -401,7 +401,7 @@ void Bitmap::hueChange(int hue)
 | 
			
		|||
 | 
			
		||||
	flush();
 | 
			
		||||
 | 
			
		||||
	TexFBO newTex = gState->texPool().request(width(), height());
 | 
			
		||||
	TEXFBO newTex = gState->texPool().request(width(), height());
 | 
			
		||||
 | 
			
		||||
	FloatRect texRect(rect());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -419,7 +419,7 @@ void Bitmap::hueChange(int hue)
 | 
			
		|||
	shader.setInputTexture(p->tex.tex);
 | 
			
		||||
 | 
			
		||||
	FBO::bind(newTex.fbo);
 | 
			
		||||
	Tex::bindMatrix(width(), height());
 | 
			
		||||
	TEX::bindMatrix(width(), height());
 | 
			
		||||
	p->pushSetViewport();
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
		 * 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(p->tex.fbo, FBO::Read);
 | 
			
		||||
| 
						 | 
				
			
			@ -519,8 +519,8 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	gState->bindTex();
 | 
			
		||||
	Tex::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA);
 | 
			
		||||
	Tex::setSmooth(true);
 | 
			
		||||
	TEX::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA);
 | 
			
		||||
	TEX::setSmooth(true);
 | 
			
		||||
 | 
			
		||||
	Quad &quad = gState->gpQuad();
 | 
			
		||||
	quad.setTexRect(FloatRect(0, 0, txtSurf->w, txtSurf->h));
 | 
			
		||||
| 
						 | 
				
			
			@ -563,7 +563,7 @@ void Bitmap::flush() const
 | 
			
		|||
	p->flushPoints();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TexFBO &Bitmap::getGLTypes()
 | 
			
		||||
TEXFBO &Bitmap::getGLTypes()
 | 
			
		||||
{
 | 
			
		||||
	return p->tex;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@
 | 
			
		|||
#include "sigc++/signal.h"
 | 
			
		||||
 | 
			
		||||
class Font;
 | 
			
		||||
struct TexFBO;
 | 
			
		||||
struct TEXFBO;
 | 
			
		||||
 | 
			
		||||
struct BitmapPrivate;
 | 
			
		||||
// FIXME make this class use proper RGSS classes again
 | 
			
		||||
| 
						 | 
				
			
			@ -102,7 +102,7 @@ public:
 | 
			
		|||
 | 
			
		||||
	/* <internal> */
 | 
			
		||||
	void flush() const;
 | 
			
		||||
	TexFBO &getGLTypes();
 | 
			
		||||
	TEXFBO &getGLTypes();
 | 
			
		||||
	void bindTexWithMatrix();
 | 
			
		||||
 | 
			
		||||
	sigc::signal<void> modified;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ struct ID \
 | 
			
		|||
	}  \
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
namespace Tex
 | 
			
		||||
namespace TEX
 | 
			
		||||
{
 | 
			
		||||
	DEF_GL_ID
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +190,7 @@ namespace FBO
 | 
			
		|||
		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);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -303,48 +303,48 @@ struct GenericBO
 | 
			
		|||
typedef struct GenericBO<GL_ARRAY_BUFFER> VBO;
 | 
			
		||||
typedef struct GenericBO<GL_ELEMENT_ARRAY_BUFFER> IBO;
 | 
			
		||||
 | 
			
		||||
struct TexFBO
 | 
			
		||||
struct TEXFBO
 | 
			
		||||
{
 | 
			
		||||
	Tex::ID tex;
 | 
			
		||||
	TEX::ID tex;
 | 
			
		||||
	FBO::ID fbo;
 | 
			
		||||
	int width, height;
 | 
			
		||||
 | 
			
		||||
	TexFBO()
 | 
			
		||||
	TEXFBO()
 | 
			
		||||
	    : 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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static inline void init(TexFBO &obj)
 | 
			
		||||
	static inline void init(TEXFBO &obj)
 | 
			
		||||
	{
 | 
			
		||||
		obj.tex = Tex::gen();
 | 
			
		||||
		obj.tex = TEX::gen();
 | 
			
		||||
		obj.fbo = FBO::gen();
 | 
			
		||||
		Tex::bind(obj.tex);
 | 
			
		||||
		Tex::setRepeat(false);
 | 
			
		||||
		Tex::setSmooth(false);
 | 
			
		||||
		TEX::bind(obj.tex);
 | 
			
		||||
		TEX::setRepeat(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::allocEmpty(width, height);
 | 
			
		||||
		TEX::bind(obj.tex);
 | 
			
		||||
		TEX::allocEmpty(width, height);
 | 
			
		||||
		obj.width = width;
 | 
			
		||||
		obj.height = height;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static inline void linkFBO(TexFBO &obj)
 | 
			
		||||
	static inline void linkFBO(TEXFBO &obj)
 | 
			
		||||
	{
 | 
			
		||||
		FBO::bind(obj.fbo);
 | 
			
		||||
		FBO::setTarget(obj.tex);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static inline void fini(TexFBO &obj)
 | 
			
		||||
	static inline void fini(TEXFBO &obj)
 | 
			
		||||
	{
 | 
			
		||||
		FBO::del(obj.fbo);
 | 
			
		||||
		Tex::del(obj.tex);
 | 
			
		||||
		TEX::del(obj.tex);
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,10 +76,10 @@ struct GlobalStatePrivate
 | 
			
		|||
 | 
			
		||||
	Font *defaultFont;
 | 
			
		||||
 | 
			
		||||
	Tex::ID globalTex;
 | 
			
		||||
	TEX::ID globalTex;
 | 
			
		||||
	int globalTexW, globalTexH;
 | 
			
		||||
 | 
			
		||||
	TexFBO gpTexFBO;
 | 
			
		||||
	TEXFBO gpTexFBO;
 | 
			
		||||
 | 
			
		||||
	Quad gpQuad;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -114,22 +114,22 @@ struct GlobalStatePrivate
 | 
			
		|||
		globalTexW = 128;
 | 
			
		||||
		globalTexH = 64;
 | 
			
		||||
 | 
			
		||||
		globalTex = Tex::gen();
 | 
			
		||||
		Tex::bind(globalTex);
 | 
			
		||||
		Tex::setRepeat(false);
 | 
			
		||||
		Tex::setSmooth(false);
 | 
			
		||||
		Tex::allocEmpty(globalTexW, globalTexH);
 | 
			
		||||
		globalTex = TEX::gen();
 | 
			
		||||
		TEX::bind(globalTex);
 | 
			
		||||
		TEX::setRepeat(false);
 | 
			
		||||
		TEX::setSmooth(false);
 | 
			
		||||
		TEX::allocEmpty(globalTexW, globalTexH);
 | 
			
		||||
 | 
			
		||||
		TexFBO::init(gpTexFBO);
 | 
			
		||||
		TEXFBO::init(gpTexFBO);
 | 
			
		||||
		/* Reuse starting values */
 | 
			
		||||
		TexFBO::allocEmpty(gpTexFBO, globalTexW, globalTexH);
 | 
			
		||||
		TexFBO::linkFBO(gpTexFBO);
 | 
			
		||||
		TEXFBO::allocEmpty(gpTexFBO, globalTexW, globalTexH);
 | 
			
		||||
		TEXFBO::linkFBO(gpTexFBO);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	~GlobalStatePrivate()
 | 
			
		||||
	{
 | 
			
		||||
		Tex::del(globalTex);
 | 
			
		||||
		TexFBO::fini(gpTexFBO);
 | 
			
		||||
		TEX::del(globalTex);
 | 
			
		||||
		TEXFBO::fini(gpTexFBO);
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -202,9 +202,9 @@ void GlobalState::bindQuadIBO()
 | 
			
		|||
 | 
			
		||||
void GlobalState::bindTex()
 | 
			
		||||
{
 | 
			
		||||
	Tex::bind(p->globalTex);
 | 
			
		||||
	Tex::allocEmpty(p->globalTexW, p->globalTexH);
 | 
			
		||||
	Tex::bindMatrix(p->globalTexW, p->globalTexH);
 | 
			
		||||
	TEX::bind(p->globalTex);
 | 
			
		||||
	TEX::allocEmpty(p->globalTexW, p->globalTexH);
 | 
			
		||||
	TEX::bindMatrix(p->globalTexW, p->globalTexH);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GlobalState::ensureTexSize(int minW, int minH, Vec2 ¤tSizeOut)
 | 
			
		||||
| 
						 | 
				
			
			@ -218,7 +218,7 @@ void GlobalState::ensureTexSize(int minW, int minH, Vec2 ¤tSizeOut)
 | 
			
		|||
	currentSizeOut = Vec2(p->globalTexW, p->globalTexH);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TexFBO &GlobalState::gpTexFBO(int minW, int minH)
 | 
			
		||||
TEXFBO &GlobalState::gpTexFBO(int minW, int minH)
 | 
			
		||||
{
 | 
			
		||||
	bool needResize = false;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -236,8 +236,8 @@ TexFBO &GlobalState::gpTexFBO(int minW, int minH)
 | 
			
		|||
 | 
			
		||||
	if (needResize)
 | 
			
		||||
	{
 | 
			
		||||
		Tex::bind(p->gpTexFBO.tex);
 | 
			
		||||
		Tex::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height);
 | 
			
		||||
		TEX::bind(p->gpTexFBO.tex);
 | 
			
		||||
		TEX::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return p->gpTexFBO;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ struct RGSSThreadData;
 | 
			
		|||
struct GlobalIBO;
 | 
			
		||||
struct mrb_state;
 | 
			
		||||
struct SDL_Window;
 | 
			
		||||
struct TexFBO;
 | 
			
		||||
struct TEXFBO;
 | 
			
		||||
struct Quad;
 | 
			
		||||
 | 
			
		||||
class Scene;
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +100,7 @@ struct GlobalState
 | 
			
		|||
	void bindTex();
 | 
			
		||||
	void ensureTexSize(int minW, int minH, Vec2 ¤tSizeOut);
 | 
			
		||||
 | 
			
		||||
	TexFBO &gpTexFBO(int minW, int minH);
 | 
			
		||||
	TEXFBO &gpTexFBO(int minW, int minH);
 | 
			
		||||
 | 
			
		||||
	Quad &gpQuad();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -216,7 +216,7 @@ struct CPUTimer
 | 
			
		|||
 | 
			
		||||
struct PingPong
 | 
			
		||||
{
 | 
			
		||||
	TexFBO rt[2];
 | 
			
		||||
	TEXFBO rt[2];
 | 
			
		||||
	unsigned srcInd, dstInd;
 | 
			
		||||
	int screenW, screenH;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -226,9 +226,9 @@ struct PingPong
 | 
			
		|||
	{
 | 
			
		||||
		for (int i = 0; i < 2; ++i)
 | 
			
		||||
		{
 | 
			
		||||
			TexFBO::init(rt[i]);
 | 
			
		||||
			TexFBO::allocEmpty(rt[i], screenW, screenH);
 | 
			
		||||
			TexFBO::linkFBO(rt[i]);
 | 
			
		||||
			TEXFBO::init(rt[i]);
 | 
			
		||||
			TEXFBO::allocEmpty(rt[i], screenW, screenH);
 | 
			
		||||
			TEXFBO::linkFBO(rt[i]);
 | 
			
		||||
			glClearColor(0, 0, 0, 1);
 | 
			
		||||
			glClear(GL_COLOR_BUFFER_BIT);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -237,7 +237,7 @@ struct PingPong
 | 
			
		|||
	~PingPong()
 | 
			
		||||
	{
 | 
			
		||||
		for (int i = 0; i < 2; ++i)
 | 
			
		||||
			TexFBO::fini(rt[i]);
 | 
			
		||||
			TEXFBO::fini(rt[i]);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Binds FBO of last good buffer for reading */
 | 
			
		||||
| 
						 | 
				
			
			@ -253,8 +253,8 @@ struct PingPong
 | 
			
		|||
		screenH = height;
 | 
			
		||||
		for (int i = 0; i < 2; ++i)
 | 
			
		||||
		{
 | 
			
		||||
			Tex::bind(rt[i].tex);
 | 
			
		||||
			Tex::allocEmpty(width, height);
 | 
			
		||||
			TEX::bind(rt[i].tex);
 | 
			
		||||
			TEX::allocEmpty(width, height);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -268,8 +268,8 @@ struct PingPong
 | 
			
		|||
		swapIndices();
 | 
			
		||||
 | 
			
		||||
		/* Discard dest buffer */
 | 
			
		||||
		Tex::bind(rt[dstInd].tex);
 | 
			
		||||
		Tex::allocEmpty(screenW, screenH);
 | 
			
		||||
		TEX::bind(rt[dstInd].tex);
 | 
			
		||||
		TEX::allocEmpty(screenW, screenH);
 | 
			
		||||
 | 
			
		||||
		bind();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -288,7 +288,7 @@ struct PingPong
 | 
			
		|||
private:
 | 
			
		||||
	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[dstInd].fbo, FBO::Draw);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -352,7 +352,7 @@ public:
 | 
			
		|||
 | 
			
		||||
		glState.blendMode.pushSet(BlendNone);
 | 
			
		||||
 | 
			
		||||
		Tex::bindMatrix(geometry.rect.w, geometry.rect.h);
 | 
			
		||||
		TEX::bindMatrix(geometry.rect.w, geometry.rect.h);
 | 
			
		||||
		screenQuad.draw();
 | 
			
		||||
 | 
			
		||||
		glState.blendMode.pop();
 | 
			
		||||
| 
						 | 
				
			
			@ -466,8 +466,8 @@ struct GraphicsPrivate
 | 
			
		|||
	CPUTimer cpuTimer;
 | 
			
		||||
 | 
			
		||||
	bool frozen;
 | 
			
		||||
	TexFBO frozenScene;
 | 
			
		||||
	TexFBO currentScene;
 | 
			
		||||
	TEXFBO frozenScene;
 | 
			
		||||
	TEXFBO currentScene;
 | 
			
		||||
	Quad screenQuad;
 | 
			
		||||
	RBOFBO transBuffer;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -483,13 +483,13 @@ struct GraphicsPrivate
 | 
			
		|||
	      cpuTimer(frameRate),
 | 
			
		||||
	      frozen(false)
 | 
			
		||||
	{
 | 
			
		||||
		TexFBO::init(frozenScene);
 | 
			
		||||
		TexFBO::allocEmpty(frozenScene, scRes.x, scRes.y);
 | 
			
		||||
		TexFBO::linkFBO(frozenScene);
 | 
			
		||||
		TEXFBO::init(frozenScene);
 | 
			
		||||
		TEXFBO::allocEmpty(frozenScene, scRes.x, scRes.y);
 | 
			
		||||
		TEXFBO::linkFBO(frozenScene);
 | 
			
		||||
 | 
			
		||||
		TexFBO::init(currentScene);
 | 
			
		||||
		TexFBO::allocEmpty(currentScene, scRes.x, scRes.y);
 | 
			
		||||
		TexFBO::linkFBO(currentScene);
 | 
			
		||||
		TEXFBO::init(currentScene);
 | 
			
		||||
		TEXFBO::allocEmpty(currentScene, scRes.x, scRes.y);
 | 
			
		||||
		TEXFBO::linkFBO(currentScene);
 | 
			
		||||
 | 
			
		||||
		FloatRect screenRect(0, 0, scRes.x, scRes.y);
 | 
			
		||||
		screenQuad.setTexPosRect(screenRect, screenRect);
 | 
			
		||||
| 
						 | 
				
			
			@ -501,8 +501,8 @@ struct GraphicsPrivate
 | 
			
		|||
 | 
			
		||||
	~GraphicsPrivate()
 | 
			
		||||
	{
 | 
			
		||||
		TexFBO::fini(frozenScene);
 | 
			
		||||
		TexFBO::fini(currentScene);
 | 
			
		||||
		TEXFBO::fini(frozenScene);
 | 
			
		||||
		TEXFBO::fini(currentScene);
 | 
			
		||||
 | 
			
		||||
		RBOFBO::fini(transBuffer);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -700,7 +700,7 @@ void Graphics::transition(int duration,
 | 
			
		|||
		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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -784,10 +784,10 @@ void Graphics::resizeScreen(int width, int height)
 | 
			
		|||
 | 
			
		||||
	p->screen.setResolution(width, height);
 | 
			
		||||
 | 
			
		||||
	Tex::bind(p->frozenScene.tex);
 | 
			
		||||
	Tex::allocEmpty(width, height);
 | 
			
		||||
	Tex::bind(p->currentScene.tex);
 | 
			
		||||
	Tex::allocEmpty(width, height);
 | 
			
		||||
	TEX::bind(p->frozenScene.tex);
 | 
			
		||||
	TEX::allocEmpty(width, height);
 | 
			
		||||
	TEX::bind(p->currentScene.tex);
 | 
			
		||||
	TEX::allocEmpty(width, height);
 | 
			
		||||
 | 
			
		||||
	FloatRect screenRect(0, 0, width, height);
 | 
			
		||||
	p->screenQuad.setTexPosRect(screenRect, screenRect);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -187,11 +187,11 @@ void Plane::draw()
 | 
			
		|||
 | 
			
		||||
	p->bitmap->flush();
 | 
			
		||||
	p->bitmap->bindTexWithMatrix();
 | 
			
		||||
	Tex::setRepeat(true);
 | 
			
		||||
	TEX::setRepeat(true);
 | 
			
		||||
 | 
			
		||||
	p->quad.draw();
 | 
			
		||||
 | 
			
		||||
	Tex::setRepeat(false);
 | 
			
		||||
	TEX::setRepeat(false);
 | 
			
		||||
	FragShader::unbind();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -85,7 +85,7 @@ void FragShader::setVec4Uniform(GLint location, const Vec4 &vec)
 | 
			
		|||
	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;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -108,17 +108,17 @@ TransShader::TransShader()
 | 
			
		|||
	GET_U(vague);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TransShader::setCurrentScene(Tex::ID tex)
 | 
			
		||||
void TransShader::setCurrentScene(TEX::ID tex)
 | 
			
		||||
{
 | 
			
		||||
	setTexUniform(u_currentScene, 0, tex);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TransShader::setFrozenScene(Tex::ID tex)
 | 
			
		||||
void TransShader::setFrozenScene(TEX::ID tex)
 | 
			
		||||
{
 | 
			
		||||
	setTexUniform(u_frozenScene, 1, tex);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TransShader::setTransMap(Tex::ID tex)
 | 
			
		||||
void TransShader::setTransMap(TEX::ID tex)
 | 
			
		||||
{
 | 
			
		||||
	setTexUniform(u_transMap, 2, tex);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -144,12 +144,12 @@ SimpleTransShader::SimpleTransShader()
 | 
			
		|||
	GET_U(prog);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SimpleTransShader::setCurrentScene(Tex::ID tex)
 | 
			
		||||
void SimpleTransShader::setCurrentScene(TEX::ID tex)
 | 
			
		||||
{
 | 
			
		||||
	setTexUniform(u_currentScene, 0, tex);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SimpleTransShader::setFrozenScene(Tex::ID tex)
 | 
			
		||||
void SimpleTransShader::setFrozenScene(TEX::ID tex)
 | 
			
		||||
{
 | 
			
		||||
	setTexUniform(u_frozenScene, 1, tex);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -232,7 +232,7 @@ void HueShader::setHueAdjust(float value)
 | 
			
		|||
	glUniform1f(u_hueAdjust, value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void HueShader::setInputTexture(Tex::ID tex)
 | 
			
		||||
void HueShader::setInputTexture(TEX::ID tex)
 | 
			
		||||
{
 | 
			
		||||
	setTexUniform(u_inputTexture, 0, tex);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -254,7 +254,7 @@ void BltShader::setSource()
 | 
			
		|||
	glUniform1i(u_source, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BltShader::setDestination(const Tex::ID value)
 | 
			
		||||
void BltShader::setDestination(const TEX::ID value)
 | 
			
		||||
{
 | 
			
		||||
	setTexUniform(u_destination, 1, value);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										16
									
								
								src/shader.h
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								src/shader.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -38,7 +38,7 @@ protected:
 | 
			
		|||
	void initFromFile(const char *filename);
 | 
			
		||||
 | 
			
		||||
	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 program;
 | 
			
		||||
| 
						 | 
				
			
			@ -49,9 +49,9 @@ class TransShader : public FragShader
 | 
			
		|||
public:
 | 
			
		||||
	TransShader();
 | 
			
		||||
 | 
			
		||||
	void setCurrentScene(Tex::ID tex);
 | 
			
		||||
	void setFrozenScene(Tex::ID tex);
 | 
			
		||||
	void setTransMap(Tex::ID tex);
 | 
			
		||||
	void setCurrentScene(TEX::ID tex);
 | 
			
		||||
	void setFrozenScene(TEX::ID tex);
 | 
			
		||||
	void setTransMap(TEX::ID tex);
 | 
			
		||||
	void setProg(float value);
 | 
			
		||||
	void setVague(float value);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -64,8 +64,8 @@ class SimpleTransShader : public FragShader
 | 
			
		|||
public:
 | 
			
		||||
	SimpleTransShader();
 | 
			
		||||
 | 
			
		||||
	void setCurrentScene(Tex::ID tex);
 | 
			
		||||
	void setFrozenScene(Tex::ID tex);
 | 
			
		||||
	void setCurrentScene(TEX::ID tex);
 | 
			
		||||
	void setFrozenScene(TEX::ID tex);
 | 
			
		||||
	void setProg(float value);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +95,7 @@ public:
 | 
			
		|||
	HueShader();
 | 
			
		||||
 | 
			
		||||
	void setHueAdjust(float value);
 | 
			
		||||
	void setInputTexture(Tex::ID tex);
 | 
			
		||||
	void setInputTexture(TEX::ID tex);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	GLint u_hueAdjust, u_inputTexture;
 | 
			
		||||
| 
						 | 
				
			
			@ -108,7 +108,7 @@ public:
 | 
			
		|||
	BltShader();
 | 
			
		||||
 | 
			
		||||
	void setSource();
 | 
			
		||||
	void setDestination(const Tex::ID value);
 | 
			
		||||
	void setDestination(const TEX::ID value);
 | 
			
		||||
	void setDestCoorF(const Vec2 &value);
 | 
			
		||||
	void setSubRect(const FloatRect &value);
 | 
			
		||||
	void setOpacity(float value);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,7 +33,7 @@
 | 
			
		|||
#include <QDebug>
 | 
			
		||||
 | 
			
		||||
typedef QPair<uint16_t, uint16_t> Size;
 | 
			
		||||
typedef QQueue<TexFBO> ObjList;
 | 
			
		||||
typedef QQueue<TEXFBO> ObjList;
 | 
			
		||||
 | 
			
		||||
static uint32_t byteCount(Size &s)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -42,8 +42,8 @@ static uint32_t byteCount(Size &s)
 | 
			
		|||
 | 
			
		||||
struct CacheObject
 | 
			
		||||
{
 | 
			
		||||
	TexFBO obj;
 | 
			
		||||
	QLinkedList<TexFBO>::iterator prioIter;
 | 
			
		||||
	TEXFBO obj;
 | 
			
		||||
	QLinkedList<TEXFBO>::iterator prioIter;
 | 
			
		||||
 | 
			
		||||
	bool operator==(const CacheObject &o)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ struct TexPoolPrivate
 | 
			
		|||
	QHash<Size, CObjList> poolHash;
 | 
			
		||||
 | 
			
		||||
	/* Contains all cached TexFBOs, sorted by release time */
 | 
			
		||||
	QLinkedList<TexFBO> priorityQueue;
 | 
			
		||||
	QLinkedList<TEXFBO> priorityQueue;
 | 
			
		||||
 | 
			
		||||
	/* Maximal allowed cache memory */
 | 
			
		||||
	const uint32_t maxMemSize;
 | 
			
		||||
| 
						 | 
				
			
			@ -90,8 +90,8 @@ TexPool::~TexPool()
 | 
			
		|||
{
 | 
			
		||||
	while (!p->priorityQueue.isEmpty())
 | 
			
		||||
	{
 | 
			
		||||
		TexFBO obj = p->priorityQueue.takeFirst();
 | 
			
		||||
		TexFBO::fini(obj);
 | 
			
		||||
		TEXFBO obj = p->priorityQueue.takeFirst();
 | 
			
		||||
		TEXFBO::fini(obj);
 | 
			
		||||
		--p->objCount;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +100,7 @@ TexPool::~TexPool()
 | 
			
		|||
	delete p;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TexFBO TexPool::request(int width, int height)
 | 
			
		||||
TEXFBO TexPool::request(int width, int height)
 | 
			
		||||
{
 | 
			
		||||
	CacheObject cobj;
 | 
			
		||||
	Size size(width, height);
 | 
			
		||||
| 
						 | 
				
			
			@ -131,20 +131,20 @@ TexFBO TexPool::request(int width, int height)
 | 
			
		|||
		                QByteArray::number(width), QByteArray::number(height));
 | 
			
		||||
 | 
			
		||||
	/* Nope, create it instead */
 | 
			
		||||
	TexFBO::init(cobj.obj);
 | 
			
		||||
	TexFBO::allocEmpty(cobj.obj, width, height);
 | 
			
		||||
	TexFBO::linkFBO(cobj.obj);
 | 
			
		||||
	TEXFBO::init(cobj.obj);
 | 
			
		||||
	TEXFBO::allocEmpty(cobj.obj, width, height);
 | 
			
		||||
	TEXFBO::linkFBO(cobj.obj);
 | 
			
		||||
 | 
			
		||||
//	qDebug() << "TexPool: <?-> (" << width << height << ")";
 | 
			
		||||
 | 
			
		||||
	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;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +152,7 @@ void TexPool::release(TexFBO &obj)
 | 
			
		|||
	{
 | 
			
		||||
		/* If we're disabled, delete without caching */
 | 
			
		||||
//		qDebug() << "TexPool: <!#> (" << obj.width << obj.height << ")";
 | 
			
		||||
		TexFBO::fini(obj);
 | 
			
		||||
		TEXFBO::fini(obj);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -179,7 +179,7 @@ void TexPool::release(TexFBO &obj)
 | 
			
		|||
		bucket.removeOne(last);
 | 
			
		||||
		p->priorityQueue.removeLast();
 | 
			
		||||
 | 
			
		||||
		TexFBO::fini(last.obj);
 | 
			
		||||
		TEXFBO::fini(last.obj);
 | 
			
		||||
 | 
			
		||||
		uint32_t removedMem = byteCount(removedSize);
 | 
			
		||||
		newMemSize -= removedMem;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,8 +32,8 @@ public:
 | 
			
		|||
	TexPool(uint32_t maxMemSize = 20000000 /* 20 MB */);
 | 
			
		||||
	~TexPool();
 | 
			
		||||
 | 
			
		||||
	TexFBO request(int width, int height);
 | 
			
		||||
	void release(TexFBO &obj);
 | 
			
		||||
	TEXFBO request(int width, int height);
 | 
			
		||||
	void release(TEXFBO &obj);
 | 
			
		||||
 | 
			
		||||
	void disable();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -194,7 +194,7 @@ struct TilemapPrivate
 | 
			
		|||
 | 
			
		||||
	/* Tile atlas */
 | 
			
		||||
	struct {
 | 
			
		||||
		TexFBO gl;
 | 
			
		||||
		TEXFBO gl;
 | 
			
		||||
		bool animated;
 | 
			
		||||
		int frameH;
 | 
			
		||||
		int width;
 | 
			
		||||
| 
						 | 
				
			
			@ -711,8 +711,8 @@ struct TilemapPrivate
 | 
			
		|||
 | 
			
		||||
	void bindAtlasWithMatrix()
 | 
			
		||||
	{
 | 
			
		||||
		Tex::bind(atlas.gl.tex);
 | 
			
		||||
		Tex::bindMatrix(atlas.animated ? atlasFrameW * 4 : atlasFrameW, atlas.frameH,
 | 
			
		||||
		TEX::bind(atlas.gl.tex);
 | 
			
		||||
		TEX::bindMatrix(atlas.animated ? atlasFrameW * 4 : atlasFrameW, atlas.frameH,
 | 
			
		||||
		                atlas.frameIdx * atlasFrameW);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -196,7 +196,7 @@ struct WindowPrivate
 | 
			
		|||
	ColorQuadArray baseQuadArray;
 | 
			
		||||
 | 
			
		||||
	/* Used when opacity < 255 */
 | 
			
		||||
	TexFBO baseTex;
 | 
			
		||||
	TEXFBO baseTex;
 | 
			
		||||
	bool useBaseTex;
 | 
			
		||||
 | 
			
		||||
	QuadChunk backgroundVert;
 | 
			
		||||
| 
						 | 
				
			
			@ -414,9 +414,9 @@ struct WindowPrivate
 | 
			
		|||
	void redrawBaseTex()
 | 
			
		||||
	{
 | 
			
		||||
		/* Discard old buffer */
 | 
			
		||||
		Tex::bind(baseTex.tex);
 | 
			
		||||
		Tex::allocEmpty(baseTex.width, baseTex.height);
 | 
			
		||||
		Tex::unbind();
 | 
			
		||||
		TEX::bind(baseTex.tex);
 | 
			
		||||
		TEX::allocEmpty(baseTex.width, baseTex.height);
 | 
			
		||||
		TEX::unbind();
 | 
			
		||||
 | 
			
		||||
		FBO::bind(baseTex.fbo);
 | 
			
		||||
		glState.pushSetViewport(baseTex.width, baseTex.height);
 | 
			
		||||
| 
						 | 
				
			
			@ -428,7 +428,7 @@ struct WindowPrivate
 | 
			
		|||
		/* Repaint base */
 | 
			
		||||
		windowskin->flush();
 | 
			
		||||
		windowskin->bindTexWithMatrix();
 | 
			
		||||
		Tex::setSmooth(true);
 | 
			
		||||
		TEX::setSmooth(true);
 | 
			
		||||
		glState.pushSetViewport(baseTex.width, baseTex.height);
 | 
			
		||||
 | 
			
		||||
		/* We need to blit the background without blending,
 | 
			
		||||
| 
						 | 
				
			
			@ -445,7 +445,7 @@ struct WindowPrivate
 | 
			
		|||
 | 
			
		||||
		glState.blendMode.pop();
 | 
			
		||||
		glState.popViewport();
 | 
			
		||||
		Tex::setSmooth(false);
 | 
			
		||||
		TEX::setSmooth(false);
 | 
			
		||||
 | 
			
		||||
		glState.clearColor.pop();
 | 
			
		||||
		glState.popViewport();
 | 
			
		||||
| 
						 | 
				
			
			@ -555,18 +555,18 @@ struct WindowPrivate
 | 
			
		|||
 | 
			
		||||
		if (useBaseTex)
 | 
			
		||||
		{
 | 
			
		||||
			Tex::bindWithMatrix(baseTex.tex, baseTex.width, baseTex.height);
 | 
			
		||||
			TEX::bindWithMatrix(baseTex.tex, baseTex.width, baseTex.height);
 | 
			
		||||
			baseTexQuad.draw();
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			windowskin->flush();
 | 
			
		||||
			windowskin->bindTexWithMatrix();
 | 
			
		||||
			Tex::setSmooth(true);
 | 
			
		||||
			TEX::setSmooth(true);
 | 
			
		||||
 | 
			
		||||
			baseQuadArray.draw();
 | 
			
		||||
 | 
			
		||||
			Tex::setSmooth(false);
 | 
			
		||||
			TEX::setSmooth(false);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		glPopMatrix();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue