//=======================================================================
// Load Textures Function
//=======================================================================
void LoadTextures()
{
	Player_Ship_Texture		= texManager.LoadTexture("Alpha.bmp", true);
	explosionTex	= texManager.LoadTexture("explosion.bmp", false);
	enemyTexI		= texManager.LoadTexture("ship6_0.bmp", true);
	enemyTexII		= texManager.LoadTexture("enemyII.bmp", true);
}
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;
		}
	}
}
Beispiel #3
0
void Item::Draw(sf::RenderWindow& renderWindow, sf::Text &text)
{
	TextureManager *t = Resources::getTextureManager("tileMap");
		sf::Sprite s;
		sf::Vector2f item_pos = GetPosition();
		t->generateSprite(id, item_pos, s, sf::Vector2f(GetWidth(),GetHeight()));
		renderWindow.draw(s);



	sf::Vector2f test_pos = GetPosition();
	text.setPosition(test_pos.x, test_pos.y);
	text.setScale(sf::Vector2f(1.5,1.5));
	renderWindow.draw(text);
		//renderWindow.draw(_sprite);
		/*if(amount >0){
			char c[10];
			sprintf(c, "%i", amount);
			std::string string(c);
			sf::String str(string);
			text.setString(str);
			text.setPosition(GetPosition().x, GetPosition().y);
			renderWindow.draw(text);	
		}*/

}
Beispiel #4
0
void MainMenu::initMap(sf::RenderWindow &window, TextureManager &textureManager)
{
	//hardcoded positions

	backgroundSprite.setTexture(*textureManager.getResource("Config/Content/Images/Menus/Backgrounds/MainMenuBackground.png"));

	sf::RectangleShape playButton;
	playButton.setSize(sf::Vector2f(143.0f, 72.0f));
	playButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/playButton.png"));
	playButton.setPosition(window.getSize().x / 2 - playButton.getSize().x / 2, 210);

	sf::RectangleShape creditsButton;
	creditsButton.setSize(sf::Vector2f(213.0f, 72.0f));
	creditsButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/creditsButton.png"));
	creditsButton.setPosition(window.getSize().x / 2 - creditsButton.getSize().x / 2, 295);

	sf::RectangleShape highScoresButton;
	highScoresButton.setSize(sf::Vector2f(338.0f,72.0f));
	highScoresButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/highScoreButton.png"));
	highScoresButton.setPosition(window.getSize().x / 2 - highScoresButton.getSize().x / 2, 380);

	sf::RectangleShape exitButton;
	exitButton.setSize(sf::Vector2f(134.0f,72.0f));
	exitButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/exitButton.png"));
	exitButton.setPosition(window.getSize().x / 2 - exitButton.getSize().x / 2, 465);

	menuItems[PLAY] = playButton;
	menuItems[CREDITS] = creditsButton;
	menuItems[HIGHSCORES] = highScoresButton;
	menuItems[EXIT] = exitButton;
}
Beispiel #5
0
	void WPN_Init(TextureManager& textureManager, Sound& sound, Console& console)
	{
		std::set<Int32> nearestFilterBoom = { 5, 6, 9, 13, 14, 15, 16 };

		console.printLine("\n===Weapon initialization===");
		for (Weapon& weap : d6WpnDef)
		{
			const std::string wpnPath = Format("{0}{1,3|0}") << D6_TEXTURE_WPN_PATH << weap.index;
			weap.textures.boom = textureManager.load(Format("{0}/boom/") << wpnPath, nearestFilterBoom.find(weap.index) != nearestFilterBoom.end() ? GL_NEAREST : GL_LINEAR, true);
			weap.textures.gun = textureManager.load(Format("{0}/gun/") << wpnPath, GL_NEAREST, true);
			weap.textures.shot = textureManager.load(Format("{0}/shot/") << wpnPath, GL_NEAREST, true);

			if (weap.shotSound)
			{
				weap.shotSample = sound.loadSample(std::string(D6_FILE_WEAPON_SOUNDS) + weap.shotSound);
			}
			if (weap.boomSound)
			{
				weap.boomSample = sound.loadSample(std::string(D6_FILE_WEAPON_SOUNDS) + weap.boomSound);
			}
		}

		Color brownColor(83, 44, 0);
		PlayerSkinColors skinColors(brownColor);
		brownSkin = std::make_unique<PlayerSkin>("textures/man/", skinColors, textureManager);
	}
