在此范围内未声明glfwOpenWindowHint GLFW3&格莱夫 [英] glfwOpenWindowHint not declared in this scope GLFW3 & GLEW

查看:125
本文介绍了在此范围内未声明glfwOpenWindowHint GLFW3&格莱夫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在针对OpenGL 3+的一些OpenGL教程之后,马上就出现了一些差异,这是我设法获得的代码,但是马上,我得到了这么多的错误,没有一个错误指出找不到标题,而仅仅是标题没有定义核心功能.

Following some OpenGL tutorials for OpenGL 3+, Right out of the gate, I've run into some discrepancies, here is the code I managed to get, but right out of the gate, I'm getting this massive slew of errors, none of which say it can't find the included headers, but merely that the headers don't define the core functions.

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

问题在于,MinGW非常不喜欢这样做,并且已经产生了大量的未声明的"错误,OpenGL窗口必须存在所有这些错误.除了一点点SDL2之外,我从未使用过任何图形库,因此您可能需要带我逐步了解一下....非常感谢.

The problem being the fact that MinGW doesn't like this very much and has produced a ton of "undeclared" errors, all of which are required for an OpenGL window to exist. I've never worked with any graphics library other than a little bit of SDL2, so you may need to walk me through this... Which would be very appreciated.

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

推荐答案

您使用 GLFW3 标头,但您编写的代码适用于 GLFW2 .

You use GLFW3 headers but the code you wrote is for GLFW2.

GLFW3 中,函数 glfwOpenWindowHint()重命名为 glfwWindowHint()

查看此页面以获取升级说明: http://www.glfw.org/docs/3.0/moving.html GLFW2 以来,发生了很多变化.

Check out this page for upgrade instructions: http://www.glfw.org/docs/3.0/moving.html There are a lot of things that changed since GLFW2.

这篇关于在此范围内未声明glfwOpenWindowHint GLFW3&amp;格莱夫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