Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: create texture from PNG raw pixel

  1. #1

    create texture from PNG raw pixel

    I want to create a texture when I receive a byte array. This byte array is converted first to QImage and after I bind it to the texture. When I run the program, it shows it for a second and then it jumps out. Do you know why?

    This is where I receive the byte array:
    Code :
    void GlWidget::pixmapCatchFromForm(QByteArray bytes)
        QImage image((const uchar* )bytes.constData(), glWidth, glHeight, QImage::Format_ARGB32);
        texture = bindTexture(image);
        qDebug() << texture; // returns 1

    and here I render:

    Code :
    void GlWidget::paintGL()
        //! [5]
        QMatrix4x4 mMatrix;
        QMatrix4x4 vMatrix;
        QMatrix4x4 cameraTransformation;
        cameraTransformation.rotate(alpha, 0, 1, 0);
        cameraTransformation.rotate(beta, 1, 0, 0);
        QVector3D cameraPosition = cameraTransformation * QVector3D(0, 0, distance);
        QVector3D cameraUpDirection = cameraTransformation * QVector3D(0, 1, 0);
        vMatrix.lookAt(cameraPosition, QVector3D(0, 0, 0), cameraUpDirection);
        //! [6]
        shaderProgram.setUniformValue("mvpMatrix", pMatrix * vMatrix * mMatrix);
        shaderProgram.setUniformValue("texture", 0);
        glBindTexture(GL_TEXTURE_2D, texture);
        shaderProgram.setAttributeArray("vertex", vertices.constData());
        shaderProgram.setAttributeArray("textureCoordinate", textureCoordinates.constData());
        glDrawArrays(GL_TRIANGLES, 0, vertices.size());
    Last edited by saman_artorious; 09-18-2013 at 06:37 AM.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Does the program exit normally or does it crash? If the latter, have you run it under a debugger to determine where the crash occurs? Do you check for OpenGL errors?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts