【发布时间】:2015-03-18 15:09:48
【问题描述】:
这样我就可以加载 OBJ 文件并将它们呈现在我的 openGL 窗口中。到目前为止,我已经做到了:
- 使用 glfw3 创建 OpenGL 上下文和窗口
- 创建了一个可执行文件(of test.cc, and its associated libraries and headers),它只在终端中将 OBJ 顶点作为文本输出
我想在我的 openGL 窗口中直观地渲染这些顶点,所以我想这涉及到将两者结合起来,但问题是什么?我假设我的 openGL 上下文同化了 obj 导入器,而不是相反,而是它在代码中的位置:
#include <GLFW/glfw3.h>
#include <GLUT/glut.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 */
/* clearing */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
还是我必须从外部链接到它?
【问题讨论】: