Skip to content

Commit

Permalink
Integrate gltf2 support without external plugin.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5605 fc73d0e0-1445-4013-8a0c-d673dee63da5
  • Loading branch information
Spoike committed Jan 20, 2020
1 parent 8e656b4 commit ffda35f
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 60 deletions.
14 changes: 8 additions & 6 deletions engine/common/com_mesh.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef COM_MESH_H
#define COM_MESH_H

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -91,7 +94,6 @@ typedef struct
//we can't be bothered with animating skins.
//We'll load up to four of them but after that you're on your own
#ifndef SERVERONLY

typedef struct
{
shader_t *shader;
Expand All @@ -100,15 +102,15 @@ typedef struct
char shadername[MAX_QPATH];
texnums_t texnums;
} skinframe_t;
typedef struct
struct galiasskin_s
{
int skinwidth;
int skinheight;
float skinspeed;
int numframes;
skinframe_t *frame;
char name[MAX_QPATH];
} galiasskin_t;
};

typedef struct
{
Expand All @@ -121,9 +123,8 @@ typedef struct
unsigned int subframe;
bucket_t bucket;
} galiascolourmapped_t;
#else
typedef void galiasskin_t;
#endif
typedef struct galiasskin_s galiasskin_t;

typedef struct
{
Expand Down Expand Up @@ -276,4 +277,5 @@ void R_Generate_Mesh_ST_Vectors(mesh_t *mesh);

#ifdef __cplusplus
};
#endif
#endif
#endif //COM_MESH_H
1 change: 1 addition & 0 deletions engine/common/config_freecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
//#define IMAGEFMT_EXR //openexr, via Industrial Light & Magic's rgba api, giving half-float data.
//#define MODELFMT_MDX
//#define MODELFMT_OBJ
//#define MODELFMT_GLTF //khronos 'transmission format'. .gltf or .glb extension. PBR. Version 2 only, for now.
//#define AVAIL_STBI //make use of Sean T. Barrett's lightweight public domain stb_image[_write] single-file-library, to avoid libpng/libjpeg dependancies.


Expand Down
1 change: 1 addition & 0 deletions engine/common/config_fteqw.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#define INTERQUAKEMODELS //Preferred model format, at least from an idealism perspective.
#define MODELFMT_MDX //kingpin's format (for hitboxes+geomsets).
#define MODELFMT_OBJ //lame mesh-only format that needs far too much processing and even lacks a proper magic identifier too
#define MODELFMT_GLTF //khronos 'transmission format'. .gltf or .glb extension. PBR. Version 2 only, for now.
#define RAGDOLL //ragdoll support. requires RBE support (via a plugin...).

//Image formats
Expand Down
1 change: 1 addition & 0 deletions engine/common/config_minimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
//#define INTERQUAKEMODELS //Preferred model format, at least from an idealism perspective.
//#define MODELFMT_MDX //kingpin's format (for hitboxes+geomsets).
//#define MODELFMT_OBJ //lame mesh-only format that needs far too much processing and even lacks a proper magic identifier too
//#define MODELFMT_GLTF //khronos 'transmission format'. .gltf or .glb extension. PBR. Version 2 only, for now.
//#define RAGDOLL //ragdoll support. requires RBE support (via a plugin...).

//Image formats
Expand Down
1 change: 1 addition & 0 deletions engine/common/config_nocompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#define INTERQUAKEMODELS //Preferred model format, at least from an idealism perspective.
//#define MODELFMT_MDX //kingpin's format (for hitboxes+geomsets).
//#define MODELFMT_OBJ //lame mesh-only format that needs far too much processing and even lacks a proper magic identifier too
//#define MODELFMT_GLTF //khronos 'transmission format'. .gltf or .glb extension. PBR. Version 2 only, for now.
#define RAGDOLL //ragdoll support. requires RBE support (via a plugin...).

//Image formats
Expand Down
1 change: 1 addition & 0 deletions engine/common/config_wastes.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
//#define HAVE_HTTPSV
//#define MODELFMT_MDX
//#define MODELFMT_OBJ
//#define MODELFMT_GLTF //khronos 'transmission format'. .gltf or .glb extension. PBR. Version 2 only, for now.

#ifdef COMPILE_OPTS
//things to configure qclib, which annoyingly doesn't include this file itself
Expand Down
36 changes: 30 additions & 6 deletions engine/common/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

#ifdef PLUGINS

#ifdef MODELFMT_GLTF
#define Q_snprintf Q_snprintfz
#define Q_strlcpy Q_strncpyz
#define Q_strlcat Q_strncatz
#include "../plugins/models/gltf.c"
#endif

