Fixed issue 9 (update opengl version of a context on OS X)
This commit is contained in:
parent
becf51572f
commit
6eac4256f3
@ -150,6 +150,13 @@ private:
|
|||||||
unsigned int bitsPerPixel,
|
unsigned int bitsPerPixel,
|
||||||
const ContextSettings& settings);
|
const ContextSettings& settings);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Finish updating our settings
|
||||||
|
/// \note The context must be active in order to get the OpenGL version.
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void UpdateOpenGLVersion();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -60,6 +60,9 @@ SFContext::SFContext(SFContext* shared)
|
|||||||
|
|
||||||
// Activate the context
|
// Activate the context
|
||||||
SetActive(true);
|
SetActive(true);
|
||||||
|
|
||||||
|
// Finish updating settings.
|
||||||
|
UpdateOpenGLVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,9 +82,12 @@ SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
|||||||
|
|
||||||
// Activate the context
|
// Activate the context
|
||||||
SetActive(true);
|
SetActive(true);
|
||||||
|
|
||||||
|
// Finish updating settings.
|
||||||
|
UpdateOpenGLVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
||||||
unsigned int width, unsigned int height)
|
unsigned int width, unsigned int height)
|
||||||
: myView(0), myWindow(0)
|
: myView(0), myWindow(0)
|
||||||
@ -106,8 +112,12 @@ SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
|||||||
|
|
||||||
// Activate the context
|
// Activate the context
|
||||||
SetActive(true);
|
SetActive(true);
|
||||||
}
|
|
||||||
|
|
||||||
|
// Finish updating settings.
|
||||||
|
UpdateOpenGLVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SFContext::~SFContext()
|
SFContext::~SFContext()
|
||||||
{
|
{
|
||||||
@ -121,7 +131,7 @@ SFContext::~SFContext()
|
|||||||
// This is not a real issue : http://stackoverflow.com/questions/3484888/nsautoreleasepool-question
|
// This is not a real issue : http://stackoverflow.com/questions/3484888/nsautoreleasepool-question
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool SFContext::MakeCurrent()
|
bool SFContext::MakeCurrent()
|
||||||
{
|
{
|
||||||
@ -129,14 +139,14 @@ bool SFContext::MakeCurrent()
|
|||||||
return myContext == [NSOpenGLContext currentContext]; // Should be true.
|
return myContext == [NSOpenGLContext currentContext]; // Should be true.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void SFContext::Display()
|
void SFContext::Display()
|
||||||
{
|
{
|
||||||
[myContext flushBuffer];
|
[myContext flushBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void SFContext::EnableVerticalSync(bool enabled)
|
void SFContext::EnableVerticalSync(bool enabled)
|
||||||
{
|
{
|
||||||
@ -150,8 +160,8 @@ void SFContext::EnableVerticalSync(bool enabled)
|
|||||||
[myContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
|
[myContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void SFContext::CreateContext(SFContext* shared,
|
void SFContext::CreateContext(SFContext* shared,
|
||||||
unsigned int bitsPerPixel,
|
unsigned int bitsPerPixel,
|
||||||
const ContextSettings& settings)
|
const ContextSettings& settings)
|
||||||
@ -210,13 +220,38 @@ void SFContext::CreateContext(SFContext* shared,
|
|||||||
// Free up.
|
// Free up.
|
||||||
[pixFmt release];
|
[pixFmt release];
|
||||||
|
|
||||||
#warning update settings with ogl version not yet implemented
|
// Save the settings. (OpenGL version is updated elsewhere.)
|
||||||
|
|
||||||
// Save the creation settings
|
|
||||||
mySettings = settings;
|
mySettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void SFContext::UpdateOpenGLVersion()
|
||||||
|
{
|
||||||
|
// Update the OpenGL version in the settings.
|
||||||
|
// NB : the context muste be active to get its version.
|
||||||
|
|
||||||
|
GLubyte const* versionString = glGetString(GL_VERSION);
|
||||||
|
|
||||||
|
if (versionString == 0) {
|
||||||
|
|
||||||
|
// (Warning) Couldn't get the OpenGL version of the context.
|
||||||
|
// This happens sometimes (but not always) when creating the first
|
||||||
|
// context for no apparent reason.
|
||||||
|
|
||||||
|
// We assume we can get at least a 2.0 valid context.
|
||||||
|
mySettings.MajorVersion = 2;
|
||||||
|
mySettings.MinorVersion = 0;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// versionString looks like "2.1 NVIDIA-1.6.26".
|
||||||
|
mySettings.MajorVersion = versionString[0];
|
||||||
|
mySettings.MinorVersion = versionString[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user