mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Added the context version to ContextSettings
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1261 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
9db63151e1
commit
8e4c61dd19
3
CSFML/doc/build/Doxygen.hpp
vendored
3
CSFML/doc/build/Doxygen.hpp
vendored
@ -18,7 +18,6 @@
|
||||
///
|
||||
/// int main()
|
||||
/// {
|
||||
/// sfWindowSettings settings = {24, 8, 0};
|
||||
/// sfVideoMode mode = {800, 600, 32};
|
||||
/// sfRenderWindow* window;
|
||||
/// sfImage* image;
|
||||
@ -29,7 +28,7 @@
|
||||
/// sfEvent event;
|
||||
///
|
||||
/// /* Create the main window */
|
||||
/// window = sfRenderWindow_Create(mode, "SFML window", sfResize | sfClose, settings);
|
||||
/// window = sfRenderWindow_Create(mode, "SFML window", sfResize | sfClose, NULL);
|
||||
/// if (!window)
|
||||
/// return EXIT_FAILURE;
|
||||
///
|
||||
|
@ -44,19 +44,19 @@
|
||||
/// \param mode : Video mode to use
|
||||
/// \param title : Title of the window
|
||||
/// \param style : Window style
|
||||
/// \param settings : Creation settings
|
||||
/// \param settings : Creation settings (pass NULL to use default values)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsigned long style, sfContextSettings settings);
|
||||
CSFML_API sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsigned long style, sfContextSettings* settings);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a renderwindow from an existing control
|
||||
///
|
||||
/// \param handle : Platform-specific handle of the control
|
||||
/// \param settings : Creation settings
|
||||
/// \param settings : Creation settings (pass NULL to use default values)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, sfContextSettings settings);
|
||||
CSFML_API sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, sfContextSettings* settings);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destroy an existing renderwindow
|
||||
|
@ -57,6 +57,8 @@ typedef struct
|
||||
unsigned int DepthBits; ///< Bits of the depth buffer
|
||||
unsigned int StencilBits; ///< Bits of the stencil buffer
|
||||
unsigned int AntialiasingLevel; ///< Level of antialiasing
|
||||
unsigned int MajorVersion; ///< Major number of the context version to create
|
||||
unsigned int MinorVersion; ///< Minor number of the context version to create
|
||||
} sfContextSettings;
|
||||
|
||||
|
||||
@ -66,19 +68,19 @@ typedef struct
|
||||
/// \param mode : Video mode to use
|
||||
/// \param title : Title of the window
|
||||
/// \param style : Window style
|
||||
/// \param settings : Creation settings
|
||||
/// \param settings : Creation settings (pass NULL to use default values)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfWindow* sfWindow_Create(sfVideoMode mode, const char* title, unsigned long style, sfContextSettings settings);
|
||||
CSFML_API sfWindow* sfWindow_Create(sfVideoMode mode, const char* title, unsigned long style, sfContextSettings* settings);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a window from an existing control
|
||||
///
|
||||
/// \param handle : Platform-specific handle of the control
|
||||
/// \param settings : Creation settings
|
||||
/// \param settings : Creation settings (pass NULL to use default values)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfWindow* sfWindow_CreateFromHandle(sfWindowHandle handle, sfContextSettings settings);
|
||||
CSFML_API sfWindow* sfWindow_CreateFromHandle(sfWindowHandle handle, sfContextSettings* settings);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destroy an existing window
|
||||
|
@ -39,15 +39,25 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a new renderwindow
|
||||
////////////////////////////////////////////////////////////
|
||||
sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsigned long style, sfContextSettings params)
|
||||
sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsigned long style, sfContextSettings* settings)
|
||||
{
|
||||
// Convert video mode
|
||||
sf::VideoMode videoMode(mode.Width, mode.Height, mode.BitsPerPixel);
|
||||
|
||||
// Convert context settings
|
||||
sf::ContextSettings params;
|
||||
if (settings)
|
||||
{
|
||||
params.DepthBits = settings->DepthBits;
|
||||
params.StencilBits = settings->StencilBits;
|
||||
params.AntialiasingLevel = settings->AntialiasingLevel;
|
||||
params.MajorVersion = settings->MajorVersion;
|
||||
params.MinorVersion = settings->MinorVersion;
|
||||
}
|
||||
|
||||
// Create the window
|
||||
sfRenderWindow* renderWindow = new sfRenderWindow;
|
||||
sf::ContextSettings settings(params.DepthBits, params.StencilBits, params.AntialiasingLevel);
|
||||
renderWindow->This.Create(videoMode, title, style, settings);
|
||||
renderWindow->This.Create(videoMode, title, style, params);
|
||||
renderWindow->Input.This = &renderWindow->This.GetInput();
|
||||
renderWindow->DefaultView = new sfView(const_cast<sf::View*>(&renderWindow->This.GetDefaultView()));
|
||||
renderWindow->CurrentView = renderWindow->DefaultView;
|
||||
@ -59,11 +69,22 @@ sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsig
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a renderwindow from an existing control
|
||||
////////////////////////////////////////////////////////////
|
||||
sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, sfContextSettings params)
|
||||
sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, sfContextSettings* settings)
|
||||
{
|
||||
// Convert context settings
|
||||
sf::ContextSettings params;
|
||||
if (settings)
|
||||
{
|
||||
params.DepthBits = settings->DepthBits;
|
||||
params.StencilBits = settings->StencilBits;
|
||||
params.AntialiasingLevel = settings->AntialiasingLevel;
|
||||
params.MajorVersion = settings->MajorVersion;
|
||||
params.MinorVersion = settings->MinorVersion;
|
||||
}
|
||||
|
||||
// Create the window
|
||||
sfRenderWindow* renderWindow = new sfRenderWindow;
|
||||
sf::ContextSettings settings(params.DepthBits, params.StencilBits, params.AntialiasingLevel);
|
||||
renderWindow->This.Create(handle, settings);
|
||||
renderWindow->This.Create(handle, params);
|
||||
renderWindow->Input.This = &renderWindow->This.GetInput();
|
||||
renderWindow->DefaultView = new sfView(const_cast<sf::View*>(&renderWindow->This.GetDefaultView()));
|
||||
renderWindow->CurrentView = renderWindow->DefaultView;
|
||||
|
@ -34,14 +34,24 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a new window
|
||||
////////////////////////////////////////////////////////////
|
||||
sfWindow* sfWindow_Create(sfVideoMode mode, const char* title, unsigned long style, sfContextSettings settings)
|
||||
sfWindow* sfWindow_Create(sfVideoMode mode, const char* title, unsigned long style, sfContextSettings* settings)
|
||||
{
|
||||
// Convert video mode
|
||||
sf::VideoMode videoMode(mode.Width, mode.Height, mode.BitsPerPixel);
|
||||
|
||||
// Convert context settings
|
||||
sf::ContextSettings params;
|
||||
if (settings)
|
||||
{
|
||||
params.DepthBits = settings->DepthBits;
|
||||
params.StencilBits = settings->StencilBits;
|
||||
params.AntialiasingLevel = settings->AntialiasingLevel;
|
||||
params.MajorVersion = settings->MajorVersion;
|
||||
params.MinorVersion = settings->MinorVersion;
|
||||
}
|
||||
|
||||
// Create the window
|
||||
sfWindow* window = new sfWindow;
|
||||
sf::ContextSettings params(settings.DepthBits, settings.StencilBits, settings.AntialiasingLevel);
|
||||
window->This.Create(videoMode, title, style, params);
|
||||
window->Input.This = &window->This.GetInput();
|
||||
|
||||
@ -52,10 +62,21 @@ sfWindow* sfWindow_Create(sfVideoMode mode, const char* title, unsigned long sty
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct a window from an existing control
|
||||
////////////////////////////////////////////////////////////
|
||||
sfWindow* sfWindow_CreateFromHandle(sfWindowHandle handle, sfContextSettings settings)
|
||||
sfWindow* sfWindow_CreateFromHandle(sfWindowHandle handle, sfContextSettings* settings)
|
||||
{
|
||||
// Convert context settings
|
||||
sf::ContextSettings params;
|
||||
if (settings)
|
||||
{
|
||||
params.DepthBits = settings->DepthBits;
|
||||
params.StencilBits = settings->StencilBits;
|
||||
params.AntialiasingLevel = settings->AntialiasingLevel;
|
||||
params.MajorVersion = settings->MajorVersion;
|
||||
params.MinorVersion = settings->MinorVersion;
|
||||
}
|
||||
|
||||
// Create the window
|
||||
sfWindow* window = new sfWindow;
|
||||
sf::ContextSettings params(settings.DepthBits, settings.StencilBits, settings.AntialiasingLevel);
|
||||
window->This.Create(handle, params);
|
||||
window->Input.This = &window->This.GetInput();
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -25,7 +25,7 @@ namespace SFML
|
||||
/// <param name="title">Title of the window</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public RenderWindow(VideoMode mode, string title) :
|
||||
this(mode, title, Styles.Resize | Styles.Close, new ContextSettings(24, 8, 0))
|
||||
this(mode, title, Styles.Resize | Styles.Close, new ContextSettings(24, 8))
|
||||
{
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ namespace SFML
|
||||
/// <param name="style">Window style (Resize | Close by default)</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public RenderWindow(VideoMode mode, string title, Styles style) :
|
||||
this(mode, title, style, new ContextSettings(24, 8, 0))
|
||||
this(mode, title, style, new ContextSettings(24, 8))
|
||||
{
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ namespace SFML
|
||||
/// <param name="settings">Creation parameters</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public RenderWindow(VideoMode mode, string title, Styles style, ContextSettings settings) :
|
||||
base(sfRenderWindow_Create(mode, title, style, settings), 0)
|
||||
base(sfRenderWindow_Create(mode, title, style, ref settings), 0)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
@ -64,7 +64,7 @@ namespace SFML
|
||||
/// <param name="handle">Platform-specific handle of the control</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public RenderWindow(IntPtr handle) :
|
||||
this(handle, new ContextSettings(24, 8, 0))
|
||||
this(handle, new ContextSettings(24, 8))
|
||||
{
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ namespace SFML
|
||||
/// <param name="settings">Creation parameters</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public RenderWindow(IntPtr handle, ContextSettings settings) :
|
||||
base(sfRenderWindow_CreateFromHandle(handle, settings), 0)
|
||||
base(sfRenderWindow_CreateFromHandle(handle, ref settings), 0)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
@ -481,10 +481,10 @@ namespace SFML
|
||||
|
||||
#region Imports
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfRenderWindow_Create(VideoMode Mode, string Title, Styles Style, ContextSettings Params);
|
||||
static extern IntPtr sfRenderWindow_Create(VideoMode Mode, string Title, Styles Style, ref ContextSettings Params);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfRenderWindow_CreateFromHandle(IntPtr Handle, ContextSettings Params);
|
||||
static extern IntPtr sfRenderWindow_CreateFromHandle(IntPtr Handle, ref ContextSettings Params);
|
||||
|
||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfRenderWindow_Destroy(IntPtr This);
|
||||
|
@ -33,11 +33,28 @@ namespace SFML
|
||||
/// <param name="stencilBits">Stencil buffer bits</param>
|
||||
/// <param name="antialiasingLevel">Antialiasing level</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public ContextSettings(uint depthBits, uint stencilBits, uint antialiasingLevel)
|
||||
public ContextSettings(uint depthBits, uint stencilBits, uint antialiasingLevel) :
|
||||
this(depthBits, stencilBits, antialiasingLevel, 2, 0)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Construct the settings from depth / stencil bits and antialiasing level
|
||||
/// </summary>
|
||||
/// <param name="depthBits">Depth buffer bits</param>
|
||||
/// <param name="stencilBits">Stencil buffer bits</param>
|
||||
/// <param name="antialiasingLevel">Antialiasing level</param>
|
||||
/// <param name="majorVersion">Major number of the context version</param>
|
||||
/// <param name="minorVersion">Minor number of the context version</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public ContextSettings(uint depthBits, uint stencilBits, uint antialiasingLevel, uint majorVersion, uint minorVersion)
|
||||
{
|
||||
DepthBits = depthBits;
|
||||
StencilBits = stencilBits;
|
||||
AntialiasingLevel = antialiasingLevel;
|
||||
MajorVersion = majorVersion;
|
||||
MinorVersion = minorVersion;
|
||||
}
|
||||
|
||||
/// <summary>Depth buffer bits (0 is disabled)</summary>
|
||||
@ -48,6 +65,12 @@ namespace SFML
|
||||
|
||||
/// <summary>Antialiasing level (0 is disabled)</summary>
|
||||
public uint AntialiasingLevel;
|
||||
|
||||
/// <summary>Major number of the context version</summary>
|
||||
public uint MajorVersion;
|
||||
|
||||
/// <summary>Minor number of the context version</summary>
|
||||
public uint MinorVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace SFML
|
||||
/// <param name="title">Title of the window</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Window(VideoMode mode, string title) :
|
||||
this(mode, title, Styles.Resize | Styles.Close, new ContextSettings(24, 8, 0))
|
||||
this(mode, title, Styles.Resize | Styles.Close, new ContextSettings(24, 8))
|
||||
{
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ namespace SFML
|
||||
/// <param name="style">Window style (Resize | Close by default)</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Window(VideoMode mode, string title, Styles style) :
|
||||
this(mode, title, style, new ContextSettings(24, 8, 0))
|
||||
this(mode, title, style, new ContextSettings(24, 8))
|
||||
{
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ namespace SFML
|
||||
/// <param name="settings">Creation parameters</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Window(VideoMode mode, string title, Styles style, ContextSettings settings) :
|
||||
base(sfWindow_Create(mode, title, style, settings))
|
||||
base(sfWindow_Create(mode, title, style, ref settings))
|
||||
{
|
||||
myInput = new Input(sfWindow_GetInput(This));
|
||||
}
|
||||
@ -86,7 +86,7 @@ namespace SFML
|
||||
/// <param name="handle">Platform-specific handle of the control</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Window(IntPtr handle) :
|
||||
this(handle, new ContextSettings(24, 8, 0))
|
||||
this(handle, new ContextSettings(24, 8))
|
||||
{
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ namespace SFML
|
||||
/// <param name="settings">Creation parameters</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public Window(IntPtr Handle, ContextSettings settings) :
|
||||
base(sfWindow_CreateFromHandle(Handle, settings))
|
||||
base(sfWindow_CreateFromHandle(Handle, ref settings))
|
||||
{
|
||||
myInput = new Input(sfWindow_GetInput(This));
|
||||
}
|
||||
@ -155,7 +155,7 @@ namespace SFML
|
||||
////////////////////////////////////////////////////////////
|
||||
public virtual uint Width
|
||||
{
|
||||
get { return sfWindow_GetWidth(This); }
|
||||
get {return sfWindow_GetWidth(This);}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -165,7 +165,7 @@ namespace SFML
|
||||
////////////////////////////////////////////////////////////
|
||||
public virtual uint Height
|
||||
{
|
||||
get { return sfWindow_GetHeight(This); }
|
||||
get {return sfWindow_GetHeight(This);}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -175,7 +175,7 @@ namespace SFML
|
||||
////////////////////////////////////////////////////////////
|
||||
public virtual ContextSettings Settings
|
||||
{
|
||||
get { return sfWindow_GetSettings(This); }
|
||||
get {return sfWindow_GetSettings(This);}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -555,10 +555,10 @@ namespace SFML
|
||||
|
||||
#region Imports
|
||||
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfWindow_Create(VideoMode Mode, string Title, Styles Style, ContextSettings Params);
|
||||
static extern IntPtr sfWindow_Create(VideoMode Mode, string Title, Styles Style, ref ContextSettings Params);
|
||||
|
||||
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr sfWindow_CreateFromHandle(IntPtr Handle, ContextSettings Params);
|
||||
static extern IntPtr sfWindow_CreateFromHandle(IntPtr Handle, ref ContextSettings Params);
|
||||
|
||||
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfWindow_Destroy(IntPtr This);
|
||||
|
@ -31,6 +31,7 @@ namespace sf
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Structure defining the settings of the OpenGL
|
||||
/// context attached to a window
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct ContextSettings
|
||||
{
|
||||
@ -40,12 +41,16 @@ struct ContextSettings
|
||||
/// \param depth Depth buffer bits
|
||||
/// \param stencil Stencil buffer bits
|
||||
/// \param antialiasing Antialiasing level
|
||||
/// \param major Major number of the context version
|
||||
/// \param minor Minor number of the context version
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit ContextSettings(unsigned int depth = 24, unsigned int stencil = 8, unsigned int antialiasing = 0) :
|
||||
explicit ContextSettings(unsigned int depth = 24, unsigned int stencil = 8, unsigned int antialiasing = 0, unsigned int major = 2, unsigned int minor = 0) :
|
||||
DepthBits (depth),
|
||||
StencilBits (stencil),
|
||||
AntialiasingLevel(antialiasing)
|
||||
AntialiasingLevel(antialiasing),
|
||||
MajorVersion (major),
|
||||
MinorVersion (minor)
|
||||
{
|
||||
}
|
||||
|
||||
@ -55,9 +60,44 @@ struct ContextSettings
|
||||
unsigned int DepthBits; ///< Bits of the depth buffer
|
||||
unsigned int StencilBits; ///< Bits of the stencil buffer
|
||||
unsigned int AntialiasingLevel; ///< Level of antialiasing
|
||||
unsigned int MajorVersion; ///< Major number of the context version to create
|
||||
unsigned int MinorVersion; ///< Minor number of the context version to create
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_CONTEXTSETTINGS_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::ContextSettings
|
||||
///
|
||||
/// ContextSettings allows to define several advanced settings
|
||||
/// of the OpenGL context attached to a window. All these
|
||||
/// settings have no impact on the regular SFML rendering
|
||||
/// (graphics module), so you may need to use this structure
|
||||
/// only if you're using SFML as a windowing system for
|
||||
/// custom OpenGL rendering.
|
||||
///
|
||||
/// The DepthBits and StencilBits members define the number
|
||||
/// of bits per pixel requested for the (respectively) depth
|
||||
/// and stencil buffers.
|
||||
///
|
||||
/// AntialiasingLevel represents the requested number of
|
||||
/// multisampling levels for anti-aliasing.
|
||||
///
|
||||
/// MajorVersion and MinorVersion define the version of the
|
||||
/// OpenGL context that you want. Only versions greater or
|
||||
/// equal to 3.0 are relevant; versions lesser than 3.0 are
|
||||
/// all handled the same way (i.e. you can use any version
|
||||
/// < 3.0 if you don't want an OpenGL 3 context).
|
||||
///
|
||||
/// Please note that these values are only a hint.
|
||||
/// No failure will be reported if one or more of these values
|
||||
/// are not supported by the system; instead, SFML will try to
|
||||
/// find the closest valid match. You can then retrieve the
|
||||
/// settings that the window actually used to create its context,
|
||||
/// with Window::GetSettings().
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -152,6 +152,8 @@ bool ContextGL::SetReferenceActive()
|
||||
{
|
||||
if (threadContext)
|
||||
return threadContext->SetActive(true);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -246,30 +246,60 @@ void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, co
|
||||
// Get the context to share display lists with
|
||||
GLXContext toShare = shared ? shared->myContext : NULL;
|
||||
|
||||
// Create the context -- first try an OpenGL 3.0 context if it is supported
|
||||
/*const GLubyte* name = reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB");
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(name));
|
||||
if (glXCreateContextAttribsARB)
|
||||
// Create the OpenGL context -- first try an OpenGL 3.0 context if it is requested
|
||||
if (settings.MajorVersion >= 3)
|
||||
{
|
||||
int nbConfigs = 0;
|
||||
GLXFBConfig* configs = glXChooseFBConfig(myDisplay, DefaultScreen(myDisplay), NULL, &nbConfigs);
|
||||
if (!configs || !nbConfigs)
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
|
||||
if (wglCreateContextAttribsARB)
|
||||
{
|
||||
std::cerr << "Failed to retrieve the framebuffer configuration" << std::endl;
|
||||
return;
|
||||
int attributes[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, settings.MajorVersion,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, settings.MinorVersion,
|
||||
0, 0
|
||||
};
|
||||
myContext = wglCreateContextAttribsARB(myDeviceContext, sharedContext, attributes);
|
||||
}
|
||||
|
||||
// Create the context
|
||||
int attributes[] =
|
||||
// If we couldn't create an OpenGL 3 context, adjust the settings
|
||||
if (!myContext)
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
0, 0
|
||||
};
|
||||
myContext = glXCreateContextAttribsARB(myDisplay, configs[0], toShare, true, attributes);
|
||||
}*/
|
||||
mySettings.MajorVersion = 2;
|
||||
mySettings.MinorVersion = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If the OpenGL 3.0 context failed, create a regular OpenGL 1.x context
|
||||
// Create the OpenGL context -- first try an OpenGL 3.0 context if it is requested
|
||||
if (settings.MajorVersion >= 3)
|
||||
{
|
||||
const GLubyte* name = reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB");
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(name));
|
||||
if (glXCreateContextAttribsARB)
|
||||
{
|
||||
int nbConfigs = 0;
|
||||
GLXFBConfig* configs = glXChooseFBConfig(myDisplay, DefaultScreen(myDisplay), NULL, &nbConfigs);
|
||||
if (configs && nbConfigs)
|
||||
{
|
||||
// Create the context
|
||||
int attributes[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, settings.MajorVersion,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, settings.MinorVersion,
|
||||
0, 0
|
||||
};
|
||||
myContext = glXCreateContextAttribsARB(myDisplay, configs[0], toShare, true, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
// If we couldn't create an OpenGL 3 context, adjust the settings
|
||||
if (!myContext)
|
||||
{
|
||||
mySettings.MajorVersion = 2;
|
||||
mySettings.MinorVersion = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If the OpenGL 3.0 context failed or if we don't want one, create a regular OpenGL 1.x/2.x context
|
||||
if (!myContext)
|
||||
{
|
||||
myContext = glXCreateContext(myDisplay, bestVisual, toShare, true);
|
||||
|
@ -261,20 +261,30 @@ void ContextWGL::CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, co
|
||||
// Get the context to share display lists with
|
||||
HGLRC sharedContext = shared ? shared->myContext : NULL;
|
||||
|
||||
// Create the OpenGL context -- first try an OpenGL 3.0 context if it is supported
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
|
||||
if (wglCreateContextAttribsARB)
|
||||
// Create the OpenGL context -- first try an OpenGL 3.0 context if it is requested
|
||||
if (settings.MajorVersion >= 3)
|
||||
{
|
||||
int attributes[] =
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
|
||||
if (wglCreateContextAttribsARB)
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
0, 0
|
||||
};
|
||||
myContext = wglCreateContextAttribsARB(myDeviceContext, sharedContext, attributes);
|
||||
int attributes[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, settings.MajorVersion,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, settings.MinorVersion,
|
||||
0, 0
|
||||
};
|
||||
myContext = wglCreateContextAttribsARB(myDeviceContext, sharedContext, attributes);
|
||||
}
|
||||
|
||||
// If we couldn't create an OpenGL 3 context, adjust the settings
|
||||
if (!myContext)
|
||||
{
|
||||
mySettings.MajorVersion = 2;
|
||||
mySettings.MinorVersion = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If the OpenGL 3.0 context failed, create a regular OpenGL 1.x context
|
||||
// If the OpenGL 3.0 context failed or if we don't want one, create a regular OpenGL 1.x/2.x context
|
||||
if (!myContext)
|
||||
{
|
||||
myContext = wglCreateContext(myDeviceContext);
|
||||
|
Loading…
Reference in New Issue
Block a user