C语言 仅将 C(无 C++)用于 OpenGL?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20023668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using only C (no C++) for OpenGL?
提问by BigBadWolf
I want to know if there is a possibility of using OpenGL in C without even scratching c++, tutorials or basic source codes are most welcome!
我想知道是否有可能在 C 中使用 OpenGL 甚至不使用 C++,教程或基本源代码是最受欢迎的!
And if it is possible, how deep would my C skills have to be to understand and use it? I'm currently still mostly learning, and I like to do that by biting off more than I can chew.
如果可能的话,我的 C 技能需要多深才能理解和使用它?我目前主要还是在学习,我喜欢通过咬得比我能咀嚼的更多来做到这一点。
回答by Zaffy
OpenGL is a C library, not a C++ one.
OpenGL 是一个 C 库,而不是 C++ 库。
The only thing why almost all programs use C++ for OpenGL is there is a higher and simpler level manipulating it through some wrappers, libraries or frameworks. It's just more comfortable.
几乎所有程序都为 OpenGL 使用 C++ 的唯一原因是有一个更高、更简单的级别通过一些包装器、库或框架来操作它。它只是更舒服。
Hereare some good examples which were distributed along with the OpenGL "Redbook" (version 2.0).
这里有一些很好的例子,它们与 OpenGL“红皮书”(2.0 版)一起分发。
However, those examples use old-style OpenGL (rendering through functions), which is deprecated, you should always use shaders and buffers instead.Although I think for beginning it can help.
但是,这些示例使用旧式 OpenGL(通过函数渲染),但已弃用,您应该始终使用着色器和缓冲区。虽然我认为开始它会有所帮助。
Here on StackOverflowwas also discussed where to find newOpenGL examples.
在 StackOverflow上还讨论了在哪里可以找到新的OpenGL 示例。

![C语言 如何将 main 的 *argv[] 传递给函数?](/res/img/loading.gif)