You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

56 lines
2.1 KiB

#include "uniquake.h"
#include "../Quake/quakedef.h"
#include "../Quake/gl_model.h"
typedef struct unity_glcalls_s
{
int(*UploadAliasModel)(void *context, const char *name, aliashdr_t *aliashdr, aliasframetype_t frametype, maliasframedesc_t *frames, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts);
int(*UploadBrushModel)(void *context, qmodel_t *model);
int(*UploadWorldModel)(void *context, qmodel_t *model);
qboolean(*UploadTexture)(void *context, gltexture_t *texture, unsigned *data, GLuint *texnum);
qboolean(*UploadLightmap)(void *context, int lmap, byte *data);
void(*SetupView)(void *context, vec3_t origin, vec3_t angles, mleaf_t *viewLeaf);
} unity_glcalls_t;
static void *unity_context;
static const unity_glcalls_t *unity_glcalls;
UNIQUAKE_API void UniQuake_SetRenderCallbacks(void *context, const unity_glcalls_t *callbacks)
{
unity_context = context;
unity_glcalls = callbacks;
}
int UQ_GL_UploadAliasModel(qmodel_t *model, aliashdr_t *aliashdr, aliasframetype_t frametype, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts)
{
// C# doesn't really understand this idea of a variable-length embedded array of structs,
// so we pass along the pointer to the first frame struct which allows us to manually marshal the entire array.
return unity_glcalls->UploadAliasModel(unity_context, model->name, aliashdr, frametype, &aliashdr->frames[0], poseVerts, triangles, stVerts);
}
int UQ_GL_UploadBrushModel(qmodel_t *model)
{
return unity_glcalls->UploadBrushModel(unity_context, model);
}
int UQ_GL_UploadWorldModel(qmodel_t *model)
{
return unity_glcalls->UploadWorldModel(unity_context, model);
}
qboolean UQ_GL_UploadTexture(gltexture_t *texture, unsigned *data)
{
// Allow UniQuake to either sync up its internal texture reference number, or assign a new one.
return unity_glcalls->UploadTexture(unity_context, texture, data, &texture->texnum);
}
qboolean UQ_GL_UploadLightmap(int lmap, byte *data)
{
return unity_glcalls->UploadLightmap(unity_context, lmap, data);
}
void UQ_GL_SetupView(vec3_t origin, vec3_t angles, mleaf_t *viewLeaf)
{
unity_glcalls->SetupView(unity_context, origin, angles, viewLeaf);
}