Rename 'GlobalState' to 'SharedState' to avoid confusion with GLState
This was particularly nasty with the shorthand macros 'gState' and 'glState'. The former is now 'shState'.
This commit is contained in:
		
							parent
							
								
									807bee5748
								
							
						
					
					
						commit
						cb6f73f7df
					
				
					 32 changed files with 222 additions and 222 deletions
				
			
		| 
						 | 
				
			
			@ -21,7 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include "audio.h"
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "intrulist.h"
 | 
			
		||||
#include "filesystem.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +123,7 @@ struct MusicEntity
 | 
			
		|||
		currentData.close();
 | 
			
		||||
 | 
			
		||||
		currentData =
 | 
			
		||||
		        gState->fileSystem().openRead(filename.constData(), FileSystem::Audio);
 | 
			
		||||
		        shState->fileSystem().openRead(filename.constData(), FileSystem::Audio);
 | 
			
		||||
 | 
			
		||||
		if (!this->music.openFromStream(currentData))
 | 
			
		||||
			return;
 | 
			
		||||
| 
						 | 
				
			
			@ -319,7 +319,7 @@ private:
 | 
			
		|||
//		{
 | 
			
		||||
//			/* Buffer not in cashe, needs to be loaded */
 | 
			
		||||
//			SDL_RWops ops;
 | 
			
		||||
//			gState->fileSystem().openRead(ops, filename, FileSystem::Audio);
 | 
			
		||||
//			shState->fileSystem().openRead(ops, filename, FileSystem::Audio);
 | 
			
		||||
 | 
			
		||||
//			Mix_Chunk *sdlBuffer = Mix_LoadWAV_RW(&ops, 1);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -435,7 +435,7 @@ private:
 | 
			
		|||
			/* Buffer not in cashe, needs to be loaded */
 | 
			
		||||
 | 
			
		||||
			FileStream data =
 | 
			
		||||
				gState->fileSystem().openRead(filename, FileSystem::Audio);
 | 
			
		||||
				shState->fileSystem().openRead(filename, FileSystem::Audio);
 | 
			
		||||
 | 
			
		||||
			buffer = new SoundBuffer;
 | 
			
		||||
			buffer->sfBuffer.loadFromStream(data);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,7 +34,7 @@
 | 
			
		|||
#include "transform.h"
 | 
			
		||||
#include "exception.h"
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "glstate.h"
 | 
			
		||||
#include "texpool.h"
 | 
			
		||||
