mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/graphicsdriver/playstation5: add DrawTriangles
This commit is contained in:
parent
6555375b06
commit
aba652c323
@ -18,24 +18,28 @@
|
|||||||
|
|
||||||
#include "graphics_playstation5.h"
|
#include "graphics_playstation5.h"
|
||||||
|
|
||||||
extern "C" ebitengine_Error ebitengine_InitializeGraphics(void) {
|
extern "C" ebitengine_Error ebitengine_InitializeGraphics(void) { return {}; }
|
||||||
|
|
||||||
|
extern "C" ebitengine_Error ebitengine_NewImage(int *image, int width,
|
||||||
|
int height) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" ebitengine_Error ebitengine_NewImage(int* image, int width, int height) {
|
extern "C" ebitengine_Error
|
||||||
|
ebitengine_NewScreenFramebufferImage(int *image, int width, int height) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" ebitengine_Error ebitengine_NewScreenFramebufferImage(int* image, int width, int height) {
|
extern "C" void ebitengine_DisposeImage(int id) {}
|
||||||
|
|
||||||
|
extern "C" ebitengine_Error
|
||||||
|
ebitengine_DrawTriangles(ebitengine_DrawTrianglesArgs *args) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void ebitengine_DisposeImage(int id) {
|
extern "C" ebitengine_Error ebitengine_NewShader(int *shader,
|
||||||
}
|
const char *source) {
|
||||||
|
|
||||||
extern "C" ebitengine_Error ebitengine_NewShader(int* shader, const char* source) {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void ebitengine_DisposeShader(int id) {
|
extern "C" void ebitengine_DisposeShader(int id) {}
|
||||||
}
|
|
||||||
|
@ -21,6 +21,7 @@ import "C"
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||||
@ -117,6 +118,52 @@ func (g *Graphics) NewShader(program *shaderir.Program) (graphicsdriver.Shader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) DrawTriangles(dst graphicsdriver.ImageID, srcs [graphics.ShaderSrcImageCount]graphicsdriver.ImageID, shader graphicsdriver.ShaderID, dstRegions []graphicsdriver.DstRegion, indexOffset int, blend graphicsdriver.Blend, uniforms []uint32, fillRule graphicsdriver.FillRule) error {
|
func (g *Graphics) DrawTriangles(dst graphicsdriver.ImageID, srcs [graphics.ShaderSrcImageCount]graphicsdriver.ImageID, shader graphicsdriver.ShaderID, dstRegions []graphicsdriver.DstRegion, indexOffset int, blend graphicsdriver.Blend, uniforms []uint32, fillRule graphicsdriver.FillRule) error {
|
||||||
|
csrcs := make([]C.int, len(srcs))
|
||||||
|
for i, src := range srcs {
|
||||||
|
csrcs[i] = C.int(src)
|
||||||
|
}
|
||||||
|
cDstRegions := make([]C.ebitengine_DstRegion, len(dstRegions))
|
||||||
|
for i, r := range dstRegions {
|
||||||
|
cDstRegions[i] = C.ebitengine_DstRegion{
|
||||||
|
Region: C.ebitengine_Rectangle{
|
||||||
|
MinX: C.int(r.Region.Min.X),
|
||||||
|
MinY: C.int(r.Region.Min.Y),
|
||||||
|
MaxX: C.int(r.Region.Max.X),
|
||||||
|
MaxY: C.int(r.Region.Max.Y),
|
||||||
|
},
|
||||||
|
IndexCount: C.int(r.IndexCount),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cUniforms := make([]C.uint32_t, len(uniforms))
|
||||||
|
for i, u := range uniforms {
|
||||||
|
cUniforms[i] = C.uint32_t(u)
|
||||||
|
}
|
||||||
|
cBlend := C.ebitengine_Blend{
|
||||||
|
BlendFactorSourceRGB: C.uint8_t(blend.BlendFactorSourceRGB),
|
||||||
|
BlendFactorSourceAlpha: C.uint8_t(blend.BlendFactorSourceAlpha),
|
||||||
|
BlendFactorDestinationRGB: C.uint8_t(blend.BlendFactorDestinationRGB),
|
||||||
|
BlendFactorDestinationAlpha: C.uint8_t(blend.BlendFactorDestinationAlpha),
|
||||||
|
BlendOperationRGB: C.uint8_t(blend.BlendOperationRGB),
|
||||||
|
BlendOperationAlpha: C.uint8_t(blend.BlendOperationAlpha),
|
||||||
|
}
|
||||||
|
|
||||||
|
args := C.ebitengine_DrawTrianglesArgs{
|
||||||
|
Dst: C.int(dst),
|
||||||
|
Srcs: &csrcs[0],
|
||||||
|
SrcCount: C.int(len(csrcs)),
|
||||||
|
Shader: C.int(shader),
|
||||||
|
DstRegions: &cDstRegions[0],
|
||||||
|
DstRegionCount: C.int(len(cDstRegions)),
|
||||||
|
IndexOffset: C.int(indexOffset),
|
||||||
|
Blend: cBlend,
|
||||||
|
Uniforms: &cUniforms[0],
|
||||||
|
UniformCount: C.int(len(cUniforms)),
|
||||||
|
FillRule: C.int(fillRule),
|
||||||
|
}
|
||||||
|
if err := C.ebitengine_DrawTriangles(&args); !C.ebitengine_IsErrorNil(&err) {
|
||||||
|
return newPlaystation5Error("(*playstation5.Graphics).DrawTriangles", err)
|
||||||
|
}
|
||||||
|
runtime.KeepAlive(args)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,26 +19,64 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct ebitengine_Error {
|
typedef struct ebitengine_Error {
|
||||||
const char* Message;
|
const char *Message;
|
||||||
int Code;
|
int Code;
|
||||||
} ebitengine_Error;
|
} ebitengine_Error;
|
||||||
|
|
||||||
static bool ebitengine_IsErrorNil(ebitengine_Error* err) {
|
static bool ebitengine_IsErrorNil(ebitengine_Error *err) {
|
||||||
return err->Message == NULL && err->Code == 0;
|
return err->Message == NULL && err->Code == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ebitengine_Error ebitengine_InitializeGraphics(void);
|
typedef struct ebitengine_Rectangle {
|
||||||
ebitengine_Error ebitengine_NewImage(int* image, int width, int height);
|
int MinX;
|
||||||
ebitengine_Error ebitengine_NewScreenFramebufferImage(int* image, int width, int height);
|
int MinY;
|
||||||
void ebitengine_DisposeImage(int id);
|
int MaxX;
|
||||||
|
int MaxY;
|
||||||
|
} ebitengine_Rectangle;
|
||||||
|
|
||||||
ebitengine_Error ebitengine_NewShader(int* shader, const char* source);
|
typedef struct ebitengine_DstRegion {
|
||||||
|
ebitengine_Rectangle Region;
|
||||||
|
int IndexCount;
|
||||||
|
} ebitengine_DstRegion;
|
||||||
|
|
||||||
|
typedef struct ebitengine_Blend {
|
||||||
|
uint8_t BlendFactorSourceRGB;
|
||||||
|
uint8_t BlendFactorSourceAlpha;
|
||||||
|
uint8_t BlendFactorDestinationRGB;
|
||||||
|
uint8_t BlendFactorDestinationAlpha;
|
||||||
|
uint8_t BlendOperationRGB;
|
||||||
|
uint8_t BlendOperationAlpha;
|
||||||
|
} ebitengine_Blend;
|
||||||
|
|
||||||
|
typedef struct ebitengine_DrawTrianglesArgs {
|
||||||
|
int Dst;
|
||||||
|
int *Srcs;
|
||||||
|
int SrcCount;
|
||||||
|
int Shader;
|
||||||
|
ebitengine_DstRegion *DstRegions;
|
||||||
|
int DstRegionCount;
|
||||||
|
int IndexOffset;
|
||||||
|
ebitengine_Blend Blend;
|
||||||
|
uint32_t *Uniforms;
|
||||||
|
int UniformCount;
|
||||||
|
int FillRule;
|
||||||
|
} ebitengine_DrawTrianglesArgs;
|
||||||
|
|
||||||
|
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);
|
||||||
|
void ebitengine_DisposeImage(int id);
|
||||||
|
ebitengine_Error ebitengine_DrawTriangles(ebitengine_DrawTrianglesArgs *args);
|
||||||
|
|
||||||
|
ebitengine_Error ebitengine_NewShader(int *shader, const char *source);
|
||||||
void ebitengine_DisposeShader(int id);
|
void ebitengine_DisposeShader(int id);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Loading…
Reference in New Issue
Block a user