示例#1
0
bool TCOD_sys_init(int w,int h, char_t *buf, char_t *oldbuf, bool fullscreen) {
	consoleWidth=w;
	consoleHeight=h;
	
	if ( fullscreen ) {
		find_resolution();
		sfWindowSettings Settings = {0, 0, 0};
		sfVideoMode Mode = {actual_fullscreen_width, actual_fullscreen_height, 32};
		renderWindow=sfRenderWindow_Create(Mode,window_title,sfFullscreen,Settings);
		TCOD_mouse_show_cursor(false);
		actual_fullscreen_width=sfRenderWindow_GetWidth(renderWindow);
		actual_fullscreen_height=sfRenderWindow_GetHeight(renderWindow);
		fullscreen_offsetx=(actual_fullscreen_width-consoleWidth*fontWidth)/2;
		fullscreen_offsety=(actual_fullscreen_height-consoleHeight*fontHeight)/2;
	} else {
		sfWindowSettings Settings = {0, 0, 0};
		sfVideoMode Mode = {w*fontWidth, h*fontHeight, 32};
		renderWindow=sfRenderWindow_Create(Mode,window_title,sfClose,Settings);
		TCOD_mouse_show_cursor(true);
	}
	charmap=sfImage_CreateFromFile(font_file);
	if (charmap == NULL ) TCOD_fatal("SFML : cannot load %s",font_file);
	if ( sfImage_GetWidth(charmap) < fontNbCharHoriz * fontWidth 
		|| sfImage_GetHeight(charmap) < fontNbCharVertic * fontHeight ) TCOD_fatal("bitmap %s too small for %dx%d, %dx%d characters\n",
		font_file,fontWidth,fontHeight,fontNbCharHoriz,fontNbCharVertic);
	sfColor colorKey={fontKeyCol.r,fontKeyCol.g,fontKeyCol.b,255};
	sfImage_CreateMaskFromColor(charmap, colorKey, 0);
	sfImage_SetSmooth(charmap, sfFalse);
	sfImage_Bind(charmap);
	charmapSprite=sfSprite_Create();
	sfSprite_SetImage(charmapSprite,charmap);
	sfSprite_SetBlendMode(charmapSprite,sfBlendNone);
	consoleBuffer=buf;
	prevConsoleBuffer=oldbuf;
	fullscreen_on=fullscreen;
	memset(key_status,0,sizeof(bool)*(TCODK_CHAR+1));
	return true;
}
示例#2
0
void TCOD_sys_set_fullscreen(bool fullscreen) {
	fullscreen_on=fullscreen;
	if ( fullscreen ) {
		find_resolution();
		sfWindowSettings Settings = {24, 8, 0};
		sfVideoMode Mode = {actual_fullscreen_width, actual_fullscreen_height, 32};
		renderWindow=sfRenderWindow_Create(Mode,window_title,sfFullscreen,Settings);
		TCOD_mouse_show_cursor(false);
		actual_fullscreen_width=sfRenderWindow_GetWidth(renderWindow);
		actual_fullscreen_height=sfRenderWindow_GetHeight(renderWindow);
		fullscreen_offsetx=(actual_fullscreen_width-consoleWidth*fontWidth)/2;
		fullscreen_offsety=(actual_fullscreen_height-consoleHeight*fontHeight)/2;
		/*
		printf ("actual resolution : %dx%d\n",actual_fullscreen_width,actual_fullscreen_height);
		printf ("offset : %dx%d\n",fullscreen_offsetx,fullscreen_offsety);
		printf ("flags : %x bpp : %d bitspp : %d\n",screen->flags, screen->format->BytesPerPixel, screen->format->BitsPerPixel);
		*/
	} else {
		sfWindowSettings Settings = {24, 8, 0};
		sfVideoMode Mode = {consoleWidth*fontWidth, consoleHeight*fontHeight, 32};
		renderWindow=sfRenderWindow_Create(Mode,window_title,sfClose|sfTitlebar,Settings);
		TCOD_mouse_show_cursor(true);
	}
}
CSFML_API sfRenderWindow *sfRenderWindow_CreateWrapper(sfVideoMode *mode, const char *title, unsigned long style, const sfContextSettings *settings)
{
  return sfRenderWindow_Create(*mode, title, style, settings);
}