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

Pages: 1 [2] 3 4
SFML development / Re: C++ standards
« on: September 07, 2018, 03:10:04 am »
it's more about the features that we need.
That's a good point about something i noticed eXpl0it3r wrote: "Code simplification: smart pointers".
Do we really need that?
I might not be an expert about programming, but if the existing codebase is working internally with good old pointers AND without memory leak issues (i'm supposing it does), which means dynamic memory is properly managed, then what's the point of replacing them with smart pointers?
In my point of view smart pointers can help to make quick code, can allow the programmer to be more lazy, but they take this small amount of resources more than normal pointers to, which in the case of an already robust code seems just a waste to me.
Am i missing something?

Sorry for the bad english, i've been awake since more than 48 hours  ::)

Graphics / Re: prevent last draw trail during resizing
« on: August 19, 2018, 06:48:46 pm »
SFML doesn't allow you to update (or redraw) the window during a resize; you need a more comprehensive window library to create and control the window (or create and control it yourself) and you can then insert SFML into that window.
Got it, thanks.

General / Re: having a time based loop within a blocking based program
« on: August 19, 2018, 04:15:46 pm »
catching mouseMoved, if its coordinates are, let's say, within 2 pixels from left border, the view should constantly move left until mouse is moved out of that position. Pretty stright to do with pollEvent since the cycle will continue even if there are no events. But i dont want my program to keep doing cycles when the user is doing nothing, except for that single case, when the mouse is near the border.

General / having a time based loop within a blocking based program
« on: August 19, 2018, 03:14:12 am »
i was enjoying working more or less flawlessly in my project (not a game). Since its an utility and it doesnt have to eat resources as a game while not being used, i opted for waitEvent instead of pollEvent.
However working on workspace navigation i ended up with a "oh shit" situation.
I planned using both mouse-near-borders and arrow keys to navigate on the working zone in case it is bigger than the window.
And yeah i cant do that with waitEvent, because once the mouse gets to the border and the event triggers once, everything stops.

Indeed thinking later about that, programs like paint and paint.net, event notepad++ have keyboard navigation based on operating system simulated key repetition when the arrow is being held; which i could pretty much do as well.

The point is, is there any workaround you can suggest me to have it work with mouse-near-borders, like in rts games?

My only idea now was putting all the draw part in a function, and have my main loop looking like that (i know its ugly)

Code: [Select]
if waitEvent(event)
    //stuff happens
        case mouse on border:
            while pollEvent(tmp_event)
                if mouse on border
                    move screen
                    break out of poll event
        case other events:

Graphics / prevent last draw trail during resizing
« on: August 19, 2018, 02:37:04 am »
is there a way to prevent a window from creating a trail of what's in the borders during window resizing?
Just having it flat black would be better than this.
Note this is during resizing, not after left button is released. Windows blocks the window until resizing is complete afaik, but other programs i made with gamemaker dont have this behaviour during resizing.

General / Re: Trying to get pixe colors of textures
« on: August 07, 2018, 07:19:31 pm »
Generally speaking, to access pixels you should use sf::Image, not sf::Texture. That said, runtime image manipulations are a job for your graphics card, hence as Laurent said, use shaders for that.

Window / get events when window is not in focus
« on: August 07, 2018, 06:19:27 pm »
Is it possible to get events with waitEvent (or even pollEvent) without the window being in focus? Some (although not many) programs do that. For example you can play with PCSX2 while the window is not in focus.

An example would be making an on screen keyboard which highlights buttons pressed without being on focus, for making usage videos of another program.

General / Re: waitEvent is not working as i expected
« on: July 28, 2018, 12:05:43 pm »
wuoldn't it be a lot more intuitive to let waitEvent work with the same code of pollEvent by just replacing it?

nevermind i just realized it'd be stupid

General / waitEvent is not working as i expected
« on: July 28, 2018, 03:09:06 am »
I thought using waitEvent instead of Poll event in the exact same cycle would make my program block until an event is recived (like a mouse click). Instead whatever i do the program is stuck there and does nothing...
int window_mode()
        sf::RenderWindow window(sf::VideoMode(800, 600), "GraphMaker");
        while (window.isOpen())
                // Process events
                sf::Event event;
                //while (window.pollEvent(event))
                while (window.waitEvent(event))
                        // Close window: exit
                        switch (event.type)
                                case sf::Event::Closed:

                                case sf::Event::MouseButtonPressed:
                                        //do stuff
                                case sf::Event::MouseButtonReleased:
                                        //do stuff
                                case sf::Event::MouseMoved:
                                        //do stuff

                // CLS

                // DRAW
                //draw stuff

        return 0;

Compiling with visual studio, if that matters.
So i'm wrong thinking it should work this way or there's something else going wrong?

General / switch console mode-window mode
« on: July 27, 2018, 08:30:36 pm »
I'm planning to have my program be able to switch between two modes;
in console mode (already mostly done) it can be used as any command line program. Then a "window mode" command would open the sfml window, use fancy graphics etcc, and a button in the window would switch back to console mode. Now, i can perfectly do all that keeping the window back but blocked while the program is stuck in the window's main loop. But can i hide the console for the time the program is in window mode in a non-platform specific way?

General discussions / Re: Rendering expression from latex syntax
« on: June 22, 2018, 01:27:57 pm »
Well i'm not aiming to full latex syntax, i'd rather focus on expressions only, which already excludes a lot of weird latex things.
(nevermind i just noticed that your library focuses on expressions only as well)
Also making it in an SFML-like manner, sharing fonts, coordinate types etcc would allow to inset it in an SFML code nicely.

latexpp uses KaTeX to render LaTeX to HTML. Because KaTeX is a JavaScript library, latexpp uses Google's V8 engine to write JavaScript from C++. Image output is enabled by the wkhtmltox C library.
This thing though smells so much overhead-ish.  :-\

General discussions / Rendering expression from latex syntax
« on: June 18, 2018, 09:14:32 am »
is anyone interested in working together on code that takes as input a latex math expression and gives as output the image of that expression, without relying on outside code?

I'd like to work on that but probably some help would benefit; still not sure if using lex/yacc for parsing or doing it manually, but i've always used such tools for simple (and sample) code at university, never used them for anything more serious.

General / Single loop vs 2 threads
« on: June 16, 2018, 02:04:41 pm »
    I'm working on a program (non game) which would have long times of non-interaction with the user. (think to some explorer windows for example, you maybe drag something and keep the window open there doing nothing.
    Since i'd not need a constant "game loop", but things happen only when the user does something i've use waitEvent instead of pollEvent. (it's not a game, i don't want it to suck computer resources, i want it to use as little as exactly needed).

    Now, let's suppose i want to add an animation in the background (some particles effect), which in NO way depend on user input. They're just there, do they thing with 0 interaction, they just update coordinates, create and destroy. Again since it's not a game supposed to get the most out of my resources, for this i'd use a fixed-time step with sleep (don't even need precise timing, just *some* timing). I don't want it to update 500 times per second really; 30 is already fine enough.

    Now my question is, since the particles are just a constantly flowing effect and have nothing to do with user interaction, should i:
    • Use poll event in the same fixed-time step loop that handles particles.
    • Use one thread for particles, which updates 30 times per second, and another thread for handling input.

    I'm more towards the second idea because of the following reasons:
    the two loops work with totally different things, it'd also help separating them logically. Since they don't affect each other in any way, i'd not even need to use mutex guards when performing calculations, because nothing is shared.

    But now comes my concern: how can i handle drawing? Particles should update the drawing 30 times per second, while the input loop should update the drawing only when the user does something. To do so each loop would have to access some of the other loop's data (for example if input loop is drawing i need to get particles coordinates as well, don't want them to disappear in between two frames). I'd have to use mutexes for the short time the drawing cycle is accessing coordinates from the other's cycle.

    When i came to that conclusion i started guessing… well maybe i should just smash everything in the same cycle and gg.
    But since i usually tend to prefer splitting things that have nothing to do with each other, i'd love to see suggestions about the second implementation...

Just thought a thing:
can i have the input loop draw in memory a "temporary image" and the particles loop draw that temporary image on screen with then the particles on top of it? That way all i'd have to do is protecting with a single mutex the access to said temporary image! Does it work in your mind?

General / Re: Interrupt based project
« on: March 12, 2018, 12:42:56 pm »
Oh that's perfect! Couldn't find it immediately...
I just noticed it was mentioned in the "events explained" page, i just missed it for some reason, thanks!

General / Interrupt based project
« on: March 12, 2018, 12:46:05 am »
is it possible (and if so is there any example of) to make an interrupt based project with sfml rather than a polling based one? For some multimedia software (non-necessairly-games) having a fixed step loop is already bad enough. For example if i make a photo viewer, i really have no reason whatsoever to update anything in the window until there's a mouse click or a key press.

Pages: 1 [2] 3 4