fix rendering glitches
This commit is contained in:
parent
0a6b133c19
commit
14b5993f0f
5663
mdl/sphere.obj
5663
mdl/sphere.obj
File diff suppressed because it is too large
Load Diff
@ -77,11 +77,11 @@ void MainWindow::open(const QString &path) {
|
||||
connect(slider, &QSlider::sliderReleased, dc, &DroneController::resume);
|
||||
connect(slider, &QSlider::valueChanged, dc, &DroneController::seek);
|
||||
connect(dc, &DroneController::frameChanged, slider, &QSlider::setValue);
|
||||
connect(settings_pane, &SettingsPane::collisionClicked,
|
||||
slider, &QSlider::setValue);
|
||||
slider->setEnabled(true);
|
||||
|
||||
// Settings pane
|
||||
connect(settings_pane, &SettingsPane::collisionClicked,
|
||||
slider, &QSlider::setValue);
|
||||
connect(dc, &DroneController::collision, settings_pane, &SettingsPane::addCollision);
|
||||
connect(settings_pane, &SettingsPane::sphereRadiusChanged,
|
||||
[&](double _) { settings_pane->clearCollisions(); });
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QSurfaceFormat>
|
||||
|
||||
|
||||
static void GLAPIENTRY opengl_debug_cb(GLenum source, GLenum type, GLuint id,
|
||||
@ -98,14 +99,15 @@ void OpenGLWidget::loadSkybox() {
|
||||
|
||||
void OpenGLWidget::loadGround() {
|
||||
QOpenGLTexture *ground_tex = new QOpenGLTexture(QImage(":/img/ground.jpg").mirrored());
|
||||
ground_tex->setMagnificationFilter(QOpenGLTexture::LinearMipMapLinear);
|
||||
ground_tex->generateMipMaps();
|
||||
ground_tex->setMagnificationFilter(QOpenGLTexture::Linear);
|
||||
ground_tex->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
|
||||
ground_tex->setWrapMode(QOpenGLTexture::MirroredRepeat);
|
||||
ground = new OpenGLMesh({
|
||||
-1000, 0, -1000, 0, 1000, 0, 0, 0,
|
||||
1000, 0, -1000, 0, 1000, 0, 1000, 0,
|
||||
-1000, 0, 1000, 0, 1000, 0, 0, 1000,
|
||||
1000, 0, -1000, 0, 1000, 0, 1000, 0,
|
||||
-1000, 0, -1000, 0, 1000, 0, 0, 0,
|
||||
1000, 0, -1000, 0, 1000, 0, 1000, 0,
|
||||
-1000, 0, 1000, 0, 1000, 0, 0, 1000,
|
||||
1000, 0, 1000, 0, 1000, 0, 1000, 1000,
|
||||
}, ground_tex, &main_program);
|
||||
@ -113,6 +115,10 @@ void OpenGLWidget::loadGround() {
|
||||
|
||||
|
||||
void OpenGLWidget::initializeGL() {
|
||||
QSurfaceFormat format;
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
format.setDepthBufferSize(24);
|
||||
setFormat(format);
|
||||
initializeOpenGLFunctions();
|
||||
GLint major, minor;
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||
@ -142,8 +148,8 @@ void OpenGLWidget::initializeGL() {
|
||||
loadGround();
|
||||
|
||||
glClearColor(1, 1, 1, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
emit initialized();
|
||||
}
|
||||
@ -156,6 +162,8 @@ void OpenGLWidget::resizeGL(int w, int h) {
|
||||
|
||||
|
||||
void OpenGLWidget::paintGL() {
|
||||
glEnable(GL_CULL_FACE); // shouldn't have to do that each frame, weird
|
||||
glEnable(GL_DEPTH_TEST); //
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
QMatrix4x4 trans;
|
||||
trans.translate(0, 0, -cam_dist);
|
||||
@ -179,18 +187,9 @@ void OpenGLWidget::paintGL() {
|
||||
main_program.setUniformValue("proj", proj);
|
||||
main_program.setUniformValue("view", view);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
ground->draw(this, QMatrix4x4());
|
||||
if (painter) painter->draw(this);
|
||||
// for (const OpenGLMesh &mesh : meshes) {
|
||||
// main_program.setUniformValue("model", mesh.mat);
|
||||
// glBindVertexArray(mesh.vao);
|
||||
// mesh.tex->bind();
|
||||
// glDrawArrays(GL_TRIANGLES, 0, mesh.nverts);
|
||||
// mesh.tex->release();
|
||||
// }
|
||||
main_program.release();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user