Results 1 to 2 of 2

Thread: textures

  1. #1
    Junior Member Newbie
    Join Date
    May 2003
    Location
    Beograd
    Posts
    1

    textures

    I want to make a texture, but I want to load it from resource, using HBITMAP and BITMAP and not auxDIBImageLoad function. I did something like this, but it didn't work:
    HBITMAP hBmp = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP));
    BITMAP bmp;
    GetObject(hBmp, sizeof(bmp), &bmp);

    glTexImage2D(GL_TEXTURE_2D, 0, 3, bmp.Width, bmp.Height, 0, GL_RGB, GL_UNSIGNED_BYTE, bmp.BltBit);

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Jan 2003
    Location
    Virginia
    Posts
    586

    Re: textures

    There is a BITMAPINFO structure at the start of the data. If the bitmap has a color lookup table then it follows, and then the pixel data follows that. You pass the pixel data to the glTexImage function.

    Something like this:

    Code :
    	HRSRC Resource = (HRSRC)LoadResource(AfxGetInstanceHandle(), FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(id), MAKEINTRESOURCE(RT_BITMAP)));
    	unsigned char *data = (unsigned char*)LockResource(Resource);
     
    	BITMAPINFO* bmpInfo = (BITMAPINFO*)data;
    	colors = data + bmpInfo->bmiHeader.biSize;
    	pixels = colors + bmpInfo->bmiHeader.biClrUsed * sizeof(bmpInfo->bmiColors);
    	width = bmpInfo->bmiHeader.biWidth;
    	height = bmpInfo->bmiHeader.biHeight;

Similar Threads

  1. Applying textures to a sphere. I know nothing about textures.
    By ElFlautas in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-28-2018, 03:47 AM
  2. model textures being redirected to font textures
    By Tcll5850 in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 09-07-2014, 10:43 PM
  3. FBO Attached Textures Reused as Shader Source Textures
    By Rennie Johnson in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-22-2012, 09:43 PM
  4. Lots of small textures or fewer large textures?
    By jlamanna in forum OpenGL: Advanced Coding
    Replies: 30
    Last Post: 01-12-2004, 03:53 AM
  5. are GL_COLOR_INDEX textures converted to RGBA-Textures?
    By TB-Rex in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 12-18-2000, 06:34 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