Thread: Idiot's Guide To Bitmap Textures?

  1. #1
    People Love Me
    Join Date
    Jan 2003
    Posts
    412

    Idiot's Guide To Bitmap Textures?

    I've read over NeHe's tut on bitmap textures, and I still really don't get how most of the stuff works. Can anyone link me to an idiot's guide to bitmap textures?

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    What don't you understand, the loading of the bitmaps or the actual texturing?

  3. #3
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Originally posted by Eibro
    What don't you understand, the loading of the bitmaps or the actual texturing?
    Loading 'em.

  4. #4
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    is there a specific part of loading them you are unclear on? Ask us a few questions im sure we can help.

  5. #5
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Originally posted by RoD
    is there a specific part of loading them you are unclear on? Ask us a few questions im sure we can help.
    Mostly like how to load more than one texture and make it work. I can't make it work for crap if I try to load two textures.

    I'm also not really familiar with the how the functions n' such you use to load bitmap files work.

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Here ya go.

    http://www.codeguru.com/bitmap/BitmapLoad.html

    It explains the structure of the BMP File and then gives you code for loading it.

    Here is my recommendation to you. Write a library for yourself to load and save BMP's. Then later when you get more and more comftorable with bitmaps you can extend it to support a lot of different manipulations to bitmaps. It will be a great exercise and you will be able to use it in a lot of different applications. Some features could be:

    * Handling RLE8 Compression
    * Bi-Linear Filtering
    * Scaling
    * Rotating
    * Inverting
    * Alpha Blending
    * Dithering

    etc.

  7. #7
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    the glaux library provides a method for loading a bitmap. I'm not sure how NeHe's does it, however this method has always worked for me. The auxDIBImageLoad(char*) function is what does the actual work of loading the bitmap, the rest just wraps around it to pass to OpenGL. I think I might've written this off of OpenGL Game Programming's code, or somethng...i don't remember.

    Anyway the aux library tends to have bugs, but this function has worked fine. It works for me because I'm lazy, and on top of being lazy I have other more interesting things to be doing...although you can't manipulate the bitmap's data as wizard suggested.


    Code:
    UINT	LoadBMP(char * FileName)
    {
    	UINT	texture = 0;
    
    	if(!FileName) 
    		return NULL;
    
    	AUX_RGBImageRec	*pImage;
    	
    	FILE	*pFile = fopen(FileName, "rb");
    	
    	if(!pFile)
    		return NULL; 
    
    	pImage = auxDIBImageLoad(FileName);
    
    	if(!pImage)
    	{		
    		return NULL;
    	}
    
    	texture = GenerateInternalTexture(pImage->data, 3, pImage->sizeX, pImage->sizeY, GL_RGB);
    
    	if (pImage)										
    	{
    		if (pImage->data)						
    		{
    			free(pImage->data);					
    		}
    
    		free(pImage);								
    	}
    
    	return texture;
    }

  8. #8
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by Silvercord
    the glaux library provides a method for loading a bitmap. I'm not sure how NeHe's does it, however this method has always worked for me. The auxDIBImageLoad(char*) function is what does the actual work of loading the bitmap, the rest just wraps around it to pass to OpenGL. I think I might've written this off of OpenGL Game Programming's code, or somethng...i don't remember.

    Anyway the aux library tends to have bugs, but this function has worked fine. It works for me because I'm lazy, and on top of being lazy I have other more interesting things to be doing...although you can't manipulate the bitmap's data as wizard suggested.


    Code:
    UINT	LoadBMP(char * FileName)
    {
    	UINT	texture = 0;
    
    	if(!FileName) 
    		return NULL;
    
    	AUX_RGBImageRec	*pImage;
    	
    	FILE	*pFile = fopen(FileName, "rb");
    	
    	if(!pFile)
    		return NULL; 
    
    	pImage = auxDIBImageLoad(FileName);
    
    	if(!pImage)
    	{		
    		return NULL;
    	}
    
    	texture = GenerateInternalTexture(pImage->data, 3, pImage->sizeX, pImage->sizeY, GL_RGB);
    
    	if (pImage)										
    	{
    		if (pImage->data)						
    		{
    			free(pImage->data);					
    		}
    
    		free(pImage);								
    	}
    
    	return texture;
    }
    You might want to match that call to fopen with a call to fclose

  9. #9
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    naw

    fclose is for losers

  10. #10
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by Silvercord
    naw

    fclose is for losers
    That's why I suggested it to you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with Bitmap Display
    By The Brain in forum Windows Programming
    Replies: 7
    Last Post: 03-23-2009, 05:33 AM
  2. The Complete Idiots Guide to Brain Surgery
    By abachler in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 05-24-2008, 05:57 PM
  3. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  4. Bitmap Textures
    By Krak in forum Game Programming
    Replies: 7
    Last Post: 04-28-2003, 11:36 AM
  5. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM