1

I am currently trying to create a game using the windows console. It is supposed to be a raytracer (in the fashion of Wolfenstein 3D). I need to shade objects that are further away with different unicode characters called "shaded blocks".

The problem is, that these characters seem to bug out the Windows console. The "full block" looks as it is supposed to look: The walls displayed with the "FULL BLOCK" character (0x2588)

However, when I use the "DARK SHADE" character, the console seems to bug out and displays this: The walls displayed with the "DARK SAHDE" character (0x2593)

I then did some other testing. When pasting the character into the CMD, it is more slim, and taller: enter image description here

However, when going into the consol properties and exiting it again, it squishes the blocks together, and adding masses of space characters after them (I added a dot to the end of the line so you can see where the spaces end): enter image description here

I used Consolas with 16pt for all of them.

Can you tell me how to display these characters properly? Thanks in advance.

D4RKS0UL23
  • 45
  • 1
  • 5
  • Possibly the spaces effect you get is connected to Windows 10's smart resize functionality. It's intended to flow text on resize, but retain line breaks specified in the original output. However, possibly the spaces effect is instead (or in addition) connected to the way you output the characters, if you do that via ordinary stream i/o. You can take complete control of a console window via the console API functions. That includes buffer size, window size, wrapping etc. Depending on your needs you may find the ncurses library helpful. It even provides some portability. – Cheers and hth. - Alf Nov 04 '17 at 14:32
  • @Cheersandhth.-Alf I am writing the characters into a buffer which gets sent to the window. But it still looks the same way. – D4RKS0UL23 Nov 04 '17 at 14:37
  • @Cheersandhth.-Alf Okay, the problem is solved by changing the console font to Lucida Console. But to be honest, I think it is kinda ugly, so is there a way to prevent this while keeping Consolas? – D4RKS0UL23 Nov 04 '17 at 14:45
  • Sorry, I don't know. It's weird that it depends on the font. – Cheers and hth. - Alf Nov 04 '17 at 14:49
  • Maybe try Courier New, but it's maybe even uglier? – Cheers and hth. - Alf Nov 04 '17 at 14:54
  • @Cheersandhth.-Alf It bugs out as if I used Consolas. I don't really know what is causing this to be font dependent, and I can't find entrys on the internet for this bug – D4RKS0UL23 Nov 04 '17 at 15:00
  • @Cheersandhth.-Alf The raster font is the best option I could find. Can't compete with Consolas, but it isn't as ugly as Lucida etc. – D4RKS0UL23 Nov 04 '17 at 15:02
  • Not very clear to me what "bug out" means. But you'll inevitably get artifacts if the character cell size in pixels is not a nice integer multiple of the pattern size. – Hans Passant Nov 04 '17 at 15:31
  • @HansPassant: It's nothing to do with the resulting pattern or not. It's a bug or set of bugs in the Windows 10 console where it spaces things out or adds spaces at end. I've seen it with simple input after prompting with Norwegian or Russian (Cyrillic) characters. As far as I know this was introduced in Windows 10. I think connected to the general console revamping in Windows 10 (reflow, ANSI escape support, etc.). – Cheers and hth. - Alf Nov 04 '17 at 15:50
  • IMHO just give up windows console, given that it is still [just broken on many things](https://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how/388500#comment80919817_388500) – Passer By Nov 04 '17 at 17:32
  • 1
    Maybe show some code :^) – Mark Tolonen Nov 04 '17 at 22:35

1 Answers1

-1

[This is not an answer. It's a comment that requires code.]

Maybe try this:

#define UNICODE
#define NOMINMAX
#define STRICT
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#include <iostream>
#include <string>
using namespace std;

namespace winapi {
    HANDLE const    std_output  = GetStdHandle( STD_OUTPUT_HANDLE );

    void write( wchar_t const* const s, int const n )
    {
        DWORD n_written;
        WriteConsole( std_output, s, n, &n_written, 0 );
    }

    void write( wstring const& s )
    {
        write( s.c_str(), s.length() );
    }
}

auto main()
    -> int
{
    wchar_t const   light_shade     = L'░';
    wchar_t const   medium_shade    = L'▒';
    wchar_t const   dark_shade      = L'▓';

    winapi::write( wstring( 64, dark_shade ) + L'\n' );
}
Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
  • This bugs out as well – D4RKS0UL23 Nov 04 '17 at 15:22
  • It showed some interesting behaviour though: When changing the 64 to a 123, it creates 3 rows of characters. If you highlight the space right to the 3 rows, some blocks will be displayed or disappear – D4RKS0UL23 Nov 04 '17 at 15:26
  • If you really want to post comment with code, just comment a link, people won't miss it even if it broke, given its a comment – Passer By Nov 04 '17 at 17:25