Skip to content

Commit 48cbef8

Browse files
committed
Update video.go error handling, add SetError() and INIT_EVENTS
1 parent 1efc02d commit 48cbef8

File tree

5 files changed

+280
-264
lines changed

5 files changed

+280
-264
lines changed

BREAKING.md

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
+ `GetCurrentVideoDriver()` returns (string, error) instead of string
6262
+ `Window.Destroy()` returns error
6363
+ `Window.GetID()` returns (uint32, error) instead of uint32
64+
+ `GetNumRenderDrivers()` returns (int, error) instead of int
65+
+ `GetRenderDriverInfo()` returns (int, error) instead of int
66+
+ `Texture.Destroy()` returns error
67+
+ `Renderer.Destroy()` returns error
6468

6569
- Unexported `Padding` in `AudioSpec` struct
6670
- Unexported `goHintCallback`

sdl/error.go

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package sdl
22

3+
/*
4+
#include "sdl_wrapper.h"
5+
6+
void GoSetError(const char *fmt) {
7+
SDL_SetError("%s", fmt);
8+
}
9+
*/
310
// #include "sdl_wrapper.h"
411
import "C"
512
import "errors"
@@ -35,6 +42,16 @@ func GetError() error {
3542
return nil
3643
}
3744

45+
// SetError set the SDL error message.
46+
// (https://wiki.libsdl.org/SDL_SetError)
47+
func SetError(err error) {
48+
if err != nil {
49+
C.GoSetError(C.CString(err.Error()))
50+
return
51+
}
52+
C.GoSetError(nil)
53+
}
54+
3855
// ClearError clears any previous error message.
3956
// (https://wiki.libsdl.org/SDL_ClearError)
4057
func ClearError() {

0 commit comments

Comments
 (0)