DevIL (OpenIL)

Since LWJGL is becoming very stable, what do you think of making a binding of DevIL (also know as OpenIL) ? It could be in a separated package, but I think it can be pretty interesting because it works evry well, support a large amount of image format and its usage is very similar to OpenGL, so it can be integrated with OpenGL without the need of AWT or SWING…

It’s just an idea…

http://openil.sourceforge.net/

Chman

I have actually been thinking about this for quite some time too - alas I am busy enough with lwjgl/fmod. If someone wants to commit to it, we can include it in lwjgl and host it in the CVS too. Unless ofcourse said project doesn’t want to be under the lwjgl “umbrella”.
But yes - DevIL is a perfect match for lwjgl!

That would be so incretibly cool. I’ld do it myself if I could :frowning: There definantly is a want for such a thing.

Ooooh! Me like!!! Could do with removing support for most of those wacky formats though and just leaving the important ones.

Cas :slight_smile:

Just curious…

What is the point? The JDK comes with loaders for JPG and PNG, and as I recall, Cas used a custom format for Alien Flux anyway.

When you are ready to deploy the game the end result only has to load the image format that you have settled on. It might make more sense to just have a conversion tool that gets images into a custom format. Keep the size of the downloads small.

[quote]Currently, DevIL can load .bmp, .cut, .dds, .doom, .gif, .ico, .jpg, .lbm, .mdl, .mng, .pal, .pbm, .pcd, .pcx, .pgm, .pic, .png, .ppm, .psd, .psp, .raw, .sgi, .tga and .tif files.
Formats supported for saving include .bmp, .dds, .h, .jpg, .pal, .pbm, .pcx, .pgm,.png, .ppm, .raw, .sgi, .tga and .tif.
[/quote]
That’s way too much.

load: dds, gif, jpg, png, tga
write: tga

That would be enough imo. Well, gif could be thrown out as well… it rarely smaller than 8bit pngs.

It’s jpeg loading from bytestreams that interests me the most. I currently have a dependency in Super Elvis on AWT as a result of jpeg loading.

Cas :slight_smile:

ive noticed it takes 1500~ millis for a png to a jpg to load via Java’s own loaders into OpenGL using LWJGL. However, with a customisable TGA Loader, it takes around 70 millis. So loading via Java’s own loaders are a bit too slow.

So all in all, i think this would be a great addition to lwjgl.

DP

TGA vs PNG loading? Isn’t that a little unfair :slight_smile:

Kev

[quote]What is the point? The JDK comes with loaders for JPG and PNG, and as I recall, Cas used a custom format for Alien Flux anyway.

When you are ready to deploy the game the end result only has to load the image format that you have settled on. It might make more sense to just have a conversion tool that gets images into a custom format.
[/quote]
If we had a fast/non-awt way of reading images, most custom formats/loaders would be unnecessary.

+1 from me.

[quote]TGA vs PNG loading? Isn’t that a little unfair :slight_smile:
[/quote]
Hm… well extremely zipped TGAs are just about 10% bigger than PNGs. If it still loads much faster and your download gets only 100-200kb bigger it might be a good option.

FYI kzip performed a bit better (~1%) than 7zip. Eventually you can get rid of some more bytes by testing several command line switches (both programms).

Well, the images I used for testing are much smaller (only 1/6) as jpg (without any visible loss). So it’s always a good idea to check which format suits best.

Sorry, I’d made the assumption that the TGA loader in question was home brew loosely based on the shabby version contained in nearly every texture loading OpenGL example for C++ in existence.

It makes it look really good but of course only loads a particular format of TGA, i.e. raw and uncompressed. It was at the point be very unstandable why PNG would take considerably longer than TGA.

Kev

raw and uncompressed

Yea yea… raw and uncompressed… it’s already compressed, because it’s jared (wereas all other formats get compressed twice without any noticeable gain from the second [jar] stage).

edit:

On a second thought. Benchmarking should also take “stored” compressed formats into account (so no additional compression for png). That should be a bit faster then.

So, what do you think, should we make the OpenIL a native binding or should we make it in pure java ?

Personnally I vote for the pure java version…

Chman

definately a binding. Doing it injava would be a waste of time - people could just as well use ImageIO then.

I started converting the constants into Java. So here are
the files IL.java, ILU.java and ILUT.java.

IL.java:

package org.devil;

public class IL {
      
      public static int IL_FALSE = 0;
      public static int IL_TRUE = 1;
      
