Skip to content

Commit

Permalink
Fixed normalized coordinates when the viewport is set
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 10, 2017
1 parent 441d309 commit 8aad492
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/render/metal/SDL_render_metal.m
Expand Up @@ -617,8 +617,8 @@ static void METAL_ActivateRenderer(SDL_Renderer * renderer)
[data.mtlcmdencoder setRenderPipelineState:ChoosePipelineState(data.mtlpipelineprims, renderer->blendMode)];
[data.mtlcmdencoder setFragmentBytes:color length:sizeof(color) atIndex:0];

const float w = (float) data.mtlpassdesc.colorAttachments[0].texture.width;
const float h = (float) data.mtlpassdesc.colorAttachments[0].texture.height;
const float w = (float)renderer->viewport.w;
const float h = (float)renderer->viewport.h;

// !!! FIXME: we can convert this in the shader. This will save the malloc and for-loop, but we still need to upload.
float *ptr = verts;
Expand Down Expand Up @@ -658,8 +658,8 @@ static void METAL_ActivateRenderer(SDL_Renderer * renderer)
[data.mtlcmdencoder setRenderPipelineState:ChoosePipelineState(data.mtlpipelineprims, renderer->blendMode)];
[data.mtlcmdencoder setFragmentBytes:color length:sizeof(color) atIndex:0];

const float w = (float) data.mtlpassdesc.colorAttachments[0].texture.width;
const float h = (float) data.mtlpassdesc.colorAttachments[0].texture.height;
const float w = (float)renderer->viewport.w;
const float h = (float)renderer->viewport.h;

for (int i = 0; i < count; i++, rects++) {
if ((rects->w <= 0.0f) || (rects->h <= 0.0f)) continue;
Expand All @@ -686,8 +686,8 @@ static void METAL_ActivateRenderer(SDL_Renderer * renderer)
METAL_ActivateRenderer(renderer);
METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata;
const float w = (float) data.mtlpassdesc.colorAttachments[0].texture.width;
const float h = (float) data.mtlpassdesc.colorAttachments[0].texture.height;
const float w = (float)renderer->viewport.w;
const float h = (float)renderer->viewport.h;
const float texw = (float) texturedata.mtltexture.width;
const float texh = (float) texturedata.mtltexture.height;

Expand Down

0 comments on commit 8aad492

Please sign in to comment.