web?
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#define COM_BITS_H
|
||||
|
||||
#include "def.h"
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* How many bits needed to represent a given number */
|
||||
|
||||
@@ -10,6 +10,19 @@
|
||||
#define COM_DEF_COMPILE_MODERN 1
|
||||
#endif
|
||||
|
||||
#define COM_DEF_TARGET_NATIVE 0
|
||||
#define COM_DEF_TARGET_WASM 1
|
||||
|
||||
#if defined(__wasm__)
|
||||
#define COM_DEF_NOSTD 1
|
||||
#define COM_DEF_TARGET COM_DEF_TARGET_WASM
|
||||
/* TODO: Move to std.h instead, forbid stdlib on any platform. */
|
||||
#define assert(m_t) (m_t)
|
||||
#define printf(...) ((void)0)
|
||||
#else
|
||||
#define COM_DEF_TARGET COM_DEF_TARGET_NATIVE
|
||||
#endif
|
||||
|
||||
/* TODO: uppercase? */
|
||||
#ifdef COM_DEF_COMPILE_MODERN
|
||||
#define com_def_alignedas(v_as) _Alignas(v_as)
|
||||
|
||||
+7
-2
@@ -3,14 +3,17 @@
|
||||
https://github.com/howerj/q/blob/master/q.c
|
||||
*/
|
||||
|
||||
#include "fix.h"
|
||||
#include "Timer/timer.h"
|
||||
#include "def.h"
|
||||
#include "fix.h"
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef COM_DEF_NOSTD
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <tgmath.h>
|
||||
#endif
|
||||
|
||||
// 4-bit LUT (16 entries) for the normalized range [0.5, 2.0)
|
||||
// It stores the initial guess scaled to Q16.16.
|
||||
@@ -130,6 +133,7 @@ void com_fix_run_bench(void) {
|
||||
}
|
||||
|
||||
void com_fix_run_tests(void) {
|
||||
#ifndef COM_DEF_NOSTD
|
||||
{
|
||||
double max_sqrt_deviation = 0.0f;
|
||||
com_fix_t sqrt_accumulator = 0;
|
||||
@@ -196,4 +200,5 @@ void com_fix_run_tests(void) {
|
||||
printf("max sincos deviations: %f %f\n", max_sin_deviation,
|
||||
max_cos_deviation);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#define COM_FIX_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define COM_FIX_FRACBITS 16
|
||||
#define COM_FIX_FRACUNIT (1 << COM_FIX_FRACBITS)
|
||||
|
||||
+1
-2
@@ -50,7 +50,7 @@ static inline com_vec_t com_gem_vec_project_clip(com_mat_t a, com_vec_t b) {
|
||||
* outside of view. Bit test against those per component. This is needed for
|
||||
* determining new view-lying clipped triangles. */
|
||||
static inline uint8_t com_gem_clip_vis_project(com_vec_t a, com_pnt_t *out) {
|
||||
uint8_t mask;
|
||||
uint8_t mask = 0;
|
||||
if (a.s.x < -a.s.z || a.s.x > a.s.z)
|
||||
mask ^= COM_GEM_VERTEX_CLIPPED_X;
|
||||
if (a.s.y < -a.s.z || a.s.y > a.s.z)
|
||||
@@ -77,7 +77,6 @@ static inline void com_gem_draw_triangle(com_pnt_t v0, com_pnt_t v1,
|
||||
// If the point is inside or on all edges, draw the pixel
|
||||
// (Assumes Clockwise vertex ordering)
|
||||
if (ws.a[0] >= 0 && ws.a[1] >= 0 && ws.a[2] >= 0) {
|
||||
printf("%i, %i\n", y, x);
|
||||
out[(y * 640 + x) * 4 + 0] = 125;
|
||||
out[(y * 640 + x) * 4 + 1] = 125;
|
||||
out[(y * 640 + x) * 4 + 2] = 125;
|
||||
|
||||
+6
-2
@@ -5,12 +5,16 @@
|
||||
|
||||
#include "lzw.h"
|
||||
#include "bits.h"
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef COM_DEF_NOSTD
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include "std.h"
|
||||
#endif
|
||||
|
||||
/* References: */
|
||||
/* https://www.w3.org/Graphics/GIF/spec-gif89a.txt */
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "fix.h"
|
||||
#include "vec.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef union {
|
||||
com_def_alignedas(64) com_def_vector(com_fix_t, a, 4 * 4);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
/* TODO: Actually implement. */
|
||||
#define realloc(m_p, m_b) (NULL)
|
||||
#define free(m_p) ((void)0)
|
||||
Reference in New Issue
Block a user