From 2da6a4aec9a249417a9e4c0106ab6bec0489a36f Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 15 Jun 2019 13:19:46 +0800 Subject: Added DevIL as an option for image loader. --- smelt/glfw/gfx_glfw.cpp | 26 ++++++++++++++++++++++++++ smelt/glfw/gfx_glfw_compat.cpp | 24 ++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) (limited to 'smelt') diff --git a/smelt/glfw/gfx_glfw.cpp b/smelt/glfw/gfx_glfw.cpp index c545073..aa5f4bd 100644 --- a/smelt/glfw/gfx_glfw.cpp +++ b/smelt/glfw/gfx_glfw.cpp @@ -9,7 +9,13 @@ * */ #include "smelt_internal.hpp" + +#ifdef USE_CXIMAGE #include "CxImage/ximage.h" +#else +#include "IL/il.h" +#endif + #define dbg printf("%d: 0x%X\n",__LINE__,glGetError()) #ifndef USE_OPENGL_COMPATIBILITY_PROFILE #include "smmath_priv.hpp" @@ -575,6 +581,8 @@ DWORD* SMELT_IMPL::decodeImage(BYTE *data,const char *fn,DWORD size,int &w,int & } return px; } + +#ifdef USE_CXIMAGE CxImage img; img.Decode(data,size,CXIMAGE_FORMAT_UNKNOWN); if(img.IsValid()) @@ -593,6 +601,24 @@ DWORD* SMELT_IMPL::decodeImage(BYTE *data,const char *fn,DWORD size,int &w,int & *(sptr++)=achannel?rgb.rgbReserved:0xFF; } } +#else + ilInit(); + ILuint iid; + ilGenImages(1,&iid); + if(ilLoadL(IL_TYPE_UNKNOWN,data,size)) + { + w=ilGetInteger(IL_IMAGE_WIDTH); + h=ilGetInteger(IL_IMAGE_HEIGHT); + if(ilGetInteger(IL_IMAGE_FORMAT)!=IL_UNSIGNED_INT||ilGetInteger(IL_IMAGE_TYPE)!=IL_RGBA) + ilConvertImage(IL_UNSIGNED_INT,IL_RGBA); + px=new DWORD[w*h]; + for(int i=0;i