Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Dyavolski_most

Pages: [1]
1
Graphics / Re: custom shape type not appear in window
« on: January 07, 2015, 08:53:55 am »
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow window(sf::VideoMode(1280, 720), "This is the title");


class EllipseShape : public sf::Shape
{
public :
    explicit EllipseShape(const sf::Vector2f& radius = sf::Vector2f(0, 0)) : m_radius(radius)
    {
        update();
    }

    void setRadius(const sf::Vector2f& radius)
    {
        m_radius = radius;
        update();
    }

    const sf::Vector2f& getRadius() const
    {
        return m_radius;
    }

    virtual unsigned int getPointCount() const
    {
        return 30; // fixed, but could be an attribute of the class if needed
    }

    virtual sf::Vector2f getPoint(unsigned int index) const
    {
        static const float pi = 3.141592654f;

        float angle = index * 2 * pi / getPointCount() - pi / 2;
        float x = std::cos(angle) * m_radius.x;
        float y = std::sin(angle) * m_radius.y;

        return sf::Vector2f(m_radius.x + x, m_radius.y + y);
    }
private :

    sf::Vector2f m_radius;
};


    while (window.isOpen())
    {
         sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        window.clear();
        window.draw(/*What goes here?*/);
        window.display();
        }
    }
    return 0;
}

This is the code, mostly just what is on the tutorial.
I mainly think i am just missing window.draw(??)
I tried EllipseShape, shape, then just tried everything else i could think of

2
Graphics / custom shape type not appear in window
« on: January 06, 2015, 02:23:44 pm »
Hi. Just started programming. I have gone from c++ to winapi and now SFML
In the 2.2 tutorial for Shapes
Working through the tutorials one by one
 
http://www.sfml-dev.org/tutorials/2.2/graphics-shape.php

For bottom section about Custom shape type

My code manages to compile, but the shape isn't appearing

I thought maybe i was missing
window.draw()
because i did forget a few times during other parts
but I can't figure out what goes into the parentheses here

Any help is much appreciated 

Pages: [1]
anything