void StatusBar::Render() {
     backgrnd.Draw(0, View::Height - backgrnd.Height, false, false, true);
     backgrnd2.Draw(0, View::Height - backgrnd.Height, false, false);
     RenderLevel();
     RenderGauge();
     RenderButtons();
 }
Exemple #2
0
void ScenePatch(){
	bool quit = false;
	SDL_Event event;

	Sprite *bgi = new Sprite("resource\\bgi_patcher.jpg",1,1);
	Sprite *title = new Sprite("resource\\title.png",1,1);

	FONT gulim;

	float progress_total = 50;
	float progress_current = 30;

	gulim.InitFont("c:\\windows\\fonts\\gulim.ttc",12);
	gulim.SetColor(255,255,255);
	gulim.SetStyle(TTF_STYLE_BOLD);

	while(!quit){
		while(SDL_PollEvent(&event)){
			switch(event.type){
			case SDL_QUIT:
				break;
			}
		}
		{
			SDL_RenderClear(renderer);

			bgi->Draw(0,0,480,272);
			title->Draw(20,20,440,170);


			SDL_Rect rtProgressTotalFrame = {20,200,440,25};
			SDL_Rect rtProgressCurrentFrame = {20,235,440,25};
			SDL_Rect rtProgressTotal = {25,205,progress_total * 4.4,15};
			SDL_Rect rtProgressCurrent = {25,240,progress_current * 4.4,15};

			SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_NONE);
			SDL_SetRenderDrawColor(renderer,64,64,64,255);
			SDL_RenderFillRect(renderer,&rtProgressTotalFrame);
			SDL_RenderFillRect(renderer,&rtProgressCurrentFrame);

			SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_BLEND);
			SDL_SetRenderDrawColor(renderer,64,255,64,196);
			SDL_RenderFillRect(renderer,&rtProgressTotal);
			SDL_RenderFillRect(renderer,&rtProgressCurrent);

			gulim.Draw(renderer,"전체 진행률",25,190);
			gulim.Draw(renderer,"현재 진행률",25,225);

			gulim.Draw(renderer,"Tank Online Patcher",343,258);

			SDL_RenderPresent(renderer);
		}

		SDL_Delay(1);
	}

	delete bgi;
}
void FontUsageScreen::DrawFTFont(FTFont * ftFont, Vector2 pos, float32 fontSize)
{
	ftFont->SetSize(fontSize);
	Size2i size = ftFont->GetStringSize(singleLineString);
	Rect rect(pos.x, pos.y, (float32)size.dx, (float32)size.dy);
	RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
	//RenderManager::Instance()->DrawRect(rect);
	
//	RenderHelper::Instance()->DrawLine(Vector2(pos.x, pos.y + ftFont->GetAscender()), Vector2(pos.x + size.dx, pos.y + ftFont->GetAscender()));
	
	int32 dx = 960;
	int32 dy = 40;
	int16 * buf;
	int bsz = dx * dy;
	buf = new int16[bsz];
	memset(buf, 0, dx * dy * sizeof(int16));
	ftFont->DrawStringToBuffer(buf, dx, dy, 0, 0, 0, 0, singleLineString, true);
	Texture *tex = Texture::CreateTextFromData(FORMAT_RGBA4444, (uint8*)buf, dx, dy, "");
	delete[] buf;
	
	Sprite * ftFontSprite = Sprite::CreateFromTexture(tex, 0, 0, (float32)dx, (float32)dy);
//	if(!isMultilineEnabled)
//	{
//		textSprite->SetDefaultPivotPoint(0.0f, (float32)(font->GetBaseline() - h));
//	}

	SafeRelease(tex);
	
	ftFontSprite->SetPosition(pos.x, pos.y);
	ftFontSprite->Draw();
	SafeRelease(ftFontSprite); 
}
void ModifyTilemaskCommand::ApplyImageToSprite(Image* image, Sprite* dstSprite)
{
	RenderManager::Instance()->SetRenderTarget(dstSprite);
	RenderManager::Instance()->ClipPush();
	RenderManager::Instance()->SetClip(updatedRect);
	
	eBlendMode srcBlend = RenderManager::Instance()->GetSrcBlend();
	eBlendMode dstBlend = RenderManager::Instance()->GetDestBlend();
	RenderManager::Instance()->SetBlendMode(BLEND_ONE, BLEND_ZERO);
	
	Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(),
											   image->GetWidth(), image->GetHeight(), false);
	Sprite* srcSprite = Sprite::CreateFromTexture(texture, 0, 0, image->GetWidth(), image->GetHeight());
	
	srcSprite->SetPosition(updatedRect.x, updatedRect.y);
	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);
	srcSprite->Draw();

	dstSprite->GetTexture()->GenerateMipmaps();

	RenderManager::Instance()->SetBlendMode(srcBlend, dstBlend);
	
	RenderManager::Instance()->ClipPop();
	RenderManager::Instance()->RestoreRenderTarget();
	
	SafeRelease(texture);
	SafeRelease(srcSprite);
}
void CommandSetVisibilityPoint::Cancel()
{
	Sprite* visibilityToolSprite = visibilityToolProxy->GetSprite();
	RenderManager::Instance()->SetRenderTarget(visibilityToolSprite);
	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);

	if (undoImage)
	{
		Texture* drawTexture = Texture::CreateFromData(undoImage->GetPixelFormat(),
													   undoImage->GetData(),
													   undoImage->GetWidth(),
													   undoImage->GetHeight(),
													   false);
		Sprite* drawSprite = Sprite::CreateFromTexture(drawTexture, 0, 0, undoImage->GetWidth(), undoImage->GetHeight());

		drawSprite->SetPosition(0.f, 0.f);
		drawSprite->Draw();

		SafeRelease(drawSprite);
		SafeRelease(drawTexture);

		visibilityToolProxy->UpdateRect(Rect(0.f, 0.f, undoImage->GetWidth(), undoImage->GetHeight()));
	}
	
	RenderManager::Instance()->RestoreRenderTarget();

	visibilityToolProxy->SetVisibilityPoint(undoVisibilityPoint);
	visibilityToolProxy->UpdateVisibilityPointSet(undoVisibilityPointSet);
}
void CommandSetVisibilityArea::ApplyImage(DAVA::Image *image)
{
	Sprite* visibilityToolSprite = visibilityToolProxy->GetSprite();

	Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(),
											   image->GetWidth(), image->GetHeight(), false);
	texture->GeneratePixelesation();
	Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, image->GetWidth(), image->GetHeight());

	RenderManager::Instance()->SetRenderTarget(visibilityToolSprite);
	RenderManager::Instance()->ClipPush();
	RenderManager::Instance()->ClipRect(updatedRect);

	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);
	sprite->SetPosition(updatedRect.x, updatedRect.y);
	sprite->Draw();

	RenderManager::Instance()->ClipPop();
	RenderManager::Instance()->RestoreRenderTarget();

	visibilityToolProxy->UpdateRect(updatedRect);

	SafeRelease(texture);
	SafeRelease(sprite);
}
Image *LandscapeEditorHeightmap::CreateToolImage(int32 sideSize)
{
    RenderManager::Instance()->LockNonMain();
    
    Image *image = currentTool->image;
    Sprite *dstSprite = Sprite::CreateAsRenderTarget((float32)sideSize, (float32)sideSize, FORMAT_RGBA8888);
    Texture *srcTex = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(), 
                                              image->GetWidth(), image->GetHeight(), false);
    Sprite *srcSprite = Sprite::CreateFromTexture(srcTex, 0, 0, (float32)image->GetWidth(), (float32)image->GetHeight());
    
    RenderManager::Instance()->SetRenderTarget(dstSprite);
    
    RenderManager::Instance()->SetColor(Color::Black());
    RenderHelper::Instance()->FillRect(Rect(0, 0, (float32)dstSprite->GetTexture()->GetWidth(), (float32)dstSprite->GetTexture()->GetHeight()));
    
    RenderManager::Instance()->SetBlendMode(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
    RenderManager::Instance()->SetColor(Color::White());
    
    srcSprite->SetScaleSize((float32)sideSize, (float32)sideSize);
    srcSprite->SetPosition(Vector2((dstSprite->GetTexture()->GetWidth() - sideSize)/2.0f, 
                                   (dstSprite->GetTexture()->GetHeight() - sideSize)/2.0f));
    srcSprite->Draw();
    RenderManager::Instance()->RestoreRenderTarget();
    
    Image *retImage = dstSprite->GetTexture()->CreateImageFromMemory();
    
    SafeRelease(srcSprite);
    SafeRelease(srcTex);
    SafeRelease(dstSprite);
    
    RenderManager::Instance()->UnlockNonMain();
    
    return retImage;
}
	void DrawPrimitives()
	{
		if( GAMESTATE->IsPlayerEnabled(m_PlayerNumber) )
		{
			DrawMask( m_fPercent );		// this is the "right endcap" to the life
			
			const float fChamberWidthInPercent = 1.0f/NUM_CHAMBERS;
			float fPercentBetweenStrips = 1.0f/NUM_STRIPS;
			// round this so that the chamber overflows align
			if( NUM_CHAMBERS > 10 )
				fPercentBetweenStrips = froundf( fPercentBetweenStrips, fChamberWidthInPercent );

			float fPercentOffset = fmodf( GAMESTATE->m_fSongBeat/4+1000, fPercentBetweenStrips );
			ASSERT( fPercentOffset >= 0  &&  fPercentOffset <= fPercentBetweenStrips );

			for( float f=fPercentOffset+1; f>=0; f-=fPercentBetweenStrips )
			{
				DrawMask( f );
				DrawStrip( f );
			}

		}

		m_sprFrame.Draw();

	}
