这两天看tutorial的openGL教程,它用了glew、glfw和glm三个库,光是环境配置就让我头疼了N久ORZ
这边记录一下我是怎么配置成功的。
glew、glfw和glm三个库都可以在SourceForge上下载到,此外还需要下载一个opengl32.lib
将glew32.dll、GLFW.dll复制到C:\WINDOWS\system32中
将glm文件夹复制到vs2010安装文件夹下的VC\Include中
将glfw.h、glew.h、wglew.h复制到vs2010安装文件夹下的VC\Include\gl中
将glew32.lib、GLFW.lib、GLFWDLL.lib、opengl32.lib复制到vs2010安装文件夹下的VC\lib中
在vs2010中打开项目属性页,在链接器→输入→附加依赖项中添加opengl32.lib;glew32.lib;GLFW.lib;GLFWDLL.lib;
最后在你的代码里包含这些就可以了:
我的编程环境目前为止是没什么问题了,希望它一直好好的,蛋疼啊_(:зゝ∠)_
2014-4-17阅读1099 评论0
cmake-2.8.12.2-win32-x86官方下载cmake-2.8.12.2-win32-x86百度网盘下载glfw-3.0.4官方github地址glfw-3.0.4百度网盘源码下载glew-1.10.0-win32官方下载glew-1.10.0-win32百度网盘下载glm-0.9.5.3官方下载glm-0.9.5.3百度网盘下载
// 00_config.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include
#include
#include
#include
GLFWwindow* window;
#include
using namespace glm;
int main( void )
{
// Initialize GLFW
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
window = glfwCreateWindow( 1366, 768, "配置OpenGL环境", NULL, NULL);
if( window == NULL ){
fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" );
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// Initialize GLEW
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
return -1;
}
// Ensure we can capture the escape key being pressed below
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
// Dark blue background
glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
do{
// Draw nothing, see you in tutorial 2 !
// Swap buffers
glfwSwapBuffers(window);
glfwPollEvents();
} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0 );
// Close OpenGL window and terminate GLFW
glfwTerminate();
return 0;
}