Skip to content

Commit

Permalink
work on rsoft backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Dec 23, 2024
1 parent 7df550f commit 640e5e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 35 deletions.
27 changes: 17 additions & 10 deletions examples/advanced/RSGL_rsoft.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void RSGL_renderBatch(RSGL_RENDER_INFO* info) {

switch (mode) {
case RSGL_TRIANGLES:
for (j = info->batches[i].start + 3; j < info->batches[i].len - 3; j += 3) {
for (j = info->batches[i].start; j < info->batches[i].len ; j += 3) {
// info->texCoords[tIndex], info->texCoords[tIndex + 1]
RSoft_vector npoints[3] = {
RSOFT_VECTOR3D(info->verts[vIndex], info->verts[vIndex + 1], info->verts[vIndex + 2]),
Expand All @@ -67,9 +67,9 @@ void RSGL_renderBatch(RSGL_RENDER_INFO* info) {
};
u8 color[4] = {info->colors[cIndex] * 255, info->colors[cIndex + 1] * 255,
info->colors[cIndex + 2] * 255, info->colors[cIndex + 3] * 255};

RSoft_drawTriangleF(RSGL_rsoft.buffer, npoints, color);

tIndex += 6;
vIndex += 9;
cIndex += 12;
Expand All @@ -92,17 +92,24 @@ void RSGL_renderBatch(RSGL_RENDER_INFO* info) {
}
break;
case RSGL_TRIANGLE_FAN:
size_t start = vIndex + 3;
for (j = info->batches[i].start; j < info->batches[i].len; j += 3) {
// info->texCoords[tIndex], info->texCoords[tIndex + 1]
RSoft_vector npoints[3] = {
RSOFT_VECTOR3D(info->verts[vIndex], info->verts[vIndex + 1], info->verts[vIndex + 2]),
RSOFT_VECTOR3D(info->verts[vIndex + 3], info->verts[vIndex + 4], info->verts[vIndex + 5]),
RSOFT_VECTOR3D(info->verts[vIndex + 6], info->verts[vIndex + 7], info->verts[vIndex + 8])
};
RSOFT_VECTOR3D(300, 300, info->verts[start + 2]),
RSOFT_VECTOR3D(info->verts[vIndex], info->verts[vIndex + 1], info->verts[vIndex + 2]),
RSOFT_VECTOR3D(info->verts[vIndex + 3], info->verts[vIndex + 4], info->verts[vIndex + 5])
};

u8 color[4] = {info->colors[cIndex] * 255, info->colors[cIndex + 1] * 255,
info->colors[cIndex + 2] * 255, info->colors[cIndex + 3] * 255};

RSoft_drawTriangleOutlineF(RSGL_rsoft.buffer, npoints, color);
info->colors[cIndex + 2] * 255, info->colors[cIndex + 3] * 255};

/*printf("{%f %f %f}, {%f %f %f}, {%f %f %f}\n",
info->verts[vIndex], info->verts[vIndex + 1], info->verts[vIndex + 2],
info->verts[vIndex + 3], info->verts[vIndex + 4], info->verts[vIndex + 5],
info->verts[vIndex + 6], info->verts[vIndex + 7], info->verts[vIndex + 8]);*/

RSoft_drawTriangleF(RSGL_rsoft.buffer, npoints, color);

tIndex += 6;
vIndex += 9;
Expand Down
28 changes: 3 additions & 25 deletions examples/advanced/rsoft.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,10 @@ int main(void) {
}

rotate.z += 1;

RSGL_rotate(rotate);
RSGL_drawRect(RSGL_RECT(200, 200, 200, 200), RSGL_RGB(255, 0, 0));

//RSGL_setTexture(iconTex);
//RSGL_rotate(rotate);
//RSGL_drawPolygon(RSGL_RECT(20, 20, 50, 50), 8, RSGL_RGB(255, 255, 255));

RSGL_setTexture(texture);

if (texTimer2 && texTimer2 + 5 > (size_t)time(0))
RSGL_setTexture(0);
else if (texTimer2 && texTimer2 + 5 <= (size_t)time(0)) {
texTimer = (size_t)time(0);
texTimer2 = 0;
}

else if (texTimer2 == 0 && texTimer + 5 <= (size_t)time(0)) {
texTimer2 = (size_t)time(0);

RSGL_setTexture(0);
}

RSGL_rotate(rotate);
RSGL_drawTriangle(RSGL_TRIANGLE(RSGL_POINT(0, 500), RSGL_POINT(200, 500), RSGL_POINT(100, 250)), RSGL_RGB(255, 255, 255));

//RSGL_rotate(rotate);
//RSGL_drawTriangle(RSGL_TRIANGLE(RSGL_POINT(0, 500), RSGL_POINT(200, 500), RSGL_POINT(100, 250)), RSGL_RGB(255, 255, 255));
RSGL_drawPolygon(RSGL_RECT(200, 200, 200, 200), 360, RSGL_RGB(0, 255, 0));

RSGL_clear(RSGL_RGB(65, 65, 65));
RGFW_window_swapBuffers(win);
Expand Down

0 comments on commit 640e5e0

Please sign in to comment.