Image* HeightmapEditorSystem::CreateToolImage(int32 sideSize, const FilePath& filePath)
{
	Sprite *dstSprite = Sprite::CreateAsRenderTarget((float32)sideSize, (float32)sideSize, FORMAT_RGBA8888);
	Texture *srcTex = Texture::CreateFromFile(filePath);
	Sprite *srcSprite = Sprite::CreateFromTexture(srcTex, 0, 0, (float32)srcTex->GetWidth(), (float32)srcTex->GetHeight());
	
	RenderManager::Instance()->SetRenderTarget(dstSprite);
	
	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);
	
	RenderManager::Instance()->SetBlendMode(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
	RenderManager::Instance()->SetColor(Color::White());
	
	srcSprite->SetScaleSize((float32)sideSize, (float32)sideSize);
	srcSprite->SetPosition(Vector2((dstSprite->GetTexture()->GetWidth() - sideSize)/2.0f,
								   (dstSprite->GetTexture()->GetHeight() - sideSize)/2.0f));
	srcSprite->Draw();
	RenderManager::Instance()->RestoreRenderTarget();
	
	Image *retImage = dstSprite->GetTexture()->CreateImageFromMemory();
	
	SafeRelease(srcSprite);
	SafeRelease(srcTex);
	SafeRelease(dstSprite);
	
	return retImage;
}
Exemple #10
0
////////////////////////////////////////////////////////////
/// Draw Hits
////////////////////////////////////////////////////////////
void MainClient::_drawHits(void)
{
	if(!bulletHits.empty()){
		//Draw hits
		std::list<Sprite>::iterator iter;
		Sprite *hit;
		std::vector< std::list<Sprite>::iterator> eraser;

		for(iter = bulletHits.begin(); iter != bulletHits.end(); ++iter){
			hit = &(*iter);

			if(hit->pInfo.aniPosition == hit->pInfo.aniLength){
				//No looping so remove the hit spot
				eraser.push_back(iter);
			}
			else {
				hit->Step();
				hit->Draw();
			}


		}

		//Remove 'finished' animations
		if(!eraser.empty()){
			for(size_t k = 0; k < eraser.size();k++){
				bulletHits.erase(eraser[k]);
			}
		}
	}
}
void LandscapeEditorCustomColors::RestoreState(DAVA::Image *image)
{
	Texture* texture = Texture::CreateTextFromData(image->GetPixelFormat(), image->GetData(), image->GetWidth(), image->GetHeight(), false);
	Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, texture->GetWidth(), texture->GetHeight());

	uint32 width = 0;
	uint32 height = 0;

	if (colorSprite)
	{
		width = colorSprite->GetWidth();
		height = colorSprite->GetHeight();
	}
	else
	{
		width = texSurf->GetWidth();
		height = texSurf->GetHeight();
	}

	SafeRelease(colorSprite);
	colorSprite = Sprite::CreateAsRenderTarget(width, height, FORMAT_RGBA8888);

	RenderManager::Instance()->SetRenderTarget(colorSprite);
	sprite->Draw();
	RenderManager::Instance()->RestoreRenderTarget();

	SafeRelease(sprite);
	SafeRelease(texture);

	if (IsActive())
		PerformLandscapeDraw();

	unsavedChanges = true;
}
Exemple #12
0
	void Sprites::Draw(int ID, int width, int height, int x, int y)
	{
		Sprite *sprt = spriteManager[ID];
		if( !sprt ) return;

		sprt->Draw(width,height,x,y,m_pD3DSprite,&textures);
	}
