1
Graphics / Grid using vertex array
« on: January 07, 2018, 03:27:13 am »
Hi there! As an exercize I made a simple c++ game of life and to make the code simple i have an array of RectangleShapes that i draw in a loop, the only thing i change about them is the FillColor. Everything runs smoothly until i hit around 20.000 of these shapes, then it starts lagging heavily. I searched how to optimize the draw of these shapes but i only found reference to vertex arrays or sprites. I don't need textures, just a black/white box. I looked up vertex arrays but didn't understand very well how to use them.
As far as i understand the problem behind the lag is that i'm making tens of thousands of draw calls and a way of solving that would be to make a single draw of many objects( a thing for which modern gpus are well designed for), but as far as i understand i'd be doing the same for vertex arrays, creating an array of quads, giving them a color and then drawing them, just not using the RectangleShape class.
Am i missing something here? Is there a way to make a single draw call for all the "cells"?
Thanks
As far as i understand the problem behind the lag is that i'm making tens of thousands of draw calls and a way of solving that would be to make a single draw of many objects( a thing for which modern gpus are well designed for), but as far as i understand i'd be doing the same for vertex arrays, creating an array of quads, giving them a color and then drawing them, just not using the RectangleShape class.
Am i missing something here? Is there a way to make a single draw call for all the "cells"?
Thanks