Thread overview
GTKD - Get the size of the context
Dec 25, 2015
TheDGuy
Dec 26, 2015
Mike Wey
Dec 26, 2015
TheDGuy
Dec 26, 2015
Bubbasaur
December 25, 2015
Hello,

i want to draw something to a GTKD context and i need the size of the context in pixel but i don't know how i can get the pixel height and width? Any ideas?

With best regards
December 26, 2015
On 12/25/2015 11:55 AM, TheDGuy wrote:
> Hello,
>
> i want to draw something to a GTKD context and i need the size of the
> context in pixel but i don't know how i can get the pixel height and
> width? Any ideas?
>
> With best regards

You could try getting the size of the widget the context is referring to with getAllocation.

GtkAllocation size;
widget.getAllocation(size);

and then use size.width and size.height.

-- 
Mike Wey
December 26, 2015
Thank you very much for your answer! I really appreciate it because it is kind of hard to find explanations for GTKD.

But know i face a strange problem:

	this(Vector3D camera, Context cr, Widget widget){
		this.camera = camera;
		this.cr = cr;
		this.widget = widget;

		GtkAllocation size;
		widget.getAllocation(size);
		this.width = size.width;
		this.height = size.height;
	}
	void restartProgressiveRendering(){
		int[this.width*this.height*3+1] space;
		this.accumulator = space;
	}

I get the error "value of 'this' is not known at compile time" which refers to the line where i create the int-array "space"
Why is it not possible to use it there?
December 26, 2015
On Saturday, 26 December 2015 at 13:28:31 UTC, TheDGuy wrote:
> I get the error "value of 'this' is not known at compile time" which refers to the line where i create the int-array "space"
> Why is it not possible to use it there?

Just for future newcomers, the answer for the above was given here:
http://forum.dlang.org/post/tqvgmsluuhzzscbxhned@forum.dlang.org

By Adam D. Ruppe:

"
Try:

auto arr = new int[](size.width*size.height*3+1);

The int[x] syntax declares a statically sized array - statically sized meaning it must be known at compile time and thus cannot be variables, along a few other differences.

The new array syntax though returns one of variable size.
"

Bubba.