Skip to content
Closed
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
5 changes: 3 additions & 2 deletions dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\examples\olcPGE3_BlendingModes.cpp" />
<ClCompile Include="..\..\..\examples\olcPGE3_CirclesEllipses.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\examples\olcPGE3_Extensions.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
Expand Down
3 changes: 3 additions & 0 deletions dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
<ClCompile Include="..\..\..\examples\olcPGE3_LocalTransforms.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\examples\olcPGE3_BlendingModes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="..\..\..\examples\assets\minsanity_texture.png">
Expand Down
42 changes: 25 additions & 17 deletions dev/src/api_macos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static constexpr const char* kCustomOpenGLViewClass = "CustomOpenGLV
static constexpr const char* kGeneralWindowDelegateClass = "GeneralWindowDelegate";

// Application Screen management selectors
static constexpr const char* kNSScreenClass = "NSScreen";
//static constexpr const char* kNSScreenClass = "NSScreen"; // Temp remove unused variable warning
static constexpr const char* kScreenSel = "screen";
static constexpr const char* kNSCursorClass = "NSCursor";
static constexpr const char* kUnhideSel = "unhide";
Expand Down Expand Up @@ -139,7 +139,7 @@ static constexpr const char* kLocaleIdentifierSel = "localeIdentif
static constexpr const char* kWindowTitle = "C macOS OpenGL Framework";
static constexpr double kDefaultWindowWidth = 800.0;
static constexpr double kDefaultWindowHeight = 600.0;
static constexpr int kBitsPerByte = 8;
// static constexpr int kBitsPerByte = 8; // Temp remove unused variable warning
static constexpr int kMinValidDimension = 0;
static constexpr int kRGBABytesPerPixel = 4;
static constexpr int kFullyOpaque = 255;
Expand All @@ -149,7 +149,7 @@ static constexpr int kZeroWidth = 0;
static constexpr int kZeroHeight = 0;
static constexpr int kFlippedOffset = 1;
static constexpr int kNoButton = -1;
static constexpr int kDefaultScreenNumber = 1;
// static constexpr int kDefaultScreenNumber = 1; // Temp remove unused variable warning
bool bAllowHideCursor = true;
bool bHideCursor = false;

