Created
May 17, 2013 04:58
-
-
Save Sushisource/5597016 to your computer and use it in GitHub Desktop.
makeCurrent crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >::data qscopedpointer.h 132 0x60a20bda | |
1 qGetPtrHelper<QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> > > qglobal.h 886 0x60a519ab | |
2 QOpenGLContext::d_func qopenglcontext.h 145 0x60a57503 | |
3 QOpenGLContext::makeCurrent qopenglcontext.cpp 746 0x60a9ded2 | |
4 QGLContext::makeCurrent qgl_qpa.cpp 218 0x64031446 | |
5 QGLWidget::makeCurrent qgl.cpp 3713 0x63fe806d | |
6 VizWidget::paintEvent vizwidget.cpp 83 0x2861b0 | |
7 QWidget::event qwidget.cpp 8029 0x612062cf | |
8 QGLWidget::event qgl_qpa.cpp 366 0x64031c04 | |
9 QApplicationPrivate::notify_helper qapplication.cpp 3442 0x611c120e | |
10 QApplication::notify qapplication.cpp 3407 0x611bf2d5 | |
11 QCoreApplication::notifyInternal qcoreapplication.cpp 871 0x604bddc4 | |
12 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 235 0x605da7c8 | |
13 QWidgetPrivate::drawWidget qwidget.cpp 5129 0x6120bb5e | |
14 QWidgetPrivate::repaint_sys qwidgetbackingstore.cpp 1330 0x611ce52b | |
15 QWidgetPrivate::syncBackingStore qwidget.cpp 1680 0x6120da74 | |
16 QWidgetWindow::handleExposeEvent qwidgetwindow.cpp 654 0x61240091 | |
17 QWidgetWindow::event qwidgetwindow.cpp 204 0x6123eab9 | |
18 QApplicationPrivate::notify_helper qapplication.cpp 3442 0x611c120e | |
19 QApplication::notify qapplication.cpp 2845 0x611bd3d2 | |
... <More> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "vizwidget.h" | |
VizWidget::VizWidget(QWidget *parent) : | |
QGLWidget(parent) | |
{ | |
playbackWidget = NULL; | |
vertShader = "./shaders/basic.vert"; | |
fragShader = "./shaders/basic.frag"; | |
needsResize = false; | |
frameCount = 0; | |
makeCurrent(); | |
glClearColor(0.0, 0.0, 0.0, 0.0); | |
glEnable(GL_DEPTH_TEST); | |
frameCount = 0; | |
// Prepare a complete shader program... | |
if ( !prepareShaders(vertShader, fragShader) ) | |
return; | |
// Bind the shader program so that we can associate variables from | |
// our application to the shaders | |
if ( !shaderProgram.bind() ) | |
{ | |
qWarning() << "Could not bind shader program to context"; | |
return; | |
} | |
// Make the background quad and bind it to the vertex buffer | |
GLfloat vertices[] = {-1, -1, 0, //bottom left corner | |
-1, 1, 0, //top left corner | |
1, 1, 0, //top right corner | |
1, -1, 0}; // bottom right corner | |
vertexBuffer.create(); | |
vertexBuffer.setUsagePattern( QOpenGLBuffer::StaticDraw ); | |
if ( !vertexBuffer.bind() ) | |
{ | |
qWarning() << "Could not bind vertex buffer to the context"; | |
return; | |
} | |
vertexBuffer.allocate(vertices, 3 * 4 * sizeof( float )); | |
shaderProgram.setAttributeBuffer("vertex", GL_FLOAT, 0, 3); | |
shaderProgram.enableAttributeArray("vertex"); | |
// Setup the fft buffer | |
fftBuffer.create(); | |
fftBuffer.bind(shaderProgram.programId(), "fftBlock"); | |
fftBuffer.allocate(FFT_SIZE); | |
} | |
VizWidget::~VizWidget() | |
{ | |
} | |
void VizWidget::setPlayBackPointer(PlaybackWidget *p) | |
{ | |
playbackWidget = p; | |
} | |
void VizWidget::updateShaders() | |
{ | |
shaderProgram.setUniformValue("winSize", winWidth, winHeight); | |
shaderProgram.setUniformValue("time", frameCount); | |
fftBuffer.write(0, &fftData, FFT_SIZE); | |
} | |
void VizWidget::resizeEvent(QResizeEvent *e) | |
{ | |
glViewport(0, 0, (GLint)winWidth, (GLint)winHeight); | |
} | |
void VizWidget::closeEvent(QCloseEvent *evt) | |
{ | |
QGLWidget::closeEvent(evt); | |
} | |
void VizWidget::paintEvent(QPaintEvent *) | |
{ | |
makeCurrent(); | |
// Clear the buffer with the current clearing color | |
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); | |
//Update the fft buffer | |
updateFFT(); | |
updateShaders(); | |
// Draw stuff | |
glDrawArrays(GL_QUADS, 0, 4); | |
parent->swapBuffers(); | |
++frameCount; | |
} | |
void VizWidget::showEvent(QShowEvent *e) | |
{ | |
QGLWidget::showEvent(e); | |
} | |
void VizWidget::hideEvent(QHideEvent *e) | |
{ | |
QGLWidget::hideEvent(e); | |
} | |
bool VizWidget::prepareShaders(const QString &vertShaderPath, const QString &fragShaderPath) | |
{ | |
// First we load and compile the vertex shader... | |
bool result = shaderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex, vertShaderPath); | |
if ( !result ) | |
qWarning() << shaderProgram.log(); | |
// ...now the fragment shader... | |
result = shaderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment, fragShaderPath); | |
if ( !result ) | |
qWarning() << shaderProgram.log(); | |
// ...and finally we link them to resolve any references. | |
result = shaderProgram.link(); | |
if ( !result ) | |
qWarning() << "Could not link shader program:" << shaderProgram.log(); | |
return result; | |
} | |
void VizWidget::updateFFT() | |
{ | |
if(playbackWidget != NULL) | |
playbackWidget->getFFT(&fftData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment