Rename structs to more sane things
This commit is contained in:
parent
3641c246d4
commit
4224594ee4
|
@ -36,7 +36,7 @@ void phys2d_shape_apply(struct phys2d_shape *shape)
|
||||||
cpShapeSetElasticity(shape->shape, shape->go->e);
|
cpShapeSetElasticity(shape->shape, shape->go->e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_phys2dshape(struct phys2d_shape *shape, struct mGameObject *go)
|
void init_phys2dshape(struct phys2d_shape *shape, struct gameobject *go)
|
||||||
{
|
{
|
||||||
shape->go = go;
|
shape->go = go;
|
||||||
phys2d_shape_apply(shape);
|
phys2d_shape_apply(shape);
|
||||||
|
@ -47,7 +47,7 @@ void phys2d_shape_del(struct phys2d_shape *shape)
|
||||||
cpSpaceRemoveShape(space, shape->shape);
|
cpSpaceRemoveShape(space, shape->shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct phys2d_circle *Make2DCircle(struct mGameObject *go)
|
struct phys2d_circle *Make2DCircle(struct gameobject *go)
|
||||||
{
|
{
|
||||||
struct phys2d_circle *new = malloc(sizeof(struct phys2d_circle));
|
struct phys2d_circle *new = malloc(sizeof(struct phys2d_circle));
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ struct phys2d_circle *Make2DCircle(struct mGameObject *go)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
void phys2d_circleinit(struct phys2d_circle *circle, struct mGameObject *go)
|
void phys2d_circleinit(struct phys2d_circle *circle, struct gameobject *go)
|
||||||
{
|
{
|
||||||
circle->shape.shape = cpSpaceAddShape(space, cpCircleShapeNew(go->body, circle->radius, cpvzero));
|
circle->shape.shape = cpSpaceAddShape(space, cpCircleShapeNew(go->body, circle->radius, cpvzero));
|
||||||
init_phys2dshape(&circle->shape, go);
|
init_phys2dshape(&circle->shape, go);
|
||||||
|
@ -87,7 +87,7 @@ void phys2d_dbgdrawcircle(struct phys2d_circle *circle)
|
||||||
draw_circle(p.x + (d * cos(a)), p.y + (d * sin(a)), cpCircleShapeGetRadius(circle->shape.shape), 1);
|
draw_circle(p.x + (d * cos(a)), p.y + (d * sin(a)), cpCircleShapeGetRadius(circle->shape.shape), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct phys2d_segment *Make2DSegment(struct mGameObject *go)
|
struct phys2d_segment *Make2DSegment(struct gameobject *go)
|
||||||
{
|
{
|
||||||
struct phys2d_segment *new = malloc(sizeof(struct phys2d_segment));
|
struct phys2d_segment *new = malloc(sizeof(struct phys2d_segment));
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ struct phys2d_segment *Make2DSegment(struct mGameObject *go)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
void phys2d_seginit(struct phys2d_segment *seg, struct mGameObject *go)
|
void phys2d_seginit(struct phys2d_segment *seg, struct gameobject *go)
|
||||||
{
|
{
|
||||||
seg->shape.shape = cpSpaceAddShape(space, cpSegmentShapeNew(go->body, cpvzero, cpvzero, seg->thickness));
|
seg->shape.shape = cpSpaceAddShape(space, cpSegmentShapeNew(go->body, cpvzero, cpvzero, seg->thickness));
|
||||||
init_phys2dshape(&seg->shape, go);
|
init_phys2dshape(&seg->shape, go);
|
||||||
|
@ -120,7 +120,7 @@ void segment_gui(struct phys2d_segment *seg)
|
||||||
phys2d_applyseg(seg);
|
phys2d_applyseg(seg);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct phys2d_box *Make2DBox(struct mGameObject *go)
|
struct phys2d_box *Make2DBox(struct gameobject *go)
|
||||||
{
|
{
|
||||||
struct phys2d_box *new = malloc(sizeof(struct phys2d_box));
|
struct phys2d_box *new = malloc(sizeof(struct phys2d_box));
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ struct phys2d_box *Make2DBox(struct mGameObject *go)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
void phys2d_boxinit(struct phys2d_box *box, struct mGameObject *go)
|
void phys2d_boxinit(struct phys2d_box *box, struct gameobject *go)
|
||||||
{
|
{
|
||||||
box->shape.shape =
|
box->shape.shape =
|
||||||
cpSpaceAddShape(space,
|
cpSpaceAddShape(space,
|
||||||
|
@ -159,7 +159,7 @@ void box_gui(struct phys2d_box *box)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct phys2d_poly *Make2DPoly(struct mGameObject *go)
|
struct phys2d_poly *Make2DPoly(struct gameobject *go)
|
||||||
{
|
{
|
||||||
struct phys2d_poly *new = malloc(sizeof(struct phys2d_poly));
|
struct phys2d_poly *new = malloc(sizeof(struct phys2d_poly));
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ struct phys2d_poly *Make2DPoly(struct mGameObject *go)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
void phys2d_polyinit(struct phys2d_poly *poly, struct mGameObject *go)
|
void phys2d_polyinit(struct phys2d_poly *poly, struct gameobject *go)
|
||||||
{
|
{
|
||||||
cpTransform T = { 0 };
|
cpTransform T = { 0 };
|
||||||
poly->shape.shape =
|
poly->shape.shape =
|
||||||
|
@ -211,7 +211,7 @@ void poly_gui(struct phys2d_poly *poly)
|
||||||
phys2d_applypoly(poly);
|
phys2d_applypoly(poly);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct phys2d_edge *Make2DEdge(struct mGameObject *go)
|
struct phys2d_edge *Make2DEdge(struct gameobject *go)
|
||||||
{
|
{
|
||||||
struct phys2d_edge *new = malloc(sizeof(struct phys2d_edge));
|
struct phys2d_edge *new = malloc(sizeof(struct phys2d_edge));
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ struct phys2d_edge *Make2DEdge(struct mGameObject *go)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
void phys2d_edgeinit(struct phys2d_edge *edge, struct mGameObject *go)
|
void phys2d_edgeinit(struct phys2d_edge *edge, struct gameobject *go)
|
||||||
{
|
{
|
||||||
edge->shapes[0] =
|
edge->shapes[0] =
|
||||||
cpSpaceAddShape(space,
|
cpSpaceAddShape(space,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <chipmunk/chipmunk.h>
|
#include <chipmunk/chipmunk.h>
|
||||||
|
|
||||||
|
|
||||||
struct mGameObject;
|
struct gameobject;
|
||||||
|
|
||||||
extern cpBody *ballBody;
|
extern cpBody *ballBody;
|
||||||
extern float phys2d_gravity;
|
extern float phys2d_gravity;
|
||||||
|
@ -13,7 +13,7 @@ extern cpSpace *space;
|
||||||
|
|
||||||
struct phys2d_shape {
|
struct phys2d_shape {
|
||||||
cpShape *shape;
|
cpShape *shape;
|
||||||
struct mGameObject *go;
|
struct gameobject *go;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct phys2d_circle {
|
struct phys2d_circle {
|
||||||
|
@ -52,37 +52,37 @@ struct phys2d_poly {
|
||||||
struct phys2d_shape shape;
|
struct phys2d_shape shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct phys2d_circle *Make2DCircle(struct mGameObject *go);
|
struct phys2d_circle *Make2DCircle(struct gameobject *go);
|
||||||
void phys2d_circleinit(struct phys2d_circle *circle, struct mGameObject *go);
|
void phys2d_circleinit(struct phys2d_circle *circle, struct gameobject *go);
|
||||||
void phys2d_circledel(struct phys2d_circle *c);
|
void phys2d_circledel(struct phys2d_circle *c);
|
||||||
void phys2d_applycircle(struct phys2d_circle *circle);
|
void phys2d_applycircle(struct phys2d_circle *circle);
|
||||||
void phys2d_dbgdrawcircle(struct phys2d_circle *circle);
|
void phys2d_dbgdrawcircle(struct phys2d_circle *circle);
|
||||||
void circle_gui(struct phys2d_circle *circle);
|
void circle_gui(struct phys2d_circle *circle);
|
||||||
|
|
||||||
struct phys2d_segment *Make2DSegment(struct mGameObject *go);
|
struct phys2d_segment *Make2DSegment(struct gameobject *go);
|
||||||
void phys2d_seginit(struct phys2d_segment *seg, struct mGameObject *go);
|
void phys2d_seginit(struct phys2d_segment *seg, struct gameobject *go);
|
||||||
void phys2d_segdel(struct phys2d_segment *seg);
|
void phys2d_segdel(struct phys2d_segment *seg);
|
||||||
void phys2d_applyseg(struct phys2d_segment *seg);
|
void phys2d_applyseg(struct phys2d_segment *seg);
|
||||||
void phys2d_dbgdrawseg(struct phys2d_segment *seg);
|
void phys2d_dbgdrawseg(struct phys2d_segment *seg);
|
||||||
void segment_gui(struct phys2d_segment *seg);
|
void segment_gui(struct phys2d_segment *seg);
|
||||||
|
|
||||||
struct phys2d_box *Make2DBox(struct mGameObject *go);
|
struct phys2d_box *Make2DBox(struct gameobject *go);
|
||||||
void phys2d_boxinit(struct phys2d_box *box, struct mGameObject *go);
|
void phys2d_boxinit(struct phys2d_box *box, struct gameobject *go);
|
||||||
void phys2d_boxdel(struct phys2d_box *box);
|
void phys2d_boxdel(struct phys2d_box *box);
|
||||||
void phys2d_applybox(struct phys2d_box *box);
|
void phys2d_applybox(struct phys2d_box *box);
|
||||||
void phys2d_dbgdrawbox(struct phys2d_box *box);
|
void phys2d_dbgdrawbox(struct phys2d_box *box);
|
||||||
void box_gui(struct phys2d_box *box);
|
void box_gui(struct phys2d_box *box);
|
||||||
|
|
||||||
struct phys2d_poly *Make2DPoly(struct mGameObject *go);
|
struct phys2d_poly *Make2DPoly(struct gameobject *go);
|
||||||
void phys2d_polyinit(struct phys2d_poly *poly, struct mGameObject *go);
|
void phys2d_polyinit(struct phys2d_poly *poly, struct gameobject *go);
|
||||||
void phys2d_polydel(struct phys2d_poly *poly);
|
void phys2d_polydel(struct phys2d_poly *poly);
|
||||||
void phys2d_applypoly(struct phys2d_poly *poly);
|
void phys2d_applypoly(struct phys2d_poly *poly);
|
||||||
void phys2d_dbgdrawpoly(struct phys2d_poly *poly);
|
void phys2d_dbgdrawpoly(struct phys2d_poly *poly);
|
||||||
void phys2d_polyaddvert(struct phys2d_poly *poly);
|
void phys2d_polyaddvert(struct phys2d_poly *poly);
|
||||||
void poly_gui(struct phys2d_poly *poly);
|
void poly_gui(struct phys2d_poly *poly);
|
||||||
|
|
||||||
struct phys2d_edge *Make2DEdge(struct mGameObject *go);
|
struct phys2d_edge *Make2DEdge(struct gameobject *go);
|
||||||
void phys2d_edgeinit(struct phys2d_edge *edge, struct mGameObject *go);
|
void phys2d_edgeinit(struct phys2d_edge *edge, struct gameobject *go);
|
||||||
void phys2d_edgedel(struct phys2d_edge *edge);
|
void phys2d_edgedel(struct phys2d_edge *edge);
|
||||||
void phys2d_applyedge(struct phys2d_edge *edge);
|
void phys2d_applyedge(struct phys2d_edge *edge);
|
||||||
void phys2d_edgeshapeapply(struct phys2d_shape *mshape, cpShape * shape);
|
void phys2d_edgeshapeapply(struct phys2d_shape *mshape, cpShape * shape);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "limits.h"
|
#include "limits.h"
|
||||||
#include "iir.h"
|
#include "iir.h"
|
||||||
|
|
||||||
struct mShader *vid_shader;
|
struct shader *vid_shader;
|
||||||
|
|
||||||
static void ds_update_texture(uint32_t unit, uint32_t texture, plm_plane_t * plane)
|
static void ds_update_texture(uint32_t unit, uint32_t texture, plm_plane_t * plane)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct soundstream;
|
||||||
|
|
||||||
struct datastream {
|
struct datastream {
|
||||||
plm_t *plm;
|
plm_t *plm;
|
||||||
struct mShader *shader;
|
struct shader *shader;
|
||||||
double last_time;
|
double last_time;
|
||||||
int playing;
|
int playing;
|
||||||
int audio_device;
|
int audio_device;
|
||||||
|
@ -20,7 +20,7 @@ struct datastream {
|
||||||
|
|
||||||
struct Texture;
|
struct Texture;
|
||||||
|
|
||||||
extern struct mShader *vid_shader;
|
extern struct shader *vid_shader;
|
||||||
|
|
||||||
struct datastream *MakeDatastream();
|
struct datastream *MakeDatastream();
|
||||||
void ds_openvideo(struct datastream *ds, const char *path, const char *adriver);
|
void ds_openvideo(struct datastream *ds, const char *path, const char *adriver);
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
|
|
||||||
static uint32_t circleVBO;
|
static uint32_t circleVBO;
|
||||||
static uint32_t circleVAO;
|
static uint32_t circleVAO;
|
||||||
static struct mShader *circleShader;
|
static struct shader *circleShader;
|
||||||
|
|
||||||
static uint32_t gridVBO;
|
static uint32_t gridVBO;
|
||||||
static uint32_t gridVAO;
|
static uint32_t gridVAO;
|
||||||
static struct mShader *gridShader;
|
static struct shader *gridShader;
|
||||||
|
|
||||||
static uint32_t rectVBO;
|
static uint32_t rectVBO;
|
||||||
static uint32_t rectVAO;
|
static uint32_t rectVAO;
|
||||||
static struct mShader *rectShader;
|
static struct shader *rectShader;
|
||||||
|
|
||||||
void debugdraw_init()
|
void debugdraw_init()
|
||||||
{
|
{
|
||||||
|
|
|
@ -974,10 +974,10 @@ void editor_asset_gui(struct fileasset *asset) {
|
||||||
|
|
||||||
void editor_makenewobject() {}
|
void editor_makenewobject() {}
|
||||||
|
|
||||||
int obj_gui_hierarchy(struct mGameObject *selected) {
|
int obj_gui_hierarchy(struct gameobject *selected) {
|
||||||
|
|
||||||
for (int i = 0; i < arrlen(gameobjects); i++) {
|
for (int i = 0; i < arrlen(gameobjects); i++) {
|
||||||
struct mGameObject *go = &gameobjects[i];
|
struct gameobject *go = &gameobjects[i];
|
||||||
|
|
||||||
if (nk_select_label(ctx, go->editor.mname, NK_TEXT_LEFT, go == selected)) {
|
if (nk_select_label(ctx, go->editor.mname, NK_TEXT_LEFT, go == selected)) {
|
||||||
if (go != selected)
|
if (go != selected)
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct editorVars {
|
||||||
nk_flags asset_srch;
|
nk_flags asset_srch;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mGameObject;
|
struct gameobject;
|
||||||
|
|
||||||
extern int show_desktop;
|
extern int show_desktop;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void game_pause();
|
||||||
|
|
||||||
void get_levels();
|
void get_levels();
|
||||||
|
|
||||||
int obj_gui_hierarchy(struct mGameObject *selected);
|
int obj_gui_hierarchy(struct gameobject *selected);
|
||||||
|
|
||||||
void sprite_gui(struct sprite *sprite);
|
void sprite_gui(struct sprite *sprite);
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
#define PL_MPEG_IMPLEMENTATION
|
#define PL_MPEG_IMPLEMENTATION
|
||||||
#include <pl_mpeg.h>
|
#include <pl_mpeg.h>
|
||||||
|
|
||||||
#define STB_
|
|
||||||
|
|
||||||
#ifdef EDITOR
|
#ifdef EDITOR
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,9 +19,9 @@ unsigned char ttf_buffer[1<<25];
|
||||||
unsigned char temp_bitmap[512 * 512];
|
unsigned char temp_bitmap[512 * 512];
|
||||||
|
|
||||||
struct sFont *font;
|
struct sFont *font;
|
||||||
static struct mShader *shader;
|
static struct shader *shader;
|
||||||
|
|
||||||
void font_init(struct mShader *textshader) {
|
void font_init(struct shader *textshader) {
|
||||||
shader = textshader;
|
shader = textshader;
|
||||||
|
|
||||||
shader_use(shader);
|
shader_use(shader);
|
||||||
|
@ -108,7 +108,7 @@ struct sFont *MakeFont(const char *fontfile, int height)
|
||||||
return newfont;
|
return newfont;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct mShader *shader, float color[3])
|
void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct shader *shader, float color[3])
|
||||||
{
|
{
|
||||||
float w = c.Size[0] * scale;
|
float w = c.Size[0] * scale;
|
||||||
float h = c.Size[1] * scale;
|
float h = c.Size[1] * scale;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "mathc.h"
|
#include "mathc.h"
|
||||||
|
|
||||||
struct mShader;
|
struct shader;
|
||||||
struct window;
|
struct window;
|
||||||
|
|
||||||
/// Holds all state information relevant to a character as loaded using FreeType
|
/// Holds all state information relevant to a character as loaded using FreeType
|
||||||
|
@ -22,10 +22,10 @@ struct sFont {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void font_init(struct mShader *s);
|
void font_init(struct shader *s);
|
||||||
void font_frame(struct window *w);
|
void font_frame(struct window *w);
|
||||||
struct sFont *MakeFont(const char *fontfile, int height);
|
struct sFont *MakeFont(const char *fontfile, int height);
|
||||||
void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct mShader *shader, float color[3]);
|
void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct shader *shader, float color[3]);
|
||||||
void text_settype(struct sFont *font);
|
void text_settype(struct sFont *font);
|
||||||
void renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw);
|
void renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw);
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,17 @@
|
||||||
|
|
||||||
#include "stb_ds.h"
|
#include "stb_ds.h"
|
||||||
|
|
||||||
struct mGameObject *gameobjects = NULL;
|
struct gameobject *gameobjects = NULL;
|
||||||
|
|
||||||
const int nameBuf[MAXNAME] = { 0 };
|
const int nameBuf[MAXNAME] = { 0 };
|
||||||
const int prefabNameBuf[MAXNAME] = { 0 };
|
const int prefabNameBuf[MAXNAME] = { 0 };
|
||||||
|
|
||||||
struct mGameObject *get_gameobject_from_id(int id)
|
struct gameobject *get_gameobject_from_id(int id)
|
||||||
{
|
{
|
||||||
return &gameobjects[id];
|
return &gameobjects[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gameobject_setpickcolor(struct mGameObject *go)
|
static void gameobject_setpickcolor(struct gameobject *go)
|
||||||
{
|
{
|
||||||
float r = ((go->editor.id & 0x000000FF) >> 0) / 255.f;
|
float r = ((go->editor.id & 0x000000FF) >> 0) / 255.f;
|
||||||
float g = ((go->editor.id & 0x0000FF00) >> 8) / 255.f;
|
float g = ((go->editor.id & 0x0000FF00) >> 8) / 255.f;
|
||||||
|
@ -35,10 +35,10 @@ static void gameobject_setpickcolor(struct mGameObject *go)
|
||||||
go->editor.color[2] = b;
|
go->editor.color[2] = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mGameObject *MakeGameobject()
|
struct gameobject *MakeGameobject()
|
||||||
{
|
{
|
||||||
YughInfo("Making new gameobject");
|
YughInfo("Making new gameobject");
|
||||||
struct mGameObject go = {
|
struct gameobject go = {
|
||||||
.editor.id = arrlen(gameobjects),
|
.editor.id = arrlen(gameobjects),
|
||||||
.transform.scale = 1.f,
|
.transform.scale = 1.f,
|
||||||
.scale = 1.f,
|
.scale = 1.f,
|
||||||
|
@ -55,7 +55,7 @@ struct mGameObject *MakeGameobject()
|
||||||
return &arrlast(gameobjects);
|
return &arrlast(gameobjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameobject_addcomponent(struct mGameObject *go, struct component *c)
|
void gameobject_addcomponent(struct gameobject *go, struct component *c)
|
||||||
{
|
{
|
||||||
arrput(go->components, *c);
|
arrput(go->components, *c);
|
||||||
struct component *newc = &arrlast(go->components);
|
struct component *newc = &arrlast(go->components);
|
||||||
|
@ -65,23 +65,25 @@ void gameobject_addcomponent(struct mGameObject *go, struct component *c)
|
||||||
|
|
||||||
void gameobject_delete(int id)
|
void gameobject_delete(int id)
|
||||||
{
|
{
|
||||||
struct mGameObject *go = &gameobjects[id];
|
YughInfo("Deleting gameobject with id %d.", id);
|
||||||
|
struct gameobject *go = &gameobjects[id];
|
||||||
for (int i = 0; i < arrlen(go->components); i++) {
|
for (int i = 0; i < arrlen(go->components); i++) {
|
||||||
free(go->components[i].data);
|
go->components[i].delete(go->components[i].data);
|
||||||
|
arrdel(go->components, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
arrfree(go->components);
|
|
||||||
|
|
||||||
arrdelswap(gameobjects, id);
|
arrdelswap(gameobjects, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameobject_delcomponent(struct mGameObject *go, int n)
|
void gameobject_delcomponent(struct gameobject *go, int n)
|
||||||
{
|
{
|
||||||
go->components[n].delete(go->components[n].data);
|
go->components[n].delete(go->components[n].data);
|
||||||
arrdel(go->components, n);
|
arrdel(go->components, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_model_transform(struct mTransform *t, struct mShader *s, float scale)
|
void setup_model_transform(struct mTransform *t, struct shader *s, float scale)
|
||||||
{
|
{
|
||||||
mfloat_t modelT[16] = { 0.f };
|
mfloat_t modelT[16] = { 0.f };
|
||||||
mfloat_t matbuff[16] = { 0.f };
|
mfloat_t matbuff[16] = { 0.f };
|
||||||
|
@ -93,7 +95,7 @@ void setup_model_transform(struct mTransform *t, struct mShader *s, float scale)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameobject_save(struct mGameObject *go, FILE * file)
|
void gameobject_save(struct gameobject *go, FILE * file)
|
||||||
{
|
{
|
||||||
fwrite(go, sizeof(*go), 1, file);
|
fwrite(go, sizeof(*go), 1, file);
|
||||||
|
|
||||||
|
@ -118,7 +120,7 @@ void gameobject_makefromprefab(char *path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mGameObject *new = MakeGameobject();
|
struct gameobject *new = MakeGameobject();
|
||||||
fread(new, sizeof(*new), 1, fprefab);
|
fread(new, sizeof(*new), 1, fprefab);
|
||||||
new->components = NULL;
|
new->components = NULL;
|
||||||
|
|
||||||
|
@ -127,21 +129,28 @@ void gameobject_makefromprefab(char *path)
|
||||||
fclose(fprefab);
|
fclose(fprefab);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameobject_init(struct mGameObject *go, FILE * fprefab)
|
void gameobject_init(struct gameobject *go, FILE * fprefab)
|
||||||
{
|
{
|
||||||
go->body = cpSpaceAddBody(space, cpBodyNew(go->mass, 1.f));
|
go->body = cpSpaceAddBody(space, cpBodyNew(go->mass, 1.f));
|
||||||
|
|
||||||
int comp_n;
|
int comp_n;
|
||||||
fread(&comp_n, sizeof(int), 1, fprefab);
|
fread(&comp_n, sizeof(int), 1, fprefab);
|
||||||
arrsetlen(go->components, comp_n);
|
arrfree(go->components);
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for (int i = 0; i < comp_n; i++) {
|
for (int i = 0; i < comp_n; i++) {
|
||||||
|
/*
|
||||||
fread(&n, sizeof(int), 1, fprefab);
|
fread(&n, sizeof(int), 1, fprefab);
|
||||||
go->components[i] = components[n];
|
go->components[i] = components[n];
|
||||||
struct component *newc = &go->components[i];
|
struct component *newc = &go->components[i];
|
||||||
newc->go = go;
|
newc->go = go;
|
||||||
newc->data = calloc(1, newc->datasize);
|
newc->data = calloc(1, newc->datasize);
|
||||||
|
*/
|
||||||
|
fread(&n, sizeof(int), 1, fprefab);
|
||||||
|
arrput(go->components, components[n]);
|
||||||
|
struct component *newc = &arrlast(go->components);
|
||||||
|
newc->go = go;
|
||||||
|
newc->data = newc->make(newc->go);
|
||||||
|
|
||||||
if (newc->io == NULL)
|
if (newc->io == NULL)
|
||||||
fread(newc->data, newc->datasize, 1, fprefab);
|
fread(newc->data, newc->datasize, 1, fprefab);
|
||||||
|
@ -152,7 +161,7 @@ void gameobject_init(struct mGameObject *go, FILE * fprefab)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameobject_saveprefab(struct mGameObject *go)
|
void gameobject_saveprefab(struct gameobject *go)
|
||||||
{
|
{
|
||||||
char prefabfname[60] = { '\0' };
|
char prefabfname[60] = { '\0' };
|
||||||
strncat(prefabfname, go->editor.prefabName, MAXNAME);
|
strncat(prefabfname, go->editor.prefabName, MAXNAME);
|
||||||
|
@ -171,7 +180,7 @@ void gameobject_saveprefab(struct mGameObject *go)
|
||||||
void gameobject_syncprefabs(char *revertPath)
|
void gameobject_syncprefabs(char *revertPath)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
struct mGameObject **go = objects;
|
struct gameobject **go = objects;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(i != nobjects) {
|
while(i != nobjects) {
|
||||||
if ((*go)->editor.curPrefabPath && !strcmp((*go)->editor.curPrefabPath, revertPath)) { ; }//objectRevertPrefab(go); //TODO: revertprefab
|
if ((*go)->editor.curPrefabPath && !strcmp((*go)->editor.curPrefabPath, revertPath)) { ; }//objectRevertPrefab(go); //TODO: revertprefab
|
||||||
|
@ -179,12 +188,12 @@ void gameobject_syncprefabs(char *revertPath)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameobject_revertprefab(struct mGameObject *go)
|
void gameobject_revertprefab(struct gameobject *go)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleprefab(struct mGameObject *go)
|
void toggleprefab(struct gameobject *go)
|
||||||
{
|
{
|
||||||
go->editor.prefabSync = !go->editor.prefabSync;
|
go->editor.prefabSync = !go->editor.prefabSync;
|
||||||
|
|
||||||
|
@ -196,13 +205,13 @@ void toggleprefab(struct mGameObject *go)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameobject_update(struct mGameObject *go)
|
void gameobject_update(struct gameobject *go)
|
||||||
{
|
{
|
||||||
if (go->script)
|
if (go->script)
|
||||||
script_run(go->script);
|
script_run(go->script);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameobject_move(struct mGameObject *go, float xs, float ys)
|
void gameobject_move(struct gameobject *go, float xs, float ys)
|
||||||
{
|
{
|
||||||
cpVect p = cpBodyGetPosition(go->body);
|
cpVect p = cpBodyGetPosition(go->body);
|
||||||
p.x += xs * deltaT;
|
p.x += xs * deltaT;
|
||||||
|
@ -210,7 +219,7 @@ void gameobject_move(struct mGameObject *go, float xs, float ys)
|
||||||
cpBodySetPosition(go->body, p);
|
cpBodySetPosition(go->body, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameobject_rotate(struct mGameObject *go, float as)
|
void gameobject_rotate(struct gameobject *go, float as)
|
||||||
{
|
{
|
||||||
cpFloat a = cpBodyGetAngle(go->body);
|
cpFloat a = cpBodyGetAngle(go->body);
|
||||||
a += as * deltaT;
|
a += as * deltaT;
|
||||||
|
@ -223,7 +232,7 @@ void update_gameobjects() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void object_gui(struct mGameObject *go)
|
void object_gui(struct gameobject *go)
|
||||||
{
|
{
|
||||||
float temp_pos[2];
|
float temp_pos[2];
|
||||||
temp_pos[0] = cpBodyGetPosition(go->body).x;
|
temp_pos[0] = cpBodyGetPosition(go->body).x;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <chipmunk/chipmunk.h>
|
#include <chipmunk/chipmunk.h>
|
||||||
|
|
||||||
struct mShader;
|
struct shader;
|
||||||
struct sprite;
|
struct sprite;
|
||||||
struct component;
|
struct component;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ struct editor {
|
||||||
char rootPrefabName[MAXNAME];
|
char rootPrefabName[MAXNAME];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mGameObject {
|
struct gameobject {
|
||||||
struct mTransform transform;
|
struct mTransform transform;
|
||||||
struct editor editor;
|
struct editor editor;
|
||||||
cpBodyType bodytype;
|
cpBodyType bodytype;
|
||||||
|
@ -36,35 +36,35 @@ struct mGameObject {
|
||||||
char *script;
|
char *script;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct mGameObject *gameobjects;
|
extern struct gameobject *gameobjects;
|
||||||
|
|
||||||
struct mGameObject *MakeGameobject();
|
struct gameobject *MakeGameobject();
|
||||||
void init_gameobjects();
|
void init_gameobjects();
|
||||||
void gameobject_delete(int id);
|
void gameobject_delete(int id);
|
||||||
void clear_gameobjects();
|
void clear_gameobjects();
|
||||||
int number_of_gameobjects();
|
int number_of_gameobjects();
|
||||||
void set_n_gameobjects(int n);
|
void set_n_gameobjects(int n);
|
||||||
void setup_model_transform(struct mTransform *t, struct mShader *s, float scale);
|
void setup_model_transform(struct mTransform *t, struct shader *s, float scale);
|
||||||
void toggleprefab(struct mGameObject *go);
|
void toggleprefab(struct gameobject *go);
|
||||||
struct mGameObject *get_gameobject_from_id(int id);
|
struct gameobject *get_gameobject_from_id(int id);
|
||||||
void gameobject_save(struct mGameObject *go, FILE * file);
|
void gameobject_save(struct gameobject *go, FILE * file);
|
||||||
void gameobject_addcomponent(struct mGameObject *go, struct component *c);
|
void gameobject_addcomponent(struct gameobject *go, struct component *c);
|
||||||
void gameobject_delcomponent(struct mGameObject *go, int n);
|
void gameobject_delcomponent(struct gameobject *go, int n);
|
||||||
void gameobject_loadcomponent(struct mGameObject *go, int id);
|
void gameobject_loadcomponent(struct gameobject *go, int id);
|
||||||
|
|
||||||
void gameobject_saveprefab(struct mGameObject *go);
|
void gameobject_saveprefab(struct gameobject *go);
|
||||||
void gameobject_makefromprefab(char *path);
|
void gameobject_makefromprefab(char *path);
|
||||||
void gameobject_syncprefabs(char *revertPath);
|
void gameobject_syncprefabs(char *revertPath);
|
||||||
void gameobject_revertprefab(struct mGameObject *go);
|
void gameobject_revertprefab(struct gameobject *go);
|
||||||
|
|
||||||
void gameobject_init(struct mGameObject *go, FILE * fprefab);
|
void gameobject_init(struct gameobject *go, FILE * fprefab);
|
||||||
|
|
||||||
void gameobject_update(struct mGameObject *go);
|
void gameobject_update(struct gameobject *go);
|
||||||
void update_gameobjects();
|
void update_gameobjects();
|
||||||
|
|
||||||
void gameobject_move(struct mGameObject *go, float xs, float ys);
|
void gameobject_move(struct gameobject *go, float xs, float ys);
|
||||||
void gameobject_rotate(struct mGameObject *go, float as);
|
void gameobject_rotate(struct gameobject *go, float as);
|
||||||
|
|
||||||
void object_gui(struct mGameObject *go);
|
void object_gui(struct gameobject *go);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,8 +36,8 @@ void load_level(char name[MAXNAME])
|
||||||
arraddn(gameobjects, objs);
|
arraddn(gameobjects, objs);
|
||||||
|
|
||||||
for (int i = 0; i < objs; i++) {
|
for (int i = 0; i < objs; i++) {
|
||||||
struct mGameObject *go = &gameobjects[i];
|
struct gameobject *go = &gameobjects[i];
|
||||||
fread(go, sizeof(struct mGameObject), 1, lfile);
|
fread(go, sizeof(struct gameobject), 1, lfile);
|
||||||
go->components = NULL;
|
go->components = NULL;
|
||||||
gameobject_init(go, lfile);
|
gameobject_init(go, lfile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ struct mDirectionalLight *MakeDLight()
|
||||||
}
|
}
|
||||||
|
|
||||||
void dlight_prepshader(struct mDirectionalLight *light,
|
void dlight_prepshader(struct mDirectionalLight *light,
|
||||||
struct mShader *shader)
|
struct shader *shader)
|
||||||
{
|
{
|
||||||
mfloat_t fwd[3] = { 0.f };
|
mfloat_t fwd[3] = { 0.f };
|
||||||
trans_forward(fwd, &light->light.obj.transform);
|
trans_forward(fwd, &light->light.obj.transform);
|
||||||
|
@ -79,14 +79,14 @@ static void prepstring(char *buffer, char *prepend, const char *append)
|
||||||
snprintf(buffer, 100, "%s%s", prepend, append);
|
snprintf(buffer, 100, "%s%s", prepend, append);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pointlights_prepshader(struct mShader *shader)
|
void pointlights_prepshader(struct shader *shader)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numLights; i++)
|
for (int i = 0; i < numLights; i++)
|
||||||
pointlight_prepshader(pointLights[i], shader, i);
|
pointlight_prepshader(pointLights[i], shader, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pointlight_prepshader(struct mPointLight *light,
|
void pointlight_prepshader(struct mPointLight *light,
|
||||||
struct mShader *shader, int num)
|
struct shader *shader, int num)
|
||||||
{
|
{
|
||||||
shader_use(shader);
|
shader_use(shader);
|
||||||
char prepend[100] = { '\0' };
|
char prepend[100] = { '\0' };
|
||||||
|
@ -132,13 +132,13 @@ struct mSpotLight *MakeSpotlight()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void spotlights_prepshader(struct mShader *shader)
|
void spotlights_prepshader(struct shader *shader)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numSpots; i++)
|
for (int i = 0; i < numSpots; i++)
|
||||||
spotlight_prepshader(spotLights[i], shader, i);
|
spotlight_prepshader(spotLights[i], shader, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spotlight_prepshader(struct mSpotLight *light, struct mShader *shader,
|
void spotlight_prepshader(struct mSpotLight *light, struct shader *shader,
|
||||||
int num)
|
int num)
|
||||||
{
|
{
|
||||||
mfloat_t fwd[3] = { 0.f };
|
mfloat_t fwd[3] = { 0.f };
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct mLight {
|
struct mLight {
|
||||||
struct mGameObject *go;
|
struct gameobject *go;
|
||||||
uint8_t color[3];
|
uint8_t color[3];
|
||||||
float strength;
|
float strength;
|
||||||
int dynamic;
|
int dynamic;
|
||||||
|
@ -21,8 +21,8 @@ struct mPointLight {
|
||||||
|
|
||||||
struct mPointLight *MakePointlight();
|
struct mPointLight *MakePointlight();
|
||||||
void pointlight_prepshader(struct mPointLight *light,
|
void pointlight_prepshader(struct mPointLight *light,
|
||||||
struct mShader *shader, int num);
|
struct shader *shader, int num);
|
||||||
void pointlights_prepshader(struct mShader *shader);
|
void pointlights_prepshader(struct shader *shader);
|
||||||
|
|
||||||
|
|
||||||
struct mSpotLight {
|
struct mSpotLight {
|
||||||
|
@ -38,9 +38,9 @@ struct mSpotLight {
|
||||||
|
|
||||||
struct mSpotLight *MakeSpotlight();
|
struct mSpotLight *MakeSpotlight();
|
||||||
void spotlight_gui(struct mSpotLight *light);
|
void spotlight_gui(struct mSpotLight *light);
|
||||||
void spotlight_prepshader(struct mSpotLight *light, struct mShader *shader,
|
void spotlight_prepshader(struct mSpotLight *light, struct shader *shader,
|
||||||
int num);
|
int num);
|
||||||
void spotlights_prepshader(struct mShader *shader);
|
void spotlights_prepshader(struct shader *shader);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ struct mDirectionalLight {
|
||||||
};
|
};
|
||||||
|
|
||||||
void dlight_prepshader(struct mDirectionalLight *light,
|
void dlight_prepshader(struct mDirectionalLight *light,
|
||||||
struct mShader *shader);
|
struct shader *shader);
|
||||||
struct mDirectionalLight *MakeDLight();
|
struct mDirectionalLight *MakeDLight();
|
||||||
|
|
||||||
extern struct mDirectionalLight *dLight;
|
extern struct mDirectionalLight *dLight;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void DrawMesh(struct mMesh *mesh, struct mShader *shader)
|
void DrawMesh(struct mesh *mesh, struct shader *shader)
|
||||||
{
|
{
|
||||||
// bind appropriate textures
|
// bind appropriate textures
|
||||||
uint32_t diffuseNr = 1;
|
uint32_t diffuseNr = 1;
|
||||||
|
@ -49,17 +49,17 @@ void DrawMesh(struct mMesh *mesh, struct mShader *shader)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawMeshAgain(struct mMesh *mesh)
|
void DrawMeshAgain(struct mesh *mesh)
|
||||||
{
|
{
|
||||||
glDrawElements(GL_TRIANGLES, (mesh->ie - mesh->indices),
|
glDrawElements(GL_TRIANGLES, (mesh->ie - mesh->indices),
|
||||||
GL_UNSIGNED_INT, 0);
|
GL_UNSIGNED_INT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mMesh *MakeMesh(struct Vertex *vertices, struct Vertex *ve,
|
struct mesh *MakeMesh(struct Vertex *vertices, struct Vertex *ve,
|
||||||
uint32_t * indices, uint32_t * ie,
|
uint32_t * indices, uint32_t * ie,
|
||||||
struct Texture *textures, struct Texture *te)
|
struct Texture *textures, struct Texture *te)
|
||||||
{
|
{
|
||||||
struct mMesh *newmesh = (struct mMesh *) malloc(sizeof(struct mMesh));
|
struct mesh *newmesh = (struct mesh *) malloc(sizeof(struct mesh));
|
||||||
newmesh->vertices = vertices;
|
newmesh->vertices = vertices;
|
||||||
newmesh->ve = ve;
|
newmesh->ve = ve;
|
||||||
newmesh->indices = indices;
|
newmesh->indices = indices;
|
||||||
|
@ -71,7 +71,7 @@ struct mMesh *MakeMesh(struct Vertex *vertices, struct Vertex *ve,
|
||||||
return newmesh;
|
return newmesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupmesh(struct mMesh *mesh)
|
void setupmesh(struct mesh *mesh)
|
||||||
{
|
{
|
||||||
// create buffers/arrays
|
// create buffers/arrays
|
||||||
glGenVertexArrays(1, &mesh->VAO);
|
glGenVertexArrays(1, &mesh->VAO);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "mathc.h"
|
#include "mathc.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct mShader;
|
struct shader;
|
||||||
struct Texture;
|
struct Texture;
|
||||||
|
|
||||||
#define MAX_BONE_INFLUENCE 4
|
#define MAX_BONE_INFLUENCE 4
|
||||||
|
@ -21,7 +21,7 @@ struct Vertex {
|
||||||
float m_Weights[MAX_BONE_INFLUENCE];
|
float m_Weights[MAX_BONE_INFLUENCE];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mMesh {
|
struct mesh {
|
||||||
struct Vertex *vertices;
|
struct Vertex *vertices;
|
||||||
struct Vertex *ve;
|
struct Vertex *ve;
|
||||||
uint32_t *indices;
|
uint32_t *indices;
|
||||||
|
@ -31,11 +31,11 @@ struct mMesh {
|
||||||
uint32_t VAO, VBO, EBO;
|
uint32_t VAO, VBO, EBO;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mMesh *MakeMesh(struct Vertex *vertices, struct Vertex *ve,
|
struct mesh *MakeMesh(struct Vertex *vertices, struct Vertex *ve,
|
||||||
uint32_t * indices, uint32_t * ie,
|
uint32_t * indices, uint32_t * ie,
|
||||||
struct Texture *textures, struct Texture *te);
|
struct Texture *textures, struct Texture *te);
|
||||||
void setupmesh(struct mMesh *mesh); /* Loads mesh into the GPU */
|
void setupmesh(struct mesh *mesh); /* Loads mesh into the GPU */
|
||||||
void DrawMesh(struct mMesh *mesh, struct mShader *shader);
|
void DrawMesh(struct mesh *mesh, struct shader *shader);
|
||||||
void DrawMeshAgain(struct mMesh *mesh); /* Draws whatever mesh was drawn last */
|
void DrawMeshAgain(struct mesh *mesh); /* Draws whatever mesh was drawn last */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,18 +8,18 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static struct mModel *lastRendered;
|
static struct model *lastRendered;
|
||||||
static struct mModel *loadedModels[100];
|
static struct model *loadedModels[100];
|
||||||
static struct mModel **lastModel = loadedModels;
|
static struct model **lastModel = loadedModels;
|
||||||
|
|
||||||
static void processnode();
|
static void processnode();
|
||||||
static void processmesh();
|
static void processmesh();
|
||||||
static void processtexture();
|
static void processtexture();
|
||||||
|
|
||||||
|
|
||||||
struct mModel *GetExistingModel(const char *path)
|
struct model *GetExistingModel(const char *path)
|
||||||
{
|
{
|
||||||
struct mModel **model = loadedModels;
|
struct model **model = loadedModels;
|
||||||
|
|
||||||
while (model++ != lastModel) {
|
while (model++ != lastModel) {
|
||||||
if (!strcmp(path, (*model)->path))
|
if (!strcmp(path, (*model)->path))
|
||||||
|
@ -34,7 +34,7 @@ struct mModel *GetExistingModel(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Make this a hash compare for speedup */
|
/* TODO: Make this a hash compare for speedup */
|
||||||
struct mModel *MakeModel(const char *path)
|
struct model *MakeModel(const char *path)
|
||||||
{
|
{
|
||||||
char *modelPath =
|
char *modelPath =
|
||||||
(char *) malloc(sizeof(char) *
|
(char *) malloc(sizeof(char) *
|
||||||
|
@ -46,8 +46,8 @@ struct mModel *MakeModel(const char *path)
|
||||||
("Created new model with modelPath %s, from data_path %s and path %s\n",
|
("Created new model with modelPath %s, from data_path %s and path %s\n",
|
||||||
modelPath, DATA_PATH, path);
|
modelPath, DATA_PATH, path);
|
||||||
|
|
||||||
struct mModel *newmodel =
|
struct model *newmodel =
|
||||||
(struct mModel *) malloc(sizeof(struct mModel));
|
(struct model *) malloc(sizeof(struct model));
|
||||||
newmodel->path = path;
|
newmodel->path = path;
|
||||||
|
|
||||||
loadmodel(newmodel);
|
loadmodel(newmodel);
|
||||||
|
@ -56,7 +56,7 @@ struct mModel *MakeModel(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Come back to this; simple optimization
|
// TODO: Come back to this; simple optimization
|
||||||
void draw_model(struct mModel *model, struct mShader *shader)
|
void draw_model(struct model *model, struct shader *shader)
|
||||||
{
|
{
|
||||||
if (lastRendered != model) {
|
if (lastRendered != model) {
|
||||||
lastRendered = model;
|
lastRendered = model;
|
||||||
|
@ -68,7 +68,7 @@ void draw_model(struct mModel *model, struct mShader *shader)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadmodel(struct mModel *model)
|
void loadmodel(struct model *model)
|
||||||
{
|
{
|
||||||
YughInfo("Loading model at path %s", model->path);
|
YughInfo("Loading model at path %s", model->path);
|
||||||
/*
|
/*
|
||||||
|
@ -77,7 +77,7 @@ void loadmodel(struct mModel *model)
|
||||||
cgltf_data *data = NULL;
|
cgltf_data *data = NULL;
|
||||||
cgltf_result result = cgltf_parse_file(&options, model->path, &data);
|
cgltf_result result = cgltf_parse_file(&options, model->path, &data);
|
||||||
|
|
||||||
meshes = (struct mMesh*)malloc(sizeof(Mesh)*cgltf_data->meshes_count);
|
meshes = (struct mesh*)malloc(sizeof(Mesh)*cgltf_data->meshes_count);
|
||||||
|
|
||||||
directory = get_directory_from_path(model->path);
|
directory = get_directory_from_path(model->path);
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
#ifndef MODEL_H
|
#ifndef MODEL_H
|
||||||
#define MODEL_H
|
#define MODEL_H
|
||||||
|
|
||||||
struct mMesh;
|
struct mesh;
|
||||||
struct mShader;
|
struct shader;
|
||||||
|
|
||||||
struct mModel {
|
struct model {
|
||||||
struct mMesh *meshes;
|
struct mesh *meshes;
|
||||||
struct mMesh *mp;
|
struct mesh *mp;
|
||||||
char *directory;
|
char *directory;
|
||||||
const char *path;
|
const char *path;
|
||||||
char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Get the model at a path, or create and return if it doesn't exist */
|
/* Get the model at a path, or create and return if it doesn't exist */
|
||||||
struct mModel *GetExistingModel(const char *path);
|
struct model *GetExistingModel(const char *path);
|
||||||
|
|
||||||
/* Make a Model struct */
|
/* Make a Model struct */
|
||||||
struct mModel *MakeModel(const char *path);
|
struct model *MakeModel(const char *path);
|
||||||
|
|
||||||
/* Load a model from memory into the GPU */
|
/* Load a model from memory into the GPU */
|
||||||
void loadmodel(struct mModel *model);
|
void loadmodel(struct model *model);
|
||||||
|
|
||||||
void draw_model(struct mModel *model, struct mShader *shader);
|
void draw_model(struct model *model, struct shader *shader);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,21 +27,21 @@ static GLuint depthMapFBO = 0;
|
||||||
static GLuint depthMap = 0;
|
static GLuint depthMap = 0;
|
||||||
const unsigned int SHADOW_WIDTH = 2048, SHADOW_HEIGHT = 2048;
|
const unsigned int SHADOW_WIDTH = 2048, SHADOW_HEIGHT = 2048;
|
||||||
|
|
||||||
static struct mShader *outlineShader;
|
static struct shader *outlineShader;
|
||||||
static struct mShader *modelShader;
|
static struct shader *modelShader;
|
||||||
static struct mShader *shadowShader;
|
static struct shader *shadowShader;
|
||||||
|
|
||||||
struct mShader *spriteShader = NULL;
|
struct shader *spriteShader = NULL;
|
||||||
struct mShader *animSpriteShader = NULL;
|
struct shader *animSpriteShader = NULL;
|
||||||
static struct mShader *textShader;
|
static struct shader *textShader;
|
||||||
static struct mShader *diffuseShader;
|
static struct shader *diffuseShader;
|
||||||
|
|
||||||
struct sFont *stdFont;
|
struct sFont *stdFont;
|
||||||
|
|
||||||
static struct mShader *debugDepthQuad;
|
static struct shader *debugDepthQuad;
|
||||||
static struct mShader *debugColorPickShader;
|
static struct shader *debugColorPickShader;
|
||||||
static struct mShader *debugGridShader;
|
static struct shader *debugGridShader;
|
||||||
static struct mShader *debugGizmoShader;
|
static struct shader *debugGizmoShader;
|
||||||
|
|
||||||
struct mStaticActor *gizmo;
|
struct mStaticActor *gizmo;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ bool renderRefraction = true;
|
||||||
bool renderReflection = true;
|
bool renderReflection = true;
|
||||||
|
|
||||||
///// for editing
|
///// for editing
|
||||||
struct mGameObject *selectedobject = NULL;
|
struct gameobject *selectedobject = NULL;
|
||||||
char objectName[200] = { '\0' }; // object name buffer
|
char objectName[200] = { '\0' }; // object name buffer
|
||||||
|
|
||||||
GLuint debugColorPickBO = 0;
|
GLuint debugColorPickBO = 0;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
struct mCamera;
|
struct mCamera;
|
||||||
struct window;
|
struct window;
|
||||||
|
|
||||||
extern struct mShader *spriteShader;
|
extern struct shader *spriteShader;
|
||||||
extern struct mShader *animSpriteShader;
|
extern struct shader *animSpriteShader;
|
||||||
|
|
||||||
extern struct sprite *tsprite;
|
extern struct sprite *tsprite;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ extern float far_plane;
|
||||||
extern char objectName[];
|
extern char objectName[];
|
||||||
extern GLuint debugColorPickBO;
|
extern GLuint debugColorPickBO;
|
||||||
|
|
||||||
extern struct mGameObject *selectedobject;
|
extern struct gameobject *selectedobject;
|
||||||
|
|
||||||
enum RenderMode {
|
enum RenderMode {
|
||||||
LIT,
|
LIT,
|
||||||
|
|
|
@ -47,12 +47,12 @@ void registry_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_component(const char *name, size_t size,
|
void register_component(const char *name, size_t size,
|
||||||
void (*make)(struct mGameObject * go, struct component * c),
|
void (*make)(struct gameobject * go, struct component * c),
|
||||||
void (*delete)(void *data),
|
void (*delete)(void *data),
|
||||||
void (*io)(void *data, FILE *f, int read),
|
void (*io)(void *data, FILE *f, int read),
|
||||||
void(*draw_debug)(void *data),
|
void(*draw_debug)(void *data),
|
||||||
void(*draw_gui)(void *data),
|
void(*draw_gui)(void *data),
|
||||||
void(*init)(void *data, struct mGameObject * go))
|
void(*init)(void *data, struct gameobject * go))
|
||||||
{
|
{
|
||||||
struct component *c = &components[ncomponent++];
|
struct component *c = &components[ncomponent++];
|
||||||
c->name = name;
|
c->name = name;
|
||||||
|
|
|
@ -6,20 +6,20 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
struct mGameObject;
|
struct gameobject;
|
||||||
|
|
||||||
struct component {
|
struct component {
|
||||||
const char *name;
|
const char *name;
|
||||||
void *(*make)(struct mGameObject * go);
|
void *(*make)(struct gameobject * go); /* Called to create the component */
|
||||||
void (*io)(void *data, FILE *f, int read);
|
void (*io)(void *data, FILE *f, int read); /* Pulls data from a component file into the component */
|
||||||
void *data;
|
void *data;
|
||||||
struct mGameObject *go;
|
struct gameobject *go;
|
||||||
void (*draw_debug)(void *data);
|
void (*draw_debug)(void *data); /* Draw debugging info in editor */
|
||||||
void (*draw_gui)(void *data);
|
void (*draw_gui)(void *data); /* Use to draw GUI for editing the component in editor */
|
||||||
void (*delete)(void *data);
|
void (*delete)(void *data); /* Deletes and cleans up component */
|
||||||
int id;
|
int id;
|
||||||
int datasize;
|
int datasize;
|
||||||
void (*init)(void *data, struct mGameObject * go);
|
void (*init)(void *data, struct gameobject * go); /* Inits the component */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct component components[MAXNAME];
|
extern struct component components[MAXNAME];
|
||||||
|
@ -27,16 +27,16 @@ extern int ncomponent;
|
||||||
|
|
||||||
void comp_draw_debug(struct component *c);
|
void comp_draw_debug(struct component *c);
|
||||||
void comp_draw_gui(struct component *c);
|
void comp_draw_gui(struct component *c);
|
||||||
void comp_update(struct component *c, struct mGameObject *go);
|
void comp_update(struct component *c, struct gameobject *go);
|
||||||
|
|
||||||
|
|
||||||
void registry_init();
|
void registry_init();
|
||||||
void register_component(const char *name, size_t size,
|
void register_component(const char *name, size_t size,
|
||||||
void (*make)(struct mGameObject * go, struct component * c),
|
void (*make)(struct gameobject * go, struct component * c),
|
||||||
void (*delete)(void *data),
|
void (*delete)(void *data),
|
||||||
void (*io)(void *data, FILE *f, int read),
|
void (*io)(void *data, FILE *f, int read),
|
||||||
void(*draw_debug)(void *data),
|
void(*draw_debug)(void *data),
|
||||||
void(*draw_gui)(void *data),
|
void(*draw_gui)(void *data),
|
||||||
void(*init)(void *data, struct mGameObject * go));
|
void(*init)(void *data, struct gameobject * go));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
|
|
||||||
#define SHADER_BUF 10000
|
#define SHADER_BUF 10000
|
||||||
|
|
||||||
static struct mShader *shaders;
|
static struct shader *shaders;
|
||||||
|
|
||||||
struct mShader *MakeShader(const char *vertpath, const char *fragpath)
|
struct shader *MakeShader(const char *vertpath, const char *fragpath)
|
||||||
{
|
{
|
||||||
if (arrcap(shaders) == 0)
|
if (arrcap(shaders) == 0)
|
||||||
arrsetcap(shaders, 20);
|
arrsetcap(shaders, 20);
|
||||||
|
|
||||||
struct mShader init = {
|
struct shader init = {
|
||||||
.vertpath = vertpath,
|
.vertpath = vertpath,
|
||||||
.fragpath = fragpath };
|
.fragpath = fragpath };
|
||||||
shader_compile(&init);
|
shader_compile(&init);
|
||||||
|
@ -86,7 +86,7 @@ GLuint load_shader_from_file(const char *path, int type)
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_compile(struct mShader *shader)
|
void shader_compile(struct shader *shader)
|
||||||
{
|
{
|
||||||
YughInfo("Making shader with %s and %s.", shader->vertpath, shader->fragpath);
|
YughInfo("Making shader with %s and %s.", shader->vertpath, shader->fragpath);
|
||||||
|
|
||||||
|
@ -103,57 +103,57 @@ void shader_compile(struct mShader *shader)
|
||||||
glDeleteShader(frag);
|
glDeleteShader(frag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_use(struct mShader *shader)
|
void shader_use(struct shader *shader)
|
||||||
{
|
{
|
||||||
glUseProgram(shader->id);
|
glUseProgram(shader->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setbool(struct mShader *shader, const char *name, int val)
|
void shader_setbool(struct shader *shader, const char *name, int val)
|
||||||
{
|
{
|
||||||
glUniform1i(glGetUniformLocation(shader->id, name), val);
|
glUniform1i(glGetUniformLocation(shader->id, name), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setint(struct mShader *shader, const char *name, int val)
|
void shader_setint(struct shader *shader, const char *name, int val)
|
||||||
{
|
{
|
||||||
glUniform1i(glGetUniformLocation(shader->id, name), val);
|
glUniform1i(glGetUniformLocation(shader->id, name), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setfloat(struct mShader *shader, const char *name, float val)
|
void shader_setfloat(struct shader *shader, const char *name, float val)
|
||||||
{
|
{
|
||||||
glUniform1f(glGetUniformLocation(shader->id, name), val);
|
glUniform1f(glGetUniformLocation(shader->id, name), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setvec2(struct mShader *shader, const char *name, mfloat_t val[2])
|
void shader_setvec2(struct shader *shader, const char *name, mfloat_t val[2])
|
||||||
{
|
{
|
||||||
glUniform2fv(glGetUniformLocation(shader->id, name), 1, val);
|
glUniform2fv(glGetUniformLocation(shader->id, name), 1, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setvec3(struct mShader *shader, const char *name, mfloat_t val[3])
|
void shader_setvec3(struct shader *shader, const char *name, mfloat_t val[3])
|
||||||
{
|
{
|
||||||
glUniform3fv(glGetUniformLocation(shader->id, name), 1, val);
|
glUniform3fv(glGetUniformLocation(shader->id, name), 1, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setvec4(struct mShader *shader, const char *name, mfloat_t val[4])
|
void shader_setvec4(struct shader *shader, const char *name, mfloat_t val[4])
|
||||||
{
|
{
|
||||||
glUniform4fv(glGetUniformLocation(shader->id, name), 1, val);
|
glUniform4fv(glGetUniformLocation(shader->id, name), 1, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setmat2(struct mShader *shader, const char *name, mfloat_t val[4])
|
void shader_setmat2(struct shader *shader, const char *name, mfloat_t val[4])
|
||||||
{
|
{
|
||||||
glUniformMatrix2fv(glGetUniformLocation(shader->id, name), 1, GL_FALSE, val);
|
glUniformMatrix2fv(glGetUniformLocation(shader->id, name), 1, GL_FALSE, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setmat3(struct mShader *shader, const char *name, mfloat_t val[9])
|
void shader_setmat3(struct shader *shader, const char *name, mfloat_t val[9])
|
||||||
{
|
{
|
||||||
glUniformMatrix3fv(glGetUniformLocation(shader->id, name), 1, GL_FALSE, val);
|
glUniformMatrix3fv(glGetUniformLocation(shader->id, name), 1, GL_FALSE, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setmat4(struct mShader *shader, const char *name, mfloat_t val[16])
|
void shader_setmat4(struct shader *shader, const char *name, mfloat_t val[16])
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shader->id, name), 1, GL_FALSE, val);
|
glUniformMatrix4fv(glGetUniformLocation(shader->id, name), 1, GL_FALSE, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_setUBO(struct mShader *shader, const char *name, unsigned int index)
|
void shader_setUBO(struct shader *shader, const char *name, unsigned int index)
|
||||||
{
|
{
|
||||||
glUniformBlockBinding(shader->id, glGetUniformBlockIndex(shader->id, name), index);
|
glUniformBlockBinding(shader->id, glGetUniformBlockIndex(shader->id, name), index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,28 +3,28 @@
|
||||||
|
|
||||||
#include "mathc.h"
|
#include "mathc.h"
|
||||||
|
|
||||||
struct mShader {
|
struct shader {
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
const char *vertpath;
|
const char *vertpath;
|
||||||
const char *fragpath;
|
const char *fragpath;
|
||||||
};
|
};
|
||||||
|
|
||||||
void shader_compile_all();
|
void shader_compile_all();
|
||||||
struct mShader *MakeShader(const char *vertpath, const char *fragpath);
|
struct shader *MakeShader(const char *vertpath, const char *fragpath);
|
||||||
void shader_compile(struct mShader *shader);
|
void shader_compile(struct shader *shader);
|
||||||
void shader_use(struct mShader *shader);
|
void shader_use(struct shader *shader);
|
||||||
|
|
||||||
void shader_setbool(struct mShader *shader, const char *name, int val);
|
void shader_setbool(struct shader *shader, const char *name, int val);
|
||||||
void shader_setint(struct mShader *shader, const char *name, int val);
|
void shader_setint(struct shader *shader, const char *name, int val);
|
||||||
void shader_setfloat(struct mShader *shader, const char *name, float val);
|
void shader_setfloat(struct shader *shader, const char *name, float val);
|
||||||
|
|
||||||
void shader_setvec2(struct mShader *shader, const char *name, mfloat_t val[2]);
|
void shader_setvec2(struct shader *shader, const char *name, mfloat_t val[2]);
|
||||||
void shader_setvec3(struct mShader *shader, const char *name, mfloat_t val[3]);
|
void shader_setvec3(struct shader *shader, const char *name, mfloat_t val[3]);
|
||||||
void shader_setvec4(struct mShader *shader, const char *name, mfloat_t val[4]);
|
void shader_setvec4(struct shader *shader, const char *name, mfloat_t val[4]);
|
||||||
void shader_setmat2(struct mShader *shader, const char *name, mfloat_t val[4]);
|
void shader_setmat2(struct shader *shader, const char *name, mfloat_t val[4]);
|
||||||
void shader_setmat3(struct mShader *shader, const char *name, mfloat_t val[9]);
|
void shader_setmat3(struct shader *shader, const char *name, mfloat_t val[9]);
|
||||||
void shader_setmat4(struct mShader *shader, const char *name, mfloat_t val[16]);
|
void shader_setmat4(struct shader *shader, const char *name, mfloat_t val[16]);
|
||||||
|
|
||||||
void shader_setUBO(struct mShader *shader, const char *name, unsigned int index);
|
void shader_setUBO(struct shader *shader, const char *name, unsigned int index);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct mSkybox {
|
||||||
unsigned int VAO;
|
unsigned int VAO;
|
||||||
unsigned int VBO;
|
unsigned int VBO;
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
struct mShader *shader;
|
struct shader *shader;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mSkybox *MakeSkybox(const char *cubemap);
|
struct mSkybox *MakeSkybox(const char *cubemap);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "gameobject.h"
|
#include "gameobject.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "stb_ds.h"
|
#include "stb_ds.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
struct TextureOptions TEX_SPRITE = { 1, 0, 0 };
|
struct TextureOptions TEX_SPRITE = { 1, 0, 0 };
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ struct sprite *sprites;
|
||||||
|
|
||||||
static uint32_t quadVAO;
|
static uint32_t quadVAO;
|
||||||
|
|
||||||
struct sprite *make_sprite(struct mGameObject *go)
|
struct sprite *make_sprite(struct gameobject *go)
|
||||||
{
|
{
|
||||||
if (arrcap(sprites) == 0)
|
if (arrcap(sprites) == 0)
|
||||||
arrsetcap(sprites, 100);
|
arrsetcap(sprites, 100);
|
||||||
|
@ -27,15 +28,17 @@ struct sprite *make_sprite(struct mGameObject *go)
|
||||||
.size = {1.f, 1.f},
|
.size = {1.f, 1.f},
|
||||||
.tex = texture_loadfromfile("ph.png"),
|
.tex = texture_loadfromfile("ph.png"),
|
||||||
.index = arrlen(sprites) };
|
.index = arrlen(sprites) };
|
||||||
|
|
||||||
sprite_init(&sprite, go);
|
sprite_init(&sprite, go);
|
||||||
|
arrput(sprites, sprite);
|
||||||
|
|
||||||
return &arrlast(sprites);
|
return &arrlast(sprites);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sprite_init(struct sprite *sprite, struct mGameObject *go)
|
void sprite_init(struct sprite *sprite, struct gameobject *go)
|
||||||
{
|
{
|
||||||
sprite->go = go;
|
sprite->go = go;
|
||||||
arrput(sprites, *sprite);
|
|
||||||
|
YughInfo("Added sprite address %p to sprite array %p.", sprite, &arrlast(sprites));
|
||||||
}
|
}
|
||||||
|
|
||||||
void sprite_io(struct sprite *sprite, FILE *f, int read)
|
void sprite_io(struct sprite *sprite, FILE *f, int read)
|
||||||
|
@ -59,11 +62,16 @@ void sprite_io(struct sprite *sprite, FILE *f, int read)
|
||||||
|
|
||||||
void sprite_delete(struct sprite *sprite)
|
void sprite_delete(struct sprite *sprite)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < arrlen(sprites); i++)
|
YughInfo("Attempting to delete sprite, address is %p.", sprite);
|
||||||
|
YughInfo("Number of sprites is %d.", arrlen(sprites));
|
||||||
|
for (int i = 0; i < arrlen(sprites); i++) {
|
||||||
|
YughInfo("Address of try sprite is %p.", &sprites[i]);
|
||||||
if (&sprites[i] == sprite) {
|
if (&sprites[i] == sprite) {
|
||||||
|
YughInfo("Deleted a sprite.");
|
||||||
arrdel(sprites, i);
|
arrdel(sprites, i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sprite_draw_all()
|
void sprite_draw_all()
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "mathc.h"
|
#include "mathc.h"
|
||||||
|
|
||||||
struct datastream;
|
struct datastream;
|
||||||
struct mGameObject;
|
struct gameobject;
|
||||||
struct Texture;
|
struct Texture;
|
||||||
|
|
||||||
struct timer;
|
struct timer;
|
||||||
|
@ -27,13 +27,13 @@ struct sprite {
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
struct Anim2D anim;
|
struct Anim2D anim;
|
||||||
struct mGameObject *go;
|
struct gameobject *go;
|
||||||
struct Texture *tex;
|
struct Texture *tex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sprite *make_sprite(struct mGameObject *go);
|
struct sprite *make_sprite(struct gameobject *go);
|
||||||
void sprite_delete(struct sprite *sprite);
|
void sprite_delete(struct sprite *sprite);
|
||||||
void sprite_init(struct sprite *sprite, struct mGameObject *go);
|
void sprite_init(struct sprite *sprite, struct gameobject *go);
|
||||||
void sprite_io(struct sprite *sprite, FILE *f, int read);
|
void sprite_io(struct sprite *sprite, FILE *f, int read);
|
||||||
void sprite_loadtex(struct sprite *sprite, const char *path);
|
void sprite_loadtex(struct sprite *sprite, const char *path);
|
||||||
void sprite_loadanim(struct sprite *sprite, const char *path, struct Anim2D anim);
|
void sprite_loadanim(struct sprite *sprite, const char *path, struct Anim2D anim);
|
||||||
|
|
|
@ -9,7 +9,7 @@ static int numShadowCasters = 0;
|
||||||
|
|
||||||
struct mStaticActor *curActor = NULL;
|
struct mStaticActor *curActor = NULL;
|
||||||
|
|
||||||
void staticactor_draw_dbg_color_pick(struct mShader *s)
|
void staticactor_draw_dbg_color_pick(struct shader *s)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numModels; i++) {
|
for (int i = 0; i < numModels; i++) {
|
||||||
shader_setvec3(s, "PickingColor", models[i]->obj.editor.color);
|
shader_setvec3(s, "PickingColor", models[i]->obj.editor.color);
|
||||||
|
@ -19,7 +19,7 @@ void staticactor_draw_dbg_color_pick(struct mShader *s)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void staticactor_draw_models(struct mShader *s)
|
void staticactor_draw_models(struct shader *s)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numModels; i++) {
|
for (int i = 0; i < numModels; i++) {
|
||||||
setup_model_transform(&models[i]->obj.transform, s, 1.f);
|
setup_model_transform(&models[i]->obj.transform, s, 1.f);
|
||||||
|
@ -27,7 +27,7 @@ void staticactor_draw_models(struct mShader *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void staticactor_draw_shadowcasters(struct mShader *s)
|
void staticactor_draw_shadowcasters(struct shader *s)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numShadowCasters; i++) {
|
for (int i = 0; i < numShadowCasters; i++) {
|
||||||
setup_model_transform(&shadow_casters[i]->obj.transform, s, 1.f);
|
setup_model_transform(&shadow_casters[i]->obj.transform, s, 1.f);
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
|
|
||||||
struct mStaticActor {
|
struct mStaticActor {
|
||||||
struct mGameObject obj;
|
struct gameobject obj;
|
||||||
struct mModel *model;
|
struct model *model;
|
||||||
char *modelPath;
|
char *modelPath;
|
||||||
char currentModelPath[MAXPATH];
|
char currentModelPath[MAXPATH];
|
||||||
bool castShadows;
|
bool castShadows;
|
||||||
};
|
};
|
||||||
|
|
||||||
void staticactor_draw_dbg_color_pick(struct mShader *s);
|
void staticactor_draw_dbg_color_pick(struct shader *s);
|
||||||
void staticactor_draw_models(struct mShader *s);
|
void staticactor_draw_models(struct shader *s);
|
||||||
void staticactor_draw_shadowcasters(struct mShader *s);
|
void staticactor_draw_shadowcasters(struct shader *s);
|
||||||
struct mStaticActor *MakeStaticActor();
|
struct mStaticActor *MakeStaticActor();
|
||||||
void staticactor_gui(struct mStaticActor *sa);
|
void staticactor_gui(struct mStaticActor *sa);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue