|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "olcPixelGameEngine.h" |
|
|
|
#include "olcPixelGameEngine.h" |
|
|
|
#include "olcPGEX_TTF.h" |
|
|
|
#include "olcPGEX_TTF.h" |
|
|
|
|
|
|
|
#include "olcUTIL_Geometry2D.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <algorithm> |
|
|
|
#include <algorithm> |
|
|
|
#include <array> |
|
|
|
#include <array> |
|
|
@ -9,6 +10,7 @@ |
|
|
|
#include <cstdint> |
|
|
|
#include <cstdint> |
|
|
|
#include <iostream> |
|
|
|
#include <iostream> |
|
|
|
#include <vector> |
|
|
|
#include <vector> |
|
|
|
|
|
|
|
#include <limits> |
|
|
|
|
|
|
|
|
|
|
|
// Declarations
|
|
|
|
// Declarations
|
|
|
|
namespace olc { |
|
|
|
namespace olc { |
|
|
@ -16,6 +18,7 @@ namespace olc { |
|
|
|
public: |
|
|
|
public: |
|
|
|
ViewPort(); |
|
|
|
ViewPort(); |
|
|
|
ViewPort(std::vector<vf2d> vertices, vf2d offset = {0, 0}); |
|
|
|
ViewPort(std::vector<vf2d> vertices, vf2d offset = {0, 0}); |
|
|
|
|
|
|
|
geom2d::rect<float>rect; |
|
|
|
virtual ~ViewPort(); |
|
|
|
virtual ~ViewPort(); |
|
|
|
void addPoint(vf2d point); |
|
|
|
void addPoint(vf2d point); |
|
|
|
void clear(); |
|
|
|
void clear(); |
|
|
@ -178,13 +181,15 @@ void olc::ViewPort::setOffset(vf2d offset) { |
|
|
|
|
|
|
|
|
|
|
|
olc::ViewPort |
|
|
|
olc::ViewPort |
|
|
|
olc::ViewPort::rectViewPort(vf2d topLeft, vf2d size, olc::vf2d offset) { |
|
|
|
olc::ViewPort::rectViewPort(vf2d topLeft, vf2d size, olc::vf2d offset) { |
|
|
|
return {{ |
|
|
|
olc::ViewPort newPort={{ |
|
|
|
topLeft, |
|
|
|
topLeft, |
|
|
|
{topLeft.x, topLeft.y + size.y}, |
|
|
|
{topLeft.x, topLeft.y + size.y}, |
|
|
|
topLeft + size, |
|
|
|
topLeft + size, |
|
|
|
{topLeft.x + size.x, topLeft.y}, |
|
|
|
{topLeft.x + size.x, topLeft.y}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
offset}; |
|
|
|
offset}; |
|
|
|
|
|
|
|
newPort.rect={topLeft,size}; |
|
|
|
|
|
|
|
return newPort; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void olc::ViewPort::DrawDecal(const olc::vf2d &pos, |
|
|
|
void olc::ViewPort::DrawDecal(const olc::vf2d &pos, |
|
|
@ -527,6 +532,15 @@ void olc::ViewPort::drawClippedDecal(Decal *decal, |
|
|
|
std::vector<float> outputWs{ws, ws + elements}; |
|
|
|
std::vector<float> outputWs{ws, ws + elements}; |
|
|
|
std::vector<Pixel> outputCols{col, col + elements}; |
|
|
|
std::vector<Pixel> outputCols{col, col + elements}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vf2d min={std::numeric_limits<float>::max(),std::numeric_limits<float>::max()},max; |
|
|
|
|
|
|
|
bool pointsOutside=false; |
|
|
|
|
|
|
|
for(vf2d&points:outputList){ |
|
|
|
|
|
|
|
if(!geom2d::contains(rect,points)){ |
|
|
|
|
|
|
|
pointsOutside=true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!pointsOutside)goto render; |
|
|
|
for (auto i = 0u; i < clipVertices.size(); i++) { |
|
|
|
for (auto i = 0u; i < clipVertices.size(); i++) { |
|
|
|
auto clipA = clipVertices[i]; |
|
|
|
auto clipA = clipVertices[i]; |
|
|
|
auto clipB = clipVertices[(i + 1) % 4]; |
|
|
|
auto clipB = clipVertices[(i + 1) % 4]; |
|
|
@ -585,6 +599,8 @@ void olc::ViewPort::drawClippedDecal(Decal *decal, |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render: |
|
|
|
|
|
|
|
|
|
|
|
for (auto &point : outputList) { |
|
|
|
for (auto &point : outputList) { |
|
|
|
point += offset; |
|
|
|
point += offset; |
|
|
|
} |
|
|
|
} |
|
|
@ -833,10 +849,10 @@ void olc::ViewPort::DrawDropShadowStringDecal(Font&font, const olc::vf2d& pos, c |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void olc::ViewPort::DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col)const{ |
|
|
|
void olc::ViewPort::DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col)const{ |
|
|
|
FillRectDecal(pos,{size.x,float(pge->GetPixelSize().y)},col); |
|
|
|
FillRectDecal(pos,{size.x+1,1},col); |
|
|
|
FillRectDecal(pos+vf2d{0,size.y-float(pge->GetPixelSize().y)},{size.x,float(pge->GetPixelSize().y)},col); |
|
|
|
FillRectDecal(pos+vf2d{0,size.y-1+1},{size.x+1,1},col); |
|
|
|
FillRectDecal(pos+vf2d{0,float(pge->GetPixelSize().y)},{float(pge->GetPixelSize().x),size.y-float(pge->GetPixelSize().y)*2},col); |
|
|
|
FillRectDecal(pos+vf2d{0,1},{1,size.y-1*2+1},col); |
|
|
|
FillRectDecal(pos+vf2d{size.x-float(pge->GetPixelSize().x),float(pge->GetPixelSize().y)},{float(pge->GetPixelSize().x),size.y-float(pge->GetPixelSize().y)*2},col); |
|
|
|
FillRectDecal(pos+vf2d{size.x-1+1,1},{1,size.y-1*2+1},col); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |