1 //----------------------------------------------------------------------------- 2 // 3 // ImageLib Utility Toolkit Sources 4 // Copyright (C) 2000-2009 by Denton Woods 5 // Last modified: 03/07/2009 6 // 7 // Filename: IL/ilut.h 8 // 9 // Description: The main include file for ILUT 10 // 11 //----------------------------------------------------------------------------- 12 13 // Doxygen comment 14 /*! \file ilut.h 15 The main include file for ILUT 16 */ 17 18 #ifndef __ilut_h_ 19 #ifndef __ILUT_H__ 20 21 #define __ilut_h_ 22 #define __ILUT_H__ 23 24 #include <IL/il.h> 25 #include <IL/ilu.h> 26 27 28 //----------------------------------------------------------------------------- 29 // Defines 30 //----------------------------------------------------------------------------- 31 32 #define ILUT_VERSION_1_7_8 1 33 #define ILUT_VERSION 178 34 35 36 // Attribute Bits 37 #define ILUT_OPENGL_BIT 0x00000001 38 #define ILUT_D3D_BIT 0x00000002 39 #define ILUT_ALL_ATTRIB_BITS 0x000FFFFF 40 41 42 // Error Types 43 #define ILUT_INVALID_ENUM 0x0501 44 #define ILUT_OUT_OF_MEMORY 0x0502 45 #define ILUT_INVALID_VALUE 0x0505 46 #define ILUT_ILLEGAL_OPERATION 0x0506 47 #define ILUT_INVALID_PARAM 0x0509 48 #define ILUT_COULD_NOT_OPEN_FILE 0x050A 49 #define ILUT_STACK_OVERFLOW 0x050E 50 #define ILUT_STACK_UNDERFLOW 0x050F 51 #define ILUT_BAD_DIMENSIONS 0x0511 52 #define ILUT_NOT_SUPPORTED 0x0550 53 54 55 // State Definitions 56 #define ILUT_PALETTE_MODE 0x0600 57 #define ILUT_OPENGL_CONV 0x0610 58 #define ILUT_D3D_MIPLEVELS 0x0620 59 #define ILUT_MAXTEX_WIDTH 0x0630 60 #define ILUT_MAXTEX_HEIGHT 0x0631 61 #define ILUT_MAXTEX_DEPTH 0x0632 62 #define ILUT_GL_USE_S3TC 0x0634 63 #define ILUT_D3D_USE_DXTC 0x0634 64 #define ILUT_GL_GEN_S3TC 0x0635 65 #define ILUT_D3D_GEN_DXTC 0x0635 66 #define ILUT_S3TC_FORMAT 0x0705 67 #define ILUT_DXTC_FORMAT 0x0705 68 #define ILUT_D3D_POOL 0x0706 69 #define ILUT_D3D_ALPHA_KEY_COLOR 0x0707 70 #define ILUT_D3D_ALPHA_KEY_COLOUR 0x0707 71 #define ILUT_FORCE_INTEGER_FORMAT 0x0636 72 73 //This new state does automatic texture target detection 74 //if enabled. Currently, only cubemap detection is supported. 75 //if the current image is no cubemap, the 2d texture is chosen. 76 #define ILUT_GL_AUTODETECT_TEXTURE_TARGET 0x0807 77 78 79 // Values 80 #define ILUT_VERSION_NUM IL_VERSION_NUM 81 #define ILUT_VENDOR IL_VENDOR 82 83 // The different rendering api's...more to be added later? 84 #define ILUT_OPENGL 0 85 #define ILUT_ALLEGRO 1 86 #define ILUT_WIN32 2 87 #define ILUT_DIRECT3D8 3 88 #define ILUT_DIRECT3D9 4 89 #define ILUT_X11 5 90 #define ILUT_DIRECT3D10 6 91 92 /* 93 // Includes specific config 94 #ifdef DJGPP 95 #define ILUT_USE_ALLEGRO 96 #elif _WIN32_WCE 97 #define ILUT_USE_WIN32 98 #elif _WIN32 99 //#ifdef __GNUC__ //__CYGWIN32__ (Cygwin seems to not define this with DevIL builds) 100 #define ILUT_USE_WIN32 101 #include "IL/config.h" 102 103 // Temporary fix for the SDL main() linker bug. 104 //#ifdef ILUT_USE_SDL 105 //#undef ILUT_USE_SDL 106 //#endif//ILUT_USE_SDL 107 108 //#else 109 // #define ILUT_USE_WIN32 110 // #define ILUT_USE_OPENGL 111 // #define ILUT_USE_SDL 112 // #define ILUT_USE_DIRECTX8 113 //#endif 114 #elif BEOS // Don't know the #define 115 #define ILUT_USE_BEOS 116 #define ILUT_USE_OPENGL 117 #elif MACOSX 118 #define ILUT_USE_OPENGL 119 #else 120 121 // We are surely using a *nix so the configure script 122 // may have written the configured config.h header 123 #include "IL/config.h" 124 #endif 125 */ 126 127 #if (defined(_WIN32) || defined(_WIN64)) 128 #if (defined(IL_USE_PRAGMA_LIBS)) && (!defined(_IL_BUILD_LIBRARY)) 129 #if defined(_MSC_VER) || defined(__BORLANDC__) 130 #pragma comment(lib, "ILUT.lib") 131 #endif 132 #endif 133 134 #include <IL/ilut_config.h> 135 #endif 136 137 138 139 //this should remain private and hidden 140 //#include "IL/config.h" 141 142 ////////////// 143 // OpenGL 144 ////////////// 145 146 #ifdef ILUT_USE_OPENGL 147 #if defined(_MSC_VER) || defined(_WIN32) 148 //#define WIN32_LEAN_AND_MEAN 149 #include <windows.h> 150 #endif//_MSC_VER 151 152 #ifdef __APPLE__ 153 #include <OpenGL/gl.h> 154 #include <OpenGL/glu.h> 155 #else 156 #include <GL/gl.h> 157 #include <GL/glu.h> 158 #endif//__APPLE__ 159 #endif 160 161 162 #ifdef ILUT_USE_WIN32 163 //#define WIN32_LEAN_AND_MEAN 164 #ifdef _DEBUG 165 #define _CRTDBG_MAP_ALLOC 166 #include <stdlib.h> 167 #ifndef _WIN32_WCE 168 #include <crtdbg.h> 169 #endif 170 #endif 171 #include <windows.h> 172 #endif 173 174 175 // 176 // If we can avoid including these in all cases thing tend to break less 177 // and we can keep all of them defined as available 178 // 179 // Kriss 180 // 181 182 // ImageLib Utility Toolkit's Allegro Functions 183 #ifdef ILUT_USE_ALLEGRO 184 // #include <allegro.h> 185 #endif//ILUT_USE_ALLEGRO 186 187 #ifdef ILUT_USE_SDL 188 // #include <SDL.h> 189 #endif 190 191 #ifdef ILUT_USE_DIRECTX8 192 #include <d3d8.h> 193 #endif//ILUT_USE_DIRECTX9 194 195 #ifdef ILUT_USE_DIRECTX9 196 #include <d3d9.h> 197 #endif//ILUT_USE_DIRECTX9 198 199 #ifdef ILUT_USE_DIRECTX10 200 #pragma warning(push) 201 #pragma warning(disable : 4201) // Disables 'nonstandard extension used : nameless struct/union' warning 202 #include <rpcsal.h> 203 #include <sal.h> 204 #include <d3d10.h> 205 #pragma warning(pop) 206 #endif//ILUT_USE_DIRECTX10 207 208 #ifdef ILUT_USE_X11 209 #include <X11/Xlib.h> 210 #include <X11/Xutil.h> 211 #ifdef ILUT_USE_XSHM 212 #include <sys/ipc.h> 213 #include <sys/shm.h> 214 #include <X11/extensions/XShm.h> 215 #endif//ILUT_USE_XSHM 216 #endif//ILUT_USE_X11 217 218 219 220 //----------------------------------------------------------------------------- 221 // Functions 222 //----------------------------------------------------------------------------- 223 224 #ifdef __cplusplus 225 extern "C" { 226 #endif 227 228 // ImageLib Utility Toolkit Functions 229 ILAPI ILboolean ILAPIENTRY ilutDisable(ILenum Mode); 230 ILAPI ILboolean ILAPIENTRY ilutEnable(ILenum Mode); 231 ILAPI ILboolean ILAPIENTRY ilutGetBoolean(ILenum Mode); 232 ILAPI void ILAPIENTRY ilutGetBooleanv(ILenum Mode, ILboolean *Param); 233 ILAPI ILint ILAPIENTRY ilutGetInteger(ILenum Mode); 234 ILAPI void ILAPIENTRY ilutGetIntegerv(ILenum Mode, ILint *Param); 235 ILAPI ILstring ILAPIENTRY ilutGetString(ILenum StringName); 236 ILAPI void ILAPIENTRY ilutInit(void); 237 ILAPI ILboolean ILAPIENTRY ilutIsDisabled(ILenum Mode); 238 ILAPI ILboolean ILAPIENTRY ilutIsEnabled(ILenum Mode); 239 ILAPI void ILAPIENTRY ilutPopAttrib(void); 240 ILAPI void ILAPIENTRY ilutPushAttrib(ILuint Bits); 241 ILAPI void ILAPIENTRY ilutSetInteger(ILenum Mode, ILint Param); 242 243 ILAPI ILboolean ILAPIENTRY ilutRenderer(ILenum Renderer); 244 245 246 // ImageLib Utility Toolkit's OpenGL Functions 247 #ifdef ILUT_USE_OPENGL 248 ILAPI GLuint ILAPIENTRY ilutGLBindTexImage(); 249 ILAPI GLuint ILAPIENTRY ilutGLBindMipmaps(void); 250 ILAPI ILboolean ILAPIENTRY ilutGLBuildMipmaps(void); 251 ILAPI GLuint ILAPIENTRY ilutGLLoadImage(ILstring FileName); 252 ILAPI ILboolean ILAPIENTRY ilutGLScreen(void); 253 ILAPI ILboolean ILAPIENTRY ilutGLScreenie(void); 254 ILAPI ILboolean ILAPIENTRY ilutGLSaveImage(ILstring FileName, GLuint TexID); 255 ILAPI ILboolean ILAPIENTRY ilutGLSubTex2D(GLuint TexID, ILuint XOff, ILuint YOff); 256 ILAPI ILboolean ILAPIENTRY ilutGLSubTex3D(GLuint TexID, ILuint XOff, ILuint YOff, ILuint ZOff); 257 ILAPI ILboolean ILAPIENTRY ilutGLSetTex2D(GLuint TexID); 258 ILAPI ILboolean ILAPIENTRY ilutGLSetTex3D(GLuint TexID); 259 ILAPI ILboolean ILAPIENTRY ilutGLTexImage(GLuint Level); 260 ILAPI ILboolean ILAPIENTRY ilutGLSubTex(GLuint TexID, ILuint XOff, ILuint YOff); 261 262 ILAPI ILboolean ILAPIENTRY ilutGLSetTex(GLuint TexID); // Deprecated - use ilutGLSetTex2D. 263 ILAPI ILboolean ILAPIENTRY ilutGLSubTex(GLuint TexID, ILuint XOff, ILuint YOff); // Use ilutGLSubTex2D. 264 #endif//ILUT_USE_OPENGL 265 266 267 // ImageLib Utility Toolkit's Allegro Functions 268 #ifdef ILUT_USE_ALLEGRO 269 #ifdef __cplusplus 270 extern "C" { 271 #endif 272 #include <allegro.h> 273 #ifdef __cplusplus 274 } 275 #endif 276 277 ILAPI BITMAP* ILAPIENTRY ilutAllegLoadImage(ILstring FileName); 278 ILAPI BITMAP* ILAPIENTRY ilutConvertToAlleg(PALETTE Pal); 279 #endif//ILUT_USE_ALLEGRO 280 281 282 // ImageLib Utility Toolkit's SDL Functions 283 #ifdef ILUT_USE_SDL 284 ILAPI struct SDL_Surface* ILAPIENTRY ilutConvertToSDLSurface(unsigned int flags); 285 ILAPI struct SDL_Surface* ILAPIENTRY ilutSDLSurfaceLoadImage(ILstring FileName); 286 ILAPI ILboolean ILAPIENTRY ilutSDLSurfaceFromBitmap(struct SDL_Surface *Bitmap); 287 #endif//ILUT_USE_SDL 288 289 290 // ImageLib Utility Toolkit's BeOS Functions 291 #ifdef ILUT_USE_BEOS 292 ILAPI BBitmap ILAPIENTRY ilutConvertToBBitmap(void); 293 #endif//ILUT_USE_BEOS 294 295 296 // ImageLib Utility Toolkit's Win32 GDI Functions 297 #ifdef ILUT_USE_WIN32 298 ILAPI HBITMAP ILAPIENTRY ilutConvertToHBitmap(HDC hDC); 299 ILAPI HBITMAP ILAPIENTRY ilutConvertSliceToHBitmap(HDC hDC, ILuint slice); 300 ILAPI void ILAPIENTRY ilutFreePaddedData(ILubyte *Data); 301 ILAPI void ILAPIENTRY ilutGetBmpInfo(BITMAPINFO *Info); 302 ILAPI HPALETTE ILAPIENTRY ilutGetHPal(void); 303 ILAPI ILubyte* ILAPIENTRY ilutGetPaddedData(void); 304 ILAPI ILboolean ILAPIENTRY ilutGetWinClipboard(void); 305 ILAPI ILboolean ILAPIENTRY ilutLoadResource(HINSTANCE hInst, ILint ID, ILstring ResourceType, ILenum Type); 306 ILAPI ILboolean ILAPIENTRY ilutSetHBitmap(HBITMAP Bitmap); 307 ILAPI ILboolean ILAPIENTRY ilutSetHPal(HPALETTE Pal); 308 ILAPI ILboolean ILAPIENTRY ilutSetWinClipboard(void); 309 ILAPI HBITMAP ILAPIENTRY ilutWinLoadImage(ILstring FileName, HDC hDC); 310 ILAPI ILboolean ILAPIENTRY ilutWinLoadUrl(ILstring Url); 311 ILAPI ILboolean ILAPIENTRY ilutWinPrint(ILuint XPos, ILuint YPos, ILuint Width, ILuint Height, HDC hDC); 312 ILAPI ILboolean ILAPIENTRY ilutWinSaveImage(ILstring FileName, HBITMAP Bitmap); 313 #endif//ILUT_USE_WIN32 314 315 // ImageLib Utility Toolkit's DirectX 8 Functions 316 #ifdef ILUT_USE_DIRECTX8 317 // ILAPI void ILAPIENTRY ilutD3D8MipFunc(ILuint NumLevels); 318 ILAPI struct IDirect3DTexture8* ILAPIENTRY ilutD3D8Texture(struct IDirect3DDevice8 *Device); 319 ILAPI struct IDirect3DVolumeTexture8* ILAPIENTRY ilutD3D8VolumeTexture(struct IDirect3DDevice8 *Device); 320 ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromFile(struct IDirect3DDevice8 *Device, char *FileName, struct IDirect3DTexture8 **Texture); 321 ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromFile(struct IDirect3DDevice8 *Device, char *FileName, struct IDirect3DVolumeTexture8 **Texture); 322 ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromFileInMemory(struct IDirect3DDevice8 *Device, void *Lump, ILuint Size, struct IDirect3DTexture8 **Texture); 323 ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromFileInMemory(struct IDirect3DDevice8 *Device, void *Lump, ILuint Size, struct IDirect3DVolumeTexture8 **Texture); 324 ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromFileHandle(struct IDirect3DDevice8 *Device, ILHANDLE File, struct IDirect3DTexture8 **Texture); 325 ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromFileHandle(struct IDirect3DDevice8 *Device, ILHANDLE File, struct IDirect3DVolumeTexture8 **Texture); 326 // These two are not tested yet. 327 ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromResource(struct IDirect3DDevice8 *Device, HMODULE SrcModule, char *SrcResource, struct IDirect3DTexture8 **Texture); 328 ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromResource(struct IDirect3DDevice8 *Device, HMODULE SrcModule, char *SrcResource, struct IDirect3DVolumeTexture8 **Texture); 329 ILAPI ILboolean ILAPIENTRY ilutD3D8LoadSurface(struct IDirect3DDevice8 *Device, struct IDirect3DSurface8 *Surface); 330 #endif//ILUT_USE_DIRECTX8 331 332 #ifdef ILUT_USE_DIRECTX9 333 #pragma warning(push) 334 #pragma warning(disable : 4115) // Disables 'named type definition in parentheses' warning 335 // ILAPI void ILAPIENTRY ilutD3D9MipFunc(ILuint NumLevels); 336 ILAPI struct IDirect3DTexture9* ILAPIENTRY ilutD3D9Texture (struct IDirect3DDevice9* Device); 337 ILAPI struct IDirect3DVolumeTexture9* ILAPIENTRY ilutD3D9VolumeTexture (struct IDirect3DDevice9* Device); 338 ILAPI struct IDirect3DCubeTexture9* ILAPIENTRY ilutD3D9CubeTexture (struct IDirect3DDevice9* Device); 339 340 ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromFile(struct IDirect3DDevice9 *Device, ILconst_string FileName, struct IDirect3DCubeTexture9 **Texture); 341 ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromFileInMemory(struct IDirect3DDevice9 *Device, void *Lump, ILuint Size, struct IDirect3DCubeTexture9 **Texture); 342 ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromFileHandle(struct IDirect3DDevice9 *Device, ILHANDLE File, struct IDirect3DCubeTexture9 **Texture); 343 ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromResource(struct IDirect3DDevice9 *Device, HMODULE SrcModule, ILconst_string SrcResource, struct IDirect3DCubeTexture9 **Texture); 344 345 ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromFile(struct IDirect3DDevice9 *Device, ILconst_string FileName, struct IDirect3DTexture9 **Texture); 346 ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromFile(struct IDirect3DDevice9 *Device, ILconst_string FileName, struct IDirect3DVolumeTexture9 **Texture); 347 ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromFileInMemory(struct IDirect3DDevice9 *Device, void *Lump, ILuint Size, struct IDirect3DTexture9 **Texture); 348 ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromFileInMemory(struct IDirect3DDevice9 *Device, void *Lump, ILuint Size, struct IDirect3DVolumeTexture9 **Texture); 349 ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromFileHandle(struct IDirect3DDevice9 *Device, ILHANDLE File, struct IDirect3DTexture9 **Texture); 350 ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromFileHandle(struct IDirect3DDevice9 *Device, ILHANDLE File, struct IDirect3DVolumeTexture9 **Texture); 351 352 // These three are not tested yet. 353 ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromResource(struct IDirect3DDevice9 *Device, HMODULE SrcModule, ILconst_string SrcResource, struct IDirect3DTexture9 **Texture); 354 ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromResource(struct IDirect3DDevice9 *Device, HMODULE SrcModule, ILconst_string SrcResource, struct IDirect3DVolumeTexture9 **Texture); 355 ILAPI ILboolean ILAPIENTRY ilutD3D9LoadSurface(struct IDirect3DDevice9 *Device, struct IDirect3DSurface9 *Surface); 356 #pragma warning(pop) 357 #endif//ILUT_USE_DIRECTX9 358 359 #ifdef ILUT_USE_DIRECTX10 360 ILAPI ID3D10Texture2D* ILAPIENTRY ilutD3D10Texture(ID3D10Device *Device); 361 ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromFile(ID3D10Device *Device, ILconst_string FileName, ID3D10Texture2D **Texture); 362 ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromFileInMemory(ID3D10Device *Device, void *Lump, ILuint Size, ID3D10Texture2D **Texture); 363 ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromResource(ID3D10Device *Device, HMODULE SrcModule, ILconst_string SrcResource, ID3D10Texture2D **Texture); 364 ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromFileHandle(ID3D10Device *Device, ILHANDLE File, ID3D10Texture2D **Texture); 365 #endif//ILUT_USE_DIRECTX10 366 367 368 369 #ifdef ILUT_USE_X11 370 ILAPI XImage * ILAPIENTRY ilutXCreateImage( Display* ); 371 ILAPI Pixmap ILAPIENTRY ilutXCreatePixmap( Display*,Drawable ); 372 ILAPI XImage * ILAPIENTRY ilutXLoadImage( Display*,char* ); 373 ILAPI Pixmap ILAPIENTRY ilutXLoadPixmap( Display*,Drawable,char* ); 374 #ifdef ILUT_USE_XSHM 375 ILAPI XImage * ILAPIENTRY ilutXShmCreateImage( Display*,XShmSegmentInfo* ); 376 ILAPI void ILAPIENTRY ilutXShmDestroyImage( Display*,XImage*,XShmSegmentInfo* ); 377 ILAPI Pixmap ILAPIENTRY ilutXShmCreatePixmap( Display*,Drawable,XShmSegmentInfo* ); 378 ILAPI void ILAPIENTRY ilutXShmFreePixmap( Display*,Pixmap,XShmSegmentInfo* ); 379 ILAPI XImage * ILAPIENTRY ilutXShmLoadImage( Display*,char*,XShmSegmentInfo* ); 380 ILAPI Pixmap ILAPIENTRY ilutXShmLoadPixmap( Display*,Drawable,char*,XShmSegmentInfo* ); 381 #endif//ILUT_USE_XSHM 382 #endif//ILUT_USE_X11 383 384 385 #ifdef __cplusplus 386 } 387 #endif 388 389 #endif // __ILUT_H__ 390 #endif // __ilut_h_ 391