我在 OpenGL,Tao 框架中工作。我已经完成了所有的编程,但我不能插入多个纹理。这是我的代码。为了将另一个图像放入数组中,我应该插入什么?这就是我调用 3 个纹理的方式,但第 3 个和其他纹理总是 owerwriten。
Gl.glClearDepth(1.0); Gl.glClearColor(0.0f, 0.2f, 0.3f, 0.0f); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glFrontFace(Gl.GL_CW); Gl.glEnable(Gl.GL_COLOR_MATERIAL); Gl.glShadeModel(Gl.GL_SMOOTH); Gl.glEnable(Gl.GL_LIGHTING); Gl.glEnable(Gl.GL_LIGHT0); Gl.glDepthFunc(Gl.GL_LEQUAL); Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST); Gl.glEnable(Gl.GL_TEXTURE_2D); texture = new uint[5]; Bitmap image = new Bitmap("1.jpg"); image.RotateFlip(RotateFlipType.RotateNoneFlipY); System.Drawing.Imaging.BitmapData bitmapdata; Rectangle rect = new Rectangle(0, 0, image.Width, image.Height); bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Gl.glGenTextures(1, texture); Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture[1]); Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, (int)Gl.GL_RGB8, image.Width, image.Height, 0, Gl.GL_BGR_EXT, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR); // Linear Filtering Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR); // Linear Filtering Gl.glViewport(0, 0, Size.Width, Size.Height); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Glu.gluPerspective(60, ((float)Size.Width / (float)Size.Height), 0.1, 1000); Gl.glEnable(Gl.GL_TEXTURE_2D); image = new Bitmap("2.jpg"); image.RotateFlip(RotateFlipType.RotateNoneFlipY); rect = new Rectangle(0, 0, image.Width, image.Height); bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Gl.glGenTextures(1, texture); Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture[0]); Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, (int)Gl.GL_RGB8, image.Width, image.Height, 0, Gl.GL_BGR_EXT, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR); // Linear Filtering Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR); // Linear Filtering Gl.glViewport(0, 0, Size.Width, Size.Height); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Glu.gluPerspective(60, ((float)Size.Width / (float)Size.Height), 0.1, 1000); Gl.glEnable(Gl.GL_TEXTURE_2D); image = new Bitmap("3.jpg"); image.RotateFlip(RotateFlipType.RotateNoneFlipY); rect = new Rectangle(0, 0, image.Width, image.Height); bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Gl.glGenTextures(1, texture); Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture[0]); Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, (int)Gl.GL_RGB8, image.Width, image.Height, 0, Gl.GL_BGR_EXT, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR); // Linear Filtering Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR); // Linear Filtering Gl.glViewport(0, 0, Size.Width, Size.Height); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Glu.gluPerspective(60, ((float)Size.Width / (float)Size.Height), 0.1, 1000); Gl.glEnable(Gl.GL_TEXTURE_2D);