Small OpenGL fixes
This commit is contained in:
@@ -22,6 +22,7 @@ unix {
|
|||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
DEFINES += _USE_MATH_DEFINES
|
DEFINES += _USE_MATH_DEFINES
|
||||||
|
CONFIG += console
|
||||||
}
|
}
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
|
|||||||
@@ -104,14 +104,14 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) {
|
|||||||
auto format = QSurfaceFormat();
|
auto format = QSurfaceFormat();
|
||||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||||
format.setVersion(3, 4);
|
format.setVersion(3, 4);
|
||||||
//format.setSamples(2);
|
format.setSamples(2);
|
||||||
auto ver = format.version();
|
|
||||||
|
|
||||||
std::cout << ver.first << " " << ver.second << std::endl;
|
|
||||||
format.setProfile(QSurfaceFormat::CompatibilityProfile);
|
format.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||||
format.setOption(QSurfaceFormat::DebugContext);
|
format.setOption(QSurfaceFormat::DebugContext);
|
||||||
|
|
||||||
setFormat(format);
|
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();
|
QOpenGLWidget::initializeGL();
|
||||||
initializeOpenGLFunctions();
|
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!!
|
// this should be the default!!
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
glFrontFace(GL_CCW);
|
glFrontFace(GL_CCW);
|
||||||
@@ -130,18 +155,6 @@ void MapView3D::initializeGL() {
|
|||||||
// additional settings
|
// additional settings
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glClearColor(0.5, 0.5, 0.5, 1.0);
|
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() {
|
void MapView3D::paintGL() {
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ int Shader::getUniform(const char* name) {
|
|||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
int Shader::getAttribute(const char* name) {
|
int Shader::getAttribute(const char* name) {
|
||||||
vao.bind();
|
|
||||||
int loc = attributeLocation(name);
|
int loc = attributeLocation(name);
|
||||||
if (loc == -1) {throw std::runtime_error("error");}
|
if (loc == -1) {throw std::runtime_error("error");}
|
||||||
return loc;
|
return loc;
|
||||||
|
|||||||
Reference in New Issue
Block a user