简体   繁体   English

C ++和Mac OSX

[英]C++ and Mac OSX

In just about all books I read it mentions windows APIs(eg DirectX) when talking about C++ and game programming. 我读过的几乎所有书籍都在谈论C ++和游戏编程时提到了Windows API(例如DirectX)。

What APIs are for Mac when using C++ or what can be used for multi-platform development? 使用C ++时,Mac的API是什么?或者用于多平台开发的API是什么?

I want to create games using C++ and am currently on a Mac. 我想使用C ++创建游戏,目前在Mac上。 I have no problem switching between Unix and Windows if it is needed. 如果需要,我在Unix和Windows之间切换没有问题。

What is recommended for C++ game development and will programming for mac be a drawback? 对C ++游戏开发有何建议,对Mac进行编程会成为缺点吗?

Or should I just go with C++ and OpenGL and use it for all platforms? 还是我应该只使用C ++和OpenGL并将其用于所有平台? :P :P

I would recommend SFML and OpenGL. 我会推荐 SFML和OpenGL。 SFML is a more modern, C++ oriented, cross platform framework that allows you to write common code for window, keyboard and mouse handling. SFML是一种更现代的,面向C ++的跨平台框架,可让您编写用于窗口,键盘和鼠标处理的通用代码。 You would then write the bulk of your game using OpenGL, which is cross platform anyway. 然后,您将使用OpenGL编写游戏的大部分内容,而OpenGL仍然是跨平台的。

\n

I am using SFML and OpenGL myself to target Mac OS X, Linux and Windows, primarily developing on Mac (I can triple boot into any of the three OSs to develop on them). 我本人正在使用SFML和OpenGL瞄准Mac OS X,Linux和Windows,主要是在Mac上进行开发(我可以将其三重引导到要在其上进行开发的三个OS中的任何一个)。

EDIT: I've had a change of heart on this as I am a bit spooked by the Mac support in SFML; 编辑:我对此有所改变,因为我对SFML中的Mac支持有些不满意; I am now going to use Qt as it is better supported, provides better tools, better documentation and better examples. 我现在将使用Qt,因为它得到了更好的支持,提供了更好的工具,更好的文档和更好的示例。

You can use OpenGL wich is cross platform, and use GLUT or SDL for handling input and windows and stuff or use just SDL. 您可以在跨平台的情况下使用OpenGL,并使用GLUT或SDL处理输入和窗口以及其他内容,或者仅使用SDL。 (I would go with mixing OpenGL and SDL and because its easier to manage input that way and is still cross platform. Unless your making a 2D game, then use SDL as SDL is for making 2D games). (我会混合使用OpenGL和SDL,因为它更容易以这种方式管理输入,并且仍然跨平台。除非您制作2D游戏,否则将SDL用作SDL就是用来制作2D游戏)。

Ohh and one addition thing about OpenGL on Mac is the header for OpenGL is a little different from most tutorials: 哦,关于Mac上OpenGL的另一件事是OpenGL的标头与大多数教程有点不同:

#include <OpenGL/OpenGL.h>

Don't spend hours on that like I did... 不要像我一样花几个小时...

Oh, and if you plan to use glut: 哦,如果您打算使用过剩食品:

#include <GLUT/glut.h>

If you're making a 2D game I would also recommend you try SFML ; 如果您要制作2D游戏,我还建议您尝试SFML it's a fairly young library that has the same scope as SDL. 它是一个相当年轻的库,具有与SDL相同的作用域。 It's pure C++ (as opposed to SDL which is just C) so development should be somewhat easier for you, if you like OOP. 它是纯C ++(而不是仅C的SDL),因此,如果您喜欢OOP,开发应该会更容易一些。

It would also appear that SFML is significantly faster than SDL: 似乎SFML明显比SDL快:
http://www.sfml-dev.org/forum/viewtopic.php?t=43 ►http : //www.sfml-dev.org/forum/viewtopic.php ? t =43

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM