Methods of rendering box2d objects

General discussion about Box2D tutorials
Post Reply
fredells
Posts: 10
Joined: Sat Jan 16, 2016 10:16 pm

Methods of rendering box2d objects

Post by fredells »

Hello,

I am looking for a simple way to render box2d objects. What I want is simple outline and fill colors. Is it possible to control debug rendered output?

Alternatively is it possible to fill the objects with a repeating texture? Do I have to create shapes from the fixtures, color them, and then attach them to the bodies?

I am a bit lost on how to render anything without attaching images in RUBE :s

Thanks for any help,

Fred
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Methods of rendering box2d objects

Post by iforce2d »

This is not really a Box2D question since methods of rendering will depend on the platform, rendering API, game framework if you're using one, device type etc etc

For simple outline and fill colors, you could copy the debug draw functions and add color parameter(s) so you can set the color of each shape individually.

Filling shapes with a repeated texture is of course possible, but not quite so simple. If you can draw a polygon, then your rendering API should have a method for generating texture coordinates. This is where you need to read the docs for whatever API you're using :)
Post Reply