无法让GLFW3库工作

时间:2014-09-03 09:48:01

标签: c++ opengl glfw

我正在尝试让GLFW3在我的工作站上运行。我确实从http://www.glfw.org/download.html

在我的Ubuntu 12.04上安装了GLFW3

这是我正在尝试的程序。从GLFW官方网站获得 http://www.glfw.org/documentation.html

#include <GLFW/glfw3.h>

#include <iostream>

int main(void)
{
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
    {
        std::cout<< "xxx\n";
        return -1;
        }

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
            std::cout<< "yyy\n";
        glfwTerminate();
        return -1;
    }

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */

        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

关注此stackoverflow问题How to build & install GLFW 3 and use it in a Linux project

将其编译为 -

g++ -I/usr/local/include  glfw.cpp -L/usr/local/lib -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi -lrt

它可以成功编译。但是,当我启动可执行文件时,我打印

yyy

这意味着未创建窗口。什么可能是错的,我该如何解决?

0 个答案:

没有答案
相关问题