mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Adjusted OpenGL and Window example to request a 24-bit instead of a 32-bit depth buffer since it might not be supported on all systems.
This commit is contained in:
parent
1d16748ed7
commit
97bdf72ce1
@ -14,9 +14,9 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
int main()
|
||||
{
|
||||
// Request a 32-bits depth buffer when creating the window
|
||||
// Request a 24-bits depth buffer when creating the window
|
||||
sf::ContextSettings contextSettings;
|
||||
contextSettings.depthBits = 32;
|
||||
contextSettings.depthBits = 24;
|
||||
|
||||
// Create the main window
|
||||
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML graphics with OpenGL", sf::Style::Default, contextSettings);
|
||||
|
@ -13,9 +13,9 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
int main()
|
||||
{
|
||||
// Request a 32-bits depth buffer when creating the window
|
||||
// Request a 24-bits depth buffer when creating the window
|
||||
sf::ContextSettings contextSettings;
|
||||
contextSettings.depthBits = 32;
|
||||
contextSettings.depthBits = 24;
|
||||
|
||||
// Create the main window
|
||||
sf::Window window(sf::VideoMode(640, 480), "SFML window with OpenGL", sf::Style::Default, contextSettings);
|
||||
|
@ -96,6 +96,11 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
// AMD drivers have issues with internal synchronization
|
||||
// We need to make sure that no operating system context
|
||||
// or pixel format operations are performed simultaneously
|
||||
sf::Mutex mutex;
|
||||
|
||||
// This per-thread variable holds the current context for each thread
|
||||
sf::ThreadLocalPtr<sf::priv::GlContext> currentContext(NULL);
|
||||
|
||||
@ -141,6 +146,8 @@ namespace priv
|
||||
////////////////////////////////////////////////////////////
|
||||
void GlContext::globalInit()
|
||||
{
|
||||
Lock lock(mutex);
|
||||
|
||||
// Create the shared context
|
||||
sharedContext = new ContextType(NULL);
|
||||
sharedContext->initialize();
|
||||
@ -155,6 +162,8 @@ void GlContext::globalInit()
|
||||
////////////////////////////////////////////////////////////
|
||||
void GlContext::globalCleanup()
|
||||
{
|
||||
Lock lock(mutex);
|
||||
|
||||
// Destroy the shared context
|
||||
delete sharedContext;
|
||||
sharedContext = NULL;
|
||||
@ -179,6 +188,9 @@ void GlContext::ensureContext()
|
||||
////////////////////////////////////////////////////////////
|
||||
GlContext* GlContext::create()
|
||||
{
|
||||
Lock lock(mutex);
|
||||
|
||||
// Create the context
|
||||
GlContext* context = new ContextType(sharedContext);
|
||||
context->initialize();
|
||||
|
||||
@ -192,6 +204,8 @@ GlContext* GlContext::create(const ContextSettings& settings, const WindowImpl*
|
||||
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
||||
ensureContext();
|
||||
|
||||
Lock lock(mutex);
|
||||
|
||||
// Create the context
|
||||
GlContext* context = new ContextType(sharedContext, settings, owner, bitsPerPixel);
|
||||
context->initialize();
|
||||
@ -207,6 +221,8 @@ GlContext* GlContext::create(const ContextSettings& settings, unsigned int width
|
||||
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
||||
ensureContext();
|
||||
|
||||
Lock lock(mutex);
|
||||
|
||||
// Create the context
|
||||
GlContext* context = new ContextType(sharedContext, settings, width, height);
|
||||
context->initialize();
|
||||
@ -221,6 +237,8 @@ GlFunctionPointer GlContext::getFunction(const char* name)
|
||||
{
|
||||
#if !defined(SFML_OPENGL_ES)
|
||||
|
||||
Lock lock(mutex);
|
||||
|
||||
return ContextType::getFunction(name);
|
||||
|
||||
#else
|
||||
@ -254,6 +272,8 @@ bool GlContext::setActive(bool active)
|
||||
{
|
||||
if (this != currentContext)
|
||||
{
|
||||
Lock lock(mutex);
|
||||
|
||||
// Activate the context
|
||||
if (makeCurrent())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user