glaux.lib(tk.obj) : error LNK2001: unresolved external symbol __ftol2
    -> glaux.lib가 너무 오래된 라이브러리라서 생기는 문제
error C2065: 'auxDIBImageLoad' : undeclared identifier
    -> glaux.h를 인클루드 하지 않아서
error LNK2001: unresolved external symbol _auxDIBImageLoadA@4
    -> glaux.lib 를 링크 시키지 않아서

해결책은 glaux에 대한 대체코드를 넣는 것이다.
#include <gl/alaux.h>를 찾아서 주석처리하고
그 밑에
#include "glauxbmp.h"를 삽입하면 OK

origin : http://www.gamedev.net/community/forums/topic.asp?topic_id=275238

//---------------------------------------------------------------------------
// glauxbmp.h
#ifndef __GLAUX_MBP_H
#define __GLAUX_MBP_H
class AUX_RGBImageRec {
   void convertBGRtoRGB();
 public:
   byte *data;
   DWORD sizeX;
   DWORD sizeY;
   bool NoErrors;
   AUX_RGBImageRec(): NoErrors(false), data(NULL) {};
   AUX_RGBImageRec(const char *FileName);
   ~AUX_RGBImageRec();
   bool loadFile(const char *FileName);
   friend AUX_RGBImageRec *auxDIBImageLoad(const char *FileName);
};

#include "glauxbmp.cpp"

#endif


//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// glauxbmp.cpp
//--------------------------------------------------------------
#include <windows.h>  // Header File For Windows - has structures for BMP format
#include <stdio.h>      // Header File For Standard Input/Output
#include <stdlib.h>
#include "GlauxBMP.h"

/*------------------------------------------------------------------
 BMP Loader - a quick and dirty substitute for GLaux
 if you only use GLaux to load BMP files will load any format of a
 windows DIB BMP format graphics file Only works on a windows box  
 Caution! memory for the data is allocated using 'new'. 
 In the NeHe tutorials the memory is reclaimed using 'free'.  
 For the small tutorials its not a big deal but not a good practice in
 larger projects (heap trashing not good). J.M. Doyle : 12 Jan 2003
------------------------------------------------------------------*/

AUX_RGBImageRec *auxDIBImageLoad(const char *FileName)
{
  return new AUX_RGBImageRec(FileName);
}


void AUX_RGBImageRec::convertBGRtoRGB()
{
 const DWORD BitmapLength = sizeX * sizeY * 3;
 byte Temp;  // not quick but it works 
 for(DWORD i=0; i< BitmapLength; i += 3)
 {
     Temp = data[i];
     data[i] = data[i+2];
     data[i+2] = Temp;
     }
 }

AUX_RGBImageRec::AUX_RGBImageRec(const char *FileName): data(NULL), NoErrors(false)
{
 loadFile(FileName);
}

AUX_RGBImageRec::~AUX_RGBImageRec()
{
  if (data != NULL) delete data;
  data = NULL;
}

bool AUX_RGBImageRec::loadFile(const char* Filename)
{
 BITMAPINFO BMInfo;        // need the current OpenGL device contexts in order to make use of windows DIB utilities 
 const HDC gldc = wglGetCurrentDC();      // a handle for the current OpenGL Device Contexts
               // assume there are errors until file is loaded successfully into memory 
 NoErrors = false;          // release old data since this object could be used to load multiple Textures 
 if(data != NULL) delete data;     // windows needs this info to determine what header info we are looking for 
 BMInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);  // Get windows to determine color bit depth in the file for us 
 BMInfo.bmiHeader.biBitCount = 0;    // Get windows to open and load the BMP file and handle the messy decompression if the file is compressed 
             // assume perfect world and no errors in reading file, Ha Ha 
 HANDLE DIBHandle = LoadImage(0,Filename, IMAGE_BITMAP, 0, 0,LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE);  // use windows to get header info of bitmap - assume no errors in header format

 GetDIBits(gldc, (HBITMAP)DIBHandle, 0,0, NULL, &BMInfo, DIB_RGB_COLORS);
 sizeX = BMInfo.bmiHeader.biWidth;
 sizeY = BMInfo.bmiHeader.biHeight;    // change color depth to 24 bits (3 bytes (BGR) / pixel) 
 BMInfo.bmiHeader.biBitCount = 24;    // don't want the data compressed 
 BMInfo.bmiHeader.biCompression = BI_RGB; 
 const DWORD BitmapLength = sizeX * sizeY * 3; // 3 bytes (BGR) per pixel (24bp) 
             // allocate enough memory to hold the pixel data in client memory 
 data = new byte[BitmapLength];     // Get windows to do the dirty work of converting the BMP into the format needed by OpenGL 
             // if file is already 24 bit color then this is a waste of time but makes for short code 
             // Get the actual Texel data from the BMP object 
 
 if (GetDIBits(gldc, (HBITMAP)DIBHandle, 0, sizeY, data, &BMInfo, DIB_RGB_COLORS))
 {
  NoErrors = true;
  convertBGRtoRGB();       // NOTE: BMP is in BGR format but OpenGL needs RGB unless you use GL_BGR_EXT
 }

 DeleteObject(DIBHandle);      // don't need the BMP Object anymore 
 return NoErrors;
}       


< 다른 방법 >
nehe's glaux replacement code
origin : nehe.gamedev.net

/************************************************************************
                         REPLACEMENT FOR GLAUX
 ************************************************************************
 This is not a full blown bitmap loader.  It is a quick and easy
 way to replace the glAux dependant code in my older tutorials
 with code that does not depend on the glAux library!

    This code only loads Truecolor Bitmap Images.  It will not load
 8-bit bitmaps.  If you encounter a bitmap that will not load
 use a program such as Irfanview to convert the bitmap to 24 bits.
 ************************************************************************/

bool NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid)     // Creates Texture From A Bitmap File
{
 HBITMAP hBMP;              // Handle Of The Bitmap
 BITMAP BMP;              // Bitmap Structure

 glGenTextures(1, &texid);           // Create The Texture
 hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );

 if (!hBMP)               // Does The Bitmap Exist?
  return FALSE;             // If Not Return False

 GetObject(hBMP, sizeof(BMP), &BMP);         // Get The Object
                  // hBMP:        Handle To Graphics Object
                  // sizeof(BMP): Size Of Buffer For Object Information
                  // &BMP:        Buffer For Object Information

 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);        // Pixel Storage Mode (Word Alignment / 4 Bytes)

 // Typical Texture Generation Using Data From The Bitmap
 glBindTexture(GL_TEXTURE_2D, texid);        // Bind To The Texture ID
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Min Filter
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Mag Filter
 glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);

 DeleteObject(hBMP);             // Delete The Object

 return TRUE;              // Loading Was Successful
}

BOOL Initialize (GL_Window* window, Keys* keys)       // Any GL Init Code & User Initialiazation Goes Here
{
 g_window = window;
 g_keys  = keys;

 // Start Of User Initialization
 if (!NeHeLoadBitmap("Data/NeHe.bmp", texture[0]))     // Load The Bitmap
  return FALSE;             // Return False If Loading Failed

반응형

'Code' 카테고리의 다른 글

[vc6] VC6에서 최신(XP) DDK 사용  (0) 2008.11.05
[vc6] uuid.lib 관련 링크에러  (0) 2008.11.05
잠긴 파일 지우기  (0) 2008.11.05
OpenGL 을 Open하다  (0) 2008.11.05
* 게임 엔진에 대한 간단한 정리  (0) 2008.11.05
Posted by codens


반응형