fixed openGL issues
This commit is contained in:
@@ -102,17 +102,16 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) {
|
|||||||
grabGesture(Qt::PinchGesture);
|
grabGesture(Qt::PinchGesture);
|
||||||
|
|
||||||
auto format = QSurfaceFormat();
|
auto format = QSurfaceFormat();
|
||||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||||
format.setVersion(3, 0);
|
format.setVersion(3, 4);
|
||||||
//format.setSamples(2);
|
//format.setSamples(2);
|
||||||
auto ver = format.version();
|
auto ver = format.version();
|
||||||
|
|
||||||
std::cout << ver.first << " " << ver.second << std::endl;
|
std::cout << ver.first << " " << ver.second << std::endl;
|
||||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
format.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||||
format.setOption(QSurfaceFormat::DebugContext);
|
format.setOption(QSurfaceFormat::DebugContext);
|
||||||
|
|
||||||
setFormat(format);
|
setFormat(format);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -131,6 +130,18 @@ 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() {
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ class MapView3D : public QOpenGLWidget, protected QOpenGLFunctions {
|
|||||||
bool usePerspectiveProjection = false;
|
bool usePerspectiveProjection = false;
|
||||||
bool useWireframe = false;
|
bool useWireframe = false;
|
||||||
|
|
||||||
|
QOpenGLDebugLogger* logger = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MapView3D(QWidget* parent = 0);
|
MapView3D(QWidget* parent = 0);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ Shader::Shader() {
|
|||||||
|
|
||||||
|
|
||||||
void Shader::setModelMatrix(const QMatrix4x4& m) {
|
void Shader::setModelMatrix(const QMatrix4x4& m) {
|
||||||
|
//vao.bind();;
|
||||||
setUniformValue(getUniform("M"), m);
|
setUniformValue(getUniform("M"), m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,6 +79,7 @@ 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