当前位置: 首页>>代码示例>>C++>>正文


C++ TextureManager::loadTexture方法代码示例

本文整理汇总了C++中TextureManager::loadTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureManager::loadTexture方法的具体用法?C++ TextureManager::loadTexture怎么用?C++ TextureManager::loadTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextureManager的用法示例。


在下文中一共展示了TextureManager::loadTexture方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: unloadPlayerStats

void RebelleUpgradeScreenGUI::unloadPlayerStats()
{
	Game* game = Game::getSingleton();
	GameGraphics *graphics = game->getGraphics();
	TextureManager *guiTextureManager = graphics->getGUITextureManager();

	unsigned int speedIconTID = guiTextureManager->loadTexture(SPEED_ICON_PATH);
	unsigned int attackIconTID = guiTextureManager->loadTexture(ATTACK_ICON_PATH);
	unsigned int defenseIconTID = guiTextureManager->loadTexture(DEFENSE_ICON_PATH);

	list<OverlayImage*>* overlayImageList = this->getOverlayImageList();

	list<OverlayImage*>::iterator it = overlayImageList->begin();
	while (it != overlayImageList->end())
	{
		OverlayImage* image = *it;
		it++;

		if (image->imageID == speedIconTID
			|| image->imageID == attackIconTID
			|| image->imageID == defenseIconTID)
		{
			overlayImageList->remove(image);
			delete image;
		}
	}
}
开发者ID:bsbae402,项目名称:Rebelle_repo,代码行数:27,代码来源:RebelleUpgradeScreenGUI.cpp

示例2: loadSpriteTypes

/*
	This method loads all the sprite types found in the provided sprite type list file
	into the game state manager, including their images.
*/
bool PoseurSpriteTypesImporter::loadSpriteTypes(Game *game, wstring spriteTypesListFileName)
{
	int slashIndex = spriteTypesListFileName.rfind('/');
	dir = string(spriteTypesListFileName.begin(), spriteTypesListFileName.end()).substr(0, slashIndex+1);
	const char *spriteTypesListFile = newCharArrayFromWstring(spriteTypesListFileName);
	bool success = loadSpriteTypesListInfo(spriteTypesListFile);
	if (!success) return false;
	for (unsigned int i = 0; i < spriteTypes.size(); i++)
	{
		success = loadSpriteTypeInfo(spriteTypes[i]);
		if (!success) return false;
	}

	TextureManager *tm = game->getGraphics()->getWorldTextureManager();
	WStringTable *wStringTable = tm->getWStringTable();

	// NOW LET'S USE ALL THE INFO WE'VE LOADED 
	// LET'S START BY LOADING THE TEXTURES INTO THE WORLD TEXTURE MANAGER
	for (unsigned int i = 0; i < spriteTypes.size(); i++)
	{
		string spriteType = spriteTypes[i];
		unsigned int offset = wStringTable->getNumWStringsInTable();
		map<int, string> images = spriteTypesImages[spriteType];
		for (int j = 0; j < images.size(); j++)
		{
			string imageToLoad = images[j];
			wstring wImageToLoad(imageToLoad.begin(), imageToLoad.end());
			tm->loadTexture(wImageToLoad);
		}

		AnimatedSpriteType *ast = new AnimatedSpriteType();
		unsigned int spriteTypeId = game->getGSM()->getSpriteManager()->addSpriteType(ast);
		ast->setSpriteTypeID(spriteTypeId);
		Dimensions dim = spriteTypesDimensions[spriteType];
		ast->setTextureSize(dim.width, dim.height);
		
		map<string, vector<Pose>> animations = spriteTypesAnimationsLists[spriteType];
		map<string, vector<Pose>>::iterator it = animations.begin();
		while (it != animations.end())
		{
			string key = it->first;
			wstring wKey(key.begin(), key.end());
			ast->addAnimationSequence(wKey);
			vector<Pose> poseList = it->second;
			vector<Pose>::iterator poseIt = poseList.begin();
			while (poseIt != poseList.end())
			{
				Pose pose = *poseIt;
				ast->addAnimationFrame(wKey, pose.imageId + offset - 1, pose.duration);
				poseIt++;
			}				
			it++;
		}
	}


	return true;
}
开发者ID:CSE380Skulls,项目名称:ForceOfReaction,代码行数:62,代码来源:PoseurSpriteTypesImporter.cpp

