assaultfish/engine/src/client.c

70 lines
1.3 KiB
C
Raw Normal View History

2026-01-12 01:54:35 +09:00
#include <GearSrc/Client.h>
2026-01-09 00:40:51 +09:00
2026-01-12 01:54:35 +09:00
#include <GearSrc/Log.h>
#include <GearSrc/GL.h>
#include <GearSrc/SkyBox.h>
#include <GearSrc/Math.h>
2026-01-09 00:40:51 +09:00
2026-01-12 01:54:35 +09:00
GSClient GSClientCreate(GSEngine engine) {
GSClient client = malloc(sizeof(*client));
2026-01-09 03:38:29 +09:00
memset(client, 0, sizeof(*client));
2026-01-09 06:12:57 +09:00
client->engine = engine;
2026-01-12 01:03:18 +09:00
client->camera[0] = 0;
client->camera[1] = 0;
client->camera[2] = 0;
2026-01-11 01:36:32 +09:00
client->look_at[0] = 0;
2026-01-12 01:03:18 +09:00
client->look_at[1] = 1;
2026-01-11 01:36:32 +09:00
client->look_at[2] = 0;
2026-01-12 04:41:17 +09:00
client->light0[0] = 2.5;
2026-01-11 17:43:03 +09:00
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-12 01:54:35 +09:00
client->gl = GSGLCreate(client);
2026-01-10 19:51:48 +09:00
2026-01-12 01:54:35 +09:00
client->skybox = GSSkyBoxOpen(client, "base:/skybox");
2026-01-12 01:03:18 +09:00
2026-01-12 01:54:35 +09:00
GSLog(GSLogInfo, "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
}
2026-01-12 01:54:35 +09:00
void GSClientDestroy(GSClient client) {
GSGLDestroy(client->gl);
2026-01-10 19:51:48 +09:00
2026-01-09 00:40:51 +09:00
free(client);
2026-01-10 19:51:48 +09:00
2026-01-12 01:54:35 +09:00
GSLog(GSLogInfo, "Destroyed client");
2026-01-09 00:40:51 +09:00
}
2026-01-09 03:38:29 +09:00
2026-01-12 01:54:35 +09:00
static void scene(GSClient client) {
2026-01-11 01:36:32 +09:00
}
2026-01-12 01:54:35 +09:00
void GSClientStep(GSClient client) {
GSGLClear(client->gl);
GSGLCameraSetup(client->gl);
GSGLSetLight(client->gl);
2026-01-11 01:36:32 +09:00
2026-01-12 01:54:35 +09:00
if(GSGLShadowBeforeMapping(client->gl)) {
2026-01-11 23:10:13 +09:00
scene(client);
2026-01-12 01:54:35 +09:00
GSGLShadowAfterMapping(client->gl);
2026-01-11 18:27:41 +09:00
}
2026-01-11 20:26:15 +09:00
2026-01-12 01:54:35 +09:00
if(client->skybox != NULL) GSSkyBoxDraw(client->skybox);
2026-01-11 23:10:13 +09:00
scene(client);
2026-01-12 01:54:35 +09:00
GSGLShadowEnd(client->gl);
2026-01-11 01:36:32 +09:00
2026-01-10 19:51:48 +09:00
client->engine->param->gl_swapbuffer();
2026-01-11 01:36:32 +09:00
2026-01-12 01:03:18 +09:00
static double r = 0;
client->look_at[0] = cos(r) * 5;
client->look_at[2] = sin(r) * 5;
2026-01-11 01:36:32 +09:00
r += 0.1;
2026-01-09 03:38:29 +09:00
}