4 ms·
I wish there was an easier way to do graphics on Linux. Xlib is really hard to use and OpenGL depends on the Xlib extension GLX. I've read that Wayland creates
by matheusmoreira 7y ago
I wish there was an easier way to do graphics on Linux. Xlib is really hard to use and OpenGL depends on the Xlib extension GLX. I've read that Wayland creates OpenGL ES contexts using nothing but the kernel's generic buffer management and direct rendering manager. Not sure how that works. Not sure if Vulcan is usable without dependencies either.
- klodolph 7y agoIt’s common to use e.g. GLWF or SDL if you want an OpenGL context on Linux. It uses Xlib underneath but you don’t have to touch it yourself.
- matheusmoreira 7y agoBut is it possible to render graphics without any libraries whatsoever?
- therein 7y agoYou could write to /dev/fb0 and use ioctl's on it to make some adjustments.
- abainbridge 7y agoYou could open your own socket to the xclient and speak xprotocol yourself.
- klodolph 7y agoI think if you ask this question you had better be prepared to add some clarifying information here. Are you asking if it is technically possible? Yes, because libraries are just code + data, and you can trivially just duplicate the library functionality in your own library. Are you trying to eliminate library dependencies for some kind of demoscene competition? You could just use the framebuffer. Are you trying to write portable code that doesn’t depend on particular libraries being installed? That’s possible too, in various ways, such as dynamic linking. Are you doing a homework assignment and want to render graphics, but the rules for the homework state “no libraries”? Also possible, but I would recommend talking to the teacher to clarify things. Do you just need to display something simple to the user? You can use ASCII art and set colors by writing ANSI escape sequences, and you can also use emoji. Some people use this to make command-line applications with some simple graphics. Finally, when you say “without any libraries” do you mean to include the standard library, or is that library OK? In general I find the “without using libraries” questions that people ask a bit vague and difficult to answer.
- DonHopkins 7y agoYou could use a speech synthesizer to describe what you want to draw in words, and let the user render the graphics in their imagination.
- vetinari 7y agoWayland compositors have to use lower-level APIs like libdrm, in order to be handle clients using OpenGL, OpenGL ES, Vulkan, libva and other hw-related APIs, all at once. Wayland clients don't have to. For OpenGL, OpenGL ES there's EGL, for Vulkan, it's the other way and Vulkan provides extensions for WSI (window system integration).
- matheusmoreira 7y agoThanks for clarifying this for me. I didn't know about libdrm. I'm going to read the source code now to learn more.
- josefx 7y agoYou can create an EGL context on Linux. I think it still uses Xlib in the background if you are running an X Server, but you would use egl instead of glX calls.