首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用DevIL打开文件

无法使用DevIL打开文件
EN

Stack Overflow用户
提问于 2013-07-12 02:30:37
回答 2查看 314关注 0票数 0

代码如下:

代码语言:javascript
复制
 public void LoadTexture(string textureId, string path)
    {
        int devilId = 0;
        Il.ilGenImages(1, out devilId);
        Il.ilBindImage(devilId); // set as the active texture

        if (!Il.ilLoadImage(path))
        {
            System.Diagnostics.Debug.Assert(false, "Could not open file, [" + path + "].");
        }
        // The files we'll be using need to be flipped before passing to OpenGL
        Ilu.iluFlipImage();
        int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH);
        int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT);
        int openGLId = Ilut.ilutGLBindTexImage();

        System.Diagnostics.Debug.Assert(openGLId != 0);
        Il.ilDeleteImages(1, ref devilId);

        _textureDatabase.Add(textureId, new Texture(openGLId, width, height));
    }

我收到断言失败,无法打开文件face.tif错误。我确保face.tif文件位于项目文件夹、解决方案文件夹、bin文件夹、bin\debug文件夹中,但仍然无法打开它。

我正在尝试遵循C#游戏编程这本书来进行严肃的游戏创作。

EN

回答 2

Stack Overflow用户

发布于 2013-07-12 02:33:26

它在您的代码运行的同一目录中查找文件face.tif

正在设置传递到LoadTexture方法中的path是什么

票数 0
EN

Stack Overflow用户

发布于 2016-09-11 06:55:13

Form主类(Ex: Form.cs)上,将以下两行放在构造函数的顶部:

代码语言:javascript
复制
public Form1(){

    InitializeComponent();
    _openGLControl.InitializeContexts();
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17600806

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档