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

Thread: Multitexturing problems in pbuffer?

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    2

    Multitexturing problems in pbuffer?

    Hi all,

    Does anyone know if there are any issues when using multitexturing on a pbuffer?

    Right now, I have written a tile engine and using register combiners to create a dynamic lightmap for the scene. I think I have set everything up correctly.

    wglMakeCurrent( hdc_pbuffer, rc_pbuffer );
    // Set up an ortho projection
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity( );
    glPushMatrix( );
    gluOrtho2D( 0, 512, 0, 512 );

    // I have disabled stage 1 and got rid of
    // the texture combiners already to narrow
    // down the problem
    glActiveTextureARB( GL_TEXTURE0_ARB );
    glEnable( GL_TEXTURE_2D );
    glBindTexture( GL_TEXTURE_2D, normalmap );
    glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );

    glActiveTextureARB( GL_TEXTURE1_ARB );
    glDisable( GL_TEXTURE_2D );

    glDisable( GL_BLEND );
    glDisable( GL_LIGHTING );
    glDisable( GL_COLOR_MATERIAL );

    // Draw the texture to the pbuffer
    glColor4f( 1.f, 0.f, 0.f, 1.f );
    glBegin( GL_QUADS );
    glTexCoord2i( 0, 0 );
    glVertex3i( 0, 0, 0 );
    glTexCoord2i( 1, 0 );
    glVertex3i( 100, 0, 0 );
    glTexCoord2i( 1, 1 );
    glVertex3i( 100, 100, 0 );
    glTexCoord2i( 0, 1 );
    glVertex3i( 0, 100, 0 );
    glEnd( );

    glPopMatrix( );

    //glFlush( ); // Makes no difference if used

    wglMakeCurrent( hdc_window, rc_window );

    Now what I do to test is to just draw a textured quad of the pbuffer to screen. This works fine so I won't bother posting the code.

    However, the actual contents of the pbuffer is not what I expected. First of all, the quad I draw in the code above is not textured (it should be because I enabled texturing on stage 0). It IS colored (it should NOT be because I disabled COLOR_MATERIAL). Everything else works fine. It's just the texturing that has me stumped.

    And fyi, the code above definitely works on the screen (i.e., if I comment out 'wglMakeCurrent( hdc_pbuffer, rc_pbuffer )', it will draw directly to the screen - and the texturing works fine like that).

    This leads me to suspect that there is an issue with multitexturing on pbuffers. Another possibility is that I need to set up the pbuffer slightly differently to allow for multitexturing.

    Does anyone have any ideas?

    Thanks,

    Alan

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: Multitexturing problems in pbuffer?

    Which texparameters has your normalmap?Default filtering is mipmapping. If you didn't download mipmaps initializing the texture object the texture is inconsistent and the unit gets disabled. You'll get no texture and the base color takes over.
    Same if you have generated the normalmap in another context and forgot to call wglShareLists to share the texture object IDs.
    Add calls to glGetError to find other problems.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    2

    Re: Multitexturing problems in pbuffer?

    Relic,

    Thanks for your reply. I set the filtering mode to MAX=LINEAR, MIN=NEAREST elsewhere, so there shouldn't be any mipmapping going on.

    As for sharing display lists : I followed samples from the NVidia website. I'm rendering directly to the pbuffer and I don't think they had to share lists in that method - am I correct?

    The confusing thing is why it works perfectly when being drawn to the screen, but texturing just 'turns off' when I render to the pbuffer.

    Thanks for your help. Have any more suggestions?

    Alan

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Oct 2001
    Posts
    612

    Re: Multitexturing problems in pbuffer?

    Sharelists shares both displaylists and Textures.. without that the textures are only in the rendercontext where they are creates.

  5. #5
    Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Karlsruhe, Germany
    Posts
    486

    Re: Multitexturing problems in pbuffer?

    Originally posted by alantangcs:
    Relic,

    Thanks for your reply. I set the filtering mode to MAX=LINEAR, MIN=NEAREST elsewhere, so there shouldn't be any mipmapping going on.
    Filtering modes are per-texture properties, make sure you really set them for that particular texture.

    Regards
    -Lev

  6. #6
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Multitexturing problems in pbuffer?

    I had exactly the same problems (no texture, or ugly artifacts), and it was caused by :

    1) mipmaping so double-check your texparameters for this texture AND this context.

    2) initializing texture on the wrong context.

    You can easily fix those 2 problems by using wglShareLists to share lists and texture objects.

Posting Permissions

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