Expand Down Expand Up @@ -280,8 +280,8 @@ namespace ObjectiveCSEL {
// NSLocale selectors
static SEL currentLocaleSel = nullptr;
static SEL localeIdentifierSel = nullptr;
static SEL currentInputContextSel = nullptr;
static SEL localizedNameSel = nullptr;
// static SEL currentInputContextSel = nullptr; // Temp remove unused variable warning
// static SEL localizedNameSel = nullptr; // Temp remove unused variable warning

// Initialize all selectors - called once at startup
void initializeSelectors() {
Expand Down Expand Up @@ -508,7 +508,7 @@ static constexpr int NSOpenGLPFAOpenGLProfile = static_cast<int>(NSOpenGLPixelFo
static constexpr int NSOpenGLPFASampleBuffers = static_cast<int>(NSOpenGLPixelFormatAttribute::SampleBuffers);
static constexpr int NSOpenGLPFAMultisample = static_cast<int>(NSOpenGLPixelFormatAttribute::Multisample);
static constexpr int NSOpenGLAllowOfflineRenderers = static_cast<int>(NSOpenGLPixelFormatAttribute::AllowOfflineRenderers);
static constexpr int NSOpenGLPFAAcceleratedCompute = static_cast<int>(NSOpenGLPixelFormatAttribute::AcceleratedCompute);
// static constexpr int NSOpenGLPFAAcceleratedCompute = static_cast<int>(NSOpenGLPixelFormatAttribute::AcceleratedCompute); // Temp remove unused variable warning

// enum for OpenGL profile versions
enum class NSOpenGLProfile : int {
Expand All @@ -517,6 +517,14 @@ enum class NSOpenGLProfile : int {
Version4_1Core = 0x4100, // OpenGL 4.1 Core Profile
};

// enum for OpenGL context parameters
enum NSOpenGLContextParameter : int {
NSOpenGLContextParameterSwapInterval = 222,
NSOpenGLContextParameterSurfaceOrder = 235,
NSOpenGLContextParameterSurfaceOpacity = 236,
NSOpenGLContextParameterSurfaceBackingSize = 237
};

// Backward compatibility
//static constexpr int NSOpenGLProfileVersion3_2Core = static_cast<int>(NSOpenGLProfile::Version3_2Core);
static constexpr int NSOpenGLProfileVersion4_1Core = static_cast<int>(NSOpenGLProfile::Version4_1Core);
Expand All @@ -538,10 +546,10 @@ enum class NSWindowStyleMask : uint16_t {
};

// Backward compatibility
static constexpr int NSWindowStyleMaskTitled = static_cast<int>(NSWindowStyleMask::Titled);
static constexpr int NSWindowStyleMaskClosable = static_cast<int>(NSWindowStyleMask::Closable);
static constexpr int NSWindowStyleMaskMiniaturizable = static_cast<int>(NSWindowStyleMask::Miniaturizable);
static constexpr int NSWindowStyleMaskResizable = static_cast<int>(NSWindowStyleMask::Resizable);
// static constexpr int NSWindowStyleMaskTitled = static_cast<int>(NSWindowStyleMask::Titled); // Temp remove unused variable warning
// static constexpr int NSWindowStyleMaskClosable = static_cast<int>(NSWindowStyleMask::Closable); // Temp remove unused variable warning
// static constexpr int NSWindowStyleMaskMiniaturizable = static_cast<int>(NSWindowStyleMask::Miniaturizable); // Temp remove unused variable warning
// static constexpr int NSWindowStyleMaskResizable = static_cast<int>(NSWindowStyleMask::Resizable); // Temp remove unused variable warning
static constexpr int NSWindowStyleMaskFullScreen = static_cast<int>(NSWindowStyleMask::FullScreen);

// enum for backing store types
Expand Down Expand Up @@ -1846,7 +1854,7 @@ extern "C" {
GLint swapInterval = enabled ? 1 : 0;

// Use NSOpenGLContext setValues:forParameter: to set swap interval
const GLint parameter = 222; // NSOpenGLContextParameterSwapInterval
const GLint parameter = NSOpenGLContextParameterSwapInterval;
((void(*)(id, SEL, const GLint*, GLint))objc_msgSend)(self->glContext, ObjectiveCSEL::setValuesSel, &swapInterval, parameter);
}

Expand Down Expand Up @@ -1897,13 +1905,13 @@ extern "C" {
CGDataProviderRef provider = CGImageGetDataProvider(image);
CFDataRef rawData = CGDataProviderCopyData(provider);

CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(image);
CGImageAlphaInfo alphaInfo = (CGImageAlphaInfo)(bitmapInfo & kCGBitmapAlphaInfoMask);
CGBitmapInfo byteOrder = bitmapInfo & kCGBitmapByteOrderMask;
//CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(image); // Temp remove unused variable warning
//CGImageAlphaInfo alphaInfo = (CGImageAlphaInfo)(bitmapInfo & kCGBitmapAlphaInfoMask); // Temp remove unused variable warning
//CGBitmapInfo byteOrder = bitmapInfo & kCGBitmapByteOrderMask; // Temp remove unused variable warning

self->width = CGImageGetWidth(image);
self->height = CGImageGetHeight(image);
self->bytesPerPixel = 4;
self->width = (int)CGImageGetWidth(image);
self->height = (int)CGImageGetHeight(image);
self->bytesPerPixel = kRGBABytesPerPixel; // 4 bytes for RGBA
self->bytesPerRow = self->width * self->bytesPerPixel;
self->hasAlpha = YES;

Expand Down
2 changes: 2 additions & 0 deletions dev/src/api_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ namespace olc::apis::opengl
{
#if OLC_HOST == OLC_HOST_WINDOWS
_wglSwapIntervalEXT(n);
#else
olc_IgnoreUnused(n);
#endif
}

Expand Down
11 changes: 10 additions & 1 deletion dev/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,20 @@

#define LICENCE_DEFAULT "OneLoneCoder.com - Pixel Game Engine 3 - "

#if OLC_HOST == OLC_HOST_MACOS
// De-Noise in clang (C++20) MacOS
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas" // Allow unknown pragmas for compatibility with different compilers
#pragma clang diagnostic ignored "-Wgnu-anonymous-struct" // Allow anonymous structs in unions

#endif

// De-Noise in MSVC (C++20) /Wall
#pragma warning(disable:4820) // Disable Padding Warnings
#pragma warning(disable:5045) // Disable Spectre Mitigation Warnings
#pragma warning(disable:4514) // Disable Unreferenced Inline Function Warnings


template<typename... Args>
inline constexpr void olc_IgnoreUnused(Args&&...) noexcept {}

Expand Down Expand Up @@ -188,4 +197,4 @@ inline constexpr void olc_IgnoreUnused(Args&&...) noexcept {}
#define OLC_FRIENDLY_HOST Host_Android
#endif

//! END CONFIGURATION
//! END CONFIGURATION
4 changes: 4 additions & 0 deletions dev/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ namespace olc
// Present final composite
pRenderer->SetViewport(vViewPos, vViewSize);
pRenderer->ClearViewport(config.colClear, true, true);
draw.SetBlendMode(olc::BlendMode::Alpha);
draw.SetCullMode(olc::CullMode::None);
draw.ImageRect(GetScreen().flipV(), { 0.0,0.0 }, vViewSize);
draw.ProcessGPUTasks();

Expand Down Expand Up @@ -514,6 +516,8 @@ namespace olc
draw.ProcessGPUTasks();

// Set to known default state
draw.SetBlendMode(olc::BlendMode::Alpha);
draw.SetCullMode(olc::CullMode::None);
draw.SetTarget(GetScreen());
draw.WorldReset();
gpu->ApplyDefaultShader();
Expand Down
28 changes: 26 additions & 2 deletions dev/src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include "gpu_iface.h"

//! START IMPLEMENTATION
#if OLC_HOST == OLC_HOST_MACOS
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpessimizing-move" // Suppress clang C++20 warning about moves preventing copy elision on macOS
#endif
using namespace olc;

// Some local pools to reduce allocations
Expand Down Expand Up @@ -266,6 +270,7 @@ GPUTask olc::Draw::TaskDrawLine(const std::vector<olc::vf2d>& vPoints, const std
task.vertexBuffer[i*2+0] = { {vPoints[i].x, vPoints[i].y, 1.0f, 1.0f}, vColours[i], {0, 0}, {0, 0}, {0, 0}, {0, 0} };
task.vertexBuffer[i*2+1] = { {vPoints[i + 1].x, vPoints[i + 1].y, 1.0f, 1.0f}, vColours[i + 1], {0, 0}, {0, 0}, {0, 0}, {0, 0} };
}
task.blendmode = blendMode;
task.tint = tint;
return task;
}
Expand All @@ -278,6 +283,7 @@ GPUTask olc::Draw::TaskDrawPolygon(olc::Structure structure, const std::vector<o
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;
}
Expand All @@ -290,6 +296,7 @@ GPUTask olc::Draw::TaskDrawPolygon(olc::Structure structure, const std::vector<o
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}, colour, {0, 0}, {0, 0}, {0, 0}, {0, 0}};
task.blendmode = blendMode;
task.tint = tint;
return task;
}
Expand All @@ -301,6 +308,7 @@ GPUTask olc::Draw::TaskFillPolygon(olc::Structure structure, const std::vector<o
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;
}
Expand All @@ -312,6 +320,7 @@ GPUTask olc::Draw::TaskFillPolygon(olc::Structure structure, const std::vector<o
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}, colour, {0, 0}, {0, 0}, {0, 0}, {0, 0} };
task.blendmode = blendMode;
task.tint = tint;
return task;
}
Expand All @@ -324,6 +333,7 @@ GPUTask olc::Draw::TaskTexturedPolygon(olc::Structure structure, const std::vect
for (size_t i = 0; i<vPoints.size(); i++)
task.vertexBuffer[i] = { {vPoints[i].x, vPoints[i].y, 1.0f, 1.0f}, vColours[i], {vTexCoords[i].x, vTexCoords[i].y}, {0, 0}, {0, 0}, {0, 0} };
task.pImage = image;
task.blendmode = blendMode;
task.tint = tint;
return task;
}
Expand All @@ -336,6 +346,7 @@ GPUTask olc::Draw::TaskTexturedPolygon(olc::Structure structure, const std::vect
for (size_t i = 0; i < vPoints.size(); i++)
task.vertexBuffer[i] = { {vPoints[i].x, vPoints[i].y, vZWs[i].x, vZWs[i].y}, vColours[i], {vTexCoords[i].x, vTexCoords[i].y}, {0, 0}, {0, 0}, {0, 0} };
task.pImage = image;
task.blendmode = blendMode;
task.tint = tint;
return task;
}
Expand All @@ -350,6 +361,7 @@ GPUTask olc::Draw::TaskWireMesh(olc::Structure structure, const std::vector<olc:
task.bDepth = bDepth;
task.cullmode = cullMode;
task.bIs3D = true;
task.blendmode = blendMode;
task.mvpMatrix = matMVP.m;

for (size_t i = 0; i < vPoints.size(); i++)
Expand All @@ -367,6 +379,7 @@ GPUTask olc::Draw::TaskFillMesh(olc::Structure structure, const std::vector<olc:
task.cullmode = cullMode;
task.bIs3D = true;
task.mvpMatrix = matMVP.m;
task.blendmode = blendMode;

for (size_t i = 0; i < vPoints.size(); i++)
task.vertexBuffer[i] = { {vPoints[i].x, vPoints[i].y, vPoints[i].z, vPoints[i].w}, vColours[i], {0, 0}, {0, 0}, {0, 0}, {0, 0} };
Expand All @@ -384,6 +397,8 @@ GPUTask olc::Draw::TaskTexturedMesh(olc::Structure structure, const std::vector<
task.bDepth = bDepth;
task.cullmode = cullMode;
task.mvpMatrix = matMVP.m;
task.blendmode = blendMode;

for (size_t i = 0; i < vPoints.size(); i++)
task.vertexBuffer[i] = { {vPoints[i].x, vPoints[i].y, vPoints[i].z, vPoints[i].w}, vColours[i], {vTexCoords[i].x, vTexCoords[i].y}, {0, 0}, {0, 0}, {0, 0} };
return task;
Expand Down Expand Up @@ -1093,11 +1108,16 @@ const GPUTask& olc::Draw::ImageRect(olc::ImageRegion image, const olc::vf2d& pos
}


void olc::Draw::SetCullMode(const olc::GPUTask::CullMode mode)
void olc::Draw::SetCullMode(const olc::CullMode mode)
{
cullMode = mode;
}

void olc::Draw::SetBlendMode(const olc::BlendMode mode)
{
blendMode = mode;
}

void olc::Draw::EnableDepth(const bool bEnable)
{
bDepth = bEnable;
Expand Down Expand Up @@ -1161,4 +1181,8 @@ const olc::mf4d& olc::Draw::GetMVPMatrix() const
return matMVP;
}

//! END IMPLEMENTATION
#if OLC_HOST == OLC_HOST_MACOS
#pragma clang diagnostic pop
#endif

//! END IMPLEMENTATION
6 changes: 4 additions & 2 deletions dev/src/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@ namespace olc
const olc::Pixel tint = olc::Colour::WHITE);

public: // Applied Rendering Modes
void SetCullMode(const olc::GPUTask::CullMode mode);
void SetCullMode(const olc::CullMode mode);
void SetBlendMode(const olc::BlendMode mode);
void EnableDepth(const bool bEnable);
void SetViewport(const olc::vi2d& pos, const olc::vi2d& size);

Expand Down Expand Up @@ -1026,7 +1027,8 @@ namespace olc
olc::vi2d vViewportSize = { 0, 0 };


olc::GPUTask::CullMode cullMode = olc::GPUTask::CullMode::None;
olc::CullMode cullMode = olc::CullMode::None;
olc::BlendMode blendMode = olc::BlendMode::Alpha;
bool bDepth = true;


Expand Down
3 changes: 2 additions & 1 deletion dev/src/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ namespace olc
fontClassicPGE.glyphs.push_back(glyph);
}
else
fontClassicPGE.glyphs.push_back(FontGlyph{ fontClassicPGE.imgFont.region({0,0}, {8,8}) , 8.0f, {8.0f, 8.0f} });
// Added missing vMonoSize for non-printable characters, which was causing -Wmissing-field-initializers
fontClassicPGE.glyphs.push_back(FontGlyph{ fontClassicPGE.imgFont.region({0,0}, {8,8}) , 8.0f, {8.0f, 8.0f}, { 0.0f, 0.0f } });
}

fontClassicPGE.fLineHeight = 8.0f;
Expand Down
Loading
Loading