Exemplo n.º 1
0
void drawSplashScreen(const std::string &filename){
	if(splashScreen.ID) gl::DeleteTextures(1, &splashScreen.ID);
	else {
		ResourceLoader loader;
		loader.reloadShader("ApplyFBO");
		splashScreen = loader.loadImage(filename);

		glfwShowWindow(Global::main.window);
		glfwSetWindowPos(Global::main.window, Global::main.screenSize.x/2.f - splashScreen.width/2, Global::main.screenSize.y/2.f - splashScreen.height/2);
		glfwSetWindowSize(Global::main.window, splashScreen.width, splashScreen.height);
	}
	gl::Viewport(0, 0, splashScreen.width, splashScreen.height);
	gl::ClearColor(0.f, 0.f, 0.f, 0.f);
	gl::Clear(gl::COLOR_BUFFER_BIT);
	gl::DepthMask(gl::FALSE_);
	gl::Enable(gl::BLEND);
	gl::BlendFunc(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);

	gl::BindBuffer(gl::ARRAY_BUFFER, 0);
	gl::DisableVertexAttribArray(0);
	gl::BindFramebuffer(gl::DRAW_FRAMEBUFFER, 0);

	auto shader = assets::getShader("ApplyFBO");
	shader.bind();
	float width = Global::main.size.x;
	float height = Global::main.size.y;

	shader.texture("uTexture", splashScreen.ID);

	drawScreen();

	glfwSwapBuffers(Global::main.window);

	CHECK_FOR_ERRORS
}
Exemplo n.º 2
0
void Particles::init(){
	/// collect textures
	std::vector<std::string> &&images = listDirectory("../res/textures/CGI256"s);
	ResourceLoader loader;
	Global::main.commonResources.textureAtlas["Cgi256"] = loader.loadAtlas(images, "../res/textures/CGI256"s);
	createBuffer();
}
Exemplo n.º 3
0
ControlTrayIcon::ControlTrayIcon(ControlProxy *serverControl,
                                 Notificator *notificator,
                                 ControlApplication *appControl,
                                 bool showAfterCreation)
