2013-08-21 33 views
7

Thực hiện theo một số hướng dẫn OpenGL cho OpenGL 3+, Phải ra khỏi cổng, tôi đã gặp phải một số khác biệt, đây là mã tôi đã quản lý, nhưng phải ra khỏi cổng , Tôi nhận được một loạt các lỗi lớn, không ai trong số đó nói rằng nó không thể tìm thấy các tiêu đề được bao gồm, nhưng chỉ đơn thuần là các tiêu đề không xác định các chức năng cốt lõi.glfwOpenWindowHint không được khai báo trong phạm vi GLFW3 & GLEW

#include <stdio.h> 
#include <stdlib.h> 
#include <GL/glew.h> 
#include <GL/glfw3.h> 
#include <glm/glm.hpp> 

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); 
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3); 
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //I don't want the 
                    //old OpenGL 

// 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 

    // 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)); 

Vấn đề là thực tế là MinGW không như thế này rất nhiều và đã sản xuất một tấn lỗi "không khai báo", tất cả đều được yêu cầu cho một cửa sổ OpenGL để tồn tại. Tôi đã không bao giờ làm việc với bất kỳ thư viện đồ họa khác hơn một chút của SDL2, vì vậy bạn có thể cần phải đi bộ cho tôi thông qua này ... Mà sẽ rất đánh giá cao.

SigmaGLPP\main.cpp:23:20: error: 'GLFW_FSAA_SAMPLES' was not declared in this scope 
SigmaGLPP\main.cpp:23:40: error: 'glfwOpenWindowHint' was not declared in this scope 
SigmaGLPP\main.cpp:24:20: error: 'GLFW_OPENGL_VERSION_MAJOR' was not declared in this 
scope 
SigmaGLPP\main.cpp:25:20: error: 'GLFW_OPENGL_VERSION_MINOR' was not declared in this 
scope 
SigmaGLPP\main.cpp:29:48: error: 'GLFW_WINDOW' was not declared in this scope 
SigmaGLPP\main.cpp:29:60: error: 'glfwOpenWindow' was not declared in this scope 
SigmaGLPP\main.cpp:43:35: error: cannot convert 'const char*' to 'GLFWwindow*' for 
argument '1' to 'void glfwSetWindowTitle(GLFWwindow*, const char*)' 
SigmaGLPP\main.cpp:46:30: error: 'glfwEnable' was not declared in this scope 
SigmaGLPP\main.cpp:52:21: error: too few arguments to function 'void 
glfwSwapBuffers(GLFWwindow*)' 
SigmaGLPP\main.cpp:55:20: error: 'GLFW_KEY_ESC' was not declared in this scope 
SigmaGLPP\main.cpp:56:21: error: 'GLFW_OPENED' was not declared in this scope 
SigmaGLPP\main.cpp:56:33: error: 'glfwGetWindowParam' was not declared in this scope 
SigmaGLPP\main.cpp:56:36: error: expected '}' at end of input 
+1

Bạn đã quản lý để tải các trình đổ bóng cơ bản chưa? – SpicyWeenie

Trả lời

8

Bạn sử dụng tiêu đề GLFW3 nhưng mã bạn viết là GLFW2.

Trong GLFW3 chức năng glfwOpenWindowHint() được đổi tên thành glfwWindowHint()

Kiểm tra trang này để hướng dẫn nâng cấp: http://www.glfw.org/docs/3.0/moving.html Có rất nhiều thứ đã thay đổi kể từ khi GLFW2.

+0

Bởi lỗi có vẻ nhiều hơn số bị thiếu –

+0

@JustinMeiners: Kiểm tra liên kết trang nâng cấp trong câu trả lời của tôi. Có rất nhiều thứ bạn nên nâng cấp. –

+0

Liên kết đã giúp rất nhiều, tôi đã không nhận ra rằng quá nhiều thay đổi từ GLFW2 đến 3. Ngoài ra, phản ứng đó nhanh hơn rất nhiều so với tôi mong đợi, haha. Hy vọng được gặp bạn! –