Exemple #1
0
void display()
{
	// Funcion que atiende al evento de display (render)
	
	// Obtenemos el tiempo actual
	time(&ltime);
	newtime = localtime(&ltime); // Conversion a tiempo local

	// Color de borrado Blanco
	glClearColor(1.0,1.0,1.0,1.0); 
	
	// Borra la pantalla y buffer de profundidad
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	// Inicializa matriz compuesta de la MV
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	gluLookAt(0,3,6, 0,0,0, 0,1,0); // subimos la cámara
	//gluLookAt(0,0,6.5, 0,0,0, 0,1,0); // Cámara normal

	/** Esfera exterior **/
	glLineWidth(1.0f);
	glColor3f(0.3,0.6,0.6);
	glutWireSphere(1.0,10,10);

	/** Puntos reloj **/;
	glPushMatrix();
	glColor3f(0.0,0.0,0.0);
	glCallList(puntos);
	glPopMatrix();

	/** Esfera horas reloj **/
	int rot = 0; // Inicialmente 0º
	for (int i = 0; i<12; i++){
		glPushMatrix();
		glColor3f(0,0.6,0.4); // Color Verde
		glRotatef(rot,0,0,1); // Rotacion sobre eje z
		glTranslatef(0,0.9,0);
		glutSolidSphere(0.05,10,10);
		glPopMatrix();
		rot += 30;
	}

	/** Estrellas rotatorias interiores **/
	glPushMatrix();
	glScalef(0.25,0.25,0.25); // Diametro 1/10
	glRotatef(beta,0,1,0); // Rotacion constante sobre eje y
	FPS(); // Muertra FPS a los que giran las estrellas

	int pos = 0; // Inicialmente 0º
	for (int i=0; i<4; i++){ // Dibuja 4 estrellas
		glPushMatrix();
		glRotatef(pos,0,1,0); // Rotacion sobre eje y
		glColor3f(0.2 + 0.2/4 *i, 0.9 - 0.5/4 *i, 0.9 - 0.9/4 *i); // Color degradado
		glCallList(triangulo1);
		glCallList(triangulo2);
		glPopMatrix();
		pos += 40;
	}
	glPopMatrix();
	
	/** Linea marca segundos **/
	glColor3f(0.4,0,1);
    glLineWidth(6.0);
    glPushMatrix();
    glRotatef((360/60) * newtime->tm_sec,0.0,0.0,-1.0);
    glBegin(GL_LINES);
    glVertex2f(0,0.1);
    glVertex2f(0,0.85);
    glEnd();
	glPopMatrix();

	/** Cono marca minutos **/
    glColor3f(0,0,0);
	glLineWidth(2.0);
    glPushMatrix();
	glRotatef(90,-1,0,0);
    glRotatef((360/60) * newtime->tm_min,0,1,0);
	glTranslatef(0,0,0.25); // Lo trasladamos hacia arriba (eje y)
    glutWireCone(0.075,0.5,10,10);
    glPopMatrix();

	/** Triangulo marca horas **/
	glPushMatrix();
	glColor3f(0.7,0,0); // Color Rojo
	glScalef(0.1,0.1,0.1); // Diametro 1/10
	glRotatef((360/12) * newtime->tm_hour, 0.0, 0.0, -1.0);
	glTranslatef(0,6,0); // Lo trasladamos hacia arriba (eje y)
	glScalef(gamma,gamma,gamma); // Rotacion sobre eje y
	glCallList(triangulo1);
	//FPS(); // Muertra FPS a los que cambia de tamaño
	glPopMatrix();

	// Intercambiar el buffer back por el front
	glutSwapBuffers();
}
Exemple #2
0
timerC::~timerC()
{
 if(Eta)
    if(Frames)	printf("%10s timer: %8.1ffps (if only this was performed)\n", Name, FPS());
    else	printf("%10s timer: %6dms\n", Name, Eta);
}
void VideoContext::SetVideo(const wxString &filename) {
	Reset();
	if (filename.empty()) {
		VideoOpen();
		return;
	}

	bool commit_subs = false;
	try {
		provider.reset(new ThreadedFrameSource(filename, this));
		videoProvider = provider->GetVideoProvider();
		videoFile = filename;

		// Check that the script resolution matches the video resolution
		int sx = context->ass->GetScriptInfoAsInt("PlayResX");
		int sy = context->ass->GetScriptInfoAsInt("PlayResY");
		int vx = GetWidth();
		int vy = GetHeight();

		// If the script resolution hasn't been set at all just force it to the
		// video resolution
		if (sx == 0 && sy == 0) {
			context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vx));
			context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vy));
			commit_subs = true;
		}
		// If it has been set to something other than a multiple of the video
		// resolution, ask the user if they want it to be fixed
		else if (sx % vx != 0 || sy % vy != 0) {
			switch (OPT_GET("Video/Check Script Res")->GetInt()) {
			case 1: // Ask to change on mismatch
				if (wxYES != wxMessageBox(
					wxString::Format(_("The resolution of the loaded video and the resolution specified for the subtitles don't match.\n\nVideo resolution:\t%d x %d\nScript resolution:\t%d x %d\n\nChange subtitles resolution to match video?"), vx, vy, sx, sy),
					_("Resolution mismatch"),
					wxYES_NO | wxCENTER,
					context->parent))

					break;
				// Fallthrough to case 2
			case 2: // Always change script res
				context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vx));
				context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vy));
				commit_subs = true;
				break;
			default: // Never change
				break;
			}
		}

		keyFrames = videoProvider->GetKeyFrames();

		// Set frame rate
		videoFPS = videoProvider->GetFPS();
		if (ovrFPS.IsLoaded()) {
			int ovr = wxMessageBox(_("You already have timecodes loaded. Would you like to replace them with timecodes from the video file?"), _("Replace timecodes?"), wxYES_NO | wxICON_QUESTION);
			if (ovr == wxYES) {
				ovrFPS = agi::vfr::Framerate();
				ovrTimecodeFile.clear();
			}
		}

		// Set aspect ratio
		double dar = videoProvider->GetDAR();
		if (dar > 0)
			SetAspectRatio(4, dar);

		// Set filename
		config::mru->Add("Video", STD_STR(filename));
		StandardPaths::SetPathValue("?video", wxFileName(filename).GetPath());

		// Show warning
		wxString warning = videoProvider->GetWarning();
		if (!warning.empty()) wxMessageBox(warning, "Warning", wxICON_WARNING | wxOK);

		hasSubtitles = false;
		if (filename.Right(4).Lower() == ".mkv") {
			hasSubtitles = MatroskaWrapper::HasSubtitles(filename);
		}

		provider->LoadSubtitles(context->ass);
		VideoOpen();
		KeyframesOpen(keyFrames);
		TimecodesOpen(FPS());
	}
	catch (agi::UserCancelException const&) { }
	catch (agi::FileNotAccessibleError const& err) {
		config::mru->Remove("Video", STD_STR(filename));
		wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxOK | wxICON_ERROR | wxCENTER);
	}
	catch (VideoProviderError const& err) {
		wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxOK | wxICON_ERROR | wxCENTER);
	}

	if (commit_subs)
		context->ass->Commit(_("change script resolution"), AssFile::COMMIT_SCRIPTINFO);
	else
		JumpToFrame(0);
}
Exemple #4
0
	//文字列の表示
	void Player::DrawStrings() {

		//文字列表示
		//行動
		wstring BEHAVIOR;
		if (m_PlayerAction == PlayerAction::Jump) {
			BEHAVIOR = L"DEFAULT行動: Aボタンでジャンプ。Bボタンで行動切り替え\n";
		}
		else {
			BEHAVIOR = L"ATTACK行動: Aボタンでアタック。Bボタンで行動切り替え\n";
		}


		auto fps = App::GetApp()->GetStepTimer().GetFramesPerSecond();
		wstring FPS(L"FPS: ");
		FPS += Util::UintToWStr(fps);
		FPS += L"\nElapsedTime: ";
		float ElapsedTime = App::GetApp()->GetElapsedTime();
		FPS += Util::FloatToWStr(ElapsedTime);
		FPS += L"\n";

		auto Pos = GetComponent<Transform>()->GetPosition();
		wstring PositionStr(L"Position:\t");
		PositionStr += L"X=" + Util::FloatToWStr(Pos.x, 6, Util::FloatModify::Fixed) + L",\t";
		PositionStr += L"Y=" + Util::FloatToWStr(Pos.y, 6, Util::FloatModify::Fixed) + L",\t";
		PositionStr += L"Z=" + Util::FloatToWStr(Pos.z, 6, Util::FloatModify::Fixed) + L"\n";
		if (GetComponent<Transform>()->GetParent()) {
			PositionStr += L"OnParent\n";
		}
		else {
			PositionStr += L"NotParent\n";
		}

		wstring RididStr(L"Velocity:\t");
		auto Velocity = GetComponent<Rigidbody>()->GetVelocity();
		RididStr += L"X=" + Util::FloatToWStr(Velocity.x, 6, Util::FloatModify::Fixed) + L",\t";
		RididStr += L"Y=" + Util::FloatToWStr(Velocity.y, 6, Util::FloatModify::Fixed) + L",\t";
		RididStr += L"Z=" + Util::FloatToWStr(Velocity.z, 6, Util::FloatModify::Fixed) + L"\n";

		wstring GravStr(L"GravityVelocity:\t");
		auto GravVelocity = GetComponent<Rigidbody>()->GetGravityVelocity();
		GravStr += L"X=" + Util::FloatToWStr(GravVelocity.x, 6, Util::FloatModify::Fixed) + L",\t";
		GravStr += L"Y=" + Util::FloatToWStr(GravVelocity.y, 6, Util::FloatModify::Fixed) + L",\t";
		GravStr += L"Z=" + Util::FloatToWStr(GravVelocity.z, 6, Util::FloatModify::Fixed) + L"\n";


		wstring StateStr(L"State: ");
		StateStr += GetStateMachine()->GetTopState()->GetStateName() + L"\n";

		wstring HitObjectStr(L"HitObject: ");
		if (GetComponent<Collision>()->GetHitObjectVec().size() > 0) {
			for (auto&v : GetComponent<Collision>()->GetHitObjectVec()) {
				HitObjectStr += Util::UintToWStr((UINT)v.get()) + L",";
			}
			HitObjectStr += L"\n";
		}
		else {
			HitObjectStr += L"NULL\n";
		}
		wstring str = BEHAVIOR + FPS + PositionStr + RididStr + GravStr + StateStr + HitObjectStr;
		//文字列をつける
		auto PtrString = GetComponent<StringSprite>();
		PtrString->SetText(str);
	}