: NotifyIcon(showAfterCreation),
  m_serverControl(serverControl), m_notificator(notificator),
  m_appControl(appControl),
  m_inWindowProc(false),
  m_termination(false)
{
  ResourceLoader *resLoader = ResourceLoader::getInstance();

  m_iconWorking = new Icon(resLoader->loadIcon(MAKEINTRESOURCE(IDI_CONNECTED)));
  m_iconIdle = new Icon(resLoader->loadIcon(MAKEINTRESOURCE(IDI_IDLE)));
  m_iconDisabled = new Icon(resLoader->loadIcon(MAKEINTRESOURCE(IDI_DISABLED)));

  setWindowProcHolder(this);

  m_updateRemoteConfigCommand = new UpdateRemoteConfigCommand(m_serverControl);
  m_updateLocalConfigCommand = new UpdateLocalConfigCommand(m_serverControl);
  m_applyChangesMacroCommand = new MacroCommand();
  m_applyChangesMacroCommand->addCommand(m_updateRemoteConfigCommand);
  m_applyChangesMacroCommand->addCommand(m_updateLocalConfigCommand);
  m_applyChangesControlCommand = new ControlCommand(m_applyChangesMacroCommand, m_notificator);

  m_configDialog = new ConfigDialog();
  m_configDialog->setConfigReloadCommand(m_applyChangesControlCommand);

  setNotConnectedState();

  syncStatusWithServer();
}
Exemplo n.º 4
0
int loader_thread(void *loader) {
    ResourceLoader *resourceLoader = (ResourceLoader *) loader;
    IResourceManager *resourceManager = resourceLoader->getResourceManager();
    LoadingJob *curJob;
    while (true) {
        // get a new job from the in list.
        curJob = resourceLoader->getJobIn();

        // process the job
        switch (curJob->type) {
        case LOAD_JOB_MESH:
            // load a mesh
            curJob->data = resourceManager->readMeshData(curJob->ref->fileName, LOAD_NORMAL_VERTEX, 1.0);
            break;

        case LOAD_JOB_TEXTURE:
            // load a texture
            curJob->data = resourceManager->loadBMPImage(curJob->ref->fileName);
            break;

        default:
            cerr << "Unknown load job\n";
            exit(1);
            break;
        }

        // put the finished job in the out list.
        resourceLoader->addJobOut(curJob);
    }
    return 0;
}
Exemplo n.º 5
0
void FileInfoListView::loadImages()
{
  if (m_smallImageList != NULL) {
    ImageList_Destroy(m_smallImageList);
  }

  m_smallImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
                                      GetSystemMetrics(SM_CYSMICON),
                                      ILC_MASK, 1, 1);

  HICON icon;

  ResourceLoader *rLoader = ResourceLoader::getInstance();

  icon = rLoader->loadIcon(MAKEINTRESOURCE(IDI_FILEUP));
  _ASSERT(icon != NULL);
  ImageList_AddIcon(m_smallImageList, icon);
  DestroyIcon(icon);

  icon = rLoader->loadIcon(MAKEINTRESOURCE(IDI_FOLDER_ICON));
  _ASSERT(icon != NULL);
  ImageList_AddIcon(m_smallImageList, icon);
  DestroyIcon(icon);

  icon = rLoader->loadIcon(MAKEINTRESOURCE(IDI_FILE_ICON));
  _ASSERT(icon != NULL);
  ImageList_AddIcon(m_smallImageList, icon);
  DestroyIcon(icon);
}
void GameStateController::loadGame(flat2d::GameData *gameData)
{
	// Clean up first
	clearAllAssets(gameData);

	flat2d::EntityContainer *entityContainer = gameData->getEntityContainer();
	CustomGameData *customGameData = static_cast<CustomGameData*>(gameData->getCustomGameData());
	LayerService *layerService = customGameData->getLayerService();

	MapParser parser;
	MapData map = maps[currentMapIndex];
	parser.createMapFrom(gameData, map.path, map.file);

	// TODO(Linus): Will this layer system work? (esp the hardcoded layers)
	layerService->registerLayer(FRONT_LAYER);
	layerService->registerLayer(OVERLAY_LAYER);
	layerService->registerLayers(entityContainer);

	flat2d::Entity* soldier = new Soldier(200, 200);
	entityContainer->registerObject(soldier, layerService->getLayerIndex(FRONT_LAYER));

	ResourceLoader *rLoader = customGameData->getResourceLoader();
	rLoader->loadMusic(gameData);
	rLoader->loadSoundEffects(gameData);

#ifdef FPS_DBG
	FrameCounter *counter = new FrameCounter(10, 10);
	entityContainer->registerObject(counter, layerService->getLayerIndex(OVERLAY_LAYER));
#endif // DEBUG
}
Exemplo n.º 7
0
void renderTitle(double elapsedTime, const ResourceLoader& resources)
{
	auto tMain = resources.getTextures().getMainTitleTexture();
	auto tSub = resources.getTextures().getSubTitleTexture();
	auto tSpace = resources.getTextures().getSpacePressTexture();

	auto main_y = elapsedTime < 1000 ? (elapsedTime / 1000.0) * (Window::Height() / 4.0f * 2.0f) - Window::Height() / 4.0f : Window::Height() / 4.0f;
	auto sub_y = 0.0;
	auto sub_angle = 0.0;
	auto main_w = tMain.size.x;

	if (elapsedTime < 1500) sub_y = -Window::Height() / 4.0f;
	else if (elapsedTime < 2500) sub_y = EaseOut(Easing::Bounce, (elapsedTime - 1500) / 1000.0) * (Window::Height() / 4.0f * 2.0f) - Window::Height() / 4.0f + 24.0f;
	else sub_y = Window::Height() / 4.0f + 24.0f;

	if (elapsedTime < 3000) sub_angle = 0.0;
	else if (elapsedTime < 3200) sub_angle = ((elapsedTime - 3000) / 200) * 5.0f;
	else sub_angle = 5.0f;

	tMain.draw(Vec2((Window::Width() - main_w) / 2.0f, main_y));
	tSub.rotateAt(Vec2(0.0f, tSub.size.y), Math::Radians(sub_angle)).draw(Vec2((Window::Width() + main_w) / 2.0f, sub_y));

	if (elapsedTime >= 4000)
	{
		if (Math::Fmod(elapsedTime, 1000.0) < 500.0)
		{
			tSpace.draw(Vec2((Window::Width() - tSpace.size.x) / 2.0, Window::Height() / 4.0 * 3.0));
		}
	}
}
Exemplo n.º 8
0
void WebFrame::convertMainResourceLoadToDownload(DocumentLoader* documentLoader, const ResourceRequest& request, const ResourceResponse& response)
{
    ASSERT(m_policyDownloadID);

    uint64_t policyDownloadID = m_policyDownloadID;
    m_policyDownloadID = 0;

    ResourceLoader* mainResourceLoader = documentLoader->mainResourceLoader();

#if ENABLE(NETWORK_PROCESS)
    if (WebProcess::shared().usesNetworkProcess()) {
        // Use 0 to indicate that there is no main resource loader.
        // This can happen if the main resource is in the WebCore memory cache.
        uint64_t mainResourceLoadIdentifier;
        if (mainResourceLoader)
            mainResourceLoadIdentifier = mainResourceLoader->identifier();
        else
            mainResourceLoadIdentifier = 0;

        WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::ConvertMainResourceLoadToDownload(mainResourceLoadIdentifier, policyDownloadID, request, response), 0);
        return;
    }
#endif

    if (!mainResourceLoader) {
        // The main resource has already been loaded. Start a new download instead.
        WebProcess::shared().downloadManager().startDownload(policyDownloadID, request);
        return;
    }

    WebProcess::shared().downloadManager().convertHandleToDownload(policyDownloadID, documentLoader->mainResourceLoader()->handle(), request, response);
}
Exemplo n.º 9
0
bool ResourceLoadScheduler::maybeLoadQuickLookResource(ResourceLoader& loader)
{
    if (!loader.request().url().protocolIs(QLPreviewProtocol()))
        return false;

    loader.start();
    return true;
}
Exemplo n.º 10
0
void TerrainWrapper::Enable()
{




	Controller * ctrl = static_cast<Controller*>(GetManager()->Get("Controller"));
	DataManager * dm = static_cast<DataManager*>(GetManager()->Get("DataManager"));



	Techniques * tech = static_cast<Techniques*>(dm->Get("Techniques"));
	ResourceLoader * res = static_cast<ResourceLoader*>(dm->Get("Resources"));
	Environment * env = static_cast<Environment*>(res->Get("Environment"));
	Camera * camera = static_cast<Camera*>(ctrl->Get("Camera"));
	View * view = camera->GetView();
	ViewInfo * info = camera->GetInfo();



	Shader::Enable();
	Shader::Set("myTextureSampler", 0);
	Shader::Set("myTextureSampler2", 1);
	Shader::Set("myTextureSampler3", 2);
	Shader::Set("shadow_map", 3);
	TerrainShader::SendTextureAttributes(terra->GetTextureAttributes(), 4);


	/**
	Raising to power for gamma correction
	*/
	getLight()->SetFog(glm::pow(env->fog_color, glm::vec3(2.2)), env->fog_density);
	getLight()->SetDirectionalLight(env->terrain_bright*
		glm::pow(env->sun_color, glm::vec3(2.2)),
		env->sun_dir,
		env->terrain_ambient,
		env->terrain_diffuse);





	Set("LightMatrix", Math::GetBiasMatrix()*
		tech->GetShadow()->GetDirectionalShadow(env, info, view));



	tech->GetShadow()->GetShadowMap()->BindTexture(0, GL_TEXTURE3);
	tech->GetShadow()->GetShadowMap()->ResetTextureState();




	ManagePlayerCollision(ctrl, false);



}
Exemplo n.º 11
0
void renderPlayer(double viewOffset, double playerAngle, const Vec2& playerPos, const ResourceLoader& resources)
{
	// player render
	auto tPlayer = resources.getTextures().getPlayerTexture().scale(2);
	auto tPlayerBody = resources.getTextures().getPlayerBodyTexture().scale(2);

	tPlayer.rotateAt(Vec2(12, 8) * 2, Math::Radians(playerAngle)).draw((playerPos - Vec2(12 + viewOffset, 8)) * 2);
	tPlayerBody.rotateAt(Vec2(12, 13) * 2, Math::Radians(playerAngle)).draw((playerPos - Vec2(12 + viewOffset, 18)) * 2);
}
Exemplo n.º 12
0
// Creates an instance of Player
// @param png - The path to the PNG representation of the sprite
// @param plist - The path to the PLIST representation of the sprite
Player* Player::create()
{
	// Create an instance of Player
	Player* playerSprite = new Player();

	// Reset travelled distance
	playerSprite->setDistanceTravelled(0);

	// Get resource loader instance
	ResourceLoader resLoader = ResourceLoader::getInstance();

	// Get running animation
	Vector<SpriteFrame*> runningAnimation = resLoader.getAnimation(PLAYER_ANIMATION_RUNNING);

	// Generate player movement sprites
	if (playerSprite->initWithSpriteFrame(runningAnimation.at(0)))
	{
		auto animation = Animation::createWithSpriteFrames(runningAnimation);

		// Set delay between frames
		animation->setDelayPerUnit(PLAYER_SPRITE_DELAY_RUNNING);

		//Create running action
		auto runningAction = RepeatForever::create(Animate::create(animation));

		//Set tag for action
		runningAction->setTag(PLAYER_ANIMATION_RUNNING);

		// Run animation forever
		playerSprite->runAction(runningAction);

		// Set properties
		playerSprite->autorelease();
		playerSprite->initOptions();
		playerSprite->setScale(Director::getInstance()->getWinSize().width * 1.8 / 800);
		playerSprite->scheduleUpdate();

		// Add weapon
		Weapon* weapon = Weapon::create();
		playerSprite->setWeapon(weapon);

		//Create physical body
		auto spriteBody = PhysicsBody::createBox(playerSprite->boundingBox().size, PhysicsMaterial(1.0f, 0.5f, 0.5f));
		spriteBody->setAngularVelocityLimit(0.0f);
		spriteBody->setMass(1);
		spriteBody->setCollisionBitmask(PLAYER_COLLISION_BITMASK);
		spriteBody->setContactTestBitmask(true);
		playerSprite->setPhysicsBody(spriteBody);
		
		// Return
		return playerSprite;
	}

	CC_SAFE_DELETE(playerSprite);
	return NULL;
}
Exemplo n.º 13
0
 static Resource *load(void *v)
 {
     ResourceLoader *l = static_cast< ResourceLoader * >(v);
     int fileSize;
     void *buffer = l->manager->loadFile(l->path, fileSize);
     if (!buffer) return NULL;
     Resource *res = l->fun(buffer, fileSize);
     free(buffer);
     return res;
 }
