本文介绍了仅glsl shader 120版可在Mac OS X上使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OS X 10.9.2上的glsl版本有问题.我正在用OpenGL和SDL2用c ++编写程序.

I have a problem with the glsl's version on my mac os X 10.9.2. I'm making a program in c++ with OpenGL and SDL2

我无法从120版升级到任何更高版本.请问我该如何升级?我这样编译:

I can't upgrade from my version 120 to any version higher. How I can upgrade please ?I compile like this :

g ++,我的标志是:-framework SDL2 -lSDLmain -framework OpenGL -framework SDL2_image -framework可可粉

g++ and my flag is :-framework SDL2 -lSDLmain -framework OpenGL -framework SDL2_image -framework cocoa

错误:0:3:":不支持版本"330"

ERROR: 0:3: '' : version '330' is not supported

推荐答案

在OS/X 10.9上,要创建OpenGL 3.3/4.1上下文,您需要在SDL_CreateWindow之前添加以下代码段.

On OS/X 10.9 to create an OpenGL 3.3/4.1 context you need to add the following snippet before SDL_CreateWindow.

  SDL_Init(SDL_INIT_VIDEO);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
  // ...
  // auto window = SDL_CreateWindow(...)
  // auto context = SDL_GL_CreateContext(window);
  cout << "OpenGL version " << glGetString​(GL_VERSION​) << endl;
  cout << "GLSL version " << glGetString​(GL_SHADING_LANGUAGE_VERSION​​) << endl;

此处提供了完整的示例:> https://gist.github.com/mortennobel/643e92bd6a63de688c6f

A full example is available here:https://gist.github.com/mortennobel/643e92bd6a63de688c6f

这篇关于仅glsl shader 120版可在Mac OS X上使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:51