运行Mac OS X C 程序与OpenGL 3.3一起工作
Running mac os x c++ program working with OpenGL 3.3
我正在运行Mac OS X Sierra 10.12.6(16G29)。我正在研究MacBook Pro。
我已经安装了啤酒和以下软件包:
brew install glfw3
brew install glew
brew install glm
这是我的C 程序:
#include <iostream>
#include <GLFW/glfw3.h>
GLFWwindow* window;
#include <GL/gl.h>
int main(int argc, const char * argv[])
{
if (!glfwInit())
{
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
// Should be true for macOS, according to GLFW docs, to get core profile.
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
// According to Apple docs, non-core profiles are limited to version 2.1.
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
window = glfwCreateWindow(640, 480, "Test 1", NULL, NULL);
if( window == NULL )
{
return -1;
}
glfwMakeContextCurrent(window);
// glGetString(GL_VERSION) is NULL at this point
return 0;
}
这是我正在运行的命令行,要编译我的程序:
g++ program.cpp -I/opt/X11/include -L/opt/X11/lib -lglfw -lGL -lGLEW
有一个运行时问题,因为我得到了一个空窗口。我已经在Linux虚拟机上编译了相同的代码,并且效果很好...
glfw docs:http://www.glfw.org/docs/latest/window_guide.html
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
// Should be true for macOS, according to GLFW docs, to get core profile.
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
// According to Apple docs, non-core profiles are limited to version 2.1.
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
另请参见:https://developer.apple.com/opengl/opengl-capabilities-tables.pdf
相关文章:
- MSVC __debugbreak() 与 openGL 错误回调一起使用时不会产生调用堆栈
- 将 OpenGL VBO 与自定义类/数据结构一起使用
- 将 OpenGL 实例化图形与移动对象一起使用
- SFML OpenGL:如何同时与他们一起工作
- OpenGL Glulookat不与着色器一起使用
- 我应该将哪个 opengl 库与 nvidia 显卡一起使用
- 如何使用 new 和 delete 与 OpenGL 的缓冲区对象一起使用?
- OpenGL 将来自 ttf 的渲染器文本与背景纹理组合在一起时出错
- OpenGL Ping Pong可与一张通行证一起工作,而不是两个通行证
- 无法让 openGL 的 glDrawElements 与几何着色器一起使用
- 运行Mac OS X C 程序与OpenGL 3.3一起工作
- 如何渲染成不同的层,然后将它们与OpenGL组合在一起
- OpenGL/ES 2.0及更高版本:如何将多个着色器文件编译在一起
- 在 Xcode 中将C++与 OpenGL 一起使用
- 在 OpenGL 中将四边形堆叠在一起
- 如何将GLFW与openGL一起使用
- 将 glm 四元数转换为旋转矩阵并将其与 opengl 一起使用
- 尝试将着色器与 Win32 OpenGL 一起使用,但顶点着色器不绘制任何内容
- 如何在OpenGL中一起绘制2D和3D内容?
- c++ /OpenGL: vao单独工作,但不能一起工作