ilut.h 15 KB

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