示例#1
0
Graphics::Graphics(Profile &profile)
: mMinAspect(0.0f), mMaxAspect(0.0f), mVSync(true), mFPSTime(0), mNumFrames(0), mFPS(0.0f), mBlendMode(BLEND_ALPHA)
{
	// setup the graphics settings
	CL_DisplayWindowDescription desc;
	desc.set_title("Balance");
	desc.set_size(CL_Size(profile.getInt("width", 1024), profile.getInt("height", 768)), true);
	desc.set_swap_interval(mVSync ? 1 : 0);
	if (profile.getBool("fullscreen", true))
	{
		desc.set_decorations(false);
		desc.set_fullscreen(true);
	}
	else
	{
		desc.set_allow_resize(true);
	}
	mWindow = CL_DisplayWindow(desc);

	// make window visible while debugging under SciTE
	mWindow.show();

	// connect window signals
	mSlots.connect(Application::getSingleton().getSigUpdate(), this, &Graphics::onUpdate);
	mSlots.connect(mWindow.get_ic().get_mouse().sig_key_down(), this, &Graphics::onMouseDown);
	mSlots.connect(mWindow.get_ic().get_mouse().sig_key_dblclk(), this, &Graphics::onMouseDown);
	mSlots.connect(mWindow.get_ic().get_mouse().sig_key_up(), this, &Graphics::onMouseUp);
	mSlots.connect(mWindow.sig_resize(), this, &Graphics::onResize);
	mSlots.connect(mWindow.sig_window_close(), this, &Graphics::onClose);

	// initialize the graphics settings
	mWindow.get_gc().set_map_mode(cl_user_projection);
	setScreenSize(1024.0f, 768.0f);
	setBlendMode(mBlendMode);

	// save the current settings
	profile.setBool("fullscreen", desc.is_fullscreen());
	profile.setInt("width", desc.get_size().width);
	profile.setInt("height", desc.get_size().height);
}
示例#2
0
int Application::main(const std::vector<CL_String> &args)
{	

	try
	{

		#ifdef DEBUG
		// Crea una ventan en consola para la salida de texto si no está disponible
		CL_ConsoleWindow console("JATG", 80, 1000); // 1000 permite una barra vertical
		CL_ConsoleLogger logger;
		#endif


		// Crea la ventana
		CL_DisplayWindowDescription desc;
		desc.set_title("JATG");

		desc.set_size(CL_Size(1024,768), true);	// Usa esta resolución

		desc.set_fullscreen(true);
		desc.set_decorations(false);

		CL_DisplayWindow window(desc);

		CL_GraphicContext gc = window.get_gc();
		CL_Mat4f matrix = CL_Mat4f::scale( (float) gc.get_width() / 1024.0f, (float) gc.get_height() / 768.0f, 1.0f);
		gc.set_modelview(matrix);

		

		CL_SoundOutput output(44100); //Inicializa Frecuencia

		// Crea el mundo
		Mundo mundo(window);

		// Corre el bucle del juego
		mundo.gameloop();

			
		
	}
	catch (CL_Exception& exception)
	{
		CL_Console::write_line("Excepcion Tomada:");
		CL_Console::write_line(exception.message);

		std::vector<CL_String> stacktrace = exception.get_stack_trace();
		int tamaño = stacktrace.size();
		if (tamaño > 0)
		{
			CL_Console::write_line("Stack Trace:");
			for (int i=0; i < tamaño; i++)
			{
				CL_Console::write_line(stacktrace[i]);
			}
		}

		CL_Console::wait_for_key(); //Espera por una tecla
	}

	return 0; 
}