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

Recent Posts

Pages: 1 ... 7 8 [9] 10
81
General discussions / about the 2.x syntax and the document
« Last post by ilenerstewart on November 15, 2024, 08:26:25 am »
If the syntax of the 2.x series changes, should the documentation also change? The current documentation still uses the old syntax, and it fails to compile with 2.6.1+vs2022
eg:https://www.sfml-dev.org/tutorials/2.6/window-window.php
and code:
sf::Event event;
82
Graphics / Colour individual triangles in a sf::TriangleStrip
« Last post by BottleNeck on November 15, 2024, 06:53:24 am »
Background:
I'm trying to make a falling sand simulation game which requires displaying a very large number of objects at once. I was drawing each "grain" of sand using a sf::RectangleShape, however for larger grids (e.g 500x500) this was far too many draw calls.

I'm currently trying to implement drawing of the sand using a sf::VertexArray. If I use sf::Triangle primitives, I'll have 6 vertices per grain, which is a lot for larger grid sizes.

Now I'm attempting to use the sf::TriangleStrip primitive to display the entire grid, using degenerate triangles to transition between rows. This reduces the number of vertices required by about two thirds, however now I have a problem with colouring the grains.

Question:
When using a sf::VertexArray to display a sf::TriangleStrip, is it possible to colour individual triangles within the strip different colours? Currently, if I want to colour two adjacent triangles in two different colours, the colours are interpolated between the vertices, forming a gradient. I want to be able to apply different colours to triangles without any gradient.

I've attached an image to show what I'm currently getting. I've drawn over the approximate locations of the triangles of the strip. I'd like the middle two triangles to be completely black.

83
SFML projects / Re: Screenshot Thread
« Last post by Bondrusiek on November 14, 2024, 06:06:15 pm »
Analog Clock

Source code: https://gist.github.com/Przemekkkth/3a0c9acae9d8824780a7b9b7bb07fbe2

Additionally I created a function which use Bresenham's line algorithm and help drawing a line between two points with specified width and color:
int drawLine(sf::RenderWindow &window, sf::Vector2i point1, sf::Vector2i point2, int lineWidth, sf::Color lineColor)
{
    int x0 = point1.x;
    int y0 = point1.y;
    int x1 = point2.x;
    int y1 = point2.y;
    int dx = abs(x1 - x0);
    int sx, sy;
    if (x0 < x1) {
        sx = 1;
    }
    else {
        sx = -1;
    }

    int dy = -abs(y1 - y0);
    if (y0 < y1) {
        sy = 1;
    }
    else {
        sy = -1;
    }

    int err = dx + dy;

    while (true) {
        sf::RectangleShape rect(sf::Vector2f(lineWidth, lineWidth));
        rect.setFillColor(lineColor);
        rect.setPosition(x0, y0);
        window.draw(rect);
        if (x0 == x1 && y0 == y1) {
            break;
        }
        int e2 = 2 * err;

        if (e2 >= dy) {
            err += dy;
            x0 += sx;
        }

        if (e2 <= dx) {
            err += dx;
            y0 += sy;
        }
    }
}
 

84
Graphics / Re: How to draw a line between two points ?
« Last post by Bondrusiek on November 14, 2024, 05:42:44 pm »
Hi, I created a function which use Bresenham's line algorithm and help drawing a line between two points:
int drawLine(sf::RenderWindow &window, sf::Vector2i point1, sf::Vector2i point2, int lineWidth, sf::Color lineColor)
{
    int x0 = point1.x;
    int y0 = point1.y;
    int x1 = point2.x;
    int y1 = point2.y;
    int dx = abs(x1 - x0);
    int sx, sy;
    if (x0 < x1) {
        sx = 1;
    }
    else {
        sx = -1;
    }

    int dy = -abs(y1 - y0);
    if (y0 < y1) {
        sy = 1;
    }
    else {
        sy = -1;
    }

    int err = dx + dy;

    while (true) {
        sf::RectangleShape rect(sf::Vector2f(lineWidth, lineWidth));
        rect.setFillColor(lineColor);
        rect.setPosition(x0, y0);
        window.draw(rect);
        if (x0 == x1 && y0 == y1) {
            break;
        }
        int e2 = 2 * err;

        if (e2 >= dy) {
            err += dy;
            x0 += sx;
        }

        if (e2 <= dx) {
            err += dx;
            y0 += sy;
        }
    }
}
 
85
Graphics / Re: rotate tanslate vs translate rotate
« Last post by fallahn on November 14, 2024, 01:47:20 pm »
SFML Drawables which inherit sf::Transformable call sf::Transformable::getTransform() which always combines the components as Translation->Rotation->Scale. If you want to combine these in a different order you'll need to replace getTransform() with your own function which combines sf::Transform in your custom order. You can then pass the result to the sf::RenderStates for your drawable.
86
Graphics / rotate tanslate vs translate rotate
« Last post by smurf on November 14, 2024, 07:18:17 am »
Back when I used to work in raw OpenGL, there was a difference between translating first then rotating, versus rotating first then translating.

In SFML, it seems that it doesnt matter what order you call SetOrigin, SetPosition, SetRotation

So how can I achieve the different behaviors (eg, rotate an object then move it to the right, versus move it to the right then rotate it)

Specifiaclly I an object to orbit my player at a distance, while always pointing toward him.
87
General discussions / Re: SFML releases
« Last post by eXpl0it3r on November 13, 2024, 12:10:05 am »
SFML 2.6.2

Read the announcement here: https://en.sfml-dev.org/forums/index.php?topic=29715.0
88
General discussions / SFML 2.6.2 released
« Last post by eXpl0it3r on November 13, 2024, 12:09:37 am »
SFML 2.6.2

Another collection of bugfixes for SFML 2.

All the fixes listed here will be included in the SFML 3.0.0 release.
Subsequent SFML 2.6.x fixes will have to either go to SFML 3.0.x or SFML 3.1.x.

See the full changelog for more details: https://www.sfml-dev.org/changelog.php#sfml-2.6.2

Visit https://www.sfml-dev.org/ for download instructions and extensive documentation. We hope you enjoy this release and would love to get some feedback!
89
General / Re: Unable to link statically compiled SFML with clang
« Last post by ebots on November 08, 2024, 11:51:50 am »
I forgot to mention I also ran the makefile after the CMake GUI
90
General / Re: Unable to link statically compiled SFML with clang
« Last post by eXpl0it3r on November 08, 2024, 11:51:07 am »
I did recompile SFML using the CMake GUI
But the CMake GUI itself doesn't build anything.
It just generates make/project files. You still need to invoke your toolchain to actually generate the libraries.
Pages: 1 ... 7 8 [9] 10