diff --git a/internal/graphicsdriver/playstation5/graphics_playstation5.go b/internal/graphicsdriver/playstation5/graphics_playstation5.go index a4ff51f2b..a9bc03279 100644 --- a/internal/graphicsdriver/playstation5/graphics_playstation5.go +++ b/internal/graphicsdriver/playstation5/graphics_playstation5.go @@ -53,7 +53,7 @@ func NewGraphics() (*Graphics, error) { } func (g *Graphics) Initialize() error { - if err := C.ebitengine_InitializeGraphics(); err.message != nil { + if err := C.ebitengine_InitializeGraphics(); !C.ebitengine_IsErrorNil(&err) { return newPlaystation5Error("(*playstation5.Graphics).Initialize", err) } return nil @@ -76,7 +76,7 @@ func (g *Graphics) SetVertices(vertices []float32, indices []uint32) error { func (g *Graphics) NewImage(width, height int) (graphicsdriver.Image, error) { var id C.int - if err := C.ebitengine_NewImage(&id, C.int(width), C.int(height)); err.message != nil { + if err := C.ebitengine_NewImage(&id, C.int(width), C.int(height)); !C.ebitengine_IsErrorNil(&err) { return nil, newPlaystation5Error("(*playstation5.Graphics).NewImage", err) } return &Image{ @@ -86,7 +86,7 @@ func (g *Graphics) NewImage(width, height int) (graphicsdriver.Image, error) { func (g *Graphics) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) { var id C.int - if err := C.ebitengine_NewScreenFramebufferImage(&id, C.int(width), C.int(height)); err.message != nil { + if err := C.ebitengine_NewScreenFramebufferImage(&id, C.int(width), C.int(height)); !C.ebitengine_IsErrorNil(&err) { return nil, newPlaystation5Error("(*playstation5.Graphics).NewScreenFramebufferImage", err) } return &Image{ @@ -108,7 +108,7 @@ func (g *Graphics) MaxImageSize() int { func (g *Graphics) NewShader(program *shaderir.Program) (graphicsdriver.Shader, error) { var id C.int // TODO: Give a source code. - if err := C.ebitengine_NewShader(&id, nil); err.message != nil { + if err := C.ebitengine_NewShader(&id, nil); !C.ebitengine_IsErrorNil(&err) { return nil, newPlaystation5Error("(*playstation5.Graphics).NewShader", err) } return &Shader{ diff --git a/internal/graphicsdriver/playstation5/graphics_playstation5.h b/internal/graphicsdriver/playstation5/graphics_playstation5.h index 40f1e8326..2a307a3c8 100644 --- a/internal/graphicsdriver/playstation5/graphics_playstation5.h +++ b/internal/graphicsdriver/playstation5/graphics_playstation5.h @@ -14,6 +14,8 @@ //go:build playstation5 +#include + #ifdef __cplusplus extern "C" { #endif @@ -23,6 +25,10 @@ typedef struct ebitengine_Error { int code; } ebitengine_Error; +bool ebitengine_IsErrorNil(ebitengine_Error* err) { + return err->message == NULL && err->code == 0; +} + ebitengine_Error ebitengine_InitializeGraphics(void); ebitengine_Error ebitengine_NewImage(int* image, int width, int height); ebitengine_Error ebitengine_NewScreenFramebufferImage(int* image, int width, int height);