Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 08, 2012 CFTE+DevIL=? | ||||
---|---|---|---|---|
| ||||
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? |
October 08, 2012 Re: CFTE+DevIL=? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhenya | 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.
|
October 08, 2012 Re: CFTE+DevIL=? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhenya | 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 |
October 09, 2012 Re: CFTE+DevIL=? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | 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/ |
Copyright © 1999-2021 by the D Language Foundation