Exemple #1
0
 public DesktopBitmap(Bitmap bitmap, IGraphicsBackend graphics)
 {
     _bitmap   = bitmap;
     Width     = bitmap.Width;
     Height    = bitmap.Height;
     _graphics = graphics;
 }
Exemple #2
0
 public AndroidBitmap(Bitmap bitmap, IGraphicsBackend graphics)
 {
     _bitmap   = bitmap;
     Width     = _bitmap.Width;
     Height    = _bitmap.Height;
     _graphics = graphics;
 }
Exemple #3
0
        public ShakeEffect(float strength = 0.05f, float decay = 0.99f, IObject target = null, IGraphicsBackend graphics = null)
		{
            _graphics = graphics ?? Hooks.GraphicsBackend;
			_target = target;
			_strength = strength;
			_decay = decay;
		}
        public AGSTextComponent(IRenderPipeline pipeline, IBoundingBoxBuilder boundingBoxBuilder,
                                IGLTextureRenderer textureRenderer, BitmapPool bitmapPool,
                                AGSBoundingBoxes labelBoundingBoxes, AGSBoundingBoxes textBoundingBoxes,
                                IGLUtils glUtils, IGraphicsBackend graphics, IFontFactory fonts,
                                IRuntimeSettings settings, IRenderMessagePump messagePump, IGameState state, IGameEvents events)
        {
            _pipeline = pipeline;
            _afterCropTextBoundingBoxes = new AGSBoundingBoxes();
            _state                       = state;
            _events                      = events;
            Width                        = 1f;
            Height                       = 1f;
            _matricesPool                = new GLMatrices[3];
            _messagePump                 = messagePump;
            OnLabelSizeChanged           = new AGSEvent();
            _graphics                    = graphics;
            _fonts                       = fonts;
            _bitmapPool                  = bitmapPool;
            _labelBoundingBoxes          = labelBoundingBoxes;
            _textBoundingBoxes           = textBoundingBoxes;
            _boundingBoxBuilder          = boundingBoxBuilder;
            _virtualResolution           = settings.VirtualResolution;
            _settings                    = settings;
            _labelBoundingBoxFakeBuilder = new BoundingBoxesEmptyBuilder();

            _instructionPool = new ObjectPool <Instruction>(pool => new Instruction(pool, glUtils, textureRenderer, _glTextHitTest), 0);

            TextVisible = true;

            subscribeTextConfigChanges();
            PropertyChanged           += onPropertyChanged;
            _shouldUpdateBoundingBoxes = true;
        }
Exemple #5
0
 public ShakeEffect(float strength = 0.05f, float decay = 0.99f, IObject target = null, IGraphicsBackend graphics = null)
 {
     _graphics = graphics ?? AGSGame.Device.GraphicsBackend;
     _target   = target;
     _strength = strength;
     _decay    = decay;
 }
Exemple #6
0
        private GLShader(string vertexSource, string fragmentSource, IGraphicsBackend graphics)
		{
            _graphics = graphics;
			_vertexSource = vertexSource;
			_fragmentSource = fragmentSource;
			_variables = new Dictionary<string, int> ();
			_textures = new Dictionary<int, int> ();
		}
 public RoomTransitionDissolve(IGLUtils glUtils, IGraphicsBackend graphics, float timeInSeconds = 1f, Func <float, float> easing = null, IGame game = null)
 {
     _graphics      = graphics;
     _timeInSeconds = timeInSeconds;
     _easing        = easing ?? Ease.Linear;
     game           = game ?? AGSGame.Game;
     _screenVectors = new QuadVectors(game, glUtils);
 }
Exemple #8
0
 public GLUtils(IGraphicsBackend graphics, IRenderMessagePump messagePump)
 {
     _graphics               = graphics;
     _messagePump            = messagePump;
     _quad                   = new GLVertex[4];
     _line                   = new GLVertex[2];
     CurrentGlobalResolution = new SizeF();
 }
Exemple #9
0
 private GLShader(string vertexSource, string fragmentSource, IGraphicsBackend graphics)
 {
     _graphics       = graphics;
     _vertexSource   = vertexSource;
     _fragmentSource = fragmentSource;
     _variables      = new Dictionary <string, int> ();
     _textures       = new Dictionary <int, int> ();
 }
