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 6122681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:55:40+00:00 2026-05-23T15:55:40+00:00

Hey i’m working on a class called a Body which holds shapes and sprites

  • 0

Hey i’m working on a class called a “Body” which holds shapes and sprites together as one object. I would like to get into the source code and add a new overload RenderWindow’s Draw() function, so this new object can be taken in and drawn easily. How do i do this?

I’m currently using

  • Windows 7
  • SFML 1.6
  • Newly msVS++ 2010 compiled static debug libraries and dlls
  • original include folder

EDIT:

I also found this in the Drawable.hpp header:

private :

    friend class RenderTarget;

////////////////////////////////////////////////////////////
/// Draw the object into the specified window
///
/// \param Target : Target into which render the object
///
////////////////////////////////////////////////////////////
void Draw(RenderTarget& Target) const;

////////////////////////////////////////////////////////////
/// Render the specific geometry of the object
///
/// \param Target : Target into which render the object
///
////////////////////////////////////////////////////////////
virtual void Render(RenderTarget& Target) const = 0;

but i can’t figure out where the full code of each function is, just the declarations.
I didn’t find a mini tutorial there either unfortunately…

  • 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-23T15:55:40+00:00Added an answer on May 23, 2026 at 3:55 pm

    Note:

    Before you derive from and implemented your own Drawable, you may want to consider if you need to do it at all. The author of SFML has stated that sf::Drawable was not initially meant to be subclassed outside of SFML.

    That aside,

    For SFML 1.6:

    It appears that all you need to do is derive your class from sf::Drawable, and then implement a virtual Render function.

    class MyDrawable : public sf::Drawable {
    
    private:
    
        virtual void Render(RenderTarget& target) const {
            // Do some rendering of whatever...
            target.Draw(mySubSprite);
        }
    
        sf::Sprite mySubSprite;
    
    };
    

    An example of this can be found on the SFML forums.

    For SFML 2.0:

    The Drawable header file from SFML contains comments that describe how to derive your own Drawable classes. You do not need to modify the SFML source code to create new Drawables.

    It also includes a simple example:

    class MyDrawable : public sf::Drawable
    {
    public :
       ...
    private :
        virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
        {
            // You can draw other high-level objects
            target.draw(m_sprite, states);
            // ... or use the low-level API
            states.texture = &m_texture;
            target.draw(m_vertices, states);
            // ... or draw with OpenGL directly
            glBegin(GL_QUADS);
            ...
            glEnd();
        }
        sf::Sprite m_sprite;
        sf::Texture m_texture;
        sf::VertexArray m_vertices;
    };
    

    This example may apply to SFML 2.0, but if you inspect the Drawable.hpp from whatever version of SFML you have it should contain a similar example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. Okay here is the situation. I would like to be able to
Hey guys! I have this little problem: I have one ViewController which adds 2
Hey guys I am working on android application. My app includes an activity which
Hey guys I'm tired and can't figure this one out so any help would
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)
Hey I can't figure out an error I got. I had my App working
Hey everyone I am a newbie and would love some help. I got the
Hey all i have two JFrames one is my main login frame, user enters
Hey guys I am struggling to create a query which gives schedule of a
Hey can we hide/show tab layout on button click which will be placed below

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.