From fd9d35fd2cfd07f9a239d795f46c6bb9e733634e Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 13 Jul 2020 01:34:31 +0300 Subject: [PATCH] - added cybersun screen - fixed gen_plane_mesh dimensions --- src/3dgfx/mesh.c | 4 +-- src/3dgfx/mesh.h | 2 ++ src/scr/cybersun.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/screen.c | 4 +++ 4 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 src/scr/cybersun.c diff --git a/src/3dgfx/mesh.c b/src/3dgfx/mesh.c index b8bb9c1..c40b491 100644 --- a/src/3dgfx/mesh.c +++ b/src/3dgfx/mesh.c @@ -364,8 +364,8 @@ int gen_plane_mesh(struct g3d_mesh *m, float width, float height, int usub, int nfaces = usub * vsub; uverts = usub + 1; vverts = vsub + 1; - du = (float)width / (float)usub; - dv = (float)height / (float)vsub; + du = 1.0f / (float)usub; + dv = 1.0f / (float)vsub; nverts = uverts * vverts; nidx = nfaces * 4; diff --git a/src/3dgfx/mesh.h b/src/3dgfx/mesh.h index 5357cb0..e02cf55 100644 --- a/src/3dgfx/mesh.h +++ b/src/3dgfx/mesh.h @@ -10,6 +10,8 @@ struct g3d_mesh { int vcount, icount; }; +int init_mesh(struct g3d_mesh *mesh, int prim, int num_verts, int num_idx); + void free_mesh(struct g3d_mesh *mesh); void destroy_mesh(struct g3d_mesh *mesh); diff --git a/src/scr/cybersun.c b/src/scr/cybersun.c new file mode 100644 index 0000000..bb6055a --- /dev/null +++ b/src/scr/cybersun.c @@ -0,0 +1,99 @@ +#include +#include "demo.h" +#include "3dgfx.h" +#include "screen.h" +#include "gfxutil.h" +#include "mesh.h" +#include "image.h" + +static int init(void); +static void destroy(void); +static void start(long trans_time); +static void draw(void); + +static struct screen scr = { + "cybersun", + init, + destroy, + start, + 0, + draw +}; + +static float cam_theta = 0, cam_phi = 10; +static float cam_dist = 6; + +static struct g3d_mesh gmesh; +#define GMESH_GRIDSZ 20 +#define GMESH_SIZE 50 +static struct image gtex; + +struct screen *cybersun_screen(void) +{ + return &scr; +} + +static int init(void) +{ + int i, j; + + if(gen_plane_mesh(&gmesh, GMESH_SIZE, GMESH_SIZE, GMESH_GRIDSZ, GMESH_GRIDSZ) == -1) { + return -1; + } + for(i=0; i