Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
WinRT: made the D3D 11.1 renderer respect the 'srcrect' parameter of …
Browse files Browse the repository at this point in the history
…SDL_RenderCopy
  • Loading branch information
DavidLudwig committed Feb 24, 2013
1 parent a3997a3 commit 9fda97a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/render/direct3d11/SDL_render_d3d11.cpp
Expand Up @@ -1261,13 +1261,17 @@ D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,

D3D11_RenderStartDrawOp(renderer);
D3D11_RenderSetBlendMode(renderer, texture->blendMode);

float minu = (float) srcrect->x / texture->w;
float maxu = (float) (srcrect->x + srcrect->w) / texture->w;
float minv = (float) srcrect->y / texture->h;
float maxv = (float) (srcrect->y + srcrect->h) / texture->h;

// WinRT, TODO: get srcrect working in tandem with SDL_RenderCopy, etc.
VertexPositionColor vertices[] = {
{XMFLOAT3(dstrect->x, dstrect->y, 0.0f), XMFLOAT2(0.0f, 0.0f), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
{XMFLOAT3(dstrect->x, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(0.0f, 1.0f), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
{XMFLOAT3(dstrect->x + dstrect->w, dstrect->y, 0.0f), XMFLOAT2(1.0f, 0.0f), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
{XMFLOAT3(dstrect->x + dstrect->w, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(1.0f, 1.0f), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
{XMFLOAT3(dstrect->x, dstrect->y, 0.0f), XMFLOAT2(minu, minv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
{XMFLOAT3(dstrect->x, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(minu, maxv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
{XMFLOAT3(dstrect->x + dstrect->w, dstrect->y, 0.0f), XMFLOAT2(maxu, minv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
{XMFLOAT3(dstrect->x + dstrect->w, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(maxu, maxv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
};
if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
return -1;
Expand Down

0 comments on commit 9fda97a

Please sign in to comment.