This commit is contained in:
Nishi 2026-01-23 15:38:08 +09:00
commit 3af095361d
Signed by: nishi
GPG key ID: 27EF69B208EB9343
10 changed files with 63 additions and 51 deletions

View file

@ -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
}

View file

@ -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);

View file

@ -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

View file

@ -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;
}

View file

@ -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)

View file

@ -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]);
}

View file

@ -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;
}

7
engine/src/gl_cull.c Normal file
View file

@ -0,0 +1,7 @@
#include <GearSrc/GL.h>
void GSGLCullCalculate(GSGL gl) {
}
GSBool GSGLCullTest(GSGL gl, GSBox* box) {
}

View file

@ -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);

@ -1 +1 @@
Subproject commit b458613f87b1cfcf05e0cf102688814861010d9f
Subproject commit 5413332506b2929c30c169a3f68934252d39cfff