Browse Source

Platform: ability to request context version in GlutApplication.

pull/51/head
Vladimír Vondruš 13 years ago
parent
commit
8c39c5f11f
  1. 15
      src/Platform/GlutApplication.cpp
  2. 17
      src/Platform/GlutApplication.h

15
src/Platform/GlutApplication.cpp

@ -24,7 +24,10 @@
#include "GlutApplication.h"
#include <tuple>
#include "Context.h"
#include "Version.h"
#include "Platform/ScreenedApplication.hpp"
@ -75,6 +78,18 @@ bool GlutApplication::tryCreateContext(const Configuration& configuration) {
glutInitDisplayMode(flags);
glutInitWindowSize(configuration.size().x(), configuration.size().y());
/* Set context version, if requested */
if(configuration.version() != Version::None) {
Int major, minor;
std::tie(major, minor) = version(configuration.version());
glutInitContextVersion(major, minor);
#ifndef MAGNUM_TARGET_GLES
if(configuration.version() >= Version::GL310)
glutInitContextProfile(GLUT_CORE_PROFILE);
#endif
}
if(!glutCreateWindow(configuration.title().data())) {
Error() << "Platform::GlutApplication::tryCreateContext(): cannot create context";
return false;

17
src/Platform/GlutApplication.h

@ -290,6 +290,22 @@ class GlutApplication::Configuration {
return *this;
}
/** @brief Context version */
Version version() const { return _version; }
/**
* @brief Set context version
*
* If requesting version greater or equal to OpenGL 3.1, core profile
* is used. The created context will then have any version which is
* backwards-compatible with requested one. Default is
* @ref Version::None, i.e. any provided version is used.
*/
Configuration& setVersion(Version version) {
_version = version;
return *this;
}
/** @brief Sample count */
Int sampleCount() const { return _sampleCount; }
@ -310,6 +326,7 @@ class GlutApplication::Configuration {
std::string _title;
Vector2i _size;
Int _sampleCount;
Version _version;
};
/**

Loading…
Cancel
Save