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

Pages: 1 [2] 3 4 ... 6
16
SFML projects / Re: [Release][GUI] ImGui-SFML
« on: February 26, 2021, 01:52:34 pm »
Thanks. And I thought the texture upside down was a feature :)

17
Graphics / Re: Why is this taking up so much memory
« on: November 15, 2020, 12:27:30 pm »
This code doesn't fill memory but burden CPU. If you want draw 1 000 000 pixels use vertex array and initialize them before clearing the screen.

https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php#example-particle-system

18
Graphics / Re: Loading large textures
« on: October 21, 2020, 03:12:39 pm »
Are you preloading images in advance before they are rendered?

19
General / Re: Drag and Drop from a Vector of Shapes
« on: August 26, 2020, 01:56:06 pm »
You can make new variable selectedShape which will be index in shapeVec, -1 if nothing is selected, >0 if something is selected. Or it can be pointer. The index should be assigned in shape vs cursor collision loop, which you don't have.

20
Graphics / Re: Alpha blendMode
« on: August 24, 2020, 02:04:33 pm »
I'm not sure without code how is cameraPosition calculated but don't forget you must also recalculate the position of the shadows which are drawn into renderTexture. For example renderTexture have dimensions 800 x 600 and you move camera to position [250; 0] (top left corner), then simply if you draw shadow with position [950; 0] you'll never see it. It must be corrected.

Something like:
shadowSpritePosition -= cameraPosition;



21
Graphics / Re: Alpha blendMode
« on: August 22, 2020, 04:43:44 pm »
Because renderTexture where you draw shadows have coordinates [0; 0,] you must update renderSprite position to match the view position

22
General / Re: How do I use these new types of sprite sheets?
« on: August 20, 2020, 01:44:15 pm »
Spine seems like chaotic mess but "sfml-example" is working for me.

Problem with Spine and another similar complex libraries (for example 2D physics engines) is that they can be used quite well only if there exists necessary interface for them like in Unity engine, Godot etc. Otherwise it's terrible spaghetti code where it's very difficult to program manually. I doubt anyone uses it that way.

23
General / Re: How do I use these new types of sprite sheets?
« on: August 19, 2020, 08:57:45 pm »
It's some 2d skeletal animation system like Spine, they usually have examples - https://github.com/EsotericSoftware/spine-runtimes/tree/3.8/spine-sfml/cpp

24
General / Re: Dumb and simple question about input.
« on: August 08, 2020, 09:55:00 pm »
You will probably use only left mouse button, then:
        //In process events
        sf::Event event;
        while (window.pollEvent(event))
        {
                switch (event.type)
                {
                case sf::Event::MouseButtonPressed:
                        if (event.mouseButton.button == sf::Mouse::Left)
                        {
                                MyMenuClass.OnMouseClick();
                        }
                        break;
                }
        }
 

Otherwise:
//Class
void MyMenuClass::OnMouseClick(const sf::Mouse::Button& button)
{
        if (button == sf::Mouse::Left)
        {
                // Do something..
        }

        if (button == sf::Mouse::Right)
        {
                // Do something..
        }
}

..
// In process events
case sf::Event::MouseButtonPressed:
        MyMenuClass.OnMouseClick(event.mouseButton.button);                    
        break;         
 

Documentation is done very well, check tutorials https://www.sfml-dev.org/tutorials/2.5/window-events.php

25
General / Re: Dumb and simple question about input.
« on: August 08, 2020, 08:10:08 pm »
It should be similar to your code above - check mouse cursor collision vs menu objects and then execute an action.

You will have something like MyMenuClass.OnUpdate(), which runs constantly in main loop and where you will change graphics depending on whether mouse cursor is over objects. And second method MyMenuClass.OnMouseClick() in events, which is performed only if you press the mouse button. It prevents constant switching.

In some improved system you can also add events like OnMouseEnter(), OnMouseLeave() or whatever, but it is not essential. These things with UI aren't entirely simple.

26
General / Re: Dumb and simple question about input.
« on: August 08, 2020, 03:31:52 pm »
Put your menu update method into process events.

        sf::Event event;
        while (window.pollEvent(event))
        {
                switch (event.type)
                {
                case sf::Event::MouseButtonPressed:
                        MyMenuClass.OnMouseClick(event.mouseButton.button);
                        break;
                }
        }

27
General / Re: How do I load relatively
« on: July 27, 2020, 01:00:08 pm »
Nice chaos. Don't use system paths and don't put files on your desktop.

Create folder on C:\ like "C:\Dev", put all your projects there, then put your assets (graphics, audio..) into specific project folder and use relative path, which will be just name of file or something like "Textures/texture.png" if you create extra folders.

28
General / Re: The shortest possible way to resize my image?
« on: July 26, 2020, 09:40:02 pm »
If you want make thumbnails on the fly then you can't use an external program. It's best to use a special library to manipulate bitmaps, converting sf::Image to another format and back should not be complicated.

29
General / Re: [SOLVED] need a better collision idea
« on: July 25, 2020, 11:02:24 pm »
Thats probably why sorting function gets errors. Maybe this line: v.reserve(v.size() + number); is problematic for your compiler. It can be omitted and use push_back instead of emplace. But it's not important.

I also thank you, I can get rid of bitmasks finally :)

About shader, I thought that part: if(pixel.a != 0.0){..} is slow, but with this code result was same:

uniform sampler2D texture;
uniform vec4 color_id;

void main(){
    vec4 textureColor = texture2D(texture, gl_TexCoord[0].xy).rgba;
    gl_FragColor = vec4(color_id.r, color_id.g, color_id.b, textureColor.a);    
}

Btw. tool for shaders which looks usable https://github.com/dfranx/SHADERed

30
General / Re: need a better collision idea
« on: July 25, 2020, 02:19:19 pm »
In Visual Studio 2019, C++17 there are no errors in debug and release modes (x64).

I tried tests with randomized seed, it was still ok.

Pages: 1 [2] 3 4 ... 6
anything