Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: texture mapping just draw nothing

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2011
    Posts
    5

    texture mapping just draw nothing

    Hi,

    recently, I was learning the raycast algorithm. And use the caculated 2Dtexture to draw the image, it draw nothing.

    Here is the code:
    // copy from pbo to texture
    glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
    glBindTexture( GL_TEXTURE_2D, tex );
    glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, 0 );
    glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );

    // draw textured quad
    glEnable(GL_TEXTURE_2D);
    glBegin(GL_QUADS);
    glTexCoord2f(1, 1); glVertex2f(0.25, 0);
    glTexCoord2f(0, 1); glVertex2f(0.75, 0);
    glTexCoord2f(0, 0); glVertex2f(0.75, 0.75);
    glTexCoord2f(1, 0); glVertex2f(0.25, 0.75);
    glEnd();

    Then I replaced the pbo with a 2D array, it works. I don't know why?

    glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, checkImage);

    Any idea please?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: texture mapping just draw nothing

    Did you set the min/mag filters prior to using the texture? It doesn't matter from where you source your data. You'll always have to setup the corresponding texture object correctly.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2011
    Posts
    5

    Re: texture mapping just draw nothing

    ok!
    I fixed the problem. my mistake was I set the wrong parameter for glTranslatef(). The object was out of view.

    Thank you for your help!

Posting Permissions

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