Fixed normalized coordinates when the viewport is set
authorSam Lantinga <slouken@libsdl.org>
Sat, 09 Dec 2017 19:41:08 -0800
changeset 1175409f7bead4e7c
parent 11753 963b438b949f
child 11755 e9a1b9ea8da0
Fixed normalized coordinates when the viewport is set
src/render/metal/SDL_render_metal.m
     1.1 --- a/src/render/metal/SDL_render_metal.m	Sat Dec 09 15:00:41 2017 -0800
     1.2 +++ b/src/render/metal/SDL_render_metal.m	Sat Dec 09 19:41:08 2017 -0800
     1.3 @@ -617,8 +617,8 @@
     1.4      [data.mtlcmdencoder setRenderPipelineState:ChoosePipelineState(data.mtlpipelineprims, renderer->blendMode)];
     1.5      [data.mtlcmdencoder setFragmentBytes:color length:sizeof(color) atIndex:0];
     1.6  
     1.7 -    const float w = (float) data.mtlpassdesc.colorAttachments[0].texture.width;
     1.8 -    const float h = (float) data.mtlpassdesc.colorAttachments[0].texture.height;
     1.9 +    const float w = (float)renderer->viewport.w;
    1.10 +    const float h = (float)renderer->viewport.h;
    1.11  
    1.12      // !!! FIXME: we can convert this in the shader. This will save the malloc and for-loop, but we still need to upload.
    1.13      float *ptr = verts;
    1.14 @@ -658,8 +658,8 @@
    1.15      [data.mtlcmdencoder setRenderPipelineState:ChoosePipelineState(data.mtlpipelineprims, renderer->blendMode)];
    1.16      [data.mtlcmdencoder setFragmentBytes:color length:sizeof(color) atIndex:0];
    1.17  
    1.18 -    const float w = (float) data.mtlpassdesc.colorAttachments[0].texture.width;
    1.19 -    const float h = (float) data.mtlpassdesc.colorAttachments[0].texture.height;
    1.20 +    const float w = (float)renderer->viewport.w;
    1.21 +    const float h = (float)renderer->viewport.h;
    1.22  
    1.23      for (int i = 0; i < count; i++, rects++) {
    1.24          if ((rects->w <= 0.0f) || (rects->h <= 0.0f)) continue;
    1.25 @@ -686,8 +686,8 @@
    1.26      METAL_ActivateRenderer(renderer);
    1.27      METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
    1.28      METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata;
    1.29 -    const float w = (float) data.mtlpassdesc.colorAttachments[0].texture.width;
    1.30 -    const float h = (float) data.mtlpassdesc.colorAttachments[0].texture.height;
    1.31 +    const float w = (float)renderer->viewport.w;
    1.32 +    const float h = (float)renderer->viewport.h;
    1.33      const float texw = (float) texturedata.mtltexture.width;
    1.34      const float texh = (float) texturedata.mtltexture.height;
    1.35