#include "shader.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +78,7 @@ struct BitmapPrivate
 | 
			
		|||
	BitmapPrivate()
 | 
			
		||||
	    : megaSurface(0)
 | 
			
		||||
	{
 | 
			
		||||
		font = &gState->defaultFont();
 | 
			
		||||
		font = &shState->defaultFont();
 | 
			
		||||
		pixman_region_init(&tainted);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +159,7 @@ struct BitmapPrivate
 | 
			
		|||
		if (pointArray.count() == 0)
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		SimpleColorShader &shader = gState->simpleColorShader();
 | 
			
		||||
		SimpleColorShader &shader = shState->simpleColorShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.setTranslation(Vec2i());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -207,7 +207,7 @@ struct BitmapPrivate
 | 
			
		|||
Bitmap::Bitmap(const char *filename)
 | 
			
		||||
{
 | 
			
		||||
	SDL_RWops ops;
 | 
			
		||||
	gState->fileSystem().openRead(ops, filename, FileSystem::Image);
 | 
			
		||||
	shState->fileSystem().openRead(ops, filename, FileSystem::Image);
 | 
			
		||||
	SDL_Surface *imgSurf = IMG_Load_RW(&ops, 1);
 | 
			
		||||
 | 
			
		||||
	if (!imgSurf)
 | 
			
		||||
| 
						 | 
				
			
			@ -228,7 +228,7 @@ Bitmap::Bitmap(const char *filename)
 | 
			
		|||
		TEXFBO tex;
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			tex = gState->texPool().request(imgSurf->w, imgSurf->h);
 | 
			
		||||
			tex = shState->texPool().request(imgSurf->w, imgSurf->h);
 | 
			
		||||
		}
 | 
			
		||||
		catch (const Exception &e)
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			@ -253,7 +253,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 = shState->texPool().request(width, height);
 | 
			
		||||
 | 
			
		||||
	p = new BitmapPrivate;
 | 
			
		||||
	p->gl = tex;
 | 
			
		||||
| 
						 | 
				
			
			@ -265,7 +265,7 @@ Bitmap::Bitmap(const Bitmap &other)
 | 
			
		|||
{
 | 
			
		||||
	p = new BitmapPrivate;
 | 
			
		||||
 | 
			
		||||
	p->gl = gState->texPool().request(other.width(), other.height());
 | 
			
		||||
	p->gl = shState->texPool().request(other.width(), other.height());
 | 
			
		||||
 | 
			
		||||
	other.flush();
 | 
			
		||||
	blt(0, 0, other, rect());
 | 
			
		||||
| 
						 | 
				
			
			@ -379,7 +379,7 @@ void Bitmap::stretchBlt(const IntRect &destRect,
 | 
			
		|||
 | 
			
		||||
		float normOpacity = (float) opacity / 255.0f;
 | 
			
		||||
 | 
			
		||||
		TEXFBO &gpTex = gState->gpTexFBO(destRect.w, destRect.h);
 | 
			
		||||
		TEXFBO &gpTex = shState->gpTexFBO(destRect.w, destRect.h);
 | 
			
		||||
 | 
			
		||||
		FBO::bind(gpTex.fbo, FBO::Draw);
 | 
			
		||||
		FBO::bind(p->gl.fbo, FBO::Read);
 | 
			
		||||
| 
						 | 
				
			
			@ -390,13 +390,13 @@ void Bitmap::stretchBlt(const IntRect &destRect,
 | 
			
		|||
		                     ((float) source.width() / sourceRect.w) * ((float) destRect.w / gpTex.width),
 | 
			
		||||
		                     ((float) source.height() / sourceRect.h) * ((float) destRect.h / gpTex.height));
 | 
			
		||||
 | 
			
		||||
		BltShader &shader = gState->bltShader();
 | 
			
		||||
		BltShader &shader = shState->bltShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.setDestination(gpTex.tex);
 | 
			
		||||
		shader.setSubRect(bltSubRect);
 | 
			
		||||
		shader.setOpacity(normOpacity);
 | 
			
		||||
 | 
			
		||||
		Quad &quad = gState->gpQuad();
 | 
			
		||||
		Quad &quad = shState->gpQuad();
 | 
			
		||||
		quad.setTexPosRect(sourceRect, destRect);
 | 
			
		||||
		quad.setColor(Vec4(1, 1, 1, normOpacity));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -459,11 +459,11 @@ void Bitmap::gradientFillRect(const IntRect &rect,
 | 
			
		|||
 | 
			
		||||
	flush();
 | 
			
		||||
 | 
			
		||||
	SimpleColorShader &shader = gState->simpleColorShader();
 | 
			
		||||
	SimpleColorShader &shader = shState->simpleColorShader();
 | 
			
		||||
	shader.bind();
 | 
			
		||||
	shader.setTranslation(Vec2i());
 | 
			
		||||
 | 
			
		||||
	Quad &quad = gState->gpQuad();
 | 
			
		||||
	Quad &quad = shState->gpQuad();
 | 
			
		||||
 | 
			
		||||
	if (vertical)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -518,13 +518,13 @@ void Bitmap::blur()
 | 
			
		|||
 | 
			
		||||
	flush();
 | 
			
		||||
 | 
			
		||||
	Quad &quad = gState->gpQuad();
 | 
			
		||||
	Quad &quad = shState->gpQuad();
 | 
			
		||||
	FloatRect rect(0, 0, width(), height());
 | 
			
		||||
	quad.setTexPosRect(rect, rect);
 | 
			
		||||
 | 
			
		||||
	TEXFBO auxTex = gState->texPool().request(width(), height());
 | 
			
		||||
	TEXFBO auxTex = shState->texPool().request(width(), height());
 | 
			
		||||
 | 
			
		||||
	BlurShader &shader = gState->blurShader();
 | 
			
		||||
	BlurShader &shader = shState->blurShader();
 | 
			
		||||
	BlurShader::HPass &pass1 = shader.pass1;
 | 
			
		||||
	BlurShader::VPass &pass2 = shader.pass2;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -552,7 +552,7 @@ void Bitmap::blur()
 | 
			
		|||
	glState.viewport.pop();
 | 
			
		||||
	glState.blendMode.pop();
 | 
			
		||||
 | 
			
		||||
	gState->texPool().release(auxTex);
 | 
			
		||||
	shState->texPool().release(auxTex);
 | 
			
		||||
 | 
			
		||||
	modified();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -613,7 +613,7 @@ void Bitmap::radialBlur(int angle, int divisions)
 | 
			
		|||
 | 
			
		||||
	qArray.commit();
 | 
			
		||||
 | 
			
		||||
	TEXFBO newTex = gState->texPool().request(_width, _height);
 | 
			
		||||
	TEXFBO newTex = shState->texPool().request(_width, _height);
 | 
			
		||||
 | 
			
		||||
	FBO::bind(newTex.fbo, FBO::Draw);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -626,7 +626,7 @@ void Bitmap::radialBlur(int angle, int divisions)
 | 
			
		|||
 | 
			
		||||
	glState.blendMode.pushSet(BlendAddition);
 | 
			
		||||
 | 
			
		||||
	SimpleMatrixShader &shader = gState->simpleMatrixShader();
 | 
			
		||||
	SimpleMatrixShader &shader = shState->simpleMatrixShader();
 | 
			
		||||
	shader.bind();
 | 
			
		||||
 | 
			
		||||
	p->bindTexture(shader);
 | 
			
		||||
| 
						 | 
				
			
			@ -648,7 +648,7 @@ void Bitmap::radialBlur(int angle, int divisions)
 | 
			
		|||
	glState.blendMode.pop();
 | 
			
		||||
	glState.clearColor.pop();
 | 
			
		||||
 | 
			
		||||
	gState->texPool().release(p->tex);
 | 
			
		||||
	shState->texPool().release(p->tex);
 | 
			
		||||
	p->tex = newTex;
 | 
			
		||||
 | 
			
		||||
	modified();
 | 
			
		||||
| 
						 | 
				
			
			@ -722,11 +722,11 @@ void Bitmap::hueChange(int hue)
 | 
			
		|||
 | 
			
		||||
	flush();
 | 
			
		||||
 | 
			
		||||
	TEXFBO newTex = gState->texPool().request(width(), height());
 | 
			
		||||
	TEXFBO newTex = shState->texPool().request(width(), height());
 | 
			
		||||
 | 
			
		||||
	FloatRect texRect(rect());
 | 
			
		||||
 | 
			
		||||
	Quad &quad = gState->gpQuad();
 | 
			
		||||
	Quad &quad = shState->gpQuad();
 | 
			
		||||
	quad.setTexPosRect(texRect, texRect);
 | 
			
		||||
	quad.setColor(Vec4(1, 1, 1, 1));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -734,7 +734,7 @@ void Bitmap::hueChange(int hue)
 | 
			
		|||
	hue = wrapRange(hue, 0, 359);
 | 
			
		||||
	float hueAdj = -((M_PI * 2) / 360) * hue;
 | 
			
		||||
 | 
			
		||||
	HueShader &shader = gState->hueShader();
 | 
			
		||||
	HueShader &shader = shState->hueShader();
 | 
			
		||||
	shader.bind();
 | 
			
		||||
	shader.setHueAdjust(hueAdj);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -750,7 +750,7 @@ void Bitmap::hueChange(int hue)
 | 
			
		|||
 | 
			
		||||
	TEX::unbind();
 | 
			
		||||
 | 
			
		||||
	gState->texPool().release(p->gl);
 | 
			
		||||
	shState->texPool().release(p->gl);
 | 
			
		||||
	p->gl = newTex;
 | 
			
		||||
 | 
			
		||||
	modified();
 | 
			
		||||
| 
						 | 
				
			
			@ -787,7 +787,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
 | 
			
		|||
 | 
			
		||||
	SDL_Surface *txtSurf;
 | 
			
		||||
 | 
			
		||||
	if (gState->rtData().config.solidFonts)
 | 
			
		||||
	if (shState->rtData().config.solidFonts)
 | 
			
		||||
		txtSurf = TTF_RenderUTF8_Solid(font, str, c);
 | 
			
		||||
	else
 | 
			
		||||
		txtSurf = TTF_RenderUTF8_Blended(font, str, c);
 | 
			
		||||
| 
						 | 
				
			
			@ -824,7 +824,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
 | 
			
		|||
	FloatRect posRect(alignX, alignY, txtSurf->w * squeeze, txtSurf->h);
 | 
			
		||||
 | 
			
		||||
	Vec2i gpTexSize;
 | 
			
		||||
	gState->ensureTexSize(txtSurf->w, txtSurf->h, gpTexSize);
 | 
			
		||||
	shState->ensureTexSize(txtSurf->w, txtSurf->h, gpTexSize);
 | 
			
		||||
 | 
			
		||||
	bool fastBlit = !p->touchesTaintedArea(posRect) && txtAlpha == 1.0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -888,7 +888,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
 | 
			
		|||
		else
 | 
			
		||||
		{
 | 
			
		||||
			/* Squeezing involved: need to use intermediary TexFBO */
 | 
			
		||||
			TEXFBO &gpTF = gState->gpTexFBO(txtSurf->w, txtSurf->h);
 | 
			
		||||
			TEXFBO &gpTF = shState->gpTexFBO(txtSurf->w, txtSurf->h);
 | 
			
		||||
 | 
			
		||||
			TEX::bind(gpTF.tex);
 | 
			
		||||
			TEX::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA_EXT);
 | 
			
		||||
| 
						 | 
				
			
			@ -905,7 +905,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 = shState->gpTexFBO(posRect.w, posRect.h);
 | 
			
		||||
 | 
			
		||||
		FBO::bind(gpTex2.fbo, FBO::Draw);
 | 
			
		||||
		FBO::bind(p->gl.fbo, FBO::Read);
 | 
			
		||||
| 
						 | 
				
			
			@ -915,7 +915,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
 | 
			
		|||
		                  (float) gpTexSize.x / gpTex2.width,
 | 
			
		||||
		                  (float) gpTexSize.y / gpTex2.height);
 | 
			
		||||
 | 
			
		||||
		BltShader &shader = gState->bltShader();
 | 
			
		||||
		BltShader &shader = shState->bltShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.setTexSize(gpTexSize);
 | 
			
		||||
		shader.setSource();
 | 
			
		||||
| 
						 | 
				
			
			@ -923,11 +923,11 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
 | 
			
		|||
		shader.setSubRect(bltRect);
 | 
			
		||||
		shader.setOpacity(txtAlpha);
 | 
			
		||||
 | 
			
		||||
		gState->bindTex();
 | 
			
		||||
		shState->bindTex();
 | 
			
		||||
		TEX::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA_EXT);
 | 
			
		||||
		TEX::setSmooth(true);
 | 
			
		||||
 | 
			
		||||
		Quad &quad = gState->gpQuad();
 | 
			
		||||
		Quad &quad = shState->gpQuad();
 | 
			
		||||
		quad.setTexRect(FloatRect(0, 0, txtSurf->w, txtSurf->h));
 | 
			
		||||
		quad.setPosRect(posRect);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1006,7 +1006,7 @@ void Bitmap::releaseResources()
 | 
			
		|||
	if (p->megaSurface)
 | 
			
		||||
		SDL_FreeSurface(p->megaSurface);
 | 
			
		||||
	else
 | 
			
		||||
		gState->texPool().release(p->gl);
 | 
			
		||||
		shState->texPool().release(p->gl);
 | 
			
		||||
 | 
			
		||||
	delete p;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@
 | 
			
		|||
#include "SDL2/SDL_timer.h"
 | 
			
		||||
#include "SDL2/SDL_thread.h"
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "graphics.h"
 | 
			
		||||
 | 
			
		||||
#include "string.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -361,7 +361,7 @@ void EventThread::showMessageBox(const char *body, int flags)
 | 
			
		|||
	SDL_PushEvent(&event);
 | 
			
		||||
 | 
			
		||||
	/* Keep repainting screen while box is open */
 | 
			
		||||
	gState->graphics().repaintWait(&msgBoxDone);
 | 
			
		||||
	shState->graphics().repaintWait(&msgBoxDone);
 | 
			
		||||
	/* Prevent endless loops */
 | 
			
		||||
	resetInputStates();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								src/font.cpp
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/font.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -21,7 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include "font.h"
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "filesystem.h"
 | 
			
		||||
#include "exception.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +79,7 @@ _TTF_Font *FontPool::request(const char *filename,
 | 
			
		|||
 | 
			
		||||
	bool useBundled = false;
 | 
			
		||||
	QByteArray path = QByteArray("Fonts/") + nameKey;
 | 
			
		||||
	if (!gState->fileSystem().exists(path.constData(), FileSystem::Font))
 | 
			
		||||
	if (!shState->fileSystem().exists(path.constData(), FileSystem::Font))
 | 
			
		||||
	{
 | 
			
		||||
		useBundled = true;
 | 
			
		||||
		nameKey = " bundled";
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ _TTF_Font *FontPool::request(const char *filename,
 | 
			
		|||
	else
 | 
			
		||||
	{
 | 
			
		||||
		ops = SDL_AllocRW();
 | 
			
		||||
		gState->fileSystem().openRead(*ops, path.constData(), FileSystem::Font, true);
 | 
			
		||||
		shState->fileSystem().openRead(*ops, path.constData(), FileSystem::Font, true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// FIXME 0.9 is guesswork at this point
 | 
			
		||||
| 
						 | 
				
			
			@ -151,7 +151,7 @@ struct FontPrivate
 | 
			
		|||
	      color(&colorTmp),
 | 
			
		||||
	      colorTmp(*defaultColor)
 | 
			
		||||
	{
 | 
			
		||||
		sdlFont = gState->fontPool().request(this->name.constData(),
 | 
			
		||||
		sdlFont = shState->fontPool().request(this->name.constData(),
 | 
			
		||||
		                                     this->size);
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -168,7 +168,7 @@ bool Font::doesExist(const char *name)
 | 
			
		|||
{
 | 
			
		||||
	QByteArray path = QByteArray("fonts/") + QByteArray(name);
 | 
			
		||||
 | 
			
		||||
	return gState->fileSystem().exists(path.constData(), FileSystem::Font);
 | 
			
		||||
	return shState->fileSystem().exists(path.constData(), FileSystem::Font);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Font::Font(const char *name,
 | 
			
		||||
| 
						 | 
				
			
			@ -198,7 +198,7 @@ void Font::setSize(int value)
 | 
			
		|||
		return;
 | 
			
		||||
 | 
			
		||||
	p->size = value;
 | 
			
		||||
	p->sdlFont = gState->fontPool().request(p->name.constData(), value);
 | 
			
		||||
	p->sdlFont = shState->fontPool().request(p->name.constData(), value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#undef CHK_DISP
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@
 | 
			
		|||
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "gl-util.h"
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "glstate.h"
 | 
			
		||||
#include "shader.h"
 | 
			
		||||
#include "scene.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +145,7 @@ public:
 | 
			
		|||
		const int w = geometry.rect.w;
 | 
			
		||||
		const int h = geometry.rect.h;
 | 
			
		||||
 | 
			
		||||
		gState->prepareDraw();
 | 
			
		||||
		shState->prepareDraw();
 | 
			
		||||
 | 
			
		||||
		pp.startRender();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -158,7 +158,7 @@ public:
 | 
			
		|||
#ifdef RGSS2
 | 
			
		||||
		if (brightEffect)
 | 
			
		||||
		{
 | 
			
		||||
			SimpleColorShader &shader = gState->simpleColorShader();
 | 
			
		||||
			SimpleColorShader &shader = shState->simpleColorShader();
 | 
			
		||||
			shader.bind();
 | 
			
		||||
			shader.applyViewportProj();
 | 
			
		||||
			shader.setTranslation(Vec2i());
 | 
			
		||||
| 
						 | 
				
			
			@ -175,7 +175,7 @@ public:
 | 
			
		|||
		pp.swapRender();
 | 
			
		||||
		pp.blitFBOs();
 | 
			
		||||
 | 
			
		||||
		PlaneShader &shader = gState->planeShader();
 | 
			
		||||
		PlaneShader &shader = shState->planeShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.setColor(c);
 | 
			
		||||
		shader.setFlash(f);
 | 
			
		||||
| 
						 | 
				
			
			@ -358,11 +358,11 @@ struct GraphicsPrivate
 | 
			
		|||
 | 
			
		||||
	void updateScreenResoRatio()
 | 
			
		||||
	{
 | 
			
		||||
		Vec2 &ratio = gState->rtData().sizeResoRatio;
 | 
			
		||||
		Vec2 &ratio = shState->rtData().sizeResoRatio;
 | 
			
		||||
		ratio.x = (float) scRes.x / scSize.x;
 | 
			
		||||
		ratio.y = (float) scRes.y / scSize.y;
 | 
			
		||||
 | 
			
		||||
		gState->rtData().screenOffset = scOffset;
 | 
			
		||||
		shState->rtData().screenOffset = scOffset;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Enforces fixed aspect ratio, if desired */
 | 
			
		||||
| 
						 | 
				
			
			@ -401,7 +401,7 @@ struct GraphicsPrivate
 | 
			
		|||
	void shutdown()
 | 
			
		||||
	{
 | 
			
		||||
		threadData->rqTermAck = true;
 | 
			
		||||
		gState->texPool().disable();
 | 
			
		||||
		shState->texPool().disable();
 | 
			
		||||
 | 
			
		||||
		scriptBinding->terminate();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -460,7 +460,7 @@ Graphics::~Graphics()
 | 
			
		|||
 | 
			
		||||
void Graphics::update()
 | 
			
		||||
{
 | 
			
		||||
	gState->checkShutdown();
 | 
			
		||||
	shState->checkShutdown();
 | 
			
		||||
 | 
			
		||||
//	p->cpuTimer->endTiming();
 | 
			
		||||
//	p->gpuTimer->startTiming();
 | 
			
		||||
| 
						 | 
				
			
			@ -479,7 +479,7 @@ void Graphics::freeze()
 | 
			
		|||
{
 | 
			
		||||
	p->frozen = true;
 | 
			
		||||
 | 
			
		||||
	gState->checkShutdown();
 | 
			
		||||
	shState->checkShutdown();
 | 
			
		||||
	p->checkResize();
 | 
			
		||||
 | 
			
		||||
	/* Capture scene into frozen buffer */
 | 
			
		||||
| 
						 | 
				
			
			@ -504,7 +504,7 @@ void Graphics::transition(int duration,
 | 
			
		|||
	 * we can use a simplified shader */
 | 
			
		||||
	if (transMap)
 | 
			
		||||
	{
 | 
			
		||||
		TransShader &shader = gState->transShader();
 | 
			
		||||
		TransShader &shader = shState->transShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.applyViewportProj();
 | 
			
		||||
		shader.setFrozenScene(p->frozenScene.tex);
 | 
			
		||||
| 
						 | 
				
			
			@ -515,7 +515,7 @@ void Graphics::transition(int duration,
 | 
			
		|||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		SimpleTransShader &shader = gState->sTransShader();
 | 
			
		||||
		SimpleTransShader &shader = shState->sTransShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.applyViewportProj();
 | 
			
		||||
		shader.setFrozenScene(p->frozenScene.tex);
 | 
			
		||||
| 
						 | 
				
			
			@ -536,9 +536,9 @@ void Graphics::transition(int duration,
 | 
			
		|||
		const float prog = i * (1.0 / duration);
 | 
			
		||||
 | 
			
		||||
		if (transMap)
 | 
			
		||||
			gState->transShader().setProg(prog);
 | 
			
		||||
			shState->transShader().setProg(prog);
 | 
			
		||||
		else
 | 
			
		||||
			gState->sTransShader().setProg(prog);
 | 
			
		||||
			shState->sTransShader().setProg(prog);
 | 
			
		||||
 | 
			
		||||
		/* Draw the composed frame to a buffer first
 | 
			
		||||
		 * (we need this because we're skipping PingPong) */
 | 
			
		||||
| 
						 | 
				
			
			@ -589,7 +589,7 @@ void Graphics::wait(int duration)
 | 
			
		|||
{
 | 
			
		||||
	for (int i = 0; i < duration; ++i)
 | 
			
		||||
	{
 | 
			
		||||
		gState->checkShutdown();
 | 
			
		||||
		shState->checkShutdown();
 | 
			
		||||
		p->checkResize();
 | 
			
		||||
		p->redrawScreen();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -666,7 +666,7 @@ void Graphics::resizeScreen(int width, int height)
 | 
			
		|||
	if (p->scRes == size)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	gState->eThread().requestWindowResize(width, height);
 | 
			
		||||
	shState->eThread().requestWindowResize(width, height);
 | 
			
		||||
 | 
			
		||||
	p->scRes = size;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -737,7 +737,7 @@ void Graphics::repaintWait(volatile bool *exitCond)
 | 
			
		|||
 | 
			
		||||
	while (!*exitCond)
 | 
			
		||||
	{
 | 
			
		||||
		gState->checkShutdown();
 | 
			
		||||
		shState->checkShutdown();
 | 
			
		||||
 | 
			
		||||
		FBO::clear();
 | 
			
		||||
		p->blitBufferFlippedScaled();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@
 | 
			
		|||
*/
 | 
			
		||||
 | 
			
		||||
#include "input.h"
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "eventthread.h"
 | 
			
		||||
#include "exception.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -552,7 +552,7 @@ Input::Input()
 | 
			
		|||
 | 
			
		||||
void Input::update()
 | 
			
		||||
{
 | 
			
		||||
	gState->checkShutdown();
 | 
			
		||||
	shState->checkShutdown();
 | 
			
		||||
 | 
			
		||||
	p->swapBuffers();
 | 
			
		||||
	p->clearBuffer();
 | 
			
		||||
| 
						 | 
				
			
			@ -614,13 +614,13 @@ int Input::dir8Value()
 | 
			
		|||
 | 
			
		||||
int Input::mouseX()
 | 
			
		||||
{
 | 
			
		||||
	RGSSThreadData &rtData = gState->rtData();
 | 
			
		||||
	RGSSThreadData &rtData = shState->rtData();
 | 
			
		||||
	return (EventThread::mouseState.x - rtData.screenOffset.x) * rtData.sizeResoRatio.x;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int Input::mouseY()
 | 
			
		||||
{
 | 
			
		||||
	RGSSThreadData &rtData = gState->rtData();
 | 
			
		||||
	RGSSThreadData &rtData = shState->rtData();
 | 
			
		||||
	return (EventThread::mouseState.y - rtData.screenOffset.y) * rtData.sizeResoRatio.y;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@
 | 
			
		|||
#include "SDL2/SDL_image.h"
 | 
			
		||||
#include "SDL2/SDL_ttf.h"
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "eventthread.h"
 | 
			
		||||
#include "debuglogger.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +100,7 @@ int rgssThreadFun(void *userdata)
 | 
			
		|||
 | 
			
		||||
	DebugLogger dLogger;
 | 
			
		||||
 | 
			
		||||
	GlobalState::initInstance(threadData);
 | 
			
		||||
	SharedState::initInstance(threadData);
 | 
			
		||||
 | 
			
		||||
	/* Start script execution */
 | 
			
		||||
	scriptBinding->execute();
 | 
			
		||||
| 
						 | 
				
			
			@ -108,7 +108,7 @@ int rgssThreadFun(void *userdata)
 | 
			
		|||
	threadData->rqTermAck = true;
 | 
			
		||||
	threadData->ethread->requestTerminate();
 | 
			
		||||
 | 
			
		||||
	GlobalState::finiInstance();
 | 
			
		||||
	SharedState::finiInstance();
 | 
			
		||||
 | 
			
		||||
	SDL_GL_DeleteContext(ctx);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include "plane.h"
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "bitmap.h"
 | 
			
		||||
#include "etc.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -186,7 +186,7 @@ void Plane::draw()
 | 
			
		|||
 | 
			
		||||
	if (p->color->hasEffect() || p->tone->hasEffect() || p->opacity != 255)
 | 
			
		||||
	{
 | 
			
		||||
		PlaneShader &shader = gState->planeShader();
 | 
			
		||||
		PlaneShader &shader = shState->planeShader();
 | 
			
		||||
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.applyViewportProj();
 | 
			
		||||
| 
						 | 
				
			
			@ -199,7 +199,7 @@ void Plane::draw()
 | 
			
		|||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		SimpleShader &shader = gState->simpleShader();
 | 
			
		||||
		SimpleShader &shader = shState->simpleShader();
 | 
			
		||||
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.applyViewportProj();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@
 | 
			
		|||
#include "GL/glew.h"
 | 
			
		||||
#include "etc-internal.h"
 | 
			
		||||
#include "gl-util.h"
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "global-ibo.h"
 | 
			
		||||
#include "shader.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -110,7 +110,7 @@ struct Quad
 | 
			
		|||
	{
 | 
			
		||||
		VAO::bind(vao);
 | 
			
		||||
		VBO::bind(vbo);
 | 
			
		||||
		gState->bindQuadIBO();
 | 
			
		||||
		shState->bindQuadIBO();
 | 
			
		||||
 | 
			
		||||
		glEnableVertexAttribArray(Shader::Color);
 | 
			
		||||
		glEnableVertexAttribArray(Shader::Position);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,7 @@
 | 
			
		|||
 | 
			
		||||
#include <QtGlobal>
 | 
			
		||||
#include "gl-util.h"
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "global-ibo.h"
 | 
			
		||||
#include "shader.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ struct ColorQuadArray
 | 
			
		|||
 | 
			
		||||
		VAO::bind(vao);
 | 
			
		||||
		VBO::bind(vbo);
 | 
			
		||||
		gState->bindQuadIBO();
 | 
			
		||||
		shState->bindQuadIBO();
 | 
			
		||||
 | 
			
		||||
		glEnableVertexAttribArray(Shader::Color);
 | 
			
		||||
		glEnableVertexAttribArray(Shader::Position);
 | 
			
		||||
| 
						 | 
				
			
			@ -83,7 +83,7 @@ struct ColorQuadArray
 | 
			
		|||
		VBO::uploadData(vertices.size() * sizeof(Vertex), vertices.constData(), GL_DYNAMIC_DRAW);
 | 
			
		||||
		VBO::unbind();
 | 
			
		||||
 | 
			
		||||
		gState->ensureQuadIBO(quadCount);
 | 
			
		||||
		shState->ensureQuadIBO(quadCount);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void draw(uint offset, uint count)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@
 | 
			
		|||
*/
 | 
			
		||||
 | 
			
		||||
#include "scene.h"
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -91,7 +91,7 @@ void Scene::composite()
 | 
			
		|||
 | 
			
		||||
SceneElement::SceneElement(Scene &scene, int z)
 | 
			
		||||
    : link(this),
 | 
			
		||||
      creationStamp(gState->genTimeStamp()),
 | 
			
		||||
      creationStamp(shState->genTimeStamp()),
 | 
			
		||||
      z(z),
 | 
			
		||||
      visible(true),
 | 
			
		||||
      scene(&scene)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@
 | 
			
		|||
*/
 | 
			
		||||
 | 
			
		||||
#include "shader.h"
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "glstate.h"
 | 
			
		||||
 | 
			
		||||
#include "GL/glew.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
** globalstate.cpp
 | 
			
		||||
** sharedstate.cpp
 | 
			
		||||
**
 | 
			
		||||
** This file is part of mkxp.
 | 
			
		||||
**
 | 
			
		||||
| 
						 | 
				
			
			@ -19,7 +19,7 @@
 | 
			
		|||
** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "filesystem.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -42,12 +42,12 @@
 | 
			
		|||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
 | 
			
		||||
GlobalState *GlobalState::instance = 0;
 | 
			
		||||
SharedState *SharedState::instance = 0;
 | 
			
		||||
static GlobalIBO *globalIBO = 0;
 | 
			
		||||
 | 
			
		||||
#define GAME_ARCHIVE "Game.rgssad"
 | 
			
		||||
 | 
			
		||||
struct GlobalStatePrivate
 | 
			
		||||
struct SharedStatePrivate
 | 
			
		||||
{
 | 
			
		||||
	void *bindingData;
 | 
			
		||||
	SDL_Window *sdlWindow;
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +96,7 @@ struct GlobalStatePrivate
 | 
			
		|||
 | 
			
		||||
	unsigned int stampCounter;
 | 
			
		||||
 | 
			
		||||
	GlobalStatePrivate(RGSSThreadData *threadData)
 | 
			
		||||
	SharedStatePrivate(RGSSThreadData *threadData)
 | 
			
		||||
	    : bindingData(0),
 | 
			
		||||
	      sdlWindow(threadData->window),
 | 
			
		||||
	      fileSystem(threadData->argv0),
 | 
			
		||||
| 
						 | 
				
			
			@ -139,41 +139,41 @@ struct GlobalStatePrivate
 | 
			
		|||
		TEXFBO::linkFBO(gpTexFBO);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	~GlobalStatePrivate()
 | 
			
		||||
	~SharedStatePrivate()
 | 
			
		||||
	{
 | 
			
		||||
		TEX::del(globalTex);
 | 
			
		||||
		TEXFBO::fini(gpTexFBO);
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void GlobalState::initInstance(RGSSThreadData *threadData)
 | 
			
		||||
void SharedState::initInstance(RGSSThreadData *threadData)
 | 
			
		||||
{
 | 
			
		||||
	globalIBO = new GlobalIBO();
 | 
			
		||||
	globalIBO->ensureSize(1);
 | 
			
		||||
 | 
			
		||||
	GlobalState *state = new GlobalState(threadData);
 | 
			
		||||
	SharedState *state = new SharedState(threadData);
 | 
			
		||||
 | 
			
		||||
	GlobalState::instance = state;
 | 
			
		||||
	SharedState::instance = state;
 | 
			
		||||
 | 
			
		||||
	state->p->defaultFont = new Font();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GlobalState::finiInstance()
 | 
			
		||||
void SharedState::finiInstance()
 | 
			
		||||
{
 | 
			
		||||
	delete GlobalState::instance->p->defaultFont;
 | 
			
		||||
	delete SharedState::instance->p->defaultFont;
 | 
			
		||||
 | 
			
		||||
	delete GlobalState::instance;
 | 
			
		||||
	delete SharedState::instance;
 | 
			
		||||
 | 
			
		||||
	delete globalIBO;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GlobalState::setScreen(Scene &screen)
 | 
			
		||||
void SharedState::setScreen(Scene &screen)
 | 
			
		||||
{
 | 
			
		||||
	p->screen = &screen;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define GSATT(type, lower) \
 | 
			
		||||
	type GlobalState :: lower() \
 | 
			
		||||
	type SharedState :: lower() \
 | 
			
		||||
	{ \
 | 
			
		||||
		return p->lower; \
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -209,28 +209,28 @@ GSATT(SimpleMatrixShader&, simpleMatrixShader)
 | 
			
		|||
GSATT(BlurShader&, blurShader)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void GlobalState::setBindingData(void *data)
 | 
			
		||||
void SharedState::setBindingData(void *data)
 | 
			
		||||
{
 | 
			
		||||
	p->bindingData = data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GlobalState::ensureQuadIBO(int minSize)
 | 
			
		||||
void SharedState::ensureQuadIBO(int minSize)
 | 
			
		||||
{
 | 
			
		||||
	globalIBO->ensureSize(minSize);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GlobalState::bindQuadIBO()
 | 
			
		||||
void SharedState::bindQuadIBO()
 | 
			
		||||
{
 | 
			
		||||
	IBO::bind(globalIBO->ibo);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GlobalState::bindTex()
 | 
			
		||||
void SharedState::bindTex()
 | 
			
		||||
{
 | 
			
		||||
	TEX::bind(p->globalTex);
 | 
			
		||||
	TEX::allocEmpty(p->globalTexW, p->globalTexH);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GlobalState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
 | 
			
		||||
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
 | 
			
		||||
{
 | 
			
		||||
	if (minW > p->globalTexW)
 | 
			
		||||
		p->globalTexW = findNextPow2(minW);
 | 
			
		||||
| 
						 | 
				
			
			@ -241,7 +241,7 @@ void GlobalState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
 | 
			
		|||
	currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEXFBO &GlobalState::gpTexFBO(int minW, int minH)
 | 
			
		||||
TEXFBO &SharedState::gpTexFBO(int minW, int minH)
 | 
			
		||||
{
 | 
			
		||||
	bool needResize = false;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -266,7 +266,7 @@ TEXFBO &GlobalState::gpTexFBO(int minW, int minH)
 | 
			
		|||
	return p->gpTexFBO;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GlobalState::checkShutdown()
 | 
			
		||||
void SharedState::checkShutdown()
 | 
			
		||||
{
 | 
			
		||||
	if (!p->rtData.rqTerm)
 | 
			
		||||
		return;
 | 
			
		||||
| 
						 | 
				
			
			@ -276,23 +276,23 @@ void GlobalState::checkShutdown()
 | 
			
		|||
	scriptBinding->terminate();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Font &GlobalState::defaultFont()
 | 
			
		||||
Font &SharedState::defaultFont()
 | 
			
		||||
{
 | 
			
		||||
	return *p->defaultFont;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned int GlobalState::genTimeStamp()
 | 
			
		||||
unsigned int SharedState::genTimeStamp()
 | 
			
		||||
{
 | 
			
		||||
	return p->stampCounter++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
GlobalState::GlobalState(RGSSThreadData *threadData)
 | 
			
		||||
SharedState::SharedState(RGSSThreadData *threadData)
 | 
			
		||||
{
 | 
			
		||||
	p = new GlobalStatePrivate(threadData);
 | 
			
		||||
	p = new SharedStatePrivate(threadData);
 | 
			
		||||
	p->screen = p->graphics.getScreen();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
GlobalState::~GlobalState()
 | 
			
		||||
SharedState::~SharedState()
 | 
			
		||||
{
 | 
			
		||||
	delete p;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
/*
 | 
			
		||||
** globalstate.h
 | 
			
		||||
** sharedstate.h
 | 
			
		||||
**
 | 
			
		||||
** This file is part of mkxp.
 | 
			
		||||
**
 | 
			
		||||
| 
						 | 
				
			
			@ -19,15 +19,15 @@
 | 
			
		|||
** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef GLOBALSTATE_H
 | 
			
		||||
#define GLOBALSTATE_H
 | 
			
		||||
#ifndef SHAREDSTATE_H
 | 
			
		||||
#define SHAREDSTATE_H
 | 
			
		||||
 | 
			
		||||
#include "sigc++/signal.h"
 | 
			
		||||
 | 
			
		||||
#define gState GlobalState::instance
 | 
			
		||||
#define glState gState->_glState()
 | 
			
		||||
#define shState SharedState::instance
 | 
			
		||||
#define glState shState->_glState()
 | 
			
		||||
 | 
			
		||||
struct GlobalStatePrivate;
 | 
			
		||||
struct SharedStatePrivate;
 | 
			
		||||
struct RGSSThreadData;
 | 
			
		||||
struct GlobalIBO;
 | 
			
		||||
struct mrb_state;
 | 
			
		||||
| 
						 | 
				
			
			@ -62,7 +62,7 @@ struct GlobalIBO;
 | 
			
		|||
struct Config;
 | 
			
		||||
struct Vec2i;
 | 
			
		||||
 | 
			
		||||
struct GlobalState
 | 
			
		||||
struct SharedState
 | 
			
		||||
{
 | 
			
		||||
	void *bindingData();
 | 
			
		||||
	void setBindingData(void *data);
 | 
			
		||||
| 
						 | 
				
			
			@ -128,15 +128,15 @@ struct GlobalState
 | 
			
		|||
	 * function will most likely not return */
 | 
			
		||||
	void checkShutdown();
 | 
			
		||||
 | 
			
		||||
	static GlobalState *instance;
 | 
			
		||||
	static SharedState *instance;
 | 
			
		||||
	static void initInstance(RGSSThreadData *threadData);
 | 
			
		||||
	static void finiInstance();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	GlobalState(RGSSThreadData *threadData);
 | 
			
		||||
	~GlobalState();
 | 
			
		||||
	SharedState(RGSSThreadData *threadData);
 | 
			
		||||
	~SharedState();
 | 
			
		||||
 | 
			
		||||
	GlobalStatePrivate *p;
 | 
			
		||||
	SharedStatePrivate *p;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // GLOBALSTATE_H
 | 
			
		||||
#endif // SHAREDSTATE_H
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include "sprite.h"
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "bitmap.h"
 | 
			
		||||
#include "etc.h"
 | 
			
		||||
#include "etc-internal.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -325,7 +325,7 @@ void Sprite::draw()
 | 
			
		|||
 | 
			
		||||
	if (renderEffect)
 | 
			
		||||
	{
 | 
			
		||||
		SpriteShader &shader = gState->spriteShader();
 | 
			
		||||
		SpriteShader &shader = shState->spriteShader();
 | 
			
		||||
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.applyViewportProj();
 | 
			
		||||
| 
						 | 
				
			
			@ -347,7 +347,7 @@ void Sprite::draw()
 | 
			
		|||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		SimpleSpriteShader &shader = gState->simpleSpriteShader();
 | 
			
		||||
		SimpleSpriteShader &shader = shState->simpleSpriteShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
 | 
			
		||||
		shader.setSpriteMat(p->trans.getMatrix());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include "texpool.h"
 | 
			
		||||
#include "exception.h"
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "glstate.h"
 | 
			
		||||
 | 
			
		||||
#include <QHash>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@
 | 
			
		|||
#include "bitmap.h"
 | 
			
		||||
#include "table.h"
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "glstate.h"
 | 
			
		||||
#include "gl-util.h"
 | 
			
		||||
#include "etc-internal.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -389,7 +389,7 @@ struct TilemapPrivate
 | 
			
		|||
		glEnableVertexAttribArray(Shader::TexCoord);
 | 
			
		||||
 | 
			
		||||
		VBO::bind(tiles.vbo);
 | 
			
		||||
		gState->bindQuadIBO();
 | 
			
		||||
		shState->bindQuadIBO();
 | 
			
		||||
 | 
			
		||||
		glVertexAttribPointer(Shader::Position, 2, GL_FLOAT, GL_FALSE, sizeof(SVertex), SVertex::posOffset());
 | 
			
		||||
		glVertexAttribPointer(Shader::TexCoord, 2, GL_FLOAT, GL_FALSE, sizeof(SVertex), SVertex::texPosOffset());
 | 
			
		||||
| 
						 | 
				
			
			@ -410,7 +410,7 @@ struct TilemapPrivate
 | 
			
		|||
		glEnableVertexAttribArray(Shader::Position);
 | 
			
		||||
 | 
			
		||||
		VBO::bind(flash.vbo);
 | 
			
		||||
		gState->bindQuadIBO();
 | 
			
		||||
		shState->bindQuadIBO();
 | 
			
		||||
 | 
			
		||||
		glVertexAttribPointer(Shader::Color,    4, GL_FLOAT, GL_FALSE, sizeof(CVertex), CVertex::colorOffset());
 | 
			
		||||
		glVertexAttribPointer(Shader::Position, 2, GL_FLOAT, GL_FALSE, sizeof(CVertex), CVertex::posOffset());
 | 
			
		||||
| 
						 | 
				
			
			@ -421,10 +421,10 @@ struct TilemapPrivate
 | 
			
		|||
 | 
			
		||||
		elem.ground = 0;
 | 
			
		||||
 | 
			
		||||
		elem.groundStamp = gState->genTimeStamp();
 | 
			
		||||
		elem.scanrowStamp = gState->genTimeStamp();
 | 
			
		||||
		elem.groundStamp = shState->genTimeStamp();
 | 
			
		||||
		elem.scanrowStamp = shState->genTimeStamp();
 | 
			
		||||
 | 
			
		||||
		prepareCon = gState->prepareDraw.connect
 | 
			
		||||
		prepareCon = shState->prepareDraw.connect
 | 
			
		||||
		        (sigc::mem_fun(this, &TilemapPrivate::prepare));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -432,7 +432,7 @@ struct TilemapPrivate
 | 
			
		|||
	{
 | 
			
		||||
		destroyElements();
 | 
			
		||||
 | 
			
		||||
		gState->texPool().release(atlas.gl);
 | 
			
		||||
		shState->texPool().release(atlas.gl);
 | 
			
		||||
		VAO::del(tiles.vao);
 | 
			
		||||
		VBO::del(tiles.vbo);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -596,8 +596,8 @@ struct TilemapPrivate
 | 
			
		|||
		updateAtlasInfo();
 | 
			
		||||
 | 
			
		||||
		/* Aquire atlas tex */
 | 
			
		||||
		gState->texPool().release(atlas.gl);
 | 
			
		||||
		atlas.gl = gState->texPool().request(atlas.size.x, atlas.size.y);
 | 
			
		||||
		shState->texPool().release(atlas.gl);
 | 
			
		||||
		atlas.gl = shState->texPool().request(atlas.size.x, atlas.size.y);
 | 
			
		||||
 | 
			
		||||
		atlasDirty = true;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -877,7 +877,7 @@ struct TilemapPrivate
 | 
			
		|||
		VBO::unbind();
 | 
			
		||||
 | 
			
		||||
		/* Ensure global IBO size */
 | 
			
		||||
		gState->ensureQuadIBO(quadCount*bufferCount());
 | 
			
		||||
		shState->ensureQuadIBO(quadCount*bufferCount());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void bindAtlas(SimpleShader &shader)
 | 
			
		||||
| 
						 | 
				
			
			@ -962,7 +962,7 @@ struct TilemapPrivate
 | 
			
		|||
		VBO::unbind();
 | 
			
		||||
 | 
			
		||||
		/* Ensure global IBO size */
 | 
			
		||||
		gState->ensureQuadIBO(flash.quadCount);
 | 
			
		||||
		shState->ensureQuadIBO(flash.quadCount);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void destroyElements()
 | 
			
		||||
| 
						 | 
				
			
			@ -1066,7 +1066,7 @@ GroundLayer::GroundLayer(TilemapPrivate *p, Viewport *viewport)
 | 
			
		|||
 | 
			
		||||
void GroundLayer::draw()
 | 
			
		||||
{
 | 
			
		||||
	SimpleShader &shader = gState->simpleShader();
 | 
			
		||||
	SimpleShader &shader = shState->simpleShader();
 | 
			
		||||
	shader.bind();
 | 
			
		||||
	shader.applyViewportProj();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1094,7 +1094,7 @@ void GroundLayer::draw()
 | 
			
		|||
		glState.blendMode.pushSet(BlendAddition);
 | 
			
		||||
		glState.texture2D.pushSet(false);
 | 
			
		||||
 | 
			
		||||
		FlashMapShader &shader = gState->flashMapShader();
 | 
			
		||||
		FlashMapShader &shader = shState->flashMapShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.applyViewportProj();
 | 
			
		||||
		shader.setAlpha(flashAlpha[p->flash.alphaIdx] / 255.f);
 | 
			
		||||
| 
						 | 
				
			
			@ -1147,7 +1147,7 @@ ScanRow::ScanRow(TilemapPrivate *p, Viewport *viewport, int index)
 | 
			
		|||
 | 
			
		||||
void ScanRow::draw()
 | 
			
		||||
{
 | 
			
		||||
	SimpleShader &shader = gState->simpleShader();
 | 
			
		||||
	SimpleShader &shader = shState->simpleShader();
 | 
			
		||||
	shader.bind();
 | 
			
		||||
	shader.applyViewportProj();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include "viewport.h"
 | 
			
		||||
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "etc.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "quad.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -101,14 +101,14 @@ struct ViewportPrivate
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
Viewport::Viewport(int x, int y, int width, int height)
 | 
			
		||||
    : SceneElement(*gState->screen()),
 | 
			
		||||
    : SceneElement(*shState->screen()),
 | 
			
		||||
      sceneLink(this)
 | 
			
		||||
{
 | 
			
		||||
	initViewport(x, y, width, height);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Viewport::Viewport(Rect *rect)
 | 
			
		||||
    : SceneElement(*gState->screen()),
 | 
			
		||||
    : SceneElement(*shState->screen()),
 | 
			
		||||
      sceneLink(this)
 | 
			
		||||
{
 | 
			
		||||
	initViewport(rect->x, rect->y, rect->width, rect->height);
 | 
			
		||||
| 
						 | 
				
			
			@ -227,12 +227,12 @@ void Viewport::releaseResources()
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
ViewportElement::ViewportElement(Viewport *viewport, int z)
 | 
			
		||||
    : SceneElement(viewport ? *viewport : *gState->screen(), z),
 | 
			
		||||
    : SceneElement(viewport ? *viewport : *shState->screen(), z),
 | 
			
		||||
      m_viewport(viewport)
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
ViewportElement::ViewportElement(Viewport *viewport, int z, unsigned int cStamp)
 | 
			
		||||
    : SceneElement(viewport ? *viewport : *gState->screen(), z, cStamp)
 | 
			
		||||
    : SceneElement(viewport ? *viewport : *shState->screen(), z, cStamp)
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
Viewport *ViewportElement::getViewport() const
 | 
			
		||||
| 
						 | 
				
			
			@ -245,7 +245,7 @@ Viewport *ViewportElement::getViewport() const
 | 
			
		|||
void ViewportElement::setViewport(Viewport *viewport)
 | 
			
		||||
{
 | 
			
		||||
	m_viewport = viewport;
 | 
			
		||||
	setScene(viewport ? *viewport : *gState->screen());
 | 
			
		||||
	setScene(viewport ? *viewport : *shState->screen());
 | 
			
		||||
	onViewportChange();
 | 
			
		||||
	onGeometryChange(scene->getGeometry());
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@
 | 
			
		|||
#include "window.h"
 | 
			
		||||
 | 
			
		||||
#include "viewport.h"
 | 
			
		||||
#include "globalstate.h"
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "bitmap.h"
 | 
			
		||||
#include "etc.h"
 | 
			
		||||
#include "etc-internal.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -271,13 +271,13 @@ struct WindowPrivate
 | 
			
		|||
		cursorVert.count = 9;
 | 
			
		||||
		pauseAniVert.count = 1;
 | 
			
		||||
 | 
			
		||||
		prepareCon = gState->prepareDraw.connect
 | 
			
		||||
		prepareCon = shState->prepareDraw.connect
 | 
			
		||||
		        (sigc::mem_fun(this, &WindowPrivate::prepare));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	~WindowPrivate()
 | 
			
		||||
	{
 | 
			
		||||
		gState->texPool().release(baseTex);
 | 
			
		||||
		shState->texPool().release(baseTex);
 | 
			
		||||
		cursorRectCon.disconnect();
 | 
			
		||||
		prepareCon.disconnect();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -405,8 +405,8 @@ struct WindowPrivate
 | 
			
		|||
		if (!resizeNeeded)
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		gState->texPool().release(baseTex);
 | 
			
		||||
		baseTex = gState->texPool().request(newW, newH);
 | 
			
		||||
		shState->texPool().release(baseTex);
 | 
			
		||||
		baseTex = shState->texPool().request(newW, newH);
 | 
			
		||||
 | 
			
		||||
		baseTexDirty = true;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -422,7 +422,7 @@ struct WindowPrivate
 | 
			
		|||
		glState.viewport.pushSet(IntRect(0, 0, baseTex.width, baseTex.height));
 | 
			
		||||
		glState.clearColor.pushSet(Vec4());
 | 
			
		||||
 | 
			
		||||
		SimpleAlphaShader &shader = gState->simpleAlphaShader();
 | 
			
		||||
		SimpleAlphaShader &shader = shState->simpleAlphaShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.applyViewportProj();
 | 
			
		||||
		shader.setTranslation(Vec2i());
 | 
			
		||||
| 
						 | 
				
			
			@ -560,7 +560,7 @@ struct WindowPrivate
 | 
			
		|||
		Vec2i trans(position.x + sceneOffset.x,
 | 
			
		||||
		            position.y + sceneOffset.y);
 | 
			
		||||
 | 
			
		||||
		SimpleAlphaShader &shader = gState->simpleAlphaShader();
 | 
			
		||||
		SimpleAlphaShader &shader = shState->simpleAlphaShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.applyViewportProj();
 | 
			
		||||
		shader.setTranslation(trans);
 | 
			
		||||
| 
						 | 
				
			
			@ -609,7 +609,7 @@ struct WindowPrivate
 | 
			
		|||
		glState.scissorBox.push();
 | 
			
		||||
		glState.scissorBox.setIntersect(windowRect);
 | 
			
		||||
 | 
			
		||||
		SimpleAlphaShader &shader = gState->simpleAlphaShader();
 | 
			
		||||
		SimpleAlphaShader &shader = shState->simpleAlphaShader();
 | 
			
		||||
		shader.bind();
 | 
			
		||||
		shader.applyViewportProj();
 | 
			
		||||
		shader.setTranslation(Vec2i(effectX, effectY));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue