コード例 #1
0
ファイル: QtHost.cpp プロジェクト: ThomasWDonnelly/ppsspp
void NativeInitGraphics()
{
	gl_lost_manager_init();
	ui_draw2d.SetAtlas(&ui_atlas);

	screenManager = new ScreenManager();
	if (boot_filename.empty()) {
		screenManager->switchScreen(new LogoScreen());
	} else {
		// Go directly into the game.
		screenManager->switchScreen(new EmuScreen(boot_filename));
	}

	UIShader_Init();

	UITheme theme = {0};
	theme.uiFont = UBUNTU24;
	theme.uiFontSmall = UBUNTU24;
	theme.uiFontSmaller = UBUNTU24;
	theme.buttonImage = I_SOLIDWHITE;  // not using classic buttons
	theme.buttonSelected = I_SOLIDWHITE;
	theme.checkOn = I_CHECKEDBOX;
	theme.checkOff = I_SQUARE;

#ifdef _WIN32
	ui_theme.uiFont = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 22);
	ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 15);
	ui_theme.uiFontSmaller = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 12);
#else
	ui_theme.uiFont = UI::FontStyle(UBUNTU24, "", 20);
	ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, "", 14);
	ui_theme.uiFontSmaller = UI::FontStyle(UBUNTU24, "", 11);
#endif
	ui_theme.checkOn = I_CHECKEDBOX;
	ui_theme.checkOff = I_SQUARE;
	ui_theme.whiteImage = I_SOLIDWHITE;
	ui_theme.sliderKnob = I_CIRCLE;
	ui_theme.dropShadow4Grid = I_DROP_SHADOW;

	ui_theme.itemStyle.background = UI::Drawable(0x55000000);
	ui_theme.itemStyle.fgColor = 0xFFFFFFFF;
	ui_theme.itemFocusedStyle.background = UI::Drawable(0xFFedc24c);
	ui_theme.itemDownStyle.background = UI::Drawable(0xFFbd9939);
	ui_theme.itemDownStyle.fgColor = 0xFFFFFFFF;
	ui_theme.itemDisabledStyle.background = UI::Drawable(0x55E0D4AF);
	ui_theme.itemDisabledStyle.fgColor = 0xFFcccccc;

	ui_theme.buttonStyle = ui_theme.itemStyle;
	ui_theme.buttonFocusedStyle = ui_theme.itemFocusedStyle;
	ui_theme.buttonDownStyle = ui_theme.itemDownStyle;
	ui_theme.buttonDisabledStyle = ui_theme.itemDisabledStyle;

	ui_theme.popupTitle.fgColor = 0xFFE3BE59;

	ui_draw2d.Init();
	ui_draw2d_front.Init();

	UIInit(&ui_atlas, theme);

	uiTexture = new Texture();
	if (!uiTexture->Load("ui_atlas.zim"))
	{
		qDebug() << "Failed to load texture";
	}
	uiTexture->Bind(0);

	uiContext = new UIContext();
	uiContext->theme = &ui_theme;
	uiContext->Init(UIShader_Get(), UIShader_GetPlain(), uiTexture, &ui_draw2d, &ui_draw2d_front);

	screenManager->setUIContext(uiContext);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	glstate.viewport.set(0, 0, pixel_xres, pixel_yres);
}
コード例 #2
0
ファイル: MenuScreens.cpp プロジェクト: cemedine/ppsspp
void LanguageScreen::render() {
	UIShader_Prepare();
	UIBegin(UIShader_Get());
	DrawBackground(1.0f);

	I18NCategory *s = GetI18NCategory("System");
	I18NCategory *g = GetI18NCategory("General");
	I18NCategory *l = GetI18NCategory("Language");

	ui_draw2d.SetFontScale(1.5f, 1.5f);
	ui_draw2d.DrawText(UBUNTU24, s->T("Language"), dp_xres / 2, 20, 0xFFFFFFFF, ALIGN_HCENTER);
	ui_draw2d.SetFontScale(1.0f, 1.0f);

	if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres-10), LARGE_BUTTON_WIDTH, 0, g->T("Back"), ALIGN_RIGHT | ALIGN_BOTTOM)) {
		screenManager()->finishDialog(this, DR_OK);
	}

	VGrid vlang(50, 100, dp_yres - 50, 10, 10);
	std::string text;
	
	for (size_t i = 0; i < langs_.size(); i++) {
		std::string code;
		size_t dot = langs_[i].name.find('.');
		if (dot != std::string::npos)
			code = langs_[i].name.substr(0, dot);

		std::string buttonTitle = langs_[i].name;

		langValuesMapping["ja_JP"] = std::make_pair("日本語", PSP_SYSTEMPARAM_LANGUAGE_JAPANESE);
		langValuesMapping["en_US"] = std::make_pair("English",PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
		langValuesMapping["fr_FR"] = std::make_pair("Français", PSP_SYSTEMPARAM_LANGUAGE_FRENCH);
		langValuesMapping["es_ES"] = std::make_pair("Español", PSP_SYSTEMPARAM_LANGUAGE_SPANISH);
		langValuesMapping["es_LA"] = std::make_pair("Español", PSP_SYSTEMPARAM_LANGUAGE_SPANISH);
		langValuesMapping["de_DE"] = std::make_pair("Deutsch", PSP_SYSTEMPARAM_LANGUAGE_GERMAN);
		langValuesMapping["it_IT"] = std::make_pair("Italiano", PSP_SYSTEMPARAM_LANGUAGE_ITALIAN); 
		langValuesMapping["nl_NL"] = std::make_pair("Nederlands", PSP_SYSTEMPARAM_LANGUAGE_DUTCH);
		langValuesMapping["pt_PT"] = std::make_pair("Português", PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE);
		langValuesMapping["pt_BR"] = std::make_pair("Português", PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE);
		langValuesMapping["ru_RU"] = std::make_pair("Русский", PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN);
		langValuesMapping["ko_KR"] = std::make_pair("한국어", PSP_SYSTEMPARAM_LANGUAGE_KOREAN);
		langValuesMapping["zh_TW"] = std::make_pair("繁體中文", PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL);
		langValuesMapping["zh_CN"] = std::make_pair("简体中文", PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED);
		langValuesMapping["gr_EL"] = std::make_pair("ελληνικά", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
		langValuesMapping["he_IL"] = std::make_pair("עברית", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
		langValuesMapping["hu_HU"] = std::make_pair("Magyar", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
		langValuesMapping["pl_PL"] = std::make_pair("Polski", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
		langValuesMapping["sv_SE"] = std::make_pair("Svenska", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
		langValuesMapping["tr_TR"] = std::make_pair("Türk", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
		langValuesMapping["ca_ES"] = std::make_pair("Català", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
		langValuesMapping["uk_UA"] = std::make_pair("Українська", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
		langValuesMapping["ro_RO"] = std::make_pair("Român", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);

		if (!code.empty()) {
			if(langValuesMapping.find(code) == langValuesMapping.end()) {
				//No title found, show locale code
				buttonTitle = code;
			} else {
				buttonTitle = langValuesMapping[code].first;
			}
		}

		if (UIButton(GEN_ID_LOOP(i), vlang, LARGE_BUTTON_WIDTH - 30, 0, buttonTitle.c_str(), ALIGN_TOPLEFT)) {
			std::string oldLang = g_Config.languageIni;
			g_Config.languageIni = code;

			if (i18nrepo.LoadIni(g_Config.languageIni)) {
				// Dunno what else to do here.

				if(langValuesMapping.find(code) == langValuesMapping.end()) {
					//Fallback to English
					g_Config.ilanguage = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
				} else {
					g_Config.ilanguage = langValuesMapping[code].second;
				}

				// After this, g and s are no longer valid. Let's return, some flicker is okay.
				g = GetI18NCategory("General");
				s = GetI18NCategory("System");
				l = GetI18NCategory("Language");
			} else {
				g_Config.languageIni = oldLang;
			}
		}
	}
	UIEnd();
}
コード例 #3
0
ファイル: MenuScreens.cpp プロジェクト: codernxtdoor/ppsspp
void MenuScreen::render() {
	UIShader_Prepare();
	UIBegin();
	DrawBackground(1.0f);

	double xoff = 150 - frames_ * frames_ * 0.4f;
	if (xoff < -20)
		xoff = -20;
	if (frames_ > 200)  // seems the above goes nuts after a while...
		xoff = -20;

	int w = LARGE_BUTTON_WIDTH + 40;

	ui_draw2d.DrawTextShadow(UBUNTU48, "PPSSPP", dp_xres + xoff - w/2, 80, 0xFFFFFFFF, ALIGN_HCENTER | ALIGN_BOTTOM);
	ui_draw2d.SetFontScale(0.7f, 0.7f);
	ui_draw2d.DrawTextShadow(UBUNTU24, PPSSPP_VERSION_STR, dp_xres + xoff, 80, 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_BOTTOM);
	ui_draw2d.SetFontScale(1.0f, 1.0f);
	VLinear vlinear(dp_xres + xoff, 95, 20);

	if (UIButton(GEN_ID, vlinear, w, "Load...", ALIGN_RIGHT)) {
#if defined(USING_QT_UI)
		QString fileName = QFileDialog::getOpenFileName(NULL, "Load ROM", g_Config.currentDirectory.c_str(), "PSP ROMs (*.iso *.cso *.pbp *.elf)");
		if (QFile::exists(fileName)) {
			QDir newPath;
			g_Config.currentDirectory = newPath.filePath(fileName).toStdString();
			g_Config.Save();
			screenManager()->switchScreen(new EmuScreen(fileName.toStdString()));
		}
#else
		FileSelectScreenOptions options;
		options.allowChooseDirectory = true;
		options.filter = "iso:cso:pbp:elf:prx:";
		options.folderIcon = I_ICON_FOLDER;
		options.iconMapping["iso"] = I_ICON_UMD;
		options.iconMapping["cso"] = I_ICON_UMD;
		options.iconMapping["pbp"] = I_ICON_EXE;
		options.iconMapping["elf"] = I_ICON_EXE;
		screenManager()->switchScreen(new FileSelectScreen(options));
#endif
		UIReset();
	}

	if (UIButton(GEN_ID, vlinear, w, "Settings", ALIGN_RIGHT)) {
		screenManager()->switchScreen(new SettingsScreen());
		UIReset();
	}

	if (UIButton(GEN_ID, vlinear, w, "Credits", ALIGN_RIGHT)) {
		screenManager()->switchScreen(new CreditsScreen());
		UIReset();
	}

	if (UIButton(GEN_ID, vlinear, w, "Exit", ALIGN_RIGHT)) {
		// TODO: Save when setting changes, rather than when we quit
		NativeShutdown();
		// TODO: Need a more elegant way to quit
		exit(0);
	}

	if (UIButton(GEN_ID, vlinear, w, "www.ppsspp.org", ALIGN_RIGHT)) {
		LaunchBrowser("http://www.ppsspp.org/");
	}

	DrawWatermark();

	UIEnd();

	glsl_bind(UIShader_Get());
	ui_draw2d.Flush(UIShader_Get());
}
コード例 #4
0
ファイル: MenuScreens.cpp プロジェクト: cemedine/ppsspp
void PauseScreen::render() {
	UIShader_Prepare();
	UIBegin(UIShader_Get());
	DrawBackground(1.0f);

	std::string title = game_title.c_str();
	// Try to ignore (tm) etc.
	//if (UTF8StringNonASCIICount(game_title.c_str()) > 2) {
	//	title = "(can't display japanese title)";
	//} else {
	//}


	UIContext *ctx = screenManager()->getUIContext();
	// This might create a texture so we must flush first.
	UIFlush();
	GameInfo *ginfo = g_gameInfoCache.GetInfo(PSP_CoreParameter().fileToStart, true);

	if (ginfo) {
		title = ginfo->title;
	}

	if (ginfo && ginfo->pic1Texture) {
		ginfo->pic1Texture->Bind(0);
		uint32_t color = whiteAlpha(ease((time_now_d() - ginfo->timePic1WasLoaded) * 3)) & 0xFFc0c0c0;
		ui_draw2d.DrawTexRect(0,0,dp_xres, dp_yres, 0,0,1,1,color);
		ui_draw2d.Flush();
		ctx->RebindTexture();
	}

	if (ginfo && ginfo->pic0Texture) {
		ginfo->pic0Texture->Bind(0);
		// Pic0 is drawn in the bottom right corner, overlaying pic1.
		float sizeX = dp_xres / 480 * ginfo->pic0Texture->Width();
		float sizeY = dp_yres / 272 * ginfo->pic0Texture->Height();
		uint32_t color = whiteAlpha(ease((time_now_d() - ginfo->timePic1WasLoaded) * 2)) & 0xFFc0c0c0;
		ui_draw2d.DrawTexRect(dp_xres - sizeX, dp_yres - sizeY, dp_xres, dp_yres, 0,0,1,1,color);
		ui_draw2d.Flush();
		ctx->RebindTexture();
	}

	if (ginfo && ginfo->iconTexture) {
		uint32_t color = whiteAlpha(ease((time_now_d() - ginfo->timeIconWasLoaded) * 1.5));
		ginfo->iconTexture->Bind(0);

		// Maintain the icon's aspect ratio.  Minis are square, for example.
		float iconAspect = (float)ginfo->iconTexture->Width() / (float)ginfo->iconTexture->Height();
		float h = 80.0f;
		float w = 144.0f;
		float x = 10.0f + (w - h * iconAspect) / 2.0f;
		w = h * iconAspect;

		ui_draw2d.DrawTexRect(x, 10, x + w, 10 + h, 0, 0, 1, 1, 0xFFFFFFFF);
		ui_draw2d.Flush();
		ctx->RebindTexture();
	}

	ui_draw2d.DrawText(UBUNTU24, title.c_str(), 10+144+10, 30, 0xFFFFFFFF, ALIGN_LEFT);

	int x = 30;
	int y = 50;
	int stride = 40;
	int columnw = 400;

	// Shared with settings
	I18NCategory *ss = GetI18NCategory("System");
	I18NCategory *gs = GetI18NCategory("Graphics");
	I18NCategory *a = GetI18NCategory("Audio");
	
	UICheckBox(GEN_ID, x, y += stride, ss->T("Show FPS"), ALIGN_TOPLEFT, &g_Config.bShowFPSCounter);
	UICheckBox(GEN_ID, x, y += stride, a->T("Enable Sound"), ALIGN_TOPLEFT, &g_Config.bEnableSound);
	// TODO: Maybe shouldn't show this if the screen ratios are very close...
	UICheckBox(GEN_ID, x, y += stride, gs->T("Stretch to Display"), ALIGN_TOPLEFT, &g_Config.bStretchToDisplay);

	UICheckBox(GEN_ID, x, y += stride, gs->T("Hardware Transform"), ALIGN_TOPLEFT, &g_Config.bHardwareTransform);
	if (UICheckBox(GEN_ID, x, y += stride, gs->T("Buffered Rendering"), ALIGN_TOPLEFT, &g_Config.bBufferedRendering)) {
		if (gpu)
			gpu->Resized();
	}
	UICheckBox(GEN_ID, x, y += stride, gs->T("Media Engine"), ALIGN_TOPLEFT, &g_Config.bUseMediaEngine);
	bool enableFrameSkip = g_Config.iFrameSkip != 0;
	UICheckBox(GEN_ID, x, y += stride, gs->T("Frame Skipping"), ALIGN_TOPLEFT, &enableFrameSkip);
	if (enableFrameSkip) {
		if (g_Config.iFrameSkip == 0)
			g_Config.iFrameSkip = 3;

		ui_draw2d.DrawText(UBUNTU24, gs->T("Frames :"), x + 60, y += stride, 0xFFFFFFFF, ALIGN_LEFT);
		HLinear hlinear1(x + 200 , y + 5, 20);
		if (UIButton(GEN_ID, hlinear1, 80, 0, "Auto", ALIGN_LEFT))
			g_Config.iFrameSkip = 3;
		if (UIButton(GEN_ID, hlinear1, 30, 0, "1", ALIGN_LEFT))
			g_Config.iFrameSkip = 1;
		if (UIButton(GEN_ID, hlinear1, 30, 0, "2", ALIGN_LEFT))
			g_Config.iFrameSkip = 2;
	}
	else {
		g_Config.iFrameSkip = 0;
	}

	I18NCategory *i = GetI18NCategory("Pause");

	// TODO: Add UI for more than one slot.
	HLinear hlinear1(x, y + 80, 20);
	if (UIButton(GEN_ID, hlinear1, LARGE_BUTTON_WIDTH, 0, i->T("Save State"), ALIGN_LEFT)) {
		SaveState::SaveSlot(0, 0, 0);
		screenManager()->finishDialog(this, DR_CANCEL);
	}
	if (UIButton(GEN_ID, hlinear1, LARGE_BUTTON_WIDTH, 0, i->T("Load State"), ALIGN_LEFT)) {
		SaveState::LoadSlot(0, 0, 0);
		screenManager()->finishDialog(this, DR_CANCEL);
	}

	VLinear vlinear(dp_xres - 10, 160, 20);
	if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH + 20, 0, i->T("Continue"), ALIGN_RIGHT)) {
		screenManager()->finishDialog(this, DR_CANCEL);
	}

	if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH + 20, 0, i->T("Settings"), ALIGN_RIGHT)) {
		screenManager()->push(new SettingsScreen(), 0);
	}

	if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH + 20, 0, i->T("Back to Menu"), ALIGN_RIGHT)) {
		screenManager()->finishDialog(this, DR_OK);
	}

	/*
	if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres - 10), LARGE_BUTTON_WIDTH*2, 0, "Debug: Dump Next Frame", ALIGN_BOTTOMRIGHT)) {
		gpu->DumpNextFrame();
	}
	*/

	DrawWatermark();
	UIEnd();
}
コード例 #5
0
ファイル: MenuScreens.cpp プロジェクト: cemedine/ppsspp
void GraphicsScreenP2::render() {
	UIShader_Prepare();
	UIBegin(UIShader_Get());
	DrawBackground(1.0f);

	I18NCategory *g = GetI18NCategory("General");
	I18NCategory *gs = GetI18NCategory("Graphics");

	ui_draw2d.SetFontScale(1.5f, 1.5f);
	ui_draw2d.DrawText(UBUNTU24, gs->T("Graphics Settings"), dp_xres / 2, 20, 0xFFFFFFFF, ALIGN_HCENTER);
	ui_draw2d.SetFontScale(1.0f, 1.0f);

	if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres - 10), LARGE_BUTTON_WIDTH, 0, g->T("Back"), ALIGN_RIGHT | ALIGN_BOTTOM)) {
		screenManager()->finishDialog(this, DR_OK);
	}

	int x = 30;
	int y = 30;
	int stride = 40;
	int columnw = 400;

	if (g_Config.bBufferedRendering) {
		if (UICheckBox(GEN_ID, x, y += stride, gs->T("AA", "Anti Aliasing"), ALIGN_TOPLEFT, &g_Config.SSAntiAliasing)) {
			if (gpu)
				gpu->Resized();
		}
	}
	UICheckBox(GEN_ID, x, y += stride, gs->T("Draw Wireframe"), ALIGN_TOPLEFT, &g_Config.bDrawWireframe);
	UICheckBox(GEN_ID, x, y += stride, gs->T("Display Raw Framebuffer"), ALIGN_TOPLEFT, &g_Config.bDisplayFramebuffer);
	UICheckBox(GEN_ID, x, y += stride, gs->T("True Color"), ALIGN_TOPLEFT, &g_Config.bTrueColor);

	bool AnisotropicFiltering = g_Config.iAnisotropyLevel != 0;
	UICheckBox(GEN_ID, x, y += stride, gs->T("Anisotropic Filtering"), ALIGN_TOPLEFT, &AnisotropicFiltering);
	if (AnisotropicFiltering) {
		if (g_Config.iAnisotropyLevel == 0)
			g_Config.iAnisotropyLevel = 2;

		ui_draw2d.DrawText(UBUNTU24, gs->T("Level :"), x + 60, y += stride - 5, 0xFFFFFFFF, ALIGN_LEFT);
		HLinear hlinear1(x + 160 , y + 5, 20);
		if (UIButton(GEN_ID, hlinear1, 45, 0, "2x", ALIGN_LEFT))
			g_Config.iAnisotropyLevel = 2;
		if (UIButton(GEN_ID, hlinear1, 45, 0, "4x", ALIGN_LEFT))
			g_Config.iAnisotropyLevel = 4;
		if (UIButton(GEN_ID, hlinear1, 45, 0, "8x", ALIGN_LEFT))
			g_Config.iAnisotropyLevel = 8;
		if (UIButton(GEN_ID, hlinear1, 60, 0, "16x", ALIGN_LEFT))
			g_Config.iAnisotropyLevel = 16;
	} else {
		g_Config.iAnisotropyLevel = 0;
	}

	bool TexScaling = g_Config.iTexScalingLevel > 1;
	UICheckBox(GEN_ID, x, y += stride + 20, gs->T("xBRZ Texture Scaling"), ALIGN_TOPLEFT, &TexScaling);
	if (TexScaling) {
		if (g_Config.iTexScalingLevel <= 1)
			g_Config.iTexScalingLevel = 2;

		ui_draw2d.DrawText(UBUNTU24, gs->T("Level :"), x + 60, y += stride + 5, 0xFFFFFFFF, ALIGN_LEFT);
		HLinear hlinear1(x + 160 , y - 5, 20);
		if (UIButton(GEN_ID, hlinear1, 45, 0, "2x", ALIGN_LEFT))
			g_Config.iTexScalingLevel = 2;
		if (UIButton(GEN_ID, hlinear1, 45, 0, "3x", ALIGN_LEFT))
			g_Config.iTexScalingLevel = 3;
		HLinear hlinear2(x + 160 , y + 60, 20);
		ui_draw2d.DrawText(UBUNTU24, gs->T("Type  :"), x + 60, y += stride + 20, 0xFFFFFFFF, ALIGN_LEFT);
		if (UIButton(GEN_ID, hlinear2, 90, 0, "xBRZ", ALIGN_LEFT))
			g_Config.iTexScalingType = 0;
		if (UIButton(GEN_ID, hlinear2, 100, 0, "Hybrid", ALIGN_LEFT))
			g_Config.iTexScalingType = 1;
	} else {
		g_Config.iTexScalingLevel = 1;
	}
	UIEnd();
}
コード例 #6
0
ファイル: EmuScreen.cpp プロジェクト: Carter07/ppsspp
void EmuScreen::render() {
	if (invalid_)
		return;

	// Reapply the graphics state of the PSP
	ReapplyGfxState();

	// We just run the CPU until we get to vblank. This will quickly sync up pretty nicely.
	// The actual number of cycles doesn't matter so much here as we will break due to CORE_NEXTFRAME, most of the time hopefully...
	int blockTicks = usToCycles(1000000 / 10);

	// Run until CORE_NEXTFRAME
	while (coreState == CORE_RUNNING) {
		PSP_RunLoopFor(blockTicks);
	}
	// Hopefully coreState is now CORE_NEXTFRAME
	if (coreState == CORE_NEXTFRAME) {
		// set back to running for the next frame
		coreState = CORE_RUNNING;
	} else if (coreState == CORE_POWERDOWN)	{
		ILOG("SELF-POWERDOWN!");
		screenManager()->switchScreen(new MainScreen());
		invalid_ = true;
	}

	if (invalid_)
		return;

	bool useBufferedRendering = g_Config.iRenderingMode != 0 ? 1 : 0;
	if (useBufferedRendering)
		fbo_unbind();

	UIShader_Prepare();

	uiTexture->Bind(0);

	glstate.viewport.set(0, 0, pixel_xres, pixel_yres);
	glstate.viewport.restore();

	ui_draw2d.Begin(UIShader_Get(), DBMODE_NORMAL);

	float touchOpacity = g_Config.iTouchButtonOpacity / 100.0f;

	if (root_) {
		UI::LayoutViewHierarchy(*screenManager()->getUIContext(), root_);
		root_->Draw(*screenManager()->getUIContext());
	}

	if (!osm.IsEmpty()) {
		osm.Draw(ui_draw2d);
	}

	if (g_Config.bShowDebugStats) {
		char statbuf[4096] = {0};
		__DisplayGetDebugStats(statbuf);
		if (statbuf[4095]) {
			ELOG("Statbuf too small! :(");
		}
		ui_draw2d.SetFontScale(.7f, .7f);
		ui_draw2d.DrawText(UBUNTU24, statbuf, 11, 11, 0xc0000000, FLAG_DYNAMIC_ASCII);
		ui_draw2d.DrawText(UBUNTU24, statbuf, 10, 10, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
		ui_draw2d.SetFontScale(1.0f, 1.0f);
	}

	if (g_Config.iShowFPSCounter) {
		float vps, fps, actual_fps;
		__DisplayGetFPS(&vps, &fps, &actual_fps);
		char fpsbuf[256];
		switch (g_Config.iShowFPSCounter) {
		case 1:
			sprintf(fpsbuf, "Speed: %0.1f%%", vps / 60.0f * 100.0f); break;
		case 2:
			sprintf(fpsbuf, "FPS: %0.1f", actual_fps); break;
		case 3:
			sprintf(fpsbuf, "%0.0f/%0.0f (%0.1f%%)", actual_fps, fps, vps / 60.0f * 100.0f); break;
		}
		ui_draw2d.SetFontScale(0.7f, 0.7f);
		ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 8, 12, 0xc0000000, ALIGN_TOPRIGHT | FLAG_DYNAMIC_ASCII);
		ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 10, 10, 0xFF3fFF3f, ALIGN_TOPRIGHT | FLAG_DYNAMIC_ASCII);
		ui_draw2d.SetFontScale(1.0f, 1.0f);
	}
	
	glsl_bind(UIShader_Get());
	ui_draw2d.End();
	ui_draw2d.Flush();

	// Tiled renderers like PowerVR should benefit greatly from this. However - seems I can't call it?
#if defined(USING_GLES2)
	bool hasDiscard = gl_extensions.EXT_discard_framebuffer;  // TODO
	if (hasDiscard) {
		//const GLenum targets[3] = { GL_COLOR_EXT, GL_DEPTH_EXT, GL_STENCIL_EXT };
		//glDiscardFramebufferEXT(GL_FRAMEBUFFER, 3, targets);
	}
#endif
}
コード例 #7
0
ファイル: MenuScreens.cpp プロジェクト: cemedine/ppsspp
void MenuScreen::render() {
	UIShader_Prepare();
	UIBegin(UIShader_Get());
	DrawBackground(1.0f);

	double xoff = 150 - frames_ * frames_ * 0.4f;
	if (xoff < -20)
		xoff = -20;
	if (frames_ > 200)  // seems the above goes nuts after a while...
		xoff = -20;

	int w = LARGE_BUTTON_WIDTH + 60;

	ui_draw2d.DrawTextShadow(UBUNTU48, "PPSSPP", dp_xres + xoff - w/2, 75, 0xFFFFFFFF, ALIGN_HCENTER | ALIGN_BOTTOM);
	ui_draw2d.SetFontScale(0.7f, 0.7f);
	ui_draw2d.DrawTextShadow(UBUNTU24, PPSSPP_GIT_VERSION, dp_xres + xoff, 85, 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_BOTTOM);
	ui_draw2d.SetFontScale(1.0f, 1.0f);
	VLinear vlinear(dp_xres + xoff, 100, 20);

	I18NCategory *m = GetI18NCategory("MainMenu");

	if (UIButton(GEN_ID, vlinear, w, 0, m->T("Load", "Load..."), ALIGN_RIGHT)) {
#if defined(USING_QT_UI) && !defined(MEEGO_EDITION_HARMATTAN)
		QString fileName = QFileDialog::getOpenFileName(NULL, "Load ROM", g_Config.currentDirectory.c_str(), "PSP ROMs (*.iso *.cso *.pbp *.elf)");
		if (QFile::exists(fileName)) {
			QDir newPath;
			g_Config.currentDirectory = newPath.filePath(fileName).toStdString();
			g_Config.Save();
			screenManager()->switchScreen(new EmuScreen(fileName.toStdString()));
		}
#elif _WIN32
		MainWindow::BrowseAndBoot("");
#else
		FileSelectScreenOptions options;
		options.allowChooseDirectory = true;
		options.filter = "iso:cso:pbp:elf:prx:";
		options.folderIcon = I_ICON_FOLDER;
		options.iconMapping["iso"] = I_ICON_UMD;
		options.iconMapping["cso"] = I_ICON_UMD;
		options.iconMapping["pbp"] = I_ICON_EXE;
		options.iconMapping["elf"] = I_ICON_EXE;
		screenManager()->switchScreen(new FileSelectScreen(options));
#endif
		UIReset();
	}

	if (UIButton(GEN_ID, vlinear, w, 0, m->T("Settings"), ALIGN_RIGHT)) {
		screenManager()->push(new SettingsScreen(), 0);
		UIReset();
	}

	if (UIButton(GEN_ID, vlinear, w, 0, m->T("Credits"), ALIGN_RIGHT)) {
		screenManager()->switchScreen(new CreditsScreen());
		UIReset();
	}

	if (UIButton(GEN_ID, vlinear, w, 0, m->T("Exit"), ALIGN_RIGHT)) {
		// TODO: Save when setting changes, rather than when we quit
		NativeShutdown();
		// TODO: Need a more elegant way to quit
#ifdef _WIN32
		ExitProcess(0);
#else
		exit(0);
#endif
	}

	if (UIButton(GEN_ID, vlinear, w, 0, "www.ppsspp.org", ALIGN_RIGHT)) {
		LaunchBrowser("http://www.ppsspp.org/");
	}

	int recentW = 350;
	if (g_Config.recentIsos.size()) {
		ui_draw2d.DrawText(UBUNTU24, m->T("Recent"), -xoff, 80, 0xFFFFFFFF, ALIGN_BOTTOMLEFT);
	}

	int spacing = 15;

	float textureButtonWidth = 144;
	float textureButtonHeight = 80;

	if (dp_yres < 480)
		spacing = 8;
	// On small screens, we can't fit four vertically.
	if (100 + spacing * 6 + textureButtonHeight * 4 > dp_yres) {
		textureButtonHeight = (dp_yres - 100 - spacing * 6) / 4;
		textureButtonWidth = (textureButtonHeight / 80) * 144;
	}

	VGrid vgrid_recent(-xoff, 100, std::min(dp_yres-spacing*2, 480), spacing, spacing);

	for (size_t i = 0; i < g_Config.recentIsos.size(); i++) {
		std::string filename;
		std::string rec = g_Config.recentIsos[i];
		for (size_t j = 0; j < rec.size(); j++)
			if (rec[j] == '\\') rec[j] = '/';
		SplitPath(rec, nullptr, &filename, nullptr);

		UIContext *ctx = screenManager()->getUIContext();
		// This might create a texture so we must flush first.
		UIFlush();
		GameInfo *ginfo = g_gameInfoCache.GetInfo(g_Config.recentIsos[i], false);
		if (ginfo && ginfo->fileType != FILETYPE_PSP_ELF) {
			u32 color;
			if (ginfo->iconTexture == 0) {
				color = 0;
			} else {
				color = whiteAlpha(ease((time_now_d() - ginfo->timeIconWasLoaded) * 2));
			}
			if (UITextureButton(ctx, (int)GEN_ID_LOOP(i), vgrid_recent, textureButtonWidth, textureButtonHeight, ginfo->iconTexture, ALIGN_LEFT, color, I_DROP_SHADOW)) {
				UIEnd();
				screenManager()->switchScreen(new EmuScreen(g_Config.recentIsos[i]));
				return;
			}
		} else {
			if (UIButton((int)GEN_ID_LOOP(i), vgrid_recent, textureButtonWidth, textureButtonHeight, filename.c_str(), ALIGN_LEFT)) {
				UIEnd();
				screenManager()->switchScreen(new EmuScreen(g_Config.recentIsos[i]));
				return;
			}
		}
	}

#if defined(_DEBUG) & defined(_WIN32)
	// Print the current dp_xres/yres in the corner. For UI scaling testing - just
	// resize to 800x480 to get an idea of what it will look like on a Nexus S.
	ui_draw2d.SetFontScale(0.4, 0.4);
	char temptext[64];
	sprintf(temptext, "%ix%i", dp_xres, dp_yres);
	ui_draw2d.DrawTextShadow(UBUNTU24, temptext, 5, dp_yres-5, 0xFFFFFFFF, ALIGN_BOTTOMLEFT);
	ui_draw2d.SetFontScale(1.0, 1.0);
#endif

	DrawWatermark();

	UIEnd();
}
コード例 #8
0
ファイル: EmuThread.cpp プロジェクト: ImandaSyachrul/ppsspp
void EmuThread::run()
{
	running = true;
	setCurrentThreadName("EmuThread");

	host->UpdateUI();
	host->InitGL(0);

	EmuThread_LockDraw(true);

#ifndef USING_GLES2
	glewInit();
#endif
	NativeInitGraphics();

	INFO_LOG(BOOT, "Starting up hardware.");

	QElapsedTimer timer;

	EmuThread_LockDraw(false);

	while(running) {
		//UpdateGamepad(*input_state);
		timer.start();

		gameMutex->lock();
		bool gRun = gameRunning;
		gameMutex->unlock();

		if(gRun)
		{
			EmuThread_LockDraw(true);
			if(needInitGame)
			{
				CoreParameter coreParameter;
				coreParameter.fileToStart = fileToStart.toStdString();
				coreParameter.enableSound = true;
				coreParameter.gpuCore = GPU_GLES;
				coreParameter.cpuCore = g_Config.bJit ? CPU_JIT : CPU_INTERPRETER;
				coreParameter.enableDebugging = true;
				coreParameter.printfEmuLog = false;
				coreParameter.headLess = false;
				coreParameter.renderWidth = (480 * g_Config.iWindowZoom) * (g_Config.SSAntiAliasing + 1);
				coreParameter.renderHeight = (272 * g_Config.iWindowZoom) * (g_Config.SSAntiAliasing + 1);
				coreParameter.outputWidth = dp_xres;
				coreParameter.outputHeight = dp_yres;
				coreParameter.pixelWidth = pixel_xres;
				coreParameter.pixelHeight = pixel_yres;
				coreParameter.startPaused = !g_Config.bAutoRun;

				std::string error_string;
				if (!PSP_Init(coreParameter, &error_string))
				{
					ERROR_LOG(BOOT, "Error loading: %s", error_string.c_str());
					FinalShutdown();
					return;
				}

				LayoutGamepad(dp_xres, dp_yres);

				_dbg_update_();

				host->UpdateDisassembly();
				Core_EnableStepping(coreParameter.startPaused ? TRUE : FALSE);

				globalUIState = coreParameter.startPaused ? UISTATE_PAUSEMENU : UISTATE_INGAME;
			#ifdef _DEBUG
				host->UpdateMemView();
			#endif
				host->BootDone();
				needInitGame = false;
			}

			glstate.Restore();
			glViewport(0, 0, pixel_xres, pixel_yres);
			Matrix4x4 ortho;
			ortho.setOrtho(0.0f, dp_xres, dp_yres, 0.0f, -1.0f, 1.0f);
			glsl_bind(UIShader_Get());
			glUniformMatrix4fv(UIShader_Get()->u_worldviewproj, 1, GL_FALSE, ortho.getReadPtr());


			ReapplyGfxState();

			Core_Run();

			// Hopefully coreState is now CORE_NEXTFRAME
			if (coreState == CORE_NEXTFRAME) {
				// set back to running for the next frame
				coreState = CORE_RUNNING;

				qint64 time = timer.elapsed();
				const int frameTime = (1.0f/60.0f) * 1000;
				if(time < frameTime)
				{
					EmuThread_LockDraw(false);
					msleep(frameTime-time);
					EmuThread_LockDraw(true);
				}
				timer.start();
			}

			fbo_unbind();

			UIShader_Prepare();

			uiTexture->Bind(0);

			glViewport(0, 0, pixel_xres, pixel_yres);

			ui_draw2d.Begin(UIShader_Get(), DBMODE_NORMAL);

			//if (g_Config.bShowTouchControls)
			//	DrawGamepad(ui_draw2d);

			glsl_bind(UIShader_Get());
			ui_draw2d.End();
			ui_draw2d.Flush();


			// Tiled renderers like PowerVR should benefit greatly from this. However - seems I can't call it?
#if defined(USING_GLES2)
			bool hasDiscard = false;  // TODO
			if (hasDiscard) {
				//glDiscardFramebuffer(GL_COLOR_EXT | GL_DEPTH_EXT | GL_STENCIL_EXT);
			}
#endif
			glWindow->swapBuffers();
			EmuThread_LockDraw(false);
		}
		else
		{
			EmuThread_LockDraw(true);
			glClearColor(0, 0, 0, 0);
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

			time_update();
			float t = (float)frames_ / 60.0f;
			frames_++;

			float alpha = t;
			if (t > 1.0f) alpha = 1.0f;
			float alphaText = alpha;
			//if (t > 2.0f) alphaText = 3.0f - t;

			glstate.Restore();
			glViewport(0, 0, pixel_xres, pixel_yres);
			Matrix4x4 ortho;
			ortho.setOrtho(0.0f, dp_xres, dp_yres, 0.0f, -1.0f, 1.0f);
			glsl_bind(UIShader_Get());
			glUniformMatrix4fv(UIShader_Get()->u_worldviewproj, 1, GL_FALSE, ortho.getReadPtr());


			ReapplyGfxState();

			UIShader_Prepare();
			glViewport(0, 0, pixel_xres, pixel_yres);
			UIBegin(UIShader_Get());
			DrawBackground(alpha);

			ui_draw2d.SetFontScale(1.5f, 1.5f);
			ui_draw2d.DrawText(UBUNTU48, "PPSSPP", dp_xres / 2, dp_yres / 2 - 30, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
			ui_draw2d.SetFontScale(1.0f, 1.0f);
			ui_draw2d.DrawText(UBUNTU24, "Created by Henrik Rydgard", dp_xres / 2, dp_yres / 2 + 40, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
			ui_draw2d.DrawText(UBUNTU24, "Free Software under GPL 2.0", dp_xres / 2, dp_yres / 2 + 70, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
			ui_draw2d.DrawText(UBUNTU24, "www.ppsspp.org", dp_xres / 2, dp_yres / 2 + 130, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);

			UIEnd();
			globalUIState = UISTATE_MENU;

			glsl_bind(UIShader_Get());
			ui_draw2d.Flush();

			glWindow->swapBuffers();
			EmuThread_LockDraw(false);
			qint64 time = timer.elapsed();
			const int frameTime = (1.0f/60.0f) * 1000;
			if(time < frameTime)
			{
				msleep(frameTime-time);
			}
			timer.start();
		}

	}

	if(gameRunning)
	{
		stopGame();
	}

}
コード例 #9
0
ファイル: NativeApp.cpp プロジェクト: arg274/ppsspp
void NativeInitGraphics() {
	CheckGLExtensions();
	gl_lost_manager_init();
	ui_draw2d.SetAtlas(&ui_atlas);
	ui_draw2d_front.SetAtlas(&ui_atlas);

	UIShader_Init();

	// memset(&ui_theme, 0, sizeof(ui_theme));
	// New style theme
#ifdef _WIN32
	ui_theme.uiFont = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 22);
	ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 15);
	ui_theme.uiFontSmaller = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 12);
#else
	ui_theme.uiFont = UI::FontStyle(UBUNTU24, "", 20);
	ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, "", 14);
	ui_theme.uiFontSmaller = UI::FontStyle(UBUNTU24, "", 11);
#endif

	ui_theme.checkOn = I_CHECKEDBOX;
	ui_theme.checkOff = I_SQUARE;
	ui_theme.whiteImage = I_SOLIDWHITE;
	ui_theme.sliderKnob = I_CIRCLE;
	ui_theme.dropShadow4Grid = I_DROP_SHADOW;

	/*
	ui_theme.buttonStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON);
	ui_theme.buttonStyle.fgColor = 0xFFFFFFFF;
	ui_theme.buttonStyle.image = I_BUTTON;
	ui_theme.buttonFocusedStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON, 0xFFe0e0e0);
	ui_theme.buttonFocusedStyle.fgColor = 0xFFFFFFFF;
	ui_theme.buttonDownStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON_SELECTED, 0xFFFFFFFF);
	ui_theme.buttonDownStyle.fgColor = 0xFFFFFFFF;
	ui_theme.buttonDisabledStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON, 0xFF404040);
	ui_theme.buttonDisabledStyle.fgColor = 0xFF707070;
	*/

	ui_theme.itemStyle.background = UI::Drawable(0x55000000);
	ui_theme.itemStyle.fgColor = 0xFFFFFFFF;
	ui_theme.itemFocusedStyle.background = UI::Drawable(0xFFedc24c);
	ui_theme.itemDownStyle.background = UI::Drawable(0xFFbd9939);
	ui_theme.itemDownStyle.fgColor = 0xFFFFFFFF;
	ui_theme.itemDisabledStyle.background = UI::Drawable(0x55E0D4AF);
	ui_theme.itemDisabledStyle.fgColor = 0xFFcccccc;
	ui_theme.itemHighlightedStyle.background = UI::Drawable(0x55bdBB39);
	ui_theme.itemHighlightedStyle.fgColor = 0xFFFFFFFF;

	ui_theme.buttonStyle = ui_theme.itemStyle;
	ui_theme.buttonFocusedStyle = ui_theme.itemFocusedStyle;
	ui_theme.buttonDownStyle = ui_theme.itemDownStyle;
	ui_theme.buttonDisabledStyle = ui_theme.itemDisabledStyle;
	ui_theme.buttonHighlightedStyle = ui_theme.itemHighlightedStyle;

	ui_theme.popupTitle.fgColor = 0xFFE3BE59;
	ui_draw2d.Init();
	ui_draw2d_front.Init();

	uiTexture = new Texture();
	if (!uiTexture->Load("ui_atlas.zim")) {
		PanicAlert("Failed to load ui_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory.");
		ELOG("Failed to load ui_atlas.zim");
	}
	uiTexture->Bind(0);

	uiContext = new UIContext();
	uiContext->theme = &ui_theme;
	uiContext->Init(UIShader_Get(), UIShader_GetPlain(), uiTexture, &ui_draw2d, &ui_draw2d_front);
	if (uiContext->Text())
		uiContext->Text()->SetFont("Tahoma", 20, 0);
	screenManager->setUIContext(uiContext);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	glstate.viewport.set(0, 0, pixel_xres, pixel_yres);
}
コード例 #10
0
ファイル: NativeApp.cpp プロジェクト: hemingke/ppsspp
void NativeInitGraphics() {
	CheckGLExtensions();
	gl_lost_manager_init();
	ui_draw2d.SetAtlas(&ui_atlas);


	UIShader_Init();

	// Old style theme, to be removed later
	UITheme theme = {0};
	theme.uiFont = UBUNTU24;
	theme.uiFontSmall = UBUNTU24;
	theme.uiFontSmaller = UBUNTU24;
	theme.buttonImage = I_BUTTON;
	theme.buttonSelected = I_BUTTON_SELECTED;
	theme.checkOn = I_CHECKEDBOX;
	theme.checkOff = I_SQUARE;

	// memset(&ui_theme, 0, sizeof(ui_theme));
	// New style theme
	ui_theme.uiFont = UBUNTU24;
	ui_theme.uiFontSmall = UBUNTU24;
	ui_theme.uiFontSmaller = UBUNTU24;
	ui_theme.checkOn = I_CHECKEDBOX;
	ui_theme.checkOff = I_SQUARE;
	ui_theme.whiteImage = SOLIDWHITE;
	ui_theme.sliderKnob = I_CIRCLE;
	ui_theme.buttonStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON);
	ui_theme.buttonStyle.fgColor = 0xFFFFFFFF;
	ui_theme.buttonStyle.image = I_BUTTON;
	ui_theme.buttonFocusedStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON, 0xFFe0e0e0);
	ui_theme.buttonFocusedStyle.fgColor = 0xFFFFFFFF;
	ui_theme.buttonDownStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON_SELECTED, 0xFFFFFFFF);
	ui_theme.buttonDownStyle.fgColor = 0xFFFFFFFF;
	ui_theme.buttonDisabledStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON, 0xFF404040);
	ui_theme.buttonDisabledStyle.fgColor = 0xFF707070;
	ui_theme.itemStyle.background = UI::Drawable(0x55000000);
	ui_theme.itemStyle.fgColor = 0xFFFFFFFF;
	ui_theme.itemFocusedStyle.background = UI::Drawable(0xCC909080);
	ui_theme.itemDownStyle.background = UI::Drawable(0xFFFFc080);
	ui_theme.itemDownStyle.fgColor = 0xFF000000;
	ui_theme.popupTitle.fgColor = 0xFFE5B533;

	ui_draw2d.Init();
	ui_draw2d_front.Init();

	UIInit(&ui_atlas, theme);

	uiTexture = new Texture();
	if (!uiTexture->Load("ui_atlas.zim")) {
		PanicAlert("Failed to load ui_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory.");
		ELOG("Failed to load ui_atlas.zim");
	}
	uiTexture->Bind(0);

	uiContext = new UIContext();
	uiContext->theme = &ui_theme;
	uiContext->Init(UIShader_Get(), UIShader_GetPlain(), uiTexture, &ui_draw2d, &ui_draw2d_front);

	screenManager->setUIContext(uiContext);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	glstate.viewport.set(0, 0, pixel_xres, pixel_yres);
}
コード例 #11
0
ファイル: EmuScreen.cpp プロジェクト: Micket/ppsspp
void EmuScreen::render() {
	if (invalid_)
		return;

	// Reapply the graphics state of the PSP
	ReapplyGfxState();

	// We just run the CPU until we get to vblank. This will quickly sync up pretty nicely.
	// The actual number of cycles doesn't matter so much here as we will break due to CORE_NEXTFRAME, most of the time hopefully...
	int blockTicks = usToCycles(1000000 / 10);

	// Run until CORE_NEXTFRAME
	while (coreState == CORE_RUNNING) {
		u64 nowTicks = CoreTiming::GetTicks();
		mipsr4k.RunLoopUntil(nowTicks + blockTicks);
	}
	// Hopefully coreState is now CORE_NEXTFRAME
	if (coreState == CORE_NEXTFRAME) {
		// set back to running for the next frame
		coreState = CORE_RUNNING;
	} else if (coreState == CORE_POWERDOWN)	{
		ILOG("SELF-POWERDOWN!");
		if (g_Config.bNewUI)
			screenManager()->switchScreen(new MainScreen());
		else
			screenManager()->switchScreen(new MenuScreen());
	}

	if (invalid_)
		return;

	if (g_Config.bBufferedRendering)
		fbo_unbind();

	UIShader_Prepare();

	uiTexture->Bind(0);

	glstate.viewport.set(0, 0, pixel_xres, pixel_yres);
	glstate.viewport.restore();

	ui_draw2d.Begin(UIShader_Get(), DBMODE_NORMAL);

	float touchOpacity = g_Config.iTouchButtonOpacity / 100.0f;
	if (g_Config.bShowTouchControls)
		DrawGamepad(ui_draw2d, touchOpacity);

	DrawWatermark();

	if (!osm.IsEmpty()) {
		osm.Draw(ui_draw2d);
	}

	if (g_Config.bShowDebugStats) {
		char statbuf[4096] = {0};
		__DisplayGetDebugStats(statbuf);
		if (statbuf[4095])
			ERROR_LOG(HLE, "Statbuf too big");
		ui_draw2d.SetFontScale(.7f, .7f);
		ui_draw2d.DrawText(UBUNTU24, statbuf, 11, 11, 0xc0000000);
		ui_draw2d.DrawText(UBUNTU24, statbuf, 10, 10, 0xFFFFFFFF);
		ui_draw2d.SetFontScale(1.0f, 1.0f);
	}

	if (g_Config.iShowFPSCounter) {
		float vps, fps;
		__DisplayGetFPS(&vps, &fps);
		char fpsbuf[256];
		switch (g_Config.iShowFPSCounter) {
		case 1:
			sprintf(fpsbuf, "Speed: %0.1f", vps); break;
		case 2:
			sprintf(fpsbuf, "FPS: %0.1f", fps); break;
		case 3:
			sprintf(fpsbuf, "Speed: %5.1f\nFPS: %0.1f", vps, fps); break;
		}
		ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 8, 12, 0xc0000000, ALIGN_TOPRIGHT);
		ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 10, 10, 0xFF3fFF3f, ALIGN_TOPRIGHT);
	}
	

	glsl_bind(UIShader_Get());
	ui_draw2d.End();
	ui_draw2d.Flush();

	// Tiled renderers like PowerVR should benefit greatly from this. However - seems I can't call it?
#if defined(USING_GLES2)
	bool hasDiscard = gl_extensions.EXT_discard_framebuffer;  // TODO
	if (hasDiscard) {
		//const GLenum targets[3] = { GL_COLOR_EXT, GL_DEPTH_EXT, GL_STENCIL_EXT };
		//glDiscardFramebufferEXT(GL_FRAMEBUFFER, 3, targets);
	}
#endif
}
コード例 #12
0
ファイル: MenuScreens.cpp プロジェクト: mickL39/ppsspp
void LanguageScreen::render() {
	UIShader_Prepare();
	UIBegin(UIShader_Get());
	DrawBackground(1.0f);

	I18NCategory *s = GetI18NCategory("System");
	I18NCategory *g = GetI18NCategory("General");
	I18NCategory *l = GetI18NCategory("Language");

	ui_draw2d.SetFontScale(1.5f, 1.5f);
	ui_draw2d.DrawText(UBUNTU24, s->T("Language"), dp_xres / 2, 20, 0xFFFFFFFF, ALIGN_HCENTER);
	ui_draw2d.SetFontScale(1.0f, 1.0f);

	if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres-10), LARGE_BUTTON_WIDTH, 0, g->T("Back"), ALIGN_RIGHT | ALIGN_BOTTOM)) {
		screenManager()->finishDialog(this, DR_OK);
	}

	VGrid vlang(50, 100, dp_yres - 50, 10, 10);

	for (size_t i = 0; i < langs_.size(); i++) {
		std::string code;
		size_t dot = langs_[i].name.find('.');
		if (dot != std::string::npos)
			code = langs_[i].name.substr(0, dot);

		std::string buttonTitle = langs_[i].name;
		if (!code.empty())
			buttonTitle = code;

		if (UIButton(GEN_ID_LOOP(i), vlang, LARGE_BUTTON_WIDTH - 40, 0, buttonTitle.c_str(), ALIGN_TOPLEFT)) {
			std::string oldLang = g_Config.languageIni;
			g_Config.languageIni = code;

			if (i18nrepo.LoadIni(g_Config.languageIni)) {
				// Dunno what else to do here.
				langValuesMapping["ja_JP"] = PSP_SYSTEMPARAM_LANGUAGE_JAPANESE;
				langValuesMapping["en_US"] = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
				langValuesMapping["fr_FR"] = PSP_SYSTEMPARAM_LANGUAGE_FRENCH;
				langValuesMapping["es_ES"] = PSP_SYSTEMPARAM_LANGUAGE_SPANISH;
				langValuesMapping["es_LA"] = PSP_SYSTEMPARAM_LANGUAGE_SPANISH;
				langValuesMapping["de_DE"] = PSP_SYSTEMPARAM_LANGUAGE_GERMAN; 
				langValuesMapping["it_IT"] = PSP_SYSTEMPARAM_LANGUAGE_ITALIAN; 
				langValuesMapping["nl_NL"] = PSP_SYSTEMPARAM_LANGUAGE_DUTCH;
				langValuesMapping["pt_BR"] = PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE;
				langValuesMapping["ru_RU"] = PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN;
				langValuesMapping["ko_KR"] = PSP_SYSTEMPARAM_LANGUAGE_KOREAN;
				langValuesMapping["zh_TW"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL;
				langValuesMapping["zh_CN"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED;

				if(langValuesMapping.find(code) == langValuesMapping.end()) {
					//Fallback to English
					g_Config.ilanguage = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
				} else {
					g_Config.ilanguage = langValuesMapping[code];
				}

				// After this, g and s are no longer valid. Let's return, some flicker is okay.
				g = GetI18NCategory("General");
				s = GetI18NCategory("System");
				l = GetI18NCategory("Language");
			} else {
				g_Config.languageIni = oldLang;
			}
		}
	}
	UIEnd();
}
コード例 #13
0
ファイル: NativeApp.cpp プロジェクト: chaserhkj/ppsspp
void NativeInitGraphics() {
	gl_lost_manager_init();
	ui_draw2d.SetAtlas(&ui_atlas);

	screenManager = new ScreenManager();

	if (boot_filename.empty()) {
#if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(ARMEABI) || defined(ARMEABI_V7A)
		if (Atrac3plus_Decoder::CanAutoInstall()) {
			Atrac3plus_Decoder::DoAutoInstall();
			screenManager->switchScreen(new LogoScreen(boot_filename));
		} else {
			screenManager->switchScreen(new LogoScreen(boot_filename));
			// If first run and can't autoinstall, let's send the user to the atrac3plus download screen.
			if (g_Config.bFirstRun && !Atrac3plus_Decoder::IsInstalled())
				screenManager->push(new PluginScreen());
		}
#else
		screenManager->switchScreen(new LogoScreen(boot_filename));
#endif
	} else {
		// Go directly into the game.
		screenManager->switchScreen(new EmuScreen(boot_filename));
	}

	UIShader_Init();

	// Old style theme, to be removed later
	UITheme theme = {0};
	theme.uiFont = UBUNTU24;
	theme.uiFontSmall = UBUNTU24;
	theme.uiFontSmaller = UBUNTU24;
	theme.buttonImage = I_BUTTON;
	theme.buttonSelected = I_BUTTON_SELECTED;
	theme.checkOn = I_CHECKEDBOX;
	theme.checkOff = I_SQUARE;

	// memset(&ui_theme, 0, sizeof(ui_theme));
	// New style theme
	ui_theme.uiFont = UBUNTU24;
	ui_theme.uiFontSmall = UBUNTU24;
	ui_theme.uiFontSmaller = UBUNTU24;
	ui_theme.checkOn = I_CHECKEDBOX;
	ui_theme.checkOff = I_SQUARE;
	ui_theme.whiteImage = SOLIDWHITE;
	ui_theme.buttonStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON);
	ui_theme.buttonStyle.fgColor = 0xFFFFFFFF;
	ui_theme.buttonStyle.image = I_BUTTON;
	ui_theme.buttonFocusedStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON, 0xFFe0e0e0);
	ui_theme.buttonFocusedStyle.fgColor = 0xFFFFFFFF;
	ui_theme.buttonDownStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON_SELECTED, 0xFFFFFFFF);
	ui_theme.buttonDownStyle.fgColor = 0xFFFFFFFF;
	ui_theme.buttonDisabledStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON, 0xFF404040);
	ui_theme.buttonDisabledStyle.fgColor = 0xFF707070;
	ui_theme.itemStyle.background = UI::Drawable(0x55000000);
	ui_theme.itemStyle.fgColor = 0xFFFFFFFF;
	ui_theme.itemFocusedStyle.background = UI::Drawable(0xCC909080);
	ui_theme.itemDownStyle.background = UI::Drawable(0xFFFFc080);
	ui_theme.itemDownStyle.fgColor = 0xFF000000;

	ui_draw2d.Init();
	ui_draw2d_front.Init();

	UIInit(&ui_atlas, theme);

	uiTexture = new Texture();
	if (!uiTexture->Load("ui_atlas.zim")) {
		PanicAlert("Failed to load ui_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory.");
		ELOG("Failed to load ui_atlas.zim");
	}
	uiTexture->Bind(0);

	uiContext = new UIContext();
	uiContext->theme = &ui_theme;
	uiContext->Init(UIShader_Get(), UIShader_GetPlain(), uiTexture, &ui_draw2d, &ui_draw2d_front);

	screenManager->setUIContext(uiContext);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	glstate.viewport.set(0, 0, pixel_xres, pixel_yres);
}
コード例 #14
0
ファイル: EmuThread.cpp プロジェクト: hwdd6873/ppsspp
void EmuThread::run()
{
	running = true;
	setCurrentThreadName("EmuThread");

	g_State.bEmuThreadStarted = true;

	host->UpdateUI();
	host->InitGL();

	glWindow->makeCurrent();

#ifndef USING_GLES2
	glewInit();
#endif
	NativeInitGraphics();

	INFO_LOG(BOOT, "Starting up hardware.");

	CoreParameter coreParameter;
	coreParameter.fileToStart = fileToStart.toStdString();
	coreParameter.enableSound = true;
	coreParameter.gpuCore = GPU_GLES;
	coreParameter.cpuCore = (CPUCore)g_Config.iCpuCore;
	coreParameter.enableDebugging = true;
	coreParameter.printfEmuLog = false;
	coreParameter.headLess = false;
	coreParameter.renderWidth = 480 * g_Config.iWindowZoom;
	coreParameter.renderHeight = 272 * g_Config.iWindowZoom;
	coreParameter.outputWidth = dp_xres;
	coreParameter.outputHeight = dp_yres;
	coreParameter.pixelWidth = pixel_xres;
	coreParameter.pixelHeight = pixel_yres;
	coreParameter.startPaused = !g_Config.bAutoRun;

	std::string error_string;
	if (!PSP_Init(coreParameter, &error_string))
	{
		ERROR_LOG(BOOT, "Error loading: %s", error_string.c_str());
		FinalShutdown();
		return;
	}

	LayoutGamepad(dp_xres, dp_yres);

	_dbg_update_();

	host->UpdateDisassembly();
	Core_EnableStepping(coreParameter.startPaused ? TRUE : FALSE);

	g_State.bBooted = true;
#ifdef _DEBUG
	host->UpdateMemView();
#endif
	host->BootDone();

	QElapsedTimer timer;

	while(running) {
		//UpdateGamepad(*input_state);
		timer.start();

		UpdateInputState(input_state);

		static const int mapping[12][2] = {
			{PAD_BUTTON_A, CTRL_CROSS},
			{PAD_BUTTON_B, CTRL_CIRCLE},
			{PAD_BUTTON_X, CTRL_SQUARE},
			{PAD_BUTTON_Y, CTRL_TRIANGLE},
			{PAD_BUTTON_UP, CTRL_UP},
			{PAD_BUTTON_DOWN, CTRL_DOWN},
			{PAD_BUTTON_LEFT, CTRL_LEFT},
			{PAD_BUTTON_RIGHT, CTRL_RIGHT},
			{PAD_BUTTON_LBUMPER, CTRL_LTRIGGER},
			{PAD_BUTTON_RBUMPER, CTRL_RTRIGGER},
			{PAD_BUTTON_START, CTRL_START},
			{PAD_BUTTON_SELECT, CTRL_SELECT},
		};

		for (int i = 0; i < 12; i++) {
            if (input_state->pad_buttons_down & mapping[i][0]) {
				__CtrlButtonDown(mapping[i][1]);
			}
            if (input_state->pad_buttons_up & mapping[i][0]) {
				__CtrlButtonUp(mapping[i][1]);
			}
		}
		__CtrlSetAnalog(input_state->pad_lstick_x, input_state->pad_lstick_y);

		EndInputState(input_state);

		glstate.Restore();
		glViewport(0, 0, pixel_xres, pixel_yres);
		Matrix4x4 ortho;
		ortho.setOrtho(0.0f, dp_xres, dp_yres, 0.0f, -1.0f, 1.0f);
		glsl_bind(UIShader_Get());
		glUniformMatrix4fv(UIShader_Get()->u_worldviewproj, 1, GL_FALSE, ortho.getReadPtr());


		ReapplyGfxState();

		Core_Run();

		// Hopefully coreState is now CORE_NEXTFRAME
		if (coreState == CORE_NEXTFRAME) {
			// set back to running for the next frame
			coreState = CORE_RUNNING;

			qint64 time = timer.elapsed();
			const int frameTime = (1.0f/60.0f) * 1000;
			if(time < frameTime)
			{
				msleep(frameTime-time);
			}
			timer.start();
		}

		fbo_unbind();

		UIShader_Prepare();

		uiTexture->Bind(0);

		glViewport(0, 0, pixel_xres, pixel_yres);

		ui_draw2d.Begin(DBMODE_NORMAL);

		//if (g_Config.bShowTouchControls)
		//	DrawGamepad(ui_draw2d);

		glsl_bind(UIShader_Get());
		ui_draw2d.End();
		ui_draw2d.Flush(UIShader_Get());


		// Tiled renderers like PowerVR should benefit greatly from this. However - seems I can't call it?
#if defined(USING_GLES2)
		bool hasDiscard = false;  // TODO
		if (hasDiscard) {
			//glDiscardFramebuffer(GL_COLOR_EXT | GL_DEPTH_EXT | GL_STENCIL_EXT);
		}
#endif

		glWindow->swapBuffers();
	}
	glWindow->doneCurrent();
}