如何使用c ++和opengl在mac中创建窗口?

时间:2012-10-28 01:20:48

标签: c++ objective-c macos opengl

我是mac开发的新手。我目前开始使用windows(使用direct3d)的3D程序,我希望使用opengl扩展到mac。我目前有关于如何初始化窗口并使用opengl和windows绘制它的代码。我正在寻找用mac接口替换这个应用程序的windows部分的最无缝的方法。

bool SystemClass::InitializeWindows(OpenGLClass* OpenGL, int& screenWidth, int&screenHeight){
WNDCLASSEX wc;
DEVMODE dmScreenSettings;
int posX, posY;

ApplicationHandle = this;
m_hinstance = GetModuleHandle(NULL);

m_applicationName = L"Engine";

wc.style         = CS_HREDRAW;
wc.lpfnWndProc   = WndProc;
wc.hInstance     = m_hinstance;
wc.hIcon         = LoadIcon(NULL, IDI_WINLOGO);
wc.hIconSm       = wc.hIcon;
wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
wc.lpszMenuName  = NULL;
wc.lpszClassName = m_applicationName;
wc.cbSize        = sizeof(WNDCLASSEX);

    //etc 
    //set full screen mode
    //set window to front
    //hide mouse

当我研究这个时,我看到许多人使用objective-c或coco,我是否必须使用objective-c或coco来获得我想要的结果?如果可以,我仍然可以在coco库中使用c ++或objective-c ++吗?

最后,与mac中的messagebox()相比最简单的是什么?我使用了NSGetCriticalAlertPanel(),但我似乎无法让它工作(主要是因为我找不到相应的库我必须包含的内容)。

PS:我正在使用xcode编译器,如果有一个更好的那个或你更喜欢的请建议它(我不是xcode的忠实粉丝)。

1 个答案:

答案 0 :(得分:0)

您可以从this SDL - openGL tutorial开始,它是最新的。您还需要安装XCode您可能拥有的内容。本教程中有关于如何在项目中安装inlcude SDL的详细内容。初始化并准备使用后,您可以找到大量general sdl tutorials here,您可以专注于此sdltutorial on openGL

也许this SDL FAQ也可以提供帮助。