PDA

View Full Version : Bad performance



Mioviz
07-05-2016, 04:46 PM
In SDL2 I can have 6000 animating sprites on screen and it only takes 7% processor time
In OpenGL just an image and text takes almost 20%
I am on Windows and using Nehe's tutorials
What am I doing wrong?

mhagain
07-05-2016, 09:56 PM
using Nehe's tutorials

This is part of what you're doing wrong. These tutorials are outdated and will teach you bad practices.

Cornix
07-06-2016, 12:45 AM
What am I doing wrong?
Probably a lot. There is many many things you can do wrong when working with OpenGL but without seeing your code we can not really say for sure.
Just remember to do as little as possible during your update loop. Ideally the only things you do is: clear the buffers, render your VBO's, flip the framebuffers.

mhagain
07-06-2016, 02:58 AM
Just to elaborate.

Saying "just an image and text" is not enough. How big is your screen? How big is the image? How much text? How large is each character? Have you much overdraw? This should be obvious but drawing more characters involves doing more work which involves more overhead which results in lower performance. If using the NeHe tutorials you probably have a single glBegin/glEnd pair for each character which runs slower than batching. You may have a single texture for each character which will run slower than using an atlas. You may be using the matrix stack to position each character which will run slower than using explicit positions. There are so many things you could be doing wrong that it's impossible to give you meaningful help unless you're prepared to tell us more about how you're drawing stuff.

Finally, just measuring CPU is an incomplete metric when it comes to OpenGL. You also need to measure GPU work.