Surfaces and Drawing

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
Lap
Cornac
Posts: 40
Joined: Sun Aug 29, 2010 1:31 am

Surfaces and Drawing

#1 Post by Lap »

It doesn't seem like there is any documentation on surfaces or drawing images. I can't even find a good example of how to draw images in the TOME module either. Any example code for drawing an image on a surface?

darkgod
Master of Eyal
Posts: 10751
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Surfaces and Drawing

#2 Post by darkgod »

Yes the C code has no luadoc this needs to be fixed :=)

To load an image the simpliest way is to do:

Code: Select all

local img = core.display.loadImage("/data/..../foo.png")
Then you can draw it on an other surface like that:

Code: Select all

dest:merge(img, x, y)
You can also directly display a surface on screen:

Code: Select all

img:toScreen(x, y)
If the surface wont change later you can make an opengl texture from it to speed up rendering:

Code: Select all

local tex = im:glTexture()
and display it:

Code: Select all

tex:toScreen(x, y, w, h)
You can actually update the texture if the surface changes (this is how dialogs work internally) this is faster than jsut drawing the surface.

But you probably dont need to optimize just yet ;)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Antagonist
Higher
Posts: 71
Joined: Sun May 23, 2010 9:55 am

Re: Surfaces and Drawing

#3 Post by Antagonist »

I see this has not been added to the wiki yet.

This situation has been fixed.

darkgod
Master of Eyal
Posts: 10751
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Surfaces and Drawing

#4 Post by darkgod »

Yeah thanks anta :)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply