Thread overview |
---|
December 25, 2015 GTKD - Get the size of the context | ||||
---|---|---|---|---|
| ||||
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 Re: GTKD - Get the size of the context | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheDGuy | 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 Re: GTKD - Get the size of the context | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Wey | 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 Re: GTKD - Get the size of the context | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheDGuy | 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. |
Copyright © 1999-2021 by the D Language Foundation