2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit aa1bc121 authored by schultezub's avatar schultezub
Browse files

added DevIL module

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@384 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 2dea1366
......@@ -36,6 +36,28 @@ namespace campvis {
const std::string ImageDataGL::loggerCat_ = "CAMPVis.core.datastructures.ImageDataGL";
ImageDataGL* ImageDataGL::createFromTexture(tgt::Texture* texture) {
tgtAssert(texture != 0, "Given texture must not be 0.");
size_t dimensionality = 0;
tgt::svec3 size(texture->getDimensions());
if (size.z > 1)
dimensionality = 3;
else if (size.y > 1)
dimensionality = 2;
else
dimensionality = 1;
return new ImageDataGL(dimensionality, size, texture);
}
ImageDataGL::ImageDataGL(size_t dimensionality, const tgt::svec3& size, tgt::Texture* texture)
: ImageData(dimensionality, size)
, _texture(texture)
{
tgtAssert(texture != 0, "Given texture must not be 0.");
}
ImageDataGL::ImageDataGL(size_t dimensionality, const tgt::svec3& size, const WeaklyTypedPointer& wtp)
: ImageData(dimensionality, size)
{
......
......@@ -50,6 +50,25 @@ namespace campvis {
*/
class ImageDataGL : public ImageData {
public:
/**
* Creates and returns new ImageDataGL representation from a tgt::Texture.
* The caller takes ownership of the returned pointer.
*
* \note This static factory method serves mainly for convenience to automatically
* calculate the dimensionality and size of the texture.
* \param texture OpenGL texture to use, must not be 0, ImageDataGL will take ownership of this texture.
*/
static ImageDataGL* createFromTexture(tgt::Texture* texture);
/**
* Creates a new ImageDataGL representation from a tgt::Texture.
*
* \param dimensionality Dimensionality of data
* \param size Size of this image (number of elements per dimension)
* \param texture OpenGL texture to use, must not be 0, ImageDataGL will take ownership of this texture.
*/
ImageDataGL(size_t dimensionality, const tgt::svec3& size, tgt::Texture* texture);
/**
* Creates a new ImageDataGL representation.
*
......@@ -76,7 +95,6 @@ namespace campvis {
*/
virtual ~ImageDataGL();
/**
* \see AbstractData::clone()
......
......@@ -82,11 +82,11 @@ SET(TGT_SOURCES
# define library target
################################################################################
ADD_LIBRARY(tgt ${TGT_SOURCES} ${TGT_HEADERS})
ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CAMPVIS_MODULE_DEFINITIONS} ${QT_DEFINITIONS})
ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisModulesDefinitions} ${QT_DEFINITIONS})
IF(CAMPVIS_SHARED_LIBS AND MSVC)
ADD_DEFINITIONS("-DTGT_BUILD_DLL")
ENDIF()
INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CAMPVIS_MODULE_INCLUDE_DIRECTORIES})
INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CampvisModulesIncludeDirs})
TARGET_LINK_LIBRARIES(tgt ${CampvisGlobalExternalLibs} ${QT_LIBRARIES})
################################################################################
......
# CMake file for DevIL module
# Tell TGT that we have the DevIL module
LIST(APPEND ThisModDefinitions -DTGT_HAS_DEVIL)
IF(UNIX)
# Unix-like systems have their DevIL lib via their package manager
FIND_PACKAGE(DevIL REQUIRED)
IF(IL_FOUND)
SET(ThisModIncludeDirs ${IL_INCLUDE_DIR})
SET(ThisModExternalLibs ${IL_LIBRARIES} ${ILU_LIBRARIES})
MESSAGE(STATUS "** Found DevIL library")
ELSE()
MESSAGE(FATAL_ERROR "Could not find DevIL library. Check your package manager to make sure DevIL is installed on your system.")
ENDIF()
ELSEIF(WIN32)
# DevIL libs for Windows systems are shipped with this module, make sure they're copied to the dist folder.
SET(ThisModIncludeDirs "${ThisModDir}/ext/devil/include")
IF(CAMPVIS_WIN32)
SET(ThisModExternalLibs
"${ThisModDir}/ext/devil/lib/win32/DevIL.lib"
"${ThisModDir}/ext/devil/lib/win32/ILU.lib"
)
LIST(APPEND CampvisExternalDllsDebug
"${ThisModDir}/ext/devil/lib/win32/DevIL.dll"
"${ThisModDir}/ext/devil/lib/win32/ILU.dll"
)
LIST(APPEND CampvisExternalDllsRelease
"${ThisModDir}/ext/devil/lib/win32/DevIL.dll"
"${ThisModDir}/ext/devil/lib/win32/ILU.dll"
)
ELSEIF(CAMPVIS_WIN64)
SET(ThisModExternalLibs
"${ThisModDir}/ext/devil/lib/win64/DevIL.lib"
"${ThisModDir}/ext/devil/lib/win64/ILU.lib"
)
LIST(APPEND CampvisExternalDllsDebug
"${ThisModDir}/ext/devil/lib/win64/DevIL.dll"
"${ThisModDir}/ext/devil/lib/win64/ILU.dll"
)
LIST(APPEND CampvisExternalDllsRelease
"${ThisModDir}/ext/devil/lib/win64/DevIL.dll"
"${ThisModDir}/ext/devil/lib/win64/ILU.dll"
)
ENDIF()
# LIST(APPEND MOD_DEBUG_DLLS "${ThisModDir}/ext/jpeg/jpeg62.dll")
# LIST(APPEND MOD_RELEASE_DLLS "${ThisModDir}/ext/jpeg/jpeg62.dll")
ENDIF()
# Source files:
FILE(GLOB ThisModSources RELATIVE ${ModulesDir}
modules/devil/processors/*.cpp
)
# Header files
FILE(GLOB ThisModHeaders RELATIVE ${ModulesDir}
modules/devil/processors/*.h
)
/* include/IL/config.h. Generated by configure. */
/* include/IL/config.h.in. Generated from configure.in by autoheader. */
#ifndef __CONFIG_H__
#define __CONFIG_H__
#define IL_USE_PRAGMA_LIBS
// Supported image formats (IL)
// #define IL_NO_BLP
// #define IL_NO_BMP
// #define IL_NO_CUT
// #define IL_NO_CHEAD
// #define IL_NO_DCX
// #define IL_NO_DDS
// #define IL_NO_DICOM
// #define IL_NO_DOOM
// #define IL_NO_EXR
// #define IL_NO_FITS
// #define IL_NO_FTX
// #define IL_NO_GIF
// #define IL_NO_HDR
// #define IL_NO_ICO
// #define IL_NO_ICNS
// #define IL_NO_IWI
// #define IL_NO_JP2
// #define IL_NO_JPG
// #define IL_NO_LCMS
// #define IL_NO_LIF
// #define IL_NO_MDL
// #define IL_NO_MNG
// #define IL_NO_PCD
// #define IL_NO_PCX
// #define IL_NO_PIC
// #define IL_NO_PIX
// #define IL_NO_PNG
// #define IL_NO_PNM
// #define IL_NO_PSD
// #define IL_NO_PSP
// #define IL_NO_PXR
// #define IL_NO_RAW
// #define IL_NO_ROT
// #define IL_NO_SGI
// #define IL_NO_SUN
// #define IL_NO_TGA
// #define IL_NO_TIF
// #define IL_NO_TPL
// #define IL_NO_WAL
// #define IL_NO_WDP
// #define IL_NO_XPM
#define IL_USE_JPEGLIB_UNMODIFIED 1
//#define IL_USE_DXTC_NVIDIA
#define IL_USE_DXTC_SQUISH
/* Supported api (ilut) */
//
// sorry just
// cant get this one to work under windows
// have disabled for the now
//
// will look at it some more later
//
// Kriss
//
#undef ILUT_USE_ALLEGRO
#undef ILUT_USE_DIRECTX8
//#define ILUT_USE_DIRECTX9
//#define ILUT_USE_DIRECTX10
//#define ILUT_USE_OPENGL
//#define ILUT_USE_SDL
//#define ILUT_USE_WIN32
/* Define to 1 if you have the <dlfcn.h> header file. */
//#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
//#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
//#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <stdint.h> header file. */
//#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
//#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
//#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
//#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
//#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
//#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
//#define HAVE_UNISTD_H 1
/* Name of package */
#define IL_PACKAGE "DevIL"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define IL_PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define IL_PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define IL_PACKAGE_TARNAME ""
/* Define to the version of this package. */
#define IL_PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
//#define IL_VERSION "1.7.3"
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* If using Mac OS X uncomment this line */
/* #include "macconfig.h" */
/* Define to 1 if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
#endif /* __CONFIG_H__ */
#ifndef __CONFIG_H__
#define __CONFIG_H__
#define IL_USE_PRAGMA_LIBS // Links to only the libraries that are requested.
#define IL_INLINE_ASM 1 // Define if you can support at least some ASM
// Supported images formats (IL)
// #define IL_NO_BLP
// #define IL_NO_BMP
// #define IL_NO_CUT
// #define IL_NO_CHEAD
// #define IL_NO_DCX
// #define IL_NO_DDS
// #define IL_NO_DICOM
// #define IL_NO_DOOM
// #define IL_NO_EXR
// #define IL_NO_FITS
// #define IL_NO_FTX
// #define IL_NO_GIF
// #define IL_NO_HDR
// #define IL_NO_ICO
// #define IL_NO_ICNS
// #define IL_NO_IWI
// #define IL_NO_JP2
// #define IL_NO_JPG
// #define IL_NO_LCMS
// #define IL_NO_LIF
// #define IL_NO_MDL
// #define IL_NO_MNG
// #define IL_NO_PCD
// #define IL_NO_PCX
// #define IL_NO_PIC
// #define IL_NO_PIX
// #define IL_NO_PNG
// #define IL_NO_PNM
// #define IL_NO_PSD
// #define IL_NO_PSP
// #define IL_NO_PXR
// #define IL_NO_RAW
// #define IL_NO_ROT
// #define IL_NO_SGI
// #define IL_NO_SUN
// #define IL_NO_TGA
// #define IL_NO_TIF
// #define IL_NO_TPL
// #define IL_NO_WAL
// #define IL_NO_WDP
// #define IL_NO_XPM
#define IL_USE_JPEGLIB_UNMODIFIED 1
#define IL_USE_DXTC_NVIDIA
#define IL_USE_DXTC_SQUISH
//#define IL_NO_GAMES
/* Supported api (ilut) */
//
// sorry just
// cant get this one to work under windows
// have disabled for the now
//
// will look at it some more later
//
// Kriss
//
#undef ILUT_USE_ALLEGRO
#undef ILUT_USE_DIRECTX8
#define ILUT_USE_DIRECTX9
#define ILUT_USE_DIRECTX10
#define ILUT_USE_OPENGL
#define ILUT_USE_SDL
#define ILUT_USE_WIN32
#endif /* __CONFIG_H__ */
//-----------------------------------------------------------------------------
//
// ImageLib Sources
// Copyright (C) 2000-2009 by Denton Woods
// Last modified: 01/06/2009
//
// Filename: IL/devil_internal_exports.h
//
// Description: Internal stuff for DevIL (IL, ILU and ILUT)
//
//-----------------------------------------------------------------------------
#ifndef IL_EXPORTS_H
#define IL_EXPORTS_H
#include "IL/il.h"
#ifdef DEBUG
#include <assert.h>
#else
#define assert(x)
#endif
//#ifndef NOINLINE
#ifndef INLINE
#if defined(__GNUC__)
#define INLINE extern inline
#elif defined(_MSC_VER) //@TODO: Get this working in MSVC++.
// http://www.greenend.org.uk/rjk/2003/03/inline.html
#define NOINLINE
//#define INLINE
/*#ifndef _WIN64 // Cannot use inline assembly in x64 target platform.
#define USE_WIN32_ASM
#endif//_WIN64*/
#define INLINE __inline
#else
#define INLINE inline
#endif
#endif
//#else
//#define INLINE
//#endif //NOINLINE
#ifdef __cplusplus
extern "C" {
#endif
#define IL_MAX(a,b) (((a) > (b)) ? (a) : (b))
#define IL_MIN(a,b) (((a) < (b)) ? (a) : (b))
//! Basic Palette struct
typedef struct ILpal
{
ILubyte* Palette; //!< the image palette (if any)
ILuint PalSize; //!< size of the palette (in bytes)
ILenum PalType; //!< the palette types in il.h (0x0500 range)
} ILpal;
//! The Fundamental Image structure
/*! Every bit of information about an image is stored in this internal structure.*/
typedef struct ILimage
{
ILuint Width; //!< the image's width
ILuint Height; //!< the image's height
ILuint Depth; //!< the image's depth
ILubyte Bpp; //!< bytes per pixel (now number of channels)
ILubyte Bpc; //!< bytes per channel
ILuint Bps; //!< bytes per scanline (components for IL)
ILubyte* Data; //!< the image data
ILuint SizeOfData; //!< the total size of the data (in bytes)
ILuint SizeOfPlane; //!< SizeOfData in a 2d image, size of each plane slice in a 3d image (in bytes)
ILenum Format; //!< image format (in IL enum style)
ILenum Type; //!< image type (in IL enum style)
ILenum Origin; //!< origin of the image
ILpal Pal; //!< palette details
ILuint Duration; //!< length of the time to display this "frame"
ILenum CubeFlags; //!< cube map flags for sides present in chain
struct ILimage* Mipmaps; //!< mipmapped versions of this image terminated by a NULL - usu. NULL
struct ILimage* Next; //!< next image in the chain - usu. NULL
struct ILimage* Faces; //!< next cubemap face in the chain - usu. NULL
struct ILimage* Layers; //!< subsequent layers in the chain - usu. NULL
ILuint* AnimList; //!< animation list
ILuint AnimSize; //!< animation list size
void* Profile; //!< colour profile
ILuint ProfileSize; //!< colour profile size
ILuint OffX; //!< x-offset of the image
ILuint OffY; //!< y-offset of the image
ILubyte* DxtcData; //!< compressed data
ILenum DxtcFormat; //!< compressed data format
ILuint DxtcSize; //!< compressed data size
} ILimage;
// Memory functions
ILAPI void* ILAPIENTRY ialloc(const ILsizei Size);
ILAPI void ILAPIENTRY ifree(const void *Ptr);
ILAPI void* ILAPIENTRY icalloc(const ILsizei Size, const ILsizei Num);
#ifdef ALTIVEC_GCC
ILAPI void* ILAPIENTRY ivec_align_buffer(void *buffer, const ILuint size);
#endif
// Internal library functions in IL
ILAPI ILimage* ILAPIENTRY ilGetCurImage(void);
ILAPI void ILAPIENTRY ilSetCurImage(ILimage *Image);
ILAPI void ILAPIENTRY ilSetError(ILenum Error);
ILAPI void ILAPIENTRY ilSetPal(ILpal *Pal);
//
// Utility functions
//
ILAPI ILubyte ILAPIENTRY ilGetBppFormat(ILenum Format);
ILAPI ILenum ILAPIENTRY ilGetFormatBpp(ILubyte Bpp);
ILAPI ILubyte ILAPIENTRY ilGetBpcType(ILenum Type);
ILAPI ILenum ILAPIENTRY ilGetTypeBpc(ILubyte Bpc);
ILAPI ILubyte ILAPIENTRY ilGetBppPal(ILenum PalType);
ILAPI ILenum ILAPIENTRY ilGetPalBaseType(ILenum PalType);
ILAPI ILuint ILAPIENTRY ilNextPower2(ILuint Num);
ILAPI ILenum ILAPIENTRY ilTypeFromExt(ILconst_string FileName);
ILAPI void ILAPIENTRY ilReplaceCurImage(ILimage *Image);
ILAPI void ILAPIENTRY iMemSwap(ILubyte *, ILubyte *, const ILuint);
//
// Image functions
//
ILAPI void ILAPIENTRY iBindImageTemp (void);
ILAPI ILboolean ILAPIENTRY ilClearImage_ (ILimage *Image);
ILAPI void ILAPIENTRY ilCloseImage (ILimage *Image);
ILAPI void ILAPIENTRY ilClosePal (ILpal *Palette);
ILAPI ILpal* ILAPIENTRY iCopyPal (void);
ILAPI ILboolean ILAPIENTRY ilCopyImageAttr (ILimage *Dest, ILimage *Src);
ILAPI ILimage* ILAPIENTRY ilCopyImage_ (ILimage *Src);
ILAPI void ILAPIENTRY ilGetClear (void *Colours, ILenum Format, ILenum Type);
ILAPI ILuint ILAPIENTRY ilGetCurName (void);
ILAPI ILboolean ILAPIENTRY ilIsValidPal (ILpal *Palette);
ILAPI ILimage* ILAPIENTRY ilNewImage (ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILubyte Bpc);
ILAPI ILimage* ILAPIENTRY ilNewImageFull (ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
ILAPI ILboolean ILAPIENTRY ilInitImage (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
ILAPI ILboolean ILAPIENTRY ilResizeImage (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILubyte Bpc);
ILAPI ILboolean ILAPIENTRY ilTexImage_ (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
ILAPI ILboolean ILAPIENTRY ilTexSubImage_ (ILimage *Image, void *Data);
ILAPI void* ILAPIENTRY ilConvertBuffer (ILuint SizeOfData, ILenum SrcFormat, ILenum DestFormat, ILenum SrcType, ILenum DestType, ILpal *SrcPal, void *Buffer);
ILAPI ILimage* ILAPIENTRY iConvertImage (ILimage *Image, ILenum DestFormat, ILenum DestType);
ILAPI ILpal* ILAPIENTRY iConvertPal (ILpal *Pal, ILenum DestFormat);
ILAPI ILubyte* ILAPIENTRY iGetFlipped (ILimage *Image);
ILAPI ILboolean ILAPIENTRY iMirror();
ILAPI void ILAPIENTRY iFlipBuffer(ILubyte *buff, ILuint depth, ILuint line_size, ILuint line_num);
ILubyte* iFlipNewBuffer(ILubyte *buff, ILuint depth, ILuint line_size, ILuint line_num);
ILAPI void ILAPIENTRY iGetIntegervImage(ILimage *Image, ILenum Mode, ILint *Param);
// Internal library functions in ILU
ILAPI ILimage* ILAPIENTRY iluRotate_(ILimage *Image, ILfloat Angle);
ILAPI ILimage* ILAPIENTRY iluRotate3D_(ILimage *Image, ILfloat x, ILfloat y, ILfloat z, ILfloat Angle);
ILAPI ILimage* ILAPIENTRY iluScale_(ILimage *Image, ILuint Width, ILuint Height, ILuint Depth);
#ifdef __cplusplus
}
#endif
#endif//IL_EXPORTS_H
This diff is collapsed.
#ifndef WRAPPER_H
#define WRAPPER_H
/*#include <il/il.h>
#include <il/ilu.h>*/
#include <IL/ilut.h> // Probably only have to #include this one
#ifdef _MSC_VER
#ifndef _IL_WRAP_BUILD_LIB
#pragma comment(lib, "il_wrap.lib")
#endif
#endif
class ilImage
{
public:
ilImage();
ilImage(char *);
ilImage(const ilImage &);
virtual ~ilImage();
ILboolean Load(char *);
ILboolean Load(char *, ILenum);
ILboolean Save(char *);
ILboolean Save(char *, ILenum);
// ImageLib functions
ILboolean ActiveImage(ILuint);
ILboolean ActiveLayer(ILuint);
ILboolean ActiveMipmap(ILuint);
ILboolean Clear(void);
ILvoid ClearColour(ILclampf, ILclampf, ILclampf, ILclampf);
ILboolean Convert(ILenum);
ILboolean Copy(ILuint);
ILboolean Default(void);
ILboolean Flip(void);
ILboolean SwapColours(void);
ILboolean Resize(ILuint, ILuint, ILuint);
ILboolean TexImage(ILuint, ILuint, ILuint, ILubyte, ILenum, ILenum, ILvoid*);
// Image handling
ILvoid Bind(void) const;
ILvoid Bind(ILuint);
ILvoid Close(void) { this->Delete(); }
ILvoid Delete(void);
ILvoid iGenBind();
ILenum PaletteAlphaIndex();
// Image characteristics
ILuint Width(void);
ILuint Height(void);
ILuint Depth(void);
ILubyte Bpp(void);
ILubyte Bitpp(void);
ILenum PaletteType(void);
ILenum Format(void);
ILenum Type(void);
ILuint NumImages(void);
ILuint NumMipmaps(void);
ILuint GetId(void) const;
ILenum GetOrigin(void);
ILubyte *GetData(void);
ILubyte *GetPalette(void);
// Rendering
ILuint BindImage(void);
ILuint BindImage(ILenum);
// Operators
ilImage& operator = (ILuint);
ilImage& operator = (const ilImage &);
protected:
ILuint Id;
private:
ILvoid iStartUp();