void TCOD_sys_set_fullscreen(bool fullscreen) { bool mouseOn=SDL_ShowCursor(-1); fullscreen_on=fullscreen; /* SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_InitSubSystem(SDL_INIT_VIDEO); charmap=SDL_LoadBMP(font_file); if (charmap == NULL ) TCOD_fatal("SDL : cannot load %s",font_file); memset(charcols,128,256*sizeof(TCOD_color_t)); */ if ( fullscreen ) { find_resolution(); screen=SDL_SetVideoMode(actual_fullscreen_width,actual_fullscreen_height,32,SDL_FULLSCREEN); if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot set fullscreen video mode"); SDL_ShowCursor(mouseOn ? 1:0); actual_fullscreen_width=screen->w; actual_fullscreen_height=screen->h; 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 { screen=SDL_SetVideoMode(consoleWidth*fontWidth,consoleHeight*fontHeight,32,0); if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot create window"); SDL_ShowCursor(mouseOn ? 1:0); fullscreen_offsetx=0; fullscreen_offsety=0; } /* SDL_WM_SetCaption(window_title,NULL); */ oldFade=-1; // to redraw the whole screen SDL_UpdateRect(screen, 0, 0, 0, 0); }
void Processor::encode_text(int padding) { static const zchar again[] = { 'a', 'g', 'a', 'i', 'n', 0, 0, 0, 0 }; static const zchar examine[] = { 'e', 'x', 'a', 'm', 'i', 'n', 'e', 0, 0 }; static const zchar wait[] = { 'w', 'a', 'i', 't', 0, 0, 0, 0, 0 }; zbyte *zchars; const zchar *ptr; zchar c; int i = 0; if (_resolution == 0) find_resolution(); zchars = new byte[3 * (_resolution + 1)]; ptr = _decoded; // Expand abbreviations that some old Infocom games lack if (_expand_abbreviations && (h_version <= V8)) { if (padding == 0x05 && _decoded[1] == 0) { switch (_decoded[0]) { case 'g': ptr = again; break; case 'x': ptr = examine; break; case 'z': ptr = wait; break; default: break; } } } // Translate string to a sequence of Z-characters while (i < 3 * _resolution) { if ((c = *ptr++) != 0) { int index, set; zbyte c2; if (c == ' ') { zchars[i++] = 0; continue; } // Search character in the alphabet for (set = 0; set < 3; set++) for (index = 0; index < 26; index++) if (c == alphabet (set, index)) goto letter_found; // Character not found, store its ZSCII value c2 = translate_to_zscii(c); zchars[i++] = 5; zchars[i++] = 6; zchars[i++] = c2 >> 5; zchars[i++] = c2 & 0x1f; continue; letter_found: // Character found, store its index if (set != 0) zchars[i++] = ((h_version <= V2) ? 1 : 3) + set; zchars[i++] = index + 6; } else {
bool TCOD_sys_init(int w,int h, char_t *buf, char_t *oldbuf, bool fullscreen) { if ( ! has_startup ) TCOD_sys_startup(); consoleWidth=w; consoleHeight=h; if (! charmap) TCOD_sys_load_font(); if ( fullscreen ) { find_resolution(); screen=SDL_SetVideoMode(actual_fullscreen_width,actual_fullscreen_height,32,SDL_FULLSCREEN); if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot set fullscreen video mode"); SDL_ShowCursor(0); actual_fullscreen_width=screen->w; actual_fullscreen_height=screen->h; fullscreen_offsetx=(actual_fullscreen_width-consoleWidth*fontWidth)/2; fullscreen_offsety=(actual_fullscreen_height-consoleHeight*fontHeight)/2; SDL_FillRect(screen,0,0); } else { screen=SDL_SetVideoMode(w*fontWidth,h*fontHeight,32,0); if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot create window"); } //if ( SDL_MUSTLOCK( charmap ) ) SDL_UnlockSurface( charmap ); SDL_EnableUNICODE(1); consoleBuffer=buf; prevConsoleBuffer=oldbuf; fullscreen_on=fullscreen; memset(key_status,0,sizeof(bool)*(TCODK_CHAR+1)); memset(ascii_updated,0,sizeof(bool)*TCOD_max_font_chars); return true; }
static void create_window(int w, int h, bool fullscreen) { Uint32 winflags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL; #if defined(TCOD_ANDROID) /* Android should always be fullscreen. */ TCOD_ctx.fullscreen = fullscreen = true; #endif if ( fullscreen ) { find_resolution(); #ifndef NO_OPENGL if (TCOD_ctx.renderer != TCOD_RENDERER_SDL ) { TCOD_opengl_init_attributes(); winflags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL; # if defined(TCOD_ANDROID) && defined(FUTURE_SUPPORT) winflags |= SDL_WINDOW_RESIZABLE; # endif window = SDL_CreateWindow(TCOD_ctx.window_title,SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,TCOD_ctx.actual_fullscreen_width,TCOD_ctx.actual_fullscreen_height,winflags); if ( window && TCOD_opengl_init_state(w, h, charmap) && TCOD_opengl_init_shaders() ) { TCOD_LOG(("Using %s renderer...\n",TCOD_ctx.renderer == TCOD_RENDERER_GLSL ? "GLSL" : "OPENGL")); } else { TCOD_LOG(("Fallback to SDL renderer...\n")); TCOD_ctx.renderer = TCOD_RENDERER_SDL; } } #endif if (TCOD_ctx.renderer == TCOD_RENDERER_SDL ) { winflags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS; # if defined(TCOD_ANDROID) && defined(FUTURE_SUPPORT) winflags |= SDL_WINDOW_RESIZABLE; # endif window = SDL_CreateWindow(TCOD_ctx.window_title,SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, TCOD_ctx.actual_fullscreen_width,TCOD_ctx.actual_fullscreen_height,winflags); if ( window == NULL ) TCOD_fatal_nopar("SDL : cannot set fullscreen video mode"); } SDL_ShowCursor(0); SDL_GetWindowSize(window,&TCOD_ctx.actual_fullscreen_width,&TCOD_ctx.actual_fullscreen_height); TCOD_sys_init_screen_offset(); } else { #ifndef NO_OPENGL if (TCOD_ctx.renderer != TCOD_RENDERER_SDL ) { TCOD_opengl_init_attributes(); winflags |= SDL_WINDOW_OPENGL; window = SDL_CreateWindow(TCOD_ctx.window_title,SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,w*TCOD_ctx.font_width,h*TCOD_ctx.font_height,winflags); if ( window && TCOD_opengl_init_state(w, h, charmap) && TCOD_opengl_init_shaders() ) { TCOD_LOG(("Using %s renderer...\n",TCOD_ctx.renderer == TCOD_RENDERER_GLSL ? "GLSL" : "OPENGL")); } else { TCOD_LOG(("Fallback to SDL renderer...\n")); TCOD_ctx.renderer = TCOD_RENDERER_SDL; } } #endif if (TCOD_ctx.renderer == TCOD_RENDERER_SDL ) { window = SDL_CreateWindow(TCOD_ctx.window_title,SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,w*TCOD_ctx.font_width,h*TCOD_ctx.font_height,winflags); TCOD_LOG(("Using SDL renderer...\n")); } if ( window == NULL ) TCOD_fatal_nopar("SDL : cannot create window"); } renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); if ( renderer == NULL ) TCOD_fatal_nopar("SDL : cannot create renderer"); SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); }
static void set_fullscreen(bool fullscreen) { bool mouseOn=SDL_ShowCursor(-1); if ( fullscreen ) { SDL_Surface *newscreen; find_resolution(); newscreen=SDL_SetVideoMode(TCOD_ctx.actual_fullscreen_width,TCOD_ctx.actual_fullscreen_height,32,SDL_FULLSCREEN); TCOD_IFNOT ( newscreen != NULL ) return; screen=newscreen; SDL_ShowCursor(mouseOn ? 1:0); TCOD_ctx.actual_fullscreen_width=screen->w; TCOD_ctx.actual_fullscreen_height=screen->h; TCOD_sys_init_screen_offset(); } else {
static void create_window(int w, int h, bool fullscreen) { if ( fullscreen ) { find_resolution(); #ifndef NO_OPENGL if (TCOD_ctx.renderer != TCOD_RENDERER_SDL ) { TCOD_opengl_init_attributes(); screen=SDL_SetVideoMode(TCOD_ctx.actual_fullscreen_width,TCOD_ctx.actual_fullscreen_height,32,SDL_FULLSCREEN|SDL_OPENGL); if ( screen && TCOD_opengl_init_state(w, h, charmap) && TCOD_opengl_init_shaders() ) { TCOD_LOG(("Using %s renderer...\n",TCOD_ctx.renderer == TCOD_RENDERER_GLSL ? "GLSL" : "OPENGL")); } else { TCOD_LOG(("Fallback to SDL renderer...\n")); TCOD_ctx.renderer = TCOD_RENDERER_SDL; } } #endif if (TCOD_ctx.renderer == TCOD_RENDERER_SDL ) { screen=SDL_SetVideoMode(TCOD_ctx.actual_fullscreen_width,TCOD_ctx.actual_fullscreen_height,32,SDL_FULLSCREEN); if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot set fullscreen video mode"); } SDL_ShowCursor(0); TCOD_ctx.actual_fullscreen_width=screen->w; TCOD_ctx.actual_fullscreen_height=screen->h; TCOD_sys_init_screen_offset(); SDL_FillRect(screen,0,0); } else { #ifndef NO_OPENGL if (TCOD_ctx.renderer != TCOD_RENDERER_SDL ) { TCOD_opengl_init_attributes(); screen=SDL_SetVideoMode(w*TCOD_ctx.font_width,h*TCOD_ctx.font_height,32,SDL_OPENGL); if ( screen && TCOD_opengl_init_state(w, h, charmap) && TCOD_opengl_init_shaders() ) { TCOD_LOG(("Using %s renderer...\n",TCOD_ctx.renderer == TCOD_RENDERER_GLSL ? "GLSL" : "OPENGL")); } else { TCOD_LOG(("Fallback to SDL renderer...\n")); TCOD_ctx.renderer = TCOD_RENDERER_SDL; } } #endif if (TCOD_ctx.renderer == TCOD_RENDERER_SDL ) { screen=SDL_SetVideoMode(w*TCOD_ctx.font_width,h*TCOD_ctx.font_height,32,0); TCOD_LOG(("Using SDL renderer...\n")); } if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot create window"); } SDL_EnableUNICODE(1); TCOD_ctx.fullscreen=fullscreen; }
static void set_fullscreen(bool fullscreen) { bool mouseOn=SDL_ShowCursor(-1); if ( fullscreen ) { find_resolution(); SDL_SetWindowFullscreen(window, fullscreen); SDL_ShowCursor(mouseOn ? 1:0); SDL_GetWindowSize(window,&TCOD_ctx.actual_fullscreen_width,&TCOD_ctx.actual_fullscreen_height); TCOD_sys_init_screen_offset(); } else { SDL_SetWindowFullscreen(window, fullscreen); SDL_ShowCursor(mouseOn ? 1:0); TCOD_ctx.fullscreen_offsetx=0; TCOD_ctx.fullscreen_offsety=0; } TCOD_ctx.fullscreen=fullscreen; oldFade=-1; /* to redraw the whole screen */ }
void Processor::load_string (zword addr, zword length) { int i = 0; if (_resolution == 0) find_resolution(); while (i < 3 * _resolution) { if (i < length) { zbyte c; LOW_BYTE(addr, c); addr++; _decoded[i++] = translate_from_zscii(c); } else { _decoded[i++] = 0; } } }
bool TCOD_sys_init(int w,int h, char_t *buf, char_t *oldbuf, bool fullscreen) { FILE *f; if ( ! has_startup ) TCOD_sys_startup(); /* check if there is a user (player) config file */ f = fopen("./libtcod.cfg","r"); if ( f ) { fclose(f); /* yes, read it */ TCOD_sys_load_player_config(); if (TCOD_ctx.fullscreen) fullscreen=true; } if (! charmap) TCOD_sys_load_font(); if ( fullscreen ) { find_resolution(); if (TCOD_ctx.renderer == TCOD_RENDERER_SDL ) { screen=SDL_SetVideoMode(TCOD_ctx.actual_fullscreen_width,TCOD_ctx.actual_fullscreen_height,32,SDL_FULLSCREEN); if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot set fullscreen video mode"); } SDL_ShowCursor(0); TCOD_ctx.actual_fullscreen_width=screen->w; TCOD_ctx.actual_fullscreen_height=screen->h; TCOD_ctx.fullscreen_offsetx=(TCOD_ctx.actual_fullscreen_width-TCOD_ctx.root->w*TCOD_ctx.font_width)/2; TCOD_ctx.fullscreen_offsety=(TCOD_ctx.actual_fullscreen_height-TCOD_ctx.root->h*TCOD_ctx.font_height)/2; SDL_FillRect(screen,0,0); } else { if (TCOD_ctx.renderer == TCOD_RENDERER_SDL ) { screen=SDL_SetVideoMode(w*TCOD_ctx.font_width,h*TCOD_ctx.font_height,32,0); TCOD_LOG(("Using SDL renderer...\n")); } if ( screen == NULL ) TCOD_fatal_nopar("SDL : cannot create window"); } SDL_EnableUNICODE(1); consoleBuffer=buf; prevConsoleBuffer=oldbuf; TCOD_ctx.fullscreen=fullscreen; memset(key_status,0,sizeof(bool)*(TCODK_CHAR+1)); memset(ascii_updated,0,sizeof(bool)*TCOD_ctx.max_font_chars); return true; }
static void add_video_format (ofGstDevice &webcam_device, ofGstVideoFormat &video_format, GstStructure &format_structure, int desired_framerate) { ofLog(OF_LOG_NOTICE,"%s %d x %d framerates:", video_format.mimetype.c_str(), video_format.width, video_format.height); get_supported_framerates (video_format, format_structure); find_framerate (video_format, desired_framerate); int i = find_resolution(webcam_device,video_format.width, video_format.height); if (i!=-1) { // Resolution already added ? float new_framerate = (float)video_format.choosen_framerate.numerator / video_format.choosen_framerate.denominator; float curr_framerate = (float)webcam_device.video_formats[i].choosen_framerate.numerator / webcam_device.video_formats[i].choosen_framerate.denominator; if (desired_framerate == -1){ if(new_framerate > curr_framerate) { ofLog(OF_LOG_VERBOSE,"higher framerate replacing existing format\n"); webcam_device.video_formats[i] = video_format; }else{ ofLog(OF_LOG_VERBOSE,"already added, skipping\n"); } }else{ if(fabs(new_framerate - desired_framerate) < fabs(curr_framerate - desired_framerate) ){ ofLog(OF_LOG_VERBOSE,"more similar framerate replacing existing format\n"); webcam_device.video_formats[i] = video_format; }else{ ofLog(OF_LOG_VERBOSE,"already added, skipping\n"); } } return; } webcam_device.video_formats.push_back(video_format); }
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; }
void CSettingDlg::ParseFilename(const char* pFilename) { int nYuvFormat = 0; int nWidth = 0; int nHeight = 0; find_resolution((char*)pFilename, nYuvFormat, nWidth, nHeight); // 保留原来的值 if (nYuvFormat != -1) { m_nYuvFormat = nYuvFormat; } if (nWidth > 0 && nHeight > 0) { m_nWidth = nWidth; m_nHeight = nHeight; } // 更新控件 UpdateRes(); m_cbYuvFormat.SetCurSel(m_nYuvFormat); UpdateData(FALSE); }
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); } }