代码如下:
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#游戏编程这本书来进行严肃的游戏创作。
发布于 2013-07-12 02:33:26
它在您的代码运行的同一目录中查找文件face.tif。
正在设置传递到LoadTexture方法中的path是什么
发布于 2016-09-11 06:55:13
在Form主类(Ex: Form.cs)上,将以下两行放在构造函数的顶部:
public Form1(){
InitializeComponent();
_openGLControl.InitializeContexts();https://stackoverflow.com/questions/17600806
复制相似问题