Mercurial > projects > myrrdin
diff src/renderer.d @ 0:a2d653eb9e99
first working version.
author | fred@reichbier.de |
---|---|
date | Thu, 17 Jul 2008 18:52:55 +0200 |
parents | |
children | 292df259cc85 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/renderer.d Thu Jul 17 18:52:55 2008 +0200 @@ -0,0 +1,45 @@ +module renderer; + +import dsfml.window.all; +import dsfml.system.all; +import dsfml.graphics.all; + +import consumer; +import imagecache; + +class Renderer { + public RenderWindow app; + public Cache cache; + private Consumer[] consumers; + + this(char[] title, int width, int height, int depth=32) { + this.app = new RenderWindow(VideoMode(width, height, depth), title); + this.app.setFramerateLimit(40); + + this.cache = new Cache("."); // TODO + } + + void add_consumer(Consumer consumer) { + this.consumers ~= consumer; + } + + /* start the mainloop */ + void mainloop() { + Event evt; + + while(this.app.isOpened()) { + // handle all events + while(this.app.getEvent(evt)) { + if (evt.Type == Event.EventType.CLOSED) { + this.app.close(); + } + } + // draw all + foreach(Consumer consumer; this.consumers) { + consumer.draw(); + } + // display all + this.app.display(); + } + } +}