游戏开发:(Java & OpenGL)还是(C++ & OpenGL & SDL)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5222066/
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
GameDevelopment: (Java & OpenGL) or (C++ & OpenGL & SDL)?
提问by Martijn Courteaux
Since Java supports OpenGL, what is the best option for developing a game?
既然 Java 支持 OpenGL,那么开发游戏的最佳选择是什么?
Java
+OpenGL
C++
+SDL
+OpenGL
Java
+OpenGL
C++
+SDL
+OpenGL
I always avoided Java (in game development, of course) because of it's speed. But, I discovered that Java supports OpenGL. So, I think speed can't be the problem anymore... What should you choose? Are there remarks?
我总是避免使用 Java(当然在游戏开发中)因为它的速度。但是,我发现 Java 支持 OpenGL。所以,我认为速度不再是问题......你应该选择什么?有备注吗?
Java would be a lot easier for me, because of my experiences in Java and the Garbage Collector.
由于我在 Java 和垃圾收集器方面的经验,Java 对我来说会容易得多。
Thanks
谢谢
回答by esaj
In my opinion, if you have an idea for a game in your head it doesn't matter what you write it with (at first), C/C++, Java, pen & paper... Pick the language you're more comfortable with, prototype and test your game idea, once you have a rough sketch and know what you need to do, throw the prototype out, design the gameplay & architecture and then start coding the actual thing. Don't optimize until after you've got most or all of the functionality working (in general, there's always minor bugs to hunt) and you actually see where the bottlenecks are.
在我看来,如果你有一个游戏的想法在你的脑海里,你用什么写它并不重要(一开始),C/C++,Java,笔和纸......选择你更舒服的语言使用、原型和测试你的游戏创意,一旦你有了一个粗略的草图并知道你需要做什么,就扔掉原型,设计游戏玩法和架构,然后开始编写实际的代码。在您使大部分或所有功能正常工作(通常,总会有小错误需要寻找)并且您确实看到瓶颈所在之前,不要进行优化。
I've seen it happen over and over again, game programmers are among the worst premature optimizers ever, trying to squeeze out a few cycles from something trivial, while missing the biggest bottlenecks and then optimize some more (in the wrong place). I've also found myself guilty of this many times. I'd say don't pick C++ (or Java for that matter) because of the speed, you can get very good performance out from both, if done "right". If need be, you can always switch to another language, if the language itself is really the bottleneck or really preventing you from doing something. Java isn't automatically slow and C++ isn't automatically fast, you can go (very) wrong with both. I used to root for C and C++ in everything, but after having worked with Java for quite a while, I really don't miss all the hassle that much.
我已经看到它一遍又一遍地发生,游戏程序员是有史以来最糟糕的过早优化者之一,他们试图从一些琐碎的事情中挤出几个周期,同时错过最大的瓶颈,然后再优化一些(在错误的地方)。我也多次发现自己为此感到内疚。我会说不要因为速度而选择 C++(或 Java),如果做得“正确”,你可以从两者中获得非常好的性能。如果需要,您可以随时切换到另一种语言,如果语言本身确实是瓶颈或确实阻止您做某事。Java 不会自动变慢,C++ 也不会自动变快,两者都可能(非常)错误。我曾经在所有方面都支持 C 和 C++,但是在使用 Java 工作了很长一段时间之后,我真的不
There are lots of (already optimized and fairly easy to use) game engines available for both languages, so there's no need to roll your own... unless you really want to. In my experience, most hobbyist "game programmers" tend to be more interested in the technical side of things than in the actual game (myself included) ;) Once all the technical hurdles are done and you get that nice model/bunch of sprites/particle effects running with some shader-effects, the enthusiasm seems to fade away... But don't let me discourage you, game programming is very fun, even if you never actually finish anything (I wouldn't call any of my own projects finished).
有很多(已经优化且相当容易使用)游戏引擎可用于两种语言,所以没有必要推出自己的......除非你真的想要。根据我的经验,大多数业余“游戏程序员”往往对事物的技术方面比对实际游戏更感兴趣(包括我自己);) 一旦完成所有技术障碍,你就会得到那个漂亮的模型/一堆精灵/粒子效果与一些着色器效果一起运行,热情似乎逐渐消退......但不要让我气馁,游戏编程非常有趣,即使你从未真正完成任何事情(我不会称之为我自己的项目完成)。
I haven't coded any games for a while, but for C++ 2D SDLis a good candidate, other option could be SFML, or if you want a lower level touch with OpenGL, you could try going with GLFW+ SOIL+ some audio library. For full-blown 3D, I'd say try either OGREor Irrlicht+ Irrklang(there are probably loads of others too).
我已经有一段时间没有编写任何游戏了,但是对于 C++ 2D SDL是一个不错的选择,其他选项可能是SFML,或者如果您想对 OpenGL 进行较低级别的接触,您可以尝试使用GLFW+ SOIL+ 一些音频库. 对于成熟的 3D,我会说尝试OGRE或Irrlicht+ Irrklang(可能还有很多其他的)。
In Java, there's at least Slick2D, Golden T Game Engineand for lower level access, LWJGL(although I think you can access LWJGL via Slick2D also). For 3D, someone recommended jMonkeyEngineto me, but I've never tried it.
在 Java 中,至少有Slick2D、Golden T Game Engine和用于较低级别访问的LWJGL(虽然我认为您也可以通过 Slick2D 访问 LWJGL)。对于 3D,有人向我推荐了jMonkeyEngine,但我从未尝试过。
回答by TheBuzzSaw
I would vote for C++ for the simple fact that you have a dependable destructor in your objects. This lets you wrap many of the OpenGL components (buffers, textures, etc.). You can know that when the object is created, the asset is allocated, and when the object is destroyed (or goes out of scope), the asset is cleaned up.
我会投票给 C++ 一个简单的事实,即您的对象中有一个可靠的析构函数。这让您可以包装许多 OpenGL 组件(缓冲区、纹理等)。可以知道,当对象被创建时,资产被分配,当对象被销毁(或超出范围)时,资产被清理。
It certainly can be done in Java. Minecraft was made in Java, and it has pulled in over $25 million.
它当然可以用Java完成。Minecraft 是用 Java 制作的,它已经获得了超过 2500 万美元的收入。
回答by Neil
Java has been proven to be just as fast if not faster than C++, though granted, you don't achieve such results without a little parameter tweaking and careful monitoring of the garbage collector. If you want to pursue game design with Java, I'd say that's a good choice to make, provided you study up on how to approach it first.
Java 已被证明与 C++ 一样快,即使不比 C++ 还要快,但如果没有一点参数调整和对垃圾收集器的仔细监视,您将无法获得这样的结果。如果您想使用 Java 进行游戏设计,我会说这是一个不错的选择,前提是您首先研究了如何处理它。
回答by Fouf
I'd go with C++, SDL, and OpenGL.. SDL is getting revamped with 1.3 at the moment, and it will be really good. In my opinion you should do it in C++ as you have stated you would feel more comfortable with Java, being comfortable after making a game in C++ would be very beneficial. You would not only make a game, but learn more at the same time.
我会使用 C++、SDL 和 OpenGL。SDL 目前正在使用 1.3 进行改进,它会非常好。在我看来,你应该用 C++ 来做,因为你说过你会觉得用 Java 会更舒服,用 C++ 制作游戏后感觉舒服会非常有益。您不仅可以制作游戏,还可以同时学习更多知识。
回答by Jeremy
If you go down the Java route you may need to ship the JVM along with your game. That's not to say don't do it but many people may not have Java installed or not have a recent enough version for the features and performance that you want. I haven't looked into the licensing requirements for shipping the JVM but that's probably something you'll want to investigate before making the decision.
如果您沿着 Java 路线走下去,您可能需要将 JVM 与您的游戏一起发布。这并不是说不要这样做,但很多人可能没有安装 Java 或者没有足够的最新版本来满足您想要的功能和性能。我还没有研究过发布 JVM 的许可要求,但这可能是您在做出决定之前需要调查的内容。
You should also be aware that when highly tuning an app that although the Java API is the same across platforms that there are differences because the implementations of those often use the underlying OS. So I doubt that using Java would reduce the test burden at all for a game.
您还应该意识到,在对应用程序进行高度调整时,尽管 Java API 跨平台相同,但存在差异,因为它们的实现通常使用底层操作系统。所以我怀疑使用 Java 会减少游戏的测试负担。
回答by DNRN
It really depends on what language your most used to. There's a steeper learning curve with c++ than with java. If you not into none of the languages, and is eager to get some development done I would recommend java.
这实际上取决于您最常用的语言。c++ 的学习曲线比 java 更陡峭。如果您不熟悉任何语言,并且渴望完成一些开发,我会推荐 java。
And a little side note. If you totally new I would also recommend looking at XNA, but it's based on DirectX. And you have to know some C#.
还有一点旁注。如果您完全陌生,我还建议您查看 XNA,但它基于 DirectX。并且您必须了解一些 C#。
回答by Leo-Neil Quilatan
It really depends on what kind of games you want to build and which programming language your more comfortable with.
这实际上取决于您想要构建什么样的游戏以及您更熟悉哪种编程语言。
If your planning to make big games in the future , C++ is best for overall experience. Most commercial games are written in C/C++. Microsoft also has XNA framework which uses C#
如果你打算在未来制作大型游戏,C++ 最适合整体体验。大多数商业游戏都是用 C/C++ 编写的。微软也有使用 C# 的 XNA 框架
Id still go with the programming language your more convenient with, they are both great
我仍然使用更方便的编程语言,它们都很棒
However, if you dont mind learning a bit more then go with C++
但是,如果你不介意多学一点,那就用 C++
回答by ultifinitus
Well I've programmed all my games in SDL and I would definitely recommend using c++. Though you may want to look at SFML!
好吧,我已经用 SDL 编写了我所有的游戏,我肯定会推荐使用 C++。虽然你可能想看看 SFML!
SFML is already integrated with OpenGL, and it's fairly easy to get up and running with game programming.
SFML 已经与 OpenGL 集成,并且可以很容易地启动和运行游戏编程。