xcode+glew+glfw-创新互联

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;
}

网页名称:xcode+glew+glfw-创新互联
转载来于:http://scjbc.cn/article/cesdsj.html

其他资讯