Beispiel #6
0
const sf::Texture* GuiHelper::getUnitTexture(UNITTYPES type, int playerId)
{
	std::string textureName = "p" + std::to_string(playerId);

	switch(type)
    {
    case EUT_SWORDMAN:
        textureName += "swordman";
        break;
    case EUT_ARCHER:
        textureName += "archer";
        break;
    case EUT_SPEARMAN:
        textureName += "spearman";
        break;
    case EUT_LADDERCARRIER:
        textureName += "laddercarrier";
        break;
    default:
        textureName = "";
        break;
    }

    TextureManager* textureManager = TextureManager::getInstance();
    const sf::Texture* texture = textureName != "" ? textureManager->getTexture(textureName) : textureManager->getFallbackTexture();
    return texture;
}
Beispiel #7
0
void InitApp(float width, float height)
{
	vec2 min, max;
	//fill in the blank
	min.x = -width/2;
	min.y = -height/2;
	max.x = width/2;
	max.y = height/2;

	pApp = new App();
	Screen* pScreen = new Screen(min.x, min.y, max.x, max.y); // create the screen so you can start using gl functions!
	//programs
	ProgramManager* pProgramManager = ProgramManager::GetProgramManager();
	int programID = pProgramManager->CreateProgram("vertex2.vert", "fragment2.frag");
	pProgramManager->AddProgram("program1", programID);
	//now add textures and programs to the App
	TextureManager* pTextureManager = TextureManager::GetTextureManager();
	pTextureManager->AddTexture("images/picture.png");
	
	//add objects
	vec2 quadDimensions = {512.0f, 512.0f};
	GLuint indices[6] = {0, 1, 3, 3, 1, 2};
	pScreen->SetMatrixUniform(); // set the projection matrix
	Quad* pQuad = new Quad(&quadDimensions, indices, 6, "images/picture.png", "program1");
	pScreen->AddObject(pQuad);
	pApp->AddObject(pScreen);
}
	void ObjectClue::draw() {

		if (!_caught) {

			if (isDebug()) {

				float* color = getBoundingSphere(0)->getColor();
				glPushMatrix();

					glDisable(GL_LIGHTING);

					glColor3f(color[0], color[1], color[2]);
					glTranslated(getBoundingSphere(0)->getPosition()[0], getBoundingSphere(0)->getPosition()[1], getBoundingSphere(0)->getPosition()[2]);
					glutWireSphere(getBoundingSphere(0)->getRadius(), 20, 20);

					glEnable(GL_LIGHTING);

				glPopMatrix();
			}

			TextureManager* tm = dynamic_cast<TextureManager*>( cg::Registry::instance()->get("TextureManager"));
			MaterialManager* mm = dynamic_cast<MaterialManager*>( cg::Registry::instance()->get("MaterialManager"));
			GLuint txClue = tm->get("clue")->getTextureDL();
			
			glPushMatrix();
				
				glEnable(GL_TEXTURE_2D);
				//mm->get("emerald")->apply();
				glTranslated(_position[0], _position[1], _position[2] + CLUE_SIZE / 2);
				glScalef(CLUE_SIZE, CLUE_SIZE, CLUE_SIZE);
				unitCube(txClue);
				glDisable(GL_TEXTURE_2D);
			glPopMatrix();
		}
	}
