使用glfw建立opengl应用程序
2017-04-29 10:52
148 查看
这里有篇答疑的文章
http://stackoverflow.com/questions/17768008/how-to-build-install-glfw-3-and-use-it-in-a-linux-project
不过看得多也没有什么用。
重点是如何编译下面这个源程序
gcc glfw-demo.c -L/usr/local/lib -lglfw3 -lrt -lXrandr -lXinerama -lXi -lXcursor -lGL -lm -ldl -lXrender -ldrm -lXdamage -lX11-xcb -lxcb-glx -lxcb-dri2 -lxcb-dri3 -lxcb-present -lxcb-sync -lxshmfence -lXxf86vm -lXfixes -lXext -lX11 -lpthread -lxcb -lXau
-lXdmcp
是不是超级长,但是这个编译是正确的,会生成a.out程序,运行会有一个窗口。
#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 */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
http://stackoverflow.com/questions/17768008/how-to-build-install-glfw-3-and-use-it-in-a-linux-project
不过看得多也没有什么用。
重点是如何编译下面这个源程序
gcc glfw-demo.c -L/usr/local/lib -lglfw3 -lrt -lXrandr -lXinerama -lXi -lXcursor -lGL -lm -ldl -lXrender -ldrm -lXdamage -lX11-xcb -lxcb-glx -lxcb-dri2 -lxcb-dri3 -lxcb-present -lxcb-sync -lxshmfence -lXxf86vm -lXfixes -lXext -lX11 -lpthread -lxcb -lXau
-lXdmcp
是不是超级长,但是这个编译是正确的,会生成a.out程序,运行会有一个窗口。
#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 */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
相关文章推荐
- 今日学习 (使用.NET Remoting 建立分布式应用程序(二))(4月7日) ——对象生存周期管理
- [转载]ASP.NET Web 服务还是 .NET Remoting:如何选择,使用 Microsoft .NET 建立分布式应用程序
- 在mac环境下用QT使用OpenGL,glut,glfw
- OpenGL 使用GLFW创建全屏窗口
- OpenGL(一) 使用Win API 建立黑色窗口
- 使用辅助库建立openGL编程环境
- linux上在不建立窗口的情况下使用opengl
- 使用ActiveX控件建立应用程序
- 使用OPENGLAppWizard建立OpenGL程序
- 使用glew、glfw配置OpenGL开发环境
- 在Expression Blend中使用XAML建立3D应用程序
- 使用Windows窗口句柄建立OpenGL环境
- 今日学习 (使用.NET Remoting 建立分布式应用程序(一))(4月6日)
- 如何使用 Eclipse 插件和简洁的 Groovy 语言在 EC2 上快速地建立和运行简单的 Web 应用程序
- 使用Away3D 4 和 Stage 3D创建3D游戏以及应用程序—第一部分:30分钟内建立一个3D项目
- 使用.NET Remoting 建立分布式应用程序
- 掌握 Ajax,第 6 部分: 建立基于 DOM 的 Web 应用程序 在不刷新页面的情况下使用 DOM 改变网页界面
- Asp.net中建立MS office组件时出现“拒绝访问”和“消息筛选器显示应用程序正在使用中”错误的解决方法
- 在Xcode中使用GLUT开发OpenGL应用程序
- 配置GLEW+GLFW并使用Xcode写OpenGL应用