0
votes

My question, not actually being a question, rather a matter of facts is that:

In my application I use PyGame for drawing sprites. So basically I'm doing the following:

surface.blit(image, [other_args])

Now this is pretty fast if the sprites are not too big. But now, I want to try to move to OpenGL (using PyOpenGL library) but I do't know if it's worth it, it would take some time and refactoring of my application.

So given that:

  • I can't batch or combine sprites (I can't put everything into a single vertex array and just issue draw command), and I can't do instancing, because the sprites differ a lot
  • There is a really big number of sprites

..is it worth to move to PyOpenGL or should I stick with PyGame only default blitting algorithm?

1
Nowadays I wouldn't use OpenGL directly or Pygame for a productive application. I would use an engine like Unity or Unreal (or similar). - Rabbid76
I'm too far into the project for rewriting it in other language/framework. - luke1985
"I can't batch or combine sprites (I can't put everything into a single vertex array and just issue draw command)" Why not? If you can issue individual draw commands per sprite, it follows that you also can instead record the relevant sprite information into a buffer. "and I can't do instancing, because the sprites differ a lot", not sure what you do there, but typically, a sprite has position, size/scale, maybe orientation and a different texture content, all that can be done with instanced draws, although for batched sprites I would recommend using pseudo-instancing based on gl_VertexID. - derhass
Please note, pygame was never meant to create productive applications. pygame is for novice and students to learn python and simple graphics programming. - Rabbid76

1 Answers

0
votes

i moved from pygame Sprites to pyOpenGl in one of my projects like a year ago. Didnt take to much work after i understood how VertexArrayBuffers work (u defenitely should get familar with that!) to translate not only my code but to upgrade my rendering system. Still hat to rework everytyhing pyglet gave me, displaying for example text took a while...

if u want to create a productive application u should keep in mind that python with openGL is not really fast, or, rendering opengl in python needs lots more CPU, it seems. Since i dont have the same project in Java or C++ i cant measure the difference, but rendering a big 3d-World and HUD with texts results in a bit of lag, even without an AI, particels, shadows and more...

In generell, prototyping ur project in python and then abstracting the needs of the architecture u wanna achieve and THAN translating to a more fitting language should be faster (development) than rebuilding from scratch mid project.

TL;DR: if u really wanna stick to python: give it a try and find out how stressed ur machine gets by your code, moving ur code to pyOpenGl shouldnt be the trouble