Я пытался скомпилировать эту простую программу в CodeBlocks сегодня:
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
// Include GLEW. Always include it before gl.h and glfw.h, since it a bit magic.
#include <GL/glew.h>
// Include GLFW
#include <GL/glfw.h>
// Include GLM
#include <glm/glm.hpp>
using namespace glm;
int main(){
// Initialise GLFW
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
return -1;
}
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); // 4x antialiasing
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // We want OpenGL 3.3
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
{
fprintf( stderr, "Failed to open GLFW window\n" );
glfwTerminate();
return -1;
}
// Initialize GLEW
glewExperimental=true; // Needed in core profile
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
return -1;
}
glfwSetWindowTitle( "Tutorial 01" );
// Ensure we can capture the escape key being pressed below
glfwEnable( GLFW_STICKY_KEYS );
do{
// Draw nothing, see you in tutorial 2 !
// Swap buffers
glfwSwapBuffers();
} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
glfwGetWindowParam( GLFW_OPENED ) );
}
Этот код из учебника http://www.opengl-tutorial.org/beginners-tutorials/tutorial-1-opening-a-window/
Я думаю, проблема может быть вызвана тем, что я не мог заставить CMake работать правильно, поэтому я просто скопировал зависимости в каталог CodeBlocks.
Все ошибки относятся к области glfw...
In function 'int main()':
|23|error: 'GLFW_FSAA_SAMPLES' was not declared in this scope
|24|error: 'GLFW_OPENGL_VERSION_MAJOR' was not declared in this scope
|25|error: 'GLFW_OPENGL_VERSION_MINOR' was not declared in this scope
|26|error: 'GLFW_OPENGL_PROFILE' was not declared in this scope
|26|error: 'GLFW_OPENGL_CORE_PROFILE' was not declared in this scope
В учебном пособии, который вы читаете, используйте Glfw 2, вы, вероятно, скачали GLFW 3.0 Downfrade glfw или следуете этому руководству для переноса версии: http://www.glfw.org/docs/3.0/moving.html
glfw.h
находится в той же системной директории, что иGL.h
? Они вообще не связаны, и должны быть в разных местах. То же самое касается GLEW.