void renderchain_set_vertices(void *data, Pass &pass, unsigned width, unsigned height, unsigned out_width, unsigned out_height, unsigned vp_width, unsigned vp_height, unsigned rotation) { renderchain_t *chain = (renderchain_t*)data; const LinkInfo &info = pass.info; if (pass.last_width != width || pass.last_height != height) { pass.last_width = width; pass.last_height = height; float _u = static_cast<float>(width) / info.tex_w; float _v = static_cast<float>(height) / info.tex_h; Vertex vert[4]; for (unsigned i = 0; i < 4; i++) { vert[i].z = 0.5f; vert[i].r = vert[i].g = vert[i].b = vert[i].a = 1.0f; } vert[0].x = 0.0f; vert[1].x = out_width; vert[2].x = 0.0f; vert[3].x = out_width; vert[0].y = out_height; vert[1].y = out_height; vert[2].y = 0.0f; vert[3].y = 0.0f; vert[0].u = 0.0f; vert[1].u = _u; vert[2].u = 0.0f; vert[3].u = _u; vert[0].v = 0.0f; vert[1].v = 0.0f; vert[2].v = _v; vert[3].v = _v; vert[0].lut_u = 0.0f; vert[1].lut_u = 1.0f; vert[2].lut_u = 0.0f; vert[3].lut_u = 1.0f; vert[0].lut_v = 0.0f; vert[1].lut_v = 0.0f; vert[2].lut_v = 1.0f; vert[3].lut_v = 1.0f; // Align texels and vertices. for (unsigned i = 0; i < 4; i++) { vert[i].x -= 0.5f; vert[i].y += 0.5f; } void *verts; pass.vertex_buf->Lock(0, sizeof(vert), &verts, 0); memcpy(verts, vert, sizeof(vert)); pass.vertex_buf->Unlock(); } renderchain_set_mvp(chain, pass.vPrg, vp_width, vp_height, rotation); renderchain_set_shader_params(chain, pass, width, height, info.tex_w, info.tex_h, vp_width, vp_height); }
static void renderchain_set_vertices( cg_renderchain_t *chain, Pass *pass, unsigned width, unsigned height, unsigned out_width, unsigned out_height, unsigned vp_width, unsigned vp_height, unsigned rotation) { const LinkInfo *info = (const LinkInfo*)&pass->info; if (pass->last_width != width || pass->last_height != height) { Vertex vert[4]; unsigned i; void *verts = NULL; float _u = float(width) / info->tex_w; float _v = float(height) / info->tex_h; pass->last_width = width; pass->last_height = height; for (i = 0; i < 4; i++) { vert[i].z = 0.5f; vert[i].r = vert[i].g = vert[i].b = vert[i].a = 1.0f; } vert[0].x = 0.0f; vert[1].x = out_width; vert[2].x = 0.0f; vert[3].x = out_width; vert[0].y = out_height; vert[1].y = out_height; vert[2].y = 0.0f; vert[3].y = 0.0f; vert[0].u = 0.0f; vert[1].u = _u; vert[2].u = 0.0f; vert[3].u = _u; vert[0].v = 0.0f; vert[1].v = 0.0f; vert[2].v = _v; vert[3].v = _v; vert[0].lut_u = 0.0f; vert[1].lut_u = 1.0f; vert[2].lut_u = 0.0f; vert[3].lut_u = 1.0f; vert[0].lut_v = 0.0f; vert[1].lut_v = 0.0f; vert[2].lut_v = 1.0f; vert[3].lut_v = 1.0f; /* Align texels and vertices. */ for (i = 0; i < 4; i++) { vert[i].x -= 0.5f; vert[i].y += 0.5f; } verts = d3d_vertex_buffer_lock(pass->vertex_buf); memcpy(verts, vert, sizeof(vert)); d3d_vertex_buffer_unlock(pass->vertex_buf); } renderchain_set_mvp(chain, pass->vPrg, vp_width, vp_height, rotation); renderchain_set_shader_params(chain, pass, width, height, info->tex_w, info->tex_h, vp_width, vp_height); }
static void renderchain_set_vertices( cg_renderchain_t *chain, Pass *pass, unsigned width, unsigned height, unsigned out_width, unsigned out_height, unsigned vp_width, unsigned vp_height, unsigned rotation) { const LinkInfo *info = (const LinkInfo*)&pass->info; if (pass->last_width != width || pass->last_height != height) { Vertex vert[4]; unsigned i; void *verts = NULL; float _u = float(width) / info->tex_w; float _v = float(height) / info->tex_h; pass->last_width = width; pass->last_height = height; vert[0].x = 0.0f; vert[0].y = out_height; vert[0].z = 0.5f; vert[0].u = 0.0f; vert[0].v = 0.0f; vert[0].lut_u = 0.0f; vert[0].lut_v = 0.0f; vert[0].r = 1.0f; vert[0].g = 1.0f; vert[0].b = 1.0f; vert[0].a = 1.0f; vert[1].x = out_width; vert[1].y = out_height; vert[1].z = 0.5f; vert[1].u = _u; vert[1].v = 0.0f; vert[1].lut_u = 1.0f; vert[1].lut_v = 0.0f; vert[1].r = 1.0f; vert[1].g = 1.0f; vert[1].b = 1.0f; vert[1].a = 1.0f; vert[2].x = 0.0f; vert[2].y = 0.0f; vert[2].z = 0.5f; vert[2].u = 0.0f; vert[2].v = _v; vert[2].lut_u = 0.0f; vert[2].lut_v = 1.0f; vert[2].r = 1.0f; vert[2].g = 1.0f; vert[2].b = 1.0f; vert[2].a = 1.0f; vert[3].x = out_width; vert[3].y = 0.0f; vert[3].z = 0.5f; vert[3].u = _u; vert[3].v = _v; vert[3].lut_u = 1.0f; vert[3].lut_v = 1.0f; vert[3].r = 1.0f; vert[3].g = 1.0f; vert[3].b = 1.0f; vert[3].a = 1.0f; /* Align texels and vertices. * * Fixes infamous 'half-texel offset' issue of D3D9 * http://msdn.microsoft.com/en-us/library/bb219690%28VS.85%29.aspx. */ for (i = 0; i < 4; i++) { vert[i].x -= 0.5f; vert[i].y += 0.5f; } verts = d3d_vertex_buffer_lock(pass->vertex_buf); memcpy(verts, vert, sizeof(vert)); d3d_vertex_buffer_unlock(pass->vertex_buf); } renderchain_set_mvp(chain, pass->vPrg, vp_width, vp_height, rotation); renderchain_set_shader_params(chain, pass, width, height, info->tex_w, info->tex_h, vp_width, vp_height); }