From fd3c1e74e7ebe9125b98dba311efcbe73e89859e Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 14 Nov 2021 14:38:06 -0500 Subject: (mkosarek) Working on undamped and damped --- shared_cpp/WebglContext.h | 7 +++++-- shared_cpp/mathlib.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'shared_cpp') diff --git a/shared_cpp/WebglContext.h b/shared_cpp/WebglContext.h index 8064b04..3b6f517 100644 --- a/shared_cpp/WebglContext.h +++ b/shared_cpp/WebglContext.h @@ -6,11 +6,13 @@ #include struct WebglContext { - EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context; + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = 0; int width = 800; int height = 600; void init(const char* query, int inWidth = 800, int inHeight = 600) { + if (context != 0) destroy(); + width = inWidth; height = inHeight; emscripten_set_canvas_element_size( query, width, height); @@ -35,5 +37,6 @@ struct WebglContext { void destroy() { emscripten_webgl_destroy_context(context); + context = 0; } -}; \ No newline at end of file +}; diff --git a/shared_cpp/mathlib.h b/shared_cpp/mathlib.h index 0a39195..fd21ae2 100644 --- a/shared_cpp/mathlib.h +++ b/shared_cpp/mathlib.h @@ -18,6 +18,7 @@ #define ABS(x) (x < 0 ? -x : x) #define SIGN(x) (x < 0 ? -1 : 1) #define PI 3.141592653589793238463 +#define E 2.71828182845904523536 #define DEG_TO_RAD(x) (x * (PI / 180.f)) #define RAD_TO_DEG(x) (x * (180.f / PI)) -- cgit v1.2.1