public static void FinishTextures(Texture[] textures) { foreach(Texture t in textures) { int textureID; GL.GenTextures(1, out textureID); GL.BindTexture(TextureTarget.Texture2D, textureID); BitmapData bmpData = t.TempBitmap.LockBits(new Rectangle(0, 0, t.TempBitmap.Width, t.TempBitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); t.TempBitmap.UnlockBits(bmpData); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, t.TempBitmap.Width, t.TempBitmap.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0); GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (float)TextureEnvMode.Modulate); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); float maxAniso; GL.GetFloat((GetPName)ExtTextureFilterAnisotropic.MaxTextureMaxAnisotropyExt, out maxAniso); GL.TexParameter(TextureTarget.Texture2D, (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt, maxAniso); GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); t.TextureID = (uint)textureID; t.TempBitmap.Dispose(); t.TempBitmap = null; t.IsFinished = true; } }
public Model(MeshVertex[] vertices, Mesh[] meshes, Texture[] textures) { Meshes = meshes; TempVertices = vertices; TempTextures = textures; IsFinished = false; }