简体   繁体   中英

How do I get a graphics program I have written in C++ to render using the GPU instead of the CPU?

I am currently writing a simple graphics application in C++ that just shows a room and objects in the room. I want to make this render using the GPU of a computer, but how do I do this with broad compatibility (Meaning Nvidia, Intel and ATI, old and new cards). My computer uses an AMD/ATI chipset (instead of an integrated graphics card on the Mother Board, I have a GPU integrated into the processor die, called an APU instead of CPU, and a dedicated graphics card, also ATI). However, most likely the computer running the program will either have an integrated graphics card from Intel or Nvidia, or have an Nvidia card, so I want it be able to use any graphics card, but not use the CPU. I am using the glut library for this application

UPDATE: The real problem is that the professor seems to think that extra code is required for the program to use the graphics card as opposed to the processor to render the graphics. As I understand it now, all graphics cards support opengl regardless.

By using an abstract API that directs the drawing calls to the GPU's driver. OpenGL and Direct3D are just such APIs. Neither OpenGL nor DirectX are libraries. Yes you link to some library called libGL.so or opengl32.dll or d3dxxx.dll but these are just talking to the GPU's driver which will then direct the GPU to whatever it's been asked for through the API.

Or in other words: If your program is using OpenGL or DirectX and links against the standard interface libraries on the system (which is what happens by default), then it will work with whatever GPU there is, as long as its driver supports the API in question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM