Example #1
0
static bool d3d_alive(void *data)
{
   unsigned temp_width = 0, temp_height = 0;
   bool ret = false;
   d3d_video_t *d3d   = (d3d_video_t*)data;
   bool        quit   = false;
   bool        resize = false;

   if (gfx_ctx_check_window(&quit, &resize,
            &temp_width, &temp_height))
   {
      if (quit)
         d3d->quitting = quit;

      if (resize)
      {
         d3d->should_resize = true;
         gfx_ctx_set_resize(temp_width, temp_height);
         d3d_restore(d3d);
      }

      ret = !quit;
   }

   if (temp_width != 0 && temp_height != 0)
      video_driver_set_size(&temp_width, &temp_height);

   return ret;
}
Example #2
0
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;
}