From aed1e3f42679026b495b4af187da96cd90719728 Mon Sep 17 00:00:00 2001 From: Javidx9 <25419386+OneLoneCoder@users.noreply.github.com> Date: Thu, 8 Oct 2026 19:05:29 +0100 Subject: [PATCH] Fixed point rendering in EMS --- .../olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj | 8 ++--- dev/src/draw.cpp | 20 +++++++++-- dev/src/draw.h | 5 +++ dev/src/gpu_opengl33.cpp | 2 ++ dev/src/image.cpp | 5 +++ dev/src/image.h | 1 + olcPixelGameEngine3.h | 33 +++++++++++++++++-- 7 files changed, 66 insertions(+), 8 deletions(-) diff --git a/dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj b/dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj index cf6056b..f044f79 100644 --- a/dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj +++ b/dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj @@ -140,8 +140,8 @@ true true - false - false + true + true true @@ -164,8 +164,8 @@ true true - true - true + false + false true diff --git a/dev/src/draw.cpp b/dev/src/draw.cpp index 86660a5..b8faf43 100644 --- a/dev/src/draw.cpp +++ b/dev/src/draw.cpp @@ -366,10 +366,26 @@ GPUTask olc::Draw::TaskDrawLine(const std::vector& vPoints, const olc } +GPUTask olc::Draw::TaskDrawPoints(const std::vector& vPoints, const std::vector& vColours, const olc::Pixel tint) +{ + GPUTask task; + task.structure = olc::Structure::Point; + task.vertexBuffer.resize(vPoints.size()); + for (size_t i = 0; i < vPoints.size(); i++) + { + task.vertexBuffer[i] = { { vPoints[i].x, vPoints[i].y, 1.0f, 1.0f }, vColours[i],{ 0, 0 },{ 0, 0 },{ 0, 0 },{ 0, 0 } }; + } + task.blendmode = blendMode; + task.tint = tint; + return task; +} + GPUTask olc::Draw::TaskDrawPolygon(olc::Structure structure, const std::vector& vPoints, const std::vector& vColours, const olc::Pixel tint) { - olc_IgnoreUnused(structure); - return TaskDrawLine(vPoints, vColours, tint, false, true); + if (structure == olc::Structure::Point) + return TaskDrawPoints(vPoints, vColours, tint); + else + return TaskDrawLine(vPoints, vColours, tint, false, true); } GPUTask olc::Draw::TaskDrawPolygon(olc::Structure structure, const std::vector& vPoints, const olc::Pixel colour, const olc::Pixel tint) diff --git a/dev/src/draw.h b/dev/src/draw.h index e082107..b1e848b 100644 --- a/dev/src/draw.h +++ b/dev/src/draw.h @@ -975,6 +975,11 @@ namespace olc const olc::Pixel tint = olc::Colour::WHITE, const bool constrain = true, const bool looped = false); + + GPUTask TaskDrawPoints( + const std::vector& vPoints, + const std::vector& vColours, + const olc::Pixel tint = olc::Colour::WHITE); GPUTask TaskDrawPolygon( olc::Structure structure, diff --git a/dev/src/gpu_opengl33.cpp b/dev/src/gpu_opengl33.cpp index 5aea813..0ceec8a 100644 --- a/dev/src/gpu_opengl33.cpp +++ b/dev/src/gpu_opengl33.cpp @@ -76,6 +76,8 @@ out vec4 oCol; R"( void main() { + gl_PointSize = 1.0; // Required for emscripten + if (pgeDrawType == 2) // 3D { gl_Position = pgeMVP * vec4(aPos.x, aPos.y, aPos.z, 1.0); diff --git a/dev/src/image.cpp b/dev/src/image.cpp index 4c48037..b54fa07 100644 --- a/dev/src/image.cpp +++ b/dev/src/image.cpp @@ -99,6 +99,11 @@ namespace olc return region({ 0,0 }, this->Size()).flipH(); } + olc::ImageRegion Image::flipD() + { + return olc::ImageRegion(*this, { 0,0 }, { 0,1 }, { 1, 0 }, { 1,1 }); + } + void Image::BindGPU() { onGPU = true; diff --git a/dev/src/image.h b/dev/src/image.h index 6cd93c2..0f57c0f 100644 --- a/dev/src/image.h +++ b/dev/src/image.h @@ -88,6 +88,7 @@ namespace olc olc::ImageRegion region(const olc::vf2d& vTL, const olc::vf2d& vTR, const olc::vf2d& vBL, const olc::vf2d& vBR); olc::ImageRegion flipV(); olc::ImageRegion flipH(); + olc::ImageRegion flipD(); public: // Make friendly private later void BindGPU(); diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index a5edfe0..149f122 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -2385,6 +2385,7 @@ namespace olc olc::ImageRegion region(const olc::vf2d& vTL, const olc::vf2d& vTR, const olc::vf2d& vBL, const olc::vf2d& vBR); olc::ImageRegion flipV(); olc::ImageRegion flipH(); + olc::ImageRegion flipD(); public: // Make friendly private later void BindGPU(); @@ -3651,6 +3652,11 @@ namespace olc const olc::Pixel tint = olc::Colour::WHITE, const bool constrain = true, const bool looped = false); + + GPUTask TaskDrawPoints( + const std::vector& vPoints, + const std::vector& vColours, + const olc::Pixel tint = olc::Colour::WHITE); GPUTask TaskDrawPolygon( olc::Structure structure, @@ -16716,6 +16722,8 @@ out vec4 oCol; R"( void main() { + gl_PointSize = 1.0; // Required for emscripten + if (pgeDrawType == 2) // 3D { gl_Position = pgeMVP * vec4(aPos.x, aPos.y, aPos.z, 1.0); @@ -18396,10 +18404,26 @@ GPUTask olc::Draw::TaskDrawLine(const std::vector& vPoints, const olc } +GPUTask olc::Draw::TaskDrawPoints(const std::vector& vPoints, const std::vector& vColours, const olc::Pixel tint) +{ + GPUTask task; + task.structure = olc::Structure::Point; + task.vertexBuffer.resize(vPoints.size()); + for (size_t i = 0; i < vPoints.size(); i++) + { + task.vertexBuffer[i] = { { vPoints[i].x, vPoints[i].y, 1.0f, 1.0f }, vColours[i],{ 0, 0 },{ 0, 0 },{ 0, 0 },{ 0, 0 } }; + } + task.blendmode = blendMode; + task.tint = tint; + return task; +} + GPUTask olc::Draw::TaskDrawPolygon(olc::Structure structure, const std::vector& vPoints, const std::vector& vColours, const olc::Pixel tint) { - olc_IgnoreUnused(structure); - return TaskDrawLine(vPoints, vColours, tint, false, true); + if (structure == olc::Structure::Point) + return TaskDrawPoints(vPoints, vColours, tint); + else + return TaskDrawLine(vPoints, vColours, tint, false, true); } GPUTask olc::Draw::TaskDrawPolygon(olc::Structure structure, const std::vector& vPoints, const olc::Pixel colour, const olc::Pixel tint) @@ -20679,6 +20703,11 @@ namespace olc return region({ 0,0 }, this->Size()).flipH(); } + olc::ImageRegion Image::flipD() + { + return olc::ImageRegion(*this, { 0,0 }, { 0,1 }, { 1, 0 }, { 1,1 }); + } + void Image::BindGPU() { onGPU = true;