@@ -33,12 +33,12 @@ public SDL3GraphicsSurface(SDL3Window window, GraphicsSurfaceType surfaceType)
3333 switch ( surfaceType )
3434 {
3535 case GraphicsSurfaceType . OpenGL :
36- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_RED_SIZE , 8 ) ;
37- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_GREEN_SIZE , 8 ) ;
38- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_BLUE_SIZE , 8 ) ;
39- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_ACCUM_ALPHA_SIZE , 0 ) ;
40- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_DEPTH_SIZE , 16 ) ;
41- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_STENCIL_SIZE , 8 ) ;
36+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_RED_SIZE , 8 ) . ThrowIfFailed ( ) ;
37+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_GREEN_SIZE , 8 ) . ThrowIfFailed ( ) ;
38+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_BLUE_SIZE , 8 ) . ThrowIfFailed ( ) ;
39+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_ACCUM_ALPHA_SIZE , 0 ) . ThrowIfFailed ( ) ;
40+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_DEPTH_SIZE , 16 ) . ThrowIfFailed ( ) ;
41+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_STENCIL_SIZE , 8 ) . ThrowIfFailed ( ) ;
4242 break ;
4343
4444 case GraphicsSurfaceType . Vulkan :
@@ -60,7 +60,7 @@ public void Initialise()
6060 public Size GetDrawableSize ( )
6161 {
6262 int width , height ;
63- SDL_GetWindowSizeInPixels ( window . SDLWindowHandle , & width , & height ) ;
63+ SDL_GetWindowSizeInPixels ( window . SDLWindowHandle , & width , & height ) . ThrowIfFailed ( ) ;
6464 return new Size ( width , height ) ;
6565 }
6666
@@ -70,27 +70,27 @@ private void initialiseOpenGL()
7070 {
7171 if ( RuntimeInfo . IsMobile )
7272 {
73- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_PROFILE_MASK , ( int ) SDL_GLProfile . SDL_GL_CONTEXT_PROFILE_ES ) ;
73+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_PROFILE_MASK , ( int ) SDL_GLProfile . SDL_GL_CONTEXT_PROFILE_ES ) . ThrowIfFailed ( ) ;
7474
7575 // Minimum OpenGL version for ES profile:
76- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_MAJOR_VERSION , 3 ) ;
77- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_MINOR_VERSION , 0 ) ;
76+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_MAJOR_VERSION , 3 ) . ThrowIfFailed ( ) ;
77+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_MINOR_VERSION , 0 ) . ThrowIfFailed ( ) ;
7878 }
7979 else
8080 {
81- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_PROFILE_MASK , ( int ) SDL_GLProfile . SDL_GL_CONTEXT_PROFILE_CORE ) ;
81+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_PROFILE_MASK , ( int ) SDL_GLProfile . SDL_GL_CONTEXT_PROFILE_CORE ) . ThrowIfFailed ( ) ;
8282
8383 // Minimum OpenGL version for core profile:
84- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_MAJOR_VERSION , 3 ) ;
85- SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_MINOR_VERSION , 2 ) ;
84+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_MAJOR_VERSION , 3 ) . ThrowIfFailed ( ) ;
85+ SDL_GL_SetAttribute ( SDL_GLAttr . SDL_GL_CONTEXT_MINOR_VERSION , 2 ) . ThrowIfFailed ( ) ;
8686 }
8787
8888 context = SDL_GL_CreateContext ( window . SDLWindowHandle ) ;
8989
9090 if ( context == null )
9191 throw new InvalidOperationException ( $ "Failed to create an SDL3 GL context ({ SDL_GetError ( ) } )") ;
9292
93- SDL_GL_MakeCurrent ( window . SDLWindowHandle , context ) ;
93+ SDL_GL_MakeCurrent ( window . SDLWindowHandle , context ) . ThrowIfFailed ( ) ;
9494
9595 loadBindings ( ) ;
9696 }
@@ -126,29 +126,13 @@ private void loadEntryPoints(GraphicsBindingsBase bindings)
126126 string ? str = Marshal . PtrToStringAnsi ( new IntPtr ( ptr ) ) ;
127127
128128 Debug . Assert ( str != null ) ;
129- entryPointsInstance [ i ] = getProcAddress ( str ) ;
129+ entryPointsInstance [ i ] = SDL_GL_GetProcAddress ( str ) ;
130130 }
131131 }
132132
133133 pointsInfo . SetValue ( bindings , entryPointsInstance ) ;
134134 }
135135
136- private IntPtr getProcAddress ( string symbol )
137- {
138- const SDL_LogCategory error_category = SDL_LogCategory . SDL_LOG_CATEGORY_ERROR ;
139- SDL_LogPriority oldPriority = SDL_GetLogPriority ( error_category ) ;
140-
141- // Prevent logging calls to SDL_GL_GetProcAddress() that fail on systems which don't have the requested symbol (typically macOS).
142- SDL_SetLogPriority ( error_category , SDL_LogPriority . SDL_LOG_PRIORITY_INFO ) ;
143-
144- IntPtr ret = SDL_GL_GetProcAddress ( symbol ) ;
145-
146- // Reset the logging behaviour.
147- SDL_SetLogPriority ( error_category , oldPriority ) ;
148-
149- return ret ;
150- }
151-
152136 int ? IOpenGLGraphicsSurface . BackbufferFramebuffer
153137 {
154138 get
@@ -195,7 +179,7 @@ bool IOpenGLGraphicsSurface.VerticalSync
195179 void IOpenGLGraphicsSurface . DeleteContext ( IntPtr context ) => SDL_GL_DestroyContext ( ( SDL_GLContextState * ) context ) ;
196180 void IOpenGLGraphicsSurface . MakeCurrent ( IntPtr context ) => SDL_GL_MakeCurrent ( window . SDLWindowHandle , ( SDL_GLContextState * ) context ) ;
197181 void IOpenGLGraphicsSurface . ClearCurrent ( ) => SDL_GL_MakeCurrent ( window . SDLWindowHandle , null ) ;
198- IntPtr IOpenGLGraphicsSurface . GetProcAddress ( string symbol ) => getProcAddress ( symbol ) ;
182+ IntPtr IOpenGLGraphicsSurface . GetProcAddress ( string symbol ) => SDL_GL_GetProcAddress ( symbol ) ;
199183
200184 #endregion
201185
@@ -217,7 +201,7 @@ bool IOpenGLGraphicsSurface.VerticalSync
217201 #region Android-specific implementation
218202
219203 [ SupportedOSPlatform ( "android" ) ]
220- IntPtr IAndroidGraphicsSurface . JniEnvHandle => SDL_GetAndroidJNIEnv ( ) ;
204+ IntPtr IAndroidGraphicsSurface . JniEnvHandle => SDL_GetAndroidJNIEnv ( ) . ThrowIfFailed ( ) ;
221205
222206 [ SupportedOSPlatform ( "android" ) ]
223207 IntPtr IAndroidGraphicsSurface . SurfaceHandle => window . SurfaceHandle ;
0 commit comments