Exemplo n.º 14
0
void TerrainWrapper::Render()
{




	Controller * ctrl = static_cast<Controller*>(GetManager()->Get("Controller"));
	DataManager * dm = static_cast<DataManager*>(GetManager()->Get("DataManager"));


	Techniques * tech = static_cast<Techniques*>(dm->Get("Techniques"));
	ResourceLoader * res = static_cast<ResourceLoader*>(dm->Get("Resources"));
	Environment * env = static_cast<Environment*>(res->Get("Environment"));
	Camera * camera = static_cast<Camera*>(ctrl->Get("Camera"));
	View * view = camera->GetView();
	ViewInfo * info = camera->GetInfo();





	if (tech->GetSSAO()->OnGeometryPass())
	{


		tech->GetSSAO()->SetGeometryPassUniforms(view->getCamera(),
			view->getViewMatrix());


	}
	else if (tech->GetShadow()->OnShadowPass())
	{

		tech->GetShadow()->UniformMVP(tech->GetShadow()->GetDirectionalShadow(env, info, view));


	}
	else
	{


		Space(glm::mat4(1.0), view);


	}



	terra->Render(camera->GetFrustum(), false);




}
Exemplo n.º 15
0
bool ViewerWindow::onNotify(int idCtrl, LPNMHDR pnmh)
{
	ResourceLoader *rLoader = ResourceLoader::getInstance();
	LPTOOLTIPTEXT toolTipText = reinterpret_cast<LPTOOLTIPTEXT>(pnmh);
	if (toolTipText->hdr.code != TTN_NEEDTEXT) {
		return false;
	}
	int resId = static_cast<int>(toolTipText->hdr.idFrom);
	rLoader->loadString(resId, &m_strToolTip);
	toolTipText->lpszText = const_cast<TCHAR *>(m_strToolTip.getString());
	return true;
}
Exemplo n.º 16
0
PlayGraphics::PlayGraphics(sf::RenderWindow& window)
	:m_window(window)
{
	m_button.setSize(sf::Vector2f(BUTTON_WIDTH, BUTTON_HEIGHT));
	m_button.setOutlineColor(sf::Color::Black);
	m_button.setFillColor(sf::Color::Transparent);
	m_button.setOutlineThickness(5);

	ResourceLoader resourceLoader;
	resourceLoader.loadFont(m_buttonFont, ResourceLoader::ARCON_FONT);
	m_buttonText.setFont(m_buttonFont);
	m_buttonText.setCharacterSize(20);
}
Exemplo n.º 17
0
void Player::update(float delta)
{
	CCLOG(to_string(this->getPosition().y).c_str());
	distanceTravelled++;
	framePassed--;

	if (this->getPhysicsBody()->getVelocity().y > 1000)
	{
		this->getPhysicsBody()->setVelocity(Vec2(this->getPhysicsBody()->getVelocity().x, 0));
	}
	if (this->getPosition().y < Director::getInstance()->getWinSize().height / GROUND_PERCENTAGE_FOR_BOX)
	{
		this->getPhysicsBody()->setVelocity(Vec2(this->getPhysicsBody()->getVelocity().x, 0));
		this->setPosition(Vec2(this->getPosition().x, Director::getInstance()->getWinSize().height / GROUND_PERCENTAGE_FOR_BOX));
	}
	if (this->currentAction != Action::RUNNING 
		&& this->getPhysicsBody()->getVelocity().y > -1.0f
		&& this->getPhysicsBody()->getVelocity().y < 1.0f)
	{
		// Get resource loader instance
		ResourceLoader resLoader = ResourceLoader::getInstance();

		// Get running animation
		Vector<SpriteFrame*> runningAnimation = resLoader.getAnimation(PLAYER_ANIMATION_RUNNING);

		auto animation = Animation::createWithSpriteFrames(runningAnimation);
		animation->setDelayPerUnit(PLAYER_SPRITE_DELAY_RUNNING);
		auto runningAction = RepeatForever::create(Animate::create(animation));
		runningAction->setTag(PLAYER_ANIMATION_RUNNING);
		this->runAction(runningAction);

		this->currentAction = Action::RUNNING;
	}

	if ((isKeyPressed(EventKeyboard::KeyCode::KEY_LEFT_ARROW) || isKeyPressed(EventKeyboard::KeyCode::KEY_A)) &&(bossMode))
	{
		this->getPhysicsBody()->applyImpulse(Vect(-((Director::getInstance()->getWinSize().height - 600)/32 + 25), 0));
	}

	if ((isKeyPressed(EventKeyboard::KeyCode::KEY_RIGHT_ARROW) || isKeyPressed(EventKeyboard::KeyCode::KEY_D)) &&(bossMode))
	{
		this->getPhysicsBody()->applyImpulse(Vect(((Director::getInstance()->getWinSize().height - 600) / 32 + 25), 0));
	}

	if (invurnerableTime != 0)
		invurnerableTime--;

	if (invurnerable && invurnerableTime == 0)
		invurnerable = false;

}
Exemplo n.º 18
0
// Load the resources for the scene from a resource loader
void MainMenu::load(const ResourceLoader& resourceLoader)
{
	Color normalColor(100, 100, 0), selectedColor(255, 255, 0);
	Font menuFont = resourceLoader.loadFont("mainMenu.ttf", 42);
	
	Game* game = getGame();

	_mainMenu.addElement(
		menuFont,
		"Play",
		normalColor,
		selectedColor);

	_mainMenu.addElement(
		menuFont,
		"Settings",
		normalColor,
		selectedColor);

	_mainMenu.addElement(
		menuFont,
		"Quit",
		normalColor,
		selectedColor,
		[&game](){
			game->quit();
		});
}
Exemplo n.º 19
0
void renderBackgrounds(double viewLeft, const ResourceLoader& resources)
{
	// render background
	auto tBehindSun = resources.getTextures().getBackgroundTextureBehindSun().scale(2);
	auto tSun = resources.getTextures().getBackgroundSunTexture().scale(2);
	auto tFrontSun = resources.getTextures().getBackgroundTextureFrontSun().scale(2);

	auto map_offset_slow = Math::Fmod(viewLeft * 0.1f, Map::instance().width() * 8.0);
	auto map_offset_slowest = Math::Fmod(viewLeft * 0.05f, 320.0 + 96.0);

	tBehindSun.draw(Vec2(int(-map_offset_slow), 0.0f) * 2);
	tBehindSun.draw(Vec2(int(320.0f - map_offset_slow), 0.0f) * 2);
	tSun.draw(Vec2(int(320.0f - map_offset_slowest) * 2, Window::Height() / 3.0));
	tFrontSun.draw(Vec2(int(-map_offset_slow), 0.0f) * 2);
	tFrontSun.draw(Vec2(int(320.0f - map_offset_slow), 0.0f) * 2);
}
Exemplo n.º 20
0
void Game::Impl::mountArchives(ResourceLoader &loader)
{
    Logger::warning( "Game: mount archives begin" );

    std::string errorStr;
    std::string c3res = SETTINGS_STR( c3gfx );
    if( !c3res.empty() )
    {
        vfs::Directory gfxDir( c3res );
        vfs::Path c3sg2( "c3.sg2" );
        vfs::Path c3path = gfxDir/c3sg2;

        if( !c3path.exist( vfs::Path::ignoreCase ) )
        {
            errorStr = "This game use resources files (.sg2, .map) from Caesar III(c), but "
                       "original game archive c3.sg2 not found in folder " + c3res +
                       "!!!.\nBe sure that you copy all .sg2, .map and .smk files placed to resource folder";
            SETTINGS_SET_VALUE( c3gfx, std::string( "" ) );
            game::Settings::save();
        }

        loader.loadFromModel( SETTINGS_RC_PATH( sg2model ), gfxDir );
        engine->setFlag( Engine::batching, false );
    }
    else
    {
        vfs::Path testPics = SETTINGS_RC_PATH( picsArchive );
        if( !testPics.exist() )
        {
            SETTINGS_SET_VALUE( resourcePath, Variant("") );
            errorStr = "Not found graphics package. Use precompiled CaesarIA archive or use\n"
                       "-c3gfx flag to set absolute path to Caesar III(r) installation folder,\n"
                       "forexample, \"-c3gfx c:/games/caesar3/\"";
        }

        loader.loadFromModel( SETTINGS_RC_PATH( remakeModel ) );
    }

    if( !errorStr.empty() )
    {
        OSystem::error( "Resources error", errorStr );
        Logger::warning( "CRITICAL: not found original resources in " + c3res );
        exit( -1 ); //kill application
    }

    loader.loadFromModel( SETTINGS_RC_PATH( archivesModel ) );
}
Exemplo n.º 21
0
void Player::isDead()
{
	// Don't kill him if he's already dead
	if (dead) { return; }

	// Remember if he's dead or not
	dead = true;

	// Get the 'dead' sprite
	ResourceLoader resLoader = ResourceLoader::getInstance();

	//Stop running animation and replace the sprite png to the DEAD one
	this->getActionManager()->removeActionByTag(PLAYER_ANIMATION_RUNNING, this);
	
	// Reinitialize with 'dead' sprite
	this->initWithFile(resLoader.getImageFile(PLAYER_ANIMATION_DEAD));
}
Exemplo n.º 22
0
NAMESPACE_RESOURCES_BEGIN

