From 3af095361d4a27b4cb91a0e7ebde358c73cc1004 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Fri, 23 Jan 2026 15:38:08 +0900 Subject: [PATCH] soon --- engine/include/GearSrc/Client.h | 4 ++-- engine/include/GearSrc/GL.h | 18 ++++++++--------- engine/include/GearSrc/TypeDefs.h | 18 +++++++++++------ engine/src/client.c | 33 +++++++++++++++---------------- engine/src/core.c | 2 +- engine/src/gl.c | 2 +- engine/src/gl_common.c | 26 ++++++++++++------------ engine/src/gl_cull.c | 7 +++++++ engine/src/model.c | 2 +- submodule/milsko | 2 +- 10 files changed, 63 insertions(+), 51 deletions(-) create mode 100644 engine/src/gl_cull.c diff --git a/engine/include/GearSrc/Client.h b/engine/include/GearSrc/Client.h index e8b47c6..ae13f67 100644 --- a/engine/include/GearSrc/Client.h +++ b/engine/include/GearSrc/Client.h @@ -11,8 +11,8 @@ extern "C" { GSDECL GSClient GSClientCreate(GSEngine engine); GSDECL void GSClientDestroy(GSClient client); GSDECL void GSClientStep(GSClient client); -GSDECL GSGL GSClientGetGL(GSClient client); -GSDECL void GSClientToggleSkybox(GSClient client, GSBool toggle); +GSDECL GSGL GSClientGetGL(GSClient client); +GSDECL void GSClientToggleSkybox(GSClient client, GSBool toggle); #ifdef __cplusplus } diff --git a/engine/include/GearSrc/GL.h b/engine/include/GearSrc/GL.h index 6ed009a..7705a41 100644 --- a/engine/include/GearSrc/GL.h +++ b/engine/include/GearSrc/GL.h @@ -23,19 +23,19 @@ GSDECL void GSGLTextureDelete(GSGL gl, GLuint texture); /* gl_common.c */ GSDECL GSBool GSGLTextureLoadFile(GSGL gl, GLuint* texture, int* width, int* height, const char* filename); GSDECL GSBool GSGLTextureTry(GSGL gl, GLuint* texture, int* width, int* height, const char* prefix); -GSDECL void GSGLTextEx(GSGL gl, double x, double y, double sx, double sy, const char* text); -GSDECL void GSGLText(GSGL gl, double x, double y, const char* text); +GSDECL void GSGLTextEx(GSGL gl, double x, double y, double sx, double sy, const char* text); +GSDECL void GSGLText(GSGL gl, double x, double y, const char* text); GSDECL double GSGLTextWidth(GSGL gl, const char* text); GSDECL double GSGLTextHeight(GSGL gl, const char* text); /* gl_shadow.c */ -GSDECL void GSGLShadowInit(GSGL gl); +GSDECL void GSGLShadowInit(GSGL gl); GSDECL GSBool GSGLShadowBeforeMapping(GSGL gl); -GSDECL void GSGLShadowAfterMapping(GSGL gl); -GSDECL void GSGLShadowEnd(GSGL gl); -GSDECL void GSGLShadowDeinit(GSGL gl); -GSDECL void GSGLShadowDisable(GSGL gl); -GSDECL void GSGLShadowEnable(GSGL gl); +GSDECL void GSGLShadowAfterMapping(GSGL gl); +GSDECL void GSGLShadowEnd(GSGL gl); +GSDECL void GSGLShadowDeinit(GSGL gl); +GSDECL void GSGLShadowDisable(GSGL gl); +GSDECL void GSGLShadowEnable(GSGL gl); /* gl.c */ GSDECL GSGL GSGLCreate(GSClient client); @@ -55,7 +55,7 @@ GSDECL void GSGLPopMatrix(GSGL gl); GSDECL GLuint GSGLBeginList(GSGL gl); GSDECL void GSGLEndList(GSGL gl); GSDECL void GSGLCallList(GSGL gl, GLuint list); -GSDECL void GSGLSetColor(GSGL gl, GSVector4 color); +GSDECL void GSGLSetColor(GSGL gl, GSVector4 color); /* gl_camera.c */ GSDECL void GSGLCameraPerspective(GSGL gl, GSNumber width, GSNumber height); diff --git a/engine/include/GearSrc/TypeDefs.h b/engine/include/GearSrc/TypeDefs.h index f9270b0..5d00fe1 100644 --- a/engine/include/GearSrc/TypeDefs.h +++ b/engine/include/GearSrc/TypeDefs.h @@ -44,6 +44,7 @@ typedef GSU8 GSBool; typedef struct _GSVersion GSVersion; typedef struct _GSEngineParam GSEngineParam; typedef struct _GSResourceKV GSResourceKV; +typedef struct _GSBox GSBox; #ifdef _GEARSRC typedef struct _GSClient* GSClient; typedef struct _GSServer* GSServer; @@ -81,6 +82,11 @@ typedef void (*GSSleepCallback)(int ms); typedef void (*GSRenderCallback)(GSEngine engine); typedef void (*GSAfterRenderCallback)(GSEngine engine); +struct _GSBox { + GSVector3 a; + GSVector3 b; +}; + struct _GSResourceKV { char* key; GSResource value; @@ -105,14 +111,14 @@ struct _GSClient { GSEngine engine; GSGL gl; - GLuint font; - int font_width; - int font_height; + GLuint font; + int font_width; + int font_height; GSVector3 look_at; GSVector3 camera; GSVector4 light0; GSSkyBox skybox; - GSBool skybox_enabled; + GSBool skybox_enabled; }; struct _GSSkyBox { @@ -197,8 +203,8 @@ struct _GSEngineParam { GSTickCallback tick; GSGetTickCallback get_tick; GSSleepCallback sleep; - GSRenderCallback render; - GSAfterRenderCallback after_render; + GSRenderCallback render; + GSAfterRenderCallback after_render; }; #endif diff --git a/engine/src/client.c b/engine/src/client.c index 311557a..836d075 100644 --- a/engine/src/client.c +++ b/engine/src/client.c @@ -33,9 +33,9 @@ GSClient GSClientCreate(GSEngine engine) { client->skybox = GSSkyBoxTry(client, "default"); - if(GSGLTextureTry(client->gl, &client->font, &client->font_width, &client->font_height, "game:/font")){ - }else if(GSGLTextureTry(client->gl, &client->font, &client->font_width, &client->font_height, "base:/font")){ - }else{ + if(GSGLTextureTry(client->gl, &client->font, &client->font_width, &client->font_height, "game:/font")) { + } else if(GSGLTextureTry(client->gl, &client->font, &client->font_width, &client->font_height, "base:/font")) { + } else { client->font = 0; } @@ -59,14 +59,14 @@ static void scene(GSClient client) { } void GSClientStep(GSClient client) { - int tw, th; - int tw2, th2; - int sw, sh; - char buf[512]; - char buf2[512]; + int tw, th; + int tw2, th2; + int sw, sh; + char buf[512]; + char buf2[512]; GSVersion ver; GSVector4 white = {1, 1, 1, 1}; - GSVector4 half = {0, 0, 0, 0.5}; + GSVector4 half = {0, 0, 0, 0.5}; GSVector2 sq[4]; GSGLClear(client->gl); @@ -78,22 +78,21 @@ void GSClientStep(GSClient client) { GSGLShadowAfterMapping(client->gl); } - if(client->skybox_enabled){ + if(client->skybox_enabled) { if(client->skybox != NULL) GSSkyBoxDraw(client->skybox); } scene(client); GSGLShadowEnd(client->gl); - GSVersionGet(&ver); - + sprintf(buf, "GearSrc Engine %s", ver.string); - + tw = GSGLTextWidth(client->gl, buf); th = GSGLTextHeight(client->gl, buf); sprintf(buf2, "%s", ver.copyright); - + tw2 = GSGLTextWidth(client->gl, buf2); th2 = GSGLTextHeight(client->gl, buf2); @@ -113,16 +112,16 @@ void GSClientStep(GSClient client) { GSGLSetColor(client->gl, white); GSGLText(client->gl, client->engine->width - tw, client->engine->height - th * 2, buf); GSGLText(client->gl, client->engine->width - tw2, client->engine->height - th2, buf2); - + client->engine->param->gl_swapbuffer(); if(client->engine->param->after_render != NULL) client->engine->param->after_render(client->engine); } -GSGL GSClientGetGL(GSClient client){ +GSGL GSClientGetGL(GSClient client) { return client->gl; } -void GSClientToggleSkybox(GSClient client, GSBool toggle){ +void GSClientToggleSkybox(GSClient client, GSBool toggle) { client->skybox_enabled = toggle; } diff --git a/engine/src/core.c b/engine/src/core.c index c6927a7..a657c7a 100644 --- a/engine/src/core.c +++ b/engine/src/core.c @@ -132,7 +132,7 @@ void GSEngineLoop(GSEngine engine) { if(engine->param->tick != NULL) engine->param->tick(); - if(wait_actually) { + if(wait_actually && !engine->param->client) { int diff = (engine->param->get_tick() - t); if(wait > diff) diff --git a/engine/src/gl.c b/engine/src/gl.c index 2856211..b7f85cf 100644 --- a/engine/src/gl.c +++ b/engine/src/gl.c @@ -146,6 +146,6 @@ void GSGLCallList(GSGL gl, GLuint list) { glCallList(list); } -void GSGLSetColor(GSGL gl, GSVector4 color){ +void GSGLSetColor(GSGL gl, GSVector4 color) { glColor4f(color[0], color[1], color[2], color[3]); } diff --git a/engine/src/gl_common.c b/engine/src/gl_common.c index 0095596..a34af17 100644 --- a/engine/src/gl_common.c +++ b/engine/src/gl_common.c @@ -38,11 +38,11 @@ GSBool GSGLTextureLoadFile(GSGL gl, GLuint* texture, int* width, int* height, co } GSBool GSGLTextureTry(GSGL gl, GLuint* texture, int* width, int* height, const char* prefix) { - char* png = GSStringConcat(prefix, ".png"); - char* bmp = GSStringConcat(prefix, ".bmp"); - char* jpg = GSStringConcat(prefix, ".jpg"); - char* jpeg = GSStringConcat(prefix, ".jpeg"); - GSBool st = GSTrue; + char* png = GSStringConcat(prefix, ".png"); + char* bmp = GSStringConcat(prefix, ".bmp"); + char* jpg = GSStringConcat(prefix, ".jpg"); + char* jpeg = GSStringConcat(prefix, ".jpeg"); + GSBool st = GSTrue; if(GSGLTextureLoadFile(gl, texture, width, height, prefix)) { } else if(GSGLTextureLoadFile(gl, texture, width, height, png)) { @@ -61,21 +61,21 @@ GSBool GSGLTextureTry(GSGL gl, GLuint* texture, int* width, int* height, const c return st; } -void GSGLTextEx(GSGL gl, double x, double y, double sx, double sy, const char* text){ +void GSGLTextEx(GSGL gl, double x, double y, double sx, double sy, const char* text) { double px = x; double py = y; - int i; + int i; double gw = gl->engine->client->font_width / 16 * sx; double gh = gl->engine->client->font_height / 16 * sy; GSGLBegin2D(gl); GSGLTextureSet(gl, gl->engine->client->font); - for(i = 0; text[i] != 0; i++){ + for(i = 0; text[i] != 0; i++) { GSVector2 v[4]; GSVector2 t[4]; - double gx = text[i] % 16; - double gy = text[i] / 16; + double gx = text[i] % 16; + double gy = text[i] / 16; gx = gx / 16; gy = gy / 16; @@ -102,14 +102,14 @@ void GSGLTextEx(GSGL gl, double x, double y, double sx, double sy, const char* t GSGLEnd2D(gl); } -void GSGLText(GSGL gl, double x, double y, const char* text){ +void GSGLText(GSGL gl, double x, double y, const char* text) { GSGLTextEx(gl, x, y, 1, 1, text); } -double GSGLTextWidth(GSGL gl, const char* text){ +double GSGLTextWidth(GSGL gl, const char* text) { return gl->engine->client->font_width / 16 * strlen(text); } -double GSGLTextHeight(GSGL gl, const char* text){ +double GSGLTextHeight(GSGL gl, const char* text) { return gl->engine->client->font_height / 16; } diff --git a/engine/src/gl_cull.c b/engine/src/gl_cull.c new file mode 100644 index 0000000..1cc4246 --- /dev/null +++ b/engine/src/gl_cull.c @@ -0,0 +1,7 @@ +#include + +void GSGLCullCalculate(GSGL gl) { +} + +GSBool GSGLCullTest(GSGL gl, GSBox* box) { +} diff --git a/engine/src/model.c b/engine/src/model.c index f94b888..2037981 100644 --- a/engine/src/model.c +++ b/engine/src/model.c @@ -274,7 +274,7 @@ GSModel GSModelOpen(GSEngine engine, const char* path) { /* TODO: check for animation */ if(gl != NULL) { - GLuint list = GSGLBeginList(gl); + GLuint list = GSGLBeginList(gl); GSModelDraw(model); GSGLEndList(gl); diff --git a/submodule/milsko b/submodule/milsko index b458613..5413332 160000 --- a/submodule/milsko +++ b/submodule/milsko @@ -1 +1 @@ -Subproject commit b458613f87b1cfcf05e0cf102688814861010d9f +Subproject commit 5413332506b2929c30c169a3f68934252d39cfff