# When to use ShapeRenderer & SpriteBatch in libGdx?

As a beginner(in GdxLib+Android), i found that for rendering particular screen, we can render that using both ways then when to use specific ones? & What is the best option for Updating the smaller part/region of the screen?

## 1 Answer

per documentation ShapeRenderer isn't efficient and shouldn't be used intensively.

Renders points, lines, rectangles, filled rectangles and boxes. This class is not meant to be used for performance sensitive applications but more oriented towards debugging.

That being said, I asked for opinions on its real impact here, but since I've got no answer yet, I decided to give a try. It's working nice so far but if you can use a texture, I'd say to go with that. (I'm not using a texture because I'm writing a small library and don't want to include non code).

• Got it. Thanks. Any comments on 2nd Question - about updating small regions of the screen? – vintesh Feb 21 '13 at 14:54
• @vintesh Sorry, but I really didn't get what you want to know there. English isn't my primary language. – petervaz Feb 21 '13 at 14:58
• I want to know that suppose i have rendered the whole grid/screen using the Texture but now suppose i want to change the one rectangle area then what should i use... ? I am using code spriteBatch.begin(); spriteBatch.draw(texture, x,y,x,y); spriteBatch.end(); code but i failed to get change the rect. – vintesh Feb 21 '13 at 16:04
• @vintesh just to be sure, are you making that second call inside the draw() method? perhaps if you shared you code it would be easier to help. – petervaz Feb 21 '13 at 16:41
• link I am unable to update the position of TILE of the grid that code is in "app.game.robo.objects.renderer" package. – vintesh Feb 21 '13 at 18:30