Exemple #13
0
void SpriteList::DrawAll( TCanvas *Canvas ) {
  Sprite *temp = root;
  while (temp!=0)
  {
	temp->Draw( Canvas );
	temp=temp->next;
  }
}
void DialogCharacter::Draw(string emotionId, bool isTalking, bool shouldChangeMouth, bool isRightSide, int xOffset)
{
    if (emotionId.length() == 0)
    {
        emotionId = defaultEmotionId;
    }

    if (characterOneTimeEmotions.count(emotionId) > 0)
    {
        Video *pVideo = characterOneTimeEmotions[emotionId]->GetVideo();
        Vector2 position((isRightSide ? (double)gScreenWidth - pVideo->GetWidth() : 0) + xOffset, (double)gScreenHeight - Dialog::Height - pVideo->GetHeight());
        pVideo->Draw(position, !isRightSide, Color::White);
        return;
    }

    Sprite *pBaseSprite = GetBaseSpriteForEmotion(emotionId);
    Sprite *pEyeSprite = GetEyeSpriteForEmotion(emotionId);
    Sprite *pMouthSprite = GetMouthSpriteForEmotion(emotionId, isTalking, shouldChangeMouth);
    vector<Animation *> *pForegroundLayers = GetForegroundLayersForEmotion(emotionId);

    if (pBaseSprite != NULL)
    {
        Vector2 position((isRightSide ? gScreenWidth / 2 : 0) + xOffset, 0);

        pBaseSprite->Draw(position, Color::White, 1.0, !isRightSide);

        if (pEyeSprite != NULL)
        {
            pEyeSprite->Draw(position, Color::White, 1.0, !isRightSide);
        }

        if (pMouthSprite != NULL)
        {
            pMouthSprite->Draw(position, Color::White, 1.0, !isRightSide);
        }

        if (pForegroundLayers != NULL)
        {
            for (unsigned int i = 0; i < pForegroundLayers->size(); i++)
            {
                (*pForegroundLayers)[i]->Draw(position, !isRightSide, 1.0);
            }
        }
    }
}
	void DrawStrip( float fRightEdgePercent )
	{
		RectI rect;

		const float fChamberWidthInPercent = 1.0f/NUM_CHAMBERS;
		const float fStripWidthInPercent = 1.0f/NUM_STRIPS;
		
		const float fCorrectedRightEdgePercent = fRightEdgePercent + fChamberWidthInPercent;
		const float fCorrectedStripWidthInPercent = fStripWidthInPercent + 2*fChamberWidthInPercent;
		const float fCorrectedLeftEdgePercent = fCorrectedRightEdgePercent - fCorrectedStripWidthInPercent;


		// set size of streams
		rect.left	= int(-METER_WIDTH/2 + METER_WIDTH*max(0,fCorrectedLeftEdgePercent));
		rect.top	= int(-METER_HEIGHT/2);
		rect.right	= int(-METER_WIDTH/2 + METER_WIDTH*min(1,fCorrectedRightEdgePercent));
		rect.bottom	= int(+METER_HEIGHT/2);

		ASSERT( rect.left <= METER_WIDTH/2  &&  rect.right <= METER_WIDTH/2 );  

		float fPercentCroppedFromLeft = max( 0, -fCorrectedLeftEdgePercent );
		float fPercentCroppedFromRight = max( 0, fCorrectedRightEdgePercent-1 );


		m_sprStreamNormal.StretchTo( rect );
		m_sprStreamHot.StretchTo( rect );


		// set custom texture coords
//		float fPrecentOffset = fRightEdgePercent;

		RectF frectCustomTexRect(
			fPercentCroppedFromLeft,
			0,
			1-fPercentCroppedFromRight,
			1);

		m_sprStreamNormal.SetCustomTextureRect( frectCustomTexRect );
		m_sprStreamHot.SetCustomTextureRect( frectCustomTexRect );

		m_sprStreamHot.SetDiffuse( RageColor(1,1,1,m_fHotAlpha) );

		m_sprStreamNormal.Draw();
		m_sprStreamHot.Draw();
	}
