Cags
Well-known member
Ive been working on an application that involved drawing a grid. In order to draw this grid I was originally using DrawRectangle to draw each individual square. Upon revisiting the code to optimise it I realised there are much faster ways to draw the grid as drawing each square indivually means that most lines between squares are drawn twice. To get around this I used the DrawLine function.
For example to draw a 9x9 grid, you only need to call DrawLine 20x as opposed to calling DrawRectangle 81x. Ok your all probably thinking well duh but bear with me. The same grid could be drawn by calling DrawLine 16x and 1x DrawRectangle (basically drawing the outline as a square instead of each individual line).
So what I was wondering is what are the overheads of each method? Does DrawRectangle encapsulate the same code as DrawLine? Which method actually takes longer to perform, DrawRectangle or DrawLine 4x. Obviously any difference is likely to be minimal and thus doesnt matter at all in the application Im working on. I was just intruiged if anyone would know.
Hope that makes sense.
For example to draw a 9x9 grid, you only need to call DrawLine 20x as opposed to calling DrawRectangle 81x. Ok your all probably thinking well duh but bear with me. The same grid could be drawn by calling DrawLine 16x and 1x DrawRectangle (basically drawing the outline as a square instead of each individual line).
So what I was wondering is what are the overheads of each method? Does DrawRectangle encapsulate the same code as DrawLine? Which method actually takes longer to perform, DrawRectangle or DrawLine 4x. Obviously any difference is likely to be minimal and thus doesnt matter at all in the application Im working on. I was just intruiged if anyone would know.
Hope that makes sense.