static void set_video_mode() { int flags = 0; #ifndef HAVE_GLES flags |= SDL_DOUBLEBUF; flags |= SDL_OPENGL; #endif if (g_fs_emu_video_fullscreen == 1) { g_fs_ml_video_width = g_fullscreen_width; g_fs_ml_video_height = g_fullscreen_height; if (g_fs_emu_video_fullscreen_window) { fs_log("using fullscreen window mode\n"); SDL_putenv("SDL_VIDEO_WINDOW_POS=0,0"); flags |= SDL_NOFRAME; fs_ml_set_fullscreen_extra(); } else { fs_log("using SDL_FULLSCREEN mode\n"); flags |= SDL_FULLSCREEN; } fs_log("setting (fullscreen) video mode %d %d\n", g_fs_ml_video_width, g_fs_ml_video_height); g_sdl_screen = SDL_SetVideoMode(g_fs_ml_video_width, g_fs_ml_video_height, 0, flags); //update_viewport(); } else { fs_log("using windowed mode\n"); SDL_putenv("SDL_VIDEO_WINDOW_POS="); g_fs_ml_video_width = g_window_width; g_fs_ml_video_height = g_window_height; if (g_window_resizable) { flags |= SDL_RESIZABLE; } fs_log("setting (windowed) video mode %d %d\n", g_fs_ml_video_width, g_fs_ml_video_height); g_sdl_screen = SDL_SetVideoMode(g_fs_ml_video_width, g_fs_ml_video_height, 0, flags); //update_viewport(); } fs_ml_configure_window(); // FIXME: this can be removed g_fs_ml_opengl_context_stamp++; log_opengl_information(); }
static void set_video_mode() { #ifdef USE_SDL2 int flags = SDL_WINDOW_OPENGL; if (g_fs_emu_video_fullscreen_mode != FULLSCREEN_WINDOW && g_window_resizable) { flags |= SDL_WINDOW_RESIZABLE; } int x = g_window_x, y = g_window_y; int w = -1, h = -1; // if (g_initial_input_grab) { // flags |= SDL_WINDOW_INPUT_GRABBED; // g_has_input_grab = 1; // } if (g_fs_emu_video_fullscreen == 1) { w = g_fullscreen_width; h = g_fullscreen_height; //w = g_window_width; //h = g_window_height; if (g_fs_emu_video_fullscreen_mode == FULLSCREEN_WINDOW) { fs_log("using fullscreen window mode\n"); x = 0; y = 0; //w = g_fullscreen_width; //h = g_fullscreen_height; flags |= SDL_WINDOW_BORDERLESS; } else if (g_fs_emu_video_fullscreen_mode == FULLSCREEN_DESKTOP) { fs_log("using fullscreen desktop mode\n"); // the width and height will not be used for the fullscreen // desktop mode, only for the window when toggling fullscreen // state w = g_window_width; h = g_window_height; // x = 0; // y = 0; // w = g_fullscreen_width; // h = g_fullscreen_height; flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; } else { fs_log("using SDL_FULLSCREEN mode\n"); flags |= SDL_WINDOW_FULLSCREEN; } fs_log("setting (fullscreen) video mode %d %d\n", w, h); } else { w = g_window_width; h = g_window_height; fs_log("using windowed mode\n"); //SDL_putenv("SDL_VIDEO_WINDOW_POS="); fs_log("setting (windowed) video mode %d %d\n", w, h); } #if 0 Uint8 data[] = "\0"; SDL_Cursor *cursor = SDL_CreateCursor(data, data, 8, 1, 0, 0); SDL_SetCursor(cursor); #endif g_fs_ml_video_width = w; g_fs_ml_video_height = h; fs_log("SDL_CreateWindow(x=%d, y=%d, w=%d, h=%d, flags=%d)\n", x, y, w, h, flags); g_fs_ml_window = SDL_CreateWindow(g_window_title, x, y, w, h, flags); g_fs_ml_context = SDL_GL_CreateContext(g_fs_ml_window); #else int flags = SDL_DOUBLEBUF | SDL_OPENGL; if (g_fs_emu_video_fullscreen == 1) { g_fs_ml_video_width = g_fullscreen_width; g_fs_ml_video_height = g_fullscreen_height; if (g_fs_emu_video_fullscreen_mode == FULLSCREEN_WINDOW) { fs_log("using fullscreen window mode\n"); SDL_putenv("SDL_VIDEO_WINDOW_POS=0,0"); flags |= SDL_NOFRAME; //fs_ml_set_fullscreen_extra(); } else { fs_log("using SDL_FULLSCREEN mode\n"); flags |= SDL_FULLSCREEN; } fs_log("setting (fullscreen) video mode %d %d\n", g_fs_ml_video_width, g_fs_ml_video_height); g_sdl_screen = SDL_SetVideoMode(g_fs_ml_video_width, g_fs_ml_video_height, 0, flags); //update_viewport(); } else { fs_log("using windowed mode\n"); //SDL_putenv("SDL_VIDEO_WINDOW_POS="); g_fs_ml_video_width = g_window_width; g_fs_ml_video_height = g_window_height; if (g_window_resizable) { flags |= SDL_RESIZABLE; } fs_log("setting (windowed) video mode %d %d\n", g_fs_ml_video_width, g_fs_ml_video_height); g_sdl_screen = SDL_SetVideoMode(g_fs_ml_video_width, g_fs_ml_video_height, 0, flags); //update_viewport(); } #endif fs_ml_configure_window(); // FIXME: this can be removed g_fs_ml_opengl_context_stamp++; log_opengl_information(); }
static void set_video_mode() { int flags = SDL_WINDOW_OPENGL; if (g_fs_emu_video_fullscreen_mode != FULLSCREEN_WINDOW && g_window_resizable) { flags |= SDL_WINDOW_RESIZABLE; } int x = g_window_x, y = g_window_y; int w = -1, h = -1; // if (g_initial_input_grab) { // flags |= SDL_WINDOW_INPUT_GRABBED; // g_has_input_grab = 1; // } if (g_fs_emu_video_fullscreen == 1) { w = g_fullscreen_width; h = g_fullscreen_height; //w = g_window_width; //h = g_window_height; if (g_fs_emu_video_fullscreen_mode == FULLSCREEN_WINDOW) { fs_log("using fullscreen window mode\n"); //x = 0; //y = 0; //w = g_fullscreen_width; //h = g_fullscreen_height; flags |= SDL_WINDOW_BORDERLESS; FSEmuMonitor monitor; fs_emu_monitor_get_by_index(g_display, &monitor); x = monitor.rect.x; y = monitor.rect.y; w = monitor.rect.w; h = monitor.rect.h; } else if (g_fs_emu_video_fullscreen_mode == FULLSCREEN_DESKTOP) { fs_log("using fullscreen desktop mode\n"); // the width and height will not be used for the fullscreen // desktop mode, only for the window when toggling fullscreen // state #if 0 w = g_window_width; h = g_window_height; #else FSEmuMonitor monitor; fs_emu_monitor_get_by_index(g_display, &monitor); x = monitor.rect.x; y = monitor.rect.y; w = monitor.rect.w; h = monitor.rect.h; #endif flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; } else { fs_log("using SDL_FULLSCREEN mode\n"); flags |= SDL_WINDOW_FULLSCREEN; } fs_log("setting (fullscreen) video mode %d %d\n", w, h); } else { w = g_window_width; h = g_window_height; fs_log("using windowed mode\n"); //SDL_putenv("SDL_VIDEO_WINDOW_POS="); fs_log("setting (windowed) video mode %d %d\n", w, h); } if (fs_config_get_boolean("window_border") == 0) { fs_log("borderless window requested\n"); flags |= SDL_WINDOW_BORDERLESS; } #if 0 Uint8 data[] = "\0"; SDL_Cursor *cursor = SDL_CreateCursor(data, data, 8, 1, 0, 0); SDL_SetCursor(cursor); #endif g_fs_ml_video_width = w; g_fs_ml_video_height = h; fs_log("[SDL] CreateWindow(x=%d, y=%d, w=%d, h=%d, flags=%d)\n", x, y, w, h, flags); g_fs_ml_window = SDL_CreateWindow(g_window_title, x, y, w, h, flags); int assume_refresh_rate = fs_config_get_int("assume_refresh_rate"); if (assume_refresh_rate != FS_CONFIG_NONE) { fs_log("[DISPLAY] Assuming host refresh rate: %d Hz (from config)\n", assume_refresh_rate); g_fs_emu_video_frame_rate_host = assume_refresh_rate; } else { SDL_DisplayMode mode; if (SDL_GetWindowDisplayMode(g_fs_ml_window, &mode) == 0) { g_fs_emu_video_frame_rate_host = mode.refresh_rate; } else { g_fs_emu_video_frame_rate_host = 0; } fs_log("[DISPLAY] Host refresh rate: %d Hz\n", g_fs_emu_video_frame_rate_host); } if (g_fs_emu_video_frame_rate_host) { g_fs_ml_target_frame_time = 1000000 / g_fs_emu_video_frame_rate_host; } g_fs_ml_context = SDL_GL_CreateContext(g_fs_ml_window); #ifdef WITH_GLEW static int glew_initialized = 0; if (!glew_initialized) { GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "[GLEW] Error: %s\n", glewGetErrorString(err)); fs_emu_fatal("[GLEW] Error initializing glew"); } fs_log("[GLEW] Version %s\n", glewGetString(GLEW_VERSION)); glew_initialized = 1; } #elif defined(WITH_GLAD) static int glad_initialized = 0; if (!glad_initialized) { if (!gladLoadGLLoader((GLADloadproc) SDL_GL_GetProcAddress)) { fs_emu_fatal("[GLAD] Failed to initialize OpenGL context"); } glad_initialized = 1; } #endif fs_ml_configure_window(); // FIXME: this can be removed g_fs_ml_opengl_context_stamp++; log_opengl_information(); }