void LODManager::PurgeMesh(ID3DXBaseMesh *mesh, int MeshNum) {
  if (!EnabledLOD.Get())
    return;

  MeshManager *mm = MeshManager::GetSingleton();
  TextureManager *tm = TextureManager::GetSingleton();

  for (int l = 0; l < GRID_LODS; l++)
  for (int x = 0; x < GRID_SIZE; x++)
  for (int y = 0; y < GRID_SIZE; y++) {
    if ((MeshIDs[l][y][x] == MeshNum)) {
      int mid = MeshIDs[l][y][x]; MeshIDs[l][y][x] = 0xFEFEFEFE;
      int cid = ColrIDs[l][y][x]; ColrIDs[l][y][x] = 0xFEFEFEFE;
      int nid = NormIDs[l][y][x]; NormIDs[l][y][x] = 0xFEFEFEFE;

      if (mid != MeshNum) mm->ReleaseMesh   (MeshIDs[l][y][x]);
      if (cid >=       0) tm->ReleaseTexture(ColrIDs[l][y][x]);
      if (nid >=       0) tm->ReleaseTexture(NormIDs[l][y][x]);

      Meshes [l][y][x] = NULL;
      Colors [l][y][x] = NULL;
      Normals[l][y][x] = NULL;
    }
  }
}
void Game::init() {
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
        std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
    }

    systemList = SystemFactory().createSystems();


    graphics = Graphics();
    graphics.clearRenderer();
    isRunning = true;

    TextureManager *manager = new TextureManager(graphics);
    manager->loadTextureWithName("guy.png");
    world.manager.setTextureManager(manager);

    EntityFactory factory;
    Entity guy = factory.createGuy(world);
    Position p;
    p.x = 600;
    p.y = 20;
    ColorMod c;
    c.r = 10;
    c.g = 170;
    c.b = 40;
    
    Entity *z = factory.createZombie(world, p, c);

}
void CarReflection::Create()
{
	//bFirstFrame = true;
	if (pSet->refl_mode == 1)  cubetexName = "ReflectionCube"; // single: use 1st cubemap
	else if (pSet->refl_mode == 2)
	{
		cubetexName = "ReflectionCube" + toStr(iIndex);
		// first cubemap: no index
		if (cubetexName == "ReflectionCube0")
			cubetexName = "ReflectionCube";
	}
	else /* static */
		cubetexName = "ReflectionCube";
	
	TextureManager* tm = TextureManager::getSingletonPtr();
	int size = ciShadowSizesA[pSet->refl_size];  // /2 ?

	//  create cube render texture
	if ( !(pSet->refl_mode == 1 && iIndex != 0) )
	{
		cubetex = tm->createManual(cubetexName, 
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_CUBE_MAP, 
			size,size, 0/*mips*/, PF_R8G8B8, TU_RENDERTARGET);
			//LogO("created rt cube");

		for (int face = 0; face < 6; face++)
		{
			Camera* mCam = pSceneMgr->createCamera("Reflect_" + toStr(iIndex) + "_" + toStr(face));
			mCam->setAspectRatio(1.0f);  mCam->setFOVy(Degree(90));
			mCam->setNearClipDistance(0.1);
			mCam->setFarClipDistance(pSet->refl_dist * 1.1f);

			RenderTarget* mRT = cubetex->getBuffer(face)->getRenderTarget();
			//LogO( "rt face Name: " + mRT->getName() );
			mRT->removeAllViewports();
			Viewport* vp = mRT->addViewport(mCam);
			vp->setOverlaysEnabled(false);
			vp->setVisibilityMask(RV_MaskReflect);
			vp->setShadowsEnabled(false);
			vp->setMaterialScheme ("reflection");
			mRT->setAutoUpdated(false);
			//mRT->addListener(this);  //-
			mCam->setPosition(Vector3::ZERO);

			Vector3 lookAt(0,0,0), up(0,0,0), right(0,0,0);  switch(face)
			{
				case 0:  lookAt.x =-1;  up.y = 1;  right.z = 1;  break;  // +X
				case 1:  lookAt.x = 1;  up.y = 1;  right.z =-1;  break;	 // -X
				case 2:  lookAt.y =-1;  up.z = 1;  right.x = 1;  break;	 // +Y
				case 3:  lookAt.y = 1;  up.z =-1;  right.x = 1;  break;	 // -Y
				case 4:  lookAt.z = 1;  up.y = 1;  right.x =-1;  break;	 // +Z
				case 5:  lookAt.z =-1;  up.y = 1;  right.x =-1;  break;	 // -Z
			}
			Quaternion orient( right, up, lookAt );  mCam->setOrientation( orient );
			pCams[face] = mCam;
			pRTs[face] = mRT;
		}
	}
}
const Texture& getTexture(const std::string& path)
{
	if (!textureManager.isLoaded(path))
	{
		textureManager.load(path);
	}
	return textureManager.get(path);
}
void GUI_Element::ApplyGlyphStyle(){
	const GUI_Style& CurrentStyle = m_style[m_state];
	TextureManager* textures = m_owner->GetManager()->GetContext()->m_textureManager;
	if (CurrentStyle.m_glyph != ""){
		m_visual.m_glyph.setTexture(*textures->GetResource(CurrentStyle.m_glyph));
	}
	m_visual.m_glyph.setPosition(m_position + CurrentStyle.m_glyphPadding);
}
Beispiel #14
0
void _loadTextures(void* arg)
{
	TextureManager* that = (TextureManager*) arg;

	that->loadTextures();

	threadMainLoop = false;
}
/*
	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;
}
CharacterSelectionMenu::CharacterSelectionMenu() : Menu()
{
    this->listAvatars = new vector<sf::Sprite*>();
    this->listValidation = new vector<bool>(NUMBER_FIGHTERS, false);

    Button * button;
    int indexLine = 0, indexColumn = 0;
    vector<bool> * active = new vector<bool>(NUMBER_FIGHTERS, true);
    sf::Sprite * sprite;
    TextureManager * textureManager = GameManager::getInstance()->getTextureManager();
    CharacterManager * characterManager = GameManager::getInstance()->getCharacterManager();
    Position * position;
	for (int i = 0; i < NUMBER_CHARACTERDATA; ++i)
    {
        indexColumn = i % NUMBER_CHARACTER_BY_LINE;
        indexLine = (int)(i / NUMBER_CHARACTER_BY_LINE);
        for (unsigned int j = 0; j < NUMBER_FIGHTERS; ++j)
        {
            position = new Position(POSITION_FIRST_CHARACTER_X + indexColumn * OFFSET_CHARACTER_X, POSITION_FIRST_CHARACTER_Y + indexLine * OFFSET_CHARACTER_Y);
            if (characterManager->getCharactersDataIndex()->size() > j)
            {
                if (characterManager->getCharactersDataIndex()->at(j) == i)
                    this->listButtons->push_back(new Button("", position, true, true, false, j));
                else
                    this->listButtons->push_back(new Button("", position, true, false, false, j));
                active->at(j) = false;
            }
            else
            {
                this->listButtons->push_back(new Button("", position, true, active->at(j), false, j));
                active->at(j) = false;
            }
            button = this->listButtons->at(this->listButtons->size() - 1);
            button->setAction(&Menu::actionValidateCharacter);
            button->setActionMove(&Menu::listMove);
        }

        this->listAvatars->push_back(new sf::Sprite());
        sprite = this->listAvatars->at(this->listAvatars->size() - 1);
        sprite->setTexture(*textureManager->getTexture(characterDataArray[i].getPathAvatar()));
        sprite->setPosition((float)(position->getX() - sprite->getTextureRect().width / 2), (float)(position->getY() - sprite->getTextureRect().height / 2));
    }
    characterManager->getCharactersDataIndex()->clear();

    // Button back
	this->listButtons->push_back(new Button("Back", new Position(POSITION_BACK_X, POSITION_BACK_Y), true, false, true, 0));
	button = this->listButtons->at(this->listButtons->size() - 1);
	button->setAction(&Menu::actionBack);
	button->setActionMove(&Menu::classicMove);

	this->title->setString("SELECT YOUR FIGHTER");
	this->title->setFont(*(GameManager::getInstance()->getFontManager()->getFont(TITLE_PLAYER_FONT)));
	this->title->setScale((float)TITLE_PLAYER_SCALE_X, (float)TITLE_PLAYER_SCALE_Y);
	this->title->setPosition((float)(POSITION_TITLE_PLAYER_X), (float)(POSITION_TITLE_PLAYER_Y));
    this->title->setColor(sf::Color(TITLE_PLAYER_COLOR_RED, TITLE_PLAYER_COLOR_GREEN, TITLE_PLAYER_COLOR_BLUE));

	this->spriteMenu->setTexture(*GameManager::getInstance()->getTextureManager()->getTexture(FILE_MENU_SELECTION));
}
Beispiel #17
0
	void TextureUnit::LoadTexture(void)
        {   
                TextureManager* texMgr = TextureManager::getSingleton();
                if(texMgr)
                {
                        texMgr->LoadTexture(this->mPicName);
                }

        } 
Beispiel #18
0
void CheckBox::AlignSizeToContent()
{
	TextureManager *dc = GetManager()->GetTextureManager();
	float th = dc->GetFrameHeight(_fontTexture, 0);
	float tw = dc->GetFrameWidth(_fontTexture, 0);
	float bh = dc->GetFrameHeight(_boxTexture, GetFrame());
	float bw = dc->GetFrameWidth(_boxTexture, GetFrame());
	Resize(bw + (tw - 1) * (float) GetText().length(), std::max(th + 1, bh));
}
Beispiel #19
0
    DepthRenderer::~DepthRenderer()
    {
        TextureManager* texMgr = TextureManager::getSingletonPtr();

        // Destroy render texture.
        if (!mDepthRenderTexture.isNull ()) {
            texMgr->remove (mDepthRenderTexture->getHandle ());
            mDepthRenderTexture.setNull ();
        }
    }
Beispiel #20
0
Aircraft::Aircraft(Type type, const TextureManager& textures, const FontManager& fonts)
: Entity(Table[type].hitpoints)
, mType(type)
, mSprite(textures.getResource(Table[type].texture), Table[type].textureRect)
, mExplosion(textures.getResource(Textures::Id::Explosion))
, mFireCommand()
, mMissileCommand()
, mFireCountdown(sf::Time::Zero)
, bFiring(false)
, bLaunchingMissile(false)
, bShowExplosion(true)
, bSpawnedPickup(false)
, bPlayedExplosionSound(false)
// , bMarkedForRemoval(false)
, mFireRateLevel(1)
, mSpreadLevel(1)
, mMissileAmmo(24)
, mDropPickupCommand()
, mTravelledDistance(0.f)
, mDirectionIndex(0)
// , mHealthDisplay(nullptr)
, mMissileDisplay(nullptr)
{
  // sf::FloatRect bounds = mSprite.getLocalBounds();

  mExplosion.setFrameSize(sf::Vector2i(256, 256));
  mExplosion.setFrameCount(16);
  mExplosion.setDuration(sf::seconds(1));

  mSprite.setOrigin(mSprite.getLocalBounds().width / 2.f, mSprite.getLocalBounds().height / 2.f);
  mExplosion.setOrigin(mExplosion.getLocalBounds().width / 2.f, mExplosion.getLocalBounds().height / 2.f);

  mFireCommand.category = Category::SceneAirLayer;
  mFireCommand.action = [this, &textures] (SceneNode& node, sf::Time) { createBullets(node, textures); };

  mMissileCommand.category = Category::SceneAirLayer;
  mMissileCommand.action = [this, &textures] (SceneNode& node, sf::Time) // FIX
    { createProjectile(node, Projectile::Missile, 0.f, 0.5f, textures); };

  mDropPickupCommand.category = Category::SceneAirLayer;
  mDropPickupCommand.action = [this, &textures] (SceneNode& node, sf::Time) { createPickup(node, textures); };

  std::unique_ptr<TextNode> healthDisplay(new TextNode("", fonts));
  mHealthDisplay = healthDisplay.get();
  attachChild(std::move(healthDisplay));

  if (getCategory() == Category::PlayerAircraft) {
    std::unique_ptr<TextNode> missileDisplay(new TextNode("", fonts));
    missileDisplay->setPosition(0, 70);
    mMissileDisplay = missileDisplay.get();
    attachChild(std::move(missileDisplay));
  }

  updateTexts();
}
Beispiel #21
0
//
// TextureManager::readAnimatedLump
//
// Reads animation definitions from the ANIMATED lump.
//
// Load the table of animation definitions, checking for existence of
// the start and end of each frame. If the start doesn't exist the sequence
// is skipped, if the last doesn't exist, BOOM exits.
//
// Wall/Flat animation sequences, defined by name of first and last frame,
// The full animation sequence is given using all lumps between the start
// and end entry, in the order found in the WAD file.
//
// This routine modified to read its data from a predefined lump or
// PWAD lump called ANIMATED rather than a static table in this module to
// allow wad designers to insert or modify animation sequences.
//
// Lump format is an array of byte packed animdef_t structures, terminated
// by a structure with istexture == -1. The lump can be generated from a
// text source file using SWANTBLS.EXE, distributed with the BOOM utils.
// The standard list of switches and animations is contained in the example
// source text file DEFSWANI.DAT also in the BOOM util distribution.
//
// [RH] Rewritten to support BOOM ANIMATED lump but also make absolutely
// no assumptions about how the compiler packs the animdefs array.
//
void TextureManager::readAnimatedLump()
{
	int lumpnum = W_CheckNumForName("ANIMATED");
	if (lumpnum == -1)
		return;

	size_t lumplen = W_LumpLength(lumpnum);
	if (lumplen == 0)
		return;

	byte* lumpdata = new byte[lumplen];
	W_ReadLump(lumpnum, lumpdata);

	for (byte* ptr = lumpdata; *ptr != 255; ptr += 23)
	{
		anim_t anim;

		Texture::TextureSourceType texture_type = *(ptr + 0) == 1 ?
					Texture::TEX_WALLTEXTURE : Texture::TEX_FLAT;

		const char* startname = (const char*)(ptr + 10);
		const char* endname = (const char*)(ptr + 1);

		texhandle_t start_texhandle =
				texturemanager.getHandle(startname, texture_type);
		texhandle_t end_texhandle =
				texturemanager.getHandle(endname, texture_type);

		if (start_texhandle == TextureManager::NOT_FOUND_TEXTURE_HANDLE ||
			start_texhandle == TextureManager::NO_TEXTURE_HANDLE ||
			end_texhandle == TextureManager::NOT_FOUND_TEXTURE_HANDLE ||
			end_texhandle == TextureManager::NO_TEXTURE_HANDLE)
			continue;

		anim.basepic = start_texhandle;
		anim.numframes = end_texhandle - start_texhandle + 1;

		if (anim.numframes <= 0)
			continue;
		anim.curframe = 0;
			
		int speed = LELONG(*(int*)(ptr + 19));
		anim.countdown = speed - 1;

		for (int i = 0; i < anim.numframes; i++)
		{
			anim.framepic[i] = anim.basepic + i;
			anim.speedmin[i] = anim.speedmax[i] = speed;
		}

		mAnimDefs.push_back(anim);
	}

	delete [] lumpdata;
}
void GUI_Element::ApplyBgStyle(){
	TextureManager* textures = m_owner->GetManager()->GetContext()->m_textureManager;
	const GUI_Style& CurrentStyle = m_style[m_state];
	if (CurrentStyle.m_backgroundImage != ""){
		m_visual.m_backgroundImage.setTexture(*textures->GetResource(CurrentStyle.m_backgroundImage));
		m_visual.m_backgroundImage.setColor(CurrentStyle.m_backgroundImageColor);
	}
	m_visual.m_backgroundImage.setPosition(m_position);
	m_visual.m_backgroundSolid.setSize(sf::Vector2f(CurrentStyle.m_size));
	m_visual.m_backgroundSolid.setFillColor(CurrentStyle.m_backgroundColor);
	m_visual.m_backgroundSolid.setPosition(m_position);
}
void Sprite::Render(ID3DXSprite *sprite) {
  TextureManager *TexMan = TextureManager::GetSingleton();

  if (enabled && TexMan->IsTextureValid(tex)) {
    TextureRecord *TexRec = TexMan->GetTexture(tex);

    if (TexRec->IsType(TR_PLANAR)) {
      sprite->SetTransform(&transform);
      sprite->Draw((LPDIRECT3DTEXTURE9)TexRec->GetTexture(), 0, 0, &pos, color);
    }
  }
}
void CreateShader(){
	TextureManager* TextMgr = TextureManager::Inst();
	unsigned int TexID = 1;
	GLuint texHandle;
	if (TextMgr->LoadTexture("resource//cy2.png", TexID, GL_RGB, GL_RGB, 0, 0)){
		texHandle=TextMgr->GetTextureHanle(TexID);
	}
	else{
		return;
	}
	RenderHandle = genRenderProg(texHandle);
}
Beispiel #25
0
MapDraw::MapDraw()
{
  showPheramone = 0;
  smoothScrollX = smoothScrollY = 0;
  boxSide = 0.1;
  picked = '\0';
  pickMode = false;
  //tm = '\0';
  TextureManager *tm = new TextureManager();
  tm->load( 0, (u8*)dirt_one_img_bin );
//  tm->bind( );
}
void Bamboo::RN_Deferred::ItlCreateFBO()
{
    TextureManager *pTextureManager = ItlGetGraphicCore()->GetTextureManager();
    assert (pTextureManager != NULL);

    //get the id of a free texture unit from the texture manager
    GLuint nUsedTextureUnit = pTextureManager->RequestFreeUnit(); //ask for a free texture unit

    //activate unit
    glActiveTexture(GL_TEXTURE0 + nUsedTextureUnit);

    m_nAlbedoDrawBuffer = ItlCreateColorTexture();
    m_nNormalMapDrawBuffer = ItlCreateColorTexture();
    m_nNormalDrawBuffer = ItlCreateColorTexture();
    m_nTangentDrawBuffer = ItlCreateColorTexture();
    m_nSpecularDrawBuffer = ItlCreateColorTexture();
    m_nDepthDrawBuffer = ItlCreateDepthTexture();
    m_nDisplaceDrawBuffer = ItlCreateColorTexture();
    m_nPositionDrawBuffer = ItlCreateColorTexture();
    m_nStencilDrawBuffer = ItlCreateColorTexture();

    glGenFramebuffers(1, &m_nFBO);
    glBindFramebuffer(GL_FRAMEBUFFER, m_nFBO);

    // attach the texture to FBO color attachment point
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_nAlbedoDrawBuffer, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, m_nNormalDrawBuffer, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, m_nTangentDrawBuffer, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_nSpecularDrawBuffer, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT4, GL_TEXTURE_2D, m_nDisplaceDrawBuffer, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT5, GL_TEXTURE_2D, m_nPositionDrawBuffer, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT6, GL_TEXTURE_2D, m_nNormalMapDrawBuffer, 0);

    // attach the renderbuffer to depth attachment point
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_nDepthDrawBuffer, 0);

    GLenum tDrawBuffers[7] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 , GL_COLOR_ATTACHMENT3, GL_COLOR_ATTACHMENT4, GL_COLOR_ATTACHMENT5, GL_COLOR_ATTACHMENT6 };
    glDrawBuffers(7, tDrawBuffers);

    //check fbo status
    GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

    if(status != GL_FRAMEBUFFER_COMPLETE)
        Logger::fatal() << "Failed to initialize FBO for RN_Deferred" << Logger::endl;

    //release used texture unit
    pTextureManager->ReleaseUnit(nUsedTextureUnit);

    //unbind fbo
    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    m_bLayeredFBO = false;
}
Beispiel #27
0
void CreditsMenu::initMap(sf::RenderWindow &window, TextureManager &textureManager)
{
	//hardcoded positions

	backgroundSprite.setTexture(*textureManager.getResource("Config/Content/Images/Menus/creditsScreen.png"));

	sf::RectangleShape backButton;
	backButton.setSize(sf::Vector2f(120.0f, 50.0f));
	backButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/backButton.png"));
	backButton.setPosition(window.getSize().x / 2 - backButton.getSize().x / 2, 520);

	menuItems[BACK] = backButton;
}
Beispiel #28
0
static RenderTarget *BuildGBuffer(Device *device, Vector2i size)
{
    RenderTarget *rt = device->addRenderTarget();
    TextureManager *tm = device->getTextureManager();
    std::vector<Texture *> textures = {tm->registerTexture("GBUFFER_COLOR")};
    for(auto texture: textures)
        texture->create(size, PixelFormat::PF_R8G8B8A8);
    rt->attachTextures(textures);
    Texture *depth_texture = tm->registerTexture("GBUFFER_DEPTH");
    depth_texture->create(size, PixelFormat::PF_D24);
    rt->attachDepthTexture(depth_texture);

    return rt;
}
/*
=================================================================================================================================================================
This class is a scroll window which displays the different rooms for using.
=================================================================================================================================================================
*/
ObjectMenu::ObjectMenu(const sf::Texture& bottomMenuTexture, TextureManager& textures)
: Object(bottomMenuTexture)
, x(45)
, y(365)
, emptyRoomSmButton     (textures.getTexture(RES_TXR_ROOMS_EMPTY_SM),       sf::Vector2f(x, y))   //Button
, emptyRoomLgButton     (textures.getTexture(RES_TXR_ROOMS_EMPTY_LG),       sf::Vector2f(x + 45 * 1, y)             )
, emptyRoomSmWdButton   (textures.getTexture(RES_TXR_ROOMS_EMPTY_SM_WD),    sf::Vector2f(x + 45 * 3, y)             )
, emptyRoomSmTlButton   (textures.getTexture(RES_TXR_ROOMS_EMPTY_SM_TL),    sf::Vector2f(x + 45 * 5, y)             )
, emptyRoomHugeButton   (textures.getTexture(RES_TXR_ROOMS_EMPTY_HG),       sf::Vector2f(x + 45 * 7, y)             )
, cannonRoomUpButton    (textures.getTexture(RES_TXR_ROOMS_CANNON),         sf::Vector2f(x + 45 * 1, y + 160 * 1)   )
, recruitButton         (textures.getTexture(RES_TXR_UNITS_RECRUIT),        sf::Vector2f(x, y)                      )
{
    mSprite.setPosition(0, 340);
    recruitButton.setTextureRect(sf::IntRect(0, 0, 38, 38 ) );
}
/*************************************************
 * OpenGL initialization
 *************************************************/
static int initGL(WININFO *winInfo)
{
	char errorString[MAX_ERROR_LENGTH + 1];

	// Create openGL functions
	for (int i=0; i<NUM_GL_NAMES; i++) glFP[i] = (GenFP)wglGetProcAddress(glnames[i]);

	// Create and initialize the shader manager
	if (shaderManager.init(errorString))
	{
		MessageBox(winInfo->hWnd, errorString, "Shader Manager Load", MB_OK);
		return -1;
	}

	// Create and initialize everything needed for texture Management
	if (textureManager.init(errorString))
	{
		MessageBox(winInfo->hWnd, errorString, "Texture Manager Load", MB_OK);
		return -1;
	}

	// Create the text editor
	if (editor.init(&shaderManager, &textureManager, errorString))
	{
		MessageBox(winInfo->hWnd, errorString, "Editor init", MB_OK);
		return -1;
	}

	return 0;
}