-2

I can't seem to find the answer I'm looking for, or I might miss understand this. Either way I am confused.

When I try to find out, there is always videos about C++ console programming, which annoys me because I wanna move away from console stuff by now. I know how to create a simple window, but not how to display real graphics on it. I have heard of stuff like OpenGL and DirectX, but it makes me wonder, what do those libraries have in their source whcih draws actual shapes and other things on the program? What C++ functions do they use in their code?

JohnSilver
  • 83
  • 1
  • 3
  • 10
  • 3
    There is nothing in the C++ standard library that would help you draw graphics. Your program would necessarily rely on the operating system-provided APIs, and/or third-party libraries (which in turn generally wrap OS API). – Igor Tandetnik Jun 25 '17 at 03:40
  • Do you want to reimplement the corresponding parts of those libraries? Or do you expect an answer which does that for you? – Yunnosch Jun 25 '17 at 03:41
  • DirectX is part of Windows itself (it's provided by MS). OpenGL is also available on most Windows OSes by default. There are hundreds of available tutorials and existing questions that you can find via your favorite search engine. Your question is far too broad in scope for this site. And there are no *C++ functions* that they use in their code; they implement the drawing by writing code, mostly in C or ASM (but sometimes in C++). There are literally hundreds of thousands of lines of code that implement those graphics libraries. – Ken White Jun 25 '17 at 03:43
  • 1
    *which annoys me because I wanna move away from console stuff by now* -- Are you having the misconception that console programs are "toy" programs? Note that many graphical programs are actually just a nice shell around the console program that is actually running. – PaulMcKenzie Jun 25 '17 at 03:48
  • Possible duplicate of [C how to draw a point / set a pixel without using graphics library or any other library functions](https://stackoverflow.com/questions/15072025/c-how-to-draw-a-point-set-a-pixel-without-using-graphics-library-or-any-other) – phuclv Jun 25 '17 at 03:52
  • This is simpler than Unity or Unreal - GDI is lines and curves and points and polygons in 2D - https://www.codeproject.com/Articles/764057/GDI-Drawing-and-Printing – Dave S Jun 25 '17 at 03:52
  • [How to draw graphics on screen without using any framework or library?](https://stackoverflow.com/q/35954645/995714) – phuclv Jun 25 '17 at 03:54
  • I think you have the hierarchy backwards in your mind. You think that the standard C++ functionality is low-level, and functionality like graphics is built on top of that. I know I used to think that. But it's actually the other way around. The operating system has a large set of lower level functionality, and C++ and its standard library is built on top of that. OpenGL and DirectX are part of that lower level functionality. So if you want to go low level, those are what you want. – Benjamin Lindley Jun 25 '17 at 04:05
  • I'm not saying I wanna do this, I am just curious as to specifically what functions OpenGL and DirectX use to draw ANY graphics at all. They're third party libraries, meaning they have a C++ source (yes?). Sorry if I am just looking so confused. I saw an answer here saying that they do somehing with the memory, telling it to draw pixels, etc. What set of functions would they use? – JohnSilver Jun 25 '17 at 14:12
  • Just to clarify, I mean drawing graphics on a windows application, not just random pixels on the screen, but in the window of the application. – JohnSilver Jun 25 '17 at 14:26

2 Answers2

1

Well, you could make your own graphics library. In that case I suggest you grab a good math book, and get ready to do some rather serious maths. You'd also have to get going and start right now to learn about Windows graphics drivers and Windows Kernel development, or about the X11 API and Linux Kernel programming, or all of those. The documentation is available on the Net.

What OpenGL and other graphics libraries do is provide a relatively simple API so you don't have to reinvent the wheel, and make your own library which would take years before having anything close to what they provide.

Don't get me wrong, even with these nice API's, there is much room for doing 'magic'. Computer graphics are an art in and of themselves. Mastering some of the techniques offered by the libraries require a good knowledge of the maths involved, and of the possibilities offered by the hardware as well.

But, like everything, it can be learnt. If you are interested in doing graphics on a computer, you should start by finding a good source on the subject, there are many online. And start playing with the APIs. OpenGL is a good place to start, but there are also open source libraries that build on that, since drawing polygons ans stuff involves many other aspects of computing. Ogre3d comes to mind, but there are also others.

Michaël Roy
  • 6,338
  • 1
  • 15
  • 19
0

Briefly, what graphics APIs have in their source is interaction with the graphics hardware, and telling it to write pixel values in memory. Ultimately this is usually done in an indirect way, such as setting up a scene graph, and and graphics APIs provide an interface to work with low level hardware systems.

Jay
  • 636
  • 6
  • 19