math functions

This commit is contained in:
Nishi 2026-01-10 19:51:48 +09:00
commit 9d11089a75
Signed by: nishi
GPG key ID: 27EF69B208EB9343
15 changed files with 265 additions and 47 deletions

View file

@ -11,7 +11,17 @@ extern "C" {
#endif
/* gl_shader.c */
GBDECL int GBGLShaderPrepare(GBEngine engine, GLuint* shader, const char* vs, const char* fs);
GBDECL int GBGLShaderPrepare(GBGL gl, GLuint* shader, const char* vs, const char* fs);
/* gl_texture.c */
GBDECL int GBGLTexturePrepare(GBGL gl, GLuint* texture, unsigned char* rgba, int width, int height);
/* gl_shadow.c */
GBDECL void GBGLShadowInit(GBGL gl);
/* gl.c */
GBDECL GBGL GBGLCreate(GBClient client);
GBDECL void GBGLDestroy(GBGL gl);
#ifdef __cplusplus
}

View file

@ -8,9 +8,15 @@
extern "C" {
#endif
GBDECL void GBMathCross(double* out, double v00, double v01, double v02, double v10, double v11, double v12);
GBDECL void GBMathNormal3(double* out, double v00, double v01, double v02, double v10, double v11, double v12, double v20, double v21, double v22);
GBDECL void GBMathNormal4(double* out, double v00, double v01, double v02, double v10, double v11, double v12, double v20, double v21, double v22, double v30, double v31, double v32);
#define GBMathPi 3.14159265358979323846
GBDECL void GBMathCross3(GBVector3 r, GBVector3 v0, GBVector3 v1);
GBDECL void GBMathNormalize3(GBVector3 vec);
GBDECL void GBMathSubtract3(GBVector3 r, GBVector3 v0, GBVector3 v1);
GBDECL void GBMathAdd3(GBVector3 r, GBVector3 v0, GBVector3 v1);
GBDECL void GBMathNormal3x3(GBVector3 r, GBVector3 v0, GBVector3 v1, GBVector3 v2);
GBDECL void GBMathNormal3x4(GBVector3 r, GBVector3 v0, GBVector3 v1, GBVector3 v2, GBVector3 v3);
GBDECL double GBMathCot(double x);
#ifdef __cplusplus
}

View file

@ -46,13 +46,17 @@ typedef struct _GBServer* GBServer;
typedef struct _GBEngine* GBEngine;
typedef struct _GBFile* GBFile;
typedef struct _GBResource* GBResource;
typedef struct _GBGL* GBGL;
#else
typedef void* GBClient;
typedef void* GBServer;
typedef void* GBEngine;
typedef void* GBFile;
typedef void* GBResource;
typedef void* GBGL;
#endif
typedef double GBVector3[3];
typedef double GBVector4[4];
typedef void (*GBGLSwapBufferCallback)(void);
typedef void (*GBReadyCallback)(int width, int height);
@ -66,8 +70,21 @@ struct _GBResourceKV {
};
#ifdef _GEARBOX
#include <GearBox/GL/GL.h>
struct _GBGL {
GBEngine engine;
GLuint shadow_texture;
GLuint shadow_shader;
};
struct _GBClient {
GBEngine engine;
GBGL gl;
GBVector3 look_at;
GBVector3 camera;
};
struct _GBServer {