Commit c9440d71 authored by Jakob Weiss's avatar Jakob Weiss

OpenGL core context, various fixes

* OpenGL core context is instantiated and enforced, for better forward compat
* Fixed DLL deployment to RelWithDebInfo and MinSizeRel configurations
* Bumped GLEW to 2.0.0
* Fixed wrong shading in various raycasters (normal was wrong sign)

Squashed commit of the following:

commit 21b33709371459552aff972124e9da4ae0077cf4
Author: Jakob Weiss <jakob.weiss@tum.de>
Date:   Mon Feb 6 15:21:12 2017 +0100

    Fixed number of texture unit query

commit 6592f366c7f24822a8681401cf5a415a622e5f6e
Author: Jakob Weiss <jakob.weiss@tum.de>
Date:   Mon Feb 6 14:27:36 2017 +0100

    Fixed core profile requirements

    * now using Framebuffer ARB version instead of EXT
    * fixed extension handling and windows version recognition
    * Removed pixel transfer functions usage and some validity checks for vis pipelines

commit 36c82733434e63309d092bf85f78f471b56bebfb
Author: Jakob Weiss <jakob.weiss@tum.de>
Date:   Mon Feb 6 13:50:08 2017 +0100

    Bumped glew to 2.0.0

commit 4a4a1d51756aad0e19aef9e723e1dfe7d07a797d
Author: Jakob Weiss <jakob.weiss@tum.de>
Date:   Fri Feb 3 16:26:07 2017 +0100

    First Progress - WIP

