本文介绍了无法初始化GLEW。缺少GL版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用最新版本的qt creator设置SFML 2.0,我已经设置了SFML,我导入了一个我在visual studio中写的小游戏。编译时,我得到:





我尝试的




  • 重新安装整个qt SDK和qt创作者IDE从头开始

  • 重新安装SFML

  • 重新安装mingw

  • 写一个简单的程序,以确保它不是我的代码,程序编译正确,但当我关闭应用程序,我得到OpenGL的错误,这是不正常的

  • 我试过在SFML上发布一个线程

  • Google搜索错误显示了一些特定于OpenGL的结果,这些结果过于本地化,它们不适用于我,没有回答这种情况in SFML 2.0



其他详细信息




  • 我正在运行Windows XP SP3,mingw和qt SDK和SFML的最新版本


  • 尝试使用Visual Studio 2010上的任何错误,甚至警告 的代码:块


  • ,我确信SFML在我的IDE设置,基本代码工作,但显示那些错误和更高级的代码显示所有精灵和文本框。

  • 我没有编译SFML自己


  • 我的gcc版本是4.6.2


  • 我的gcc是DW2一个




我没有收到任何结果,我甚至不知道如何远程接近修复这个问题,甚至不在哪里开始。



EDIT
我无法显示我的所有代码,它超过20个文件,我几乎90%它不是我的代码,我已经说过了:我可以运行这个代码没有任何警告,甚至在任何IDE除了qt creator的错误。

解决方案

这是因为你没有初始化OpenGL。
lib过期的示例。



错误:

  glewInit(); // ERROR MISSING GL VERSION 
glutInitDisplayMode(GLUT_RGB);

好:

 code> glutInitDisplayMode(GLUT_RGB); 
glewInit();

EDIT 我认为SFML:

  sf :: Window App(sf :: VideoMode(400,400,32),Window); 
glewInit();

编辑2 测试此代码。

  #include  
#include< iostream>
#include< GL / glew.h>

int
main(int,const char **)
{
GLenum err;

std :: cout<< Start<< std :: endl;
std :: cout<< 试验1<< std :: endl;
if((err = glewInit())!= GLEW_OK)
std :: cout< glewGetErrorString(err)< std :: endl;

std :: cout<< Init window<< std :: endl;
sf :: Window app(sf :: VideoMode(400,400,32),Windows);

std :: cout<< 测试2<< std :: endl;
if((err = glewInit())!= GLEW_OK)
std :: cout< glewGetErrorString(err)< std :: endl;
std :: cout<< End<< std :: endl;
return 0;
}

我的输出:
$ b 开始
测试1
缺少GL版本
初始化窗口
测试2
结束

编译: g ++ -W -Wall -Werror main.cpp -lsfml- window -lGLEW



祝你好运;)


I've tried to set up SFML 2.0 with the latest version of the qt creator, I've set up SFML right and I imported a small game I wrote in visual studio. Upon compilation, I get this:

What I tried

  • Reinstalling the entire qt SDK and qt creator IDE from scratch
  • Reinstalling SFML
  • reinstalling mingw
  • I tried to write a simple program to make sure it's not my code, the program compiles correctly but when I close the application, I get OpenGL errors which is not normal
  • I tried posting a thread on the SFML forums but to no avail.
  • Googling the errors shows a few results, which are specific to OpenGL, and which are too localized, they don't apply to me, no answer for this happening in SFML 2.0

Additional details

  • I'm running windows XP SP3, latest version of mingw and qt SDK and SFML

  • The code I'm trying to work with works without any errors or even warnings on Visual Studio 2010 and Code::Blocks

  • Yes, I am sure that SFML is set up on my IDE, basic code works but shows those errors and more advanced code shows all sprites and text as boxes.
  • I did not compile SFML myself

  • My gcc version is 4.6.2

  • My gcc is a DW2 one

I'm getting no results, I don't even know how to remotely get close to fixing this, not even where to start.

EDITI can't show you all of my code, it's over 20 files and I'm almost 90% sure it's not my code, I've said it above: I can run this code without any warnings or even errors on any IDE except qt creator.

解决方案

It's because you are not initializing OpenGL.Example with the lib glut.

Wrong:

 glewInit();  // ERROR MISSING GL VERSION
 glutInitDisplayMode(GLUT_RGB);

Good:

 glutInitDisplayMode(GLUT_RGB);
 glewInit();

EDIT I think for SFML:

 sf::Window   App(sf::VideoMode(400, 400, 32), "Window");
 glewInit();

EDIT 2 Test this code.

#include <SFML/Window.hpp>
#include <iostream>
#include <GL/glew.h>

int
main(int, const char**)
{
    GLenum      err;

    std::cout << "Start" << std::endl;
    std::cout << "Test 1" << std::endl;
    if ((err = glewInit()) != GLEW_OK)
        std::cout << glewGetErrorString(err) << std::endl;

    std::cout << "Init window" << std::endl;
    sf::Window  app(sf::VideoMode(400, 400, 32), "Windows");

    std::cout << "Test 2" << std::endl;
    if ((err = glewInit()) != GLEW_OK)
        std::cout << glewGetErrorString(err) << std::endl;
    std::cout << "End" << std::endl;
    return 0;
}

My output:

Start
Test 1
Missing GL version
Init window
Test 2
End

Compile with: g++ -W -Wall -Werror main.cpp -lsfml-window -lGLEW

Good Luck ;)

这篇关于无法初始化GLEW。缺少GL版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 01:30