Where can I find out how to interact with a graphics card using C ++?

I am learning C ++ right now and I would like to start interacting with a graphics card and play with the basics of 3d graphics. I did not find it in my book or in Internet searches, and in fact I have no idea where to start. Can C ++ code run on a graphics card after compiling it? I understand that I am referring to GPU processing through OpenGL, but it is unclear whether it is just a library for access through C ++ (and possibly other languages) for transferring functions to the GPU, or if it is specific to GLSL. So what is OpenGL and how can I use it in combination with C ++ to pass processing to the GPU? Are there other more direct or flexible ways to work with C ++ and a graphics card?

+6
c ++ gpu 3d opengl glsl
source share
6 answers

OpenGL is a library. Your C ++ code, which compiles to machine code (for your processor, not the GPU), calls OpenGL functions that send data to your graphics card (GPU). The graphics card interprets this data and uses it to accomplish what you requested. The GPU does not run any of your C ++ code.

GLSL (OpenGL Shading Language) is a language used to indicate what GPU shaders do. Note that the name is a little wrong, because the code written in shading languages ​​is now much more than hatching. Typically, you will write your GLSL code the same way you write your C ++ code, and then use OpenGL calls to compile GLSL code, and then use more OpenGL calls to tell the processor to use shader programs.


CPU

C ++ code calls functions OpenGL calls the graphics driver code , which passes instructions to the graphics processor through the hardware.

GPU

Interprets the hardware signals received from the graphics driver to run its own internal programs. This may include compiled GLSL programs, which are also sent from the CPU in the same way.


Note. You can replace "Open GL functions" with "DirectX functions" and "GLSL" with another shader language, and the diagram is the same.

+8
source share

OpenGL and DirectX interact with the graphics card for you.

You can write low-level code yourself, but I would suggest getting an understanding of the basics first.

Once you do this, you can look at the graphics drivers yourself, but do not expect that you will lose the performance of developers of development cards.

+6
source share

The final place for Opengl NeHe . The tutorials here will help you get started with the basics.

+2
source share

Simply put, OpenGL is a library that interacts with your graphics card driver. You call OpenGL functions in C ++, which lead to sending commands to the GPU for processing. Your C ++ code always runs on the CPU, including all of your OpenGL library calls, but calls are translated into commands that are understood by the graphics card driver.

In the past, the GPU had a conveyor with a fixed function, and OpenGL acted as a state machine, where you could enable or disable certain functions, such as indicating the position of the light source or what image should be mapped to the object. OpenGL is still a state machine, but with programmable shaders, you write programs in a C-like language (GLSL) and use the OpenGL functions to tell the driver to compile and link programs and run them on the GPU.

A good place to start learning more about OpenGL is OpenGL SuperBible . The latest version does not apply to old pipelines with a fixed function (where you cannot write shaders) and requires a somewhat decent graphics card.

+1
source share

To get started, I recommend you use the GLUT API (GL Utility Toolkit). Take a look at this here ... http://www.opengl.org/resources/libraries/glut/

I think this is the best way to start graphical programming with openGL.

0
source share

Are you interested in using a GPU for ...

Graphics You have two interfaces: OpenGL (multi-platform) and Direct3D (Windows), supported by almost all GPU drivers.

Calculation . The most common ATM interface is NVidia's CUDA (GeForce cards only). There also OpenCL (should be supported everywhere, but I'm not sure about the current state on GeForce, everything is fine on ATI) and some proprietary AMD / ATI solutions that I am not familiar with.

Choose whatever you like and start exploring it; there are many examples and guides for any of the above that can be found on the Internet.

0
source share

All Articles