I'm porting some code from Visual Studio 2005 to Visual Studio 2008.
Can i use the glaux.lib found in Visual Studio 2005 found in \PlatformSDK\Lib folder in Visual Studio 2008 ? I don't want to change my APIs and have the requirement to use glaux.h
as said here , does this work
looks like g开发者_JAVA百科laux.lib is deprecated. Instead link to kernel32.lib, user32.lib, gdi32.lib and advapi32.lib
Download gluax.h from http://www.songho.ca/opengl/files/glaux.h and gluax.lib from http://www.songho.ca/opengl/files/glaux.lib.
Set the path and you are done.
AFAIK, most programmers miss the auxDIBImageLoad() function, and there is no documented workaround. The glaux.lib is a static library and introduces some code bloat.
This image loader will work without <glaux.h>:
HBITMAP hbm=LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(1));
if (!hbm) return false;
BITMAP bm;
GetObject(hbm,sizeof bm,&bm);
BITMAPINFO bmi={sizeof bmi,bm.bmWidth,bm.bmHeight,1,
32}; // 24 = GL_BGR_EXT, 32 = GL_BGRA_EXT; all other fields are 0
DWORD*bits=new DWORD[bm.bmWidth*bm.bmHeight];
GetDIBits(hDC,hbm,0,bm.bmHeight,bits,&bmi,DIB_RGB_COLORS);
...
glTexImage2D(GL_TEXTURE_2D,0,3,bm.bmWidth,bm.bmHeight,0,
GL_BGRA_EXT,GL_UNSIGNED_BYTE,bits);
...
delete[] bits;
DeleteBitmap(hbm);
This routine will handle both RGB (24-bit) and indexed images correctly! No need for manual pixel twiddeling! The example loads from process.exe's resource with numeric ID 1.
The LoadBitmap() can be replaced by LoadImage() to load from a file.
If your input image is known to be of uncompressed RGB type, GetDIBits is not needed, as you can LoadImage() with LR_CREATEDIBSECTION, access the bits using the bmBits pointer, and use the GL_BGR_EXT constant. (new and delete operators are not needed.)
GetDIBits needs any valid device context handle to succeed. Use GetDC/ReleaseDC if you have no handle handy.
The GL_BGRA_EXT constant is a Microsoft extension to opengl, its use is exactly for such GetDIBits output.
Loading compressed PNG/GIF/JPG is not tested here but should work the same way; GetDIBits() is your friend.
Moreover, that bitmap can be selected into a memory device context (making it to a painting canvas) and then modified by plain old GDI functions, especially text writing functions, to insert text to the bitmap.
精彩评论