|
| 1 | +using Silk.NET.Maths; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// The OpenGL component of a <see cref="Surface" />. The <see cref="IGLContext" /> methods can only be executed once |
| 5 | +/// <see cref="ISurfaceApplication.Initialize{TSurface}" /> has executed. |
| 6 | +/// </summary> |
| 7 | +/// <remarks> |
| 8 | +/// These objects may be shared with child windows created using <see cref="ISurfaceChildren" /> and vice versa i.e. |
| 9 | +/// this object can be shared between all surfaces that share a common ancestor (the "root surface"). Beyond that, these |
| 10 | +/// objects are not guaranteed to be valid across surfaces. This allows one event handler to enact changes on multiple |
| 11 | +/// surfaces. This is important for <see cref="SharedContext" /> purposes. |
| 12 | +/// </remarks> |
| 13 | +public interface ISurfaceOpenGL : IGLContext |
| 14 | +{ |
| 15 | + /// <summary> |
| 16 | + /// Gets or sets a value indicating whether OpenGL support is enabled for this surface. Setting |
| 17 | + /// <see cref="Profile" /> to a value other than <see cref="OpenGLContextProfile.None" /> will automatically set |
| 18 | + /// this property to <c>true</c>, and likewise toggling the value assigned to this property will change the value of |
| 19 | + /// <see cref="Profile" />. |
| 20 | + /// </summary> |
| 21 | + /// <remarks> |
| 22 | + /// This can only be set during the <see cref="ISurfaceApplication.Initialize{TSurface}" /> method. |
| 23 | + /// </remarks> |
| 24 | + // Included for consistency with Vulkan. |
| 25 | + bool IsEnabled |
| 26 | + { |
| 27 | + get => Profile != OpenGLContextProfile.None; |
| 28 | + set => |
| 29 | + Profile = value |
| 30 | + ? Profile == OpenGLContextProfile.None |
| 31 | + ? OpenGLContextProfile.Default |
| 32 | + : Profile |
| 33 | + : OpenGLContextProfile.None; |
| 34 | + } |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// Preferred depth buffer bits of the window's framebuffer. |
| 38 | + /// </summary> |
| 39 | + /// <remarks> |
| 40 | + /// Pass <c>null</c> or <c>-1</c> to use the system default. |
| 41 | + /// This can only be set during the <see cref="ISurfaceApplication.Initialize{TSurface}" /> method. |
| 42 | + /// Setting this property will automatically set <see cref="Profile" /> to |
| 43 | + /// <see cref="OpenGLContextProfile.Default" /> if it is currently <see cref="OpenGLContextProfile.None" />. |
| 44 | + /// </remarks> |
| 45 | + int? PreferredDepthBufferBits { get; set; } |
| 46 | + |
| 47 | + /// <summary> |
| 48 | + /// Preferred stencil buffer bits of the window's framebuffer. |
| 49 | + /// </summary> |
| 50 | + /// <remarks> |
| 51 | + /// Pass <c>null</c> or <c>-1</c> to use the system default. |
| 52 | + /// </remarks> |
| 53 | + int? PreferredStencilBufferBits { get; set; } |
| 54 | + |
| 55 | + /// <summary> |
| 56 | + /// Preferred red, green, blue, and alpha bits of the window's framebuffer. |
| 57 | + /// </summary> |
| 58 | + /// <remarks> |
| 59 | + /// Pass <c>null</c> or <c>-1</c> for any of the channels to use the system default. |
| 60 | + /// </remarks> |
| 61 | + Vector4D<int>? PreferredBitDepth { get; set; } |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// Preferred number of samples for multi-sample anti-aliasing. |
| 65 | + /// </summary> |
| 66 | + /// <remarks> |
| 67 | + /// This can only be set during the <see cref="ISurfaceApplication.Initialize{TSurface}" /> method. |
| 68 | + /// </remarks> |
| 69 | + int? PreferredSampleCount { get; set; } |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// The API version to use. |
| 73 | + /// </summary> |
| 74 | + /// <remarks> |
| 75 | + /// This can only be set during the <see cref="ISurfaceApplication.Initialize{TSurface}" /> method. |
| 76 | + /// </remarks> |
| 77 | + Version32? Version { get; set; } |
| 78 | + |
| 79 | + /// <summary> |
| 80 | + /// Flags used to create the OpenGL context. |
| 81 | + /// </summary> |
| 82 | + /// <remarks> |
| 83 | + /// This can only be set during the <see cref="ISurfaceApplication.Initialize{TSurface}" /> method. |
| 84 | + /// </remarks> |
| 85 | + OpenGLContextFlags Flags { get; set; } |
| 86 | + |
| 87 | + /// <summary> |
| 88 | + /// The profile the OpenGL context should use. If <see cref="OpenGLContextProfile.None" /> is used, the OpenGL |
| 89 | + /// component is effectively disabled, allowing for other graphics APIs/components to be used. If any of the other |
| 90 | + /// properties on this class are set while this property is <see cref="OpenGLContextProfile.None" />, this property |
| 91 | + /// shall automatically be populated with the value <see cref="OpenGLContextProfile.Default" />. |
| 92 | + /// </summary> |
| 93 | + /// <remarks> |
| 94 | + /// This can only be set during the <see cref="ISurfaceApplication.Initialize{TSurface}" /> method. If the value is |
| 95 | + /// <see cref="OpenGLContextProfile.Default" />, this shall be replaced with the actual value upon exit from |
| 96 | + /// <see cref="ISurfaceApplication.Initialize{TSurface}" />. |
| 97 | + /// </remarks> |
| 98 | + OpenGLContextProfile Profile { get; set; } |
| 99 | + |
| 100 | + /// <summary> |
| 101 | + /// Gets a value indicating whether the current configuration is supported (e.g. version number). If |
| 102 | + /// <see cref="Profile" /> is not <see cref="OpenGLContextProfile.None" /> and this property is <c>true</c>, the |
| 103 | + /// OpenGL context shall be created and accessible upon exit from |
| 104 | + /// <see cref="ISurfaceApplication.Initialize{TSurface}" />. |
| 105 | + /// </summary> |
| 106 | + bool IsSupported { get; } |
| 107 | + |
| 108 | + /// <summary> |
| 109 | + /// Gets or sets a value indicating whether the platform should automatically <see cref="IGLContext.SwapBuffers" /> |
| 110 | + /// after <see cref="Surface.Render" />. Defaults to <c>true</c>. |
| 111 | + /// </summary> |
| 112 | + /// <remarks> |
| 113 | + /// This can be set at any point throughout the surface's execution. |
| 114 | + /// </remarks> |
| 115 | + bool ShouldSwapAutomatically { get; set; } |
| 116 | + |
| 117 | + /// <summary> |
| 118 | + /// Gets or sets the context with which this context should share resources. |
| 119 | + /// </summary> |
| 120 | + /// <remarks> |
| 121 | + /// This can only be set during the <see cref="ISurfaceApplication.Initialize{TSurface}" /> method. |
| 122 | + /// </remarks> |
| 123 | + IGLContext? SharedContext { get; set; } |
| 124 | +} |
0 commit comments