Basic 3D graphics for the MBED application-shield on-board LCD (initial/incomplete).
Diff: gfx3d.h
- Revision:
- 8:55ee7af49f47
- Parent:
- 6:0bd002c936bb
- Child:
- 9:db4ec6f7d8b2
--- a/gfx3d.h Fri Nov 27 22:46:17 2015 +0000 +++ b/gfx3d.h Sat Nov 28 01:40:16 2015 +0000 @@ -3,8 +3,6 @@ * Copyright (C) 2015 Fred Barnes, University of Kent <frmb@kent.ac.uk> */ -/** @file gfx3d.h */ - #ifndef __GFX3D_H #define __GFX3D_H @@ -35,6 +33,7 @@ g3d_2p3_t pts[G3D_MAX_POLY_POINTS]; uint16_t tx_pts[G3D_MAX_POLY_POINTS]; /* texture co-ords are 0xYYXX */ int32_t norm; /** face normal */ + uint8_t *txptr; /** texture pointer (null if unset) */ } g3d_poly_t; /** g3d_edgebuf_t polygon edge-buffer */ @@ -71,10 +70,18 @@ #define G3D_ZBADD (32.0f) #define G3D_ZBSCALE (256.0f) +#define G3D_Z_DEPTH_MIN (10.0f) +#define G3D_Z_DEPTH_MAX (64.0f) +#define G3D_X_SCALE_MIN (32.0f) +#define G3D_X_SCALE_MAX (512.0f) +#define G3D_Y_SCALE_MIN (32.0f) +#define G3D_Y_SCALE_MAX (512.f) + #define G3D_Z_DEPTH (12.0f) #define G3D_X_SCALE (120.0f) #define G3D_Y_SCALE (80.0f) +extern "C" void gfx3d_set_z_depth (const float zd); extern "C" void gfx3d_rotate_demo (const g3d_p3_t *src, g3d_p3_t *dst, const int npnts, const angle_t a); extern "C" void gfx3d_rotate_x (const g3d_p3_t *src, g3d_p3_t *dst, const int npnts, const angle_t a); @@ -83,7 +90,7 @@ extern "C" void gfx3d_scale (const g3d_p3_t *src, g3d_p3_t *dst, const int npnts, const g3d_p3_t scl); extern "C" void gfx3d_translate (const g3d_p3_t *src, g3d_p3_t *dst, const int npnts, const g3d_p3_t tx); extern "C" void gfx3d_project (const g3d_p3_t *src, g3d_2p3_t *dst, const int npnts); -extern "C" void gfx3d_cubify_points (const g3d_2p3_t *src, g3d_poly_t *dst, int *npoly, const int backfaces); +extern "C" void gfx3d_cubify_points (const g3d_2p3_t *src, g3d_poly_t *dst, int *npoly, const int backfaces, const uint8_t **txptrs); extern "C" void gfx3d_squarify_points (const g3d_2p3_t *src, g3d_poly_t *dst, int *npoly, const int backfaces); extern "C" void gfx3d_clear_zb (void); @@ -95,7 +102,7 @@ extern "C" void gfx3d_edgebuf_z (const g3d_poly_t *src, g3d_edgebuf_t *dst); extern "C" void gfx3d_wireedge (const g3d_edgebuf_t *edge, C12832 &lcd); -extern "C" void gfx3d_polytxmap (const g3d_poly_t *src, uint8_t *txbuf, C12832 &lcd); +extern "C" void gfx3d_polytxmap (const g3d_poly_t *src, C12832 &lcd); extern "C" void gfx3d_polynormmap (const g3d_poly_t *src, C12832 &lcd); @@ -105,6 +112,9 @@ extern "C" void gfx3d_wirecube (const g3d_2p3_t *src, C12832 &lcd); +/* some hacky font stuff */ +extern "C" void gfx3d_font04b_tx_putchar (uint8_t *txbuf, int *xptr, int y, char ch); +extern "C" void gfx3d_font04b_tx_putstr (uint8_t *txbuf, int *xptr, int y, char *str); static inline uint8_t g3d_texture_bit (const uint8_t *tx, int x, int y) {