CFTE+DevIL=?

2012-10-08 Thread Zhenya

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?


Re: CFTE+DevIL=?

2012-10-08 Thread Piotr Szturmaj

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.


Re: CFTE+DevIL=?

2012-10-08 Thread Jacob Carlborg

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


Re: CFTE+DevIL=?

2012-10-08 Thread Mike Parker

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/