疯狂闪烁窗口OpenGL GLFW
我已经完成了以下视频 但是,我的hello world窗口如下所示: 知道我哪里出错了吗?我正在使用osx yosemite和最新的GLFW 干杯疯狂闪烁窗口OpenGL GLFW,opengl,glfw,Opengl,Glfw,我已经完成了以下视频 但是,我的hello world窗口如下所示: 知道我哪里出错了吗?我正在使用osx yosemite和最新的GLFW 干杯 应要求: “我的项目文件夹”由3个文件组成,这些文件是使用终端制作的过程的一部分: main.cpp(C++源代码) 生成文件(txt) 测试(Unix可执行文件) 我已经使用自制软件在我的mac上设置了glfw3库 Main.cpp是为了在图中的窗口中产生不希望的效果而运行的,它由GLFW网站文档部分的示例代码组成: include <GL
应要求: “我的项目文件夹”由3个文件组成,这些文件是使用终端制作的过程的一部分:
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;
}
包括
内部主(空)
{
GLFWwindow*窗口;
/*初始化库*/
如果(!glfwInit())
返回-1;
/*创建窗口模式窗口及其OpenGL上下文*/
window=glfwCreateWindow(640480,“你好世界”,空,空);
如果(!窗口)
{
glfwTerminate();
返回-1;
}
/*将窗口的上下文设置为当前*/
glfwMakeContextCurrent(窗口);
/*循环,直到用户关闭窗口*/
而(!glfwWindowShouldClose(窗口))
{
/*在这里渲染*/
/*交换前后缓冲区*/
glfwSwapBuffers(窗口);
/*轮询并处理事件*/
glfwPollEvents();
}
glfwTerminate();
返回0;
}
插入glClear(GL\u COLOR\u BUFFER\u BIT)
在glfwSwapBuffers
之前-它基本上是从未初始化的“帧缓冲区”内存进行更新,GL实现可能已将其用于石英合成器中的其他用途,如背景存储、纹理等
把它想象成对malloc的调用;内存不需要初始化或归零。没有人能从截图中猜出是什么问题。请提供(最低限度)必要的代码来复制这个。嗨,德哈斯,我做了相应的修改,但不幸的是,我无法将代码放在一个工作完美的blockCheers mate中;终端甚至提醒我在表达式后面加一个分号,这一点都不成问题。据我所知,有一个屏幕外缓冲区(后),可见窗口缓冲区(前)从中复制以显示最终结果;这个表达是指后者吗?