C++ pixel manipulation.

closed account (9y8C5Di1)
Instead of using pre-defined graphics functions provided by certain libraries like SDL, i would like to write my own graphics functions from the ground up (at least almost). I have little idea of how this works, but my guess is that i need to interact with devices like the graphics card, in order to display pixels.

Can anyone elaborate? Is it possible to create a function to draw pixels on to the screen with pure c++, or do i need a tool of some kind to allow device interaction in order to draw pixels?

Keep in mind, i have very little knowledge about graphics.

just use OpenCV and save a lot of time.
@Darkmaster: did you mean OpenGL? ;)
almost the same :D
Can anyone elaborate? Is it possible to create a function to draw pixels on to the screen with pure c++


Define "pure C++"

C++ is just a language, and strictly speaking you can't do anything with it without the use of libraries. Not even keyboard input/console output.

Everything is done with libraries. Unless you're interfacing with the video driver directly (not recommended... and I'm not even sure if it's possible for programs to do that on modern OS's... since that would be an EXTREMELY high system security/stability risk).

Libraries like SDL, SFML, Allegro, etc just use other libraries like DirectX, OpenGL, etc. DirectX, OpenGL etc provide a common API to interface with the actual hardware.

But it all goes through the OS, because the OS has to manage system resources.


Basically, the days of one-on-one communication with the hardware are gone. Unless you are writing device drivers, or boot systems, etc... you probably won't be doing actual hardware communication anymore.


So yeah... everything is done with libraries. So to answer your question... "no, you can't do that with pure C++. You need a library."

The question now is what kind of library do you want to use?

Higher level libraries like SFML, SDL, Allegro are easier to use and work across several platforms... but add an additional dependency to your program.

Lower level libraries like DirectX, OpenGL are generally more difficult to use but offer greater flexibility. Using these libs still require a dependency, but many people already have these libs installed on their system so it usually isn't an issue.



So the question you have to ask yourself is which library do you want to use? Low level or high level? Is there any benefit to gain from using a lower level lib? If your only concern is being able to plot individual pixels, I would stick with a higher level lib. No sense in making things needlessly more difficult for yourself.
Topic archived. No new replies allowed.