Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dev/msvc/olcPGE3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\extensions\miniaudio\olcPGEX3_Miniaudio.h" />
<ClInclude Include="..\..\utilities\olcUTIL3_Animate2D.h" />
<ClInclude Include="..\..\utilities\olcUTIL3_Camera2D.h" />
<ClInclude Include="..\..\utilities\olcUTIL3_GameMode.h" />
Expand Down Expand Up @@ -276,6 +277,7 @@
<ClInclude Include="..\src\window.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\extensions\miniaudio\demo_Miniaudio.cpp" />
<ClCompile Include="..\src\api_macos.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
Expand Down
6 changes: 6 additions & 0 deletions dev/msvc/olcPGE3.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
<ClInclude Include="..\src\host_wxwidgets.h">
<Filter>Hosts\wxWidgets Specific</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\miniaudio\olcPGEX3_Miniaudio.h">
<Filter>Extensions\MiniAudio</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\core.cpp">
Expand Down Expand Up @@ -278,6 +281,9 @@
<ClCompile Include="..\src\host_wxwidgets.cpp">
<Filter>Hosts\wxWidgets Specific</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\miniaudio\demo_Miniaudio.cpp">
<Filter>Extensions\MiniAudio</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\README.md">
Expand Down
41 changes: 41 additions & 0 deletions dev/src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,27 @@ olc::Pixel olc::Draw::GetPixel(olc::Image& image, const olc::vf2d& pos, const ol
return failcol;
}

void olc::Draw::SetPixel(olc::Image& image, const olc::vf2d& pos, const olc::Pixel col)
{
// Check if in bounds
olc::vf2d tpos = transformAffine.forwardRound(pos);
if (tpos.x >= 0 && tpos.y >= 0 && tpos.x < float(pTarget->Size().x) && tpos.y < float(pTarget->Size().y))
{
PrepareImageForSW(image);
pTarget->Pixel(tpos) = col;
}
}

olc::Pixel olc::Draw::GetPixel(const olc::vf2d& pos, const olc::Pixel failcol)
{
return GetPixel(GetTarget(), pos, failcol);
}

void olc::Draw::SetPixel(const olc::vf2d& pos, const olc::Pixel col)
{
SetPixel(GetTarget(), pos, col);
}

