[visual-studio]在 0x585727FF 土壤未处理的异常

标签: Visual-Studio
发布时间: 2014/3/1 3:52:29
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

我有我不知道如何解决的错误。

我创建一个简单的程序,使用 VS2012,为了测试土壤 (从土壤的网站示例代码):

#include "SOIL.h"
#include <iostream>
#include <glew.h>
#include <freeglut.h>

int main() {
std::cout << "Started" << std::endl;

/* load an image file directly as a new OpenGL texture */
GLuint tex_2d = SOIL_load_OGL_texture
    (
    "img.png",
    SOIL_LOAD_AUTO,
    SOIL_CREATE_NEW_ID,
    SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
    );

/* check for an error during the load process */
if( 0 == tex_2d )
{
    printf( "SOIL loading error: '%s'\n", SOIL_last_result() );
}
}

出现错误:

Unhandled exception at 0x585727FF (msvcr110d.dll) in imageLib.exe: 0xC0000005: Access violation reading location 0x00000000.

任何帮助被赞赏。谢谢。

解决方法 1:

我做的一切是为了确保在尝试使用 GLuint 作为 Necrolis 建议之前加载的 GL。

如果您有库加载正确的这个小示例应运行没有错误 (不会显示任何东西,但显示 GL 和土壤的顺序:

#include "SOIL.h"
#include <iostream>
#include <glew.h>
#include <freeglut.h>

#define WINDOW_WIDTH  800
#define WINDOW_HEIGHT 600

void LoadTexture() {
/* load an image file directly as a new OpenGL texture */
GLuint tex_2d = SOIL_load_OGL_texture
    (
    "Data/img.png",
    SOIL_LOAD_AUTO,
    SOIL_CREATE_NEW_ID,
    SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
    );

/* check for an error during the load process */
if( 0 == tex_2d )
{
    printf( "SOIL loading error: '%s'\n", SOIL_last_result() );
}

// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, tex_2d);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}

int main(int argc, char** argv) {
std::cout << "Started" << std::endl;

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
glutInitWindowPosition(100, 100);
glutCreateWindow("Tutorial 15");

glutSwapBuffers();

LoadTexture();

glEnable(GL_TEXTURE_2D);                            // Enable Texture Mapping ( NEW )
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

glutMainLoop();

return 0;
}
官方微信
官方QQ群
31647020