assaultfish/engine/src/client.c

66 lines
1.1 KiB
C
Raw Normal View History

2026-01-09 00:40:51 +09:00
#include <GearBox/Client.h>
#include <GearBox/Log.h>
2026-01-10 19:51:48 +09:00
#include <GearBox/GL.h>
2026-01-11 20:26:15 +09:00
#include <GearBox/Math.h>
2026-01-09 00:40:51 +09:00
GBClient GBClientCreate(GBEngine engine) {
2026-01-09 03:38:29 +09:00
GBClient client = malloc(sizeof(*client));
memset(client, 0, sizeof(*client));
2026-01-09 06:12:57 +09:00
client->engine = engine;
2026-01-11 20:26:15 +09:00
client->camera[0] = 5;
client->camera[1] = 5;
client->camera[2] = 5;
2026-01-11 01:36:32 +09:00
client->look_at[0] = 0;
client->look_at[1] = 0;
client->look_at[2] = 0;
2026-01-11 17:43:03 +09:00
client->light0[0] = 5;
client->light0[1] = 5;
client->light0[2] = 5;
2026-01-11 18:27:41 +09:00
client->light0[3] = 1;
2026-01-11 01:36:32 +09:00
2026-01-10 19:51:48 +09:00
client->gl = GBGLCreate(client);
GBLog(GBLogInfo, "Created client");
2026-01-09 00:40:51 +09:00
2026-01-09 03:38:29 +09:00
return client;
2026-01-09 00:40:51 +09:00
}
void GBClientDestroy(GBClient client) {
2026-01-10 19:51:48 +09:00
GBGLDestroy(client->gl);
2026-01-09 00:40:51 +09:00
free(client);
2026-01-10 19:51:48 +09:00
GBLog(GBLogInfo, "Destroyed client");
2026-01-09 00:40:51 +09:00
}
2026-01-09 03:38:29 +09:00
2026-01-11 20:26:15 +09:00
static double r = 0;
2026-01-11 23:10:13 +09:00
static void scene(GBClient client) {
2026-01-11 01:36:32 +09:00
}
2026-01-09 03:38:29 +09:00
void GBClientStep(GBClient client) {
2026-01-11 23:10:13 +09:00
GBGLClear(client->gl);
GBGLCameraSetup(client->gl);
GBGLSetLight(client->gl);
2026-01-11 01:36:32 +09:00
2026-01-11 18:27:41 +09:00
if(GBGLShadowBeforeMapping(client->gl)) {
2026-01-11 23:10:13 +09:00
scene(client);
2026-01-11 18:27:41 +09:00
GBGLShadowAfterMapping(client->gl);
}
2026-01-11 20:26:15 +09:00
2026-01-11 23:10:13 +09:00
scene(client);
2026-01-11 01:36:32 +09:00
GBGLShadowEnd(client->gl);
2026-01-10 19:51:48 +09:00
client->engine->param->gl_swapbuffer();
2026-01-11 01:36:32 +09:00
2026-01-11 23:10:13 +09:00
client->camera[0] = cos(r) * 5;
client->camera[2] = sin(r) * 5;
2026-01-11 01:36:32 +09:00
r += 0.1;
2026-01-09 03:38:29 +09:00
}