mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
update metal backend for projection changes.
This commit is contained in:
@@ -65,6 +65,8 @@ public:
|
|||||||
love::graphics::Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) override;
|
love::graphics::Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) override;
|
||||||
love::graphics::Buffer *newBuffer(const Buffer::Settings &settings, const std::vector<Buffer::DataDeclaration> &format, const void *data, size_t size, size_t arraylength) override;
|
love::graphics::Buffer *newBuffer(const Buffer::Settings &settings, const std::vector<Buffer::DataDeclaration> &format, const void *data, size_t size, size_t arraylength) override;
|
||||||
|
|
||||||
|
Matrix4 computeDeviceProjection(const Matrix4 &projection, bool rendertotexture) const override;
|
||||||
|
|
||||||
void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override;
|
void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override;
|
||||||
bool setMode(void *context, int width, int height, int pixelwidth, int pixelheight, bool windowhasstencil, int msaa) override;
|
bool setMode(void *context, int width, int height, int pixelwidth, int pixelheight, bool windowhasstencil, int msaa) override;
|
||||||
void unSetMode() override;
|
void unSetMode() override;
|
||||||
|
|||||||
@@ -418,6 +418,12 @@ love::graphics::Buffer *Graphics::newBuffer(const Buffer::Settings &settings, co
|
|||||||
return new Buffer(this, device, settings, format, data, size, arraylength);
|
return new Buffer(this, device, settings, format, data, size, arraylength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix4 Graphics::computeDeviceProjection(const Matrix4 &projection, bool /*rendertotexture*/) const
|
||||||
|
{
|
||||||
|
uint32 flags = DEVICE_PROJECTION_FLIP_Y;
|
||||||
|
return calculateDeviceProjection(projection, flags);
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelheight)
|
void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelheight)
|
||||||
{
|
{
|
||||||
this->width = width;
|
this->width = width;
|
||||||
@@ -428,9 +434,7 @@ void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelh
|
|||||||
if (!isRenderTargetActive())
|
if (!isRenderTargetActive())
|
||||||
{
|
{
|
||||||
dirtyRenderState |= STATEBIT_VIEWPORT | STATEBIT_SCISSOR;
|
dirtyRenderState |= STATEBIT_VIEWPORT | STATEBIT_SCISSOR;
|
||||||
|
resetProjection();
|
||||||
// Set up the projection matrix
|
|
||||||
projectionMatrix = Matrix4::ortho(0.0, (float) width, (float) height, 0.0, -10.0f, 10.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture::Settings settings;
|
Texture::Settings settings;
|
||||||
@@ -1009,7 +1013,7 @@ void Graphics::applyShaderUniforms(id<MTLRenderCommandEncoder> renderEncoder, lo
|
|||||||
auto builtins = (Shader::BuiltinUniformData *) (bufferdata + s->getBuiltinUniformDataOffset());
|
auto builtins = (Shader::BuiltinUniformData *) (bufferdata + s->getBuiltinUniformDataOffset());
|
||||||
|
|
||||||
builtins->transformMatrix = getTransform();
|
builtins->transformMatrix = getTransform();
|
||||||
builtins->projectionMatrix = getProjection();
|
builtins->projectionMatrix = getDeviceProjection();
|
||||||
|
|
||||||
// The normal matrix is the transpose of the inverse of the rotation portion
|
// The normal matrix is the transpose of the inverse of the rotation portion
|
||||||
// (top-left 3x3) of the transform matrix.
|
// (top-left 3x3) of the transform matrix.
|
||||||
@@ -1299,7 +1303,7 @@ bool Graphics::dispatch(int x, int y, int z)
|
|||||||
return true;
|
return true;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int w, int h, int /*pixelw*/, int /*pixelh*/, bool /*hasSRGBtexture*/)
|
void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int /*w*/, int /*h*/, int /*pixelw*/, int /*pixelh*/, bool /*hasSRGBtexture*/)
|
||||||
{ @autoreleasepool {
|
{ @autoreleasepool {
|
||||||
endPass();
|
endPass();
|
||||||
|
|
||||||
@@ -1336,7 +1340,6 @@ void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int w, int h,
|
|||||||
setAttachment(rt, passDesc.stencilAttachment, attachmentStoreActions.stencil);
|
setAttachment(rt, passDesc.stencilAttachment, attachmentStoreActions.stencil);
|
||||||
}
|
}
|
||||||
|
|
||||||
projectionMatrix = Matrix4::ortho(0.0, (float) w, (float) h, 0.0, -10.0f, 10.0f);
|
|
||||||
dirtyRenderState = STATEBIT_ALL;
|
dirtyRenderState = STATEBIT_ALL;
|
||||||
lastVertexAttributes = VertexAttributes();
|
lastVertexAttributes = VertexAttributes();
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user