fixed openGL issues

This commit is contained in:
k-a-z-u
2018-04-04 11:00:57 +02:00
parent 479f58e7e3
commit d578a60a0c
3 changed files with 19 additions and 4 deletions

View File

@@ -102,17 +102,16 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) {
grabGesture(Qt::PinchGesture);
auto format = QSurfaceFormat();
format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setVersion(3, 0);
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setVersion(3, 4);
//format.setSamples(2);
auto ver = format.version();
std::cout << ver.first << " " << ver.second << std::endl;
format.setProfile(QSurfaceFormat::CoreProfile);
format.setProfile(QSurfaceFormat::CompatibilityProfile);
format.setOption(QSurfaceFormat::DebugContext);
setFormat(format);
}
@@ -131,6 +130,18 @@ 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

@@ -24,6 +24,8 @@ class MapView3D : public QOpenGLWidget, protected QOpenGLFunctions {
bool usePerspectiveProjection = false;
bool useWireframe = false;
QOpenGLDebugLogger* logger = nullptr;
public:
MapView3D(QWidget* parent = 0);

View File

@@ -51,6 +51,7 @@ Shader::Shader() {
void Shader::setModelMatrix(const QMatrix4x4& m) {
//vao.bind();;
setUniformValue(getUniform("M"), m);
}
@@ -78,6 +79,7 @@ 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;