Skip to content

Commit

Permalink
add icon example
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Jan 22, 2025
1 parent 0fbdf00 commit bdd28f7
Show file tree
Hide file tree
Showing 4 changed files with 8,022 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ EXAMPLE_OUTPUTS = \
examples/basic/basic \
examples/buffer/buffer \
examples/events/events \
examples/callbacks/callbacks
examples/callbacks/callbacks \
examples/icons/icons


EXAMPLE_OUTPUTS_CUSTOM = \
Expand Down
32 changes: 32 additions & 0 deletions examples/icons/icons.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#define RGFW_DEBUG
#define RGFW_IMPLEMENTATION
#include "RGFW.h"

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

int main(void) {
int w, h, c;
unsigned char* icon = stbi_load("logo.png", &w, &h, &c, 0);

RGFW_mouse* mouse = RGFW_loadMouse(icon, RGFW_AREA(w, h), c);

RGFW_window* win = RGFW_createWindow("RGFW icons", RGFW_RECT(0, 0, 600, 400), RGFW_windowCenter | RGFW_windowNoResize);

RGFW_window_setIcon(win, icon, RGFW_AREA(w, h), c);
RGFW_window_setMouse(win, mouse);

while (RGFW_window_shouldClose(win) == RGFW_FALSE) {
while (RGFW_window_checkEvent(win));

glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

RGFW_window_swapBuffers(win);
}

RGFW_freeMouse(mouse);
RGFW_window_close(win);
stbi_image_free(icon);
return 0;
}
Binary file added examples/icons/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bdd28f7

Please sign in to comment.