      // Matches OpenGL's right now.
      public static int IL_COLOUR_INDEX = 0x1900;
      public static int IL_COLOR_INDEX = 0x1900;
      public static int IL_RGB = 0x1907;
      public static int IL_RGBA = 0x1908;
      public static int IL_BGR = 0x80E0;
      public static int IL_BGRA = 0x80E1;
      public static int IL_LUMINANCE = 0x1909;
      
      public static int IL_BYTE = 0x1400;
      public static int IL_UNSIGNED_BYTE = 0x1401;
      public static int IL_SHORT = 0x1402;
      public static int IL_UNSIGNED_SHORT = 0x1403;
      public static int IL_INT = 0x1404;
      public static int IL_UNSIGNED_INT = 0x1405;
      public static int IL_FLOAT = 0x1406;
      public static int IL_DOUBLE = 0x140A;
      
      public static int IL_VENDOR = 0x1F00;
      
      // IL-specific public const's
      public static int IL_VERSION_1_6_0 = 1;
      public static int IL_VERSION = 160;
      public static int IL_LOAD_EXT = 0x1F01;
      public static int IL_SAVE_EXT = 0x1F02;
      
      // Attribute Bits
      public static int IL_ORIGIN_BIT = 0x1;
      public static int IL_FILE_BIT = 0x2;
      public static int IL_PAL_BIT = 0x4;
      public static int IL_FORMAT_BIT = 0x8;
      public static int IL_TYPE_BIT = 0x10;
      public static int IL_COMPRESS_BIT = 0x20;
      public static int IL_LOADFAIL_BIT = 0x40;
      public static int IL_FORMAT_SPECIFIC_BIT = 0x80;
      public static int IL_ALL_ATTRIB_BITS = 0xFFFFF;
      
      // Palette types
      public static int IL_PAL_NONE = 0x400;
      public static int IL_PAL_RGB24 = 0x401;
      public static int IL_PAL_RGB32 = 0x402;
      public static int IL_PAL_RGBA32 = 0x403;
      public static int IL_PAL_BGR24 = 0x404;
      public static int IL_PAL_BGR32 = 0x405;
      public static int IL_PAL_BGRA32 = 0x406;
      
      // Image types
      public static int IL_TYPE_UNKNOWN = 0x0;
      public static int IL_BMP = 0x420;
      public static int IL_CUT = 0x421;
      public static int IL_DOOM = 0x422;
      public static int IL_DOOM_FLAT = 0x423;
      public static int IL_ICO = 0x424;
      public static int IL_JPG = 0x425;
      public static int IL_LBM = 0x426;
      public static int IL_PCD = 0x427;
      public static int IL_PCX = 0x428;
      public static int IL_PIC = 0x429;
      public static int IL_PNG = 0x42A;
      public static int IL_PNM = 0x42B;
      public static int IL_SGI = 0x42C;
      public static int IL_TGA = 0x42D;
      public static int IL_TIF = 0x42E;
      public static int IL_CHEAD = 0x42F;
      public static int IL_RAW = 0x430;
      public static int IL_MDL = 0x431;
      public static int IL_WAL = 0x432;
      public static int IL_OIL = 0x433;
      public static int IL_LIF = 0x434;
      public static int IL_MNG = 0x435;
      public static int IL_JNG = 0x435;
      public static int IL_GIF = 0x436;
      public static int IL_DDS = 0x437;
      public static int IL_DCX = 0x438;
      public static int IL_PSD = 0x439;
      public static int IL_EXIF = 0x43A;
      public static int IL_PSP = 0x43B;
      public static int IL_PIX = 0x43C;
      public static int IL_PXR = 0x43D;
      public static int IL_XPM = 0x43E;
      
      public static int IL_JASC_PAL = 0x475;
      
      // Error Types
      public static int IL_NO_ERROR = 0x0;
      public static int IL_INVALID_ENUM = 0x501;
      public static int IL_OUT_OF_MEMORY = 0x502;
      public static int IL_FORMAT_NOT_SUPPORTED = 0x503;
      public static int IL_INTERNAL_ERROR = 0x504;
      public static int IL_INVALID_VALUE = 0x505;
      public static int IL_ILLEGAL_OPERATION = 0x506;
      public static int IL_ILLEGAL_FILE_VALUE = 0x507;
      public static int IL_INVALID_FILE_HEADER = 0x508;
      public static int IL_INVALID_PARAM = 0x509;
      public static int IL_COULD_NOT_OPEN_FILE = 0x50A;
      public static int IL_INVALID_EXTENSION = 0x50B;
      public static int IL_FILE_ALREADY_EXISTS = 0x50C;
      public static int IL_OUT_FORMAT_SAME = 0x50D;
      public static int IL_STACK_OVERFLOW = 0x50E;
      public static int IL_STACK_UNDERFLOW = 0x50F;
      public static int IL_INVALID_CONVERSION = 0x510;
      public static int IL_BAD_DIMENSIONS = 0x511;
      public static int IL_FILE_READ_ERROR = 0x512;
      
