private void uploadBitmapToOpenGl() { _texture = createTexture(); IBitmap bitmap = _bitmapPool.Acquire(_draw.BitmapWidth, _draw.BitmapHeight); try { IBitmapTextDraw textDraw = bitmap.GetTextDraw(); using (var context = textDraw.CreateContext()) { textDraw.DrawText(_draw.Text, _draw.Config, _draw.TextSize, _draw.BaseSize, _draw.MaxWidth, (int)_draw.HeightF, 0f); drawCaret(_draw.OriginalText, _draw.TextSize, _draw.HeightF, _draw.BaseSize, textDraw, _draw.Config, _draw.MaxWidth); } // Upload the Bitmap to OpenGL. // Do this only when text changes. bitmap.LoadTexture(_texture); } catch (InvalidOperationException e) { Debug.WriteLine(e.ToString()); throw; } finally { releaseBitmap(bitmap); } }
private IImage loadImage(ITexture texture, IBitmap bitmap, string id, ILoadImageConfig config, ISpriteSheet spriteSheet) { manipulateImage(bitmap, config); bitmap.LoadTexture(null); GLImage image = new GLImage(bitmap, id, texture, spriteSheet, config); string imageId = image.ID; _textures?.GetOrAdd(imageId, () => image.Texture); image.OnImageDisposed.Subscribe(() => _textures.Remove(imageId)); return(image); }
private IImage loadImage(ITexture texture, IBitmap bitmap, string id, ILoadImageConfig config, ISpriteSheet spriteSheet) { manipulateImage(bitmap, config); bitmap.LoadTexture(null); GLImage image = new GLImage(bitmap, id, texture, spriteSheet, config); if (_textures != null) { _textures.GetOrAdd(image.ID, () => image.Texture); } return(image); }
private void uploadBitmapToOpenGl() { try { // Upload the Bitmap to OpenGL. // Do this only when text changes. _bitmap.LoadTexture(_texture); } catch (InvalidOperationException e) { Debug.WriteLine(e.ToString()); throw; } }
private IImage loadImage(ITexture texture, IBitmap bitmap, string id, ILoadImageConfig config, ISpriteSheet spriteSheet) { manipulateImage(bitmap, config); bitmap.LoadTexture(null); GLImage image = new GLImage (bitmap, id, texture, spriteSheet, config); if (_textures != null) _textures.GetOrAdd (image.ID, () => image.Texture); return image; }