Results 1 to 4 of 4

Thread: loading bitmaps from resources in VC++

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

    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,12;
    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
    Member Newbie
    Join Date
    May 2001
    Location
    Hungary
    Posts
    30

    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,502

    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
    11

    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

Similar Threads

  1. Loading Bitmaps
    By Mukund in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 04-05-2010, 10:55 AM
  2. loading/displaying bitmaps in dll
    By bheimsoth in forum OpenGL: Windows
    Replies: 0
    Last Post: 08-19-2005, 07:18 AM
  3. Loading Bitmaps
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-06-2004, 12:48 AM
  4. Loading bitmaps
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-04-2004, 08:28 PM
  5. help with loading bitmaps
    By jono_123 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 04-02-2002, 06:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean