internal Surface(IntSize size, MultisampleQuality multisample, SurfaceType surfaceType, bool isScreenBound) { if (size.Width <= 0 || size.Height <= 0) { throw new ArgumentException("Surface dimensions must be greater than zero."); } Size = size; IsScreenBound = isScreenBound; SurfaceType = surfaceType; // Keep highest supported MSAA level. Multisample = Calc.Min(multisample, GraphicsAdapter.SurfaceFactory.MaxSupportedMultisampleQuality); if (Multisample != multisample) { Log.Warning($"Requested MSAA level '{multisample}' was not supported on this device."); } if (!IsScreenBound) { // Surface is an offscreen render target Native = GraphicsAdapter.SurfaceFactory.Create(this); Multisample = multisample; } else { if (SurfaceType != SurfaceType.UnsignedByte) { throw new ArgumentException($"Screen bound surfaces must be have type '{nameof(SurfaceType.UnsignedByte)}'."); } } }
public HeirloomSurfaceView(Activity context, IntSize resolution, MultisampleQuality multisample = MultisampleQuality.None) : base(context) { // Holder.AddCallback(this); Holder.SetFixedSize(resolution.Width, resolution.Height); Holder.SetFormat(Format.Rgb888); Console.WriteLine($"[EGL] Creating OpenGL ES 3.0 Context"); // Find best configuration for 24 bit color no depth var config = Egl.ChooseConfig(new EglConfigAttributes { RedBits = 8, GreenBits = 8, BlueBits = 8, AlphaBits = 0, DepthBits = 0, StencilBits = 0, Samples = 0 }); // Create OpenGL ES 3.0 Context & Surface EglContext = Egl.CreateContext(config); // Create render context, and set to initial size _renderContext = new AndroidRenderContext(this, multisample); _renderContext.SetDefaultSurfaceSize(resolution); }
protected GameContext(Window window, MultisampleQuality multisample) { _entities = new List <Entity>(); Window = window ?? throw new ArgumentNullException(nameof(window)); Renderer = new Renderer(multisample); Loop = GameLoop.Create(Window.Graphics, OnUpdate); }
public Renderer(MultisampleQuality multisample) { Multisample = multisample; EffectLayers = new List <EffectLayer>() { // Always have a "do nothing layer" to render anything at all new EffectLayer(int.MaxValue, SurfaceEffect.None) }; }
private static Queue <Surface> GetPool(IntSize size, MultisampleQuality multisample) { var key = (multisample, size); if (_pools.TryGetValue(key, out var pool)) { // Return already known pool return(pool); } else { // Construct pool _pools[key] = new Queue <Surface>(); return(_pools[key]); } }
/// <summary> /// Requests a temporary surface. /// </summary> /// <param name="size">The size of the surface.</param> /// <param name="multisample">The multisample quality of the surface.</param> /// <returns>A surface owned by this pool.</returns> public static Surface Request(IntSize size, MultisampleQuality multisample = MultisampleQuality.None) { // Get the associated pool the specified multisample level var pool = GetPool(size, multisample); lock (pool) { if (pool.Count > 0) { // Return an existing surface return(pool.Dequeue()); } } // The pool did not return a surface... lock (_owned) { // Construct a new surface and return it. var surface = new Surface(size, multisample); _owned.Add(surface); return(surface); } }
internal AndroidRenderContext(HeirloomSurfaceView surfaceView, MultisampleQuality multisample) : base(multisample) { SurfaceView = surfaceView; }
/// <summary> /// Requests a temporary surface. /// </summary> /// <param name="width">The width of the surface.</param> /// <param name="height">The height of the surface.</param> /// <param name="multisample">The multisample quality of the surface.</param> /// <returns>A surface owned by this pool.</returns> public static Surface Request(int width, int height, MultisampleQuality multisample = MultisampleQuality.None) { return(Request(new IntSize(width, height), multisample)); }
/// <summary> /// Creates a new surface. /// </summary> /// <param name="size">Size of the surface in pixels.</param> /// <param name="multisample">MSAA to use on the surface</param> /// <param name="surfaceType">The storage format of the surface.</param> public Surface(IntSize size, MultisampleQuality multisample = MultisampleQuality.None, SurfaceType surfaceType = SurfaceType.UnsignedByte) : this(size, multisample, surfaceType, false) { }
/// <summary> /// Creates a new surface. /// </summary> /// <param name="width">Width of the surface in pixels.</param> /// <param name="height">Height of the surface in pixels.</param> /// <param name="multisample">MSAA to use on the surface</param> /// <param name="surfaceType">The storage format of the surface.</param> public Surface(int width, int height, MultisampleQuality multisample = MultisampleQuality.None, SurfaceType surfaceType = SurfaceType.UnsignedByte) : this(new IntSize(width, height), multisample, surfaceType) { }
public HeirloomSurfaceView(Activity activity, MultisampleQuality multisample = MultisampleQuality.None) : this(activity, AndroidHelper.ComputeAutomaticResolution(activity), multisample) { }
/// <summary> /// Constructs a new window. /// </summary> /// <param name="title">The text in the titlebar of the window.</param> /// <param name="multisample">What level of MSAA to use.</param> /// <param name="vsync">Enable VSync on this window.</param> /// <param name="transparent">Enable transparent framebuffer (if OS supports it).</param> public Window(string title, MultisampleQuality multisample = MultisampleQuality.None, bool vsync = true, bool transparent = false) : this(title, (512, 512), multisample, vsync, transparent)
protected DesktopGameContext(string title, MultisampleQuality multisample) : this(new Window(title, multisample)) { }