mirror of
https://github.com/love2d/megasource.git
synced 2026-08-17 19:24:09 +02:00
Add DevIL 1.7.8.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// Almost identical to Allegro's ex15.c
|
||||
|
||||
#include <IL/il.h>
|
||||
#include <IL/ilu.h>
|
||||
#include <IL/ilut.h>
|
||||
#include <allegro.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BITMAP *Image;
|
||||
PALETTE Pal;
|
||||
ILuint Id;
|
||||
|
||||
if (argc != 2) {
|
||||
printf("Please specify a filename.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ilInit();
|
||||
ilGenImages(1, &Id);
|
||||
ilBindImage(Id);
|
||||
ilLoadImage(argv[1]);
|
||||
|
||||
// if (ilGetInteger(IL_IMAGE_FORMAT) == GL_BGR ||
|
||||
// ilGetInteger(IL_IMAGE_FORMAT) == GL_BGRA)
|
||||
ilSwapColours();
|
||||
|
||||
Image = (BITMAP*)ilutConvertToAlleg(Pal);
|
||||
|
||||
allegro_init();
|
||||
install_keyboard();
|
||||
if (ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL) == 8) {
|
||||
set_color_depth(8);
|
||||
set_palette(Pal);
|
||||
}
|
||||
else
|
||||
set_color_depth(32);
|
||||
set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
|
||||
|
||||
blit(Image, screen, 0, 0, (SCREEN_W - Image->w) / 2,
|
||||
(SCREEN_H - Image->h) / 2, Image->w, Image->h);
|
||||
|
||||
destroy_bitmap(Image);
|
||||
|
||||
readkey();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user