//public unsafe GLTexture(GLModel gLModel, MDL0TextureNode tex) //{ // _name = tex.Name; //} public unsafe uint Initialize(GLContext context) { if (_remake) { ClearTexture(context); uint id = 0; context.glGenTextures(1, &id); _texId = id; context.glBindTexture(GLTextureTarget.Texture2D, id); context.glTexParameter(GLTextureTarget.Texture2D, GLTextureParameter.MagFilter, (int)GLTextureFilter.LINEAR); context.glTexParameter(GLTextureTarget.Texture2D, GLTextureParameter.MinFilter, (int)GLTextureFilter.NEAREST_MIPMAP_LINEAR); context.glTexParameter(GLTextureTarget.Texture2D, GLTextureParameter.BaseLevel, 0); context.glTexParameter(GLTextureTarget.Texture2D, GLTextureParameter.MaxLevel, _textures.Length - 1); for (int i = 0; i < _textures.Length; i++) { Bitmap bmp = _textures[i]; BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); context.glTexImage2D(GLTexImageTarget.Texture2D, i, (GLInternalPixelFormat)4, data.Width, data.Height, 0, GLPixelDataFormat.BGRA, GLPixelDataType.UNSIGNED_BYTE, (void *)data.Scan0); bmp.UnlockBits(data); } _remake = false; ClearImages(); } return(_texId); }
//public GLTexture() { } public unsafe GLTexture(GLContext ctx, int width, int height) { uint id; ctx.glGenTextures(1, &id); if ((_id = id) == 0) { ctx.CheckErrors(); } _context = ctx; _width = width; _height = height; }