# Conflicts:
#	ext/cgt/texturemanager.cpp
parent 1699bbaf
......@@ -6,7 +6,7 @@
# win32: GLEW_LIBRARY_DEBUG, GLEW_LIBRARY_RELEASE, GLEW_DLL_DEBUG, GLEW_DLL_RELEASE, GLEW_LICENSE_FILE
IF (WIN32)
SET(GLEW_DIR "${CampvisHome}/ext/glew" CACHE PATH "If glew is not found, set this path")
SET(GLEW_DIR "${CampvisHome}/ext/glew-2.0.0" CACHE PATH "If glew is not found, set this path")
# SET(GLEW_DEFINITIONS "-DGLEW_STATIC")
......@@ -14,15 +14,15 @@ IF (WIN32)
# set debug and release library
IF(CAMPVIS_WIN32)
SET(GLEW_LIBRARY_DEBUG "${GLEW_DIR}/lib/win32/glew32.lib")
SET(GLEW_DLL_DEBUG "${GLEW_DIR}/lib/win32/glew32.dll")
SET(GLEW_LIBRARY_RELEASE "${GLEW_DIR}/lib/win32/glew32.lib")
SET(GLEW_DLL_RELEASE "${GLEW_DIR}/lib/win32/glew32.dll")
SET(GLEW_LIBRARY_DEBUG "${GLEW_DIR}/lib/Release/Win32/glew32.lib")
SET(GLEW_DLL_DEBUG "${GLEW_DIR}/bin/Release/Win32/glew32.dll")
SET(GLEW_LIBRARY_RELEASE "${GLEW_DIR}/lib/Release/Win32/glew32.lib")
SET(GLEW_DLL_RELEASE "${GLEW_DIR}/bin/Release/Win32/glew32.dll")
ELSEIF(CAMPVIS_WIN64)
SET(GLEW_LIBRARY_DEBUG "${GLEW_DIR}/lib/win64/glew32.lib")
SET(GLEW_DLL_DEBUG "${GLEW_DIR}/lib/win64/glew32.dll")
SET(GLEW_LIBRARY_RELEASE "${GLEW_DIR}/lib/win64/glew32.lib")
SET(GLEW_DLL_RELEASE "${GLEW_DIR}/lib/win64/glew32.dll")
SET(GLEW_LIBRARY_DEBUG "${GLEW_DIR}/lib/Release/x64/glew32.lib")
SET(GLEW_DLL_DEBUG "${GLEW_DIR}/bin/Release/x64/glew32.dll")
SET(GLEW_LIBRARY_RELEASE "${GLEW_DIR}/lib/Release/x64/glew32.lib")
SET(GLEW_DLL_RELEASE "${GLEW_DIR}/bin/Release/x64/glew32.dll")
ELSE()
MESSAGE(FATAL_ERROR "Neither CAMPVIS_WIN32 nor CAMPVIS_WIN64 defined!")
ENDIF(CAMPVIS_WIN32)
......@@ -31,7 +31,7 @@ IF (WIN32)
SET(GLEW_LIBRARY debug ${GLEW_LIBRARY_DEBUG} optimized ${GLEW_LIBRARY_RELEASE})
ENDIF(GLEW_LIBRARY_DEBUG AND GLEW_LIBRARY_RELEASE)
SET(GLEW_LICENSE_FILE "${GLEW_DIR}/license.txt")
SET(GLEW_LICENSE_FILE "${GLEW_DIR}/LICENSE.txt")
ELSE (WIN32)
FIND_PATH(
......
......@@ -2,8 +2,8 @@ IF(NOT CommonconfProcessed)
SET(CampvisHome ${CMAKE_CURRENT_SOURCE_DIR})
SET(CampvisBinaryDir ${CMAKE_BINARY_DIR})
MESSAGE(STATUS "TUMVis Source Directory: ${CampvisHome}")
MESSAGE(STATUS "TUMVis Binary Directory: ${CampvisBinaryDir}")
MESSAGE(STATUS "CAMPVis Source Directory: ${CampvisHome}")
MESSAGE(STATUS "CAMPVis Binary Directory: ${CampvisBinaryDir}")
# include macros
INCLUDE(${CampvisHome}/cmake/macros.cmake)
......
......@@ -291,16 +291,18 @@ MACRO(COPY_EXTERNAL_DLLS DebugDLLs ReleaseDLLs failOnError)
ENDFOREACH()
SET(release_dir "${CMAKE_BINARY_DIR}/bin/Release")
SET(minsizerel_dir "${CMAKE_BINARY_DIR}/bin/MinSizeRel")
SET(relwithdebinfo_dir "${CMAKE_BINARY_DIR}/bin/RelWithDebInfo")
IF(NOT EXISTS ${release_dir})
FILE(MAKE_DIRECTORY ${release_dir})
ENDIF()
FOREACH(dllPath ${${ReleaseDLLs}})
IF(EXISTS ${dllPath})
GET_FILENAME_COMPONENT(dllName ${dllPath} NAME)
IF(EXISTS ${release_dir}/${dllName})
FILE(REMOVE ${release_dir}/${dllName})
ENDIF()
FILE(COPY ${dllPath} DESTINATION ${release_dir})
FILE(COPY ${dllPath} DESTINATION ${minsizerel_dir})
FILE(COPY ${dllPath} DESTINATION ${relwithdebinfo_dir})
ELSEIF(${failOnError})
MESSAGE(FATAL_ERROR "Release DLL not found: ${dllPath}")
ELSE()
......
......@@ -99,37 +99,9 @@ namespace campvis {
tempUnit.activate();
_texture->bind();
// map signed integer types from [-1.0:1.0] to [0.0:1.0] in order to avoid clamping of negative values
if (wtp.isInteger() && wtp.isSigned()) {
glPixelTransferf(GL_RED_SCALE, 0.5f);
glPixelTransferf(GL_GREEN_SCALE, 0.5f);
glPixelTransferf(GL_BLUE_SCALE, 0.5f);
glPixelTransferf(GL_ALPHA_SCALE, 0.5f);
glPixelTransferf(GL_RED_BIAS, 0.5f);
glPixelTransferf(GL_GREEN_BIAS, 0.5f);
glPixelTransferf(GL_BLUE_BIAS, 0.5f);
glPixelTransferf(GL_ALPHA_BIAS, 0.5f);
//_mappingInformation.setRealWorldMapping(LinearMapping<float>(.5f, .5f));
}
_texture->uploadTexture(reinterpret_cast<GLubyte*>(wtp._pointer), wtp.getGlFormat(), wtp.getGlDataType());
_texture->setWrapping(cgt::Texture::CLAMP_TO_EDGE);
if (wtp.isInteger() && wtp.isSigned()) {
// restore default
glPixelTransferf(GL_RED_SCALE, 1.0f);
glPixelTransferf(GL_GREEN_SCALE, 1.0f);
glPixelTransferf(GL_BLUE_SCALE, 1.0f);
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
glPixelTransferf(GL_RED_BIAS, 0.0f);
glPixelTransferf(GL_GREEN_BIAS, 0.0f);
glPixelTransferf(GL_BLUE_BIAS, 0.0f);
glPixelTransferf(GL_ALPHA_BIAS, 0.0f);
}
cgt::TextureUnit::setZeroUnit();
LGL_ERROR;
}
......
......@@ -239,20 +239,7 @@ namespace campvis {
cgtAssert(cgt::getGlBool(GL_DEPTH_TEST) == false, "Invalid OpenGL state after processor execution, GL_DEPTH_TEST != false.");
cgtAssert(cgt::getGlBool(GL_SCISSOR_TEST) == false, "Invalid OpenGL state after processor execution, GL_SCISSOR_TEST != false.");
cgtAssert(cgt::getGlInt(GL_CULL_FACE_MODE) == GL_BACK, "Invalid OpenGL state after processor execution, GL_CULL_FACE_MODE != GL_BACk.");
cgtAssert(cgt::getGlInt(GL_DEPTH_FUNC) == GL_LESS, "Invalid OpenGL state after processor execution, GL_DEPTH_FUNC != GL_LESS.");
cgtAssert(cgt::getGlFloat(GL_DEPTH_CLEAR_VALUE) == 1.f, "Invalid OpenGL state after processor execution, GL_DEPTH_CLEAR_VALUE != 1.f.");
cgtAssert(cgt::getGlFloat(GL_RED_SCALE) == 1.f, "Invalid OpenGL state after processor execution, GL_RED_SCALE != 1.f.");
cgtAssert(cgt::getGlFloat(GL_GREEN_SCALE) == 1.f, "Invalid OpenGL state after processor execution, GL_GREEN_SCALE != 1.f.");
cgtAssert(cgt::getGlFloat(GL_BLUE_SCALE) == 1.f, "Invalid OpenGL state after processor execution, GL_BLUE_SCALE != 1.f.");
cgtAssert(cgt::getGlFloat(GL_ALPHA_SCALE) == 1.f, "Invalid OpenGL state after processor execution, GL_ALPHA_SCALE != 1.f.");
cgtAssert(cgt::getGlFloat(GL_RED_BIAS) == 0.f, "Invalid OpenGL state after processor execution, GL_RED_BIAS != 0.f.");
cgtAssert(cgt::getGlFloat(GL_GREEN_BIAS) == 0.f, "Invalid OpenGL state after processor execution, GL_GREEN_BIAS != 0.f.");
cgtAssert(cgt::getGlFloat(GL_BLUE_BIAS) == 0.f, "Invalid OpenGL state after processor execution, GL_BLUE_BIAS != 0.f.");
cgtAssert(cgt::getGlFloat(GL_ALPHA_BIAS) == 0.f, "Invalid OpenGL state after processor execution, GL_ALPHA_BIAS != 0.f.");
#endif
}
......
......@@ -33,14 +33,13 @@
namespace cgt {
GLenum _lGLError(int line, const char* file) {
GLenum err = glGetError();
if (err != GL_NO_ERROR) {
const GLubyte* exp = gluErrorString(err);
GLenum err;
while ((err = glGetError()) != GL_NO_ERROR) {
std::string exp = getErrorString(err);
std::ostringstream tmp1, tmp2, loggerCat;
tmp2 << " File: " << file << "@" << line;
tmp1 << (exp ? (const char*) exp : "unknown");
tmp1 << exp;
loggerCat << "gl-error:" << file << ':' << line;
LogMgr.log(loggerCat.str(), cgt::Error, tmp1.str(), tmp2.str());
......@@ -67,4 +66,28 @@ GLfloat getGlFloat(GLenum param) {
return toReturn;
}
CGT_API const char* getErrorString(GLenum err)
{
switch (err) {
case GL_NO_ERROR:
return "GL_NO_ERROR: No error has been recorded.";
case GL_INVALID_ENUM:
return "GL_INVALID_ENUM: An unacceptable value is specified for an enumerated argument.";
case GL_INVALID_VALUE:
return "GL_INVALID_VALUE: A numeric argument is out of range.";
case GL_INVALID_OPERATION:
return "GL_INVALID_OPERATION: The specified operation is not allowed in the current state.";
case GL_INVALID_FRAMEBUFFER_OPERATION:
return "GL_INVALID_FRAMEBUFFER_OPERATION: The framebuffer object is not complete.";
case GL_OUT_OF_MEMORY:
return "GL_OUT_OF_MEMORY: There is not enough memory left to execute the command.";
case GL_STACK_UNDERFLOW:
return "GL_STACK_UNDERFLOW: An attempt has been made to perform an operation that would cause an internal stack to underflow.";
case GL_STACK_OVERFLOW:
return "GL_STACK_OVERFLOW: An attempt has been made to perform an operation that would cause an internal stack to overflow.";
default:
return "UNKNOWN: An unknown error occurred or the enum is not an error code.";
}
}
} // namespace cgt
......@@ -45,11 +45,18 @@
namespace cgt {
CGT_API GLenum _lGLError(int line, const char* file);
CGT_API GLboolean getGlBool(GLenum param);;
CGT_API GLboolean getGlBool(GLenum param);
CGT_API GLint getGlInt(GLenum param);;
CGT_API GLint getGlInt(GLenum param);
CGT_API GLfloat getGlFloat(GLenum param);
/**
* Maps an GLenum returned by glGetError() to a humanly readable string.
* Essentially, this is a replacement for gluErrorString()
* \param err see https://www.opengl.org/sdk/docs/man/docbook4/xhtml/glGetError.xml
*/
CGT_API const char* getErrorString(GLenum err);
} // namespace cgt
#ifdef CGT_DEBUG
......
......@@ -45,7 +45,7 @@ FramebufferObject::FramebufferObject()
FramebufferObject::~FramebufferObject()
{
glDeleteFramebuffersEXT(1, &id_);
glDeleteFramebuffers(1, &id_);
}
void FramebufferObject::activate()
......@@ -55,13 +55,13 @@ void FramebufferObject::activate()
LWARNING("Binding a new FBO while another FBO is bound. Do you really want to do this?");
#endif
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id_);
glBindFramebuffer(GL_FRAMEBUFFER, id_);
LGL_ERROR;
}
void FramebufferObject::deactivate()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
LGL_ERROR;
}
......@@ -69,16 +69,16 @@ void FramebufferObject::attachTexture(Texture* texture, GLenum attachment, int m
{
switch(texture->getType()) {
case GL_TEXTURE_1D:
glFramebufferTexture1DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_1D, texture->getId(), mipLevel );
glFramebufferTexture1D( GL_FRAMEBUFFER, attachment, GL_TEXTURE_1D, texture->getId(), mipLevel );
break;
case GL_TEXTURE_3D:
glFramebufferTexture3DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_3D, texture->getId(), mipLevel, zSlice );
glFramebufferTexture3D( GL_FRAMEBUFFER, attachment, GL_TEXTURE_3D, texture->getId(), mipLevel, zSlice );
break;
case GL_TEXTURE_2D_ARRAY:
glFramebufferTextureLayerEXT( GL_FRAMEBUFFER_EXT, attachment, texture->getId(), mipLevel, zSlice );
glFramebufferTextureLayer( GL_FRAMEBUFFER, attachment, texture->getId(), mipLevel, zSlice );
break;
default: //GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, texture->getType(), texture->getId(), mipLevel );
glFramebufferTexture2D( GL_FRAMEBUFFER, attachment, texture->getType(), texture->getId(), mipLevel );
break;
}
LGL_ERROR;
......@@ -102,16 +102,16 @@ void FramebufferObject::detachTexture(GLenum attachment) {
if (attachments_[index] != 0) {
switch (attachments_[index]->getType()) {
case GL_TEXTURE_1D:
glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_1D, 0, 0);
glFramebufferTexture1D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_1D, 0, 0);
break;
case GL_TEXTURE_2D_ARRAY:
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment, 0, 0, 0);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER, attachment, 0, 0, 0);
break;
case GL_TEXTURE_3D:
glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_3D, 0, 0, 0);
glFramebufferTexture3D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_3D, 0, 0, 0);
break;
default: // GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, 0, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, 0, 0);
break;
}
attachments_[index] = 0;
......@@ -142,31 +142,31 @@ bool FramebufferObject::isComplete() const
{
bool complete = false;
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
switch(status) {
case GL_FRAMEBUFFER_COMPLETE_EXT:
case GL_FRAMEBUFFER_COMPLETE:
complete = true;
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
LERROR("GL_FRAMEBUFFER_EXT_INCOMPLETE_ATTACHMENT");
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
LERROR("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
LERROR("GL_FRAMEBUFFER_EXT_INCOMPLETE_MISSING_ATTACHMENT");
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
LERROR("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
LERROR("GL_FRAMEBUFFER_EXT_INCOMPLETE_DIMENSIONS");
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
LERROR("GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE");
break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
LERROR("GL_FRAMEBUFFER_EXT_INCOMPLETE_FORMATS");
case GL_FRAMEBUFFER_UNDEFINED:
LERROR("GL_FRAMEBUFFER_UNDEFINED ");
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
LERROR("GL_FRAMEBUFFER_EXT_INCOMPLETE_DRAW_BUFFER");
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
LERROR("GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER");
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
LERROR("GL_FRAMEBUFFER_EXT_INCOMPLETE_READ_BUFFER");
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
LERROR("GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER");
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
LERROR("GL_FRAMEBUFFER_EXT_UNSUPPORTED");
case GL_FRAMEBUFFER_UNSUPPORTED:
LERROR("GL_FRAMEBUFFER_UNSUPPORTED");
break;
default:
LERROR("Unknown error!");
......@@ -180,13 +180,13 @@ bool FramebufferObject::isActive() const {
GLuint FramebufferObject::getActiveObject() {
GLint fbo;
glGetIntegerv (GL_FRAMEBUFFER_BINDING_EXT, &fbo);
glGetIntegerv (GL_FRAMEBUFFER_BINDING, &fbo);
return static_cast<GLuint>(fbo);
}
GLuint FramebufferObject::generateId() {
id_ = 0;
glGenFramebuffersEXT(1, &id_);
glGenFramebuffers(1, &id_);
LGL_ERROR;
return id_;
}
......
......@@ -80,7 +80,7 @@ std::string GpuCapabilities::getVendorAsString() {
}
bool GpuCapabilities::isExtensionSupported(string extension) {
return (glExtensionsString_.find(extension) != string::npos);
return (std::find(glExtensions_.begin(), glExtensions_.end(), extension) != glExtensions_.end());
}
string GpuCapabilities::getGlVersionString() {
......@@ -99,8 +99,8 @@ string GpuCapabilities::getShadingLanguageVersionString() {
return glslVersionString_;
}
string GpuCapabilities::getGlExtensionsString() {
return glExtensionsString_;
const std::vector<string>& GpuCapabilities::getGlExtensions() {
return glExtensions_;
}
bool GpuCapabilities::areShadersSupported() {
......@@ -190,8 +190,13 @@ void GpuCapabilities::logCapabilities(bool extensionsString, bool osString) {
}
LINFO("GPU Vendor: " << glVendorString_ << " (" << getVendorAsString() << ")");
if (extensionsString)
LINFO("OpenGL Extensions: " << glExtensionsString_);
if (extensionsString) {
std::stringstream exts;
for (auto& s : glExtensions_) {
exts << "\t" << s << std::endl;
}
LINFO("OpenGL Extensions: " << std::endl << exts.str());
}
stringstream features;
features << "Texturing: " << (isOpenGlVersionSupported(GlVersion::CGT_GL_VERSION_1_1) ? "yes" : "no");
......@@ -271,7 +276,9 @@ void GpuCapabilities::detectCapabilities() {
glVersionString_ = string(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
glVendorString_ = string(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
glRendererString_ = string(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
glExtensionsString_ = string(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
queryExtensions();
// Prevent segfault
const char* glslVS = reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION));
......@@ -338,14 +345,10 @@ void GpuCapabilities::detectCapabilities() {
max3DTexSize_ = 0;
}
// see http://developer.nvidia.com/object/General_FAQ.html#t6
// for information about texture units
numTextureUnits_ = -1;
if (isExtensionSupported("GL_ARB_fragment_program"))
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, (GLint *) &numTextureUnits_);
if (numTextureUnits_ < 0)
glGetIntegerv(GL_MAX_TEXTURE_UNITS, (GLint *) &numTextureUnits_);
numTextureUnits_ = -1;
if (glVersion_ >= GlVersion::CGT_GL_VERSION_3_0)
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, (GLint *) &numTextureUnits_);
glGetIntegerv(GL_MAX_IMAGE_UNITS, (GLint*)&numImageUnits_);
......@@ -387,6 +390,21 @@ void GpuCapabilities::detectCapabilities() {
}
void GpuCapabilities::queryExtensions()
{
GLint numExtensions;
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
glExtensions_.resize(numExtensions);
for(int i = 0; i < numExtensions; ++i) {
const char* strPtr = reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i));
if (strPtr && strPtr[0] != '\0')
glExtensions_[i] = string(strPtr);
else
break;
}
}
void GpuCapabilities::detectOS() {
osVersion_ = OS_UNKNOWN;
osVersionString_ = "unknown";
......@@ -429,6 +447,18 @@ void GpuCapabilities::detectOS() {
osVersion_ = OS_WIN_7;
oss << "Windows 7";
}
else if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2) {
osVersion_ = OS_WIN_8;
oss << "Windows 8";
}
else if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 3) {
osVersion_ = OS_WIN_8_1;
oss << "Windows 8.1";
}
else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0) {
osVersion_ = OS_WIN_10;
oss << "Windows 10";
}
else {
oss << "unknown Windows version " << osvi.dwMajorVersion << "." << osvi.dwMinorVersion;
}
......
......@@ -30,6 +30,7 @@
#define CGT_GPUCAPABILITIES_H
#include <string>
#include <vector>
#include "cgt/singleton.h"
#include "cgt/cgt_gl.h"
......@@ -170,6 +171,9 @@ public:
OS_WIN_SERVER_2003,
OS_WIN_SERVER_2008,
OS_WIN_7,
OS_WIN_8,
OS_WIN_8_1,
OS_WIN_10,
OS_POSIX ///< For Linux and other POSIX-like OS. Have a look at getOSVersionString for details.
};
......@@ -245,11 +249,11 @@ public:
/**
* Returns the complete OpenGL extensions-string
* retrieved by <tt>glGetString(GL_EXTENSIONS)</tt>.
* retrieved by <tt>glGetStringi(GL_EXTENSIONS)</tt>.
* This strings contains all OpenGL extensions supported
* by this OpenGL implementation, separated by spaces.
* by this OpenGL implementation
*/
std::string getGlExtensionsString();
const std::vector<std::string>& getGlExtensions();
/**
* Returns the complete Shading Language Version string
......@@ -400,6 +404,9 @@ public:
/**
* Get the OS version.
* Note: On windows > 8, still windows 8 will be reported unless the application is
* manifested properly (not easily possible with cmake).
* See https://msdn.microsoft.com/de-de/library/windows/desktop/ms724451 for more info.
*/
OSVersion getOSVersion();
......@@ -416,6 +423,12 @@ protected:
*/
virtual void detectCapabilities();
/**
* Is called by the constructor to query all extensions and
* populate \a glExtensions_
*/
void queryExtensions();
/**
* Is called by the constructor and performs the
* operating system detection. The results
......@@ -433,7 +446,7 @@ private:
GlVersion glVersion_;
std::string glVersionString_;
std::string glExtensionsString_;
std::vector<std::string> glExtensions_;
std::string glVendorString_;
std::string glRendererString_;
std::string glslVersionString_;
......
......@@ -68,7 +68,7 @@ QtCanvas::QtCanvas(const std::string& title,
}
QtCanvas::QtCanvas(QWidget* parent, bool shared, Qt::WindowFlags f, char* /*name*/)
: QGLWidget(0, (shared ? shareWidget_ : 0), f)
: QGLWidget(getQGLFormat(), 0, (shared ? shareWidget_ : 0), f)
{
if (shared && shareWidget_ == 0)
shareWidget_ = this;
......@@ -256,7 +256,7 @@ cgt::Event::Modifier QtCanvas::getModifier(QInputEvent* e) {
}
QGLFormat QtCanvas::getQGLFormat(const Buffers buffers) {
QGLFormat format = QGLFormat();
QGLFormat format = getQGLFormat();
format.setAlpha(buffers & GLCanvas::ALPHA_BUFFER);
format.setDepth(buffers & GLCanvas::DEPTH_BUFFER);
format.setDoubleBuffer(buffers & GLCanvas::DOUBLE_BUFFER);
......@@ -268,6 +268,15 @@ QGLFormat QtCanvas::getQGLFormat(const Buffers buffers) {
return format;
}
QGLFormat QtCanvas::getQGLFormat()
{
QGLFormat format = QGLFormat(QGL::NoDeprecatedFunctions);
format = QGLFormat(QGL::NoDeprecatedFunctions);
format.setProfile(QGLFormat::CoreProfile);
//format.setVersion(3, 3);
return format;
}
KeyEvent::KeyCode QtCanvas::getKey(int key) {
switch(key) {
case Qt::Key_Escape : return cgt::KeyEvent::K_ESCAPE;
......
......@@ -151,6 +151,7 @@ public:
static cgt::Event::Modifier getModifier(QInputEvent* e);
static KeyEvent::KeyCode getKey(int key);
static QGLFormat getQGLFormat(const Buffers buffers);
static QGLFormat getQGLFormat();
signals:
void s_sizeChangedExternally(int w, int h);
......
......@@ -371,52 +371,6 @@ GLenum Texture::calcMatchingPixelDataType(GLint internalFormat) {
}
std::string Texture::calcMatchingWriteFormat(GLint internalFormat) {
//// supports all formats from https://www.opengl.org/sdk/docs/man4/html/glBindImageTexture.xhtml
//switch (internalFormat) {
// case GL_RGBA32F: return "rgba32f";
// case GL_RGBA16F: return "rgba16f";
// case GL_RG32F: return "rg32f";
// case GL_RG16F: return "rg16f";
// case GL_R11F_G11F_B10F: return "r11f_g11f_b10f";
// case GL_R32F: return "r32f";
// case GL_R16F: return "r16f";
// case GL_RGBA32UI: return "rgba32ui";
// case GL_RGBA16UI: return "rgba16ui";
// case GL_RGB10_A2UI: return "rgb10_a2ui";
// case GL_RGBA8UI: return "rgba8ui";
// case GL_RG32UI: return "rg32ui";
// case GL_RG16UI: return "rg16ui";
// case GL_RG8UI: return "rg8ui";
// case GL_R32UI: return "r32ui";
// case GL_R16UI: return "r16ui";
// case GL_R8UI: return "r8ui";
// case GL_RGBA32I: return "rgba32i";
// case GL_RGBA16I: return "rgba16i";
// case GL_RGBA8I: return "rgba8i";
// case GL_RG32I: return "rg32i";
// case GL_RG16I: return "rg16i";
// case GL_RG8I: return "rg8i";
// case GL_R32I: return "r32i";
// case GL_R16I: return "r16i";
// case GL_R8I: return "r8i";
// case GL_RGBA16: return "rgba16";
// case GL_RGB10_A2: return "rgb10_a2";
// case GL_RGBA8: return "rgba8";
// case GL_RG16: return "rg16";
// case GL_RG8: return "rg8";
// case GL_R16: return "r16";
// case GL_R8: return "r8";
// case GL_RGBA16_SNORM: return "rgba16_snorm";
// case GL_RGBA8_SNORM: return "rgba8_snorm";
// case GL_RG16_SNORM: return "rg16_snorm";
// case GL_RG8_SNORM: return "rg8_snorm";
// case GL_R16_SNORM: return "r16_snorm";
// case GL_R8_SNORM: return "r8_snorm";
// default:
// cgtAssert(false, "Unknown internal format, this should not happen!");
// return 0;
//}
auto ft = GLTextureFormatTraits::get(internalFormat);
if (ft.known())
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
** The OpenGL Extension Wrangler Library
** Copyright (C) 2008-2014, Nigel Stewart <nigels[]users sourceforge net>
** Copyright (C) 2008-2015, Nigel Stewart <nigels[]users sourceforge net>
** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
** Copyright (C) 2002, Lev Povalahev
......@@ -392,6 +392,10 @@ typedef Bool ( * PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (GLXContext ctx);
#ifndef GLX_ARB_context_flush_control
#define GLX_ARB_context_flush_control 1
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000
#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#define GLXEW_ARB_context_flush_control GLXEW_GET_VAR(__GLXEW_ARB_context_flush_control)
#endif /* GLX_ARB_context_flush_control */
......@@ -447,8 +451,8 @@ typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBCo
#ifndef GLX_ARB_fbconfig_float
#define GLX_ARB_fbconfig_float 1
#define GLX_RGBA_FLOAT_BIT 0x00000004
#define GLX_RGBA_FLOAT_TYPE 0x20B9
#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004
#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9
#define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float)
......@@ -666,6 +670,17 @@ typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context
#endif /* GLX_EXT_import_context */
/* ---------------------------- GLX_EXT_libglvnd --------------------------- */
#ifndef GLX_EXT_libglvnd
#define GLX_EXT_libglvnd 1
#define GLX_VENDOR_NAMES_EXT 0x20F6
#define GLXEW_EXT_libglvnd GLXEW_GET_VAR(__GLXEW_EXT_libglvnd)
#endif /* GLX_EXT_libglvnd */
/* -------------------------- GLX_EXT_scene_marker ------------------------- */
#ifndef GLX_EXT_scene_marker
......@@ -1011,6 +1026,17 @@ typedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int
#endif /* GLX_NV_present_video */
/* ------------------ GLX_NV_robustness_video_memory_purge ----------------- */
#ifndef GLX_NV_robustness_video_memory_purge
#define GLX_NV_robustness_video_memory_purge 1
#define GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x20F7
#define GLXEW_NV_robustness_video_memory_purge GLXEW_GET_VAR(__GLXEW_NV_robustness_video_memory_purge)
#endif /* GLX_NV_robustness_video_memory_purge */
/* --------------------------- GLX_NV_swap_group --------------------------- */
#ifndef GLX_NV_swap_group
......@@ -1496,13 +1522,8 @@ typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window,
/* ------------------------------------------------------------------------- */
#ifdef GLEW_MX
#define GLXEW_FUN_EXPORT GLEW_FUN_EXPORT
#define GLXEW_VAR_EXPORT
#else
#define GLXEW_FUN_EXPORT GLEW_FUN_EXPORT
#define GLXEW_VAR_EXPORT GLEW_VAR_EXPORT
#endif /* GLEW_MX */
GLXEW_FUN_EXPORT PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay;
......@@ -1654,12 +1675,6 @@ GLXEW_FUN_EXPORT PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN;
GLXEW_FUN_EXPORT PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN;
GLXEW_FUN_EXPORT PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN;
#if defined(GLEW_MX)
struct GLXEWContextStruct
{
#endif /* GLEW_MX */
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_0;
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_1;
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_2;
......@@ -1686,6 +1701,7 @@ GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_create_context_es_profile;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_import_context;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_libglvnd;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_scene_marker;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_stereo_tree;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control;
......@@ -1707,6 +1723,7 @@ GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_delay_before_swap;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_float_buffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_multisample_coverage;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_present_video;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_robustness_video_memory_purge;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_swap_group;