Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MapView constructor:
- MapView::MapView(World* mWorld, QWidget* parent)
- : QOpenGLWidget(parent)
- , world(mWorld)
- , camera(new Camera(this))
- , ...
- {
- setFocusPolicy(Qt::StrongFocus);
- setMouseTracking(true);
- QSurfaceFormat format;
- format.setDepthBufferSize(24);
- format.setMajorVersion(4);
- format.setMinorVersion(3);
- format.setSamples(4);
- format.setProfile(QSurfaceFormat::CoreProfile);
- format.setOption(QSurfaceFormat::DebugContext);
- QSurfaceFormat::setDefaultFormat(format);
- surface = new QOffscreenSurface();
- surface->setFormat(format);
- surface->create();
- qDebug() << "surface validation:" << surface->isValid(); // return true
- // Initialize the camera position and orientation
- camera->setPosition(QVector3D(250.0f, 10.0f, 250.0f));
- camera->setViewCenter(QVector3D(250.0f, 10.0f, 249.0f));
- camera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f));
- // Assign camera to World
- world->setCamera(camera);
- startTimer(16);
- }
- MapView intializeGL:
- void MapView::initializeGL()
- {
- QOpenGLContext* _context = world->getContext();
- qDebug() << _context->makeCurrent(surface); // return true
- qDebug() << _context->isValid() << (QOpenGLContext::currentContext() == _context); // return true true
- initializeOpenGLFunctions(); // its still working? or have I call gl funcs from world?
- // Initialize World
- world->initialize(/*this->context(),*/ size(), worldCoords);
- // Initialize camera shader
- camera->initialize();
- // Enable depth testing
- world->getGLFunctions()->glEnable(GL_DEPTH_TEST);
- world->getGLFunctions()->glEnable(GL_CULL_FACE);
- world->getGLFunctions()->glDepthFunc(GL_LEQUAL); // just testing new depth func
- world->getGLFunctions()->glClearColor(0.65f, 0.77f, 1.0f, 1.0f);
- }
- MapView paintGL: I think there is some problem
- void MapView::paintGL()
- {
- world->getContext()->makeCurrent(surface);
- world->getGLFunctions()->glDrawBuffer(GL_FRONT);
- world->getGLFunctions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- world->draw(...);
- //world->getContext()->swapBuffers(surface); // not working even uncommented
- }
- World initialize:
- void World::initialize(/*QOpenGLContext* context,*/ QSize fboSize, bool** mapCoords)
- {
- GLfuncs = context->versionFunctions<QOpenGLFunctions_4_2_Core>();
- if(!GLfuncs)
- {
- qDebug() << QObject::tr("Requires OpenGL >= 4.2");
- qFatal(QObject::tr("Requires OpenGL >= 4.2").toLatin1().data());
- exit(1);
- }
- GLfuncs->initializeOpenGLFunctions();
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement