Small OpenGL fixes

This commit is contained in:
2018-04-04 11:41:06 +02:00
parent d578a60a0c
commit 9030841910
3 changed files with 31 additions and 18 deletions

View File

@@ -22,6 +22,7 @@ unix {
win32 {
DEFINES += _USE_MATH_DEFINES
CONFIG += console
}
INCLUDEPATH += \

View File

@@ -104,14 +104,14 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) {
auto format = QSurfaceFormat();
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setVersion(3, 4);
//format.setSamples(2);
auto ver = format.version();
std::cout << ver.first << " " << ver.second << std::endl;
format.setSamples(2);
format.setProfile(QSurfaceFormat::CompatibilityProfile);
format.setOption(QSurfaceFormat::DebugContext);
setFormat(format);
auto ver = format.version();
std::cout << "OpenGL Context Version: " << ver.first << "." << ver.second << std::endl;
}
@@ -122,6 +122,31 @@ void MapView3D::initializeGL() {
QOpenGLWidget::initializeGL();
initializeOpenGLFunctions();
logger = new QOpenGLDebugLogger(this);
if (logger->initialize()) {
connect(logger, &QOpenGLDebugLogger::messageLogged, [] (const QOpenGLDebugMessage& debugMessage) {
std::cout << debugMessage.message().toStdString() << std::endl;
});
logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
}
// Print device info
const GLubyte* vendor = glGetString(GL_VENDOR);
const GLubyte* renderer = glGetString(GL_RENDERER);
const GLubyte* version = glGetString(GL_VERSION);
std::cout << "Device info: ";
if (vendor) {
std::cout << (const char*) vendor << " ";
}
if (renderer) {
std::cout << (const char*) renderer << " ";
}
if (version) {
std::cout << (const char*) version << " ";
}
std::cout << std::endl;
// this should be the default!!
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
@@ -130,18 +155,6 @@ void MapView3D::initializeGL() {
// additional settings
glEnable(GL_DEPTH_TEST);
glClearColor(0.5, 0.5, 0.5, 1.0);
//QOpenGLContext* ctx = QOpenGLContext::currentContext();
logger = new QOpenGLDebugLogger(this);
if (logger->initialize()) {
connect(logger, &QOpenGLDebugLogger::messageLogged, [] (const QOpenGLDebugMessage& debugMessage) {
std::cout << debugMessage.message().toStdString() << std::endl;
});
logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
}
}
void MapView3D::paintGL() {

View File

@@ -79,7 +79,6 @@ int Shader::getUniform(const char* name) {
return loc;
}
int Shader::getAttribute(const char* name) {
vao.bind();
int loc = attributeLocation(name);
if (loc == -1) {throw std::runtime_error("error");}
return loc;