      public static int IL_LIB_GIF_ERROR = 0x5E1;
      public static int IL_LIB_JPEG_ERROR = 0x5E2;
      public static int IL_LIB_PNG_ERROR = 0x5E3;
      public static int IL_LIB_TIFF_ERROR = 0x5E4;
      public static int IL_LIB_MNG_ERROR = 0x5E5;
      public static int IL_UNKNOWN_ERROR = 0x5FF;
      
      // Origin Definitions
      public static int IL_ORIGIN_SET = 0x600;
      public static int IL_ORIGIN_LOWER_LEFT = 0x601;
      public static int IL_ORIGIN_UPPER_LEFT = 0x602;
      public static int IL_ORIGIN_MODE = 0x603;
      
      // Format and Type Mode Definitions
      public static int IL_FORMAT_SET = 0x610;
      public static int IL_FORMAT_MODE = 0x611;
      public static int IL_TYPE_SET = 0x612;
      public static int IL_TYPE_MODE = 0x613;
      
      // File definitions
      public static int IL_FILE_OVERWRITE = 0x620;
      public static int IL_FILE_MODE = 0x621;
      
      // Palette definitions
      public static int IL_CONV_PAL = 0x630;
      
      // Load fail definitions
      public static int IL_DEFAULT_ON_FAIL = 0x632;
      
      // Key colour definitions
      public static int IL_USE_KEY_COLOUR = 0x635;
      public static int IL_USE_KEY_COLOR = 0x635;
      
      // Interlace definitions
      public static int IL_SAVE_INTERLACED = 0x639;
      public static int IL_INTERLACE_MODE = 0x63A;
      
      // Quantization definitions
      public static int IL_QUANTIZATION_MODE = 0x640;
      public static int IL_WU_QUANT = 0x641;
      public static int IL_NEU_QUANT = 0x642;
      public static int IL_NEU_QUANT_SAMPLE = 0x643;
      
      // Hints
      public static int IL_FASTEST = 0x660;
      public static int IL_LESS_MEM = 0x661;
      public static int IL_DONT_CARE = 0x662;
      public static int IL_MEM_SPEED_HINT = 0x665;
      public static int IL_USE_COMPRESSION = 0x666;
      public static int IL_NO_COMPRESSION = 0x667;
      public static int IL_COMPRESSION_HINT = 0x668;
      
      // Subimage types
      public static int IL_SUB_NEXT = 0x680;
      public static int IL_SUB_MIPMAP = 0x681;
      public static int IL_SUB_LAYER = 0x682;
      
      // Compression definitions (mostly for .oil)
      public static int IL_COMPRESS_MODE = 0x700;
      public static int IL_COMPRESS_NONE = 0x701;
      public static int IL_COMPRESS_RLE = 0x702;
      public static int IL_COMPRESS_LZO = 0x703;
      public static int IL_COMPRESS_ZLIB = 0x704;
      
      // File format-specific values
      public static int IL_TGA_CREATE_STAMP = 0x710;
      public static int IL_JPG_QUALITY = 0x711;
      public static int IL_PNG_INTERLACE = 0x712;
      public static int IL_TGA_RLE = 0x713;
      public static int IL_BMP_RLE = 0x714;
      public static int IL_SGI_RLE = 0x715;
      public static int IL_TGA_ID_STRING = 0x717;
      public static int IL_TGA_AUTHNAME_STRING = 0x718;
      public static int IL_TGA_AUTHCOMMENT_STRING = 0x719;
      public static int IL_PNG_AUTHNAME_STRING = 0x71A;
      public static int IL_PNG_TITLE_STRING = 0x71B;
      public static int IL_PNG_DESCRIPTION_STRING = 0x71C;
      public static int IL_TIF_DESCRIPTION_STRING = 0x71D;
      public static int IL_TIF_HOSTCOMPUTER_STRING = 0x71E;
      public static int IL_TIF_DOCUMENTNAME_STRING = 0x71F;
      public static int IL_TIF_AUTHNAME_STRING = 0x720;
      public static int IL_JPG_SAVE_FORMAT = 0x721;
      public static int IL_CHEAD_HEADER_STRING = 0x722;
      public static int IL_PCD_PICNUM = 0x723;
      
      // DXTC definitions
      public static int IL_DXTC_FORMAT = 0x705;
      public static int IL_DXT1 = 0x706;
      public static int IL_DXT2 = 0x707;
      public static int IL_DXT3 = 0x708;
      public static int IL_DXT4 = 0x709;
      public static int IL_DXT5 = 0x70A;
      public static int IL_DXT_NO_COMP = 0x70B;
      public static int IL_KEEP_DXTC_DATA = 0x70C;
      public static int IL_DXTC_DATA_FORMAT = 0x70D;
      
      // Cube map definitions
      public static int IL_CUBEMAP_POSITIVEX = 0x400;
      public static int IL_CUBEMAP_NEGATIVEX = 0x800;
      public static int IL_CUBEMAP_POSITIVEY = 0x1000;
      public static int IL_CUBEMAP_NEGATIVEY = 0x2000;
      public static int IL_CUBEMAP_POSITIVEZ = 0x4000;
      public static int IL_CUBEMAP_NEGATIVEZ = 0x8000;
      
      // Values
      public static int IL_VERSION_NUM = 0xDE2;
      public static int IL_IMAGE_WIDTH = 0xDE4;
      public static int IL_IMAGE_HEIGHT = 0xDE5;
      public static int IL_IMAGE_DEPTH = 0xDE6;
      public static int IL_IMAGE_SIZE_OF_DATA = 0xDE7;
      public static int IL_IMAGE_BPP = 0xDE8;
      public static int IL_IMAGE_BYTES_PER_PIXEL = 0xDE8;
      public static int IL_IMAGE_BITS_PER_PIXEL = 0xDE9;
      public static int IL_IMAGE_FORMAT = 0xDEA;
      public static int IL_IMAGE_TYPE = 0xDEB;
      public static int IL_PALETTE_TYPE = 0xDEC;
      public static int IL_PALETTE_SIZE = 0xDED;
      public static int IL_PALETTE_BPP = 0xDEE;
      public static int IL_PALETTE_NUM_COLS = 0xDEF;
      public static int IL_PALETTE_BASE_TYPE = 0xDF0;
      public static int IL_NUM_IMAGES = 0xDF1;
      public static int IL_NUM_MIPMAPS = 0xDF2;
      public static int IL_NUM_LAYERS = 0xDF3;
      public static int IL_ACTIVE_IMAGE = 0xDF4;
      public static int IL_ACTIVE_MIPMAP = 0xDF5;
      public static int IL_ACTIVE_LAYER = 0xDF6;
      public static int IL_CUR_IMAGE = 0xDF7;
      public static int IL_IMAGE_DURATION = 0xDF8;
      public static int IL_IMAGE_PLANESIZE = 0xDF9;
      public static int IL_IMAGE_BPC = 0xDFA;
      public static int IL_IMAGE_OFFX = 0xDFB;
      public static int IL_IMAGE_OFFY = 0xDFC;
      public static int IL_IMAGE_CUBEFLAGS = 0xDFD;
      
      public static int IL_SEEK_SET = 0;
      public static int IL_SEEK_CUR = 1;
      public static int IL_SEEK_END = 2;
      public static int IL_EOF = -1;
}

WiESi

ILU.java:

package org.devil;

public class ILU {
      
      public static int ILU_VERSION_1_6_0 = 1;
      public static int ILU_VERSION = 160;
      
      public static int ILU_FILTER = 0x2600;
      public static int ILU_NEAREST = 0x2601;
      public static int ILU_LINEAR = 0x2602;
      public static int ILU_BILINEAR = 0x2603;
      public static int ILU_SCALE_BOX = 0x2604;
      public static int ILU_SCALE_TRIANGLE = 0x2605;
      public static int ILU_SCALE_BELL = 0x2606;
      public static int ILU_SCALE_BSPLINE = 0x2607;
      public static int ILU_SCALE_LANCZOS3 = 0x2608;
      public static int ILU_SCALE_MITCHELL = 0x2609;
      
      // Error types
      public static int ILU_INVALID_ENUM = 0x501;
      public static int ILU_OUT_OF_MEMORY = 0x502;
      public static int ILU_INTERNAL_ERROR = 0x504;
      public static int ILU_INVALID_VALUE = 0x505;
      public static int ILU_ILLEGAL_OPERATION = 0x506;
      public static int ILU_INVALID_PARAM = 0x509;
            
