p-ranav / tabulate

Table Maker for Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weird exeption when using with OpenGL 4.3

ENGY-ORG opened this issue · comments

Whenever I try to create a table and show it, it will do so. But then it will throw me an exception in my case that the position of my OpenGL framebuffer object could not be read. I tried both c++14 and c++17 and it's a x64 bit executable if that matters.

(Win32): "C:\Windows\System32\TextInputFramework.dll" loaded.
Exception thrown at 0x00007FF6D4FC4D3E in .exe: 0xC0000005: access violation at position 0x0000000000000000.

I'm not sure if this has anything to do with tabulate? tabulate simply does string formatting that you can print to a stream.

It seems like your OpenGL framebuffer object could not be read, which is causes an exception. Maybe try and figure out why and address those issues?

If I'm mistaken, please describe your problem with a piece of sample code that I can test against. Ideally, I would need a standalone example that uses tabulate, with a clear explanation of the tabulate-related bug (i.e., behavior that is inconsistent with expectations).

The problem is that whenever I try to run this code:

Table universal_constants;

universal_constants.add_row({ "Quantity", "Value" });
universal_constants.add_row({ "Characteristic impedance of vacuum", "376.730 313 461... Ω" });
universal_constants.add_row({ "Electric constant (permittivity of free space)", "8.854 187 817... × 10⁻¹²F·m⁻¹" });
universal_constants.add_row({ "Magnetic constant (permeability of free space)", "4π × 10⁻⁷ N·A⁻² = 1.2566 370 614... × 10⁻⁶ N·A⁻²" });
universal_constants.add_row({ "Gravitational constant (Newtonian constant of gravitation)", "6.6742(10) × 10⁻¹¹m³·kg⁻¹·s⁻²" });
universal_constants.add_row({ "Planck's constant", "6.626 0693(11) × 10⁻³⁴ J·s" });
universal_constants.add_row({ "Dirac's constant", "1.054 571 68(18) × 10⁻³⁴ J·s" });
universal_constants.add_row({ "Speed of light in vacuum", "299 792 458 m·s⁻¹" });

universal_constants.format()
	.font_style({ FontStyle::bold })
	.border_top(" ")
	.border_bottom(" ")
	.border_left(" ")
	.border_right(" ")
	.corner(" ");

universal_constants[0].format()
	.padding_top(1)
	.padding_bottom(1)
	.font_align(FontAlign::center)
	.font_style({ FontStyle::underline })
	.font_background_color(Color::red);

universal_constants.column(1).format()
	.font_color(Color::yellow);

universal_constants[0][1].format()
	.font_background_color(Color::blue)
	.font_color(Color::white);

universal_constants.print(std::cout);

It throws this and other random exceptions. I've already tried to run tabulate as a stand-alone application, and it works fine.
My question here is, does tabulate maybe include something which messes up with OpenGL libraries like glador glfw?
Perhaps the order in which the headers include certain files?

I can't think of anything since tabulate only includes standard headers (i.e., no platform-specific headers like Windows.h) - You can check the single_include file here.

What terminal are you using?

Okay, so I fixed the issue with the exception. Turns out that Table universal_constants; makes a random function in my code return false instead of true. Now I got a completely different problem. Whenever I change the color of anything using tabulate, it will completely mix up the color output of my shader. I don't expect you to know why. But maybe you have an idea on why this is happening? I can send reference screenshots when needed.
To your question: I am using the default Windows terminal.


universal_constants[0].format()
		.padding_top(1)
		.padding_bottom(1)
		.font_align(FontAlign::center)
		.font_style({ FontStyle::underline })
		.font_background_color(Color::red);

	universal_constants.column(1).format()
		.font_color(Color::yellow);

	universal_constants[0][1].format()
		.font_background_color(Color::blue)
		.font_color(Color::white);

Only calling universal_constants.add_row({ "Quantity", "Value" }); will mix up the light color. Can't figure out why.

Are you rendering something to the terminal with OpenGL? (is that a thing? don't you have a separate OpenGL context + window?) I'm trying to understand why tabulate/terminal colors would affect your shaders.

If you want to try and reset the terminal colors after printing the table, you could try stream << termcolor::reset;, see here. tabulate calls this after printing each element in the table to reset the colors and colorize the next element (cell, row, etc.) in the table.

The terminal runs on its own, and resetting the colors doesn't help. It's really weird, and I think that this might be an error with OpenGL itself and how colors operate. Not sure though.