Exemplo n.º 1
0
void LightningTestGame::Draw()
{
    constexpr bool enableFxaa = true;

    if (enableFxaa) {
        auto bounds = renderTarget->Bounds();
        graphicsContext->SetRenderTarget(renderTarget);
        graphicsContext->SetViewport(Viewport{bounds});
        graphicsContext->SetScissorRectangle(bounds);
    }

    SceneEditor::EditorColorScheme colorScheme;

    graphicsContext->Clear(colorScheme.BackgroundDark);
    editorBackground->Draw(*graphicsContext);

    //graphicsContext->SetSamplerState(0, samplerPoint);
    DrawSprites();

    if (enableFxaa) {
        graphicsContext->SetRenderTarget();
        graphicsContext->SetViewport(clientViewport);
        graphicsContext->SetScissorRectangle(clientViewport.GetBounds());
        graphicsContext->Clear(Color::CornflowerBlue);
        fxaa->SetTexture(renderTarget);
        fxaa->Apply(*graphicsContext);
        screenQuad->DrawQuad(*graphicsContext);
    }

    gameEditor->DrawGUI(*graphicsContext);
    commandQueue->Present();
}
Exemplo n.º 2
0
bool Graphics2D::draw()
{
	// 1. clear the back buffer to black (0,0,0) and the z buffer to 1
	HRESULT hr=m_d3dDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(0,0,0),1.0f,0);
	if (!CheckHR(hr))
		return false;

	// 2. begin the scene
	hr=m_d3dDevice->BeginScene();
	if (!CheckHR(hr))
		return false;

	// 3. draw me some sprites!!
	if (!DrawSprites())
		return false;

	// 4. End the scene and present it
	hr=m_d3dDevice->EndScene();
	if (!CheckHR(hr))
		return false;

	// 5. ...... ta da!
	hr=m_d3dDevice->Present(NULL,NULL,NULL,NULL);
	if (!CheckHR(hr))
		return false;

	return true;
}
Exemplo n.º 3
0
void World::DrawShadows()
{
    float shadow_plane[] = { 0.0f, 0.0f, 100.0f, 1.0f };
	Vector3 vec = light_.GetLocation();
	float position[] = {vec.X(), vec.Y(), vec.Z(), 1.0f};
	BuildShadowMatrix(shadow_matrix, position, shadow_plane);
	
    glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF);
    glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glColor4f(0.1f, 0.1f, 0.1f, 0.8f);
    
    glPushMatrix();
    glTranslatef(0.0f, -0.8f, 0.5f);
    glMultMatrixf(shadow_matrix);
   
    DrawSprites();
   
    glPopMatrix();
    glDisable(GL_BLEND);
    glEnable(GL_DEPTH_TEST);
}
Exemplo n.º 4
0
void World::DrawScene()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    camera_.Apply();
    
    glLoadIdentity();

    DrawReflections();
    DrawShadows();

    // ¹Ù´Ú ±×¸®±â
	glDisable(GL_STENCIL_TEST);
	glEnable(GL_BLEND);
	glDisable(GL_LIGHTING);
	glColor4f(1.0f, 1.0f, 1.0f, 0.8f);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	DrawFloor();
	glEnable(GL_LIGHTING);
	glDisable(GL_BLEND);

    // ½Ç¹° ½ºÇÁ¶óÀÌÆ® ±×¸®±â
    //glTranslatef(0.0f, 0.0f, 1.5f);
    DrawSprites();

    DrawOrigin();
    DrawCollisionInfo();
}
Exemplo n.º 5
0
void QUADAPULT_Draw()
{
    if (s_useGraph)
    {
        if (s_useBatching)
            DrawSpritesBatched(&s_spriteVec[0], s_spriteVec.size());
        else
            DrawSprites(&s_spriteVec[0], s_spriteVec.size());
        s_spriteVec.clear();
    }
    else
    {
        if (s_useBatching)
            DrawSpritesBatched(&s_spriteVec[1], s_spriteVec.size() - 1);
        else
            DrawSprites(&s_spriteVec[0], s_spriteVec.size());
    }
}
Exemplo n.º 6
0
void Scene::Update(const ObjectList& objList, float dt)
{
	UNREFERENCED_PARAMETER(objList);

	//Refresh the screen
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(m_bgColor.x, m_bgColor.y, m_bgColor.z, m_bgColor.w);

	// Set mouse position
	GetPerspPosition();
	GetOrthoPosition();

	//Todo: Lambda loop expression
	//std::for_each(m_DrawList.begin(), m_DrawList.end(), [&](DrawList::iterator& it)
	//{

	for (auto it = m_DrawList.begin(); it != m_DrawList.end(); ++it)
	{
		if ((*it)->GetType() != PARTICLE)
		{
			//Update pipeline
			Pipeline((*it), dt);
			vec4 sptColor = (*it)->GetColor();

			glUniform4f(m_GSM->GetGLManager()->GetUnifrom(COLOR), sptColor.x, sptColor.y, sptColor.z, sptColor.w);
			glUniform1i(m_GSM->GetGLManager()->GetUnifrom(TYPE), (*it)->GetType());
			glUniform1f(m_GSM->GetGLManager()->GetUnifrom(TIME), Timer::GetInstance().GetElapsedTime());

			//Todo: high quality?
			//glUniformMatrix4fv();

			// Draw Texts 
			if ((*it)->GetType() == TEXT)
				DrawTexts(static_cast<Text*>(*it));
			
			else if ((*it)->GetType() == LIGHT)
				DrawLights(static_cast<Light*>(*it));

			// Draw Sprites
			else if ((*it)->GetType() == SPRITE ||
				(*it)->GetType() == DARKNESS)
				DrawSprites(*it);

		}

		// Draw Particles
		else 
			DrawParticle(static_cast<Emitter*>(*it), dt);
		
	}
}
Exemplo n.º 7
0
int main()
{
	

	
	InitGraphics();



	giftable.packet_count	= GIF_PACKET_MAX;
	giftable.packet			= &packets[0];



	

	InitSprites();

	

	

	while(1)
	{
		GsGifPacketsClear(&giftable);		// clear the area that we are going to put the sprites/triangles/....

		

		MoveSprites();
		DrawSprites(&giftable);				//add stuff to the packet area
	
		


		GsDrawSync(0);
		GsVSync(0);
		GsClearDrawEnv1(&draw_env);			// clear the draw environment before we draw stuff on it
		GsGifPacketsExecute(&giftable, 1);	// set to '1' becuse we want to wait for drawing to finish. if we dont wait we will write on packets that is currently writing to the gif
		
	}


	return 0;
}
Exemplo n.º 8
0
void GrassBlendingGame::Draw()
{
    constexpr bool enableFxaa = true;

    if (enableFxaa) {
        auto bounds = renderTarget->Bounds();
        graphicsContext->SetRenderTarget(renderTarget);
        graphicsContext->SetViewport(Viewport{bounds});
        graphicsContext->SetScissorRectangle(bounds);
    }

    graphicsContext->Clear(Color::CornflowerBlue);
    {
        auto transform = mainCamera.Component<Transform2D>();
        auto camera = mainCamera.Component<Camera2D>();

        POMDOG_ASSERT(transform && camera);
        auto viewMatrix = SandboxHelper::CreateViewMatrix(*transform, *camera);
        auto projectionMatrix = Matrix4x4::CreateOrthographicLH(
            clientViewport.Width, clientViewport.Height, 0.1f, 1000.0f);

        editorBackground->SetViewProjection(viewMatrix * projectionMatrix);
    }
    editorBackground->Draw(*graphicsContext);

    graphicsContext->SetSamplerState(0, samplerPoint);
    DrawSprites();
    DrawSkinnedMesh();

    if (enableFxaa) {
        graphicsContext->SetRenderTarget();
        graphicsContext->SetViewport(clientViewport);
        graphicsContext->SetScissorRectangle(clientViewport.GetBounds());
        graphicsContext->Clear(Color::CornflowerBlue);
        fxaa->SetTexture(renderTarget);
        fxaa->Apply(*graphicsContext);
        screenQuad->DrawQuad(*graphicsContext);
    }

    gameEditor->DrawGUI(*graphicsContext);
    commandQueue->Present();
}
Exemplo n.º 9
0
void World::DrawReflections()
{
    //glTranslatef(1.0f, 0.0f, -3.6f);  // * ÇÊ¿ä¾ø´Â Translate·Î º¸ÀÓ
	glColorMask(0, 0, 0, 0);
	glEnable(GL_STENCIL_TEST);
	glStencilFunc(GL_ALWAYS, 1, 1);
	glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
	glDisable(GL_DEPTH_TEST);
	DrawFloor();
	glEnable(GL_DEPTH_TEST);
	glColorMask(1,1,1,1);
	glStencilFunc(GL_EQUAL, 1, 1);
	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
	
    glPushMatrix();
    glTranslatef(0.0f, 0.0f, -1.5f);
	glScalef(1.0f, 1.0f, -1.0f);
	
    DrawSprites();
	
    glPopMatrix();
}
Exemplo n.º 10
0
//----------------------------------------------------------------------------------------------------
void GBGpu::DrawLine()
{
    uint32 u32Offset = m_u8LCDScanline * GBScreenWidth;
    for( uint32 i = u32Offset; i < u32Offset + GBScreenWidth; ++i )
    {
        m_u32ScreenData[ i ] = ColorWhite;
    }

    if( IsBackgroundEnabled() )
    {
        DrawBackground();
    }

    if( IsWindowEnabled() )
    {
        DrawWindow();
    }

    if( IsSpriteEnabled() )
    {
        DrawSprites();
    }
}
Exemplo n.º 11
0
void	InitLevel( void )
{
	int		i;
	char	text[64];

	in_level=0;
	pause=0;
	killall=0;
	action=0;
	lem_in=0;
	lem_run=0;
	afunc=-1;
	main_x=660;
	memset(deko,0,sizeof(deko));
	memset(bgImage,STEELBLUE,1600*160);
	deko[0]=CreateSprite(0,0,main_x+160,80);			// cursor
	deko[0]->anilocked=1;
	switch( level )
	{
	case 1 :
	case 4 :
	case 6 :
		/* deko */
		deko[1]=CreateSprite(1,0,726,39);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,0,871,106);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,876,108);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,902,108);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		switch( level )
		{
		case 6 :
			portfolio[7]=2;
			portfolio[3]=2;
			portfolio[2]=2;
			break;
		case 1 :
			portfolio[7]=10;
#if 1
portfolio[6]=10;
portfolio[4]=10;
portfolio[3]=10;
portfolio[2]=10;
#endif
			break;
		case 4 :
			portfolio[2]=5;
			break;
		}
		haus_x=889;
		haus_y1=117;
		haus_y2=135;
		to_rescue=level==6?39:5;
		newspeed=level==6?1:50;
		lem_cnt=level==6?40:10;
		break;
	case 2 :
		/* deko */
		deko[1]=CreateSprite(1,0,726,7);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,1,700,128);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,704,129);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,731,129);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		portfolio[3]=4;
		haus_x=718;
		haus_y1=139;
		haus_y2=157;
		to_rescue=25;
		newspeed=50;
		lem_cnt=50;
		break;
	case 3 :
		/* deko */
		deko[1]=CreateSprite(1,0,726,23);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,1,1000,128);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,1004,129);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,1031,129);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		portfolio[3]=2;
		portfolio[7]=2;
		haus_x=1018;
		haus_y1=139;
		haus_y2=157;
		to_rescue=50;
		newspeed=50;
		lem_cnt=50;
		break;
	case 5 :
		/* deko */
		deko[1]=CreateSprite(1,0,712,3);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,1,1150,117);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,1154,118);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,1181,118);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* feuer */
		deko[5]=CreateSprite(9,0,849,39);		// feuer
		deko[6]=CreateSprite(9,0,979,39);		// feuer
		deko[7]=CreateSprite(9,0,880,66);		// feuer
		deko[8]=CreateSprite(9,0,880,107);		// feuer
		deko[9]=CreateSprite(9,0,979,131);		// feuer
		deko[10]=CreateSprite(9,0,1002,86);		// feuer

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		portfolio[2]=5;
		portfolio[3]=3;
		haus_x=1168;
		haus_y1=128;
		haus_y2=146;
		to_rescue=30;
		newspeed=50;
		lem_cnt=50;
		break;
	}
	minspeed=newspeed;
	DrawLevelIntoBg();
	/* copy level to screen */
	CopyBg2Screen( main_x, 0, 328, 160 );
	SpritesGetBackground();
	DrawSprites();
	/* Draw Menu-Item-Numbers */
	for( i=0; i<8; i++ )
		DrawNumber( 106+i*32, 389, portfolio[i] );

	DrawNumber( 42, 389, newspeed );
	DrawNumber( 74, 389, 100-newspeed );
	DrawInfo(3);
	/* show level info */
	FBFillRect( 60, 448, 200, 100, BLACK );
	sprintf(text,"Lemmings : %d  ",lem_cnt);
	FBDrawString(64,450,32,text,WHITE,0);
	sprintf(text,"%d%% to be saved  ",to_rescue*100/lem_cnt);
	FBDrawString(64,482,32,text,WHITE,0);
	sprintf(text,"Release Rate %d  ",100-newspeed);
	FBDrawString(64,514,32,text,WHITE,0);
	SoundPlay( SND_LETSGO );
}
Exemplo n.º 12
0
static void DrvDraw()
{
	DrawBackground();
	DrawSprites();
}
Exemplo n.º 13
0
//
// Draw
//
void Raycaster::Draw()
{
	float angle;
	float horizDist, vertDist, distance;
	int wallH, x, texIndex, texIndexHor, texIndexVert;
	float texelX, texelXHor, texelXVert;
	bool dark;
	
	UpdateDoors();
	
	if(badQuality)
	{
		framework->FillRect(&upperRect, roofColor);
		framework->FillRect(&lowerRect, floorColor);
	}
	else
	{
		framework->Draw(skyImg);
		framework->Draw(roofImg, 0, skyImg->h);
	}
		
	framework->LockScreen();
	
	angle = alpha + FOV / 2;
	
	for(x = 0; x < target->w; x++)
	{		
		if(angle < 0)
			angle += 360;
		else if(angle > 360)
			angle -= 360;
		
		if(angle == 90 || angle == 0 || angle == 270)
			angle += 0.00001f;
		
		horizDist = CastThroughIntersections(angle, ID_HORIZONTAL, &texIndexHor, &texelXHor);
		vertDist = CastThroughIntersections(angle, ID_VERTICAL, &texIndexVert, &texelXVert);
		
		if(horizDist < vertDist)
		{
			texIndex = texIndexHor;
			distance = horizDist;
			texelX = texelXHor;
			dark = true;
		}
		else
		{
			texIndex = texIndexVert;
			distance = vertDist;
			texelX = texelXVert;
			dark = false;
		}		
		
		distance = CorrDistance(distance, angle);
		zBuffer[x] = distance;
		wallH = DistToWallHeight(distance);
		
		texelX *= (float)TEXTURE_W;
		texelX = TEXTURE_W - texelX;
		
		DrawWallSlice(x, wallH, texIndex, texelX, dark);
		
		if(badQuality)
		{
			x++;
			zBuffer[x] = distance;
			DrawWallSlice(x, wallH, texIndex, texelX, dark);
			angle -= (float)FOV / (float)target->w * 2.0f;
		}
		else
			angle -= (float)FOV / (float)target->w;
	}
	
	DrawSprites();
	
	framework->UnlockScreen();
}