      // Values
      public static int ILU_PLACEMENT = 0x700;
      public static int ILU_LOWER_LEFT = 0x701;
      public static int ILU_LOWER_RIGHT = 0x702;
      public static int ILU_UPPER_LEFT = 0x703;
      public static int ILU_UPPER_RIGHT = 0x704;
      public static int ILU_CENTER = 0x705;
      public static int ILU_CONVOLUTION_MATRIX = 0x710;
      public static int ILU_VERSION_NUM = 0xDE2;
      
      // Filters
      public static int ILU_FILTER_BLUR = 0x803;
      public static int ILU_FILTER_GAUSSIAN_3x3 = 0x804;
      public static int ILU_FILTER_GAUSSIAN_5X5 = 0x805;
      public static int ILU_FILTER_EMBOSS1 = 0x807;
      public static int ILU_FILTER_EMBOSS2 = 0x808;
      public static int ILU_FILTER_LAPLACIAN1 = 0x80A;
      public static int ILU_FILTER_LAPLACIAN2 = 0x80B;
      public static int ILU_FILTER_LAPLACIAN3 = 0x80C;
      public static int ILU_FILTER_LAPLACIAN4 = 0x80D;
      public static int ILU_FILTER_SHARPEN1 = 0x80E;
      public static int ILU_FILTER_SHARPEN2 = 0x80F;
      public static int ILU_FILTER_SHARPEN3 = 0x810;
}

ILUT.java:

package org.devil;

public class ILUT {
      
      public static int ILUT_VERSION_1_6_0 = 1;
      public static int ILUT_VERSION = 160;
      
      // Attribute Bits
      public static int ILUT_OPENGL_BIT = 0x1;
      public static int ILUT_D3D_BIT = 0x2;
      public static int ILUT_ALL_ATTRIB_BITS = 0xFFFFF;
      
      // Error Types
      public static int ILUT_INVALID_ENUM = 0x501;
      public static int ILUT_OUT_OF_MEMORY = 0x502;
      public static int ILUT_INVALID_VALUE = 0x505;
      public static int ILUT_ILLEGAL_OPERATION = 0x506;
      public static int ILUT_INVALID_PARAM = 0x509;
      public static int ILUT_COULD_NOT_OPEN_FILE = 0x50A;
      public static int ILUT_STACK_OVERFLOW = 0x50E;
      public static int ILUT_STACK_UNDERFLOW = 0x50F;
      public static int ILUT_NOT_SUPPORTED = 0x550;
      
      // State Definitions
      public static int ILUT_PALETTE_MODE = 0x600;
      public static int ILUT_OPENGL_CONV = 0x610;
      public static int ILUT_D3D_MIPLEVELS = 0x620;
      public static int ILUT_MAXTEX_WIDTH = 0x630;
      public static int ILUT_MAXTEX_HEIGHT = 0x631;
      public static int ILUT_MAXTEX_DEPTH = 0x632;
      public static int ILUT_GL_USE_S3TC = 0x634;
      public static int ILUT_D3D_USE_DXTC = 0x634;
      public static int ILUT_GL_GEN_S3TC = 0x635;
      public static int ILUT_D3D_GEN_DXTC = 0x635;
      public static int ILUT_S3TC_FORMAT = 0x705;
      public static int ILUT_DXTC_FORMAT = 0x706;
      
      // Values
      public static int ILUT_VERSION_NUM = 0xDE2;
      
      public static boolean ILUT_USE_ALLEGRO = false;
      public static boolean ILUT_USE_WIN32 = true;
      public static boolean ILUT_USE_OPENGL = true;
      
      // The different rendering api's...more to be added later?
      public static int ILUT_OPENGL = 0;
      public static int ILUT_ALLEGRO = 1;
      public static int ILUT_WIN32 = 2;
}

WiESi

I’ll give it a shot. Give me a few of days to get a bare bones implementation going. It doesn’t look hard to do it in JNI. Once I get something in there, you can decide if you want all portable features or just a subset.

[quote]definately a binding. Doing it injava would be a waste of time - people could just as well use ImageIO then.
[/quote]
So what’s the point at all then? If AWT dependance is the only problem, I’d suggest just a couple of most used file loaders (I’d guess only .png and .jpg should do) made in pure java instead of bringing in another .dll, .so etc. plus all required additional maintenance and deployment hassles.

Just my 2cts.

Porting the JPEG decoder ain’t gonna be fun :confused:

Cas :slight_smile: