扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
1,
下载glew和glfw,camke生成xcode工程文件,编译出.a文件
2,
拖拽glew和glfw各自的头文件+.a文件到工程。
3,
运行,此时一直glfw报错 is not a fat file
4,
百度之上面的错误时生成文件时候选择编译平台不对,arm平台的东西不适用于x86,但是检查工程没问题时生成的x86_64.
再查glfw文档有下面这句:
If you are using the dynamic library version of GLFW, simply add it to the project dependencies.
If you are using the static library version of GLFW, add it and the Cocoa, OpenGL, IOKit and CoreVideo frameworks to the project as dependencies. They can all be found in /System/Library/Frameworks.
5,把上面几个库文件选入工程,ok了
//// main.cpp
// lh_gl
//// Created by Liuhan333 on 2017/8/29.
// Copyright © 2017年 Liuhan333. All rights reserved.
//
#include
#include"../glew/GL/glew.h"
#include"../glfw/GLFW/glfw3.h"void Render(void)
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
{
glColor3f(1.0,0.0,0.0);
glVertex2f(0, .5);
glColor3f(0.0,1.0,0.0);
glVertex2f(-.5,-.5);
glColor3f(0.0, 0.0, 1.0);
glVertex2f(.5, -.5);
}
glEnd();
}
int main(int argc, const char * argv[]) {
GLFWwindow* win;
if(!glfwInit()){
return -1;
}
win= glfwCreateWindow(640, 480, "OpenGL Base Project", NULL, NULL);
if(!win)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
if(!glewInit())
{
return -1;
}
glfwMakeContextCurrent(win);
while(!glfwWindowShouldClose(win)){
Render();
glfwSwapBuffers(win);
glfwPollEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
return 0;
}
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流