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 4 of 4

Thread: bad behavior of wglReleaseTexImageARB

  1. #1
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    bad behavior of wglReleaseTexImageARB

    I having some difficulties again while working with render to texture. It's hard to explain it cause I tried various things and some of them work, some don't.

    I create a p-buffer, I release it so that I can make it current and make some GL calls but in some circumstances wglReleaseTexImageARB fails.

    myfunction_CreatePbuffer(); //success
    wglMakeCurrent(MainWindowDC, MainWindowGL);
    glBindTexture(GL_TEXTURE_2D, 0);
    wglMakeCurrent(NULL, NULL);
    wglReleaseTexImageARB; //fails

    GetLastError with FormatString says "The procedure could not be found"
    What the hell does that mean???

    Anyway, I made some changed and that part works and it still doesn't make any sense.

    In another part, I want to render to this RTT, so again I call

    wglMakeCurrent(NULL, NULL);
    wglReleaseTexImageARB

    and it fails with the same message.

    so I decieded to remove wglMakeCurrent(NULL, NULL); and now it returns 0 but the error message is "The operation completed successfully"

    and then wglMakeCurrent(TexDC, TexGL);
    returns 1 but nothing seems to be rendered to the texture. It always remains black.

    The only thing that might explain it is that this is a MDI app with a single GL window.

    When I worked with simple window or dialog based window, I had no such problems.

    I must say that wgl functions suck big time.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  2. #2
    Advanced Member Frequent Contributor plasmonster's Avatar
    Join Date
    Mar 2004
    Posts
    750

    Re: bad behavior of wglReleaseTexImageARB

    Why are you fooling with MakeCurrent when you release. As far as I know, you only need to do that before drawing to the texture.

    Basic proceedure:

    ReleaseTexture();
    MakeTextureContextCurrent();
    DrawToTexture();
    MakePreviousContextCurrent();
    ...
    BindTexture();
    DrawWithTexture();

    repeat.

    Your call may fail becuse there is no context for it.

  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: bad behavior of wglReleaseTexImageARB

    Looking at NVidia's render_to_texture from their SDK, I solved it.

    It looks like the problem comes from not having the right texture bound. So I guess you need to make a context current and also call glBindTexture before releasing or binding.

    So you are partly correct.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  4. #4
    Advanced Member Frequent Contributor plasmonster's Avatar
    Join Date
    Mar 2004
    Posts
    750

    Re: bad behavior of wglReleaseTexImageARB

    I assumed that it goes without saying that you need a current context before you make context specific calls.

    edit:
    By the way, i agree with you. It would be nice if some day the whole wgl business went away.

Posting Permissions

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