[Commits] SDL: Fixed normalized coordinates when the viewport is set

libsdl.org revision control commits-owner at libsdl.org
Sat Dec 9 19:41:11 PST 2017


details:   https://hg.libsdl.org/SDL/rev/09f7bead4e7c
changeset: 11754:09f7bead4e7c
user:      Sam Lantinga <slouken at libsdl.org>
date:      Sat Dec 09 19:41:08 2017 -0800
description:
Fixed normalized coordinates when the viewport is set

diffstat:

 src/render/metal/SDL_render_metal.m |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (36 lines):

diff -r 963b438b949f -r 09f7bead4e7c src/render/metal/SDL_render_metal.m
--- a/src/render/metal/SDL_render_metal.m	Sat Dec 09 15:00:41 2017 -0800
+++ b/src/render/metal/SDL_render_metal.m	Sat Dec 09 19:41:08 2017 -0800
@@ -617,8 +617,8 @@
     [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;
@@ -658,8 +658,8 @@
     [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;
@@ -686,8 +686,8 @@
     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;
 


More information about the commits mailing list