Ejemplo n.º 1
0
	GraphicsPrivate(RGSSThreadData *rtData)
	    : scRes(DEF_SCREEN_W, DEF_SCREEN_H),
	      scSize(scRes),
	      winSize(rtData->config.defScreenW, rtData->config.defScreenH),
	      screen(scRes.x, scRes.y),
	      threadData(rtData),
	      glCtx(SDL_GL_GetCurrentContext()),
	      frameRate(DEF_FRAMERATE),
	      frameCount(0),
	      brightness(255),
	      fpsLimiter(frameRate),
	      frozen(false)
	{
		recalculateScreenSize(rtData);
		updateScreenResoRatio(rtData);

		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);

		FloatRect screenRect(0, 0, scRes.x, scRes.y);
		screenQuad.setTexPosRect(screenRect, screenRect);

		TEXFBO::init(transBuffer);
		TEXFBO::allocEmpty(transBuffer, scRes.x, scRes.y);
		TEXFBO::linkFBO(transBuffer);

		fpsLimiter.resetFrameAdjust();
		
		const std::string &olImage = rtData->config.touchOverlay.image;
		if (!olImage.empty())
		{
			SDL_RWops *ops = SDL_RWFromFile(olImage.c_str(), "rb");
			SDL_Surface *surf = IMG_Load_RW(ops, 1);

			if (surf)
			{
				overlayTex = TEX::gen();

				TEX::bind(overlayTex);
				TEX::setRepeat(false);
				TEX::setSmooth(true);
				TEX::uploadImage(surf->w, surf->h, surf->pixels, GL_RGBA);

				overlayTexSize = Vec2i(surf->w, surf->h);
			}
			else
			{
				Debug() << "failed to load overlay image:" << SDL_GetError();
			}
		}
	}
Ejemplo n.º 2
0
	void checkSyncLock()
	{
		if (!threadData->syncPoint.mainSyncLocked())
			return;

		/* Releasing the GL context before sleeping and making it
		 * current again on wakeup seems to avoid the context loss
		 * when the app moves into the background on Android */
		SDL_GL_MakeCurrent(threadData->window, 0);
		threadData->syncPoint.waitMainSync();
		SDL_GL_MakeCurrent(threadData->window, glCtx);

		fpsLimiter.resetFrameAdjust();
	}