疯狂的闪烁窗口OpenGL GLFW



我已经完成了以下视频https://www.youtube.com/watch?v=shpdt6hCsT4但是,我的"你好世界"窗口看起来像这样:http://s1303.photobucket.com/user/eskimo___/media/screenshot_124_zps890ae561.jpg.html有什么想法我哪里出错了吗?我使用带有最新GLFW的osx优胜美地干杯


根据要求:

我的项目文件夹由 3 个文件组成,这些文件是作为使用终端的过程的一部分制作的:

  1. 主.cpp(C++源代码)
  2. Makefile(txt)
  3. 测试(Unix可执行文件)

我已经使用自制软件在Mac上设置了GLFW3库。

Main.cpp,即在图中的窗口中运行以产生不希望的效果,由网站GLFW文档部分的示例代码组成:

include <GLFW/glfw3.h>
int main(void)
{
    GLFWwindow* window;
    /* Initialize the library */
    if (!glfwInit())
        return -1;
    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        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;
}

glfwSwapBuffers之前插入glClear(GL_COLOR_BUFFER_BIT) - 它基本上是从未初始化的"帧缓冲"内存更新的,GL 实现可能已将其用于其他目的,例如 Quartz 合成器中的后备存储、纹理等。

把它想象成对malloc的调用;内存不需要初始化或清零。

最新更新