Skip to content

Commit

Permalink
update RSGL
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Jan 1, 2025
1 parent 0d4da33 commit 3833f93
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 16 deletions.
11 changes: 11 additions & 0 deletions examples/advanced/RSGL_rsoft.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ void RSGL_renderBatch(RSGL_RENDER_INFO* info) {
info->vert_len = 0;
}

void RSGL_renderScissorStart(RSGL_rectF scissor) {
RSGL_draw();

// TODO
}

void RSGL_renderScissorEnd(void) {
RSGL_draw();
// TODO
}

/* textures / images */
RSGL_texture RSGL_renderCreateTexture(u8* bitmap, RSGL_area memsize, u8 channels) {
RSGL_rsoft_texture* tex = (RSGL_rsoft_texture*)RSGL_MALLOC(sizeof(RSGL_rsoft_texture));
Expand Down
5 changes: 3 additions & 2 deletions examples/advanced/glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ int main(void)
glfwPollEvents();

RSGL_setFont(comicSans);
RSGL_clear(RSGL_RGB(20, 20, 60));
RSGL_drawText("Hello, GLFW!", RSGL_CIRCLE(100, 100, 20), RSGL_RGB(255, 255, 255));

RSGL_drawRect((RSGL_rect){200, 200, 200, 200}, RSGL_RGB(255, 0, 0));
RSGL_clear(RSGL_RGB(20, 20, 60));

RSGL_draw();
glfwSwapBuffers(window);
}

Expand Down
5 changes: 3 additions & 2 deletions examples/advanced/rsoft.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ int main(void) {
break;
}

RSGL_clear(RSGL_RGB(65, 65, 65));
rotate.z += 1;

RSGL_rotate(rotate);
Expand All @@ -44,8 +45,8 @@ int main(void) {
//RSGL_drawPolygon(RSGL_RECT(200, 200, 200, 200), 360, RSGL_RGB(0, 255, 0));

//RSGL_drawText("Hello, RSOFT!", RSGL_CIRCLE(100, 20, 20), RSGL_RGB(255, 255, 255));

RSGL_clear(RSGL_RGB(65, 65, 65));
RSGL_draw();
RGFW_window_swapBuffers(win);

RGFW_window_checkFPS(win, 60);
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ int main(void) {
if (window->event.type == RGFW_quit) break;
}

RSGL_clear(RSGL_RGB(20, 20, 20));
RSGL_setProgram(0);
RSGL_drawRect(RSGL_RECT(100, 200, 200, 200), RSGL_RGB(255, 0, 0));

Expand All @@ -78,8 +79,7 @@ int main(void) {
RSGL_renderSetShaderValue(program.program, "u_mouse", (float[3]){RSGL_GET_WORLD_POINT((float)window->event.point.x, (float)window->event.point.y, 0)}, 2);
RSGL_renderSetShaderValue(program.program, "pos", (float[2]){(float)window->event.point.x, (float)window->event.point.y}, 2);


RSGL_clear(RSGL_RGB(20, 20, 20));
RSGL_draw();
RGFW_window_swapBuffers(window);
}

Expand Down
13 changes: 8 additions & 5 deletions examples/basics/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,24 @@ int main(void) {
if (win->event.type == RGFW_quit)
running = 0;
}

RGFW_window_makeCurrent(win);

RSGL_updateSize(RSGL_AREA(win->r.w, win->r.h));

RSGL_clear(RSGL_RGB(255, 255, 255));
RSGL_setGradient(gradient, 3);
RSGL_drawTriangle(RSGL_TRIANGLE(RSGL_POINT(20, win->r.h - 20), RSGL_POINT(win->r.w - 20,win->r.h - 20), RSGL_POINT((win->r.w - 40) / 2, 20)), RSGL_RGB(255, 255, 0));

RSGL_clear(RSGL_RGB(255, 255, 255));
RSGL_draw();
RGFW_window_swapBuffers(win);

#ifndef __EMSCRIPTEN__
{
RGFW_window_makeCurrent(win2);
RSGL_updateSize(RSGL_AREA(win2->r.w, win2->r.h));
RSGL_clear(RSGL_RGB(255, 255, 255));

float points[] = {
RSGL_GET_WORLD_POINT(20, win2->r.h - 20, 0.0f),
RSGL_GET_WORLD_POINT(win2->r.w - 20, win2->r.h - 20, 0.0f),
Expand All @@ -93,8 +96,8 @@ int main(void) {

if (running == false)
break;
RSGL_clear(RSGL_RGB(255, 255, 255));

RSGL_draw();
RGFW_window_swapBuffers(win2);
}
#endif
Expand Down
4 changes: 3 additions & 1 deletion examples/basics/shapes.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ int main(void) {
}
}

RSGL_clear(RSGL_RGB(65, 65, 65));

rotate.z += 1;

if ((rand() % 200) <= 5)
Expand All @@ -43,7 +45,7 @@ int main(void) {
RSGL_rotate(rotate);
RSGL_drawTriangle(RSGL_TRIANGLE(RSGL_POINT(0, 500), RSGL_POINT(200, 500), RSGL_POINT(100, 250)), RSGL_RGB(0, 0, 255));

RSGL_clear(RSGL_RGB(65, 65, 65));
RSGL_draw();
RGFW_window_swapBuffers(win);

RGFW_window_checkFPS(win, 60);
Expand Down
4 changes: 3 additions & 1 deletion examples/basics/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ int main(void) {
if (win->event.type == RGFW_quit)
break;

RSGL_clear(RSGL_RGB(255, 255, 255));

RSGL_drawText("Text example\nnewlines too", RSGL_CIRCLE(200, 200, 20), RSGL_RGB(255, 0, 0));
RSGL_drawText(RSGL_strFmt("FPS : %i\nOpenGL %s", fps, RSGL_args.legacy ? "legacy (2-)" : "modern (3.3 +)"), RSGL_CIRCLE(0, 40, 40), RSGL_RGB(255, 0, 0));

RSGL_clear(RSGL_RGB(255, 255, 255));
RSGL_draw();
RGFW_window_swapBuffers(win);

fps = RGFW_window_checkFPS(win, 0);
Expand Down
7 changes: 4 additions & 3 deletions examples/basics/textures.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ int main(void) {
if (win->event.type == RGFW_quit) {
break;
}


RSGL_clear(RSGL_RGB(65, 65, 65));
rotate.z += 1;

RSGL_rotate(rotate);
Expand Down Expand Up @@ -56,8 +57,8 @@ int main(void) {
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_clear(RSGL_RGB(65, 65, 65));
RGFW_window_swapBuffers(win);
RSGL_draw();
RGFW_window_swapBuffers(win);

RGFW_window_checkFPS(win, 60);
}
Expand Down

0 comments on commit 3833f93

Please sign in to comment.