summaryrefslogtreecommitdiff
path: root/src/SFML/Window/OSX/SFContext.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/SFML/Window/OSX/SFContext.mm')
-rw-r--r--src/SFML/Window/OSX/SFContext.mm48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/SFML/Window/OSX/SFContext.mm b/src/SFML/Window/OSX/SFContext.mm
index cf74de9..4383799 100644
--- a/src/SFML/Window/OSX/SFContext.mm
+++ b/src/SFML/Window/OSX/SFContext.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2018 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2023 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -26,13 +26,20 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
+#include <SFML/Window/OSX/AutoreleasePoolWrapper.hpp>
#include <SFML/Window/OSX/SFContext.hpp>
#include <SFML/Window/OSX/WindowImplCocoa.hpp>
#include <SFML/System/Err.hpp>
#include <dlfcn.h>
#include <stdint.h>
-#import <SFML/Window/OSX/AutoreleasePoolWrapper.h>
+#if defined(__APPLE__)
+ #if defined(__clang__)
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ #elif defined(__GNUC__)
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ #endif
+#endif
namespace sf
{
@@ -42,12 +49,11 @@ namespace priv
////////////////////////////////////////////////////////////
SFContext::SFContext(SFContext* shared) :
+m_context(0),
m_view(0),
m_window(0)
{
- // Ask for a pool.
- ensureThreadHasPool();
-
+ AutoreleasePool pool;
// Create the context
createContext(shared,
VideoMode::getDesktopMode().bitsPerPixel,
@@ -58,12 +64,11 @@ m_window(0)
////////////////////////////////////////////////////////////
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
const WindowImpl* owner, unsigned int bitsPerPixel) :
+m_context(0),
m_view(0),
m_window(0)
{
- // Ask for a pool.
- ensureThreadHasPool();
-
+ AutoreleasePool pool;
// Create the context.
createContext(shared, bitsPerPixel, settings);
@@ -76,15 +81,14 @@ m_window(0)
////////////////////////////////////////////////////////////
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
unsigned int width, unsigned int height) :
+m_context(0),
m_view(0),
m_window(0)
{
+ AutoreleasePool pool;
// Ensure the process is setup in order to create a valid window.
WindowImplCocoa::setUpProcess();
- // Ask for a pool.
- ensureThreadHasPool();
-
// Create the context.
createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, settings);
@@ -103,6 +107,7 @@ m_window(0)
////////////////////////////////////////////////////////////
SFContext::~SFContext()
{
+ AutoreleasePool pool;
// Notify unshared OpenGL resources of context destruction
cleanupUnsharedResources();
@@ -121,6 +126,7 @@ SFContext::~SFContext()
////////////////////////////////////////////////////////////
GlFunctionPointer SFContext::getFunction(const char* name)
{
+ AutoreleasePool pool;
static void* image = NULL;
if (!image)
@@ -133,6 +139,7 @@ GlFunctionPointer SFContext::getFunction(const char* name)
////////////////////////////////////////////////////////////
bool SFContext::makeCurrent(bool current)
{
+ AutoreleasePool pool;
if (current)
{
[m_context makeCurrentContext];
@@ -149,6 +156,7 @@ bool SFContext::makeCurrent(bool current)
////////////////////////////////////////////////////////////
void SFContext::display()
{
+ AutoreleasePool pool;
[m_context flushBuffer];
}
@@ -156,6 +164,7 @@ void SFContext::display()
////////////////////////////////////////////////////////////
void SFContext::setVerticalSyncEnabled(bool enabled)
{
+ AutoreleasePool pool;
GLint swapInterval = enabled ? 1 : 0;
[m_context setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
@@ -167,6 +176,7 @@ void SFContext::createContext(SFContext* shared,
unsigned int bitsPerPixel,
const ContextSettings& settings)
{
+ AutoreleasePool pool;
// Save the settings. (OpenGL version is updated elsewhere.)
m_settings = settings;
@@ -182,14 +192,14 @@ void SFContext::createContext(SFContext* shared,
if (bitsPerPixel > 24)
{
attrs.push_back(NSOpenGLPFAAlphaSize);
- attrs.push_back((NSOpenGLPixelFormatAttribute)8);
+ attrs.push_back(static_cast<NSOpenGLPixelFormatAttribute>(8));
}
attrs.push_back(NSOpenGLPFADepthSize);
- attrs.push_back((NSOpenGLPixelFormatAttribute)m_settings.depthBits);
+ attrs.push_back(static_cast<NSOpenGLPixelFormatAttribute>(m_settings.depthBits));
attrs.push_back(NSOpenGLPFAStencilSize);
- attrs.push_back((NSOpenGLPixelFormatAttribute)m_settings.stencilBits);
+ attrs.push_back(static_cast<NSOpenGLPixelFormatAttribute>(m_settings.stencilBits));
if (m_settings.antialiasingLevel > 0)
{
@@ -209,11 +219,11 @@ void SFContext::createContext(SFContext* shared,
// Only one buffer is currently available
attrs.push_back(NSOpenGLPFASampleBuffers);
- attrs.push_back((NSOpenGLPixelFormatAttribute)1);
+ attrs.push_back(static_cast<NSOpenGLPixelFormatAttribute>(1));
// Antialiasing level
attrs.push_back(NSOpenGLPFASamples);
- attrs.push_back((NSOpenGLPixelFormatAttribute)m_settings.antialiasingLevel);
+ attrs.push_back(static_cast<NSOpenGLPixelFormatAttribute>(m_settings.antialiasingLevel));
// No software renderer - only hardware renderer
attrs.push_back(NSOpenGLPFAAccelerated);
@@ -230,7 +240,7 @@ void SFContext::createContext(SFContext* shared,
if (legacy)
{
- m_settings.attributeFlags &= ~ContextSettings::Core;
+ m_settings.attributeFlags &= ~static_cast<unsigned int>(ContextSettings::Core);
m_settings.majorVersion = 2;
m_settings.minorVersion = 1;
attrs.push_back(NSOpenGLPFAOpenGLProfile);
@@ -252,10 +262,10 @@ void SFContext::createContext(SFContext* shared,
if (m_settings.attributeFlags & ContextSettings::Debug)
{
sf::err() << "Warning. OpenGL debugging not supported on this platform." << std::endl;
- m_settings.attributeFlags &= ~ContextSettings::Debug;
+ m_settings.attributeFlags &= ~static_cast<unsigned int>(ContextSettings::Debug);
}
- attrs.push_back((NSOpenGLPixelFormatAttribute)0); // end of array
+ attrs.push_back(static_cast<NSOpenGLPixelFormatAttribute>(0)); // end of array
// All OS X pixel formats are sRGB capable
m_settings.sRgbCapable = true;