从 OpenGL 和 C++ 开始,正确的路径吗?

发布于 2024-10-31 19:33:22 字数 792 浏览 4 评论 0原文

我需要一些具体和一般性的建议。我是一位相当熟练的 Java 程序员和一位非常有经验的 Web 程序员,但我想进入软件开发领域,并且我一直在研究 C++。我对我想做的游戏有一个好主意,并且我意识到这将是一项艰巨的任务 - 但我更多地关注它是为了有机会学习 C++、包装,无论我在游戏中遇到什么开发流程...

但我无法从概念上迈入门槛!我可以很好地处理 C++ 方面,它只是以正确的方式设置图形,这让我感到困惑。我已经浏览了一堆关于 OpenGL 和 C++ 的教程,它们都说了不同的事情,但我无法真正开始工作......

有些人说使用 GLUT 和 GLEW。有人说 GLUT 已经死了,FreeGLUT 才是现在的主流。有些人完全忽略了这些,并使用了一堆我似乎找不到的文件,例如“glaux.h”——以及其他致力于避免“glaux.h”的教程......我发现的大多数教程都带有警告在评论中,他们的 OpenGL 版本已经过时,我应该使用更新的库——还有其他一些第三方库,如 Ogre 和 Aurora。

我浏览了很多书籍和教程,它们对于使用 OpenGL 和 C++ 都有几乎完全不同的设置。我意识到本身可能没有一种正确的方法来做到这一点,但我正在寻找最新、最流行的方法,并且能够最大限度地提高项目的实用性作为我的学习...任何教程或一般建议的链接都非常感谢。

顺便说一句,我正在使用 Visual Studio Express 2010(好主意?)。我的游戏不会太图形化(等轴测 2d),但需要大量逻辑和大量数据,这就是为什么我想通过使用 C++ 来加快速度。任何其他关于比使用 c++ 进行登录和图形更好的方法(从行业角度来看)的见解对我来说也非常有价值!提前致谢!

I need some specific and some general advice. I'm a fairly proficient Java programmer and a very experienced web programmer, but I would like to get into software development and I've been tackling C++. I have a great idea for a game I'd like to do, and I realize it will be a huge undertaking--but I'm looking at it more for an opportunity to learn C++, wrapping, really whatever I run into in the dev process...

But I can't get my foot in the door conceptually! I can handle the C++ aspect fine, it's just setting up the graphics, the RIGHT way, that's confusing me. I've run through a bunch of tutorials for OpenGL with C++ that all say the different things, none of which I can really get to work...

Some say to use GLUT and GLEW. Some say GLUT is dead and that FreeGLUT is the thing now. Some ignore those entirely and use a bunch of files like "glaux.h" that I can't seem to find--and other tutorials devoted to AVOIDING "glaux.h"... Most tutorials I've found come with the caveat in the comments that their version of OpenGL is dated and I should be using newer libraries-- and still others with 3rd party libraries like Ogre and Aurora.

I've been looking through a bunch of books and tutorials that ALL have an almost completely different setup for using OpenGL with C++. I realized there is probably not one right way of doing it, per se, but I'm looking for the way that is the most current, most popular, and will maximize the usefulness of the project as far as my learning... Any links to tutorials or advice in general is much appreciated.

BTW, I'm using Visual Studio Express 2010 (good idea?). My game won't be too graphically intense (isometric 2d) but will require a TON of logic and a TON of data, which is why I want to speed things up by using C++. Any other insights on better ways of doing it than using c++ for login AND graphics (from an industry perspective) are also very valuable to me! Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

糖粟与秋泊 2024-11-07 19:33:22

假设您将学习 OpenGL 作为一种学习体验,我会向您推荐以下内容:

使用 GLEW,无需争论。就做吧,每个人都做
仅对核心配置文件进行编码。默认情况下,OpenGL接受旧的命令(例如固定功能管道),这些命令稍后会消失,您不想在这上面浪费时间。具体来说:了解 VBO、纹理,最重要的是,了解着色器。

忘记高涨和过剩。 Freeglut 是一个很好且非常标准的选择。一个不太明显的选择是 qt,但它的 QGLWidget 允许您轻松进行 gl 调用,而不必担心上下文创建等问题。添加 GUI 选项非常容易,这在图形编程时总是非常好的。

要真正学习 OpenGL,我建议 http: //duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html。 Nehe 存在这样的问题:超过一半的内容对于学习来说是无用的,并且周围有很多废话(窗口创建等)。

但是,我并不真正推荐 OpenGL 作为学习实时图形编程的方法。您的选择不限于 DirectX。我通过使用 Ogre3D 学到了大量的图形编码知识。您仍然可以掌握需要了解的所有概念(使用顶点和索引缓冲区、纹理、着色器进行低级别工作),并实现大量的东西来让您的生活更轻松。您可能不会了解特定 API 的来龙去脉,但您将在概念上了解您需要了解的所有内容。当我成为一名图形程序员时,我没有编写一行 DirectX 代码,但我很快就掌握了我们的引擎。之后我就很容易地学会了实际的调用。了解硬件和概念。无论如何,实际的实施会随着时间的推移而变化。

哦,以防万一我没有重复足够的内容。学习着色器

Assuming you're learning OpenGL as a learning experience, I would recommend you this:

Use GLEW, no argument. Just do it, everyone does
Code only to the core profile. By default, OpenGL accepts old command (eg fixed function pipeline) that will later disappear, and you don't want to waste your time on that. Specifically: learn about VBO's, texture's, and, most of all, learn about shaders.

Forget about glaux and glut. Freeglut is a good and very standard option. A less obvious choice would be qt, but it's QGLWidget allows you to easily make gl calls, and not worry about context creation and all that. And it's dead easy to add gui options, which is always very nice to have when programming graphics.

To actually learn OpenGL, I would recommend http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html. Nehe has that problem where more than half of the stuff is useless to learn, and there's a lot of fluff (window creation et al) around it.

But, I wouldn't really recommend OpenGL as a way to learn real-time graphics programming. Your alternatives are not limited to DirectX. I learned a ton of graphics coding from working with Ogre3D. You still have all the concepts at your disposal that you need to know (working low level with Vertex and Index buffers, Textures, shaders), and implements tons of stuff to make your life easier. You might not learn the ins and outs of a specific API, but you will learn all you need to know conceptually. When I became a graphics programmer, I hadn't written a line of DirectX code, but I got to grips with our engine really swiftly. I learned the actually calls very easy after that. Know the hardware, and the concepts. The actual implementation changes over time anyway.

Oh, and just in case I haven't repeated it enough. LEARN SHADERS

与之呼应 2024-11-07 19:33:22

最好的教程是(可以说,任何“最好的”教程)Nehe opengl 教程。至少,这个教程已经被建议很多年了。

另外,由于您有 Java 背景,您可能更喜欢来自 Tao 等框架的 opengl C# 绑定,但是实际的设置可能比说的更难,下载示例并运行它们。

The best tutorial around is (arguably, as anything "best") Nehe opengl tutorial. At least, this tutorial has been suggested for many years.

Also since you come from a Java background you might prefer C# bindings for opengl from frameworks such as Tao, but the actual setup might be harder than say, downloading samples and running them.

口干舌燥 2024-11-07 19:33:22

很容易看出 OpenGL 与 C++ 的可用选择可能有点令人困惑。在大多数情况下,Java 在两种可能性之间提供了一个非常明确的选择(您是否想要场景图?)

C++ 的情况肯定更复杂。

  1. Glut:这基本上是一个面向 OpenGL 的应用程序框架。显然,编写它的主要目的是让示例简短,但仍然有效。最初的实现有一些众所周知的错误,并且十多年来没有更新。我只会在大致最初预期的上下文中使用它:简短的示例/示例/演示。
  2. 格劳克斯:这里的故事有点类似于过剩。它存在一些已知的内存泄漏问题,但十多年来一直没有修复。无论如何,它从来都不是便携式的。我会完全避免这个。
  3. GLEW/GLEE:这些允许相对容易地使用来自 OpenGL 实现(例如 Microsoft 的)的较新版本的 OpenGL 添加的功能,这些功能尚未更新为包含标头/库以提供对它们的直接访问。我更喜欢《欢乐合唱团》,因为它会自动初始化,但两者都工作得很好。
  4. FreeGLUT:最近已更新,并且消除了一些错误。但它仍然没有对 GLUT 的基本设计进行太多改进。对于简短的演示/样本来说可能是更好的选择,但仍然不(IMO)适合严肃的使用。
  5. Ogre3D:这比前面的任何库都要大得多。它是一个成熟的场景图形库,具有纹理加载、定义的文件格式等。一个可靠的库,但要注意,如果你使用它,你通常根本不会直接使用 OpenGL(例如,在 Windows 上,它可以通过 OpenGL 或 Direct3D 进行渲染,而无需更改源代码)。
  6. OpengSceneGraph:更常用于面向科学的应用程序,但与 Ogre3D 最接近。
  7. FLTK:一个小型、轻量级的 GUI 库,运行在 OpenGL 之上。
  8. GLFW:与 GLUT 具有相同的总体精神,但它最近更新了很多,没有那么多错误,并且(IMO)是一个更好的设计 - 最小但仍然适合“真正”使用。

