public OpenGLESTexture2D( int mipLevels, int width, int height, PixelFormat veldridFormat, OpenTK.Graphics.ES30.PixelFormat pixelFormat, PixelType pixelType) : base(TextureTarget.Texture2D, width, height) { MipLevels = mipLevels; _veldridFormat = veldridFormat; _pixelFormat = pixelFormat; _pixelType = pixelType; _texComponentCount = OpenGLESFormats.MapTextureComponentCount(veldridFormat, pixelFormat == OpenTK.Graphics.ES30.PixelFormat.DepthComponent); Bind(); for (int currentLevel = 0; currentLevel < mipLevels; currentLevel++) { // Set size, load empty data into texture GL.TexImage2D( TextureTarget2d.Texture2D, currentLevel, _texComponentCount, width, height, 0, // border _pixelFormat, _pixelType, IntPtr.Zero); Utilities.CheckLastGLES3Error(); width = Math.Max(1, width / 2); height = Math.Max(1, height / 2); } }
public OpenGLESCubemapTexture( IntPtr pixelsFront, IntPtr pixelsBack, IntPtr pixelsLeft, IntPtr pixelsRight, IntPtr pixelsTop, IntPtr pixelsBottom, int width, int height, PixelFormat format) : base(TextureTarget.TextureCubeMap, width, height) { _texComponentCount = OpenGLESFormats.MapTextureComponentCount(format, false); _format = OpenGLESFormats.MapPixelFormat(format); _type = OpenGLESFormats.MapPixelType(format); Bind(); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); Utilities.CheckLastGLES3Error(); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)TextureMagFilter.Linear); Utilities.CheckLastGLES3Error(); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge); Utilities.CheckLastGLES3Error(); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); Utilities.CheckLastGLES3Error(); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapR, (int)TextureWrapMode.ClampToEdge); Utilities.CheckLastGLES3Error(); SetFacePixels(0, pixelsRight); SetFacePixels(1, pixelsLeft); SetFacePixels(2, pixelsTop); SetFacePixels(3, pixelsBottom); SetFacePixels(4, pixelsBack); SetFacePixels(5, pixelsFront); }