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: loading bitmaps from resources in VC++

  1. #1
    Junior Member Newbie
    Join Date
    May 2004
    Posts
    5

    loading bitmaps from resources in VC++

    I'm trying to load my textures from bitmaps I put in my resources and I'm having trouble. I'm trying the following:

    CBitmap Bitmap;
    LPVOID lpBitmap;
    BITMAP bm;
    DWORD dwBitmapSize;

    Bitmap.LoadBitmap(IDB_SKY);
    Bitmap.SetBitmapDimension(128,128);
    Bitmap.GetObject(sizeof(bm), &bm);
    dwBitmapSize=bm.bmHeight*bm.bmWidthBytes * bm.bmPlanes;
    Bitmap.GetBitmapBits(dwBitmapSize, lpBitmap);

    glGenTextures(1, &m_textures[0]);

    glBindTexture(GL_TEXTURE_2D, m_textures[0]);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_RGB, GL_UNSIGNED_BYTE, lpBitmap);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR_MIPMAP_NEAREST);
    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 128, 128, GL_RGB, GL_UNSIGNED_BYTE, lpBitmap);

    Any tips on what I'm doing wrong?

  2. #2
    Intern Newbie
    Join Date
    May 2001
    Location
    Hungary
    Posts
    36

    Re: loading bitmaps from resources in VC++

    What's the problem exactly? Do you use 24bit BGR bitmap resources?

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,757

    Re: loading bitmaps from resources in VC++

    I'm assuming the bitmap resource's original size is 128 by 128 correct?

  4. #4
    Junior Member Newbie
    Join Date
    May 2004
    Posts
    5

    Re: loading bitmaps from resources in VC++

    Originally posted by DFrey:
    I'm assuming the bitmap resource's original size is 128 by 128 correct?
    Yes the bitmap is 128x128. Actually I removed that function call since it seems unnecessary.

    The problem is that I get an "Unhandled Exception 0xC0000005: Access Violation" on

    glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, lpBitmap);

    The call stack shows:
    NVOGLNT! DrvSetPixelFormat + 468892 bytes

Posting Permissions

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