Add GeometryQueue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c
index af81021..2a969a4 100644
--- a/src/render/ps2/SDL_render_ps2.c
+++ b/src/render/ps2/SDL_render_ps2.c
@@ -34,6 +34,20 @@
/* turn black GS Screen */
#define GS_BLACK GS_SETREG_RGBA(0x00, 0x00, 0x00, 0x80)
+typedef struct texture_vertex {
+ float x;
+ float y;
+ float u;
+ float v;
+ SDL_Color color;
+} texture_vertex;
+
+typedef struct color_vertex {
+ float x;
+ float y;
+ SDL_Color color;
+} color_vertex;
+
typedef struct
{
GSGLOBAL *gsGlobal;
@@ -104,8 +118,6 @@ PS2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
static int
PS2_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
- int bpp;
- Uint32 Rmask, Gmask, Bmask, Amask;
GSTEXTURE* ps2_tex = (GSTEXTURE*) SDL_calloc(1, sizeof(GSTEXTURE));
PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata;
@@ -206,9 +218,99 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y)
{
+ PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata;
+ int i;
+ int count = indices ? num_indices : num_vertices;
+
+ cmd->data.draw.count = count;
+ size_indices = indices ? size_indices : 0;
+
+ if (texture) {
+ GSTEXTURE* ps2_tex = (GSTEXTURE*) texture->driverdata;
+ texture_vertex *vertices;
+
+ vertices = (texture_vertex *)SDL_AllocateRenderVertices(renderer,
+ count * sizeof(texture_vertex),
+ 4,
+ &cmd->data.draw.first);
+
+ if (!vertices) {
+ return -1;
+ }
+
+
+ for (i = 0; i < count; i++) {
+ int j;
+ float *xy_;
+ float *uv_;
+ SDL_Color col_;
+ if (size_indices == 4) {
+ j = ((const Uint32 *)indices)[i];
+ } else if (size_indices == 2) {
+ j = ((const Uint16 *)indices)[i];
+ } else if (size_indices == 1) {
+ j = ((const Uint8 *)indices)[i];
+ } else {
+ j = i;
+ }
+
+ xy_ = (float *)((char*)xy + j * xy_stride);
+ col_ = *(SDL_Color *)((char*)color + j * color_stride);
+ uv_ = (float *)((char*)uv + j * uv_stride);
+
+ vertices[i].x = xy_[0] * scale_x;
+ vertices[i].y = xy_[1] * scale_y;
+ vertices[i].u = uv_[0];
+ vertices[i].v = uv_[1];
+ vertices[i].color = col_;
+
+ vertices++;
+ }
+
+ } else {
+ color_vertex *vertices;
+
+ vertices = (color_vertex *)SDL_AllocateRenderVertices(renderer,
+ count * sizeof(color_vertex),
+ 4,
+ &cmd->data.draw.first);
+
+ if (!vertices) {
+ return -1;
+ }
+
+
+ for (i = 0; i < count; i++) {
+ int j;
+ float *xy_;
+ SDL_Color col_;
+ if (size_indices == 4) {
+ j = ((const Uint32 *)indices)[i];
+ } else if (size_indices == 2) {
+ j = ((const Uint16 *)indices)[i];
+ } else if (size_indices == 1) {
+ j = ((const Uint8 *)indices)[i];
+ } else {
+ j = i;
+ }
+
+ xy_ = (float *)((char*)xy + j * xy_stride);
+ col_ = *(SDL_Color *)((char*)color + j * color_stride);
+
+ vertices[i].x = xy_[0] * scale_x;
+ vertices[i].y = xy_[1] * scale_y;
+ vertices[i].color = col_;
+
+ vertices++;
+ }
+
+ }
+
return 0;
+
}
+
static int
PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
{