In my application, I needed to pull the textures onto a geometric object. Actually, I did it. I use Tao.Opengl in the program. For texturing - DevIl
//Загрузка текстур private static uint MakeGlTexture(int Format, IntPtr pixels, int w, int h) { uint texObject; Gl.glGenTextures(1, out texObject); Gl.glPixelStorei(Gl.GL_UNPACK_ALIGNMENT, 1); Gl.glBindTexture(Gl.GL_TEXTURE_2D, texObject); // устанавливаем режим фильтрации и повторения текстуры Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR); Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_REPLACE); Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, w, h, 0, Gl.GL_RGB, Gl.GL_UNSIGNED_BYTE, pixels); return texObject; } public static byte[] ImageToByte(Image img) { ImageConverter converter = new ImageConverter(); return (byte[])converter.ConvertTo(img, typeof(byte[])); } private unsafe void texture(int imageId,Bitmap pic,int type, uint*obj) { Il.ilGenImages(1, out imageId); Il.ilBindImage(imageId); byte[] buf = ImageToByte(pic); Il.ilLoadL(type, buf, buf.Length); int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); *obj = MakeGlTexture(Gl.GL_RGB, Il.ilGetData(), width, height); Il.ilDeleteImages(1, ref imageId); } private unsafe void textureLoad() { fixed (uint* tex = &earth_tex) { texture(imageId_e, Properties.Resources.e2, Il.IL_JPG, tex); } fixed (uint* tex = &space_tex) { texture(imageId_s, Properties.Resources.space_b, Il.IL_JPG, tex); } fixed (uint* tex = &meteor_tex) { texture(imageId_m, Properties.Resources.meteor, Il.IL_JPG, tex); } } Glu.GLUquadric quadr; //Отрисовка сферы с текстурой: quadr = Glu.gluNewQuadric(); Glu.gluQuadricTexture(quadr, Gl.GL_TRUE); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glBindTexture(Gl.GL_TEXTURE_2D, earth_tex); Glu.gluSphere(quadr, EARTH_RADIUS_Z, 64, 64); Gl.glDisable(Gl.GL_TEXTURE_2D); The textures are displayed successfully on my computer and my friends' computers. However, running the project on the terminal computers of the university presented the following picture to me:
The following image is used for texturing:
Here's what I actually look like:
How can this be caused? How to fix it?