//-----------------------------------//

void ResourceTaskRun(Task* task)
{
	ResourceLoadOptions* options = (ResourceLoadOptions*) task->userdata;

	Stream* stream = options->stream;
	Resource* resource = options->resource;
	const Path& path = resource->getPath();
	
	ResourceManager* res = GetResourceManager();
	ResourceLoader* loader = res->findLoader( PathGetFileExtension(path) );

	bool decoded = loader->decode(*options);

	if( !decoded )
	{
		resource->setStatus( ResourceStatus::Error );
		LogWarn("Error decoding resource '%s'", path.CString());
		goto cleanup;
	}

	resource->setStatus( ResourceStatus::Loaded );

	LogInfo("Loaded resource '%s'", path.CString());

	if( options->sendLoadEvent )
	{
		ResourceEvent event;
		event.resource = resource;
		res->resourceEvents.push_back(event);
	}

cleanup:

	res->numResourcesQueuedLoad.decrement();
	res->resourceFinishLoad->wakeOne();

	if( !options->keepStreamOpen )
		Deallocate(stream);

	Deallocate(options);
}
Exemplo n.º 23
0
void renderMap(double viewOffset, const ResourceLoader& resources)
{
	// map
	Map::instance().render([&](int x, int y, int d)
	{
		resources.getTextures().getMapchipTexture(d)
			.scale(2).draw(Vec2(Math::Floor(x * 16.0f - Math::Fmod(viewOffset, Map::instance().width() * 8.0)), y * 16.0f) * 2);
	});
}
	bool ResourceCompilerImpl::compile(const char* fileName, std::map<std::string, std::string>& options) {
		std::cout << "Compiling " << fileName << std::endl;

		engine::Hashed id(fileName);

		if(resourcesCompiled.count(id) > 0) {
			std::cout << fileName << " already compiled" << std::endl;
			return true;
		}

		ResourceLoader* loader = findLoader(engine::file::getExtension(fileName).c_str());

		resourcesCompiled.insert(id);
		loader->compileResource(fileName, options);

		std::cout << "Compiled " << fileName << std::endl;
		return true;
	}
Exemplo n.º 25
0
void initialize(ClimateType climate)
{
    VariantMap climateArchives = config::load( SETTINGS_RC_PATH( climateModel ) );

    std::string optName;
    if( climate == central ) {
        optName = CAESARIA_STR_A(central);
    }
    else if( climate == northen )  {
        optName = "north";
    }
    else if( climate == desert ) {
        optName = "south";
    }

    StringArray archives = climateArchives.get( optName ).toStringArray();

    for( auto& str : archives )
    {
        Path archivePath = str;
        Directory dir = archivePath.directory();

        archivePath = dir.find( archivePath.baseName(), Path::ignoreCase );

        ArchivePtr archive = FileSystem::instance().mountArchive( archivePath );

        if( archive.isNull() )
        {
            Logger::warning( "ClimateManager: can't load file " + archivePath.toString() );
            continue;
        }

        ResourceLoader rc;
        NFile atlasInfo = archive->createAndOpenFile( "info" );
        if( atlasInfo.isOpen() )
        {
            rc.loadAtlases( atlasInfo, false );
        }
        else
        {
            rc.loadFiles( archive );
        }
    }
}
Exemplo n.º 26
0
void SkyWrapper::Enable()
{
	


	Controller * ctrl = static_cast<Controller*>(GetManager()->Get("Controller"));
	DataManager * dm = static_cast<DataManager*>(GetManager()->Get("DataManager"));




	ResourceLoader * res = static_cast<ResourceLoader*>(dm->Get("Resources"));
	Environment * env = static_cast<Environment*>(res->Get("Environment"));
	Camera * camera = static_cast<Camera*>(ctrl->Get("Camera"));
	ViewInfo * info = camera->GetInfo();
	View * view = camera->GetView();





	glm::mat4 m_rot = Math::Rotate(0, glfwGetTime() / 150.0, 0);
	glm::mat4 ModelMatrix = Math::Translation(info->getCameraPos() - info->getDirection()*info->getDistance())*
		m_rot*
		Math::Scale(glm::vec3(info->getRenderDistance()));




	Shader::Enable();
	Shader::Set("cube", 0);
    Shader::Set("MVP", view->getCamera()*ModelMatrix);
	Shader::Set("MV", view->getViewMatrix() * ModelMatrix);
	glm::vec4 f = glm::vec4(env->fog_color, 1.0);
	Shader::Set("fog_color", f);



	SkyRender::Enable();
	Shader::Stop();



}
Exemplo n.º 27
0
/*static*/
std::vector<Vector3>
EngineHelper::LoadDravenVerts(){
	vector<glm::vec3> out_vertices = vector<glm::vec3>(); 
	vector<glm::vec2> out_uvs = vector<glm::vec2>(); 
	vector<glm::vec3> out_normals = vector<glm::vec3>(); 

	vector<Vector3> ret = vector<Vector3>(); 

	ResourceLoader loader =  ResourceLoader();
	vector<Vector3> manequinVerts = vector<Vector3>(); 
	loader.LoadMeshOBJ("D:/Tools/Development/Dropbox/Workspaces/WorkspaceCpp/Kevlar3D/K3Res/cube.obj",out_vertices,out_uvs,out_normals);

	int meshSize = out_vertices.size();
	for (int i=0;i<meshSize;i++){
		ret.push_back(Vector3(out_vertices.at(i)));
	}
		
	return ret;
}
Exemplo n.º 28
0
std::string ResourceManager::GetFilename( const std::string& path, const ResourceLoader& loader ) {
	std::string ident( loader.GetIdentifier() + ":" );
	std::size_t ident_pos( path.find( ident ) );

	if( ident_pos == std::string::npos || ident_pos != 0 ) {
		return path;
	}

	return path.substr( ident.size() );
}
Exemplo n.º 29
0
std::shared_ptr<AudioClip> AudioClip::loadResource(ResourceLoader& loader)
{
	bool streaming = loader.getMeta().getBool("streaming", false);
	int channels = loader.getMeta().getInt("channels", 1);
	auto result = std::make_shared<AudioClip>(size_t(channels));

	if (streaming) {
		std::shared_ptr<ResourceDataStream> stream = loader.getStream();
		Concurrent::execute([stream, result] ()	{
			result->loadFromStream(stream);
		});
	} else {
		loader
			.getAsync()
			.then([result](std::unique_ptr<ResourceDataStatic> data) {
				result->loadFromStatic(std::shared_ptr<ResourceDataStatic>(std::move(data)));
			});
	}

	return result;
}
Exemplo n.º 30
0
void ViewerWindow::changeCursor(int type)
{
	HCURSOR hcur = 0;

	ResourceLoader *rLoader = ResourceLoader::getInstance();
	switch (type) {
	case ConnectionConfig::DOT_CURSOR:
		hcur = rLoader->loadCursor(IDI_CDOT);
		break;
	case ConnectionConfig::SMALL_CURSOR:
		hcur = rLoader->loadCursor(IDI_CSMALLDOT);
		break;
	case ConnectionConfig::NO_CURSOR:
		hcur = rLoader->loadCursor(IDI_CNOCURSOR);
		break;
	case ConnectionConfig::NORMAL_CURSOR:
		hcur = rLoader->loadStandardCursor(IDC_ARROW);
		break;
	}
	setClassCursor(hcur);
}