It's easy to see where the variety of choices available for OpenGL with C++ would be a bit bewildering. For the most part, Java gives two a pretty clear-cut choice between two possibilities (do you want a scene graph or not?)

The situation with C++ is certainly more complex.

  1. Glut: This is basically an OpenGL-oriented application framework. It was apparently written primarily to allow examples to be short, but still work. The original implementation has some pretty well-known bugs, and hasn't been updated in over a decade. I would only use it in roughly the originally-intended context: short samples/examples/demos.
  2. glaux: The story here is sort of similar to GLUT. It has some memory leaks that have been known but unfixed for over a decade now. It was never portable in any case. I'd avoid this one completely.
  3. GLEW/GLEE: These allow relatively easy use of the functions added in newer versions of OpenGL from OpenGL implementations (e.g., Microsoft's) that haven't been updated to include headers/libraries to provide access to them directly. I prefer Glee by a small margin because it initializes itself automatically, but both work fine.
  4. FreeGLUT: This has been updated more recently, and some of the bugs expunged. It still hasn't done much to improve the basic design of GLUT though. Probably a better choice for short demos/samples, but still not (IMO) suitable for much serious use.
  5. Ogre3D: This is much bigger than any of the preceding libraries. It's a full-blown scene graph library, with texture loading, defined file format, etc. A solid library, but be aware that if you use it, you won't normally use OpenGL directly at all (e.g., on Windows, it can render via either OpenGL or Direct3D without changing the source code at all).
  6. OpengSceneGraph: More often used for scientifically-oriented applications, but most closely comparable to Ogre3D.
  7. FLTK: a small, lightweight GUI library that runs on top of OpenGL.
  8. GLFW: In the same general spirit as GLUT, but it's been updated much more recently, doesn't have nearly as many bugs, and is (IMO) a nicer design -- minimal but still suitable for "real" use.
蒲公英的约定 2024-11-07 19:33:22

如果您想编写便携式 3D 应用程序,您应该使用 OpenGL。 Windows、Linux 和 Mac OS X 支持它。

您可能想看看 NeHe 教程。它是网络上最好的 OpenGL 教程之一。

You should be using OpenGL if you want to write portable 3D applications. Windows, Linux and Mac OS X supports it.

You might want to take a look at NeHe tutorials. It's one of the best OpenGL tutorials available on the web.

木落 2024-11-07 19:33:22

我的理解是,如果您想要对最新版本的 OpenGL 进行简单支持,您将不得不离开 Windows 领域,所以当入门很复杂时,请尝试从容地对待它。

我认为 OpenGL 可能是正确的选择。您可能还想考虑 DirectX(它在 Windows 上得到更好的支持),但我个人不太喜欢它。您也可以学习 C# 并使用 XNA,但如果您想学习 C++,那就达不到目的了。 (我也忍不住提到,即使不使用 C++,你也有可能让它足够快)

我必须同意其他人的观点,NeHe 的教程非常经典。您可能还想考虑 OpenGL 红皮书,但这要花钱。

关于第三段,GLUT 已经很旧了(就此而言,GLU 也很旧),但是如果你看到一个使用它们的好教程,我不认为它们有什么问题。一旦你湿了你的脚,你可能需要考虑放弃 GLUT 并使用 SDL 我认为这是更加“活跃”。

就 GLEW 而言,我已经成功地使用了它,如果您想做一些像 Windows 上的着色器这样奇特的事情,那就太好了。不过,我想说一开始不要担心,因为它会增加您的设置时间并让您无法获得有趣的东西:)

My understanding is that if you want simple support for a recent version of OpenGL you'll have to leave Windows-land, so try take it in stride when getting started is ... complicated.

I think OpenGL is probably the right choice. You might also want to consider DirectX (which is better supported on Windows), but I'm personally not a big fan of it. You could also learn C# and use XNA, but if you want to learn C++ it just defeats the purpose. (I also can't help mentioning there's a good chance you could make it fast enough without C++)

I have to agree with the others that NeHe's tutorials are pretty much classic. You might also want to consider the OpenGL Red Book, but that costs money.

Regarding the 3rd paragraph, GLUT is old (and for that matter so is GLU), but if you see a good tutorial that uses them, I don't see anything wrong with them. Once you have your feet wet you might want to consider ditching GLUT and using SDL which I believe is a lot more 'alive'.

As far as GLEW goes, I've used it with success and it's nice if you want to do something fancy like shaders on Windows. However, I would say don't worry about it at first, because it will increase your setup time and keep you from getting to the fun stuff :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文