From f89cd2d2073e4baba7d521320fb34428ff44afe3 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Wed, 4 Sep 2013 19:07:28 +0200 Subject: [PATCH] Provide general purpose Quad in GlobalState --- src/bitmap.cpp | 9 +++++---- src/globalstate.cpp | 4 ++++ src/globalstate.h | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bitmap.cpp b/src/bitmap.cpp index a63909c..66259d0 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -254,7 +254,7 @@ void Bitmap::stretchBlt(const IntRect &destRect, shader.setSubRect(bltSubRect); shader.setOpacity(normOpacity); - Quad quad; + Quad &quad = gState->gpQuad(); quad.setTexPosRect(sourceRect, destRect); quad.setColor(Vec4(1, 1, 1, normOpacity)); @@ -303,7 +303,7 @@ void Bitmap::gradientFillRect(const IntRect &rect, flush(); - Quad quad; + Quad &quad = gState->gpQuad(); if (vertical) { @@ -405,8 +405,9 @@ void Bitmap::hueChange(int hue) FloatRect texRect(rect()); - Quad quad; + Quad &quad = gState->gpQuad(); quad.setTexPosRect(texRect, texRect); + quad.setColor(Vec4(1, 1, 1, 1)); /* Calculate hue parameter */ hue = wrapRange(hue, 0, 359); @@ -521,7 +522,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align) Tex::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA); Tex::setSmooth(true); - Quad quad; + Quad &quad = gState->gpQuad(); quad.setTexRect(FloatRect(0, 0, txtSurf->w, txtSurf->h)); quad.setPosRect(posRect); SDL_FreeSurface(txtSurf); diff --git a/src/globalstate.cpp b/src/globalstate.cpp index 3510441..c12a0cc 100644 --- a/src/globalstate.cpp +++ b/src/globalstate.cpp @@ -33,6 +33,7 @@ #include "eventthread.h" #include "gl-util.h" #include "global-ibo.h" +#include "quad.h" #include "binding.h" #include @@ -80,6 +81,8 @@ struct GlobalStatePrivate TexFBO gpTexFBO; + Quad gpQuad; + unsigned int stampCounter; GlobalStatePrivate(RGSSThreadData *threadData) @@ -180,6 +183,7 @@ GSATT(HueShader&, hueShader) GSATT(BltShader&, bltShader) GSATT(TexPool&, texPool) GSATT(FontPool&, fontPool) +GSATT(Quad&, gpQuad) void GlobalState::setBindingData(void *data) { diff --git a/src/globalstate.h b/src/globalstate.h index f930563..509825e 100644 --- a/src/globalstate.h +++ b/src/globalstate.h @@ -33,6 +33,7 @@ struct GlobalIBO; struct mrb_state; struct SDL_Window; struct TexFBO; +struct Quad; class Scene; class FileSystem; @@ -101,6 +102,8 @@ struct GlobalState TexFBO &gpTexFBO(int minW, int minH); + Quad &gpQuad(); + /* Checks EventThread's shutdown request flag and if set, * requests the binding to terminate. In this case, this * function will most likely not return */