static void menu_display_d3d_blend_begin(void) { d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false); if (!d3d) return; d3d_enable_blend_func(d3d->dev); }
static void menu_display_d3d_blend_begin(void) { d3d_video_t *d3d = d3d_get_ptr(); if (!d3d) return; d3d_enable_blend_func(d3d->dev); }
static void menu_display_d3d_blend_begin(video_frame_info_t *video_info) { d3d_video_t *d3d = video_info ? (d3d_video_t*)video_info->userdata : NULL; if (!d3d) return; d3d_enable_blend_func(d3d->dev); }
static bool texture_image_render(d3d_video_t *d3d, struct texture_image *out_img, int x, int y, int w, int h, bool force_fullscreen) { LPDIRECT3DTEXTURE d3dt; LPDIRECT3DVERTEXBUFFER d3dv; void *verts = NULL; float fX = (float)(x); float fY = (float)(y); if (!d3d) return false; d3dt = (LPDIRECT3DTEXTURE)out_img->texture_buf; d3dv = (LPDIRECT3DVERTEXBUFFER)out_img->vertex_buf; if (!d3dt || !d3dv) return false; /* Create the new vertices. */ Vertex newVerts[] = { // x, y, z, color, u ,v {fX, fY, 0.0f, 0, 0, 0}, {fX + w, fY, 0.0f, 0, 1, 0}, {fX + w, fY + h, 0.0f, 0, 1, 1}, {fX, fY + h, 0.0f, 0, 0, 1} }; /* Load the existing vertices */ verts = d3d_vertex_buffer_lock(d3dv); if (!verts) return false; /* Copy the new verts over the old verts */ memcpy(verts, newVerts, sizeof(newVerts)); d3d_vertex_buffer_unlock(d3dv); d3d_enable_blend_func(d3d->dev); d3d_enable_alpha_blend_texture_func(d3d->dev); /* Draw the quad. */ d3d_set_texture(d3d->dev, 0, d3dt); d3d_set_stream_source(d3d->dev, 0, d3dv, 0, sizeof(Vertex)); d3d_set_vertex_shader(d3d->dev, D3DFVF_CUSTOMVERTEX, NULL); if (force_fullscreen) d3d_set_viewport(d3d, w, h, force_fullscreen, false); d3d_draw_primitive(d3d->dev, D3DPT_QUADLIST, 0, 1); return true; }
static void menu_display_d3d_blend_begin(void) { d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); if (!d3d) return; d3d_enable_blend_func(d3d->dev); #if 0 if (gl->shader && gl->shader->use) gl->shader->use(gl, GL_SHADER_STOCK_BLEND); #endif }
static void d3d_draw_texture(d3d_video_t *d3d) { if (!d3d) return; #if defined(HAVE_RMENU) menu_texture->x = 0; menu_texture->y = 0; if (d3d->menu->enabled) { d3d_enable_blend_func(d3d->dev); texture_image_render(d3d, menu_texture, menu_texture->x, menu_texture->y, d3d->screen_width, d3d->screen_height, true); d3d_disable_blend_func(d3d->dev); } #endif }
static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) { struct video_viewport vp; unsigned width, height; void *verts; unsigned i; float vert[4][9]; float overlay_width, overlay_height; #ifndef _XBOX1 LPDIRECT3DVERTEXDECLARATION vertex_decl; /* set vertex declaration for overlay. */ D3DVERTEXELEMENT vElems[4] = { {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, {0, 20, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, D3DDECL_END() }; #endif if (!d3d) return; if (!overlay || !overlay->tex) return; if (!overlay->vert_buf) { overlay->vert_buf = d3d_vertex_buffer_new( d3d->dev, sizeof(vert), 0, 0, D3DPOOL_MANAGED, NULL); if (!overlay->vert_buf) return; } for (i = 0; i < 4; i++) { vert[i][2] = 0.5f; vert[i][5] = 1.0f; vert[i][6] = 1.0f; vert[i][7] = 1.0f; vert[i][8] = overlay->alpha_mod; } d3d_viewport_info(d3d, &vp); overlay_width = vp.width; overlay_height = vp.height; vert[0][0] = overlay->vert_coords[0] * overlay_width; vert[1][0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; vert[2][0] = overlay->vert_coords[0] * overlay_width; vert[3][0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; vert[0][1] = overlay->vert_coords[1] * overlay_height; vert[1][1] = overlay->vert_coords[1] * overlay_height; vert[2][1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; vert[3][1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; vert[0][3] = overlay->tex_coords[0]; vert[1][3] = overlay->tex_coords[0] + overlay->tex_coords[2]; vert[2][3] = overlay->tex_coords[0]; vert[3][3] = overlay->tex_coords[0] + overlay->tex_coords[2]; vert[0][4] = overlay->tex_coords[1]; vert[1][4] = overlay->tex_coords[1]; vert[2][4] = overlay->tex_coords[1] + overlay->tex_coords[3]; vert[3][4] = overlay->tex_coords[1] + overlay->tex_coords[3]; /* Align texels and vertices. */ for (i = 0; i < 4; i++) { vert[i][0] -= 0.5f; vert[i][1] += 0.5f; } overlay->vert_buf->Lock(0, sizeof(vert), &verts, 0); memcpy(verts, vert, sizeof(vert)); d3d_vertex_buffer_unlock(overlay->vert_buf); d3d_enable_blend_func(d3d->dev); #ifndef _XBOX1 d3d->dev->CreateVertexDeclaration(vElems, &vertex_decl); d3d_set_vertex_declaration(d3d->dev, vertex_decl); vertex_decl->Release(); #endif d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf, 0, sizeof(*vert)); video_driver_get_size(&width, &height); if (overlay->fullscreen) { D3DVIEWPORT vp_full; vp_full.X = 0; vp_full.Y = 0; vp_full.Width = width; vp_full.Height = height; vp_full.MinZ = 0.0f; vp_full.MaxZ = 1.0f; d3d_set_viewports(d3d->dev, &vp_full); } /* Render overlay. */ d3d_set_texture(d3d->dev, 0, overlay->tex); d3d_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_BORDER); d3d_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_BORDER); d3d_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_LINEAR); d3d_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_LINEAR); d3d_draw_primitive(d3d->dev, D3DPT_TRIANGLESTRIP, 0, 2); /* Restore previous state. */ d3d_disable_blend_func(d3d->dev); d3d_set_viewports(d3d->dev, &d3d->final_viewport); }
static bool texture_image_render(d3d_video_t *d3d, struct texture_image *out_img, int x, int y, int w, int h, bool force_fullscreen) { void *verts = NULL; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; float fX = (float)(x); float fY = (float)(y); if (!d3d) return false; if (!out_img->pixels || !out_img->vertex_buf) return false; /* Create the new vertices. */ Vertex newVerts[] = { // x, y, z, color, u ,v {fX, fY, 0.0f, 0, 0, 0}, {fX + w, fY, 0.0f, 0, 1, 0}, {fX + w, fY + h, 0.0f, 0, 1, 1}, {fX, fY + h, 0.0f, 0, 0, 1} }; /* Load the existing vertices */ verts = d3d_vertex_buffer_lock(out_img->vertex_buf); if (!verts) return false; /* Copy the new verts over the old verts */ memcpy(verts, newVerts, sizeof(newVerts)); d3d_vertex_buffer_unlock(out_img->vertex_buf); d3d_enable_blend_func(d3d->dev); /* Also blend the texture with the set alpha value. */ d3d->dev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); d3d->dev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); d3d->dev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE); /* Draw the quad. */ d3d_set_texture(d3dr, 0, out_img->texture_buf); d3d_set_stream_source(d3dr, 0, out_img->vertex_buf, 0, sizeof(Vertex)); d3d_set_vertex_shader(d3dr, D3DFVF_CUSTOMVERTEX, NULL); if (force_fullscreen) { D3DVIEWPORT vp = {0}; vp.Width = w; vp.Height = h; vp.X = 0; vp.Y = 0; vp.MinZ = 0.0f; vp.MaxZ = 1.0f; d3d_set_viewport(d3dr, &vp); } d3d_draw_primitive(d3dr, D3DPT_QUADLIST, 0, 1); return true; }
static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) { void *verts; unsigned i; struct overlay_vertex { float x, y, z; float u, v; float r, g, b, a; } vert[4]; float overlay_width, overlay_height; #ifndef _XBOX1 LPDIRECT3DVERTEXDECLARATION vertex_decl; /* set vertex declaration for overlay. */ D3DVERTEXELEMENT vElems[4] = { {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, {0, 20, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, D3DDECL_END() }; #endif if (!d3d) return; if (!overlay || !overlay->tex) return; if (!overlay->vert_buf) { overlay->vert_buf = (LPDIRECT3DVERTEXBUFFER)d3d_vertex_buffer_new( d3d->dev, sizeof(vert), 0, 0, D3DPOOL_MANAGED, NULL); if (!overlay->vert_buf) return; } for (i = 0; i < 4; i++) { vert[i].z = 0.5f; vert[i].r = vert[i].g = vert[i].b = 1.0f; vert[i].a = overlay->alpha_mod; } overlay_width = d3d->final_viewport.Width; overlay_height = d3d->final_viewport.Height; vert[0].x = overlay->vert_coords.x * overlay_width; vert[1].x = (overlay->vert_coords.x + overlay->vert_coords.w) * overlay_width; vert[2].x = overlay->vert_coords.x * overlay_width; vert[3].x = (overlay->vert_coords.x + overlay->vert_coords.w) * overlay_width; vert[0].y = overlay->vert_coords.y * overlay_height; vert[1].y = overlay->vert_coords.y * overlay_height; vert[2].y = (overlay->vert_coords.y + overlay->vert_coords.h) * overlay_height; vert[3].y = (overlay->vert_coords.y + overlay->vert_coords.h) * overlay_height; vert[0].u = overlay->tex_coords.x; vert[1].u = overlay->tex_coords.x + overlay->tex_coords.w; vert[2].u = overlay->tex_coords.x; vert[3].u = overlay->tex_coords.x + overlay->tex_coords.w; vert[0].v = overlay->tex_coords.y; vert[1].v = overlay->tex_coords.y; vert[2].v = overlay->tex_coords.y + overlay->tex_coords.h; vert[3].v = overlay->tex_coords.y + overlay->tex_coords.h; /* Align texels and vertices. */ for (i = 0; i < 4; i++) { vert[i].x -= 0.5f; vert[i].y += 0.5f; } overlay->vert_buf->Lock(0, sizeof(vert), &verts, 0); memcpy(verts, vert, sizeof(vert)); d3d_vertex_buffer_unlock(overlay->vert_buf); d3d_enable_blend_func(d3d->dev); #ifndef _XBOX1 d3d->dev->CreateVertexDeclaration(vElems, &vertex_decl); d3d->dev->SetVertexDeclaration(vertex_decl); vertex_decl->Release(); #endif d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf, 0, sizeof(overlay_vertex)); if (overlay->fullscreen) { /* Set viewport to full window. */ D3DVIEWPORT vp_full = {0}; vp_full.X = 0; vp_full.Y = 0; vp_full.Width = d3d->screen_width; vp_full.Height = d3d->screen_height; vp_full.MinZ = 0.0f; vp_full.MaxZ = 1.0f; d3d_set_viewport(d3d->dev, &vp_full); } /* Render overlay. */ d3d_set_texture(d3d->dev, 0, overlay->tex); d3d_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_BORDER); d3d_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_BORDER); d3d_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_LINEAR); d3d_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_LINEAR); d3d_draw_primitive(d3d->dev, D3DPT_TRIANGLESTRIP, 0, 2); /* Restore previous state. */ d3d_disable_blend_func(d3d->dev); d3d_set_viewport(d3d->dev, &d3d->final_viewport); }