as an game engine dev i created an console graphics engine to create blazing graphics contains lighting and shadows and draw algorithms and the for loop for my 3D part was running slow and no flicker but slowly generates the walls and everything and when i update the frame again the same thing happens

Dani AI

Generated

Short diagnosis and where to look first (based on description and comments)
The symptom "no flicker but the frame slowly appears" usually means either (A) the program is writing to the terminal character-by-character or flushing frequently, or (B) the CPU work for each cell (lighting, divisions, trig) is too heavy. Which one is dominant depends on OS and how output is done. Missing details that change the fix: Windows vs POSIX terminal, whether you use std::cout/printf, and the frame buffer size.

Concrete, fast checks to run immediately

  • Disable C++ iostream syncing and avoid std::endl (which flushes).
  • Allocate your frame buffer once, draw into it in memory, then write that buffer in one call.
  • Measure generation time vs IO time with chrono to see which is the bottleneck.

Example snippets (minimal patterns)

Disable iostream sync and increase stdout buffering:

std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
setvbuf(stdout, nullptr, _IOFBF, 1<<20);

POSIX-style single write of a full text frame:

std::string frame = /* width*height chars + newlines */;
write(STDOUT_FILENO, frame.data(), frame.size());

Windows console: build a CHAR_INFO array and call WriteConsoleOutput once per frame:

HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
// fill std::vector<CHAR_INFO> buf(width*height) with chars and attributes
COORD bufSize = { width, height };
COORD bufPos = { 0, 0 };
SMALL_RECT rect = { 0, 0, (SHORT)(width-1), (SHORT)(height-1) };
WriteConsoleOutput(out, buf.data(), bufSize, bufPos, &rect);

Algorithmic and workflow tips

  • Profile inner loops; expensive ops (div, sqrt, sin/cos) should be replaced with lookup tables or fixed-point where possible.
  • Avoid per-pixel dynamic allocations and per-pixel system calls. Precompute reciprocal/depth math.
  • Use dirty-rect updating if only parts of the frame change.
  • If the console cannot meet your target FPS, move to a windowed graphics API (SDL/OpenGL) which uses GPU acceleration for lighting/shading.

Troubleshooting steps

  • Time only the buffer fill (CPU) and then time only the single write (IO). That isolates whether to optimize algorithms or change output method.
  • Try a very small frame and a very large frame to see scaling.
  • If using Windows, test WriteConsoleOutput; if POSIX, test a single write or ncurses.

Recommended Answers

All 2 Replies

For gaming I found I need pretty high end systems to get high performance unless I'm running an old game such as Doom. Details are absent here but I have run into folk trying to write a game (console or not) on old laptops with Intel graphics and they are like Dorothy in the Wizard of Oz. A little lost but at the beginning of the journey. Eventually they learn that you can only milk lower end PCs for so much or move to a better machine. About 1 in 100 will double down that they can get the performance up on their machine and few of those achieve their goals. It's that hard. Even I tried to see what I could eek out of Intel graphics and the short story is lesson learned. Hardware is cheaper than spending years trying to get triple A games to work well on the low end PCs.

commented: but the thing i can run an game like call of duty warzone on high settings this the console sir not that big is there any way to make it faster +0

Tell more. By console you could mean the command prompt in Windows or something else. But let's look at Warzone. A quick look finds it uses the following engine:

If games and game developers need speed they pick an engine. But here you haven't written enough for me to offer much else other than go get a game engine and build on that system.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.