void LoadTexture(byte[] bytes) { LogFile.WriteLine("loading texture to opengl, bytescount = " + bytes.Length); // from http://svn.sourceforge.net/viewvc/boogame/trunk/BooGame/src/Texture.cs?view=markup int ilImage; Il.ilGenImages(1, out ilImage); Il.ilBindImage(ilImage); if (!Il.ilLoadL(Il.IL_TYPE_UNKNOWN, bytes, bytes.Length)) { throw new Exception("Failed to load image."); } if (!Il.ilConvertImage(Il.IL_RGBA, Il.IL_UNSIGNED_BYTE)) { throw new Exception("Failed to convert image."); } int m_BytesPerPixel = Il.ilGetInteger(Il.IL_IMAGE_BPP); int m_Width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); int m_Height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); int m_Format = Il.ilGetInteger(Il.IL_IMAGE_FORMAT); int m_Depth = Il.ilGetInteger(Il.IL_IMAGE_DEPTH); LogFile.WriteLine("size: " + m_Width + " x " + m_Height + " depth " + m_Depth + " bytesperpixel " + m_BytesPerPixel); int m_TextureWidth = NextPowerOfTwo(m_Width); int m_TextureHeight = NextPowerOfTwo(m_Height); if ((m_TextureWidth != m_Width) || (m_TextureHeight != m_Height)) { Ilu.iluEnlargeCanvas(m_TextureWidth, m_TextureHeight, m_Depth); } //Ilu.iluFlipImage(); Gl.glBindTexture(Gl.GL_TEXTURE_2D, idingraphicsengine); Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST); Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST); Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, m_BytesPerPixel, m_TextureWidth, m_TextureHeight, 0, m_Format, Gl.GL_UNSIGNED_BYTE, Il.ilGetData()); Il.ilDeleteImages(1, ref ilImage); }