mirror of
https://github.com/SFML/SFML.git
synced 2025-02-18 06:18:01 +08:00
Activated OpenGL 3 contexts on Linux
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1210 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
9944cdcbba
commit
a6e353f11b
@ -43,9 +43,9 @@ ContextGLX::ContextGLX(ContextGLX* shared) :
|
|||||||
myWindow (0),
|
myWindow (0),
|
||||||
myContext (NULL),
|
myContext (NULL),
|
||||||
myOwnsWindow(true)
|
myOwnsWindow(true)
|
||||||
{
|
{
|
||||||
// Open a connection with the X server
|
// Open a connection with the X server
|
||||||
myDisplay = XOpenDisplay(NULL);
|
myDisplay = XOpenDisplay(NULL);
|
||||||
|
|
||||||
// Create a dummy window (disabled and hidden)
|
// Create a dummy window (disabled and hidden)
|
||||||
int screen = DefaultScreen(myDisplay);
|
int screen = DefaultScreen(myDisplay);
|
||||||
@ -75,9 +75,9 @@ ContextGLX::ContextGLX(ContextGLX* shared, const WindowImpl* owner, unsigned int
|
|||||||
myWindow (0),
|
myWindow (0),
|
||||||
myContext (NULL),
|
myContext (NULL),
|
||||||
myOwnsWindow(false)
|
myOwnsWindow(false)
|
||||||
{
|
{
|
||||||
// Use the same context as the owner window (important!)
|
// Use the same context as the owner window (important!)
|
||||||
myDisplay = static_cast<const WindowImplX11*>(owner)->GetDisplay();
|
myDisplay = static_cast<const WindowImplX11*>(owner)->GetDisplay();
|
||||||
|
|
||||||
// Get the owner window and its device context
|
// Get the owner window and its device context
|
||||||
myWindow = static_cast<Window>(owner->GetHandle());
|
myWindow = static_cast<Window>(owner->GetHandle());
|
||||||
@ -110,12 +110,12 @@ ContextGLX::~ContextGLX()
|
|||||||
{
|
{
|
||||||
XDestroyWindow(myDisplay, myWindow);
|
XDestroyWindow(myDisplay, myWindow);
|
||||||
XFlush(myDisplay);
|
XFlush(myDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the connection with the X server
|
// Close the connection with the X server
|
||||||
if (myOwnsWindow)
|
if (myOwnsWindow)
|
||||||
{
|
{
|
||||||
XCloseDisplay(myDisplay);
|
XCloseDisplay(myDisplay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,18 +275,18 @@ void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, co
|
|||||||
GLXContext toShare = shared ? shared->myContext : NULL;
|
GLXContext toShare = shared ? shared->myContext : NULL;
|
||||||
|
|
||||||
// Create the context -- first try an OpenGL 3.0 context if it is supported
|
// Create the context -- first try an OpenGL 3.0 context if it is supported
|
||||||
/*const GLubyte* name = reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB");
|
const GLubyte* name = reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB");
|
||||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(name));
|
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(name));
|
||||||
if (glXCreateContextAttribsARB)
|
if (glXCreateContextAttribsARB)
|
||||||
{
|
{
|
||||||
int nbConfigs = 0;
|
int nbConfigs = 0;
|
||||||
GLXFBConfig* configs = glXChooseFBConfig(myDisplay, DefaultScreen(myDisplay), NULL, &nbConfigs);
|
GLXFBConfig* configs = glXChooseFBConfig(myDisplay, DefaultScreen(myDisplay), NULL, &nbConfigs);
|
||||||
if (!configs || !nbConfigs)
|
if (!configs || !nbConfigs)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to retrieve the framebuffer configuration" << std::endl;
|
std::cerr << "Failed to retrieve the framebuffer configuration" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
int attributes[] =
|
int attributes[] =
|
||||||
{
|
{
|
||||||
@ -295,17 +295,17 @@ void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, co
|
|||||||
0, 0
|
0, 0
|
||||||
};
|
};
|
||||||
myContext = glXCreateContextAttribsARB(myDisplay, configs[0], toShare, true, attributes);
|
myContext = glXCreateContextAttribsARB(myDisplay, configs[0], toShare, true, attributes);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// If the OpenGL 3.0 context failed, create a regular OpenGL 1.x context
|
// If the OpenGL 3.0 context failed, create a regular OpenGL 1.x context
|
||||||
if (!myContext)
|
if (!myContext)
|
||||||
{
|
{
|
||||||
myContext = glXCreateContext(myDisplay, bestVisual, toShare, true);
|
myContext = glXCreateContext(myDisplay, bestVisual, toShare, true);
|
||||||
if (!myContext)
|
if (!myContext)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to create an OpenGL context for this window" << std::endl;
|
std::cerr << "Failed to create an OpenGL context for this window" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the creation settings from the chosen format
|
// Update the creation settings from the chosen format
|
||||||
|
Loading…
x
Reference in New Issue
Block a user