Enable support for unity builds
This commit is contained in:
parent
47a4e88704
commit
f162b3a037
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -21,6 +21,8 @@ jobs:
|
|||||||
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }
|
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }
|
||||||
|
|
||||||
include:
|
include:
|
||||||
|
- platform: { name: Windows VS2019, os: windows-latest }
|
||||||
|
config: { name: Unity, flags: -DBUILD_SHARED_LIBS=TRUE -DCMAKE_UNITY_BUILD=ON }
|
||||||
- platform: { name: MacOS XCode, os: macos-latest }
|
- platform: { name: MacOS XCode, os: macos-latest }
|
||||||
config: { name: Frameworks, flags: -DSFML_BUILD_FRAMEWORKS=TRUE }
|
config: { name: Frameworks, flags: -DSFML_BUILD_FRAMEWORKS=TRUE }
|
||||||
- platform: { name: MacOS XCode, os: macos-latest }
|
- platform: { name: MacOS XCode, os: macos-latest }
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
const sf::Uint8 audioData = 1;
|
const sf::Uint8 clientAudioData = 1;
|
||||||
const sf::Uint8 endOfStream = 2;
|
const sf::Uint8 clientEndOfStream = 2;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -71,7 +71,7 @@ private:
|
|||||||
{
|
{
|
||||||
// Pack the audio samples into a network packet
|
// Pack the audio samples into a network packet
|
||||||
sf::Packet packet;
|
sf::Packet packet;
|
||||||
packet << audioData;
|
packet << clientAudioData;
|
||||||
packet.append(samples, sampleCount * sizeof(sf::Int16));
|
packet.append(samples, sampleCount * sizeof(sf::Int16));
|
||||||
|
|
||||||
// Send the audio packet to the server
|
// Send the audio packet to the server
|
||||||
@ -86,7 +86,7 @@ private:
|
|||||||
{
|
{
|
||||||
// Send a "end-of-stream" packet
|
// Send a "end-of-stream" packet
|
||||||
sf::Packet packet;
|
sf::Packet packet;
|
||||||
packet << endOfStream;
|
packet << clientEndOfStream;
|
||||||
m_socket.send(packet);
|
m_socket.send(packet);
|
||||||
|
|
||||||
// Close the socket
|
// Close the socket
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
|
||||||
const sf::Uint8 audioData = 1;
|
const sf::Uint8 serverAudioData = 1;
|
||||||
const sf::Uint8 endOfStream = 2;
|
const sf::Uint8 serverEndOfStream = 2;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -123,7 +123,7 @@ private:
|
|||||||
sf::Uint8 id;
|
sf::Uint8 id;
|
||||||
packet >> id;
|
packet >> id;
|
||||||
|
|
||||||
if (id == audioData)
|
if (id == serverAudioData)
|
||||||
{
|
{
|
||||||
// Extract audio samples from the packet, and append it to our samples buffer
|
// Extract audio samples from the packet, and append it to our samples buffer
|
||||||
const sf::Int16* samples = reinterpret_cast<const sf::Int16*>(static_cast<const char*>(packet.getData()) + 1);
|
const sf::Int16* samples = reinterpret_cast<const sf::Int16*>(static_cast<const char*>(packet.getData()) + 1);
|
||||||
@ -136,7 +136,7 @@ private:
|
|||||||
std::copy(samples, samples + sampleCount, std::back_inserter(m_samples));
|
std::copy(samples, samples + sampleCount, std::back_inserter(m_samples));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (id == endOfStream)
|
else if (id == serverEndOfStream)
|
||||||
{
|
{
|
||||||
// End of stream reached: we stop receiving audio data
|
// End of stream reached: we stop receiving audio data
|
||||||
std::cout << "Audio data has been 100% received!" << std::endl;
|
std::cout << "Audio data has been 100% received!" << std::endl;
|
||||||
|
@ -25,11 +25,18 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#define SF_GLAD_GL_IMPLEMENTATION
|
|
||||||
#include <SFML/Graphics/GLExtensions.hpp>
|
#include <SFML/Graphics/GLExtensions.hpp>
|
||||||
#include <SFML/Window/Context.hpp>
|
#include <SFML/Window/Context.hpp>
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
|
|
||||||
|
// We check for this definition in order to avoid multiple definitions of GLAD
|
||||||
|
// entities during unity builds of SFML.
|
||||||
|
#ifndef SF_GLAD_GL_IMPLEMENTATION_INCLUDED
|
||||||
|
#define SF_GLAD_GL_IMPLEMENTATION_INCLUDED
|
||||||
|
#define SF_GLAD_GL_IMPLEMENTATION
|
||||||
|
#include <glad/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(GL_MAJOR_VERSION)
|
#if !defined(GL_MAJOR_VERSION)
|
||||||
#define GL_MAJOR_VERSION 0x821B
|
#define GL_MAJOR_VERSION 0x821B
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,6 +51,9 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
{
|
||||||
|
// A nested named namespace is used here to allow unity builds of SFML.
|
||||||
|
namespace RenderTargetImpl
|
||||||
{
|
{
|
||||||
// Mutex to protect ID generation and our context-RenderTarget-map
|
// Mutex to protect ID generation and our context-RenderTarget-map
|
||||||
sf::Mutex mutex;
|
sf::Mutex mutex;
|
||||||
@ -143,6 +146,7 @@ namespace
|
|||||||
return GLEXT_GL_FUNC_ADD;
|
return GLEXT_GL_FUNC_ADD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -167,7 +171,7 @@ RenderTarget::~RenderTarget()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void RenderTarget::clear(const Color& color)
|
void RenderTarget::clear(const Color& color)
|
||||||
{
|
{
|
||||||
if (isActive(m_id) || setActive(true))
|
if (RenderTargetImpl::isActive(m_id) || setActive(true))
|
||||||
{
|
{
|
||||||
// Unbind texture to fix RenderTexture preventing clear
|
// Unbind texture to fix RenderTexture preventing clear
|
||||||
applyTexture(NULL);
|
applyTexture(NULL);
|
||||||
@ -282,7 +286,7 @@ void RenderTarget::draw(const Vertex* vertices, std::size_t vertexCount,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (isActive(m_id) || setActive(true))
|
if (RenderTargetImpl::isActive(m_id) || setActive(true))
|
||||||
{
|
{
|
||||||
// Check if the vertex count is low enough so that we can pre-transform them
|
// Check if the vertex count is low enough so that we can pre-transform them
|
||||||
bool useVertexCache = (vertexCount <= StatesCache::VertexCacheSize);
|
bool useVertexCache = (vertexCount <= StatesCache::VertexCacheSize);
|
||||||
@ -382,7 +386,7 @@ void RenderTarget::draw(const VertexBuffer& vertexBuffer, std::size_t firstVerte
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (isActive(m_id) || setActive(true))
|
if (RenderTargetImpl::isActive(m_id) || setActive(true))
|
||||||
{
|
{
|
||||||
setupDraw(false, states);
|
setupDraw(false, states);
|
||||||
|
|
||||||
@ -424,11 +428,12 @@ bool RenderTarget::setActive(bool active)
|
|||||||
{
|
{
|
||||||
// Mark this RenderTarget as active or no longer active in the tracking map
|
// Mark this RenderTarget as active or no longer active in the tracking map
|
||||||
{
|
{
|
||||||
sf::Lock lock(mutex);
|
sf::Lock lock(RenderTargetImpl::mutex);
|
||||||
|
|
||||||
Uint64 contextId = Context::getActiveContextId();
|
Uint64 contextId = Context::getActiveContextId();
|
||||||
|
|
||||||
ContextRenderTargetMap::iterator iter = contextRenderTargetMap.find(contextId);
|
using RenderTargetImpl::contextRenderTargetMap;
|
||||||
|
RenderTargetImpl::ContextRenderTargetMap::iterator iter = contextRenderTargetMap.find(contextId);
|
||||||
|
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
@ -462,7 +467,7 @@ bool RenderTarget::setActive(bool active)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void RenderTarget::pushGLStates()
|
void RenderTarget::pushGLStates()
|
||||||
{
|
{
|
||||||
if (isActive(m_id) || setActive(true))
|
if (RenderTargetImpl::isActive(m_id) || setActive(true))
|
||||||
{
|
{
|
||||||
#ifdef SFML_DEBUG
|
#ifdef SFML_DEBUG
|
||||||
// make sure that the user didn't leave an unchecked OpenGL error
|
// make sure that the user didn't leave an unchecked OpenGL error
|
||||||
@ -494,7 +499,7 @@ void RenderTarget::pushGLStates()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void RenderTarget::popGLStates()
|
void RenderTarget::popGLStates()
|
||||||
{
|
{
|
||||||
if (isActive(m_id) || setActive(true))
|
if (RenderTargetImpl::isActive(m_id) || setActive(true))
|
||||||
{
|
{
|
||||||
glCheck(glMatrixMode(GL_PROJECTION));
|
glCheck(glMatrixMode(GL_PROJECTION));
|
||||||
glCheck(glPopMatrix());
|
glCheck(glPopMatrix());
|
||||||
@ -523,7 +528,7 @@ void RenderTarget::resetGLStates()
|
|||||||
setActive(false);
|
setActive(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (isActive(m_id) || setActive(true))
|
if (RenderTargetImpl::isActive(m_id) || setActive(true))
|
||||||
{
|
{
|
||||||
// Make sure that extensions are initialized
|
// Make sure that extensions are initialized
|
||||||
priv::ensureExtensionsInit();
|
priv::ensureExtensionsInit();
|
||||||
@ -582,7 +587,7 @@ void RenderTarget::initialize()
|
|||||||
|
|
||||||
// Generate a unique ID for this RenderTarget to track
|
// Generate a unique ID for this RenderTarget to track
|
||||||
// whether it is active within a specific context
|
// whether it is active within a specific context
|
||||||
m_id = getUniqueId();
|
m_id = RenderTargetImpl::getUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -608,6 +613,9 @@ void RenderTarget::applyCurrentView()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void RenderTarget::applyBlendMode(const BlendMode& mode)
|
void RenderTarget::applyBlendMode(const BlendMode& mode)
|
||||||
{
|
{
|
||||||
|
using RenderTargetImpl::factorToGlConstant;
|
||||||
|
using RenderTargetImpl::equationToGlConstant;
|
||||||
|
|
||||||
// Apply the blend mode, falling back to the non-separate versions if necessary
|
// Apply the blend mode, falling back to the non-separate versions if necessary
|
||||||
if (GLEXT_blend_func_separate)
|
if (GLEXT_blend_func_separate)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,9 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
{
|
||||||
|
// A nested named namespace is used here to allow unity builds of SFML.
|
||||||
|
namespace TextureImpl
|
||||||
{
|
{
|
||||||
sf::Mutex idMutex;
|
sf::Mutex idMutex;
|
||||||
sf::Mutex maximumSizeMutex;
|
sf::Mutex maximumSizeMutex;
|
||||||
@ -54,6 +57,7 @@ namespace
|
|||||||
return id++;
|
return id++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -69,7 +73,7 @@ m_isRepeated (false),
|
|||||||
m_pixelsFlipped(false),
|
m_pixelsFlipped(false),
|
||||||
m_fboAttachment(false),
|
m_fboAttachment(false),
|
||||||
m_hasMipmap (false),
|
m_hasMipmap (false),
|
||||||
m_cacheId (getUniqueId())
|
m_cacheId (TextureImpl::getUniqueId())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +89,7 @@ m_isRepeated (copy.m_isRepeated),
|
|||||||
m_pixelsFlipped(false),
|
m_pixelsFlipped(false),
|
||||||
m_fboAttachment(false),
|
m_fboAttachment(false),
|
||||||
m_hasMipmap (false),
|
m_hasMipmap (false),
|
||||||
m_cacheId (getUniqueId())
|
m_cacheId (TextureImpl::getUniqueId())
|
||||||
{
|
{
|
||||||
if (copy.m_texture)
|
if (copy.m_texture)
|
||||||
{
|
{
|
||||||
@ -206,7 +210,7 @@ bool Texture::create(unsigned int width, unsigned int height)
|
|||||||
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP)));
|
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP)));
|
||||||
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
||||||
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
||||||
m_cacheId = getUniqueId();
|
m_cacheId = TextureImpl::getUniqueId();
|
||||||
|
|
||||||
m_hasMipmap = false;
|
m_hasMipmap = false;
|
||||||
|
|
||||||
@ -422,7 +426,7 @@ void Texture::update(const Uint8* pixels, unsigned int width, unsigned int heigh
|
|||||||
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
||||||
m_hasMipmap = false;
|
m_hasMipmap = false;
|
||||||
m_pixelsFlipped = false;
|
m_pixelsFlipped = false;
|
||||||
m_cacheId = getUniqueId();
|
m_cacheId = TextureImpl::getUniqueId();
|
||||||
|
|
||||||
// Force an OpenGL flush, so that the texture data will appear updated
|
// Force an OpenGL flush, so that the texture data will appear updated
|
||||||
// in all contexts immediately (solves problems in multi-threaded apps)
|
// in all contexts immediately (solves problems in multi-threaded apps)
|
||||||
@ -525,7 +529,7 @@ void Texture::update(const Texture& texture, unsigned int x, unsigned int y)
|
|||||||
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
||||||
m_hasMipmap = false;
|
m_hasMipmap = false;
|
||||||
m_pixelsFlipped = false;
|
m_pixelsFlipped = false;
|
||||||
m_cacheId = getUniqueId();
|
m_cacheId = TextureImpl::getUniqueId();
|
||||||
|
|
||||||
// Force an OpenGL flush, so that the texture data will appear updated
|
// Force an OpenGL flush, so that the texture data will appear updated
|
||||||
// in all contexts immediately (solves problems in multi-threaded apps)
|
// in all contexts immediately (solves problems in multi-threaded apps)
|
||||||
@ -581,7 +585,7 @@ void Texture::update(const Window& window, unsigned int x, unsigned int y)
|
|||||||
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
|
||||||
m_hasMipmap = false;
|
m_hasMipmap = false;
|
||||||
m_pixelsFlipped = true;
|
m_pixelsFlipped = true;
|
||||||
m_cacheId = getUniqueId();
|
m_cacheId = TextureImpl::getUniqueId();
|
||||||
|
|
||||||
// Force an OpenGL flush, so that the texture will appear updated
|
// Force an OpenGL flush, so that the texture will appear updated
|
||||||
// in all contexts immediately (solves problems in multi-threaded apps)
|
// in all contexts immediately (solves problems in multi-threaded apps)
|
||||||
@ -790,7 +794,7 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
unsigned int Texture::getMaximumSize()
|
unsigned int Texture::getMaximumSize()
|
||||||
{
|
{
|
||||||
Lock lock(maximumSizeMutex);
|
Lock lock(TextureImpl::maximumSizeMutex);
|
||||||
|
|
||||||
static bool checked = false;
|
static bool checked = false;
|
||||||
static GLint size = 0;
|
static GLint size = 0;
|
||||||
@ -832,8 +836,8 @@ void Texture::swap(Texture& right)
|
|||||||
std::swap(m_fboAttachment, right.m_fboAttachment);
|
std::swap(m_fboAttachment, right.m_fboAttachment);
|
||||||
std::swap(m_hasMipmap, right.m_hasMipmap);
|
std::swap(m_hasMipmap, right.m_hasMipmap);
|
||||||
|
|
||||||
m_cacheId = getUniqueId();
|
m_cacheId = TextureImpl::getUniqueId();
|
||||||
right.m_cacheId = getUniqueId();
|
right.m_cacheId = TextureImpl::getUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
{
|
||||||
|
// A nested named namespace is used here to allow unity builds of SFML.
|
||||||
|
namespace VertexBufferImpl
|
||||||
{
|
{
|
||||||
sf::Mutex isAvailableMutex;
|
sf::Mutex isAvailableMutex;
|
||||||
|
|
||||||
@ -48,6 +51,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -143,7 +147,7 @@ bool VertexBuffer::create(std::size_t vertexCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glCheck(GLEXT_glBindBuffer(GLEXT_GL_ARRAY_BUFFER, m_buffer));
|
glCheck(GLEXT_glBindBuffer(GLEXT_GL_ARRAY_BUFFER, m_buffer));
|
||||||
glCheck(GLEXT_glBufferData(GLEXT_GL_ARRAY_BUFFER, sizeof(Vertex) * vertexCount, 0, usageToGlEnum(m_usage)));
|
glCheck(GLEXT_glBufferData(GLEXT_GL_ARRAY_BUFFER, sizeof(Vertex) * vertexCount, 0, VertexBufferImpl::usageToGlEnum(m_usage)));
|
||||||
glCheck(GLEXT_glBindBuffer(GLEXT_GL_ARRAY_BUFFER, 0));
|
glCheck(GLEXT_glBindBuffer(GLEXT_GL_ARRAY_BUFFER, 0));
|
||||||
|
|
||||||
m_size = vertexCount;
|
m_size = vertexCount;
|
||||||
@ -186,7 +190,7 @@ bool VertexBuffer::update(const Vertex* vertices, std::size_t vertexCount, unsig
|
|||||||
// Check if we need to resize or orphan the buffer
|
// Check if we need to resize or orphan the buffer
|
||||||
if (vertexCount >= m_size)
|
if (vertexCount >= m_size)
|
||||||
{
|
{
|
||||||
glCheck(GLEXT_glBufferData(GLEXT_GL_ARRAY_BUFFER, sizeof(Vertex) * vertexCount, 0, usageToGlEnum(m_usage)));
|
glCheck(GLEXT_glBufferData(GLEXT_GL_ARRAY_BUFFER, sizeof(Vertex) * vertexCount, 0, VertexBufferImpl::usageToGlEnum(m_usage)));
|
||||||
|
|
||||||
m_size = vertexCount;
|
m_size = vertexCount;
|
||||||
}
|
}
|
||||||
@ -230,7 +234,7 @@ bool VertexBuffer::update(const VertexBuffer& vertexBuffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glCheck(GLEXT_glBindBuffer(GLEXT_GL_ARRAY_BUFFER, m_buffer));
|
glCheck(GLEXT_glBindBuffer(GLEXT_GL_ARRAY_BUFFER, m_buffer));
|
||||||
glCheck(GLEXT_glBufferData(GLEXT_GL_ARRAY_BUFFER, sizeof(Vertex) * vertexBuffer.m_size, 0, usageToGlEnum(m_usage)));
|
glCheck(GLEXT_glBufferData(GLEXT_GL_ARRAY_BUFFER, sizeof(Vertex) * vertexBuffer.m_size, 0, VertexBufferImpl::usageToGlEnum(m_usage)));
|
||||||
|
|
||||||
void* destination = 0;
|
void* destination = 0;
|
||||||
glCheck(destination = GLEXT_glMapBuffer(GLEXT_GL_ARRAY_BUFFER, GLEXT_GL_WRITE_ONLY));
|
glCheck(destination = GLEXT_glMapBuffer(GLEXT_GL_ARRAY_BUFFER, GLEXT_GL_WRITE_ONLY));
|
||||||
@ -332,7 +336,7 @@ VertexBuffer::Usage VertexBuffer::getUsage() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool VertexBuffer::isAvailable()
|
bool VertexBuffer::isAvailable()
|
||||||
{
|
{
|
||||||
Lock lock(isAvailableMutex);
|
Lock lock(VertexBufferImpl::isAvailableMutex);
|
||||||
|
|
||||||
static bool checked = false;
|
static bool checked = false;
|
||||||
static bool available = false;
|
static bool available = false;
|
||||||
|
@ -32,9 +32,13 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// This per-thread variable holds the last activated sf::Context for each thread
|
// A nested named namespace is used here to allow unity builds of SFML.
|
||||||
|
namespace ContextImpl
|
||||||
|
{
|
||||||
|
// This per-thread variable holds the current context for each thread
|
||||||
sf::ThreadLocalPtr<sf::Context> currentContext(NULL);
|
sf::ThreadLocalPtr<sf::Context> currentContext(NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
@ -60,7 +64,7 @@ bool Context::setActive(bool active)
|
|||||||
bool result = m_context->setActive(active);
|
bool result = m_context->setActive(active);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
currentContext = (active ? this : NULL);
|
ContextImpl::currentContext = (active ? this : NULL);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -76,6 +80,8 @@ const ContextSettings& Context::getSettings() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const Context* Context::getActiveContext()
|
const Context* Context::getActiveContext()
|
||||||
{
|
{
|
||||||
|
using ContextImpl::currentContext;
|
||||||
|
|
||||||
// We have to check that the last activated sf::Context is still active (a RenderTarget activation may have deactivated it)
|
// We have to check that the last activated sf::Context is still active (a RenderTarget activation may have deactivated it)
|
||||||
if (currentContext && currentContext->m_context == priv::GlContext::getActiveContext())
|
if (currentContext && currentContext->m_context == priv::GlContext::getActiveContext())
|
||||||
return currentContext;
|
return currentContext;
|
||||||
|
@ -39,10 +39,18 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// We check for this definition in order to avoid multiple definitions of GLAD
|
||||||
|
// entities during unity builds of SFML.
|
||||||
|
#ifndef SF_GLAD_EGL_IMPLEMENTATION_INCLUDED
|
||||||
|
#define SF_GLAD_EGL_IMPLEMENTATION_INCLUDED
|
||||||
#define SF_GLAD_EGL_IMPLEMENTATION
|
#define SF_GLAD_EGL_IMPLEMENTATION
|
||||||
#include <glad/egl.h>
|
#include <glad/egl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
{
|
||||||
|
// A nested named namespace is used here to allow unity builds of SFML.
|
||||||
|
namespace EglContextImpl
|
||||||
{
|
{
|
||||||
EGLDisplay getInitializedDisplay()
|
EGLDisplay getInitializedDisplay()
|
||||||
{
|
{
|
||||||
@ -85,6 +93,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -98,10 +107,10 @@ m_context (EGL_NO_CONTEXT),
|
|||||||
m_surface (EGL_NO_SURFACE),
|
m_surface (EGL_NO_SURFACE),
|
||||||
m_config (NULL)
|
m_config (NULL)
|
||||||
{
|
{
|
||||||
ensureInit();
|
EglContextImpl::ensureInit();
|
||||||
|
|
||||||
// Get the initialized EGL display
|
// Get the initialized EGL display
|
||||||
m_display = getInitializedDisplay();
|
m_display = EglContextImpl::getInitializedDisplay();
|
||||||
|
|
||||||
// Get the best EGL config matching the default video settings
|
// Get the best EGL config matching the default video settings
|
||||||
m_config = getBestConfig(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings());
|
m_config = getBestConfig(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings());
|
||||||
@ -129,7 +138,7 @@ m_context (EGL_NO_CONTEXT),
|
|||||||
m_surface (EGL_NO_SURFACE),
|
m_surface (EGL_NO_SURFACE),
|
||||||
m_config (NULL)
|
m_config (NULL)
|
||||||
{
|
{
|
||||||
ensureInit();
|
EglContextImpl::ensureInit();
|
||||||
|
|
||||||
#ifdef SFML_SYSTEM_ANDROID
|
#ifdef SFML_SYSTEM_ANDROID
|
||||||
|
|
||||||
@ -142,7 +151,7 @@ m_config (NULL)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get the initialized EGL display
|
// Get the initialized EGL display
|
||||||
m_display = getInitializedDisplay();
|
m_display = EglContextImpl::getInitializedDisplay();
|
||||||
|
|
||||||
// Get the best EGL config matching the requested video settings
|
// Get the best EGL config matching the requested video settings
|
||||||
m_config = getBestConfig(m_display, bitsPerPixel, settings);
|
m_config = getBestConfig(m_display, bitsPerPixel, settings);
|
||||||
@ -166,7 +175,7 @@ m_context (EGL_NO_CONTEXT),
|
|||||||
m_surface (EGL_NO_SURFACE),
|
m_surface (EGL_NO_SURFACE),
|
||||||
m_config (NULL)
|
m_config (NULL)
|
||||||
{
|
{
|
||||||
ensureInit();
|
EglContextImpl::ensureInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -202,7 +211,7 @@ EglContext::~EglContext()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlFunctionPointer EglContext::getFunction(const char* name)
|
GlFunctionPointer EglContext::getFunction(const char* name)
|
||||||
{
|
{
|
||||||
ensureInit();
|
EglContextImpl::ensureInit();
|
||||||
|
|
||||||
return reinterpret_cast<GlFunctionPointer>(eglGetProcAddress(name));
|
return reinterpret_cast<GlFunctionPointer>(eglGetProcAddress(name));
|
||||||
}
|
}
|
||||||
@ -288,7 +297,7 @@ void EglContext::destroySurface()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixel, const ContextSettings& settings)
|
EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixel, const ContextSettings& settings)
|
||||||
{
|
{
|
||||||
ensureInit();
|
EglContextImpl::ensureInit();
|
||||||
|
|
||||||
// Set our video settings constraint
|
// Set our video settings constraint
|
||||||
const EGLint attributes[] = {
|
const EGLint attributes[] = {
|
||||||
@ -352,10 +361,10 @@ void EglContext::updateSettings()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsPerPixel, const ContextSettings& settings)
|
XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsPerPixel, const ContextSettings& settings)
|
||||||
{
|
{
|
||||||
ensureInit();
|
EglContextImpl::ensureInit();
|
||||||
|
|
||||||
// Get the initialized EGL display
|
// Get the initialized EGL display
|
||||||
EGLDisplay display = getInitializedDisplay();
|
EGLDisplay display = EglContextImpl::getInitializedDisplay();
|
||||||
|
|
||||||
// Get the best EGL config matching the default video settings
|
// Get the best EGL config matching the default video settings
|
||||||
EGLConfig config = getBestConfig(display, bitsPerPixel, settings);
|
EGLConfig config = getBestConfig(display, bitsPerPixel, settings);
|
||||||
|
@ -148,6 +148,9 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
{
|
||||||
|
// A nested named namespace is used here to allow unity builds of SFML.
|
||||||
|
namespace GlContextImpl
|
||||||
{
|
{
|
||||||
// AMD drivers have issues with internal synchronization
|
// AMD drivers have issues with internal synchronization
|
||||||
// We need to make sure that no operating system context
|
// We need to make sure that no operating system context
|
||||||
@ -303,6 +306,7 @@ namespace
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -312,6 +316,12 @@ namespace priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void GlContext::initResource()
|
void GlContext::initResource()
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::mutex;
|
||||||
|
using GlContextImpl::resourceCount;
|
||||||
|
using GlContextImpl::currentContext;
|
||||||
|
using GlContextImpl::sharedContext;
|
||||||
|
using GlContextImpl::loadExtensions;
|
||||||
|
|
||||||
// Protect from concurrent access
|
// Protect from concurrent access
|
||||||
Lock lock(mutex);
|
Lock lock(mutex);
|
||||||
|
|
||||||
@ -345,6 +355,10 @@ void GlContext::initResource()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void GlContext::cleanupResource()
|
void GlContext::cleanupResource()
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::mutex;
|
||||||
|
using GlContextImpl::resourceCount;
|
||||||
|
using GlContextImpl::sharedContext;
|
||||||
|
|
||||||
// Protect from concurrent access
|
// Protect from concurrent access
|
||||||
Lock lock(mutex);
|
Lock lock(mutex);
|
||||||
|
|
||||||
@ -367,13 +381,17 @@ void GlContext::cleanupResource()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void GlContext::registerContextDestroyCallback(ContextDestroyCallback callback, void* arg)
|
void GlContext::registerContextDestroyCallback(ContextDestroyCallback callback, void* arg)
|
||||||
{
|
{
|
||||||
contextDestroyCallbacks.insert(std::make_pair(callback, arg));
|
GlContextImpl::contextDestroyCallbacks.insert(std::make_pair(callback, arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void GlContext::acquireTransientContext()
|
void GlContext::acquireTransientContext()
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::mutex;
|
||||||
|
using GlContextImpl::TransientContext;
|
||||||
|
using GlContextImpl::transientContext;
|
||||||
|
|
||||||
// Protect from concurrent access
|
// Protect from concurrent access
|
||||||
Lock lock(mutex);
|
Lock lock(mutex);
|
||||||
|
|
||||||
@ -390,6 +408,9 @@ void GlContext::acquireTransientContext()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void GlContext::releaseTransientContext()
|
void GlContext::releaseTransientContext()
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::mutex;
|
||||||
|
using GlContextImpl::transientContext;
|
||||||
|
|
||||||
// Protect from concurrent access
|
// Protect from concurrent access
|
||||||
Lock lock(mutex);
|
Lock lock(mutex);
|
||||||
|
|
||||||
@ -412,6 +433,9 @@ void GlContext::releaseTransientContext()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlContext* GlContext::create()
|
GlContext* GlContext::create()
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::mutex;
|
||||||
|
using GlContextImpl::sharedContext;
|
||||||
|
|
||||||
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
||||||
assert(sharedContext != NULL);
|
assert(sharedContext != NULL);
|
||||||
|
|
||||||
@ -440,6 +464,11 @@ GlContext* GlContext::create()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlContext* GlContext::create(const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel)
|
GlContext* GlContext::create(const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel)
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::mutex;
|
||||||
|
using GlContextImpl::resourceCount;
|
||||||
|
using GlContextImpl::sharedContext;
|
||||||
|
using GlContextImpl::loadExtensions;
|
||||||
|
|
||||||
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
||||||
assert(sharedContext != NULL);
|
assert(sharedContext != NULL);
|
||||||
|
|
||||||
@ -488,6 +517,11 @@ GlContext* GlContext::create(const ContextSettings& settings, const WindowImpl*
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlContext* GlContext::create(const ContextSettings& settings, unsigned int width, unsigned int height)
|
GlContext* GlContext::create(const ContextSettings& settings, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::mutex;
|
||||||
|
using GlContextImpl::resourceCount;
|
||||||
|
using GlContextImpl::sharedContext;
|
||||||
|
using GlContextImpl::loadExtensions;
|
||||||
|
|
||||||
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
||||||
assert(sharedContext != NULL);
|
assert(sharedContext != NULL);
|
||||||
|
|
||||||
@ -536,6 +570,7 @@ GlContext* GlContext::create(const ContextSettings& settings, unsigned int width
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool GlContext::isExtensionAvailable(const char* name)
|
bool GlContext::isExtensionAvailable(const char* name)
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::extensions;
|
||||||
return std::find(extensions.begin(), extensions.end(), name) != extensions.end();
|
return std::find(extensions.begin(), extensions.end(), name) != extensions.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,7 +578,7 @@ bool GlContext::isExtensionAvailable(const char* name)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlFunctionPointer GlContext::getFunction(const char* name)
|
GlFunctionPointer GlContext::getFunction(const char* name)
|
||||||
{
|
{
|
||||||
Lock lock(mutex);
|
Lock lock(GlContextImpl::mutex);
|
||||||
|
|
||||||
return ContextType::getFunction(name);
|
return ContextType::getFunction(name);
|
||||||
}
|
}
|
||||||
@ -552,6 +587,7 @@ GlFunctionPointer GlContext::getFunction(const char* name)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const GlContext* GlContext::getActiveContext()
|
const GlContext* GlContext::getActiveContext()
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::currentContext;
|
||||||
return currentContext;
|
return currentContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,6 +595,7 @@ const GlContext* GlContext::getActiveContext()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Uint64 GlContext::getActiveContextId()
|
Uint64 GlContext::getActiveContextId()
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::currentContext;
|
||||||
return currentContext ? currentContext->m_id : 0;
|
return currentContext ? currentContext->m_id : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,6 +603,9 @@ Uint64 GlContext::getActiveContextId()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlContext::~GlContext()
|
GlContext::~GlContext()
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::currentContext;
|
||||||
|
using GlContextImpl::sharedContext;
|
||||||
|
|
||||||
// Deactivate the context before killing it, unless we're inside Cleanup()
|
// Deactivate the context before killing it, unless we're inside Cleanup()
|
||||||
if (sharedContext)
|
if (sharedContext)
|
||||||
{
|
{
|
||||||
@ -585,6 +625,10 @@ const ContextSettings& GlContext::getSettings() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool GlContext::setActive(bool active)
|
bool GlContext::setActive(bool active)
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::mutex;
|
||||||
|
using GlContextImpl::currentContext;
|
||||||
|
using GlContextImpl::sharedContext;
|
||||||
|
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
if (this != currentContext)
|
if (this != currentContext)
|
||||||
@ -637,7 +681,7 @@ bool GlContext::setActive(bool active)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlContext::GlContext() :
|
GlContext::GlContext() :
|
||||||
m_id(id++)
|
m_id(GlContextImpl::id++)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
@ -675,6 +719,10 @@ int GlContext::evaluateFormat(unsigned int bitsPerPixel, const ContextSettings&
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void GlContext::cleanupUnsharedResources()
|
void GlContext::cleanupUnsharedResources()
|
||||||
{
|
{
|
||||||
|
using GlContextImpl::currentContext;
|
||||||
|
using GlContextImpl::ContextDestroyCallbacks;
|
||||||
|
using GlContextImpl::contextDestroyCallbacks;
|
||||||
|
|
||||||
// Save the current context so we can restore it later
|
// Save the current context so we can restore it later
|
||||||
GlContext* contextToRestore = currentContext;
|
GlContext* contextToRestore = currentContext;
|
||||||
|
|
||||||
@ -742,6 +790,8 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
// OpenGL ES Full profile: The beginning of the returned string is "OpenGL ES major.minor"
|
// OpenGL ES Full profile: The beginning of the returned string is "OpenGL ES major.minor"
|
||||||
// Desktop OpenGL: The beginning of the returned string is "major.minor"
|
// Desktop OpenGL: The beginning of the returned string is "major.minor"
|
||||||
|
|
||||||
|
using GlContextImpl::parseVersionString;
|
||||||
|
|
||||||
if (!parseVersionString(version, "OpenGL ES-CL ", m_settings.majorVersion, m_settings.minorVersion) &&
|
if (!parseVersionString(version, "OpenGL ES-CL ", m_settings.majorVersion, m_settings.minorVersion) &&
|
||||||
!parseVersionString(version, "OpenGL ES-CM ", m_settings.majorVersion, m_settings.minorVersion) &&
|
!parseVersionString(version, "OpenGL ES-CM ", m_settings.majorVersion, m_settings.minorVersion) &&
|
||||||
!parseVersionString(version, "OpenGL ES ", m_settings.majorVersion, m_settings.minorVersion) &&
|
!parseVersionString(version, "OpenGL ES ", m_settings.majorVersion, m_settings.minorVersion) &&
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#define SF_GLAD_GLX_IMPLEMENTATION
|
|
||||||
#include <SFML/Window/Unix/WindowImplX11.hpp> // important to be included first (conflict with None)
|
#include <SFML/Window/Unix/WindowImplX11.hpp> // important to be included first (conflict with None)
|
||||||
#include <SFML/Window/Unix/GlxContext.hpp>
|
#include <SFML/Window/Unix/GlxContext.hpp>
|
||||||
#include <SFML/Window/Unix/Display.hpp>
|
#include <SFML/Window/Unix/Display.hpp>
|
||||||
@ -34,6 +33,14 @@
|
|||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// We check for this definition in order to avoid multiple definitions of GLAD
|
||||||
|
// entities during unity builds of SFML.
|
||||||
|
#ifndef SF_GLAD_GLX_IMPLEMENTATION_INCLUDED
|
||||||
|
#define SF_GLAD_GLX_IMPLEMENTATION_INCLUDED
|
||||||
|
#define SF_GLAD_GLX_IMPLEMENTATION
|
||||||
|
#include <glad/glx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(GLX_DEBUGGING) && defined(SFML_DEBUG)
|
#if !defined(GLX_DEBUGGING) && defined(SFML_DEBUG)
|
||||||
// Enable this to print messages to err() everytime GLX produces errors
|
// Enable this to print messages to err() everytime GLX produces errors
|
||||||
//#define GLX_DEBUGGING
|
//#define GLX_DEBUGGING
|
||||||
|
@ -61,6 +61,9 @@
|
|||||||
// Private data
|
// Private data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
namespace
|
namespace
|
||||||
|
{
|
||||||
|
// A nested named namespace is used here to allow unity builds of SFML.
|
||||||
|
namespace WindowsImplX11Impl
|
||||||
{
|
{
|
||||||
sf::priv::WindowImplX11* fullscreenWindow = NULL;
|
sf::priv::WindowImplX11* fullscreenWindow = NULL;
|
||||||
std::vector<sf::priv::WindowImplX11*> allWindows;
|
std::vector<sf::priv::WindowImplX11*> allWindows;
|
||||||
@ -473,6 +476,7 @@ namespace
|
|||||||
return sf::Keyboard::Unknown;
|
return sf::Keyboard::Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -500,6 +504,8 @@ m_iconPixmap (0),
|
|||||||
m_iconMaskPixmap (0),
|
m_iconMaskPixmap (0),
|
||||||
m_lastInputTime (0)
|
m_lastInputTime (0)
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Open a connection with the X server
|
// Open a connection with the X server
|
||||||
m_display = OpenDisplay();
|
m_display = OpenDisplay();
|
||||||
|
|
||||||
@ -549,6 +555,8 @@ m_iconPixmap (0),
|
|||||||
m_iconMaskPixmap (0),
|
m_iconMaskPixmap (0),
|
||||||
m_lastInputTime (0)
|
m_lastInputTime (0)
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Open a connection with the X server
|
// Open a connection with the X server
|
||||||
m_display = OpenDisplay();
|
m_display = OpenDisplay();
|
||||||
|
|
||||||
@ -755,6 +763,8 @@ m_lastInputTime (0)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplX11::~WindowImplX11()
|
WindowImplX11::~WindowImplX11()
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Cleanup graphical resources
|
// Cleanup graphical resources
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
@ -804,6 +814,8 @@ WindowHandle WindowImplX11::getSystemHandle() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::processEvents()
|
void WindowImplX11::processEvents()
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
|
||||||
// Pick out the events that are interesting for this window
|
// Pick out the events that are interesting for this window
|
||||||
@ -826,6 +838,8 @@ void WindowImplX11::processEvents()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i WindowImplX11::getPosition() const
|
Vector2i WindowImplX11::getPosition() const
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Get absolute position of our window relative to root window. This
|
// Get absolute position of our window relative to root window. This
|
||||||
// takes into account all information that X11 has, including X11
|
// takes into account all information that X11 has, including X11
|
||||||
// border widths and any decorations. It corresponds to where the
|
// border widths and any decorations. It corresponds to where the
|
||||||
@ -1119,6 +1133,8 @@ void WindowImplX11::setMouseCursor(const CursorImpl& cursor)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setMouseCursorGrabbed(bool grabbed)
|
void WindowImplX11::setMouseCursorGrabbed(bool grabbed)
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// This has no effect in fullscreen mode
|
// This has no effect in fullscreen mode
|
||||||
if (m_fullscreen || (m_cursorGrabbed == grabbed))
|
if (m_fullscreen || (m_cursorGrabbed == grabbed))
|
||||||
return;
|
return;
|
||||||
@ -1162,6 +1178,8 @@ void WindowImplX11::setKeyRepeatEnabled(bool enabled)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::requestFocus()
|
void WindowImplX11::requestFocus()
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Focus is only stolen among SFML windows, not between applications
|
// Focus is only stolen among SFML windows, not between applications
|
||||||
// Check the global list of windows to find out whether an SFML window has the focus
|
// Check the global list of windows to find out whether an SFML window has the focus
|
||||||
// Note: can't handle console and other non-SFML windows belonging to the application.
|
// Note: can't handle console and other non-SFML windows belonging to the application.
|
||||||
@ -1226,6 +1244,8 @@ bool WindowImplX11::hasFocus() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::grabFocus()
|
void WindowImplX11::grabFocus()
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
Atom netActiveWindow = None;
|
Atom netActiveWindow = None;
|
||||||
|
|
||||||
if (ewmhSupported())
|
if (ewmhSupported())
|
||||||
@ -1275,6 +1295,8 @@ void WindowImplX11::grabFocus()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setVideoMode(const VideoMode& mode)
|
void WindowImplX11::setVideoMode(const VideoMode& mode)
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Skip mode switching if the new mode is equal to the desktop mode
|
// Skip mode switching if the new mode is equal to the desktop mode
|
||||||
if (mode == VideoMode::getDesktopMode())
|
if (mode == VideoMode::getDesktopMode())
|
||||||
return;
|
return;
|
||||||
@ -1379,6 +1401,8 @@ void WindowImplX11::setVideoMode(const VideoMode& mode)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::resetVideoMode()
|
void WindowImplX11::resetVideoMode()
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
if (fullscreenWindow == this)
|
if (fullscreenWindow == this)
|
||||||
{
|
{
|
||||||
// Try to set old configuration
|
// Try to set old configuration
|
||||||
@ -1441,6 +1465,8 @@ void WindowImplX11::resetVideoMode()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::switchToFullscreen()
|
void WindowImplX11::switchToFullscreen()
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
grabFocus();
|
grabFocus();
|
||||||
|
|
||||||
if (ewmhSupported())
|
if (ewmhSupported())
|
||||||
@ -1497,6 +1523,8 @@ void WindowImplX11::switchToFullscreen()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setProtocols()
|
void WindowImplX11::setProtocols()
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
Atom wmProtocols = getAtom("WM_PROTOCOLS");
|
Atom wmProtocols = getAtom("WM_PROTOCOLS");
|
||||||
Atom wmDeleteWindow = getAtom("WM_DELETE_WINDOW");
|
Atom wmDeleteWindow = getAtom("WM_DELETE_WINDOW");
|
||||||
|
|
||||||
@ -1563,6 +1591,8 @@ void WindowImplX11::setProtocols()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::initialize()
|
void WindowImplX11::initialize()
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Create the input context
|
// Create the input context
|
||||||
m_inputMethod = XOpenIM(m_display, NULL, NULL, NULL);
|
m_inputMethod = XOpenIM(m_display, NULL, NULL, NULL);
|
||||||
|
|
||||||
@ -1676,6 +1706,8 @@ void WindowImplX11::cleanup()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool WindowImplX11::processEvent(XEvent& windowEvent)
|
bool WindowImplX11::processEvent(XEvent& windowEvent)
|
||||||
{
|
{
|
||||||
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// This function implements a workaround to properly discard
|
// This function implements a workaround to properly discard
|
||||||
// repeated key events when necessary. The problem is that the
|
// repeated key events when necessary. The problem is that the
|
||||||
// system's key events policy doesn't match SFML's one: X server will generate
|
// system's key events policy doesn't match SFML's one: X server will generate
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/Win32/VulkanImplWin32.hpp>
|
#include <SFML/Window/Win32/VulkanImplWin32.hpp>
|
||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define VK_USE_PLATFORM_WIN32_KHR
|
#define VK_USE_PLATFORM_WIN32_KHR
|
||||||
#define VK_NO_PROTOTYPES
|
#define VK_NO_PROTOTYPES
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#define SF_GLAD_WGL_IMPLEMENTATION
|
|
||||||
#include <SFML/Window/WindowImpl.hpp> // included first to avoid a warning about macro redefinition
|
#include <SFML/Window/WindowImpl.hpp> // included first to avoid a warning about macro redefinition
|
||||||
#include <SFML/Window/Win32/WglContext.hpp>
|
#include <SFML/Window/Win32/WglContext.hpp>
|
||||||
#include <SFML/System/ThreadLocalPtr.hpp>
|
#include <SFML/System/ThreadLocalPtr.hpp>
|
||||||
@ -35,8 +34,17 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// We check for this definition in order to avoid multiple definitions of GLAD
|
||||||
|
// entities during unity builds of SFML.
|
||||||
|
#ifndef SF_GLAD_WGL_IMPLEMENTATION_INCLUDED
|
||||||
|
#define SF_GLAD_WGL_IMPLEMENTATION_INCLUDED
|
||||||
|
#define SF_GLAD_WGL_IMPLEMENTATION
|
||||||
|
#include <glad/wgl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
{
|
||||||
|
namespace WglContextImpl
|
||||||
{
|
{
|
||||||
// Some drivers are bugged and don't track the current HDC/HGLRC properly
|
// Some drivers are bugged and don't track the current HDC/HGLRC properly
|
||||||
// In order to deactivate successfully, we need to track it ourselves as well
|
// In order to deactivate successfully, we need to track it ourselves as well
|
||||||
@ -70,6 +78,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -101,7 +110,7 @@ m_deviceContext(NULL),
|
|||||||
m_context (NULL),
|
m_context (NULL),
|
||||||
m_ownsWindow (false)
|
m_ownsWindow (false)
|
||||||
{
|
{
|
||||||
ensureInit();
|
WglContextImpl::ensureInit();
|
||||||
|
|
||||||
// TODO: Delegate to the other constructor in C++11
|
// TODO: Delegate to the other constructor in C++11
|
||||||
|
|
||||||
@ -124,7 +133,7 @@ m_deviceContext(NULL),
|
|||||||
m_context (NULL),
|
m_context (NULL),
|
||||||
m_ownsWindow (false)
|
m_ownsWindow (false)
|
||||||
{
|
{
|
||||||
ensureInit();
|
WglContextImpl::ensureInit();
|
||||||
|
|
||||||
// Save the creation settings
|
// Save the creation settings
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
@ -145,7 +154,7 @@ m_deviceContext(NULL),
|
|||||||
m_context (NULL),
|
m_context (NULL),
|
||||||
m_ownsWindow (false)
|
m_ownsWindow (false)
|
||||||
{
|
{
|
||||||
ensureInit();
|
WglContextImpl::ensureInit();
|
||||||
|
|
||||||
// Save the creation settings
|
// Save the creation settings
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
@ -167,10 +176,10 @@ WglContext::~WglContext()
|
|||||||
// Destroy the OpenGL context
|
// Destroy the OpenGL context
|
||||||
if (m_context)
|
if (m_context)
|
||||||
{
|
{
|
||||||
if (currentContext == this)
|
if (WglContextImpl::currentContext == this)
|
||||||
{
|
{
|
||||||
if (wglMakeCurrent(m_deviceContext, NULL) == TRUE)
|
if (wglMakeCurrent(m_deviceContext, NULL) == TRUE)
|
||||||
currentContext = NULL;
|
WglContextImpl::currentContext = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wglDeleteContext(m_context);
|
wglDeleteContext(m_context);
|
||||||
@ -234,7 +243,7 @@ bool WglContext::makeCurrent(bool current)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentContext = (current ? this : NULL);
|
WglContextImpl::currentContext = (current ? this : NULL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -252,7 +261,7 @@ void WglContext::display()
|
|||||||
void WglContext::setVerticalSyncEnabled(bool enabled)
|
void WglContext::setVerticalSyncEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
// Make sure that extensions are initialized
|
// Make sure that extensions are initialized
|
||||||
ensureExtensionsInit(m_deviceContext);
|
WglContextImpl::ensureExtensionsInit(m_deviceContext);
|
||||||
|
|
||||||
if (SF_GLAD_WGL_EXT_swap_control)
|
if (SF_GLAD_WGL_EXT_swap_control)
|
||||||
{
|
{
|
||||||
@ -277,7 +286,7 @@ void WglContext::setVerticalSyncEnabled(bool enabled)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPixel, const ContextSettings& settings, bool pbuffer)
|
int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPixel, const ContextSettings& settings, bool pbuffer)
|
||||||
{
|
{
|
||||||
ensureInit();
|
WglContextImpl::ensureInit();
|
||||||
|
|
||||||
// Let's find a suitable pixel format -- first try with wglChoosePixelFormatARB
|
// Let's find a suitable pixel format -- first try with wglChoosePixelFormatARB
|
||||||
int bestFormat = 0;
|
int bestFormat = 0;
|
||||||
@ -658,7 +667,7 @@ void WglContext::createContext(WglContext* shared)
|
|||||||
static Mutex mutex;
|
static Mutex mutex;
|
||||||
Lock lock(mutex);
|
Lock lock(mutex);
|
||||||
|
|
||||||
if (currentContext == shared)
|
if (WglContextImpl::currentContext == shared)
|
||||||
{
|
{
|
||||||
if (wglMakeCurrent(shared->m_deviceContext, NULL) == FALSE)
|
if (wglMakeCurrent(shared->m_deviceContext, NULL) == FALSE)
|
||||||
{
|
{
|
||||||
@ -666,7 +675,7 @@ void WglContext::createContext(WglContext* shared)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentContext = NULL;
|
WglContextImpl::currentContext = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,7 +737,7 @@ void WglContext::createContext(WglContext* shared)
|
|||||||
static Mutex mutex;
|
static Mutex mutex;
|
||||||
Lock lock(mutex);
|
Lock lock(mutex);
|
||||||
|
|
||||||
if (currentContext == shared)
|
if (WglContextImpl::currentContext == shared)
|
||||||
{
|
{
|
||||||
if (wglMakeCurrent(shared->m_deviceContext, NULL) == FALSE)
|
if (wglMakeCurrent(shared->m_deviceContext, NULL) == FALSE)
|
||||||
{
|
{
|
||||||
@ -736,7 +745,7 @@ void WglContext::createContext(WglContext* shared)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentContext = NULL;
|
WglContextImpl::currentContext = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wglShareLists(sharedContext, m_context) == FALSE)
|
if (wglShareLists(sharedContext, m_context) == FALSE)
|
||||||
@ -749,7 +758,7 @@ void WglContext::createContext(WglContext* shared)
|
|||||||
if (!shared && m_context)
|
if (!shared && m_context)
|
||||||
{
|
{
|
||||||
makeCurrent(true);
|
makeCurrent(true);
|
||||||
ensureExtensionsInit(m_deviceContext);
|
WglContextImpl::ensureExtensionsInit(m_deviceContext);
|
||||||
makeCurrent(false);
|
makeCurrent(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
#ifdef _WIN32_WINNT
|
#ifdef _WIN32_WINNT
|
||||||
#undef _WIN32_WINNT
|
#undef _WIN32_WINNT
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef WINVER
|
||||||
|
#undef WINVER
|
||||||
|
#endif
|
||||||
#define _WIN32_WINDOWS 0x0501
|
#define _WIN32_WINDOWS 0x0501
|
||||||
#define _WIN32_WINNT 0x0501
|
#define _WIN32_WINNT 0x0501
|
||||||
#define WINVER 0x0501
|
#define WINVER 0x0501
|
||||||
|
@ -32,9 +32,13 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
{
|
||||||
|
// A nested named namespace is used here to allow unity builds of SFML.
|
||||||
|
namespace WindowsBaseImpl
|
||||||
{
|
{
|
||||||
const sf::WindowBase* fullscreenWindow = NULL;
|
const sf::WindowBase* fullscreenWindow = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -366,14 +370,14 @@ void WindowBase::initialize()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const WindowBase* WindowBase::getFullscreenWindow()
|
const WindowBase* WindowBase::getFullscreenWindow()
|
||||||
{
|
{
|
||||||
return fullscreenWindow;
|
return WindowsBaseImpl::fullscreenWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowBase::setFullscreenWindow(const WindowBase* window)
|
void WindowBase::setFullscreenWindow(const WindowBase* window)
|
||||||
{
|
{
|
||||||
fullscreenWindow = window;
|
WindowsBaseImpl::fullscreenWindow = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user