[英]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. 我目前正在用C ++编写一个简单的图形应用程序,只显示房间里的房间和物体。 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). 我想使用计算机的GPU进行渲染,但是如何通过广泛的兼容性来实现这一点(意味着Nvidia,Intel和ATI,新旧卡)。 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). 我的电脑使用AMD / ATI芯片组(而不是主板上的集成显卡,我将GPU集成到处理器芯片中,称为APU而不是CPU,以及专用显卡,也是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. 但是,运行该程序的计算机很可能要么有Intel或Nvidia的集成显卡,要么有Nvidia卡,所以我希望它能够使用任何显卡,但不能使用CPU。 I am using the glut library for this application 我正在使用glut库来实现这个应用程序
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. 据我所知,所有显卡都支持opengl。
By using an abstract API that directs the drawing calls to the GPU's driver. 通过使用抽象API将绘图调用指向GPU的驱动程序。 OpenGL and Direct3D are just such APIs. OpenGL和Direct3D就是这样的API。 Neither OpenGL nor DirectX are libraries. OpenGL和DirectX都不是库。 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. 是的,您链接到一些名为libGL.so
或opengl32.dll
或d3dxxx.dll
库,但这些只是与GPU的驱动程序通信,然后将GPU指向通过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. 或者换句话说:如果您的程序使用OpenGL或DirectX并且链接系统上的标准接口库(默认情况下会发生这种情况),那么只要其驱动程序支持API,它就可以使用任何GPU。有问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.