cvar_t plug_sbar = CVARD("plug_sbar", "3", "Controls whether plugins are allowed to draw the hud, rather than the engine (when allowed by csqc). This is typically used to permit the ezhud plugin without needing to bother unloading it.\n=0: never use hud plugins.\n&1: Use hud plugins in deathmatch.\n&2: Use hud plugins in singleplayer/coop.\n=3: Always use hud plugins (when loaded).");
cvar_t plug_loaddefault = CVARD("plug_loaddefault", "1", "0: Load plugins only via explicit plug_load commands\n1: Load built-in plugins and those selected via the package manager\n2: Scan for misc plugins, loading all that can be found, but not built-ins.\n3: Scan for plugins, and then load any built-ins");

Expand All @@ -23,6 +30,9 @@ static struct
#endif
#if defined(USE_INTERNAL_ODE)
{"ODE_internal", Plug_ODE_Init},
#endif
#if defined(MODELFMT_GLTF)
{"GLTF", Plug_GLTF_Init},
#endif
{NULL}
};
Expand Down Expand Up @@ -236,6 +246,7 @@ static plugin_t *Plug_Load(const char *file)
Con_DPrintf("Activated module %s\n", file);
newplug->lib = NULL;

Q_strncpyz(newplug->filename, staticplugins[u].name, sizeof(newplug->filename));
currentplug = newplug;
success = staticplugins[u].initfunction();
break;
Expand Down Expand Up @@ -1614,6 +1625,7 @@ int QDECL Plug_List_Print(const char *fname, qofs_t fsize, time_t modtime, void
//lots of awkward logic so we hide modules for other cpus.
size_t nl = strlen(fname);
size_t u;
char *arch_ext = ARCH_DL_POSTFIX;
static const char *knownarch[] =
{
"x32", "x64", "amd64", "x86", //various x86 ABIs
Expand All @@ -1625,9 +1637,14 @@ int QDECL Plug_List_Print(const char *fname, qofs_t fsize, time_t modtime, void
while ((mssuck=strchr(fname, '\\')))
*mssuck = '/';
#endif
if (nl >= strlen(ARCH_DL_POSTFIX) && !Q_strcasecmp(fname+nl-strlen(ARCH_DL_POSTFIX), ARCH_DL_POSTFIX))
if (!parm)
{
parm = "";
arch_ext = ""; //static plugins have no extension.
}
if (nl >= strlen(arch_ext) && !Q_strcasecmp(fname+nl-strlen(arch_ext), arch_ext))
{
nl -= strlen(ARCH_DL_POSTFIX);
nl -= strlen(arch_ext);
for (u = 0; u < countof(knownarch); u++)
{
size_t al = strlen(knownarch[u]);
Expand Down Expand Up @@ -1664,18 +1681,26 @@ void Plug_List_f(void)
char rootpath[MAX_OSPATH];
unsigned int u;
plugin_t *plug;

Con_Printf("Loaded plugins:\n");
for (plug = plugs; plug; plug = plug->next)
Con_Printf("^[^2%s\\type\\plug_close %s\\^]: loaded\n", plug->filename, plug->name);

if (staticplugins[0].name)
{
Con_DPrintf("Internal plugins:\n");
for (u = 0; staticplugins[u].name; u++)
Plug_List_Print(staticplugins[u].name, 0, 0, NULL, NULL);
}

if (FS_NativePath("", FS_BINARYPATH, binarypath, sizeof(binarypath)))
{
#ifdef _WIN32
char *mssuck;
while ((mssuck=strchr(binarypath, '\\')))
*mssuck = '/';
#endif
Con_Printf("Scanning for plugins at %s:\n", binarypath);
Con_DPrintf("Scanning for plugins at %s:\n", binarypath);
Sys_EnumerateFiles(binarypath, PLUGINPREFIX"*" ARCH_DL_POSTFIX, Plug_List_Print, binarypath, NULL);
}
if (FS_NativePath("", FS_ROOT, rootpath, sizeof(rootpath)))
Expand All @@ -1687,13 +1712,12 @@ void Plug_List_f(void)
#endif
if (strcmp(binarypath, rootpath))
{
Con_Printf("Scanning for plugins at %s:\n", rootpath);
Con_DPrintf("Scanning for plugins at %s:\n", rootpath);
Sys_EnumerateFiles(rootpath, PLUGINPREFIX"*" ARCH_DL_POSTFIX, Plug_List_Print, rootpath, NULL);
}
}

for (u = 0; staticplugins[u].name; u++)
Plug_List_Print(staticplugins[u].name, 0, 0, "", NULL);
//should probably check downloadables too.
}

void Plug_Shutdown(qboolean preliminary)
Expand Down
Loading

0 comments on commit ffda35f

Please sign in to comment.