mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/graphicsdriver/playstation5: add ebitengine_IsErrorNil
This commit is contained in:
parent
e0ccd013ac
commit
f0509096f8
@ -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{
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
//go:build playstation5
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#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);
|
||||
|
Loading…
Reference in New Issue
Block a user