Exemple #10
0
        public static async Task<GLShader> FromResource(string vertexResource, string fragmentResource, IGraphicsBackend graphics = null)
		{
            graphics = graphics ?? Hooks.GraphicsBackend;
			ResourceLoader loader = new ResourceLoader ();
			string vertexSource = await getSource(vertexResource, loader);
			string fragmentSource = await getSource(fragmentResource, loader);
            return FromText(vertexSource, fragmentSource, graphics);
		}
        public RoomTransitionDissolve(IGLUtils glUtils, IGraphicsBackend graphics, float timeInSeconds = 1f, Func<float, float> easing = null, IGame game = null)
		{
            _graphics = graphics;
			_timeInSeconds = timeInSeconds;
			_easing = easing ?? Ease.Linear;
			game = game ?? AGSGame.Game;
            _screenVectors = new QuadVectors (game, glUtils);
		}
Exemple #12
0
 public GLUtils(IGraphicsBackend graphics, IRenderMessagePump messagePump, IGameState state)
 {
     _state            = state;
     _graphics         = graphics;
     _messagePump      = messagePump;
     _quad             = new GLVertex[4];
     _line             = new GLVertex[2];
     CurrentResolution = new SizeF();
 }
Exemple #13
0
 public GLShader(string vertexSource, string fragmentSource, IGraphicsBackend graphics)
 {
     _graphics                  = graphics;
     _vertexSource              = vertexSource;
     _fragmentSource            = fragmentSource;
     _variables                 = new Dictionary <string, int> ();
     _textures                  = new Dictionary <int, int> ();
     _queryVariableLocationFunc = queryVariableLocation; //Caching delegate to avoid memory allocations on critical path
 }
Exemple #14
0
        public GLFrameBuffer(Size size, IGraphicsBackend graphics)
		{
            _width = size.Width;
            _height = size.Height;
            Texture = new GLTexture(null, graphics);
            _graphics = graphics;
            _graphics.TexImage2D(_width, _height, IntPtr.Zero);

			_fbo = _graphics.GenFrameBuffer();
		}
Exemple #15
0
 public GLTexture(ITextureConfig config, IGraphicsBackend graphics)
 {
     _graphics = graphics;
     if (Environment.CurrentManagedThreadId != AGSGame.UIThreadID)
     {
         throw new InvalidOperationException("Must generate textures on the UI thread");
     }
     ID = _graphics.GenTexture();
     Config = config ?? new AGSTextureConfig();
 }
Exemple #16
0
 public GLTexture(ITextureConfig config, IGraphicsBackend graphics)
 {
     _graphics = graphics;
     if (Environment.CurrentManagedThreadId != AGSGame.UIThreadID)
     {
         throw new InvalidOperationException("Must generate textures on the UI thread");
     }
     ID     = _graphics.GenTexture();
     Config = config ?? new AGSTextureConfig();
 }
Exemple #17
0
        public GLFrameBuffer(Size size, IGraphicsBackend graphics)
        {
            _width    = size.Width;
            _height   = size.Height;
            Texture   = new GLTexture(null, graphics);
            _graphics = graphics;
            _graphics.TexImage2D(_width, _height, IntPtr.Zero);

            _fbo = _graphics.GenFrameBuffer();
        }
        public GLGraphicsFactory (Dictionary<string, ITexture> textures, IContainer resolver, IGLUtils glUtils, IGraphicsBackend graphics)
		{
			this._textures = textures;
			this._resolver = resolver;
			this._resources = resolver.Resolve<IResourceLoader>();
			this._bitmapLoader = Hooks.BitmapLoader;
            this._spriteSheetLoader = new SpriteSheetLoader (_resources, _bitmapLoader, addAnimationFrame, loadImage, graphics);
            
            AGSGameSettings.CurrentSkin = new AGSBlueSkin(this, glUtils).CreateSkin();
		}
Exemple #19
0
 public SpriteSheetLoader(IResourceLoader resources, IBitmapLoader bitmapLoader,
                          Action <IImage, AGSAnimation> addAnimationFrame,
                          Func <ITexture, IBitmap, string, ILoadImageConfig, ISpriteSheet, IImage> loadImage,
                          IGraphicsBackend graphics)
 {
     _graphics          = graphics;
     _resources         = resources;
     _bitmapLoader      = bitmapLoader;
     _addAnimationFrame = addAnimationFrame;
     _loadImage         = loadImage;
 }
		public SpriteSheetLoader (IResourceLoader resources, IBitmapLoader bitmapLoader, 
                                  Action<IImage, AGSAnimation> addAnimationFrame,
                                  Func<ITexture, IBitmap, string, ILoadImageConfig, ISpriteSheet, IImage> loadImage,
                                  IGraphicsBackend graphics)
		{
            _graphics = graphics;
			_resources = resources;
			_bitmapLoader = bitmapLoader;
			_addAnimationFrame = addAnimationFrame;
			_loadImage = loadImage;
		}
Exemple #21
0
        public GLText (IGraphicsBackend graphics, BitmapPool pool, string text = "", int maxWidth = int.MaxValue)
		{
            _graphics = graphics;
			this._maxWidth = maxWidth;
			this._text = text;
			this._bitmapPool = pool;            
			_texture = createTexture ();
			_config = new AGSTextConfig ();

			drawToBitmap();
		}
Exemple #22
0
        public GLText(IGraphicsBackend graphics, IFontLoader fonts, BitmapPool pool, string text = "", int maxWidth = int.MaxValue)
        {
            _fonts           = fonts;
            _graphics        = graphics;
            this._maxWidth   = maxWidth;
            this._text       = text;
            this._bitmapPool = pool;
            _texture         = createTexture();
            _config          = new AGSTextConfig();

            drawToBitmap();
        }
Exemple #23
0
        public GLGraphicsFactory(Dictionary <string, ITexture> textures, IContainer resolver, IGLUtils glUtils,
                                 IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IUIThread uiThread)
        {
            this._uiThread          = uiThread;
            this._textures          = textures;
            this._resolver          = resolver;
            this._resources         = resolver.Resolve <IResourceLoader>();
            this._bitmapLoader      = bitmapLoader;
            this._spriteSheetLoader = new SpriteSheetLoader(_resources, _bitmapLoader, addAnimationFrame, loadImage, graphics);

            AGSGameSettings.CurrentSkin = new AGSBlueSkin(this, glUtils).CreateSkin();
        }
Exemple #24
0
 public AGSGame(IGameState state, IGameEvents gameEvents, IRenderMessagePump renderMessagePump, IUpdateMessagePump updateMessagePump,
                IGraphicsBackend graphics, IGLUtils glUtils)
 {
     _renderMessagePump = renderMessagePump;
     _renderMessagePump.SetSyncContext();
     _updateMessagePump = updateMessagePump;
     State          = state;
     Events         = gameEvents;
     _relativeSpeed = state.Speed;
     _graphics      = graphics;
     _glUtils       = glUtils;
     GLUtils        = _glUtils;
 }
Exemple #25
0
 public AGSGame(IGameState state, IGameEvents gameEvents, IMessagePump messagePump,
                IGraphicsBackend graphics, IGLUtils glUtils)
 {
     _messagePump = messagePump;
     _messagePump.SetSyncContext();
     State            = state;
     Events           = gameEvents;
     _relativeSpeed   = state.Speed;
     _renderEventArgs = new AGSEventArgs();
     _graphics        = graphics;
     _glUtils         = glUtils;
     GLUtils          = _glUtils;
 }
Exemple #26
0
#pragma warning restore CS0067

        public GLLabelRenderer(Dictionary <string, ITexture> textures,
                               IBoundingBoxBuilder boundingBoxBuilder, IGLColorBuilder colorBuilder,
                               IGLTextureRenderer textureRenderer, BitmapPool bitmapPool, IGLViewportMatrixFactory viewportMatrix,
                               AGSBoundingBoxes labelBoundingBoxes, AGSBoundingBoxes textBoundingBoxes, IGraphicsFactory graphicsFactory,
                               IGLUtils glUtils, IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IFontLoader fonts,
                               IRuntimeSettings settings, IRenderMessagePump messagePump, IGameState state, IGameEvents events)
        {
            _bindings = new List <IComponentBinding>();
            _afterCropTextBoundingBoxes = new AGSBoundingBoxes();
            _state                       = state;
            _events                      = events;
            Width                        = 1f;
            Height                       = 1f;
            _matricesPool                = new GLMatrices[3];
            _messagePump                 = messagePump;
            OnLabelSizeChanged           = new AGSEvent();
            _glUtils                     = glUtils;
            _graphics                    = graphics;
            _fonts                       = fonts;
            _bitmapPool                  = bitmapPool;
            _viewport                    = viewportMatrix;
            _textureRenderer             = textureRenderer;
            _labelBoundingBoxes          = labelBoundingBoxes;
            _textBoundingBoxes           = textBoundingBoxes;
            _boundingBoxBuilder          = boundingBoxBuilder;
            _virtualResolution           = settings.VirtualResolution;
            _settings                    = settings;
            _labelBoundingBoxFakeBuilder = new BoundingBoxesEmptyBuilder();
            _bgRenderer                  = new GLImageRenderer(textures,
                                                               colorBuilder, _textureRenderer, graphicsFactory, glUtils, bitmapLoader);

            _colorBuilder = colorBuilder;

            TextVisible           = true;
            TextBackgroundVisible = true;

            subscribeTextConfigChanges();
            PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(TextBackgroundVisible))
                {
                    return;
                }
                onBoundingBoxShouldChange();
                if (e.PropertyName == nameof(Config))
                {
                    subscribeTextConfigChanges();
                }
            };
            _shouldUpdateBoundingBoxes = true;
        }
Exemple #27
0
        public GLText(IGraphicsBackend graphics, IRenderMessagePump messagePump, IFontLoader fonts, BitmapPool pool,
                      bool alwaysMeasureOnly, string text = "", int maxWidth = int.MaxValue)
        {
            _messagePump       = messagePump;
            _fonts             = fonts;
            _graphics          = graphics;
            _alwaysMeasureOnly = alwaysMeasureOnly;
            this._maxWidth     = maxWidth;
            this._text         = text;
            this._bitmapPool   = pool;
            _config            = new AGSTextConfig();

            prepareBitmapDraw();
        }
Exemple #28
0
        public GLText(IGraphicsBackend graphics, IRenderMessagePump messagePump, IFontFactory fonts, IFont defaultFont, BitmapPool pool,
                      bool alwaysMeasureOnly, string text = "", int maxWidth = int.MaxValue)
        {
            _messagePump       = messagePump;
            _fonts             = fonts;
            _graphics          = graphics;
            _alwaysMeasureOnly = alwaysMeasureOnly;
            _maxWidth          = maxWidth;
            _text       = text;
            _bitmapPool = pool;
            _config     = fonts.GetTextConfig(font: defaultFont);

            prepareBitmapDraw();
        }
Exemple #29
0
        public GLGraphicsFactory(Dictionary <string, ITexture> textures, Resolver resolver, IGLUtils glUtils,
                                 IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IRenderThread renderThread,
                                 IResourceLoader resources, IIconFactory icons, IBrushLoader brushes, IRenderMessagePump messagePump)
        {
            Icons              = icons;
            Brushes            = brushes;
            _renderThread      = renderThread;
            _textures          = textures;
            _resolver          = resolver;
            _resources         = resources;
            _bitmapLoader      = bitmapLoader;
            _spriteSheetLoader = new SpriteSheetLoader(_resources, _bitmapLoader, addAnimationFrame, loadImage, graphics, messagePump);

            AGSGameSettings.CurrentSkin = new AGSBlueSkin(this, glUtils).CreateSkin();
        }
Exemple #30
0
        public GLGraphicsFactory(ITextureCache textures, Resolver resolver,
                                 IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IRenderThread renderThread,
                                 IResourceLoader resources, IIconFactory icons, IBrushLoader brushes,
                                 IRenderMessagePump messagePump, IGameSettings settings, IBorderFactory borders)
        {
            Icons              = icons;
            Brushes            = brushes;
            Borders            = borders;
            _renderThread      = renderThread;
            _textures          = textures;
            _resolver          = resolver;
            _resources         = resources;
            _bitmapLoader      = bitmapLoader;
            _spriteSheetLoader = new SpriteSheetLoader(_resources, _bitmapLoader, addAnimationFrame, loadImage, graphics, messagePump);

            settings.Defaults.Skin = new AGSBlueSkin(this).CreateSkin();
        }
