static void menu_display_d3d_draw(void *data) { #if 0 math_matrix_4x4 *mat = NULL; #endif d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false); menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; if (!d3d || !draw) return; if (!draw->coords->vertex) draw->coords->vertex = menu_display_d3d_get_default_vertices(); if (!draw->coords->tex_coord) draw->coords->tex_coord = menu_display_d3d_get_default_tex_coords(); if (!draw->coords->lut_tex_coord) draw->coords->lut_tex_coord = menu_display_d3d_get_default_tex_coords(); menu_display_d3d_viewport(draw); menu_display_d3d_bind_texture(draw); #if 0 mat = (math_matrix_4x4*)draw->matrix_data; if (!mat) mat = (math_matrix_4x4*) menu_display_d3d_get_default_mvp(); video_shader_driver_set_coords(d3d, draw->coords); video_shader_driver_set_mvp(d3d, mat); #endif d3d_draw_primitive(d3d->dev, (D3DPRIMITIVETYPE) menu_display_prim_to_d3d_enum(draw->prim_type), 0, draw->coords->vertices); }
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; }