Exemple #16
0
void EditorLandscape::DrawFullTiledTexture(DAVA::Texture *renderTarget, const DAVA::Rect &drawRect)
{
    Texture *fullTiledTexture = nestedLandscape->GetTexture(Landscape::TEXTURE_TILE_FULL);
    Sprite *background = Sprite::CreateFromTexture(fullTiledTexture, 0, 0, (float32)fullTiledTexture->GetWidth(), (float32)fullTiledTexture->GetHeight());

    background->SetPosition(0.f, 0.f);
    background->SetScaleSize((float32)renderTarget->GetWidth(), (float32)renderTarget->GetHeight());
    background->Draw();
    
    SafeRelease(background);
}
Exemple #17
0
void MainClient::_drawWeapons()
{
	Sprite* weapon = NULL;

	if(mPlayer->pHasWeapon && mPlayer->pHealth > 0.0f){
		weapon = &gs.Weapon[mPlayer->pWeaponID];
		weapon->pInfo.pos = mPlayer->pWeaponPos;
		weapon->pInfo.angle = mPlayer->pAngle;

		weapon->Draw();
	}

	if(mRobot->pHasWeapon && mRobot->pHealth > 0.0f){
		weapon = &gs.Weapon[mRobot->pWeaponID];
		weapon->pInfo.pos = mRobot->pWeaponPos;
		weapon->pInfo.angle = mRobot->pAngle;

		weapon->Draw();
	}
}
Exemple #18
0
void NLS::Map::DrawClock() {
	if (!node["clock"]) return;
	int32_t x = node["clock"]["x"], y = node["clock"]["y"];
	NLS::Node clockImgs = WZ["Map"]["Obj"]["etc"]["clock"]["fontTime"];

	y += 81;
	x += 12;

	time_t rawtime = time(0);
	tm *timeinfo = localtime(&rawtime);
	uint8_t digit_1 = timeinfo->tm_hour / 10;
	uint8_t digit_2 = timeinfo->tm_hour % 10;
	uint8_t digit_3 = timeinfo->tm_min / 10;
	uint8_t digit_4 = timeinfo->tm_min % 10;
	
	string ampm = timeinfo->tm_hour >= 12 ? "pm" : "am";

	Sprite sprite_ampm = clockImgs[ampm];
	sprite_ampm.Draw(x, y);

	x += sprite_ampm.data->width + 10;

	Sprite digit = clockImgs[tostring(digit_1)];
	digit.Draw(x, y);
	x += digit.data->width + 5;

	digit = clockImgs[tostring(digit_2)];
	digit.Draw(x, y);
	x += digit.data->width + 5;

	digit = clockImgs["comma"];
	digit.Draw(x, y);
	x += digit.data->width + 5;

	digit = clockImgs[tostring(digit_3)];
	digit.Draw(x, y);
	x += digit.data->width + 5;

	digit = clockImgs[tostring(digit_4)];
	digit.Draw(x, y);
}
Exemple #19
0
void FuelNode::Draw()
{
  AmjuGL::PushMatrix();

  AmjuGL::MultMatrix(m_local);
  AmjuGL::RotateX(-90.0f); // so x-y plane is x-z plane
  static const float HSIZE = SIZE * 0.5f;
  AmjuGL::Translate(-HSIZE, -HSIZE, 0); 
  m_sprite.Draw(Vec2f(0, 0), 2.0f);

  AmjuGL::PopMatrix();
}
void LandscapeEditorColor::CreateMaskFromTexture(Texture *tex)
{
    SafeRelease(maskSprite);
	SafeRelease(oldMaskSprite);
    SafeRelease(toolSprite);
    
    float32 texSize = (float32)settings->maskSize;
    if(tex)
    {
        texSize = (float32)tex->width;
    }
    
    maskSprite = Sprite::CreateAsRenderTarget(texSize, texSize, FORMAT_RGBA8888);
	oldMaskSprite = Sprite::CreateAsRenderTarget(texSize, texSize, FORMAT_RGBA8888);
    toolSprite = Sprite::CreateAsRenderTarget(texSize, texSize, FORMAT_RGBA8888);
    
    if(tex)
    {
        RenderManager::Instance()->LockNonMain();
        RenderManager::Instance()->SetBlendMode(BLEND_ONE, BLEND_ZERO);
        
        Sprite *oldMask = Sprite::CreateFromTexture(tex, 0, 0, (float32)tex->width, (float32)tex->height);
        
        RenderManager::Instance()->SetRenderTarget(oldMaskSprite);
        oldMask->SetPosition(0.f, 0.f);
        oldMask->Draw();
        RenderManager::Instance()->RestoreRenderTarget();
        
        RenderManager::Instance()->SetRenderTarget(maskSprite);
        oldMask->SetPosition(0.f, 0.f);
        oldMask->Draw();
        RenderManager::Instance()->RestoreRenderTarget();
        
        SafeRelease(oldMask);
        
        RenderManager::Instance()->UnlockNonMain();
    }
    
	workingLandscape->SetTexture(Landscape::TEXTURE_TILE_MASK, oldMaskSprite->GetTexture());
}
Exemple #21
0
LandscapeTool::LandscapeTool(int32 _ID, eToolType _type, const String & _imageName)
{
    toolID = _ID;
    type = _type;
    
    imageName = _imageName;
    image = Image::CreateFromFile(imageName);
    
    RenderManager::Instance()->LockNonMain();
    
    int32 sideSize = image->width;
    sprite = Sprite::CreateAsRenderTarget(sideSize, sideSize, FORMAT_RGBA8888);
    
    Texture *srcTex = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(), 
                                              image->GetWidth(), image->GetHeight());
    
    Sprite *srcSprite = Sprite::CreateFromTexture(srcTex, 0, 0, image->GetWidth(), image->GetHeight());
    
    RenderManager::Instance()->SetRenderTarget(sprite);
    
    RenderManager::Instance()->SetColor(Color::Black());
    RenderHelper::Instance()->FillRect(Rect(0, 0, sideSize, sideSize));
    
    RenderManager::Instance()->SetBlendMode(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
    RenderManager::Instance()->SetColor(Color::White());
    
    srcSprite->SetScaleSize(sideSize, sideSize);
    srcSprite->SetPosition(Vector2(0, 0));
    srcSprite->Draw();
    RenderManager::Instance()->RestoreRenderTarget();
    
    
    SafeRelease(srcSprite);
    SafeRelease(srcTex);
    
    RenderManager::Instance()->UnlockNonMain();
    
    maxSize = 0.f;
    size = 0.f;
    maxStrength = 0.f;
    strength = 0.f;
    height = 0.0f;
    averageStrength = 0.f;

    
    relativeDrawing = true;
    averageDrawing = false;
    absoluteDropperDrawing = false;
    
    copyHeightmap = false;
    copyTilemask = false;
}
void FontUsageScreen::Draw(const UIGeometricData &geometricData)
{
	//DrawFTFont(ftFont1, Vector2(1, 10), 24);
	DrawGraphicsFont(graphicsFont1, Vector2(10, 50), originalSize);
	DrawGraphicsFont(graphicsFont1, Vector2(10, 130), originalSize / 2);
	DrawGraphicsFont(graphicsFont1, Vector2(10, 160), originalSize / 3);
	DrawGraphicsFont(graphicsFont1, Vector2(10, 200), originalSize / 5);


	Sprite * sp = textSpriteWithFreetypeSingleLineFont->GetSprite();
	sp->SetPosition(10, 300);
	sp->Draw();
	
}
Sprite* ModifyTilemaskCommand::ApplyImageToTexture(DAVA::Image *image, DAVA::Texture *texture)
{
	int32 width = texture->GetWidth();
	int32 height = texture->GetHeight();

	Sprite* resSprite = Sprite::CreateAsRenderTarget((float32)width, (float32)height, FORMAT_RGBA8888);
	RenderManager::Instance()->SetRenderTarget(resSprite);
	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);

	eBlendMode srcBlend = RenderManager::Instance()->GetSrcBlend();
	eBlendMode dstBlend = RenderManager::Instance()->GetDestBlend();
	RenderManager::Instance()->SetBlendMode(BLEND_ONE, BLEND_ZERO);

	Sprite* s = Sprite::CreateFromTexture(texture, 0, 0, (float32)width, (float32)height);
	s->SetPosition(0.f, 0.f);
	s->Draw();
	SafeRelease(s);

	RenderManager::Instance()->ClipPush();
	RenderManager::Instance()->SetClip(updatedRect);
	RenderManager::Instance()->ClearWithColor(0.f, 0.f, 0.f, 0.f);

	Texture* t = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(),
										 image->GetWidth(), image->GetHeight(), false);
	s = Sprite::CreateFromTexture(t, 0, 0, (float32)t->GetWidth(), (float32)t->GetHeight());
	s->SetPosition(updatedRect.x, updatedRect.y);
	s->Draw();
	SafeRelease(s);
	SafeRelease(t);

	RenderManager::Instance()->ClipPop();
	RenderManager::Instance()->SetBlendMode(srcBlend, dstBlend);
	RenderManager::Instance()->ResetColor();
	RenderManager::Instance()->RestoreRenderTarget();

	return resSprite;
}
bool CustomColorsSystem::LoadTexture( const DAVA::FilePath &filePath, bool createUndo /* = true */ )
{
	if(filePath.IsEmpty())
		return false;

    Vector<Image*> images;
    ImageSystem::Instance()->Load(filePath, images);
	if(images.empty())
		return false;

	Image* image = images.front();
	if(image)
	{
		Texture* texture = Texture::CreateFromData(image->GetPixelFormat(),
												   image->GetData(),
												   image->GetWidth(),
												   image->GetHeight(),
												   false);
		Sprite* sprite = Sprite::CreateFromTexture(texture, 0, 0, texture->GetWidth(), texture->GetHeight());

		if (createUndo)
		{
			StoreOriginalState();
		}
		RenderManager::Instance()->SetRenderTarget(drawSystem->GetCustomColorsProxy()->GetSprite());
        
        Sprite::DrawState drawState;
		sprite->Draw(&drawState);
        
		RenderManager::Instance()->RestoreRenderTarget();
		AddRectToAccumulator(Rect(Vector2(0.f, 0.f), Vector2(texture->GetWidth(), texture->GetHeight())));

		SafeRelease(sprite);
		SafeRelease(texture);
		for_each(images.begin(), images.end(), SafeRelease<Image>);

		if (createUndo)
		{
			((SceneEditor2*)GetScene())->BeginBatch("Load custom colors texture");
			StoreSaveFileName(filePath);
			CreateUndoPoint();
			((SceneEditor2*)GetScene())->EndBatch();
		}
	}

    return true;
}
void DrawBulletsRemaining(Weapon* DrawMe, int timediff)
{
	Sprite* BulletSprite;
	Sprite* MySprite;
	Bullet* TheBullet;
	char* Name = "INVALID BULLETS";
	RECT Client;
	GetClientRect(TheDisplay.GetHWnd(), &Client);

	
	TheBullet = GetGlobalBulletData(DrawMe->mBulletID);
	if(!TheBullet)
		return;
	Name = TheBullet->mName;
	BulletSprite = GetGlobalSpriteData(TheBullet->mFullBulletSpriteID);
	if(!BulletSprite)
		return;

	MySprite = new Sprite;
	MySprite->InitializeSpriteCopy(BulletSprite);
	POINT FontOrigin;
	FontOrigin.x = Client.right - DrawMe->mMaxRounds * BulletSprite->GetWidth();
	int StrWidth = GetFontBySizeIndex(WEAPONSELECTOR_BULLET_FONT_ID)->GetStringWidth(Name);
	if(FontOrigin.x + StrWidth > Client.right)
		FontOrigin.x -= (FontOrigin.x + StrWidth) - Client.right + 20;
	FontOrigin.y = Client.bottom - BulletSprite->GetHeight() - GetFontBySizeIndex(WEAPONSELECTOR_BULLET_FONT_ID)->GetCharHeight() - 5;
	int FullWidth = DrawMe->mCurrentRounds * BulletSprite->GetWidth();
	if(FullWidth > Client.right - Client.left)
		return;
	GameWeaponSelector.BulletName->SetLoc(FontOrigin);
	GameWeaponSelector.BulletName->SetWidth(Client.right - Client.left);
	int FullHeight = BulletSprite->GetHeight();
	POINT Loc;
	Loc.x = Client.right - FullWidth;
	Loc.y = Client.bottom - FullHeight;
	for(int i = 0; i < DrawMe->mCurrentRounds; i++)
	{
		MySprite->SetLoc(Loc);
		MySprite->Draw(TheDisplay);
		Loc.x += BulletSprite->GetWidth();
	}
	GameWeaponSelector.BulletName->Update(timediff);
	GameWeaponSelector.BulletName->Draw(TheDisplay);
	delete MySprite;
}
Exemple #26
0
//=============================================================================
//存在してるポリゴンをすべて描画
//=============================================================================
void Sprite::DrawAll(int priority)
{
	Renderer::SetStream2D();
	Sprite* Polygon = Top_[priority];
	if (_Shader == nullptr){ _Shader = CShader2D::Instance(); }
	
	if (priority == LAYER_INTERFACE || priority == LAYER_BACKGROUND){ Camera2D::GetCamera(0)->SetNoMove(); }
	else { Camera2D::Set(0); }
	
	_Shader->DrawBegin();
	while (Polygon)
	{
		Polygon->Draw();
		Polygon = Polygon->Next_;
	}
	_Shader->DrawEnd();
	
}
HRESULT RenderFrame(HWND hwnd)
{
    HRESULT hr = S_OK;

    if (g_pRT && g_pRT->CheckWindowState() == D2D1_WINDOW_STATE_OCCLUDED)
    {
        return S_OK; // The render target is occluded.
    }

    if (!g_pRT)
    {
        // Create the Direct2D resources.
        hr = CreateDrawingResources(hwnd);
    }

    if (SUCCEEDED(hr))
    {

        float fTime = float(g_Timer.GetFrameNumber()) / 30;

        g_pRT->BeginDraw();

        g_pRT->Clear(BACKGROUND_COLOR);

        // Update and draw each sprite.
        for (DWORD i = 0; i < MAX_SPRITES; i++)
        {
            Sprite *pSprite = &g_pSprites[i];
            if (pSprite)
            {
                pSprite->Update(g_pRT, fTime);

                pSprite->Draw(g_pRT);
            }
        }

        // Reset the transform to the identiy matrix.
        g_pRT->SetTransform(D2D1::Matrix3x2F::Identity());

        hr = g_pRT->EndDraw();
    }

    return hr;
}
void LandscapeEditorCustomColors::PrepareRenderLayers()
{
	UpdateCircleTexture(false);

    Sprite* blankSprite = Sprite::CreateFromTexture(circleTexture, 0, 0, (float32)circleTexture->width, (float32)circleTexture->height);
    
	//fill color sprite to get opportunity to save its texture separately 
	RenderManager::Instance()->SetRenderTarget(colorSprite);
	
	Vector2 newPoint = workingLandscape->GetCursor()->GetCursorPosition(); 
	RenderManager::Instance()->SetColor(paintColor);
	
    blankSprite->SetPosition(newPoint); 
	blankSprite->Draw();
	RenderManager::Instance()->RestoreRenderTarget();
    RenderManager::Instance()->ResetColor();
	SafeRelease(blankSprite);
	
}
void LandscapeEditorCustomColors::PerformLandscapeDraw()
{
	Sprite* sprLandscape = Sprite::CreateFromTexture(texSurf, 0, 0, texSurf->GetWidth(), texSurf->GetHeight());
	Sprite* sprTargetSurf = Sprite::CreateAsRenderTarget(texSurf->width, texSurf->height, FORMAT_RGBA8888);
	//render original and color layer to final container 
    RenderManager::Instance()->SetRenderTarget(sprTargetSurf);
	sprLandscape->Draw();
	RenderManager::Instance()->SetColor(1.f, 1.f, 1.f, .5f);
    colorSprite->Draw();
	RenderManager::Instance()->SetColor(Color::White());
    texSurf->GenerateMipmaps();
    RenderManager::Instance()->RestoreRenderTarget();

	workingLandscape->SetTexture(Landscape::TEXTURE_TILE_FULL, sprTargetSurf->GetTexture());
	
	SafeRelease(sprTargetSurf);
	SafeRelease(sprLandscape);
	
}
Exemple #30
0
void SpriteHolder::DrawSprites(){
	SpriteList * result = new SpriteList();
	for (int i = 0; i <= spritetype_t::UI; i++){
		
		GetSprites((spritetype_t)i, result);
		for (std::list<Sprite *>::iterator it = result->begin(); it != result->end(); ++it){
			Sprite * s = (*it);
			spritestate_t state = s->GetState();

			if (state == spritestate_t::ALIVE){
				s->Draw();
			}
			else if (state == spritestate_t::DEAD) {
				if (s->GetType() != spritetype_t::PLAYER) LatelyDestroyable::Add(s);
				s->SetState(spritestate_t::WAIT);
			}
		}
	}
	delete result;
}