olc::Pixel olc::Draw::GetRawPixel(olc::Image& image, const olc::vi2d& pos, const olc::Pixel failcol)
{
if (pos.x >= 0 && pos.y >= 0 && pos.x < float(image.Size().x) && pos.y < float(image.Size().y))
Expand All @@ -270,22 +286,47 @@ olc::Pixel olc::Draw::GetRawPixel(olc::Image& image, const olc::vi2d& pos, const
return failcol;
}

void olc::Draw::SetRawPixel(olc::Image& image, const olc::vi2d& pos, const olc::Pixel col)
{
if (pos.x >= 0 && pos.y >= 0 && pos.x < float(image.Size().x) && pos.y < float(image.Size().y))
{
PrepareImageForSW(image);
image.Pixel(pos) = col;
}
}

olc::Pixel olc::Draw::GetRawPixel(const olc::vi2d& pos, const olc::Pixel failcol)
{
return GetRawPixel(GetTarget(), pos, failcol);
}

void olc::Draw::SetRawPixel(const olc::vi2d& pos, const olc::Pixel col)
{
SetRawPixel(GetTarget(), pos, col);
}

olc::Pixel olc::Draw::GetUnsafeRawPixel(olc::Image& image, const olc::vi2d& pos)
{
PrepareImageForSW(image);
return image.Pixel(pos);
}

void olc::Draw::SetUnsafeRawPixel(olc::Image& image, const olc::vi2d& pos, const olc::Pixel col)
{
PrepareImageForSW(image);
image.Pixel(pos) = col;
}

olc::Pixel olc::Draw::GetUnsafeRawPixel(const olc::vi2d& pos)
{
return GetUnsafeRawPixel(GetTarget(), pos);
}

void olc::Draw::SetUnsafeRawPixel(const olc::vi2d& pos, const olc::Pixel col)
{
SetUnsafeRawPixel(GetTarget(), pos, col);
}

void olc::Draw::Clear(const olc::Pixel& col)
{
PrepareTargetForHW();
Expand Down
35 changes: 35 additions & 0 deletions dev/src/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,37 +233,72 @@ namespace olc
const olc::Pixel col = olc::Colour::WHITE,
const olc::Pixel tint = olc::Colour::WHITE);

// Lower-Level Pixel Manipulation

// Read a pixel from an image (guarantees fresh)
olc::Pixel GetPixel(
olc::Image& image,
const olc::vf2d& pos,
const olc::Pixel failcol = olc::Colour::BLACK);

// Write a pixel to an image
void SetPixel(
olc::Image& image,
const olc::vf2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read a pixel from target image (guarantees fresh)
olc::Pixel GetPixel(
const olc::vf2d& pos,
const olc::Pixel failcol = olc::Colour::BLACK);

// Write a pixel to target image
void SetPixel(
const olc::vf2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read an untransformed pixel from an image (guarantees fresh)
olc::Pixel GetRawPixel(
olc::Image& image,
const olc::vi2d& pos,
const olc::Pixel failcol = olc::Colour::BLACK);

// Write an untransformed pixel to an image
void SetRawPixel(
olc::Image& image,
const olc::vi2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read an untransformed pixel from target image (guarantees fresh)
olc::Pixel GetRawPixel(
const olc::vi2d& pos,
const olc::Pixel failcol = olc::Colour::BLACK);

// Write an untransformed pixel to target image
void SetRawPixel(
const olc::vi2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read an untransformed pixel from a target image with no bounds checking (gurantees fresh)
olc::Pixel GetUnsafeRawPixel(
olc::Image& image,
const olc::vi2d& pos);

// Write an untransformed pixel to a target image with no bounds checking
void SetUnsafeRawPixel(
olc::Image& image,
const olc::vi2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read an untransformed pixel from target image with no bounds checking (gurantees fresh)
olc::Pixel GetUnsafeRawPixel(
const olc::vi2d& pos);

// Write an untransformed pixel to target image with no bounds checking
void SetUnsafeRawPixel(
const olc::vi2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Clear entire draw target to specific colour
void Clear(const olc::Pixel& col);

Expand Down
76 changes: 76 additions & 0 deletions olcPixelGameEngine3.h
Original file line number Diff line number Diff line change
Expand Up @@ -2909,37 +2909,72 @@ namespace olc
const olc::Pixel col = olc::Colour::WHITE,
const olc::Pixel tint = olc::Colour::WHITE);

// Lower-Level Pixel Manipulation

// Read a pixel from an image (guarantees fresh)
olc::Pixel GetPixel(
olc::Image& image,
const olc::vf2d& pos,
const olc::Pixel failcol = olc::Colour::BLACK);

// Write a pixel to an image
void SetPixel(
olc::Image& image,
const olc::vf2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read a pixel from target image (guarantees fresh)
olc::Pixel GetPixel(
const olc::vf2d& pos,
const olc::Pixel failcol = olc::Colour::BLACK);

// Write a pixel to target image
void SetPixel(
const olc::vf2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read an untransformed pixel from an image (guarantees fresh)
olc::Pixel GetRawPixel(
olc::Image& image,
const olc::vi2d& pos,
const olc::Pixel failcol = olc::Colour::BLACK);

// Write an untransformed pixel to an image
void SetRawPixel(
olc::Image& image,
const olc::vi2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read an untransformed pixel from target image (guarantees fresh)
olc::Pixel GetRawPixel(
const olc::vi2d& pos,
const olc::Pixel failcol = olc::Colour::BLACK);

// Write an untransformed pixel to target image
void SetRawPixel(
const olc::vi2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read an untransformed pixel from a target image with no bounds checking (gurantees fresh)
olc::Pixel GetUnsafeRawPixel(
olc::Image& image,
const olc::vi2d& pos);

// Write an untransformed pixel to a target image with no bounds checking
void SetUnsafeRawPixel(
olc::Image& image,
const olc::vi2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Read an untransformed pixel from target image with no bounds checking (gurantees fresh)
olc::Pixel GetUnsafeRawPixel(
const olc::vi2d& pos);

// Write an untransformed pixel to target image with no bounds checking
void SetUnsafeRawPixel(
const olc::vi2d& pos,
const olc::Pixel col = olc::Colour::WHITE);

// Clear entire draw target to specific colour
void Clear(const olc::Pixel& col);

Expand Down Expand Up @@ -18249,11 +18284,27 @@ olc::Pixel olc::Draw::GetPixel(olc::Image& image, const olc::vf2d& pos, const ol
return failcol;
}

void olc::Draw::SetPixel(olc::Image& image, const olc::vf2d& pos, const olc::Pixel col)
{
// Check if in bounds
olc::vf2d tpos = transformAffine.forwardRound(pos);
if (tpos.x >= 0 && tpos.y >= 0 && tpos.x < float(pTarget->Size().x) && tpos.y < float(pTarget->Size().y))
{
PrepareImageForSW(image);
pTarget->Pixel(tpos) = col;
}
}

olc::Pixel olc::Draw::GetPixel(const olc::vf2d& pos, const olc::Pixel failcol)
{
return GetPixel(GetTarget(), pos, failcol);
}

void olc::Draw::SetPixel(const olc::vf2d& pos, const olc::Pixel col)
{
SetPixel(GetTarget(), pos, col);
}

olc::Pixel olc::Draw::GetRawPixel(olc::Image& image, const olc::vi2d& pos, const olc::Pixel failcol)
{
if (pos.x >= 0 && pos.y >= 0 && pos.x < float(image.Size().x) && pos.y < float(image.Size().y))
Expand All @@ -18265,22 +18316,47 @@ olc::Pixel olc::Draw::GetRawPixel(olc::Image& image, const olc::vi2d& pos, const
return failcol;
}

void olc::Draw::SetRawPixel(olc::Image& image, const olc::vi2d& pos, const olc::Pixel col)
{
if (pos.x >= 0 && pos.y >= 0 && pos.x < float(image.Size().x) && pos.y < float(image.Size().y))
{
PrepareImageForSW(image);
image.Pixel(pos) = col;
}
}

olc::Pixel olc::Draw::GetRawPixel(const olc::vi2d& pos, const olc::Pixel failcol)
{
return GetRawPixel(GetTarget(), pos, failcol);
}

void olc::Draw::SetRawPixel(const olc::vi2d& pos, const olc::Pixel col)
{
SetRawPixel(GetTarget(), pos, col);
}

olc::Pixel olc::Draw::GetUnsafeRawPixel(olc::Image& image, const olc::vi2d& pos)
{
PrepareImageForSW(image);
return image.Pixel(pos);
}

void olc::Draw::SetUnsafeRawPixel(olc::Image& image, const olc::vi2d& pos, const olc::Pixel col)
{
PrepareImageForSW(image);
image.Pixel(pos) = col;
}

olc::Pixel olc::Draw::GetUnsafeRawPixel(const olc::vi2d& pos)
{
return GetUnsafeRawPixel(GetTarget(), pos);
}

void olc::Draw::SetUnsafeRawPixel(const olc::vi2d& pos, const olc::Pixel col)
{
SetUnsafeRawPixel(GetTarget(), pos, col);
}

void olc::Draw::Clear(const olc::Pixel& col)
{
PrepareTargetForHW();
Expand Down
Loading