Exemple #1
0
void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw)
{
   math_matrix_4x4 matrix_rotated, matrix_scaled;
   math_matrix_4x4 *b = NULL;

   if (!draw || !menu_disp || !menu_disp->get_default_mvp)
      return;

   b = (math_matrix_4x4*)menu_disp->get_default_mvp();

   matrix_4x4_rotate_z(&matrix_rotated, draw->rotation);
   matrix_4x4_multiply(draw->matrix, &matrix_rotated, b);

   if (!draw->scale_enable)
      return;

   matrix_4x4_scale(&matrix_scaled,
         draw->scale_x, draw->scale_y, draw->scale_z);
   matrix_4x4_multiply(draw->matrix, &matrix_scaled, draw->matrix);
}
Exemple #2
0
void menu_display_matrix_4x4_rotate_z(void *data, float rotation,
      float scale_x, float scale_y, float scale_z, bool scale_enable)
{
   math_matrix_4x4 *matrix, *b;
   math_matrix_4x4 matrix_rotated;
   math_matrix_4x4 matrix_scaled;
   menu_display_ctx_driver_t *menu_disp = menu_display_context_get_ptr();
   if (!menu_disp || !menu_disp->get_default_mvp)
      return;

   matrix = (math_matrix_4x4*)data;
   b      = (math_matrix_4x4*)menu_disp->get_default_mvp();
   if (!matrix)
      return;

   matrix_4x4_rotate_z(&matrix_rotated, rotation);
   matrix_4x4_multiply(matrix, &matrix_rotated, b);

   if (!scale_enable)
      return;

   matrix_4x4_scale(&matrix_scaled, scale_x, scale_y, scale_z);
   matrix_4x4_multiply(matrix, &matrix_scaled, matrix);
}
Exemple #3
0
static void vita2d_set_projection(vita_video_t *vita,
      struct video_ortho *ortho, bool allow_rotate)
{
   math_matrix_4x4 rot;

   /* Calculate projection. */
   matrix_4x4_ortho(&vita->mvp_no_rot, ortho->left, ortho->right,
         ortho->bottom, ortho->top, ortho->znear, ortho->zfar);

   if (!allow_rotate)
   {
      vita->mvp = vita->mvp_no_rot;
      return;
   }

   matrix_4x4_rotate_z(&rot, M_PI * vita->rotation / 180.0f);
   matrix_4x4_multiply(&vita->mvp, &rot, &vita->mvp_no_rot);
}
Exemple #4
0
static void gl1_set_projection(gl1_t *gl1,
      struct video_ortho *ortho, bool allow_rotate)
{
   math_matrix_4x4 rot;

   /* Calculate projection. */
   matrix_4x4_ortho(gl1->mvp_no_rot, ortho->left, ortho->right,
         ortho->bottom, ortho->top, ortho->znear, ortho->zfar);

   if (!allow_rotate)
   {
      gl1->mvp = gl1->mvp_no_rot;
      return;
   }

