简体   繁体   English

如何使用C ++编写的图形程序使用GPU而不是CPU进行渲染?

[英]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.soopengl32.dlld3dxxx.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.

相关问题 如何在C ++(Linux)中获得CPU时钟速度? - How do I get CPU Clock Speed in C++ (Linux)? 图形程序无法在Borland C ++中运行,我该怎么办? - Graphics program not run in Borland c++ ,what i do? 用 C++ 编写的程序如何在多个 CPU 架构上运行? - How can a program written in C++ be run on multiple CPU architectures? 我如何获取和使用头文件<graphics.h>在我的 C++ 程序中? - How I can get and use the header file <graphics.h> in my C++ program? 如何在 C++ 进程中将数据从 CPU 复制到 GPU,并在指向复制的内存的同时在另一个 python 进程中运行 TF? - How do I copy data from CPU to GPU in a C++ process and run TF in another python process while pointing to the copied memory? 如何使用 Windows 程序在 C++ 中获得控制台输出? - How do I get console output in C++ with a Windows program? 如何让 c++ 中的这个二进制加法程序工作? - How do I get this binary addition program in c++ to work? 在c ++中使用system()时,我的程序被卡住了,如何使它继续进行? - When using system() in c++ my program gets stuck, how do I get it to proceed? 如何使用C ++打开Java程序 - How do I open a Java program using C++ 如何使用 C++ 程序截取 FSX 的屏幕截图? - How do I take a screenshot of FSX using a C++ Program?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM