ilut.h
Upload User: wmy0603
Upload Date: 2022-05-02
Package Size: 1808k
Code Size: 15k
Development Platform:

Visual C++

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