Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 887515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:14:33+00:00 2026-05-15T13:14:33+00:00

I succeed installing Box2D into my project. But how can I render a body?

  • 0

I succeed installing Box2D into my project. But how can I render a body? Assume I’m using something that supports drawing polygons. I just want to find out the current positions of the vertices of the body-polygon, to draw it with the engine.

If you can help me, I will be very thankful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:14:34+00:00Added an answer on May 15, 2026 at 1:14 pm

    I found it!!!

    void Box2DUtils::DrawBody(SDL_Surface *buffer, b2Body *body, int fr, int fg, int fb, int falpha, int lr, int lg, int lb, int lalpha, bool aa)
    {
        const b2Transform& xf = body->GetTransform();
        for (b2Fixture* f = body->GetFixtureList(); f; f = f->GetNext())
        {
            switch (f->GetType())
            {
            case b2Shape::e_circle:
            {
                b2CircleShape* circle = (b2CircleShape*) f->GetShape();
    
                b2Vec2 center = b2Mul(xf, circle->m_p);
                float32 radius = circle->m_radius;
                b2Vec2 axis = xf.R.col1;
    
                //m_debugDraw->DrawSolidCircle(center, radius, axis, color);
                if (falpha > 0)
                {
                    filledCircleRGBA(buffer, center.x, center.y, (int) radius, fr, fg, fb, falpha);
                }
                if (lalpha > 0)
                {
                    if (aa)
                    {
                        aacircleRGBA(buffer, center.x, center.y, (int) radius, lr, lg, lb, lalpha);
                    } else
                    {
                        aacircleRGBA(buffer, center.x, center.y, (int) radius, lr, lg, lb, lalpha);
                    }
                } else if (aa)
                {
                    aacircleRGBA(buffer, center.x, center.y, (int) radius, fr, fg, fb, falpha);
                }
    
            }
                break;
    
            case b2Shape::e_polygon:
            {
                b2PolygonShape* poly = (b2PolygonShape*) f->GetShape();
                int32 vertexCount = poly->m_vertexCount;
                b2Assert(vertexCount <= b2_maxPolygonVertices);
                b2Vec2 vertices[b2_maxPolygonVertices];
                Sint16 xv[b2_maxPolygonVertices];
                Sint16 yv[b2_maxPolygonVertices];
                for (int32 i = 0; i < vertexCount; ++i)
                {
                    vertices[i] = b2Mul(xf, poly->m_vertices[i]);
                    xv[i] = (int) vertices[i].x;
                    yv[i] = (int) vertices[i].y;
                }
                if (falpha > 0)
                {
                    filledPolygonRGBA(buffer, xv, yv, (Sint16) vertexCount, fr, fg, fb, falpha);
                }
                if (lalpha > 0)
                {
                    if (aa)
                    {
                        aapolygonRGBA(buffer, xv, yv, (Sint16) vertexCount, lr, lg, lb, lalpha);
                    } else
                    {
                        polygonRGBA(buffer, xv, yv, (Sint16) vertexCount, lr, lg, lb, lalpha);
                    }
                } else if (aa)
                {
                    aapolygonRGBA(buffer, xv, yv, (Sint16) vertexCount, fr, fg, fb, falpha);
                }
                //m_debugDraw->DrawSolidPolygon(vertices, vertexCount, color);
            }
                break;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I succeed in writing my code to that address using int 13h
I succeed to include ojdbc14_g.jar to my project, but I am asked to import
I have a succeed ajax request that can download the whole html contents, now
I'm here trying to convert 4-digit hexa into dec but didn't succeed. Here is
I was trying to find a solution but did not succeed even if it
I am trying to create an object of Console class, but could not succeed.
I tried using Exist and IN. Not only did I not succeed, it didn't
I'm creating an actionscript project in Flex Builder. I succeed to export from Flash
Can't overcome problem. Everytime i generating new rails project on windows get the massage:
I succeed scrolling to top of my page using the following jQuery script: $(html,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.