I only know C programming. Using C programming, I want to build my own library (to control my Display and Speakers) that's specifically useful for my projects.
I don't want any readymade libraries with different features, I just want direct control to every pixel of a computer (atleast my computer's display, I will think about cross platform later) and every vibration of my speaker(s).
How can I get this?
First Edit: After getting some informations in the comment-section/answers, I came to an understanding that in modern computers, direct access is not possible as every aspect regarding Display and speaker is controlled by the OS, and I can only request the OS to display a graphics in it's Window or play a sound by pre-encoding my sound in one of the supported audio formats (correct me if I'm wrong).
Now, let's change the scenario. I have my Display (with its driver hardware), my speaker (with its driver hardware), and a Micro-controller.
Now, by coding my own OS and booting it in my microcontroller, can I get direct control to every pixel of a computer and every vibration of my speaker(s).
CodePudding user response:
You can't. You have to get the OS to do it for you - in fact, that's the entire point of an OS. And that means either making system calls directly from assembly code (hard on Linux; practically impossible on Windows because they are undocumented) or using a library to tell the OS to do things.
You are probably interested in using a library that's as close to the OS as possible - "batteries not included" - so in Linux that would be something like ALSA (sound) and XCB (graphics) rather than something like Qt.
You can minimize your library usage - for example, if you make an array of pixels, and you only tell the OS "please create a window" and "please draw these pixels in my window" and "please play this sound data".
Of course it is also possible to tell it to make your program fullscreen so that the user can't see anything else. This is usually done by making a window and then making the window fullscreen. Linux does actually have ways to get more direct screen control - accessing the screen as a "framebuffer device" - but if you use this, you can't run any other graphics programs at the same time (not even the desktop). And you are still asking the operating system to put pixels on the screen - not talking to the hardware.
If you want to write a program that doesn't run with an OS, that's a completely different question (and still difficult).