示例3: buildImageLayer

void TMXMapImporter::buildImageLayer(Game *game, ImageLayerInfo *ili, int idOffset)
{
	TiledLayer *imageLayerToAdd = new TiledLayer(	1,
													1,
													ili->imagewidth,
													ili->imageheight,
													0,
													ili->collidable,
													largestLayerWidth,
													largestLayerHeight);
	game->getGSM()->getWorld()->addLayer(imageLayerToAdd);
	TextureManager *textureManager = game->getGraphics()->getWorldTextureManager();
	Tile *imageTile = new Tile();
	imageTile->collidable = ili->collidable;
	wstring imageSourceW(ili->imageSource.begin(), ili->imageSource.end());
	imageTile->textureID = textureManager->loadTexture(dir + imageSourceW) + idOffset - 1;
	imageLayerToAdd->addTile(imageTile);
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例4: View

ImageView::ImageView(const char *name, float w, float h) : View() {
	figure = NULL;
	clickable = false;
	
	ApplicationController *ctl = ApplicationController::getInstance();
	TextureManager *texMgr = ctl->texMgr;
	Texture *tex = NULL;
	SharedTexture *stex = NULL;
	if ((stex = texMgr->findSharedTexture(name))) {
		if (w > 0 && h > 0) {
			this->setFigure(stex->makePlateWithSize(name, w, h));
		} else if (w > 0) {
			this->setFigure(stex->makeFixPlate(name, w));
		} else {
			this->setFigure(stex->makePlate(name));
		}
		this->setTexture(stex);
	} else if ((tex = texMgr->loadTexture(name))) {
		this->setFigure(tex->makePlate());
		this->setTexture(tex);
	}
}
开发者ID:gclue,项目名称:GCube,代码行数:22,代码来源:ImageView.cpp

示例5: buildWorldFromInfo

bool TMXMapImporter::buildWorldFromInfo(Game *game)
{
	TextureManager *worldTextureManager = game->getGraphics()->getWorldTextureManager();
	if (mapType == MapType::ORTHOGONAL_MAP)
	{
		World *world = game->getGSM()->getWorld();
		int largestLayerWidth = 0;
		int largestLayerHeight = 0;

		// LET'S FIRST FIGURE OUT THE WORLD WIDTH AND HEIGHT

		// FIRST THE IMAGE LAYERS
		map<string, ImageLayerInfo>::const_iterator iliIt = imageLayerInfos.begin();
		while (iliIt != imageLayerInfos.end())
		{
			string key = iliIt->first;
			ImageLayerInfo ili = imageLayerInfos[key];
			if (ili.imagewidth > largestLayerWidth)
				largestLayerWidth = ili.imagewidth;
			if (ili.imageheight > largestLayerHeight)
				largestLayerHeight = ili.imageheight;

			iliIt++;
		}
		// AND THE TILED LAYERS
		map<string, TiledLayerInfo>::const_iterator tliIt = tiledLayerInfos.begin();
		while (tliIt != tiledLayerInfos.end())
		{
			string key = tliIt->first;
			TiledLayerInfo tli = tiledLayerInfos[key];
			int layerWidth = tli.width * tli.tileSetInfo->tilewidth;
			if (layerWidth > largestLayerWidth)
				largestLayerWidth = layerWidth;
			int layerHeight = tli.height * tli.tileSetInfo->tileheight;
			if (layerHeight > largestLayerHeight)
				largestLayerHeight = layerHeight;
			tliIt++;
		}
		unsigned int idOffset = worldTextureManager->getWStringTable()->getNumWStringsInTable();

		// FIRST LOAD ALL THE TILE SETS
		map<string, TileSetInfo>::const_iterator tsiIt = tileSetInfos.begin();
		while (tsiIt != tileSetInfos.end())
		{
			string key = tsiIt->first;
			TileSetInfo tsi = tileSetInfos[key];
			wstring sourceImageW(tsi.sourceImage.begin(), tsi.sourceImage.end());
			bool success = worldTextureManager->loadTileSetFromTexture(game, dir, sourceImageW, tsi.tilewidth, tsi.tileheight);
			if (!success) return false;
			tsiIt++;
		}

		// NOW LOAD THE IMAGE LAYERS, IF THERE ARE ANY
		iliIt = imageLayerInfos.begin();
		while (iliIt != imageLayerInfos.end())
		{
			string key = iliIt->first;
			ImageLayerInfo ili = imageLayerInfos[key];
			
			TiledLayer *imageLayerToAdd = new TiledLayer(	1,
				1,
				ili.imagewidth,
				ili.imageheight,
				0,
				ili.collidable,
				largestLayerWidth,
				largestLayerHeight);
			world->addLayer(imageLayerToAdd);

			Tile *imageTile = new Tile();
			imageTile->collidable = ili.collidable;
			wstring imageSourceW(ili.imageSource.begin(), ili.imageSource.end());
			imageTile->textureID = worldTextureManager->loadTexture(dir + imageSourceW);
			imageLayerToAdd->addTile(imageTile);
	
			iliIt++;
		}

		// AND NOW LOAD THE TILED LAYERS, WHICH REFERENCE THE TILE SETS
		tliIt = tiledLayerInfos.begin();
		while (tliIt != tiledLayerInfos.end())
		{
			// @TODO WE'LL NEED TO CUSTOMIZE THIS
			bool collidableLayer = false;
			string key = tliIt->first;
			TiledLayerInfo tli = tiledLayerInfos[key];
			TiledLayer *tiledLayerToAdd = new TiledLayer(	tli.width,
															tli.height,
															tli.tileSetInfo->tilewidth,
															tli.tileSetInfo->tileheight,
															0,
															tli.collidable,
															largestLayerWidth,
															largestLayerHeight);
			world->addLayer(tiledLayerToAdd);

			// WE HAVE TO ADD ALL THE TILES
			int row = 0;
			int col = 0;
			int uncollidableIndex = tli.tileSetInfo->firstgid;
//.........这里部分代码省略.........
开发者ID:DavidLui,项目名称:-CSE380-Balloon-Escape,代码行数:101,代码来源:TMXMapImporter.cpp

示例6: loadPlayerStats

void RebelleUpgradeScreenGUI::loadPlayerStats()
{
	Game* game = Game::getSingleton();
	GameStateManager* gsm = game->getGSM();
	SpriteManager* spriteMgr = gsm->getSpriteManager();
	GameGraphics *graphics = game->getGraphics();
	TextureManager *guiTextureManager = graphics->getGUITextureManager();

	PlayerSprite *player = spriteMgr->getPlayer();
	int speed = player->getSpeed();
	int attack = player->getAttack();
	int defense = player->getDefense();
	unsigned int speedIconTID = guiTextureManager->loadTexture(SPEED_ICON_PATH);
	unsigned int attackIconTID = guiTextureManager->loadTexture(ATTACK_ICON_PATH);
	unsigned int defenseIconTID = guiTextureManager->loadTexture(DEFENSE_ICON_PATH);

	//// - first speed icon will be rendered at 20px right to upgrade button
	int speedIconY = statListY + statLineHeight + ydistBetweenStats;
	int nextSpeedIconX = statListX + statTitleWidth + statTitleWidth + upgradeButtonWidth + 20;
	for (int i = 0; i < speed; i++)
	{
		OverlayImage *speedIcon = new OverlayImage();
		speedIcon->alpha = 255;
		speedIcon->width = STAT_ICON_WIDTH;
		speedIcon->height = STAT_ICON_HEIGHT;
		speedIcon->x = nextSpeedIconX;
		speedIcon->y = speedIconY;
		speedIcon->z = 0;
		speedIcon->imageID = speedIconTID;

		this->addOverlayImage(speedIcon);
		nextSpeedIconX += STAT_ICON_WIDTH + 3;
	}

	//// attack icons should be next to Attack stat title and the button.
	int attackIconY = speedIconY + statLineHeight + ydistBetweenStats;
	int nextAttackIconX = statListX + statTitleWidth + statTitleWidth + upgradeButtonWidth + 20;
	for (int i = 0; i < attack; i++)
	{
		OverlayImage *attackIcon = new OverlayImage();
		attackIcon->alpha = 255;
		attackIcon->width = STAT_ICON_WIDTH;
		attackIcon->height = STAT_ICON_HEIGHT;
		attackIcon->x = nextAttackIconX;
		attackIcon->y = attackIconY;
		attackIcon->z = 0;
		attackIcon->imageID = attackIconTID;

		this->addOverlayImage(attackIcon);
		nextAttackIconX += STAT_ICON_WIDTH + 3;
	}

	//// defense icons
	int defenseIconY = attackIconY + statLineHeight + ydistBetweenStats;
	int nextDefenseIconX = statListX + statTitleWidth + statTitleWidth + upgradeButtonWidth + 20;
	for (int i = 0; i < attack; i++)
	{
		OverlayImage *defenseIcon = new OverlayImage();
		defenseIcon->alpha = 255;
		defenseIcon->width = STAT_ICON_WIDTH;
		defenseIcon->height = STAT_ICON_HEIGHT;
		defenseIcon->x = nextDefenseIconX;
		defenseIcon->y = defenseIconY;
		defenseIcon->z = 0;
		defenseIcon->imageID = defenseIconTID;

		this->addOverlayImage(defenseIcon);
		nextDefenseIconX += STAT_ICON_WIDTH + 3;
	}
}
开发者ID:bsbae402,项目名称:Rebelle_repo,代码行数:70,代码来源:RebelleUpgradeScreenGUI.cpp

示例7: main

int main()
{

	if (!glfwInit())
	{
		fprintf(stderr, "Failed to initialize GLFW\n");
		return -1;
	}

	glfwWindowHint(GLFW_SAMPLES, 4);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

	//int w = 1024;
	int w = 768;
	int h = 768;
	window = glfwCreateWindow(w, h,
		"Cyborg-Engine", NULL, NULL);
	if (window == NULL){
		fprintf(stderr, "Failed to open GLFW window.");
		glfwTerminate();
		return -1;
	}
	glfwMakeContextCurrent(window);
	glfwSetFramebufferSizeCallback(window, Renderer::FramebufferSizeCallback);
	glfwSetKeyCallback(window, Renderer::key_callback);
	Renderer::FramebufferSizeCallback(window, w, h);
	glewExperimental = true; // Needed for core profile
	if (glewInit() != GLEW_OK) {
		fprintf(stderr, "Failed to initialize GLEW\n");
		return -1;
	}

	glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);

	Renderer::initRender(window);

	//load resources:
	TextureManager* TM = TextureManager::getInstance();

	TM->loadTexture("testi", "./textures/polygon.png");
	TM->loadTexture("part", "./textures/particle2.png");
	TM->loadTexture("sheet","./textures/spriteSheetTest.png");
	float a = 0;
	float b = 0;			// For rotation
	float spriteTimer = 0;
	int spriteNumber = 0;

	PointSprite ps(0, 0, "part");
	
	//sprite stuff
	Sprite aa;
	aa.setUp(6,5);
	glm::vec2 rain[50];
	for (int i = 0; i < 50; i++)
	{
		rain[i] = glm::vec2((float)(rand() % 2000) / 1000 - 1.0, (float)(rand() % 2000) / 1000 - 1.2);
	}

	Polygon p;
	
	glm::vec2 points[]
	{

		glm::vec2(0.0, 0.21),
			glm::vec2(0.05, 0.05),
			glm::vec2(0.4, 0.0),
			glm::vec2(0.05, -0.05),
			glm::vec2(0.0, -0.21),
			glm::vec2(-0.05, -0.05),
			glm::vec2(-0.4, 0.0),
			glm::vec2(-0.05, 0.05),
	};
	p.setPoints(points, 8);
	p.setOrigin(-0.5, 0.0);

	Circle c;
	c.setPrecision(8);

	bool isEnterPressed = false;
	int scene = 0;

    //INITIALIZATION FOR NP_PHYSICS STUFF -------------------------------------------------------------------- START
    // Creating physics world
    NP_World world;
    // Creating objects
    NP_Object testObj, testObj2, testObj3, testObj4, testObj5, testObj6;
    // Creating bodies to the world
    NP_Body testBody(world, 2.f), testBody2(world, 1.f), testBody3(world, 1.f), testBody4(world, 0.5f), testBody5(world, 0.5f), testBody6(world, 100.f);

    //testBody3.m_mass = 10.f;
    


    // Binding objects to bodies
    testObj.bindBody(&testBody);
    testObj2.bindBody(&testBody2);
    testObj3.bindBody(&testBody3);
    testObj4.bindBody(&testBody4);
//.........这里部分代码省略.........
开发者ID:Purilainen,项目名称:NP_Physics,代码行数:101,代码来源:Source.cpp


注:本文中的TextureManager::loadTexture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。