Results 1 to 2 of 2

Thread: Binding Textures in opengl window

  1. #1
    Join Date
    Sep 2011
    Posts
    27
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Unhappy Binding Textures in opengl window

    Hello,

    I am trying to display an Image in the Opengl window for that I have created the .QRC file and named it as Texture array. And remaining code is as below.

    1st I am trying to precompile the textures:
    I am calling 2 functions from the PaintGL method.
    preCompile_Textures() for setting up a quad for my Imaage dimensions.
    Draw_Textures() for drawing the actual image for given positions

    void GLWidget:aintGL()
    {

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslated(0.0f,0.0f, 0.0f);
    //glScaled(scale,scale,scale);
    glRotated(0.0f, 1.0f, 0.0f, 0.0f);
    glRotated(0.0f, 0.0f, 1.0f, 0.0f);
    glRotated(0.0f, 0.0f, 0.0f, 1.0f);

    // Generate Lists required for Pre-Compilation

    gen_texture= glGenLists( 17);

    // Car Texture - Position will be loaded later
    // Use Length for Width and changes in ConFig file does not modify width
    struct_Dimensions.Init( 200*2.0946, 400*1.10 );
    preCompile_Textures( gen_texture + 0, struct_Dimensions , Textures[0] );



    Draw_Textures(struct_Postions, struct_Rotations, struct_Color,gen_texture + 0);
    }

    And, preCompile_Textures( )

    void GLWidget:reCompile_Textures
    (
    int _iIndex ,
    sDimensions _sDim ,
    GLuint _iPicID
    )
    {
    // Call NewList to compile the data below
    glNewList(_iIndex , GL_COMPILE );

    // Enable certian co-ordinates for Belnd
    glEnable(GL_BLEND);
    glEnable(GL_TEXTURE_2D);

    // Blend along with Alpha Channel Enabled
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    // Bind Texture of the picture with the quad drawn
    glBindTexture(GL_TEXTURE_2D, _iPicID );

    // Begin Drawing the Quad
    glBegin(GL_QUADS);

    glTexCoord2d(0.0,1.0);
    glVertex3f( -_sDim.fWidth/2 , -_sDim.fHeight/2 , 0.0f);

    glTexCoord2d(0.0,0.0);
    glVertex3f( -_sDim.fWidth/2 , +_sDim.fHeight/2 , 0.0f);

    glTexCoord2d(1.0,0.0);
    glVertex3f( +_sDim.fWidth/2 , +_sDim.fHeight/2 , 0.0f);

    glTexCoord2d(1.0,1.0);
    glVertex3f( +_sDim.fWidth/2 , -_sDim.fHeight/2 , 0.0f);

    glEnd();

    // End CallList
    glEndList();
    }

    Draw_Textures:

    void GLWidget::vDrawTex
    (
    sPos _sP ,
    sRot _sRot ,
    sColor _sClr ,
    int _iIndex
    )
    {


    glPushMatrix( );


    glTranslated( _sP.fX , _sP.fY , _sP.fZ );
    glRotatef( _sRot.fAngle , _sRot.fX_R , _sRot.fY_R , _sRot.fZ_R );
    glColor4f( _sClr.fR , _sClr.fG , _sClr.fB , 1.0f );

    // Call the required texture from the list
    glCallList( _iIndex );
    updateGL();
    //Return the Screen back to normal scenario
    glPopMatrix();
    }

    After doing this it compiles well but I cannot see any Image being loaded and sometimes it crashes too.

    Please let me know what went wrong in the above code and also let me know if I can do the same differently using some QT API's.

    Thanks in Advance!

  2. #2
    Join Date
    Sep 2011
    Posts
    27
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Binding Textures in opengl window

    I think I have confused a lot, I dint get any reply,

    Here actually my problem is I need to load some images on to my Opengl Window, I am using Devil IL, ILU and ILUT libraries for doing that stuff. But unfortunately there is an error saying that "ilutGLLoadImage" cannot be resolved.

    Can anyone please help me how to use Devil libraries in QT for acheiving this task?

    Thanks in Advance!

Similar Threads

  1. Tiling with OpenGL and textures
    By soxs060389 in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2009, 21:06
  2. OpenGL Textures + Rotating
    By aleksgidenko in forum Qt Programming
    Replies: 9
    Last Post: 21st August 2009, 16:57
  3. OpenGl textures in Qt
    By Ashitaka in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2006, 15:45
  4. Switching textures in opengl??
    By Randulf in forum Qt Programming
    Replies: 2
    Last Post: 18th September 2006, 17:59
  5. Opengl - Textures - Qt
    By Alex63 in forum Installation and Deployment
    Replies: 1
    Last Post: 29th June 2006, 09:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.