Giter Site home page Giter Site logo

Flickering about cpp-terminal HOT 20 OPEN

iganinja avatar iganinja commented on August 10, 2024 1
Flickering

from cpp-terminal.

Comments (20)

iganinja avatar iganinja commented on August 10, 2024 1

Hi @flagarde, thanks for your answer.

I have this currently:

image

(Yeah, colors are horrible, but they will be configurable 😂 )

I'm waiting to input with Term::Platform::read_raw(), then update things accordingly, create the string with Window::render() and show it with std::cout + std::flush . Wait 100ms and start again.

With flickering I mean that whole screen was blinking, some frames were drawn black, or the screen filling was noticeable. That was happening until I pulled cpp-terminal code from master yesterday, now it does not blink at all, even if I don't do the 100ms waiting. So I guess the problem is solved, but my question was that cpp-terminal being used the way I use it, should not blink/flicker at all, shouldn't it?

When I change the size of the terminal strange artifacts occur and also some blinking, but this doesn't bother me, it's normal even in graphical applications. After I stop resizing everything works perfectly. I didn't try the new way provided in the link you mention, I use the Window class for the moment.

from cpp-terminal.

certik avatar certik commented on August 10, 2024 1

@iganinja nice Turbo Pascal style menus. :) It would be nice to have them as widgets in cpp-terminal eventually.

from cpp-terminal.

flagarde avatar flagarde commented on August 10, 2024

@iganinja Hello, thanks for your nice words. Some changes has been done related to resizing and maybe this create new issues. Would you mind give some codes to test ? What do you call flickering, something like redrawing (sorry my english is not so good)?

Does this happen when you change the size of your terminal? have you tried to use the new way provided by #234 (in https://github.com/jupyter-xeus/cpp-terminal/blob/master/examples/menu.cpp). The API has changed quite a lot and it is still not fixed; pulling gives you the new features but would need to change your code too, that's why there is not official new version. I'm just proposing some change and @MCWertGaming is the maintainer of the package

from cpp-terminal.

flagarde avatar flagarde commented on August 10, 2024

@iganinja I know they were some bug before the last merge in windows. Please note that key can be NO_KEY so you should add a test case for this. The reason is that read_raw return Event that can be other things than Key. But it is allowed to cast Event to Key and in the case the event is not a key, the key is then NO_KEY.

I recommend you to use the same trick than in menu.cpp in the example. Maybe you don't have to do the wait by yourself. You could use read_event that return only when it received event (key, change screen size ...). read_raw is more an internal function

from cpp-terminal.

flagarde avatar flagarde commented on August 10, 2024

@iganinja This is fixed ?

from cpp-terminal.

iganinja avatar iganinja commented on August 10, 2024

Hi!
I tested it with my program in Windows: it flickers a little bit in a line. In Linux it seems rock solid, no flickering at all.

from cpp-terminal.

flagarde avatar flagarde commented on August 10, 2024

@iganinja thx for the feedback. We can let this open then.. Not sure if it's a problem from the library of from Window$. Maybe there is some hack we could use I remember some discussion about this.

Are you using cout or Term::terminal<< ?

from cpp-terminal.

iganinja avatar iganinja commented on August 10, 2024

std::cout. Perhaps I have somewhat older version? I didn't touch it in weeks.

from cpp-terminal.

TobiasWallner avatar TobiasWallner commented on August 10, 2024

I noticed flickering too in my application as you described on Windows but not on Linux. I figured it was probably an issue with the frame rate of the console or when the console triggers a new redraw of the screen. I guessed that the Windows console maybe has a higher frame rate so it is more likely to trigger a redraw just after the ClearScreen command. So I got rid of ClearScreen and rewrote the rendering of my screen elements so that they do not need a clear screen before printing.

Maybe that helps

from cpp-terminal.

flagarde avatar flagarde commented on August 10, 2024

I wonder if it's not the contrary the console in windows is poorly optimized. Are you using Term::terminal or cout. I heard somewhere cout is not buffered or things like this in windows or a very small buffer

from cpp-terminal.

TobiasWallner avatar TobiasWallner commented on August 10, 2024

I notized it with both. but part of my change from not using ClearScreen anymore also involves of just rendering and printing the few characters that actually change instead of re-rendering and drawing the whole screen. So maybe because my newer solution needs less memory or buffer space as you suggest fixed it.

from cpp-terminal.

flagarde avatar flagarde commented on August 10, 2024

@TobiasWallner Your solution is general or a bit hacky? If it's a general one I think this could be incorporated into this library as it would be a very nice addition 😀

from cpp-terminal.

TobiasWallner avatar TobiasWallner commented on August 10, 2024

it is general to my application but probably specific in terms of your library.

It is only applies to the design elemts of my projet like grids, labels, editable text fields, comman lines and the like.

The idea is that each element has functions that change something, like inserting a character or moveing the cursor. They will do that + give you a render of the changes which is just a move to the one character and the new value.

from cpp-terminal.

flagarde avatar flagarde commented on August 10, 2024

I see, so it seems the problem is the clearscreen ?

from cpp-terminal.

TobiasWallner avatar TobiasWallner commented on August 10, 2024

yes I think so

from cpp-terminal.

flagarde avatar flagarde commented on August 10, 2024

@TobiasWallner I'm trying to implement a more system base API to wrtite to console. I have been told the C C++ Windows is quite buggy and not so efficient sometimes. I already did a first step with file.hpp but need to improve it. Maybe this will improve performance. I have seen an other way to improve performance I will do a PR for this

I didn't benchmark as i'm doind on virtualbox so the results it's maybe not what one should expect but I can see it by eyes so lets implement and check on other system

from cpp-terminal.

TobiasWallner avatar TobiasWallner commented on August 10, 2024

I could run a benchmark natively if you want me too.

from cpp-terminal.

flagarde avatar flagarde commented on August 10, 2024

@TobiasWallner Would be great or to have a program with benching on this repo :)

from cpp-terminal.

TobiasWallner avatar TobiasWallner commented on August 10, 2024

Your solution is general or a bit hacky? If it's a general one I think this could be incorporated into this library as it would be a very nice addition

I was wondering, you do have a class that stores one frame, the window class, right?
Could we calculate the difference of of two windows? - which is then a map of all things that changed? and then just print that to reduce the ammount of data that gets printed every time?

could look like this:

newFrame = render();
diff = newFrame - prevFrame;
Term::cout << diff;
prevFrame = newFrame;

from cpp-terminal.

certik avatar certik commented on August 10, 2024

We already do the diff, although the diff is quite "primitive":

std::string Term::Window::render(const std::size_t& x0, const std::size_t& y0, bool term)
, we need to minimize the change needed to output, so that it flickers less.

However, the demos that we have don't seem to flicker for me.

from cpp-terminal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.