PDA

View Full Version : Not displayed elements by glDrawElements function in QOpenGLWidget



iMashine
6th July 2017, 04:00
I want to integrate a particle system in my app on QOpenGLWIdget. I have one thing - Magic Particle by Astralax. I integrate functions of this framework in my app, but I don't see anything on the screen. I don't understand what the problem is. I try to change any params of QOpenGLContext, but nothing work. paintDevice->paint() is calling glDrawElements. What could reason of this problem?

You can all code on GitHub (https://github.com/iMashine/MPGLES).

mainwidget.cpp



void MainWidget::initializeGL()
{
makeCurrent();
initializeOpenGLFunctions();
glClearColor(0, 0, 0, 1);

m_paintDevice = new PaintDevice(this->width(), this->height());
timer.start(12, this);
}

void MainWidget::timerEvent(QTimerEvent *e)
{
m_paintDevice->update();
update();
}

void MainWidget::paintGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_paintDevice->paint();
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
}

mp_wrap.cpp



void MP_Device_WRAP::DrawVertices(int starting_index, int indexes_count, int max_vertices)
{
MP_BUFFER_RAM *index_buffer_ram = (MP_BUFFER_RAM *)index_buffer;

#ifdef INDEX_BUFFER_32_WRAP
glDrawElements(GL_TRIANGLES, indexes_count, GL_UNSIGNED_INT, &(index_buffer_ram->buffer[starting_index * 4]));
#else
glDrawElements(GL_TRIANGLES, indexes_count, GL_UNSIGNED_SHORT, &(index_buffer_ram->buffer[starting_index * 2]));
#endif
}