Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- QImage GLWidget::getImage(void){
- QGLPixelBuffer *buffer = new QGLPixelBuffer(mStartImage.width(),mStartImage.height());
- buffer->makeCurrent();
- initializeGL();
- QImage image = paintGL(buffer);
- glDeleteLists(mIndex, 1);
- buffer->doneCurrent();
- delete(buffer);
- return image;
- }
- void GLWidget::initializeGL(void){
- glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- glEnable(GL_TEXTURE_2D);
- glViewport(0, 0, mWidth, mHeight);
- glMatrixMode(GL_PROJECTION);
- glOrtho(-mHeightHalf*1.77777, mHeightHalf*1.77777, -mHeightHalf, mHeightHalf,
- 500.0, -500.0);
- glMatrixMode(GL_MODELVIEW);
- mIndex = glGenLists(1);
- glNewList(mIndex, GL_COMPILE);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0, 0.0);
- glVertex2f( -mWidthHalf, -mHeightHalf);
- glTexCoord2f(1.0,0.0);
- glVertex2f( mWidthHalf, -mHeightHalf);
- glTexCoord2f(1.0, 1.0);
- glVertex2f( mWidthHalf, mHeightHalf);
- glTexCoord2f(0.0,1.0);
- glVertex2f(-mWidthHalf, mHeightHalf);
- glEnd();
- glEndList();
- }
- QImage GLWidget::paintGL(QGLPixelBuffer *buffer){
- glLoadIdentity();
- glPushMatrix();
- mEndImageTexture = buffer->bindTexture(mEndImage,GL_TEXTURE_2D);
- glCallList(mIndex);
- glPopMatrix();
- glPushMatrix();
- float value = pow(1.6,mFactor-10)+1;
- glScalef(1.0/value, 1.0/value, 1.0/value);
- mStartImageTexture = buffer->bindTexture(mStartImage,GL_TEXTURE_2D);
- glCallList(mIndex);
- glPopMatrix();
- #if 0
- buffer->deleteTexture(mStartImageTexture);
- buffer->deleteTexture(mEndImageTexture);
- #endif
- glFlush();
- QImage image = buffer->toImage();
- return image;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement