コード例 #1
0
ファイル: main.cpp プロジェクト: Lamorna/engine
/*
==================
==================
*/
void Lamorna_Setup(

	game_data_& game_data,
	FILE *boot_log

)
{
	game_data.memory_chunk.chunk_ptr = game_data.memory_chunk.chunk;

	Get_System_Info(game_data.thread_pool);

	Initialise_Input(game_data.timer, game_data.user_input);

	Load_UI(game_data.user_interface, game_data.memory_chunk);

	Load_Map_Elements(game_data.model_token_manager);

	Load_External_Models(game_data.model_manager, game_data.memory_chunk);

	Hardcode_Cube_Template(

		game_data.model_manager.model[model_::id_::CUBE],
		game_data.model_manager.model[model_::id_::CUBE_BACKFACE],
		game_data.memory_chunk
	);

	Specialise_Cube_Template(game_data.model_manager, game_data.memory_chunk);

	Create_BVH(

		game_data.model_token_manager,
		game_data.lightmap_manager,
		game_data.model_manager,
		game_data.memory_chunk,
		game_data.grid
	);

	Load_Sounds(game_data.memory_chunk, game_data.sound_system.wavs);

	Initialise_Sound(game_data.sound_system.direct_sound, game_data.sound_system.sound_buffer, game_data.sound_system.sound_mixer);

	{
		for (__int32 i_thread = 0; i_thread < thread_pool_::MAX_WORKER_THREADS; i_thread++) {
			for (__int32 bin_y = 0; bin_y < display_::N_BINS_Y; bin_y++) {
				for (__int32 bin_x = 0; bin_x < display_::N_BINS_X; bin_x++) {

					screen_bin_& bin = game_data.display.screen_bin[i_thread][bin_y][bin_x];

					for (__int32 i_draw_call = 0; i_draw_call < draw_call_::id_::COUNT; i_draw_call++) {
						bin.draw_id[i_draw_call] = -1;
						bin.n_tris[i_draw_call] = 0;
					}

					bin.n_draw_calls = -1;
					bin.n_triangles = 0;
				}
			}
		}
	}

	Initialise_Systems(

		game_data.sound_system.sound_event_table,
		game_data.animation_manager,
		game_data.behaviour_manager,
		game_data.collision_manager,
		game_data.way_point_manager,
		game_data.lightmap_manager,
		game_data.model_manager,
		game_data.component_data,
		game_data.model_token_manager,
		game_data.timer,
		game_data.particle_manager,
		game_data.command_buffer_handler,
		game_data.collision_response,
		game_data.grid,
		game_data.memory_chunk
	);

	Load_Frame_Jobs(

		game_data.model_token_manager,
		game_data.model_manager,
		game_data.user_input,
		game_data.timer,
		game_data.sound_system,
		game_data.display,
		game_data.game_matrices,
		game_data.behaviour_manager,
		game_data.animation_manager,
		game_data.way_point_manager,
		game_data.command_buffer_handler,
		game_data.collision_response,
		game_data.particle_manager,
		game_data.collision_manager,
		game_data.lightmap_manager,
		game_data.component_data,
		game_data.frame_jobs,
		game_data.thread_pool,
		game_data.user_interface,
		game_data.grid

	);

	{
		for (__int32 i_thread = 0; i_thread < thread_pool_::MAX_WORKER_THREADS; i_thread++) {
			Clear_Tile_Buffer(i_thread, game_data.display);
		}
	}

	const __int64 num_bytes_allocated = (char*)game_data.memory_chunk.chunk_ptr - (char*)game_data.memory_chunk.chunk;
	const __int64 num_bytes_unallocated = memory_chunk_::NUM_BYTES - num_bytes_allocated;
	printf_s("MEMORY REMAINING: %i \n", (__int32)num_bytes_unallocated);

	Thread_Pool_Initialise(game_data.thread_pool);

	printf_s("\n...WELCOME to Lamorna Engine! \n");
}
コード例 #2
0
ファイル: Editor.cpp プロジェクト: Neuromancer56/NodeBox
bool Editor::run(IrrlichtDevice* irr_device){
	// Irrlicht Device
	device=irr_device;
	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();
	coli=smgr->getSceneCollisionManager();
	device->setEventReceiver(this);

	// Editor Settings
	data=new ed_data();
	data->snapping = true;
	data->limiting = true;
	data->type = TOOL_NODEB;
	data->menu = NULL;

	// Load editor
	Load_Scene();
	Load_UI();

	// Create project
	project = new Project();
	project->nodes[0] = new Node(device,data);
	MoveTarget(project->nodes[0]->getPosition());

	// Set up window	
	device->setWindowCaption(convert((project->mod + stringc(" - The NodeBox Editor")).c_str()));
	device->setResizable(true);

	// Step data
	unsigned int counter=0;
	dimension2d<irr::u32> last_render_size = driver->getCurrentRenderTargetSize();

	while (device->run()){
		counter++;
		driver->beginScene(true, true, irr::video::SColor(255,100,101,140));
	
		int ResX = driver->getScreenSize().Width;
		int ResY = driver->getScreenSize().Height;

		if (isSplitScreen==true)
		{
			// Draw Camera 0
			if (camera[0]){
				smgr->setActiveCamera(camera[0]);
				driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
				smgr->drawAll();
			}

			// Draw Camera 1
			if (camera[1]){
				smgr->setActiveCamera(camera[1]);
				driver->setViewPort(rect<s32>(ResX/2,0,ResX,ResY/2));
				smgr->drawAll();
				
				updatePoint(0,5);
			}

			// Draw Camera 2
			if (camera[2]){
				smgr->setActiveCamera(camera[2]);
				driver->setViewPort(rect<s32>(0,ResY/2,ResX/2,ResY));
				smgr->drawAll();

				updatePoint(5,10);
			}

			// Draw Camera 3
			if (camera[3]){
				smgr->setActiveCamera(camera[3]);
				driver->setViewPort(rect<s32>(ResX/2,ResY/2,ResX,ResY));				
				smgr->drawAll();

				updatePoint(10,15);
			}

			// Draw GUI
			driver->setViewPort(rect<s32>(0,0,ResX,ResY));
			driver->draw2DLine(vector2d<irr::s32>(0,ResY/2),vector2d<irr::s32>(ResX,ResY/2),SColor(175,255,255,255));
			driver->draw2DLine(vector2d<irr::s32>(0,ResY/2-1),vector2d<irr::s32>(ResX,ResY/2-1),SColor(175,255,255,255));
			driver->draw2DLine(vector2d<irr::s32>(ResX/2,0),vector2d<irr::s32>(ResX/2,ResY),SColor(175,255,255,255));
			driver->draw2DLine(vector2d<irr::s32>(ResX/2+1,0),vector2d<irr::s32>(ResX/2+1,ResY),SColor(175,255,255,255));
		}else if (camera[currentWindow]){
			smgr->setActiveCamera(camera[currentWindow]);
			driver->setViewPort(rect<s32>(0,0,ResX,ResY));			
			smgr->drawAll();
			updatePoint(0,15);
		}

		guienv->drawAll();
		driver->endScene();

		
		if ( driver->getCurrentRenderTargetSize() != last_render_size){
			printf("Adjusting FOV to new screen size...\n");
			last_render_size = driver->getCurrentRenderTargetSize();
			camera[0]->setAspectRatio((float)driver->getScreenSize().Width/(float)driver->getScreenSize().Height);

			// reset matrix
			matrix4 projMat;
			irr::f32 orth_w = (float)driver->getScreenSize().Width / (float)driver->getScreenSize().Height;
			orth_w = 3 * orth_w;
			projMat.buildProjectionMatrixOrthoLH(orth_w,3,1,100);

			for (int i=1;i<4;i++){
				if (camera[i]){
					camera[i]->remove();
					camera[i]=NULL;
				}
			}

			// Remake cameras
			camera[1]=smgr->addCameraSceneNode(target,vector3df(0,2,-0.01),vector3df(0,0,0));
			camera[1]->setProjectionMatrix(projMat,true);
			camera[2]=smgr->addCameraSceneNode(target,vector3df(0,0,-5),vector3df(0,0,0));
			camera[2]->setProjectionMatrix(projMat,true);
			camera[3]=smgr->addCameraSceneNode(target,vector3df(-5,0,0),vector3df(0,0,0));
			camera[3]->setProjectionMatrix(projMat,true);	
		}

		if (counter>500){	
			counter=0;
			if (project->GetCurNode())
				project->GetCurNode()->update();	
		}

	}

	return true;
}