www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - CFTE+DevIL=?

reply "Zhenya" <zheny list.ru> writes:
Hi!
I need to load some textures for my game,but I woud like to do it 
in compile time.
I know that CTFE imposes restrictions on functions.So can I 
execute some DevIL(Derelict3) functions?
Oct 08 2012
next sibling parent Piotr Szturmaj <bncrbme jadamspam.pl> writes:
Zhenya wrote:
 Hi!
 I need to load some textures for my game,but I woud like to do it in
 compile time.
 I know that CTFE imposes restrictions on functions.So can I execute some
 DevIL(Derelict3) functions?
CTFE can only evaluate D functions that have their bodies available. It means that external code coming from C or D external library can't be evaluated.
Oct 08 2012
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2012-10-08 15:24, Zhenya wrote:
 Hi!
 I need to load some textures for my game,but I woud like to do it in
 compile time.
 I know that CTFE imposes restrictions on functions.So can I execute some
 DevIL(Derelict3) functions?
What you can do is importing the textures into the executable, at compile time, if that helps: http://dlang.org/expression.html#ImportExpression -- /Jacob Carlborg
Oct 08 2012
parent "Mike Parker" <aldacron gmail.com> writes:
On Monday, 8 October 2012 at 18:07:49 UTC, Jacob Carlborg wrote:
 On 2012-10-08 15:24, Zhenya wrote:
 Hi!
 I need to load some textures for my game,but I woud like to do 
 it in
 compile time.
 I know that CTFE imposes restrictions on functions.So can I 
 execute some
 DevIL(Derelict3) functions?
What you can do is importing the textures into the executable, at compile time, if that helps: http://dlang.org/expression.html#ImportExpression
That can bring the image into the app as an array of bytes. Then at runtime, you can use DevIL to load the image data from the byte array. I've got a blog post[1] about doing this very thing (with SDL rather than DevIL, but it's all the same). [1] http://www.gamedev.net/blog/1140/entry-2254294-compiling-data-into-a-d-executable/
Oct 08 2012