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.


Topics - Sean Mulligan

Pages: [1]
1
SFML website / SFML Website Design
« on: June 07, 2023, 03:40:10 am »
Hello, The SFML website needs a graphical update. The aero style that rules the website isn't trustworthy in the present day because people associate it with viruses and phishing sites. If SFML got a graphical update then more people would use it because it would seem more appealing to those who want to create projects that are up-to-date with the current times. I do graphical design as a hobby, and I would be willing to help you, thanks.

2
Graphics / Cannot Open File sfml-graphics-2-d.dll
« on: May 14, 2023, 06:49:35 am »
Hello, I am trying to link SFML dynamically for Visual Studio's debug mode. I downloaded the 32bit version of SFML 2.5.1 and am running with the correct version on Visual Studio. The dll file exists and is included in additional dependencies, and I have set everything up correctly following many tutorials to make sure that it was correct. Thanks for your help, and if this is Exploiter I would like to like to give you extra thanks for replying to all my petty questions.

3
I am creating a personal SFML GUI library, but I have ran into an error, and I can't find any place online to fix it. In the main file, I am creating a panel and pushing buttons onto it. All the sizing is working correctly to be on screen and are out putted in the console. I am then drawing the panel which should be drawing the buttons, but that function is not activating. Please, how do I fix this?

main
int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "SFMin");

        sfm::Button button([]() {std::cout << "Hello World" << std::endl;}, "test");
        sfm::Button button2([]() {std::cout << "Hello World" << std::endl;}, "really really long name for testing purposes only");
        sfm::Panel panel(sfm::Layouts::LIST);
        panel.pushBackElement(button);
        panel.pushBackElement(button2);

        while (window.isOpen())
        {
                sfm::RegionCoordinates<sf::Vector2f> windowArea(sf::Vector2f(0.0f, 0.0f), sf::Vector2f(window.getSize().x, window.getSize().y));
                // ----------------polling----------------

                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                        {
                                window.close();
                        }
                        if (event.type == sf::Event::Resized)
                        {
                                sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
                                window.setView(sf::View(visibleArea));
                                window.setSize(sf::Vector2u(event.size.width, event.size.height));
                        }
                }

                // ----------------update----------------

                panel.update(windowArea, &window);
                window.clear(sf::Color::White);

                // ----------------draw----------------

                panel.draw(windowArea, &window);
                window.display();
        }
        return 0;
}
 

Panel
void sfm::Panel::draw(sfm::RegionCoordinates<sf::Vector2f> drawingRegion, sf::RenderWindow* window)
{
        drawingRegion.correctCoordinates();
        float width = drawingRegion.endCoordinate.x - drawingRegion.startCoordinate.x;
        float height = drawingRegion.endCoordinate.y - drawingRegion.startCoordinate.y;
        //std::cout << "Width: " << width << "Height: " << height << "\n";
        float topPadding = (TOP_ELEMENT_PADDING * height) + (TOP_PANEL_PADDING * height);
        float bottomPadding = (BOTTOM_ELEMENT_PADDING * height) + (BOTTOM_PANEL_PADDING * height);
        float leftPadding = (LEFT_ELEMENT_PADDING * width) + (LEFT_PANEL_PADDING * width);
        float rightPadding = (RIGHT_ELEMENT_PADDING * width) + (RIGHT_PANEL_PADDING * width);

        float heightDivision = (height - topPadding - bottomPadding) / elements.size();
        float widthDivision = (width - leftPadding - rightPadding) / elements.size();
        this->elements.at(1).draw(drawingRegion, window);
        /*
        switch (this->layout)
        {
        case Layouts::LIST:
                break;
        case Layouts::ROW:
                break;
        }
        */

        for (unsigned int i = 0; i < this->elements.size(); i++)
        {
                sf::Vector2f startCoordinate(leftPadding, heightDivision * i + topPadding);
                sf::Vector2f endCoordinate(width - rightPadding, heightDivision * (i + 1) + topPadding);
                std::cout << "Start " << "X: " << startCoordinate.x << " Y: " << startCoordinate.y << "\n";
                std::cout << "End " << "X: " << endCoordinate.x << " Y: " << endCoordinate.y << "\n";

                RegionCoordinates<sf::Vector2f> elementRegion(startCoordinate, endCoordinate);
                this->elements.at(i).draw(elementRegion, window);
        }
}
 

Button
void sfm::Button::draw(sfm::RegionCoordinates<sf::Vector2f> drawingRegion, sf::RenderWindow* window)
{
        std::cout << "Hello World" << std::endl;
        drawingRegion.correctCoordinates();

        // ----------------background----------------

        sf::RectangleShape background;
        background.setPosition(drawingRegion.startCoordinate.x, drawingRegion.startCoordinate.y);
       
        // sizing
        float width = drawingRegion.endCoordinate.x - drawingRegion.startCoordinate.x;
        float height = drawingRegion.endCoordinate.y - drawingRegion.startCoordinate.y;
        background.setSize(sf::Vector2f(width, height));
       
        // styling
        if (hover)
        {
                background.setFillColor(ELEMENT_COLOR_HOVER);
        }
        else
        {
                background.setFillColor(ELEMENT_COLOR_NORMAL);
        }
        background.setOutlineColor(OUTLINE_COLOR);
        background.setOutlineThickness(OUTLINE_THICKNESS);

        window->draw(background);

        // ----------------text----------------

        if (this->textDescription.length() > 0)
        {
                sf::Text text;
                text.setPosition(drawingRegion.startCoordinate.x, drawingRegion.startCoordinate.y);
                text.setString(this->textDescription);

                // styling
                text.setFillColor(TEXT_COLOR);
                text.setFont(this->font);

                // sizing
                sf::FloatRect rectangle = text.getLocalBounds();
                float ratio = width / rectangle.width;
                text.setCharacterSize(unsigned int((float)text.getCharacterSize() * ratio));
               
                rectangle = text.getLocalBounds();
                ratio = width / rectangle.width;
                text.setScale(ratio, ratio);

                window->draw(text);
        }

        // test drawing
        sf::RectangleShape shape;
        shape.setPosition(0, 0);
        shape.setSize(sf::Vector2f(100, 100));
        shape.setFillColor(sf::Color::Cyan);
        window->draw(shape);
}
 

4
General / Type casting in c++
« on: November 28, 2022, 08:45:46 pm »
Thanks for your help. I have been coding in c++ for about a year, but I am unsure on more complex subjects.

5
Whenever I try drawing an sfml sprite with a negative position to a render window, it will not display. Is this intentional? If so how do I go around it? If not how do I fix it? Please help, I have been trying to fix this for hours.

Further details:
I am using a view on the window that is provided in an sfml resource on how to allow resizing in a window. It ranges from (0,0) to the window's border
The window is render window, and I am accessing it using a pointer.
The sprite's texture is applied from a variable.
A a texture rect is applied to allow for correct sizing.
Then the sprite's size is set.

Pages: [1]
anything