Coder Social home page Coder Social logo

Comments (4)

VincentFoulon80 avatar VincentFoulon80 commented on June 10, 2024

I wasn't aware of this kind of issue, I originally tried to avoid overdrawing because printing chars is notoriously slow on most terminals (sometimes worse on Windows)

from console_engine.

lesleyrs avatar lesleyrs commented on June 10, 2024

Yea all I'm doing right now is just filling a full screen (actual screen) with dots which is a lot. I think it takes about 4 ms if I saw correctly (debug mode).

However speed is not my problem right now, I set the frame rate at 1 per second but because it immediately flushes if I draw more than a few rows it's just ignored and flushes instantly. Then whatever is drawn on top either flickers or doesn't show.

The part that I don't understand is that avoiding overdrawing can't be the fix to my problem as the FIRST frame in console_engine already loads the way it should.

In console_engine if you call:
let mut engine = console_engine::ConsoleEngine::init(160, 45, 1).unwrap();

It draws the entire screen (for me anyway) after waiting the full 1 second which is correct.

But my behavior on a simple project is when I draw the full screen this way it just flushes instantly, no waiting unless I draw a tiny area. I think I'll keep looking into this.

https://docs.rs/crossterm/latest/crossterm/macro.queue.html

Queued commands must be flushed to the underlying device to be executed. This generally happens in the following cases:

When flush is called manually on the given type implementing io::Write.
The terminal will flush automatically if the buffer is full.
Each line is flushed in case of stdout, because it is line buffered.

Edit: I see you have another draw function that uses execute!, but not sure about the difference in usage between them.

from console_engine.

lesleyrs avatar lesleyrs commented on June 10, 2024

Ok some friendly guy in the crossterm discord helped me solve the problem. I had to replace:
let mut stdout = stdout();
with
let mut stdout = BufWriter::with_capacity(640000, stdout());

I guess the reason you didn't need to do this is because you are using screens as the buffer and that magically solves it? Problem solved anyway :D

from console_engine.

VincentFoulon80 avatar VincentFoulon80 commented on June 10, 2024

Interesting to know though, thank you for reporting back !

from console_engine.

Related Issues (12)

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.