public static Texture FromPicture(PictureObjectModel pic, TextureRotation rotation, TextureFlip flip) { if (texturesByPicture.ContainsKey(pic)) { Texture tex = texturesByPicture[pic]; tex.Rotation = rotation; tex.Flip = flip; return tex; } uint[] textureIDs = new uint[1]; Internal.OpenGL.Methods.glGenTextures(1, textureIDs); Internal.OpenGL.Methods.glErrorToException(); uint textureID = textureIDs[0]; Texture texture = new Texture(textureID); texture.Target = TextureTarget.Texture2D; texture.TextureImage = pic; texture.MinFilter = TextureFilter.Linear; texture.MagFilter = TextureFilter.Linear; texture.TextureWrapR = TextureWrap.Repeat; texture.TextureWrapS = TextureWrap.Repeat; texture.TextureWrapT = TextureWrap.Repeat; texture.Rotation = rotation; texture.Flip = flip; if (!texturesByID.ContainsKey(textureID)) { texturesByID.Add(textureID, texture); } if (!texturesByPicture.ContainsKey(pic)) { texturesByPicture.Add(pic, texture); } return texture; }
public static Texture FromFile(string FileName, TextureRotation rotation, TextureFlip flip) { if (texturesByFileName.ContainsKey(FileName)) { Texture tex = texturesByFileName[FileName]; tex.Rotation = rotation; tex.Flip = flip; return tex; } uint[] textureIDs = new uint[1]; Internal.OpenGL.Methods.glGenTextures(1, textureIDs); uint textureID = textureIDs[0]; Texture texture = new Texture(textureID); texture.Target = TextureTarget.Texture2D; texture.FileName = FileName; texture.MinFilter = TextureFilter.Linear; texture.MagFilter = TextureFilter.Linear; // texture.TextureWrapR = TextureWrap.Repeat; texture.TextureWrapS = TextureWrap.Repeat; texture.TextureWrapT = TextureWrap.Repeat; texture.Rotation = rotation; texture.Flip = flip; if (!texturesByID.ContainsKey(textureID)) { texturesByID.Add(textureID, texture); } if (!texturesByFileName.ContainsKey(FileName)) { texturesByFileName.Add(FileName, texture); } return texture; }