assaultfish/client/main.c

50 lines
1 KiB
C
Raw Normal View History

2025-12-19 02:38:21 +09:00
#include <af_common.h>
MwWidget root, window, opengl;
static void resize(MwWidget handle, void* user, void* client){
2025-12-19 03:08:40 +09:00
int ww = MwGetInteger(window, MwNwidth);
int wh = MwGetInteger(window, MwNheight);
MwVaApply(opengl,
MwNwidth, ww,
MwNheight, wh,
NULL);
glViewport(0, 0, ww, wh);
}
static void tick(MwWidget handle, void* user, void* client){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
MwOpenGLSwapBuffer(opengl);
}
static void* gl_load(const char* name){
return MwOpenGLGetProcAddress(opengl, name);
2025-12-19 02:38:21 +09:00
}
2025-12-19 00:58:41 +09:00
int main(){
2025-12-19 02:38:21 +09:00
MwLibraryInit();
root = MwVaCreateWidget(NULL, "root", NULL, 0, 0, 0, 0,
MwNwaitMS, 15,
NULL);
window = MwVaCreateWidget(MwWindowClass, "main", root, MwDEFAULT, MwDEFAULT, 800, 600,
MwNtitle, "AssaultFish",
NULL);
opengl = MwCreateWidget(MwOpenGLClass, "opengl", window, 0, 0, 800, 600);
MwOpenGLMakeCurrent(opengl);
2025-12-19 03:08:40 +09:00
gladLoadGLLoader(gl_load);
resize(window, NULL, NULL);
2025-12-19 02:38:21 +09:00
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
2025-12-19 03:08:40 +09:00
MwAddUserHandler(root, MwNtickHandler, tick, NULL);
2025-12-19 02:38:21 +09:00
MwLoop(root);
2025-12-19 00:58:41 +09:00
}