Permalink
Browse files

update ct-head & ct_rand_xxx handling, bugfix gl error checks in glfw…

… example
  • Loading branch information...
postspectacular committed Aug 16, 2016
1 parent 307fd39 commit 5c4124fe81b684fa247f8587c22c7725805c3929
@@ -1,3 +1,5 @@
+#include "ct-head/random.h"
+
#include "geom/hull.h"
#include "io/svg.h"
View
@@ -1,5 +1,7 @@
#include <float.h>
+#include "ct-head/random.h"
+
#include "data/spatialgrid.h"
#include "io/svg.h"
#include "math/math.h"
View
@@ -74,10 +74,12 @@ GLuint init_shader(GLenum type, const char *src) {
GLuint shader = glCreateShader(type);
glShaderSource(shader, 1, &src, NULL);
glCompileShader(shader);
- glGetShaderInfoLog(shader, 0x400, &status, log);
- CT_CHECK(!status, "shader error: %s", log);
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
+ CT_CHECK(status == GL_TRUE, "shader compiler error: %d", status);
return shader;
fail:
+ glGetShaderInfoLog(shader, 0x400, &status, log);
+ CT_ERROR("%s", log);
exit(1);
}
@@ -93,7 +95,7 @@ GLuint init_shader_program(const char *vsrc, const char *fsrc) {
glGetProgramiv(program, GL_LINK_STATUS, &status);
glDeleteShader(vs);
glDeleteShader(fs);
- CT_CHECK(!status, "link error: %d", status);
+ CT_CHECK(status == GL_TRUE, "link error: %d", status);
return program;
fail:
exit(1);
View
@@ -1,6 +1,8 @@
#include <string.h>
#include <unistd.h>
+#include "ct-head/random.h"
+
#include "io/svg.h"
#include "math/math.h"
#include "math/poisson.h"
View
@@ -1,3 +1,5 @@
+#include "ct-head/random.h"
+
#include "io/svg.h"
#include "math/math.h"
#include "math/vec.h"
View
@@ -1,3 +1,5 @@
+#include "ct-head/random.h"
+
#include "io/svg.h"
#include "math/math.h"
#include "math/vec.h"
Submodule ct-head updated 5 files
+18 −19 log.h
+50 −39 math.h
+113 −0 random.h
+8 −0 test.c
+14 −2 test.h
View
@@ -1,3 +1,5 @@
+#include "ct-head/random.h"
+
#include "geom/rect.h"
ct_export float ct_rect2f_area(const CT_Rect2f *r) {
View
@@ -1,5 +1,7 @@
#include <math.h>
+#include "ct-head/random.h"
+
#include "geom/isec.h"
#include "math/poisson.h"
View
@@ -1 +0,0 @@
-#include "math/random.h"
View
@@ -1,65 +0,0 @@
-#include <math.h>
-
-#include "cthing.h"
-
-typedef struct {
- uint32_t seed;
- uint32_t iter;
-} CT_Smush;
-
-typedef struct {
- uint32_t x;
- uint32_t y;
- uint32_t z;
- uint32_t w;
-} CT_XorShift;
-
-// https://gist.github.com/voidqk/d112165a26b45244a65298933c0349a4
-
-ct_inline void ct_smush_init(CT_Smush *rnd, uint32_t s) {
- rnd->seed = s;
- rnd->iter = 0;
-}
-
-ct_inline uint32_t ct_smush(CT_Smush *rnd) {
- const uint32_t m = 0x5bd1e995;
- const uint32_t k = rnd->iter++ * m;
- rnd->seed = (k ^ (k >> 24) ^ (rnd->seed * m)) * m;
- return rnd->seed ^ (rnd->seed >> 13);
-}
-
-ct_inline float ct_smush_norm(CT_Smush *rnd) {
- return (float)ct_smush(rnd) / (float)(UINT32_MAX >> 1) - 1.f;
-}
-
-ct_inline float ct_smush_normpos(CT_Smush *rnd) {
- return (float)ct_smush(rnd) / (float)UINT32_MAX;
-}
-
-// xorshift128 - https://en.wikipedia.org/wiki/Xorshift
-
-ct_inline void ctss_xors_init(CT_XorShift *rnd) {
- rnd->x = 0xdecafbad;
- rnd->y = 0x2fa9d05b;
- rnd->z = 0x041f67e3;
- rnd->w = 0x5c83ec1a;
-}
-
-ct_inline uint32_t ct_xors(CT_XorShift *rnd) {
- uint32_t t = rnd->x;
- t ^= t << 11;
- t ^= t >> 8;
- rnd->x = rnd->y;
- rnd->y = rnd->z;
- rnd->z = rnd->w;
- rnd->w ^= rnd->w >> 19;
- return rnd->w ^= t;
-}
-
-ct_inline float ct_xors_norm(CT_XorShift *rnd) {
- return (float)ct_xors(rnd) / (float)(UINT32_MAX >> 1) - 1.f;
-}
-
-ct_inline float ct_xors_normpos(CT_XorShift *rnd) {
- return (float)ct_xors(rnd) / (float)UINT32_MAX;
-}
View
@@ -1,6 +1,8 @@
#include <stdio.h>
#include <string.h>
+#include "ct-head/random.h"
+
#include "math/math.h"
#include "sim/ca.h"
View
@@ -1,5 +1,6 @@
#include <string.h>
+#include "ct-head/random.h"
#include "ct-head/test.h"
#include "data/hashset.h"
View
@@ -1,5 +1,6 @@
#include <string.h>
+#include "ct-head/random.h"
#include "ct-head/test.h"
#include "data/hashtable.h"
View
@@ -1,3 +1,4 @@
+#include "ct-head/random.h"
#include "ct-head/test.h"
#include "geom/hull.h"
View
@@ -1,3 +1,4 @@
+#include "ct-head/random.h"
#include "ct-head/test.h"
#include "data/octree.h"
View
@@ -1,3 +1,4 @@
+#include "ct-head/random.h"
#include "ct-head/test.h"
#include "data/quadtree.h"
View
@@ -1,7 +1,6 @@
+#include "ct-head/random.h"
#include "ct-head/test.h"
-#include "math/random.h"
-
CT_TEST_DECLS
#define NUM 16
View
@@ -1,3 +1,4 @@
+#include "ct-head/random.h"
#include "ct-head/test.h"
#include "data/array.h"

0 comments on commit 5c4124f

Please sign in to comment.