コード例 #1
0
ファイル: blur.cpp プロジェクト: foxblock/BattlePong
void ShaderBlur::Apply( SDL_Surface* Target )
{
	// Keep render target (might not be applying shader to screen)
	SDL_Surface* r = spGetRenderTarget();

	SDL_Surface* t = spUniqueCopySurface( Target );
	
	spSetHorizontalOrigin( SP_LEFT );
	spSetVerticalOrigin( SP_TOP );

	spSelectRenderTarget( t );
	spSetBlending( SP_ONE );
	spBlitSurface( 0, 0, -1, Target );
	spSetBlending( SP_ONE >> 2 );
	for( int y = -1; y <= 1; y++ )
	{
		for( int x = -1; x <= 1; x++ )
		{
			if( x != 0 && y != 0 )
			{
				spBlitSurface( x, y, -1, Target );
			}
		}
	}

	spSelectRenderTarget( Target );
	spSetBlending( SP_ONE );
	spBlitSurface( 0, 0, -1, t );

	spDeleteSurface( t );

	// Restore render target
	spSelectRenderTarget( r );
}
コード例 #2
0
ファイル: fade.cpp プロジェクト: foxblock/BattlePong
void TransitionFade::Render()
{
	spSetHorizontalOrigin( SP_LEFT );
	spSetVerticalOrigin( SP_TOP );

	// Draw original source
	spSetBlending( SP_ONE );
	spBlitSurface( 0, 0, -1, SourceScreen );
	// Alpha it to the actual screen
	spSetBlending( Alpha );
	spBlitSurface( 0, 0, -1, TargetScreen );
	spSetBlending( SP_ONE );
}
コード例 #3
0
ファイル: sparrowFont.c プロジェクト: bzar/sparrow3d
PREFIX void spFontDraw( Sint32 x, Sint32 y, Sint32 z, const char* text, spFontPointer font )
{
	int l = 0;
	int pos = x;
	while ( text[l] != 0 )
	{
		if (text[l] == '\n')
		{
			pos = x;
			y+=font->maxheight;
			l++;
			continue;
		}
    spLetterPointer letter;
    //first we look for buttons
    if (text[l]==spFontButtonLeft && (letter = spLetterFind( font->buttonRoot, text[l+1])) && text[l+2]==spFontButtonRight)
      l+=2;
    else
      letter = spFontGetLetter( font, text[l] ); //TODO utf8
		if ( letter )
		{
			pos += letter->width >> 1;
			spBlitSurface( pos, y + letter->height / 2, z, letter->surface );
			pos += letter->width - ( letter->width >> 1 );
		}
		l++;
	}
}
コード例 #4
0
ファイル: sparrowFont.c プロジェクト: bzar/sparrow3d
PREFIX void spFontDrawMiddle( Sint32 x, Sint32 y, Sint32 z,const char* text, spFontPointer font )
{
	int l = 0;
	int width;
	spLetterIterPointer first = NULL;
	spLetterIterPointer last = NULL;
	int again = 1;
  while (again)
  {
		width = 0;
		again = 0;
		while ( text[l] != 0 )
		{
			if (text[l] == '\n')
			{
				again = 1;
				l++;
				break;
			}
      spLetterPointer letter;
      //first we look for buttons
      if (text[l]==spFontButtonLeft && (letter = spLetterFind( font->buttonRoot, text[l+1])) && text[l+2]==spFontButtonRight)
        l+=2;
      else
        letter = spFontGetLetter( font, text[l] ); //TODO utf8
			if ( letter )
			{
				spLetterIterPointer iter = ( spLetterIterPointer )malloc( sizeof( spLetterIterStruct ) );
				iter->letter = letter;
				if ( first == NULL )
				{
					first = iter;
					last = iter;
				}
				else
				{
					last->next = iter;
					last = iter;
				}
				width += letter->width;
				iter->next = NULL;
			}
			l++;
		}
		int pos = x - width / 2;
		while ( first != NULL )
		{
			pos += first->letter->width >> 1;
			spBlitSurface( pos, y + first->letter->height / 2, z, first->letter->surface );
			pos += first->letter->width - ( first->letter->width >> 1 );
			spLetterIterPointer mom = first;
			first = first->next;
			free( mom );
		}
		if (again)
		  y+=font->maxheight;
	}
}
コード例 #5
0
ファイル: strips.cpp プロジェクト: foxblock/BattlePong
void TransitionStrips::Render()
{
	spSetHorizontalOrigin( SP_LEFT );
	spSetVerticalOrigin( SP_TOP );

	// Draw original source
	spBlitSurface( 0, 0, -1, SourceScreen );

	// Draw strips
	for( int i = 0; i < numStrips; i++ )
	{
		spBlitSurfacePart( i * stripWidth, 0, -1, TargetScreen, i * stripWidth, 0, stripWidth, speedList[i] * frameIndex );
	}
}
コード例 #6
0
ファイル: sparrowSprite.c プロジェクト: foxblock/sparrow3d
PREFIX void spDrawSprite( Sint32 x, Sint32 y, Sint32 z, spSpritePointer sprite )
{
	if ( sprite->rotation == 0 &&
			sprite->zoomX == ( SP_ONE ) &&
			sprite->zoomY == ( SP_ONE ) )
	{
		if ( sprite->momSub->sx < 0 )
			spBlitSurface( x, y, z, sprite->momSub->surface );
		else
			spBlitSurfacePart( x, y, z, sprite->momSub->surface, sprite->momSub->sx, sprite->momSub->sy, sprite->momSub->sw, sprite->momSub->sh );
	}
	else
	{
		if ( sprite->momSub->sx < 0 )
			spRotozoomSurface( x, y, z, sprite->momSub->surface, sprite->zoomX, sprite->zoomY, sprite->rotation );
		else
			spRotozoomSurfacePart( x, y, z, sprite->momSub->surface, sprite->momSub->sx, sprite->momSub->sy, sprite->momSub->sw, sprite->momSub->sh, sprite->zoomX, sprite->zoomY, sprite->rotation );
	}
}
コード例 #7
0
ファイル: titlestage.cpp プロジェクト: pmprog/TriggerHappy
void TitleStage::Render()
{
	if( filterIn[7] != 0xFF )
	{
		spSetPattern8(filterIn[0], filterIn[1], filterIn[2], filterIn[3], filterIn[4], filterIn[5], filterIn[6], filterIn[7]);
	}

	spBlitSurface( (gameSettings->ScreenWidth / 2), (gameSettings->ScreenHeight / 2), -1, background );

	if( filterIn[7] != 0xFF )
	{
		spDeactivatePattern();
		return;
	}

	spDeactivatePattern();
	spFontDraw( (gameSettings->ScreenWidth / 2), (gameSettings->ScreenHeight / 4), -1, "[ ] Start Game", mainFont );
	
}
コード例 #8
0
ファイル: fadein.cpp プロジェクト: foxblock/BattlePong
void TransitionFadeIn::Render()
{
	SDL_Surface* b = spGetWindowSurface();
	SDL_Surface* t = spUniqueCopySurface( b );

	// Fade from colour
	spClearTarget( SourceColour );

	// Buffer the next stages screen
	spSelectRenderTarget( t );
	Target->Render();
	spSelectRenderTarget( b );

	// Alpha it to the actual screen
	spSetHorizontalOrigin( SP_LEFT );
	spSetVerticalOrigin( SP_TOP );
	spSetBlending( Alpha );
	spBlitSurface( 0, 0, -1, t );
	spSetBlending( SP_ONE );

	spDeleteSurface( t );
}
コード例 #9
0
ファイル: account.c プロジェクト: theZiz/Sparrow-C4A-Manager
void draw_account(spFontPointer font,spFontPointer font_small,spFontPointer font_very_small)
{
	SDL_Surface* screen = spGetWindowSurface();
	spFontDrawRight( screen->w-2, 2, 0, "[X] Back", font_very_small );
	if (spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS)	
		spFontDrawMiddle( screen->w*2/3, 2, 0, "[B] Enter letter", font_very_small );
	if (spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS)
		spFontDraw( 2, 2, 0, "[L] & [R]: Select Row", font_very_small );
	else
		spFontDraw( 2, 2, 0, SP_PAD_NAME": Select Row", font_very_small );
	switch (mode)
	{
		case 0:
			spFontDrawMiddle( 2*screen->w/3, 1*screen->h/9, 0, ">>> Account Creating <<<", font);
			spFontDrawMiddle( 2*screen->w/3, 2*screen->h/11, 0, "Press [S] to create the account", font_small);
			break;		
		case 1:
			spFontDrawMiddle( 2*screen->w/3, 1*screen->h/9, 0, ">>> Account Editing <<<", font);
			spFontDrawMiddle( 2*screen->w/3, 2*screen->h/11, 0, "Press [S] to save the changes", font_small);
			spFontDrawMiddle( 2*screen->w/3, 2*screen->h/8, 0, "Press [E] to delete the account", font_small);
			break;		
	}
	
	char* mom_line = NULL;
	switch (line)
	{
		case 0: mom_line = shortName; break;
		case 1: mom_line = longName; break;
		case 2: mom_line = password; break;
		case 3: mom_line = mail; break;
	}
	spLine( 2*screen->w/3 + spFontWidth(mom_line,font)/2+1, (line*2+6)*screen->h/18, 0,
	        2*screen->w/3 + spFontWidth(mom_line,font)/2+1, (line*2+7)*screen->h/18, 0, ((blink/512)&1)?0:65535);
	
	spFontDrawRight( screen->w/3, 3*screen->h/9, 0, "3 Letter Nick:", font);
	spFontDrawMiddle( 2*screen->w/3, 3*screen->h/9, 0, shortName, font);
	spLine( screen->w/3+10, 7*screen->h/18, 0, screen->w-10, 7*screen->h/18,0,65535);
	spFontDrawMiddle( 2*screen->w/3, 7*screen->h/18, 0, "(e.g. JHN)", font_very_small);

	spFontDrawRight( screen->w/3, 4*screen->h/9, 0, "Display Nick:", font);
	spFontDrawMiddle( 2*screen->w/3, 4*screen->h/9, 0, longName, font);
	spLine( screen->w/3+10, 9*screen->h/18, 0, screen->w-10, 9*screen->h/18,0,65535);
	spFontDrawMiddle( 2*screen->w/3, 9*screen->h/18, 0, "(e.g. JohnSmith)", font_very_small);

	spFontDrawRight( screen->w/3, 5*screen->h/9, 0, "Password:"******"(alphanumeric, e.g. aBc123)", font_very_small);

	spFontDrawRight( screen->w/3, 6*screen->h/9, 0, "E-Mail address:", font);
	spFontDrawMiddle( 2*screen->w/3, 6*screen->h/9, 0, mail, font);
	spLine( screen->w/3+10, 13*screen->h/18, 0, screen->w-10, 13*screen->h/18,0,65535);
	spFontDrawMiddle( 2*screen->w/3, 13*screen->h/18, 0, "(for score being beaten notification)", font_very_small);
	if (spIsKeyboardPolled() && spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS)
		spBlitSurface(screen->w/2,screen->h-spGetVirtualKeyboard()->h/2,0,spGetVirtualKeyboard());
	
	switch (askMode)
	{
		case 1:
			spInterpolateTargetToColor(0,3*SP_ONE/4);
			spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Are you sure to delete your profile forever?", font);
			spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[S] Yes...     [X] Hell No!", font);
			break;
		case 2:
			spInterpolateTargetToColor(0,3*SP_ONE/4);
			spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Your 3 Letter Nick needs 3 alphanumeric letters.", font);
			spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Okay...", font);
			break;
		case 3:
			spInterpolateTargetToColor(0,3*SP_ONE/4);
			spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Only numbers and characters are allowed for your Nick!", font);
			spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Uuups...", font);
			break;
		case 4:
			spInterpolateTargetToColor(0,3*SP_ONE/4);
			spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Only numbers and characters are allowed for passwords!", font);
			spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Okay...", font);
			break;
		case 5:
			spInterpolateTargetToColor(0,3*SP_ONE/4);
			spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "IF you enter a e-mail, make sure it contains an @.", font);
			spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Okay...", font);
			break;
		case 6:
			spInterpolateTargetToColor(0,3*SP_ONE/4);
			spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Couldn't connect to Server! Check your connection.", font);
			spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Ok", font);
			break;
		case 7:
			spInterpolateTargetToColor(0,3*SP_ONE/4);
			spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Account created successfully", font);
			spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Ok", font);
			break;
		case 8:
			spInterpolateTargetToColor(0,3*SP_ONE/4);
			spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Account edited successfully", font);
			spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Ok", font);
			break;
		case 9:
			spInterpolateTargetToColor(0,3*SP_ONE/4);
			spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Account deleted successfully", font);
			spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, "[B] Ok", font);
			break;
	}	
	if (spNetC4AGetStatus() > 0)
	{
		spInterpolateTargetToColor(0,3*SP_ONE/4);
		spFontDrawMiddle( screen->w/2, screen->h/2-font->maxheight/2, 0, "Connecting to server...", font);
		char buffer[256];
		sprintf(buffer,"Timeout in %i.%i",spNetC4AGetTimeOut()/1000,(spNetC4AGetTimeOut()/100)%10);
		spFontDrawMiddle( screen->w/2, screen->h/2+font->maxheight/2, 0, buffer, font);
	}
}