1
Java / Re: 15%-20% CPU usage when drawing a grid
« on: February 16, 2014, 04:03:17 am »I'm not really sure why the rectangle approach would use that much CPU load, I will try this myself one of these days.
I think it's like FRex said, too many draw calls per frame. In my original example, I was performing 3072 draw calls every frame. While that isn't a huge amount of calls, it sure doesn't beat one draw call with a vertex array. He's also right that this isn't specific to JSFML, as I was able to reproduce it with SFML.NET too.
Anyway, this is a job for vertex arrays indeed. In that latest version of your code, if you call your "update()" function only when needed, it should approach 0% CPU load. There's no need to fill the vertex array with the same information in every frame, it's enough to do it when the application starts or something in the game field changes.
You're right, doing that did drop the CPU usage to 0%.
I appreciate the feedback. I'm new to game/graphics programming, so there's definitely more for me to learn.