Exemple #31
0
 /// <summary>
 /// Retrieves the main rendering buffer's pixel data from video memory in the Rgba8 format.
 /// As a storage array type, either byte or <see cref="ColorRgba"/> is recommended.
 /// </summary>
 /// <param name="target">The target buffer to store transferred pixel data in.</param>
 /// <param name="dataLayout">The desired color layout of the specified buffer.</param>
 /// <param name="dataElementType">The desired color element type of the specified buffer.</param>
 /// <param name="x">The x position of the rectangular area to read.</param>
 /// <param name="y">The y position of the rectangular area to read.</param>
 /// <param name="width">The width of the rectangular area to read. Defaults to the rendering targets width.</param>
 /// <param name="height">The height of the rectangular area to read. Defaults to the rendering targets height.</param>
 public static void GetOutputPixelData <T>(
     this IGraphicsBackend backend,
     T[] target,
     ColorDataLayout dataLayout,
     ColorDataElementType dataElementType,
     int x, int y,
     int width, int height) where T : struct
 {
     using (PinnedArrayHandle pinned = new PinnedArrayHandle(target))
     {
         backend.GetOutputPixelData(
             pinned.Address,
             dataLayout,
             dataElementType,
             x, y,
             width,
             height);
     }
 }
Exemple #32
0
        public GLLabelRenderer(Dictionary <string, ITexture> textures,
                               IGLBoundingBoxBuilder boundingBoxBuilder, IGLColorBuilder colorBuilder,
                               IGLTextureRenderer textureRenderer, BitmapPool bitmapPool, IGLViewportMatrixFactory viewportMatrix,
                               IGLBoundingBoxes labelBoundingBoxes, IGLBoundingBoxes textBoundingBoxes, IGraphicsFactory graphicsFactory,
                               IGLUtils glUtils, IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IFontLoader fonts)
        {
            _glUtils            = glUtils;
            _graphics           = graphics;
            _fonts              = fonts;
            _bitmapPool         = bitmapPool;
            _viewport           = viewportMatrix;
            _textureRenderer    = textureRenderer;
            _labelBoundingBoxes = labelBoundingBoxes;
            _textBoundingBoxes  = textBoundingBoxes;
            _boundingBoxBuilder = boundingBoxBuilder;
            _bgRenderer         = new GLImageRenderer(textures,
                                                      new BoundingBoxesEmptyBuilder(), colorBuilder, _textureRenderer, _labelBoundingBoxes,
                                                      viewportMatrix, graphicsFactory, glUtils, bitmapLoader);

            _colorBuilder = colorBuilder;

            TextVisible = true;
        }
Exemple #33
0
        public AndroidBitmap(Bitmap bitmap, IGraphicsBackend graphics)
		{
			_bitmap = bitmap;
            _graphics = graphics;
		}
Exemple #34
0
 public IOSBitmap(UIImage image, IGraphicsBackend graphics)
 {
     setImage(image);
     _graphics = graphics;
 }
		public AndroidBitmapLoader(IGraphicsBackend graphics)
        {
            _graphics = graphics;
        }
Exemple #36
0
 public GLUtils(IGraphicsBackend graphics)
 {
     _graphics = graphics;
 }
 public IOSBitmapLoader(IGraphicsBackend graphics)
 {
     _graphics = graphics;
 }
Exemple #38
0
        public static async Task <GLShader> FromResource(string vertexResource, string fragmentResource, IGraphicsBackend graphics = null)
        {
            graphics = graphics ?? AGSGame.Device.GraphicsBackend;
            ResourceLoader loader       = new ResourceLoader(AGSGame.Device.FileSystem, AGSGame.Device.Assemblies);
            string         vertexSource = await getSource(vertexResource, loader);

            string fragmentSource = await getSource(fragmentResource, loader);

            return(FromText(vertexSource, fragmentSource, graphics));
        }
Exemple #39
0
 public static GLShader FromText(string vertexSource, string fragmentSource, IGraphicsBackend graphics = null)
 {
     graphics = graphics ?? AGSGame.Device.GraphicsBackend;
     return(new GLShader(vertexSource, fragmentSource, graphics));
 }
Exemple #40
0
        public DesktopBitmap(Bitmap bitmap, IGraphicsBackend graphics)
		{
			_bitmap = bitmap;
            _graphics = graphics;
		}
Exemple #41
0
 public AndroidBitmapLoader(IGraphicsBackend graphics)
 {
     _graphics = graphics;
 }
 public DesktopBitmapLoader(IGraphicsBackend graphics)
 {
     _graphics = graphics;
 }
Exemple #43
0
        public static GLShader FromText(string vertexSource, string fragmentSource, IGraphicsBackend graphics = null)
		{
            graphics = graphics ?? Hooks.GraphicsBackend;
            return new GLShader (vertexSource, fragmentSource, graphics);
		}
Exemple #44
0
 public GLUtils(IGraphicsBackend graphics)
 {
     _graphics = graphics;
 }