   matrix_4x4_rotate_z(rot, M_PI * gl1->rotation / 180.0f);
   matrix_4x4_multiply(gl1->mvp, rot, gl1->mvp_no_rot);
}
Exemple #5
0
static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
{
   unsigned i;
   video_shader_ctx_mvp_t mvp;
   math_matrix_4x4 mop, m1, m2;
   unsigned width, height;
   d3d_video_t *d3d              = video_info ? (d3d_video_t*)video_info->userdata : NULL;   
   menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
   Vertex * pv                   = NULL;
   const float *vertex           = NULL;
   const float *tex_coord        = NULL;
   const float *color            = NULL;

   if (!d3d || !draw || draw->pipeline.id)
      return;
   if((d3d->menu_display.offset + draw->coords->vertices )
         > (unsigned)d3d->menu_display.size)
      return;

   pv           = (Vertex*)
      d3d_vertex_buffer_lock(d3d->menu_display.buffer);

   if (!pv)
      return;

   pv          += d3d->menu_display.offset;
   vertex       = draw->coords->vertex;
   tex_coord    = draw->coords->tex_coord;
   color        = draw->coords->color;

   if (!vertex)
      vertex    = menu_display_d3d_get_default_vertices();
   if (!tex_coord)
      tex_coord = menu_display_d3d_get_default_tex_coords();

   for (i = 0; i < draw->coords->vertices; i++)
   {
      int colors[4];

      colors[0]   = *color++ * 0xFF;
      colors[1]   = *color++ * 0xFF;
      colors[2]   = *color++ * 0xFF;
      colors[3]   = *color++ * 0xFF;

      pv[i].x     = *vertex++;
      pv[i].y     = *vertex++;
      pv[i].z     = 0.5f;
      pv[i].u     = *tex_coord++;
      pv[i].v     = *tex_coord++;
#ifdef HAVE_D3D8
	  if ((void*)draw->texture)
      {
         D3DSURFACE_DESC desc;
         if (d3d_texture_get_level_desc((void*)draw->texture, 0, &desc))
         {
            pv[i].u *= desc.Width;
            pv[i].v *= desc.Height;
         }
      }
#endif

      pv[i].color =
         D3DCOLOR_ARGB(
               colors[3], /* A */
               colors[0], /* R */
               colors[1], /* G */
               colors[2]  /* B */
               );
   }
   d3d_vertex_buffer_unlock(d3d->menu_display.buffer);

   if(!draw->matrix_data)
      draw->matrix_data = menu_display_d3d_get_default_mvp(video_info);

   /* ugh */
   video_driver_get_size(&width, &height);
   matrix_4x4_scale(m1,       2.0,  2.0, 0);
   matrix_4x4_translate(mop, -1.0, -1.0, 0);
   matrix_4x4_multiply(m2, mop, m1);
   matrix_4x4_multiply(m1,
         *((math_matrix_4x4*)draw->matrix_data), m2);
   matrix_4x4_scale(mop,
         (draw->width  / 2.0) / width,
         (draw->height / 2.0) / height, 0);
   matrix_4x4_multiply(m2, mop, m1);
   matrix_4x4_translate(mop,
         (draw->x + (draw->width  / 2.0)) / width,
         (draw->y + (draw->height / 2.0)) / height,
         0);
   matrix_4x4_multiply(m1, mop, m2);
   matrix_4x4_multiply(m2, d3d->mvp_transposed, m1);
   d3d_matrix_transpose(&m1, &m2);

   mvp.data   = d3d;
   mvp.matrix = &m1;
   video_driver_set_mvp(&mvp);
   menu_display_d3d_bind_texture(draw, (d3d_video_t*)video_info->userdata);
   d3d_draw_primitive(d3d->dev,
         menu_display_prim_to_d3d_enum(draw->prim_type),
         d3d->menu_display.offset,
         draw->coords->vertices - 
         ((draw->prim_type == MENU_DISPLAY_PRIM_TRIANGLESTRIP) 
          ? 2 : 0));

   d3d->menu_display.offset += draw->coords->vertices;
}
static void menu_display_d3d9_draw(menu_display_ctx_draw_t *draw,
      video_frame_info_t *video_info)
{
   unsigned i;
   video_shader_ctx_mvp_t mvp;
   math_matrix_4x4 mop, m1, m2;
   unsigned width, height;
   LPDIRECT3DDEVICE9 dev;
   d3d9_video_t *d3d              = video_info ?
      (d3d9_video_t*)video_info->userdata : NULL;
   Vertex * pv                   = NULL;
   const float *vertex           = NULL;
   const float *tex_coord        = NULL;
   const float *color            = NULL;

   if (!d3d || !draw || draw->pipeline.id)
      return;

   dev                           = d3d->dev;

   if((d3d->menu_display.offset + draw->coords->vertices )
         > (unsigned)d3d->menu_display.size)
      return;

   pv           = (Vertex*)
      d3d9_vertex_buffer_lock((LPDIRECT3DVERTEXBUFFER9)d3d->menu_display.buffer);

   if (!pv)
      return;

   pv          += d3d->menu_display.offset;
   vertex       = draw->coords->vertex;
   tex_coord    = draw->coords->tex_coord;
   color        = draw->coords->color;

   if (!vertex)
      vertex    = menu_display_d3d9_get_default_vertices();
   if (!tex_coord)
      tex_coord = menu_display_d3d9_get_default_tex_coords();

   for (i = 0; i < draw->coords->vertices; i++)
   {
      int colors[4];

      colors[0]   = *color++ * 0xFF;
      colors[1]   = *color++ * 0xFF;
      colors[2]   = *color++ * 0xFF;
      colors[3]   = *color++ * 0xFF;

      pv[i].x     = *vertex++;
      pv[i].y     = *vertex++;
      pv[i].z     = 0.5f;
      pv[i].u     = *tex_coord++;
      pv[i].v     = *tex_coord++;

      pv[i].color =
         D3DCOLOR_ARGB(
               colors[3], /* A */
               colors[0], /* R */
               colors[1], /* G */
               colors[2]  /* B */
               );
   }
   d3d9_vertex_buffer_unlock((LPDIRECT3DVERTEXBUFFER9)d3d->menu_display.buffer);

   if(!draw->matrix_data)
      draw->matrix_data = menu_display_d3d9_get_default_mvp(video_info);

   /* ugh */
   video_driver_get_size(&width, &height);
   matrix_4x4_scale(m1,       2.0,  2.0, 0);
   matrix_4x4_translate(mop, -1.0, -1.0, 0);
   matrix_4x4_multiply(m2, mop, m1);
   matrix_4x4_multiply(m1,
         *((math_matrix_4x4*)draw->matrix_data), m2);
   matrix_4x4_scale(mop,
         (draw->width  / 2.0) / width,
         (draw->height / 2.0) / height, 0);
   matrix_4x4_multiply(m2, mop, m1);
   matrix_4x4_translate(mop,
         (draw->x + (draw->width  / 2.0)) / width,
         (draw->y + (draw->height / 2.0)) / height,
         0);
   matrix_4x4_multiply(m1, mop, m2);
   matrix_4x4_multiply(m2, d3d->mvp_transposed, m1);
   d3d_matrix_transpose(&m1, &m2);

   mvp.data   = d3d;
   mvp.matrix = &m1;
   video_driver_set_mvp(&mvp);

   if (draw && draw->texture)
      menu_display_d3d9_bind_texture(draw, d3d);

   d3d9_draw_primitive(dev,
         (D3DPRIMITIVETYPE)menu_display_prim_to_d3d9_enum(draw->prim_type),
         d3d->menu_display.offset,
         draw->coords->vertices -
         ((draw->prim_type == MENU_DISPLAY_PRIM_TRIANGLESTRIP)
          ? 2 : 0));

   d3d->menu_display.offset += draw->coords->vertices;
}