All pastes #795072 Raw Edit

Unnamed

public text v1 · immutable
#795072 ·published 2007-11-23 17:28 UTC
rendered paste body
int init()

{

	if (SDL_Init(SDL_INIT_VIDEO /*| SDL_INIT_AUDIO*/) < 0)

	{

		fprintf(stderr, "Failed to initialize SDL: %s\n", SDL_GetError());

		return -1;

	}

	atexit(SDL_Quit);

	

	SetVideoMode( false, g_oState.m_bFullscreen );

	if (gamescreen == NULL)

	{

		fprintf(stderr, "failed to set video mode: %s\n", SDL_GetError());

		return -1;

	}

	

	SDL_WM_SetCaption( "OpenMortal", "OpenMortal" );

	std::string sPath = std::string(DATADIR) + "/gfx/icon.png";

	SDL_WM_SetIcon(IMG_Load(sPath.c_str()), NULL);

	SDL_ShowCursor( SDL_DISABLE );



	int i;

	for ( i=0; i<16; ++i ) 

	{ 

		Colors[i].r *=4; Colors[i].g *=4; Colors[i].b *=4;

	}

	if ( gamescreen->format->BitsPerPixel > 8 )

	{

		i = 0;

		C_BLACK			= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_BLUE			= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_GREEN			= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_CYAN			= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;



		C_RED			= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_MAGENTA		= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_ORANGE		= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_LIGHTGRAY		= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;



		C_DARKGRAY		= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_LIGHTBLUE		= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_LIGHTGREEN	= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_LIGHTCYAN		= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;



		C_LIGHTRED		= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_LIGHTMAGENTA	= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_YELLOW		= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

		C_WHITE			= SDL_MapRGB( gamescreen->format, Colors[i].r, Colors[i].g, Colors[i].b ); ++i;

	}

	else

	{

		SDL_SetColors( gamescreen, Colors, 256-16, 16 );

		C_BLACK			= 240;

		C_BLUE			= 241;

		C_GREEN			= 242;

		C_CYAN			= 243;



		C_RED			= 244;

		C_MAGENTA		= 245;

		C_ORANGE		= 246;

		C_LIGHTGRAY		= 247;



		C_DARKGRAY		= 248;

		C_LIGHTBLUE		= 249;

		C_LIGHTGREEN	= 250;

		C_LIGHTCYAN		= 251;



		C_LIGHTRED		= 252;

		C_LIGHTMAGENTA	= 253;

		C_YELLOW		= 254;

		C_WHITE			= 255;

	}



	if ( sge_TTF_Init() )

	{

		fprintf(stderr, "couldn't start ttf engine: %s\n", SDL_GetError());

		return -1;

	}



	sge_TTF_AAOff();

	

	inkFont = LoadTTF( "aardvark.ttf", 20 );

	if ( !inkFont ) return -1;

	impactFont = LoadTTF( "bradybun.ttf", 20 );	// gooddogc.ttf, 20

	if ( !impactFont ) return -1;

	titleFont = LoadTTF( "deadgrit.ttf", 48 );		// deadgrit.ttf, 48

	if ( !titleFont ) return -1;

	chatFont = LoadTTF( "thin.ttf", 20 );		// deadgrit.ttf, 48

	if ( !chatFont ) return -1;



	fastFont = LoadBMPFont( "brandybun3.png" );

	if ( !fastFont ) return -1;

	creditsFont = LoadBMPFont( "CreditsFont2.png" );//"fangfont.png" );

	if ( !creditsFont ) return -1;

	storyFont = LoadBMPFont( "glossyfont.png" );

	if ( !storyFont ) return -1;

	

    return 0;

}