Skip to content

Commit

Permalink
2D-Renderer: Fix 2D-render coordinate mapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
kullingk committed Sep 20, 2024
1 parent d492d8e commit 4f0a6ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/Engine/RenderBackend/2D/CanvasRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct DrawCmd {
inline void mapCoordinates(const Rect2i &resolution, i32 x, i32 y, f32 &xOut, f32 &yOut) {
xOut = (2.0f * static_cast<f32>(x) / static_cast<f32>(resolution.width)) - 1.0f;
yOut = (2.0f * static_cast<f32>(y) / static_cast<f32>(resolution.height)) - 1.0f;
//yOut = -1.0f * yOut;
yOut = -1.0f * yOut;
}

inline void clip(const Rect2i &resolution, i32 x, i32 y, i32 &x_out, i32 &y_out) {
Expand Down Expand Up @@ -350,12 +350,12 @@ static void createRectVertices(DrawCmd *drawCmd, const Color4 &penColor, const R
drawCmd->NumIndices = 6;
drawCmd->Indices = new ui16[drawCmd->NumIndices];
drawCmd->Indices[0] = 0;
drawCmd->Indices[1] = 1;
drawCmd->Indices[2] = 2;
drawCmd->Indices[1] = 2;
drawCmd->Indices[2] = 1;

drawCmd->Indices[3] = 3;
drawCmd->Indices[4] = 4;
drawCmd->Indices[5] = 5;
drawCmd->Indices[4] = 5;
drawCmd->Indices[5] = 4;
}

void CanvasRenderer::drawRect(i32 x, i32 y, i32 w, i32 h, bool filled) {
Expand Down
4 changes: 3 additions & 1 deletion src/Engine/RenderBackend/RenderCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,9 @@ struct OSRE_EXPORT IRenderPath {
Shader *mShader;
};

inline IRenderPath::IRenderPath() : mShader(nullptr) {}
inline IRenderPath::IRenderPath() : mShader(nullptr) {
// empty
}

enum class GLSLVersion {
Invalid = -1,
Expand Down

0 comments on commit 4f0a6ec

Please sign in to comment.