static bool vg_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, const char *msg) { unsigned width, height; vg_t *vg = (vg_t*)data; static struct retro_perf_counter vg_fr = {0}; static struct retro_perf_counter vg_image = {0}; rarch_perf_init(&vg_fr, "vg_fr"); retro_perf_start(&vg_fr); video_driver_get_size(&width, &height); if (frame_width != vg->mRenderWidth || frame_height != vg->mRenderHeight || vg->should_resize) { vg->mRenderWidth = frame_width; vg->mRenderHeight = frame_height; vg_calculate_quad(vg); matrix_3x3_quad_to_quad( vg->x1, vg->y1, vg->x2, vg->y1, vg->x2, vg->y2, vg->x1, vg->y2, /* needs to be flipped, Khronos loves their bottom-left origin */ 0, frame_height, frame_width, frame_height, frame_width, 0, 0, 0, &vg->mTransformMatrix); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadMatrix(vg->mTransformMatrix.data); vg->should_resize = false; } vgSeti(VG_SCISSORING, VG_FALSE); vgClear(0, 0, width, height); vgSeti(VG_SCISSORING, VG_TRUE); rarch_perf_init(&vg_image, "vg_image"); retro_perf_start(&vg_image); vg_copy_frame(vg, frame, frame_width, frame_height, pitch); retro_perf_stop(&vg_image); vgDrawImage(vg->mImage); #if 0 if (msg && vg->mFontsOn) vg_draw_message(vg, msg); #endif gfx_ctx_update_window_title(vg); retro_perf_stop(&vg_fr); gfx_ctx_swap_buffers(vg); return true; }
static bool gfx_ctx_set_video_mode( unsigned width, unsigned height, bool fullscreen) { struct sigaction sa = {{0}}; sa.sa_handler = sighandler; sa.sa_flags = SA_RESTART; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); int x_off = 0; int y_off = 0; bool windowed_full = g_settings.video.windowed_fullscreen; bool true_full = false; int (*old_handler)(Display*, XErrorEvent*) = NULL; XSetWindowAttributes swa = {0}; XVisualInfo *vi = glXGetVisualFromFBConfig(g_dpy, g_fbc); if (!vi) goto error; swa.colormap = g_cmap = XCreateColormap(g_dpy, RootWindow(g_dpy, vi->screen), vi->visual, AllocNone); swa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask; swa.override_redirect = fullscreen ? True : False; if (fullscreen && !windowed_full) { if (x11_enter_fullscreen(g_dpy, width, height, &g_desktop_mode)) { g_should_reset_mode = true; true_full = true; } else RARCH_ERR("[GLX]: Entering true fullscreen failed. Will attempt windowed mode.\n"); } if (g_settings.video.monitor_index) g_screen = g_settings.video.monitor_index - 1; #ifdef HAVE_XINERAMA if (fullscreen || g_screen != 0) { unsigned new_width = width; unsigned new_height = height; if (x11_get_xinerama_coord(g_dpy, g_screen, &x_off, &y_off, &new_width, &new_height)) RARCH_LOG("[GLX]: Using Xinerama on screen #%u.\n", g_screen); else RARCH_LOG("[GLX]: Xinerama is not active on screen.\n"); if (fullscreen) { width = new_width; height = new_height; } } #endif RARCH_LOG("[GLX]: X = %d, Y = %d, W = %u, H = %u.\n", x_off, y_off, width, height); g_win = XCreateWindow(g_dpy, RootWindow(g_dpy, vi->screen), x_off, y_off, width, height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask | (true_full ? CWOverrideRedirect : 0), &swa); XSetWindowBackground(g_dpy, g_win, 0); g_glx_win = glXCreateWindow(g_dpy, g_fbc, g_win, 0); gfx_ctx_update_window_title(true); x11_set_window_attr(g_dpy, g_win); if (fullscreen) x11_hide_mouse(g_dpy, g_win); if (true_full) { RARCH_LOG("[GLX]: Using true fullscreen.\n"); XMapRaised(g_dpy, g_win); } else if (fullscreen) // We attempted true fullscreen, but failed. Attempt using windowed fullscreen. { XMapRaised(g_dpy, g_win); RARCH_LOG("[GLX]: Using windowed fullscreen.\n"); // We have to move the window to the screen we want to go fullscreen on first. // x_off and y_off usually get ignored in XCreateWindow(). x11_move_window(g_dpy, g_win, x_off, y_off, width, height); x11_windowed_fullscreen(g_dpy, g_win); } else { XMapWindow(g_dpy, g_win); // If we want to map the window on a different screen, we'll have to do it by force. // Otherwise, we should try to let the window manager sort it out. // x_off and y_off usually get ignored in XCreateWindow(). if (g_screen) x11_move_window(g_dpy, g_win, x_off, y_off, width, height); } XEvent event; XIfEvent(g_dpy, &event, glx_wait_notify, NULL); g_ctx = glXCreateNewContext(g_dpy, g_fbc, GLX_RGBA_TYPE, 0, True); if (!g_ctx) { RARCH_ERR("[GLX]: Failed to create new context.\n"); goto error; } glXMakeContextCurrent(g_dpy, g_glx_win, g_glx_win, g_ctx); XSync(g_dpy, False); g_quit_atom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False); if (g_quit_atom) XSetWMProtocols(g_dpy, g_win, &g_quit_atom, 1); int val; glXGetConfig(g_dpy, vi, GLX_DOUBLEBUFFER, &val); g_is_double = val; if (g_is_double) { const char *swap_func = NULL; g_pglSwapInterval = (int (*)(int))glXGetProcAddress((const GLubyte*)"glXSwapIntervalMESA"); if (g_pglSwapInterval) swap_func = "glXSwapIntervalMESA"; if (!g_pglSwapInterval) { g_pglSwapInterval = (int (*)(int))glXGetProcAddress((const GLubyte*)"glXSwapIntervalSGI"); if (g_pglSwapInterval) swap_func = "glXSwapIntervalSGI"; } if (!g_pglSwapInterval) RARCH_WARN("[GLX]: Cannot find swap interval call.\n"); else RARCH_LOG("[GLX]: Found swap function: %s.\n", swap_func); } else RARCH_WARN("[GLX]: Context is not double buffered!.\n"); gfx_ctx_swap_interval(g_interval); // This can blow up on some drivers. It's not fatal, so override errors for this call. old_handler = XSetErrorHandler(nul_handler); XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); XSync(g_dpy, False); XSetErrorHandler(old_handler); XFree(vi); g_has_focus = true; g_inited = true; driver.display_type = RARCH_DISPLAY_X11; driver.video_display = (uintptr_t)g_dpy; driver.video_window = (uintptr_t)g_win; g_true_full = true_full; return true; error: if (vi) XFree(vi); gfx_ctx_destroy(); return false; }
static bool gfx_ctx_set_video_mode( unsigned width, unsigned height, bool fullscreen) { DWORD style; HMONITOR hm_to_use = NULL; MONITORINFOEX current_mon; monitor_info(¤t_mon, &hm_to_use); RECT mon_rect = current_mon.rcMonitor; g_resize_width = width; g_resize_height = height; bool windowed_full = g_settings.video.windowed_fullscreen; if (fullscreen) { if (windowed_full) { style = WS_EX_TOPMOST | WS_POPUP; g_resize_width = width = mon_rect.right - mon_rect.left; g_resize_height = height = mon_rect.bottom - mon_rect.top; } else { style = WS_POPUP | WS_VISIBLE; if (!set_fullscreen(width, height, current_mon.szDevice)) goto error; // display settings might have changed, get new coordinates GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon); mon_rect = current_mon.rcMonitor; g_restore_desktop = true; } } else { style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; RECT rect = {0}; rect.right = width; rect.bottom = height; AdjustWindowRect(&rect, style, FALSE); width = rect.right - rect.left; height = rect.bottom - rect.top; } g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", style, fullscreen ? mon_rect.left : CW_USEDEFAULT, fullscreen ? mon_rect.top : CW_USEDEFAULT, width, height, NULL, NULL, NULL, NULL); if (!g_hwnd) goto error; gfx_ctx_update_window_title(true); if (!fullscreen || windowed_full) { ShowWindow(g_hwnd, SW_RESTORE); UpdateWindow(g_hwnd); SetForegroundWindow(g_hwnd); SetFocus(g_hwnd); } show_cursor(!fullscreen); // Wait until GL context is created (or failed to do so ...) MSG msg; while (!g_inited && !g_quit && GetMessage(&msg, g_hwnd, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (g_quit) goto error; p_swap_interval = (BOOL (APIENTRY *)(int))wglGetProcAddress("wglSwapIntervalEXT"); gfx_ctx_swap_interval(g_interval); driver.display_type = RARCH_DISPLAY_WIN32; driver.video_display = 0; driver.video_window = (uintptr_t)g_hwnd; return true; error: gfx_ctx_destroy(); return false; }
static void *vg_init(const video_info_t *video, const input_driver_t **input, void **input_data) { unsigned temp_width = 0, temp_height = 0; VGfloat clearColor[4] = {0, 0, 0, 1}; settings_t *settings = config_get_ptr(); driver_t *driver = driver_get_ptr(); const gfx_ctx_driver_t *ctx = NULL; vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t)); if (!vg) goto error; ctx = gfx_ctx_init_first(vg, settings->video.context_driver, GFX_CTX_OPENVG_API, 0, 0, false); if (!ctx) goto error; driver->video_context = ctx; gfx_ctx_get_video_size(vg, &temp_width, &temp_height); RARCH_LOG("Detecting screen resolution %ux%u.\n", temp_width, temp_height); if (temp_width != 0 && temp_height != 0) { video_driver_set_size_width(temp_width); video_driver_set_size_width(temp_height); } gfx_ctx_swap_interval(vg, video->vsync ? 1 : 0); gfx_ctx_update_window_title(vg); vg->mTexType = video->rgb32 ? VG_sXRGB_8888 : VG_sRGB_565; vg->keep_aspect = video->force_aspect; unsigned win_width = video->width; unsigned win_height = video->height; if (video->fullscreen && (win_width == 0) && (win_height == 0)) { video_driver_get_size(&temp_width, &temp_height); win_width = temp_width; win_height = temp_height; } if (!gfx_ctx_set_video_mode(vg, win_width, win_height, video->fullscreen)) goto error; video_driver_get_size(&temp_width, &temp_height); temp_width = 0; temp_height = 0; gfx_ctx_get_video_size(vg, &temp_width, &temp_height); vg->should_resize = true; if (temp_width != 0 && temp_height != 0) { RARCH_LOG("Verified window resolution %ux%u.\n", temp_width, temp_height); video_driver_set_size_width(temp_width); video_driver_set_size_height(temp_height); } video_driver_get_size(&temp_width, &temp_height); vg->mScreenAspect = (float)temp_width / temp_height; gfx_ctx_translate_aspect(vg, &vg->mScreenAspect, temp_width, temp_height); vgSetfv(VG_CLEAR_COLOR, 4, clearColor); vg->mTextureWidth = vg->mTextureHeight = video->input_scale * RARCH_SCALE_BASE; vg->mImage = vgCreateImage(vg->mTexType, vg->mTextureWidth, vg->mTextureHeight, video->smooth ? VG_IMAGE_QUALITY_BETTER : VG_IMAGE_QUALITY_NONANTIALIASED); vg_set_nonblock_state(vg, !video->vsync); gfx_ctx_input_driver(vg, input, input_data); if (settings->video.font_enable && font_renderer_create_default(&vg->font_driver, &vg->mFontRenderer, *settings->video.font_path ? settings->video.font_path : NULL, settings->video.font_size)) { vg->mFont = vgCreateFont(0); if (vg->mFont != VG_INVALID_HANDLE) { vg->mFontsOn = true; vg->mFontHeight = settings->video.font_size; vg->mPaintFg = vgCreatePaint(); vg->mPaintBg = vgCreatePaint(); VGfloat paintFg[] = { settings->video.msg_color_r, settings->video.msg_color_g, settings->video.msg_color_b, 1.0f }; VGfloat paintBg[] = { settings->video.msg_color_r / 2.0f, settings->video.msg_color_g / 2.0f, settings->video.msg_color_b / 2.0f, 0.5f }; vgSetParameteri(vg->mPaintFg, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); vgSetParameterfv(vg->mPaintFg, VG_PAINT_COLOR, 4, paintFg); vgSetParameteri(vg->mPaintBg, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); vgSetParameterfv(vg->mPaintBg, VG_PAINT_COLOR, 4, paintBg); } } if (vg_query_extension("KHR_EGL_image") && gfx_ctx_image_buffer_init(vg, video)) { pvgCreateEGLImageTargetKHR = (PFNVGCREATEEGLIMAGETARGETKHRPROC)gfx_ctx_get_proc_address("vgCreateEGLImageTargetKHR"); if (pvgCreateEGLImageTargetKHR) { RARCH_LOG("[VG] Using EGLImage buffer\n"); vg->mEglImageBuf = true; } } #if 0 const char *ext = (const char*)vgGetString(VG_EXTENSIONS); if (ext) RARCH_LOG("[VG] Supported extensions: %s\n", ext); #endif return vg; error: if (vg) free(vg); if (driver) driver->video_context = NULL; return NULL; }
static bool gfx_ctx_set_video_mode( unsigned width, unsigned height, bool fullscreen) { struct sigaction sa = {{0}}; sa.sa_handler = sighandler; sa.sa_flags = SA_RESTART; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); XVisualInfo temp = {0}; XSetWindowAttributes swa = {0}; XVisualInfo *vi = NULL; bool windowed_full = g_settings.video.windowed_fullscreen; bool true_full = false; int x_off = 0; int y_off = 0; EGLint vid; if (!eglGetConfigAttrib(g_egl_dpy, g_config, EGL_NATIVE_VISUAL_ID, &vid)) goto error; temp.visualid = vid; EGLint num_visuals; vi = XGetVisualInfo(g_dpy, VisualIDMask, &temp, &num_visuals); if (!vi) goto error; swa.colormap = g_cmap = XCreateColormap(g_dpy, RootWindow(g_dpy, vi->screen), vi->visual, AllocNone); swa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask; swa.override_redirect = fullscreen ? True : False; if (fullscreen && !windowed_full) { if (x11_enter_fullscreen(g_dpy, width, height, &g_desktop_mode)) { g_should_reset_mode = true; true_full = true; } else RARCH_ERR("[X/EGL]: Entering true fullscreen failed. Will attempt windowed mode.\n"); } if (g_settings.video.monitor_index) g_screen = g_settings.video.monitor_index - 1; #ifdef HAVE_XINERAMA if (fullscreen || g_screen != 0) { unsigned new_width = width; unsigned new_height = height; if (x11_get_xinerama_coord(g_dpy, g_screen, &x_off, &y_off, &new_width, &new_height)) RARCH_LOG("[X/EGL]: Using Xinerama on screen #%u.\n", g_screen); else RARCH_LOG("[X/EGL]: Xinerama is not active on screen.\n"); if (fullscreen) { width = new_width; height = new_height; } } #endif RARCH_LOG("[X/EGL]: X = %d, Y = %d, W = %u, H = %u.\n", x_off, y_off, width, height); g_win = XCreateWindow(g_dpy, RootWindow(g_dpy, vi->screen), x_off, y_off, width, height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask | (true_full ? CWOverrideRedirect : 0), &swa); XSetWindowBackground(g_dpy, g_win, 0); // GLES 2.0. Don't use for any other API. static const EGLint egl_ctx_gles_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, }; g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, (g_api == GFX_CTX_OPENGL_ES_API) ? egl_ctx_gles_attribs : NULL); if (!g_egl_ctx) goto error; g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_config, (EGLNativeWindowType)g_win, NULL); if (!g_egl_surf) goto error; if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) goto error; gfx_ctx_update_window_title(true); x11_set_window_attr(g_dpy, g_win); if (fullscreen) x11_hide_mouse(g_dpy, g_win); if (true_full) { RARCH_LOG("[GLX]: Using true fullscreen.\n"); XMapRaised(g_dpy, g_win); } else if (fullscreen) // We attempted true fullscreen, but failed. Attempt using windowed fullscreen. { XMapRaised(g_dpy, g_win); RARCH_LOG("[X/EGL]: Using windowed fullscreen.\n"); // We have to move the window to the screen we want to go fullscreen on first. // x_off and y_off usually get ignored in XCreateWindow(). x11_move_window(g_dpy, g_win, x_off, y_off, width, height); x11_windowed_fullscreen(g_dpy, g_win); } else { XMapWindow(g_dpy, g_win); // If we want to map the window on a different screen, we'll have to do it by force. // Otherwise, we should try to let the window manager sort it out. // x_off and y_off usually get ignored in XCreateWindow(). if (g_screen) x11_move_window(g_dpy, g_win, x_off, y_off, width, height); } XEvent event; XIfEvent(g_dpy, &event, egl_wait_notify, NULL); XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); g_quit_atom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False); if (g_quit_atom) XSetWMProtocols(g_dpy, g_win, &g_quit_atom, 1); gfx_ctx_swap_interval(g_interval); XFree(vi); g_has_focus = true; g_inited = true; driver.display_type = RARCH_DISPLAY_X11; driver.video_display = (uintptr_t)g_dpy; driver.video_window = (uintptr_t)g_win; g_true_full = true_full; return true; error: if (vi) XFree(vi); gfx_ctx_destroy(); return false; }
static void *gl_init(const video_info_t *video, const input_driver_t **input, void **input_data) { #ifdef _WIN32 gfx_set_dwm(); #endif #ifdef RARCH_CONSOLE if (driver.video_data) return driver.video_data; #endif gl_t *gl = (gl_t*)calloc(1, sizeof(gl_t)); if (!gl) return NULL; if (!gfx_ctx_init()) { free(gl); return NULL; } unsigned full_x = 0, full_y = 0; gfx_ctx_get_video_size(&full_x, &full_y); RARCH_LOG("Detecting resolution %ux%u.\n", full_x, full_y); gfx_ctx_set_swap_interval(video->vsync ? 1 : 0, false); unsigned win_width = video->width; unsigned win_height = video->height; if (video->fullscreen && (win_width == 0) && (win_height == 0)) { win_width = full_x; win_height = full_y; } if (!gfx_ctx_set_video_mode(win_width, win_height, g_settings.video.force_16bit ? 15 : 0, video->fullscreen)) { free(gl); return NULL; } #ifndef RARCH_CONSOLE gfx_ctx_update_window_title(true); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); #endif #if (defined(HAVE_XML) || defined(HAVE_CG)) && defined(_WIN32) // Win32 GL lib doesn't have some functions needed for XML shaders. // Need to load dynamically :( if (!load_gl_proc()) { gfx_ctx_destroy(); free(gl); return NULL; } #endif gl->vsync = video->vsync; gl->fullscreen = video->fullscreen; gl->full_x = full_x; gl->full_y = full_y; gl->win_width = win_width; gl->win_height = win_height; RARCH_LOG("GL: Using resolution %ux%u\n", gl->win_width, gl->win_height); #if defined(HAVE_CG_MENU) && defined(RARCH_CONSOLE) RARCH_LOG("Initializing menu shader ...\n"); gl_cg_set_menu_shader(default_paths.menu_shader_file); #endif if (!gl_shader_init()) { RARCH_ERR("Shader init failed.\n"); gfx_ctx_destroy(); free(gl); return NULL; } RARCH_LOG("GL: Loaded %u program(s).\n", gl_shader_num()); #ifdef HAVE_FBO // Set up render to texture. gl_init_fbo(gl, RARCH_SCALE_BASE * video->input_scale, RARCH_SCALE_BASE * video->input_scale); #endif gl->keep_aspect = video->force_aspect; // Apparently need to set viewport for passes when we aren't using FBOs. gl_shader_use(0); gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); gl_shader_use(1); gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); bool force_smooth = false; if (gl_shader_filter_type(1, &force_smooth)) gl->tex_filter = force_smooth ? GL_LINEAR : GL_NEAREST; else gl->tex_filter = video->smooth ? GL_LINEAR : GL_NEAREST; gl->texture_type = RARCH_GL_TEXTURE_TYPE; gl->texture_fmt = video->rgb32 ? RARCH_GL_FORMAT32 : RARCH_GL_FORMAT16; gl->base_size = video->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); glEnable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glDisable(GL_DITHER); glClearColor(0, 0, 0, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(2, GL_FLOAT, 0, vertex_ptr); memcpy(gl->tex_coords, tex_coords, sizeof(tex_coords)); glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords); glColorPointer(4, GL_FLOAT, 0, white_color); set_lut_texture_coords(tex_coords); gl->tex_w = RARCH_SCALE_BASE * video->input_scale; gl->tex_h = RARCH_SCALE_BASE * video->input_scale; #ifdef HAVE_OPENGL_TEXREF glGenBuffers(1, &gl->pbo); glBindBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, gl->pbo); glBufferData(GL_TEXTURE_REFERENCE_BUFFER_SCE, gl->tex_w * gl->tex_h * gl->base_size * TEXTURES, NULL, GL_STREAM_DRAW); #endif // Empty buffer that we use to clear out the texture with on res change. gl->empty_buf = calloc(gl->tex_w * gl->tex_h, gl->base_size); gl_init_textures(gl); for (unsigned i = 0; i < TEXTURES; i++) { gl->last_width[i] = gl->tex_w; gl->last_height[i] = gl->tex_h; } for (unsigned i = 0; i < TEXTURES; i++) { gl->prev_info[i].tex = gl->texture[(gl->tex_index - (i + 1)) & TEXTURES_MASK]; gl->prev_info[i].input_size[0] = gl->tex_w; gl->prev_info[i].tex_size[0] = gl->tex_w; gl->prev_info[i].input_size[1] = gl->tex_h; gl->prev_info[i].tex_size[1] = gl->tex_h; memcpy(gl->prev_info[i].coord, tex_coords, sizeof(tex_coords)); } gfx_ctx_input_driver(input, input_data); gl_init_font(gl, g_settings.video.font_path, g_settings.video.font_size); if (!gl_check_error()) { gfx_ctx_destroy(); free(gl); return NULL; } return gl; }
static bool gl_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { gl_t *gl = (gl_t*)data; gl_shader_use(1); gl->frame_count++; glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); #ifdef HAVE_FBO // Render to texture in first pass. if (gl->fbo_inited) { // Recompute FBO geometry. // When width/height changes or window sizes change, we have to recalcuate geometry of our FBO. gl_compute_fbo_geometry(gl, width, height, gl->vp_out_width, gl->vp_out_height); gl_start_frame_fbo(gl); } #endif if (gl->should_resize) { gl->should_resize = false; gfx_ctx_set_resize(gl->win_width, gl->win_height); // On resize, we might have to recreate our FBOs due to "Viewport" scale, and set a new viewport. gl_update_resize(gl); } if (frame) // Can be NULL for frame dupe / NULL render. { gl_update_input_size(gl, width, height, pitch); gl_copy_frame(gl, frame, width, height, pitch); } struct gl_tex_info tex_info = {0}; tex_info.tex = gl->texture[gl->tex_index]; tex_info.input_size[0] = width; tex_info.input_size[1] = height; tex_info.tex_size[0] = gl->tex_w; tex_info.tex_size[1] = gl->tex_h; memcpy(tex_info.coord, gl->tex_coords, sizeof(gl->tex_coords)); glClear(GL_COLOR_BUFFER_BIT); gl_shader_set_params(width, height, gl->tex_w, gl->tex_h, gl->vp_width, gl->vp_height, gl->frame_count, &tex_info, gl->prev_info, NULL, 0); glDrawArrays(GL_QUADS, 0, 4); #ifdef HAVE_FBO if (gl->fbo_inited) gl_frame_fbo(gl, &tex_info); #endif gl_next_texture_index(gl, &tex_info); if (msg) { gl_render_msg(gl, msg); gl_render_msg_post(gl); } #ifndef RARCH_CONSOLE gfx_ctx_update_window_title(false); #endif #ifdef RARCH_CONSOLE if (!gl->block_swap) #endif gfx_ctx_swap_buffers(); #ifdef HAVE_CG_MENU if (gl->menu_render) gl_render_menu(gl); #endif return true; }