0
\$\begingroup\$

I've watched some tutorials on java game development and when they start using spritesheets all they do is get a subimage out of the spritesheet and create a new BufferedImage out of that. Does java do some sort of batching behind the scene when drawing the images like some engines and libraries do? Is it even possible to batch in java, and if so how would I go about doing it?

\$\endgroup\$
0
\$\begingroup\$

You don't need to do batching in Java(but if you want to try it here is a link to a usefull link: https://www.youtube.com/watch?v=X6KjDwA7mZg), let me tel you why:

The idea of batching is to draw all models that have the same texture and other data, like vertex data, in batches so that you minimize the amount of binds and unbinds for said data as much as possible, when using APIs like OpenGL or DirectX. So instead of having to bind and unbind the texture add all the other data for every same model, we can simply draw all the models at once, binding and unbind only once the data needed.(IF you haven't understood click on the link above).

In Java this isn't need because your are not bind or unbinding anything. What you can do is, at the beginning of the program load all the sprites from spritesheets and then every time your render to the screen simply draw them using something like a JCanvas. Batching is all about minimizing the amount of bind and unbinds, as mentioned before, so since in Java you do need to bind anything to draw to the screen, batching is useless.

I know this might not have help you a lot do feel free to ask questions

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy