1

I’m trying to find out how to draw graphics in C/C++ without any external libraries. I know it is possible because I’m pretty sure the libraries are programmed in either C or C++ and I want to know how. Do they use their own virtual machine sort of like I’m pretty sure Java works, or do they access your machines video memory? I’m mainly asking about libraries like OpenGL and SDL2.

I’ve tried the win32 api but realized that it’s technically an external library and also even if it isn’t, are there any other ways? I’m also avoiding win32 cuz of how complicated it looks but I might just be being a wussy.

7
  • C++ does not have graphics as part of the Standard C++ Library. You'll have to use an external library. C does not have graphics as part of the Standard C Library. You'll have to use an external library. C is not C++; C++ is not C. There is no language called C/C++ (although I'm working on a language that I'm calling C/C++ based on OCaml). Commented May 10, 2024 at 13:23
  • how would you do that ? send zeros and ones to the monitor ?! the OS controls the monitor and your GPU and gives you the ability to manipulate them using those APIs, so you need some API to draw on screen. Commented May 10, 2024 at 13:23
  • You cannot put OpenGL and SDL next to each other. OpenGL libraries are provided by your graphics card manufacturer and they translate the very high level OpenGL drawing commands to low-level drawing operations for the graphics card to consume. SDL in turn provides drawing commands that translate to OpenGL drawing commands. Commented May 10, 2024 at 13:26
  • 2
    @AhmedAEK "send zeros and ones to the monitor ?!" - well, this is pretty much what we do with bare-metal or could do and done back in the DOS times. Not that far-fetched. Sure, not something we do with modern OS. Commented May 10, 2024 at 13:26
  • 1
    Your best bet is a cross-platform library such as SDL, SFML, Raylib. Commented May 10, 2024 at 13:29

2 Answers 2

2

I’m trying to find out how to draw graphics in C/C++ without any external libraries.

C does not define graphics functions.

Sign up to request clarification or add additional context in comments.

Comments

1

No modern OS that I know of allows direct access to video memory. It is all mediated through the driver for the graphics card or chip. That is in turn mediated by the OS. There is very little to be learned from trying to bypass these two layers.

If you just want to plot pixels and nothing else, other people have had success with raylib.

2 Comments

Is raylib programmed in c or c++? If so, how did the developers make it work?
Read the source code or at least the site. OpenGL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.