Skip to content
Open
2 changes: 1 addition & 1 deletion DevIL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6)

project(ImageLib)
# include our custom modules
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")

add_subdirectory(src-IL)
add_subdirectory(src-ILU)
Expand Down
23 changes: 15 additions & 8 deletions DevIL/src-IL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@ if(WIN32)
add_definitions(-DIL_DLL -DJPEGSTATIC)
# note: .def not used for now - __declspec() in source handles export.
set(DevIL_SRCS ${DevIL_SRCS} msvc/il.def)
if(UNICODE)
set(DevIL_RSRC ${DevIL_RSRC} "msvc/resources/IL Logo.ico" "msvc/IL Unicode.rc")
else(UNICODE)
set(DevIL_RSRC ${DevIL_RSRC} "msvc/resources/IL Logo.ico" "msvc/IL.rc")
endif(UNICODE)
set(DevIL_TXT ${DevIL_TXT} ../AUTHORS ../ChangeLog ../CREDITS ../libraries.txt ../README.md ../README.cmake ../TODO)
if(${MSVC_VERSION} GREATER 1899) # MSVC 2015 or later
option(DEVIL_INCLUDE_RESOURCES "DevIL: compile-in resources" OFF)
else()
option(DEVIL_INCLUDE_RESOURCES "DevIL: compile-in resources" ON)
endif()
if(DEVIL_INCLUDE_RESOURCES)
if(UNICODE)
set(DevIL_RSRC ${DevIL_RSRC} "msvc/resources/IL Logo.ico" "msvc/IL Unicode.rc")
else(UNICODE)
set(DevIL_RSRC ${DevIL_RSRC} "msvc/resources/IL Logo.ico" "msvc/IL.rc")
endif(UNICODE)
endif(DEVIL_INCLUDE_RESOURCES)
set(DevIL_TXT ${DevIL_TXT} ../AUTHORS ../ChangeLog ../CREDITS ../Libraries.txt ../README.md ../README.cmake ../TODO)
# SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:msvcrt.lib ")
set(CMAKE_C_FLAGS_RELEASE "/MT /O2")
else(BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -293,11 +300,11 @@ if(IL_USE_DXTC_SQUISH)
endif(IL_USE_DXTC_SQUISH)


include_directories(${incs})
include_directories(${incs} "${CMAKE_CURRENT_BINARY_DIR}/include")
target_link_libraries(IL ${libs})

# generate config.h
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.cmake.in ${CMAKE_CURRENT_SOURCE_DIR}/include/config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)



Expand Down
19 changes: 16 additions & 3 deletions DevIL/src-IL/src/il_iwi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ typedef struct IWIHEAD
ILubyte Flags;
ILushort Width;
ILushort Height;
ILubyte Unknown1;
ILubyte Unknown2;
ILuint Filesize;
ILuint OffsetTexture;
ILuint OffsetMipmap1;
ILuint OffsetMipmap2;
} IWIHEAD;

#define IWI_ARGB8 0x01
Expand Down Expand Up @@ -90,14 +96,18 @@ ILboolean ilIsValidIwiL(const void *Lump, ILuint Size)
// Internal function used to get the IWI header from the current file.
ILboolean iGetIwiHead(IWIHEAD *Header)
{
//Partially based on: https://github.com/CptAsgard/CoD2Unity/blob/master/Assets/cod2iwifiles.txt
Header->Signature = GetLittleUInt();
Header->Format = igetc();
Header->Flags = igetc(); //@TODO: Find out what the flags mean.
Header->Width = GetLittleUShort();
Header->Height = GetLittleUShort();

// @TODO: Find out what is in the rest of the header.
iseek(18, IL_SEEK_CUR);
Header->Unknown1 = igetc(); //@TODO: Find out what this byte means.
Header->Unknown2 = igetc(); //@TODO: Find out what this byte means.
Header->Filesize = GetLittleUInt();
Header->OffsetTexture = GetLittleUInt();
Header->OffsetMipmap1 = GetLittleUInt();
Header->OffsetMipmap2 = GetLittleUInt();

return IL_TRUE;
}
Expand Down Expand Up @@ -292,13 +302,16 @@ ILboolean IwiReadImage(ILimage *BaseImage, IWIHEAD *Header, ILuint NumMips)
ILubyte *CompData = NULL;
ILint i, j, k, m;

iseek(Header->OffsetTexture, IL_SEEK_SET);

for (i = NumMips; i >= 0; i--) {
Image = BaseImage;
// Go to the ith mipmap level.
// The mipmaps go from smallest to the largest.
for (j = 0; j < i; j++)
Image = Image->Mipmaps;

//@TODO: Seek to the mipmap offset
switch (Header->Format)
{
case IWI_ARGB8: // These are all
Expand Down
10 changes: 7 additions & 3 deletions DevIL/src-ILU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ source_group("Source Files" FILES src/*.cpp)
source_group("Header Files" FILES ${ILU_INC} )
source_group("Resource Files" FILES ${ILU_RSRC} )

# Remove SHARED to create a static library
add_library(ILU SHARED ${ILU_SRCS} ${ILU_INC} ${ILU_RSRC})
set_target_properties(ILU PROPERTIES SOVERSION 1)
if(BUILD_SHARED_LIBS)
add_library(ILU SHARED ${ILU_SRCS} ${ILU_INC} ${ILU_RSRC})
set_target_properties(ILU PROPERTIES SOVERSION 1)
else(BUILD_SHARED_LIBS)
add_library(ILU ${ILU_SRCS} ${ILU_INC} ${ILU_RSRC})
endif(BUILD_SHARED_LIBS)



## ILU requires IL
Expand Down
10 changes: 7 additions & 3 deletions DevIL/src-ILUT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ source_group("Source Files" FILES src/*.cpp)
source_group("Header Files" FILES ${ILUT_INC} )
source_group("Resource Files" FILES ${ILUT_RSRC} )

# Remove SHARED to create a static library
add_library(ILUT SHARED ${ILUT_SRCS} ${ILUT_INC} ${ILUT_RSRC})
set_target_properties(ILUT PROPERTIES SOVERSION 1)
if(BUILD_SHARED_LIBS)
add_library(ILUT SHARED ${ILUT_SRCS} ${ILUT_INC} ${ILUT_RSRC})
set_target_properties(ILUT PROPERTIES SOVERSION 1)
else(BUILD_SHARED_LIBS)
add_library(ILUT ${ILUT_SRCS} ${ILUT_INC} ${ILUT_RSRC})
endif(BUILD_SHARED_LIBS)


## add link sub library info
target_link_libraries(ILUT
Expand Down