www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Pixelbuffer to draw on a surface

reply TheDGuy <loder.feuer googlemail.com> writes:
Hi,
is there any possibility, to draw with a pixelbuffer to a surface 
(for example with GTKD) and to update it every few milliseconds?
Nov 30 2015
parent reply lobo <swamplobo gmail.com> writes:
On Monday, 30 November 2015 at 08:37:04 UTC, TheDGuy wrote:
 Hi,
 is there any possibility, to draw with a pixelbuffer to a 
 surface (for example with GTKD) and to update it every few 
 milliseconds?
Are any of these suitable for your needs? https://github.com/DerelictOrg/DerelictSDL2 http://dgame-dev.de/ https://github.com/DerelictOrg/DerelictSFML2 https://github.com/DerelictOrg/DerelictAllegro5 http://api.gtkd.org/src/gdk/Cairo.html I'm using DerelictSDL2 and Dgame for small 2D hobby games and loving it. Haven't used the others for D pixel rendering but I'm sure they're fine too. bye, lobo
Nov 30 2015
parent reply TheDGuy <loder.feuer googlemail.com> writes:
On Monday, 30 November 2015 at 09:09:00 UTC, lobo wrote:
 On Monday, 30 November 2015 at 08:37:04 UTC, TheDGuy wrote:
 Hi,
 is there any possibility, to draw with a pixelbuffer to a 
 surface (for example with GTKD) and to update it every few 
 milliseconds?
Are any of these suitable for your needs? https://github.com/DerelictOrg/DerelictSDL2 http://dgame-dev.de/ https://github.com/DerelictOrg/DerelictSFML2 https://github.com/DerelictOrg/DerelictAllegro5 http://api.gtkd.org/src/gdk/Cairo.html I'm using DerelictSDL2 and Dgame for small 2D hobby games and loving it. Haven't used the others for D pixel rendering but I'm sure they're fine too. bye, lobo
Thanks for your answer, but there is no specific solution inside GTKD?
Nov 30 2015
next sibling parent reply drug <drug2004 bk.ru> writes:
On 30.11.2015 15:49, TheDGuy wrote:
 On Monday, 30 November 2015 at 09:09:00 UTC, lobo wrote:
 On Monday, 30 November 2015 at 08:37:04 UTC, TheDGuy wrote:
 Hi,
 is there any possibility, to draw with a pixelbuffer to a surface
 (for example with GTKD) and to update it every few milliseconds?
Are any of these suitable for your needs? https://github.com/DerelictOrg/DerelictSDL2 http://dgame-dev.de/ https://github.com/DerelictOrg/DerelictSFML2 https://github.com/DerelictOrg/DerelictAllegro5 http://api.gtkd.org/src/gdk/Cairo.html I'm using DerelictSDL2 and Dgame for small 2D hobby games and loving it. Haven't used the others for D pixel rendering but I'm sure they're fine too. bye, lobo
Thanks for your answer, but there is no specific solution inside GTKD?
As I know cairo is a part of GTK, so you consider using cairo as a specific solution.
Nov 30 2015
parent drug <drug2004 bk.ru> writes:
On 30.11.2015 16:09, drug wrote:
 On 30.11.2015 15:49, TheDGuy wrote:
 On Monday, 30 November 2015 at 09:09:00 UTC, lobo wrote:
 On Monday, 30 November 2015 at 08:37:04 UTC, TheDGuy wrote:
 Hi,
 is there any possibility, to draw with a pixelbuffer to a surface
 (for example with GTKD) and to update it every few milliseconds?
Are any of these suitable for your needs? https://github.com/DerelictOrg/DerelictSDL2 http://dgame-dev.de/ https://github.com/DerelictOrg/DerelictSFML2 https://github.com/DerelictOrg/DerelictAllegro5 http://api.gtkd.org/src/gdk/Cairo.html I'm using DerelictSDL2 and Dgame for small 2D hobby games and loving it. Haven't used the others for D pixel rendering but I'm sure they're fine too. bye, lobo
Thanks for your answer, but there is no specific solution inside GTKD?
As I know cairo is a part of GTK, so you consider using cairo as a specific solution.
*you can consider
Nov 30 2015
prev sibling parent reply visitor <visitor gmail.com> writes:
 but there is no specific solution inside GTKD?
for example, in pseudo code auto surf = new Surface(.......); // look for cairo.Surface doc auto cr = cairo.Context.Context.create(surf); // pb is an existing gdkpixbuf.Pixbuf gdk.Cairo.setSourcePixbuf(cr, pb, width, height); cr.paint(); adding onDraw event listener on the widget owner of the Pixbuf (gtk.Image for example)
Nov 30 2015
parent reply TheDGuy <loder.feuer googlemail.com> writes:
Thanks for your answers. I think Cairo is the right way but i 
have a hard time to translate any of those C++ or Python 
tutorials to D, my current code:

import gtk.Main;
import gtk.MainWindow;
import gtk.DrawingArea;
import gdk.Cairo;
import gtk.Widget;

void main(string[] args){
	Main.init(args);
	MainWindow win = new MainWindow("Tutorial");
	win.setDefaultSize(250,250);

	win.add(new MyArea());
	win.showAll();
	Main.run();
}

class MyArea : DrawingArea
{
	this(){
	}

	bool on_draw(){

		return true;
	}
}

I tried to work with this Python tutorial (i think Python is 
easier to read than C++):
http://www.tortall.net/mu/wiki/PyGTKCairoTutorial

but if i try to do this: "cr = self.window.cairo_create()" i get:
"No property Window for type main.Area"?
Dec 04 2015
parent reply visitor <visitor gmail.com> writes:
gtkd demos for examples, might be of interest, like clock :
https://github.com/gtkd-developers/GtkD/blob/master/demos/cairo/cairo_clock/clock.d
Dec 06 2015
parent TheDGuy <loder.feuer googlemail.com> writes:
On Sunday, 6 December 2015 at 13:32:19 UTC, visitor wrote:
 gtkd demos for examples, might be of interest, like clock :
 https://github.com/gtkd-developers/GtkD/blob/master/demos/cairo/cairo_clock/clock.d
Thanks! I didn't knew about that source, that helped me alot :)
Dec 07 2015