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 - Sakman

Pages: [1]
1
Graphics / Re: Do I really have to use std::vector<sf::CircleShape> ?
« on: July 17, 2018, 04:44:20 pm »
Thank you for your response!

I'm a bit confused. So what I need to do is make an empty texture and draw the circles on it?

Could you link a tutorial or an example, please. Thank you.

2
Graphics / Do I really have to use std::vector<sf::CircleShape> ?
« on: July 17, 2018, 03:53:53 pm »


Hello! Lets say I have collection of circles that I want to draw. They are identical in color, outline etc. Like shown in the picture above.

Let's say I store the positions and radiuses in vectors. I don't want to store every sf::CircleShape individually since that takes too much memory and makes the program slow.

Is there a way to make a single sf::CircleShape and use (tranform?) something to move and scale the circle with the vectors mentioned above? And is there a way to draw them with a single RenderTarget::draw() like with sf::VertexArray?

Responses are greatly appreciated.

3


Hello! Lets say I have collection of circles that I want to draw. They are identical in color, outline etc. Like shown in the picture above.

Let's say I store the positions and radiuses in vectors. I don't want to store every sf::CircleShape individually since that takes too much memory and makes the program slow.

Is there a way to make a single sf::CircleShape and use (tranform?) something to move and scale the circle with the vectors mentioned above? And is there a way to draw them with a single RenderTarget::draw() like with sf::VertexArray?

Responses are greatly appreciated.

4
General / Transform problem
« on: June 29, 2018, 01:41:22 pm »
I am trying to make two copies of 'lines' where the other one is slightly moved in the X direction. Is there a way to directly change it or do I need to make another entity and use its position to change the transform...?

sf::RenderStates states;

states.transform *= getTransform();
window.draw(lines, states);

sf::CircleShape circle;   //I used circleshape just because idk
circle.setPosition(sf::Vector2f(300, 0));

states.transform *= circle.getTransform(); //how do I do this without another entity
window.draw(lines, states);
 

There must be way to do this so please let me know. I have tried to Google and searched the tutorials so please don't tell me to go look harder.

5
Graphics / Custom shapes with textures
« on: June 24, 2018, 11:57:23 am »


I want to make a custom shape that has two textures. What I learned from the tutorials is that I need to make a class that inherits from sf::Drawable and sf::Transformable, and then overload the draw function.

This was from the tutorial:
class MyEntity : public sf::Drawable, public sf::Transformable
{
public:

    // add functions to play with the entity's geometry / colors / texturing...

private:

    virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
    {
        // apply the entity's transform -- combine it with the one that was passed by the caller
        states.transform *= getTransform(); // getTransform() is defined by sf::Transformable

        // apply the texture
        states.texture = &m_texture;

        // you may also override states.shader or states.blendMode if you want

        // draw the vertex array
        target.draw(m_vertices, states);
    }

    sf::VertexArray m_vertices;
    sf::Texture m_texture;
};
 

Could someone post a simple example with two rectangles or give me a better option, please. Thank you.

Pages: [1]