Standardized graphics library for C++ is not coming

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Standardized graphics library for C++ is not coming

Post by albinopapa » April 7th, 2019, 11:32 pm

2D or not 2D

While working with the chili framework is fine and there are plenty of third party game libraries, it would be nice to have something that comes standard with the C++ library. I find it cumbersome to have to download a new chili framework or whatever just to try something new out. When you just want some text on screen, it's real easy to create a main function and use printf/scanf or cout/cin, but nothing like that for testing out something graphically. Creating a Windows window and setting up some sort of rendering back end can take quite some time if done by hand. I don't know how long it takes or what is involved in making a Linux window and setting up an OpenGL back end, but I'm sure it's not as simple as:

Code: Select all

#include <graphics> 
#include <input>

int main()
{
     auto target = std::graphics::render_target( 800, 600, std::color_depth::32bpp );
     auto window = target.get_window();
     auto mouse = std::input::mouse();
     auto keyboard = std::input::keyboard();
     
     std::point<int> origin{};
     mouse >> origin;

     while( window.is_open() )
     {
          std::input::keyboard::state kbd_state;
          keyboard >> kbd_state;
          
          if( kbd_state && (*kbd_state) == std::input::keyboard::key_press )
          {
               if( (*kbd_state).code == std::input::keyboard::key::escape )
               {
                    window.close();
               }
          }

          std::point<int> endpoint {};
          mouse >> endpoint;

          target << std::graphics::line( origin, endpoint );
     }
}
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
Uta
Posts: 9
Joined: April 1st, 2019, 10:12 pm

Re: Standardized graphics library for C++ is not coming

Post by Uta » April 8th, 2019, 12:02 am

I don't know I'm understanding this thread right, but I believe the creator of C++ said he didn't want to add special graphics stuff because by the time he had thought about doing it there were already several great third party set-ups for it, and if he added his own it would have to be modeled after one of those, and ultimately leaves someone jilted. So he left it out and just trusts people to find the third party support they need for the tasks they wish to accomplish.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Standardized graphics library for C++ is not coming

Post by albinopapa » April 8th, 2019, 4:54 am

That is only one side of the argument though.

Look at chili's approach to teaching C++. He created a framework to allow beginners the joy of seeing their efforts graphically. This gets and keeps people interested and this is the other side of the argument. A lot of people probably get turned off by the lack of graphics support in the standard library and a new comer isn't going to understand how to install a third party library to use in a C++ project they barely know how to create in the first place. So they will see that and go over to Java or C# with the .Net Framework.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Standardized graphics library for C++ is not coming

Post by chili » April 8th, 2019, 12:52 pm

There are proposals, so it might happen someday. I'm more interested in seeing a <networking> lib tbh, but <graphics> would be nice.

http://www.open-std.org/jtc1/sc22/wg21/ ... 0267r7.pdf
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Standardized graphics library for C++ is not coming

Post by albinopapa » April 8th, 2019, 7:10 pm

Lol, I used the url tags, but didn't put a description between them, so the link didn't show up. The article is dated after that paper you posted from a guy ( named Guy ), that presented this papaer or a version of it. Six years apparently and they finally decide to drop it because of "complexity" in standardizing the wording or something like that.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Standardized graphics library for C++ is not coming

Post by albinopapa » April 8th, 2019, 7:32 pm

A networking lib is more likely than a graphics lib at this point because work is being done with executors is geared to that end anyway. In a cppcon video I think, the presenter said they had to get executors in place before a network library among other threaded related libraries can be implemented.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

JDB
Posts: 41
Joined: August 5th, 2015, 9:50 am
Location: Australia

Re: Standardized graphics library for C++ is not coming

Post by JDB » April 9th, 2019, 10:44 pm

albinopapa wrote:
April 7th, 2019, 11:32 pm
2D or not 2D

Creating a Windows window and setting up some sort of rendering back end can take quite some time if done by hand. I don't know how long it takes or what is involved in making a Linux window and setting up an OpenGL back end, but I'm sure it's not as simple as:
If you use a library like GLFW or SFML it's basically the same difficulty, and they have nice documentation which helps a lot. The main.cpp file from my negative mass simulator is basically a full example of how to create an OpenGL window using GLFW. I also handle the creation of different window types based on a config file, it can create a fullscreen window, fake fullscreen window, and a normal window. It should also work on both Windows and Linux systems since OpenGL is cross-platform and I wrote the code to compile with GCC so it should be portable. Another advantage of OpenGL is that there's interoperability with OpenCL, which is what I used to compute the particle physics in my simulation. Being able to use the GPU for common problems which benefit from parallelization is a very nice tool to have, and since the OpenCL kernel code is basically C it's very easy to learn.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Standardized graphics library for C++ is not coming

Post by albinopapa » April 10th, 2019, 5:19 am

I really have nothing against the third party libraries, SFML is by far my favorite. One issue I've noticed though with using different libraries is there isn't a standard data type for a two-dimensional vector or bounding rectangle. Could we at least get an extended math library with these data types and their associated math functions at least?

I think every 2D and probably some 3D libraries have a vectors, matrices and bounding areas/valumes, I think it would be a very nice thing to have these types standardized and a math library to deals on them. I've even gone as far as making unions for the different types I was using.

Code: Select all

	union Vec2f
	{
		Vec2f()=default;
		constexpr Vec2( const b2Vec2& pt )noexcept
			:
			pvec2( pt )
		{}
		constexpr Vec2( const sf::Vector2& pt )noexcept
			:
			d2dvec2( pt )
		{}
		constexpr operator b2Vec2()const noexcept { return b2vec2; }
		constexpr operator sf::Vector2()const noexcept { return sfvec2; }
		b2Vec2 b2vec2 = { 0.f, 0.f };
		sf::Vector2 sfvec2;
	};
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Standardized graphics library for C++ is not coming

Post by chili » April 12th, 2019, 12:45 pm

Standard for 2-element to 4-element vectors with SIMD support where applicable would be nice.
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Standardized graphics library for C++ is not coming

Post by albinopapa » April 12th, 2019, 6:29 pm

chili wrote:
April 12th, 2019, 12:45 pm
Standard for 2-element to 4-element vectors with SIMD support where applicable would be nice.
Right?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply