View previous topic :: View next topic |
Author |
Message |
dav1d
Joined: 12 Sep 2011 Posts: 40
|
Posted: Wed Jan 18, 2012 1:25 pm Post subject: DevIL |
|
|
I am trying to run this code and I keep getting a segmentation fault from ilLoadImage, I already checked, the function is not null. I alos tried a relative and absolute path! If I pass the result of toStringz to ilLoadImage, the same happens.
I am on 32bit archlinux, latest dmd (2.057), and derelict2-svn, 601 since the current fails to build. Code: | make[1]: Entering directory `/tmp/yaourt-tmp-dav1d/aur-derelict2-svn/src/Derelict2/DerelictFT'
dmd -release -O -inline -lib -I../DerelictUtil derelict/freetype/ft.d derelict/freetype/ftfuncs.d derelict/freetype/fttypes.d -Hd/tmp/yaourt-tmp-dav1d/aur-derelict2-svn/pkg/usr/include/d2/derelict/freetype -oflibDerelictFT.a
derelict/freetype/ftfuncs.d(115): Error: undefined identifier FR_Face, did you mean alias FT_Face?
|
Code: | import derelict.opengl.gl;
import derelict.sdl.sdl;
import derelict.devil.il;
import derelict.devil.ilu;
import derelict.devil.ilut;
import derelict.util.exception;
static this() {
DerelictSDL.load();
DerelictGL.load();
DerelictIL.load();
DerelictILU.load();
DerelictILUT.load();
}
struct TextureHandle {
ILuint id;
ILubyte* data;
ILint width;
ILint height;
this(ILuint id_, ILubyte* d, ILint w, ILint h) {
data = d;
id = id_;
width = w;
height = h;
}
}
TextureHandle load_image_devil(const(char)* filename) {
//origin bottom left?
ILuint id;
ilGenImages(1, &id);
ilBindImage(id);
if(!ilLoadImage(filename)) {
throw new Exception(format("loading the image \"%s\" failed!", filename));
}
writefln("before convert");
ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);
return TextureHandle(id, ilGetData(), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT));
}
void main() {TextureHandle t = load_image_devil("woodcrate.jpg"); } |
|
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Wed Jan 18, 2012 11:07 pm Post subject: Re: DevIL |
|
|
dav1d wrote: | I am trying to run this code and I keep getting a segmentation fault from ilLoadImage, I already checked, the function is not null. I alos tried a relative and absolute path! If I pass the result of toStringz to ilLoadImage, the same happens. |
In the code you posted, I don't see any call to ilInit. Perhaps that is the problem? You need to call that before attempting to load any images. The DevIL documentation says not doing so will almost certainly result in a crash. You'll also need to call iluInit and ilutInit if you plan to use those.
Quote: | I am on 32bit archlinux, latest dmd (2.057), and derelict2-svn, 601 since the current fails to build. |
Sorry, my fault. I haven't tested the build after the last few updates. For future reference, though, you don't need to build everything if you only need a few packages. In this case you could have done this (as specified in the docs), rather than working with an older revision:
Code: |
make -flinux.mak DC=dmd DerelictUtil DerelictGL DerelictSDL DerelictIL_ALL |
_________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
dav1d
Joined: 12 Sep 2011 Posts: 40
|
Posted: Thu Jan 19, 2012 11:38 am Post subject: |
|
|
Thanks, that was it!
=> DevIL documentation sucks…
Btw. I am using the AUR pkgbuild to build it. |
|
Back to top |
|
|
bioinfornatics
Joined: 22 Jun 2010 Posts: 90
|
Posted: Thu Jan 19, 2012 11:56 am Post subject: |
|
|
But it seem DevIL-ILUT do not exist on AUR |
|
Back to top |
|
|
dav1d
Joined: 12 Sep 2011 Posts: 40
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|