dispmap/svpointcloudviewer.cpp

46 lines
1.2 KiB
C++
Raw Normal View History

2014-07-25 11:32:00 +04:00
#include "svpointcloudviewer.h"
2014-07-28 00:04:18 +04:00
#include <QtGui/QOpenGLShaderProgram>
#include <QtGui/QOpenGLContext>
2014-07-25 11:32:00 +04:00
SvPointCloudViewer::SvPointCloudViewer(QQuickItem *parent) :
2014-07-28 00:04:18 +04:00
QQuickPaintedItem(parent)
2014-07-25 11:32:00 +04:00
{
2014-07-28 00:04:18 +04:00
setRenderTarget(QQuickPaintedItem::FramebufferObject);
2014-07-25 11:32:00 +04:00
}
2014-07-28 00:04:18 +04:00
void SvPointCloudViewer::paint(QPainter *painter)
2014-07-25 11:32:00 +04:00
{
2014-07-28 20:25:39 +04:00
if (!m_pointCloud) {
qDebug() << "point cloud not set!";
return;
2014-07-25 11:32:00 +04:00
}
2014-07-28 20:25:39 +04:00
painter->beginNativePainting();
2014-07-28 00:04:18 +04:00
2014-07-28 20:25:39 +04:00
glViewport(0, 0, width(), height());
2014-07-29 17:47:14 +04:00
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
2014-07-28 20:25:39 +04:00
glMatrixMode(GL_MODELVIEW);
2014-07-29 17:47:14 +04:00
//glEnable (GL_BLEND);
//glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2014-07-28 20:25:39 +04:00
glLoadIdentity();
2014-07-29 17:47:14 +04:00
glTranslatef(100.0f, height()-10, -40.0f);
2014-07-28 20:25:39 +04:00
glBegin(GL_POINTS);
for (int y = 0; y < m_pointCloud->getHeight(); y++) {
for (int x = 0; x < m_pointCloud->getWidth(); x++) {
SvPoint *p = m_pointCloud->point(x, y);
if (p) {
2014-07-29 17:47:14 +04:00
glColor3ub(qRed(p->color()), qGreen(p->color()), qBlue(p->color()));
glVertex3i(x, -y, 0);
2014-07-28 20:25:39 +04:00
}
}
}
glEnd();
2014-07-28 00:04:18 +04:00
painter->endNativePainting();
2014-07-25 11:32:00 +04:00
}
2014-07-28 00:04:18 +04:00