Giter Club home page Giter Club logo

cute_headers's Introduction

cute_headers

Various single-file cross-platform C/C++ headers implementing self-contained libraries.

library description latest version language(s)
cute_c2 2D collision detection routines on primitives, boolean results and/or manifold generation, shape cast/sweep test, raycasts 1.10 C/C++
cute_net Networking library for games requiring an optional reliability layer over UDP with a baked in security scheme 1.03 C/C++
cute_tiled Very efficient loader for Tiled maps exported to JSON format 1.07 C/C++
cute_aseprite Parses .ase/.aseprite files into a compact and convenient struct collection 1.02 C/C++
cute_sound Load/play/loop (with plugin)/pan WAV + OGG (stb_vorbis wrapper for OGG) in mono/stereo, high performance custom mixer, music + crossfade support 2.04 C/C++
cute_math Professional level 3D vector math via SSE intrinsics 1.02 C++
cute_png load/save PNG, texture atlas compiler, DEFLATE compliant decompressor 1.05 C/C++
cute_spritebatch Run-time 2d sprite batcher. Builds atlases on-the-fly in-memory. Useful to implement a sprite batcher for any purpose (like 2D games) for high-performance rendering, without the need to precompile texture atlases on-disk. 1.04 C/C++
cute_sync Collection of practical synchronization primitives, including read/write lock and threadpool/task system 1.01 C/C++
cute_tls Create a TLS connection to a website over TCP, useful for HTTPS requests. 1.01 C/C++/Obj-C

How to Use

Generally these headers do not have dependencies and are intended to be included directly into your source (check each header for specific documentation at the top of the file). Each header has a LIBNAME_IMPLEMENTATION symbol; add this to a single translation unit in your code and include the header right after in order to define library symbols. Just include the header as normal otherwise.

Examples and Tests

Some headers also have example code or demos. In this repo just look for the corresponding examples or tests folders. The example folders are particularly useful for figuring out how to use a particular header.

Contact

Here's a link to the discord chat for cute_headers. Feel free to pop in and ask questions, make suggestions, or have a discussion. If anyone has used cute_headers it would be great to hear your experience! https://discord.gg/2DFHRmX

Another easy way to get a hold of me is on twitter @randypgaul.

FAQ

  • What's the point of making a single file? Why is there implementation and static functions in the headers?

Including these headers is like including a normal header. However, to define the implementation each header looks something like this:

// Do this ONCE in a .c/.cpp file
#define LIBNAME_IMPLEMENTATION
#include "libname.h"

// Everywhere else, just include like a typical header
#include "libname.h"

This will turn the file into a header + c file combo, one time. The point of this is: A) handling the header or sending it to people is easy, no zip files or anything just copy and paste a single file; B) build scripts are a pain in the ass, and these single-file libs can be integrated into any project without modifying a single build script.

  • Doesn't writing all the code in a header ruin compile times?

The stigma that header implementations slow compile time come from inline'd code and template spam. In either case every single translation unit must churn through the header and place inline versions of functions, or for templates generate various type-specific functions. It gets worse once the linker kicks in and needs to coalesce translation units together, deleting duplicated symbols. Often linkers are single-threaded tasks and can really bottleneck build times.

A well constructed single-file header will not use any templates and make use of inline sparingly. Additionally well constructed single-file headers use a #define to place implementation (the function definitions and symbols) into a single translation unit. In this way a well crafted single-file header is pretty much the best thing a C compiler can come across, as far as build times go. Especially when the header can optionally #define out unneeded features.

  • Aren't these header only libraries just a new fad?

I personally don't really know if it's a fad or not, but these files aren't really just headers. They are headers with the .C file part (the implementation) attached to the end. It's two different files stuck together with the C preprocessor, but the implementation part never shows up unless the user does #define LIB_IMPLEMENTATION. This define step is the only integration step required to use these headers.

Unfortunately writing a good header library is pretty hard, so just any random header lib out there in the wild is probably not a good one. The STB and RJM are pretty good header libs, and are a good reference to get an idea at what a good header lib looks like. Mattias Gustavsson has my favorite collection of headers.

  • What is the license?

Each lib contains license info at the end of the file. There is a choice between public domain, and zlib.

  • I was looking for a header I've seen before, but it's missing. Where did it go?

Some of the unpopular or not so useful headers became deprecated, and live here now.

  • *Do you have any higher level libraries? These seem a bit too low-level.

The cute headers are indeed rather low-level. They solve specific problems. If you're looking for a higher level game creation framework I suggestion trying out Cute Framework, a 2D game creation framework built largely on-top of the various low-level cute headers seen here.

cute_headers's People

Contributors

aganm avatar andykt avatar captain4lk avatar cxong avatar dbohdan avatar dexp avatar dkorpel avatar egordorichev avatar empyreanx avatar felselva avatar greyvy avatar james-bern avatar kariem2k avatar kavika13 avatar m-r-hunt avatar mathewmariani avatar meshula avatar molguin92 avatar mupfdev avatar randomerrormessage avatar randygaul avatar ricop avatar robloach avatar roig avatar seemk avatar sigiesec avatar sro5h avatar themattrosen avatar to-miz avatar wizzard033 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cute_headers's Issues

tsMix SIMD

Should use SSE + SSE2 in the tsMix function. tinysound was written with SIMD in mind so this should be a nearly one-to-one conversion.

Core Audio Port

For OSX/iOS it looks like CoreAudio is the analog to DirectSound on Windows. tinysound is ready to be ported. A port would be a prime project for someone looking to contribute to open source. Here's how:

  • tsContext holds OS-specific pointers or handles.
  • tsMakeContext initializes tsContext and calls into OS-specific APIs.
  • tsShutdownContext frees any memory allocated in tsMakeContext, and calls into OS-specific APIs.
  • tsMix is platform independent, portable C code. However, it calls tsPosition and tsMemcpyToDS, both are platform specific to Windows DirectSound. These two functions will need to be deleted/rewritten using OS-specific APIs.

Summary: Loading the tsContext and shutting it down requires OS-specific code. Mixing is platform independent, and is just adding floats together then converting them into 16-bit integers. However, writing these 16-bit integers to the sound API is OS-specific (this writing out is what tsPosition and tsMemcpyToDS are for).

Conversion

Randy, to correctly convert from nanoseconds to seconds on Linux change this line

float elapsed = (float)((double)(now.tv_nsec - prev.tv_nsec) * 1e9);

to

float elapsed = (float)((double)(now.tv_nsec - prev.tv_nsec) * 1e-9);

stb_vorbis example

Most people would probably use stb_vorbis with tinysound, so it would be good for me to see if a demo, or maybe a support function, would be a good addition.

TinySound thread issues..

Awesome speed improvement on the pitch code!

I noticed a few issues:

You will need a tsLock() for tsSetPitch() OR read playing->pitch just once in tsMix()? In tsPlaySound() you will need an unlock:

if ( !playing )
{
	tsUnlock( ctx );
	return 0;
}

tsStopAllSounds() is not thread safe with tsMix()
A possible solution:

void tsStopAllSounds( tsContext* ctx )
{
        tsLock( ctx );
	tsPlayingSound* sound = ctx->playing;
	while ( sound )
	{
		// let tsMix() remove the sound
                sound->active = 0;
		sound = sound->next;
	}
        tsUnlock( ctx );
}

tinysound: Feedback and Feature Requests

Ok, I've trying to integrate tinysound for some time, and just realized that it still lacks certain features I'd consider essential to a game.

  1. Streaming

The ogg/wav files are essentially loaded wholesale into memory as far as I can see. Load times thus suffer hard; and you can't always have all your sounds loaded at initialization time (I have ~200megs of sound, some of them are 5mb+). You can keep the file pointers (or oggstreams) in your tinysound structs, and stream the data using the mixer thread.

  1. FreeSound() troubles

I'm using the lower level apis, and a separate thread for mixing, pools set to 0. When I call FreeSound() in the main loop upon a keypress (with the intention of playing another piece of ambient music), FreeSound() does not remove the playingsound pointer from the context's playing list. The examples don't test for such a case either - they all call FreeSound() at termination.

  1. Music not playing on global focus (Windows)

Minor detail, but give an option to add DSBCAPS_GLOBALFOCUS to bufdesc.dwFlags for the secondary buffer on line 883, which allows music to be playing while the window is not focused.

All in all, tinysound isn't quite production ready yet. I can't quite consider it at version 1.0.

Time library error

I have checked your tinytime.h library and found one error. This error is in linux realization. Sometimes, returned delta time is less than 0. It happens every second. And i think error is in nanoseconds only. There should be also seconds. Sorry for my english. Just look to code, it can look like this:

float delta = (float) (double)(end.tv_sec - start.tv_sec) + ((double)(end.tv_nsec - start.tv_nsec) * 1.0e-9);

Compilation of tiny2c.h fails under g++

When compiling under linux g++ complains about memcpy not being declared:

In file included from main.cpp:4:0:
./tinyc2.h: In function ‘int c2Hull(c2v*, int)’:
./tinyc2.h:913:55: error: ‘memcpy’ was not declared in this scope
  memcpy( verts, hull_verts, sizeof( c2v ) * out_count );

Including cstring before tiny2c.h fixes the error.

Os: Ubuntu 16.04 LTS
Compiler: g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005

tinymath2d: C++ wrapper for tinyc2 functions

Considering the addition of tinymath2d i think it would be nice to have a C++ wrapper for tinyc2. I'm thinking of a base class c2Shape that holds the position information so the user could manipulate the position of a shape without knowing what type it is (which is something i am missing from tinyc2). Kind of like that:

namespace c2 {

struct Shape
{
        c2v position;
};

struct Aabb : public Shape
{
        float w;
        float h;
};

struct Circle : public Shape
{
        float r;
};

.
.
.

void collide(const Shape& A, const Shape& B, c2Manifold* m)
{
        // Calculate the manifold
}

}

One would need to cast the Shape to calculate the manifold then (either using the c API from tinyc2 or tinymath2d if possible). It would be nicer though to avoid the cast, but i can't think of way to do this right now.
Anyway just wanted to hear your opinion on that

tinyc2 cannot be used in C code

In few places it uses C++ syntax:

  • true bool literal in line 802
  • C++11 list initialization in line 1422
  • C++11 list initialization in line 1459 (from C2_PLANE_AT macro)

tinysound port to Linux

If you enjoyed these headers please consider contributing a Linux audio port of tinysound :)

tinysound cannot run on Linux. Right now only Windows/Apple are supported through DirectSound and CoreAudio. tinysound is ready to be ported. A port would be a prime project for someone looking to contribute to open source. Here's how:

  • tsContext holds OS-specific pointers or handles.
  • tsMakeContext initializes tsContext and calls into OS-specific APIs.
  • tsShutdownContext frees any memory allocated in tsMakeContext, and calls into OS-specific APIs.
  • tsMix is platform independent, portable C code. However, it calls tsPosition and tsMemcpyToDS, both are platform specific to Windows DirectSound. These two functions will need to be deleted/rewritten using OS-specific APIs. There are also similar calls to CoreAudio specific functions.

Summary: Loading the tsContext and shutting it down requires OS-specific code. Mixing is platform independent, and is just adding floats together then converting them into 16-bit integers. However, writing these 16-bit integers to the sound API is OS-specific.

Errors out on wave files with fact chunk

Line 566 assumes the first chunk will be a data chunk, but this is not always the case.

In my case, I have a wav file with a fact chunk, and the load routine errors out.

mingw support

Hi
i tried to compile tinysound example (sdl one) , but tons of errors appears !
does mingw considered as supported compiler for this library ?

GCC 'selectany' attribute warning

tinysound.h:2102:1: warning: 'selectany' attribute directive ignored [-Wattributes]
 _PS_CONST_TYPE( sign_mask, int, (int)0x80000000 );
 ^~~~~~~~~~~~~~
tinysound.h:2103:1: warning: 'selectany' attribute directive ignored [-Wattributes]
 _PS_CONST_TYPE( inv_sign_mask, int, (int)~0x80000000 );
 ^~~~~~~~~~~~~~

It's related to following line:

	#define TS_SELECTANY const __attribute__( (selectany) )

How to fix it better?

GCC info:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc-multilib/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp
Thread model: posix
gcc version 7.1.1 20170630 (GCC)

tinyc2: Inconsistent normal direction if using c2Collide

If you use c2Collide to calculate the c2Manifold of a collision, the normal doesn't always point from shape A to B, if the type of A is different from the type of B. If both are of the same type the normal always points from A to B. This happens because the arguments of c2XtoX functions for different shape types have a fixed order.
E.g. Shape A is a c2Circle and B is a c2AABB.

// If passed in this order the normal will point from A -> B.
c2Collide(&A, NULL, C2_CIRCLE, &B, NULL, C2_AABB, &manifold);

Now switch the shapes, A now is a c2AABB and B a c2Circle

// Now c2Collide will call c2CircletoAABBManifold(*B, *A, manifold)
// If passed in this order the normal will point from B -> A.
c2Collide(&A, NULL, C2_AABB, &B, NULL, C2_CIRCLE, &manifold);

A simple solution would be: For each call in c2Collide where A and B are switched (e.g. c2XtoX(*B, *A, &m)) the normal needs to be inverted.

tinysound demos port

Most of the tinysound demos don't run on Apple machines. The only one that does right now is the pitch demo. Demos need to be updated so they can run on OSX/iOS as well as Windows.

tinyfiles.h wrong defines usage

In line 115:

#elif TF_PLATFORM == TF_MAC || TN_PLATFORM == TN_UNIX

should be:

#elif TF_PLATFORM == TF_MAC || TF_PLATFORM == TF_UNIX

Same in line 278 and 345

WIN64 in tinyfiles

In TinyFiles I had to replace the line 54 with
#if defined( _WIN32 ) || defined ( _WIN64 )

for 64 bits compiling (on MVSC2015 and 2017 for sure).

You should add this on other header too.

It's not really important but it could be nice.

And thank's a lot for the work

Make load wav accept a buffer instead of path

This is generally a much better idea since not everyone who will use your api will be wanting to load stuff from disk. If you just let them provide you a buffert then they can pick if they want file-loading or memory-streaming or whatever.

Really nice API btw :)

c2RaytoAABB missing check if cast.t < 0

I just did some more testing and found out that if the c2AABB is over ray.p then c2Raycast::t is negative.
Here are my c2Ray and c2AABB:

c2AABB aabb;
aabb.min = c2V(80, 80);
aabb.max = c2V(120, 120);

c2Ray ray;
ray.p = c2V(100, 100);
ray.d = c2V(100, 100);
ray.t = 1;

I included a picture to illustrate the problem.
screenshot from 2017-06-19 10-36-05
PS: I hope it's ok if I keep opening issues for the bugs I find :)

Macro C2_PLANE_AT error

The macro C2_PLANE_AT, defined at https://github.com/RandyGaul/tinyheaders/blob/ff76ac374a6bec431d8748a82f91ec44f2952d96/tinyc2.h#L1357 raises the following error on GCC 6.3.1, Linux:

tinyc2.h: In functionc2AntinormalFace’:
tinyc2.h:1357:29: error: expected expression before ‘{’ token
 #define C2_PLANE_AT( p, i ) { (p)->norms[ i ], c2Dot( (p)->norms[ i ], (p)->verts[ i ] ) }
                             ^

I think that multi-statement macros aren't ANSI/ISO C/C++, that's why it works on Visual Studio, but not on GCC. Since the macro is used in many places, the only solution I can think of is to replace it with a function or replace where the macro is used with the explicit code.

Extra #endif in tinyfiles.h

I think there's an extra #endif in tinyfiles.h. Around line 88 there's this:

#if defined( TINYPATH_IMPLEMENTATION )
#endif TINYPATH_IMPLEMENTATION

That #endif doesn't look like it should be there. I get compilation errors about the final #endif having no matching #if

Compiling tinyc2 on Mac OSX

Hey.

I used tinyc2 for a gamejam project and had same issues compiling it on my friend's Apple laptop.
I don't know anything about versions of his stuff.

I'll post a diff here if you are at all interested in this. The changes were minimal.
I'm sorry that line numbers aren't included, also I don't have the energy or time to make a proper diff or Github pull request.

diff linux_gamejam_2017_kopi/tinyc2.h linux_gamejam_2017_original/tinyc2.h
1357c1357
< #define C2_PLANE_AT( p, i ) (c2h){ (p)->norms[ i ], c2Dot( (p)->norms[ i ], (p)->verts[ i ] ) }
---
> #define C2_PLANE_AT( p, i ) { (p)->norms[ i ], c2Dot( (p)->norms[ i ], (p)->verts[ i ] ) }
1422c1422
< 	if ( h ) *h = (c2h){ c2CCW90( in ), c2Dot( c2CCW90( in ), ra ) };
---
> 	if ( h ) *h = { c2CCW90( in ), c2Dot( c2CCW90( in ), ra ) };

tinysound: Streaming OGG Files

OGG support in tinysound is done via stb_vorbis, which already has its own streaming API (more info here). Hooking up some code into tinysound to handle streaming would be a great feature to add.

This feature would be perfect for someone looking to contribute to tinysound! If tinysound is appealing, please consider adding a pull request.

My implementation suggestion would be to add another int field to tsLoadedSound to specify a streamed file (for values 0 and 1 to specify no stream, and streamed). Additional information like sample offsets can also be stored in this struct. Then within tsMix, on this line

tsLoadedSound* loaded = playing->loaded_sound;

The loaded sound can be examined and the stb_vorbis API can be used to perform streaming as necessary. This strategy would incur disk overhead into the mixing function, however, since most people will pop off a tsMix thread this is probably not a huge issue.

tinyfiles.h compile error

tinyfiles.h(267): error C4996: 'strerror': This function or variable may be unsafe. Consider using strerror_s instead.

dotc integration?

@RandyGaul I love this collection of small, useful, tight header files! I'm using tinyc2 in a game project right now.

I'm wondering if you'd be open to a PR that integrates dotc: https://www.npmjs.com/package/dotc

The tl;dr is it's a preprocessor that copies the semantics of node's module lookup algorithm without modifying anything else about the c language.

What's really nice about this is you can expose only the things that you want to be available from your module and everything else stays private, (i.e., not in the global namespace.)

If this is something you'd be interested in I'd be happy to send a PR (would basically look like this:)

#ifdef DOTC
#export c2AABB
#export c2Ray
#export c2Circle
#export c2CircletoCircle
// etc....
#endif

Ray to Circle collision broken

c2CircletoRay collision seems to be always broken.
My c2Ray & c2Circle:

c2Ray ray;
ray.p = c2V(100, 100);
ray.d = c2V(100, 100);
ray.t = 1;

c2Circle circle;
circle.r = 30;
circle.p = c2V(200, 200);

I get the impact with:

c2Raycast cast;
if (c2RaytoCircle(ray, circle, &cast)) {
        c2v impact = c2Impact(ray, cast.t);
}

The resulting impact is { 147.852, 147.852 }, which is outside the circle. In each case(circle position) I tested the resulting impact is always outside the circle.

tmseek - potential memory access bug

In tinymemfile all offsets are signed integers and there is an ambiguity in tmseek. Assert's body suggests that smseek will add offset to the current bytes_read and checks if greater than zero but smseek overwrites bytes_read with offset. Consider two scenarios:

  1. assert error
fp->bytes_read = 0;
tmseek(fp, MAX_INT); // assert ok, bytes_read + offset >= 0;
                     // assign ok, will set bytes_read to MAX_INT - a valid memory offset
tmseek(fp, 1);       // assert error,  bytes_read + offset < 0;
                     // assign ok, will set bytes-read to 1 - still a valid offset
  1. assign error
fp->bytes_read = 0;
tmseek(fp, MAX_INT); // assert ok, bytes_read + offset >= 0;
                     // assign ok, will set bytes_read to MAX_INT - a valid memory offset
tmseek(fp, -1);      // assert ok,  bytes_read + offset >= 0;
                     // assign error, will set bytes-read to -1 - not a valid offset

Standardize custom allocator and CRT support

Each header should have consistency for custom malloc/free implementations. Each one should be able to take a context pointer. Should be documented at top of header for ease to find.

Collision solving with c2Poly

I can't figure out how I am supposed to correctly resolve a collision between a c2Poly and a c2Circle.
For c2Circle vs c2AABB the following code worked:

c2CircletoAABBManifold(circle, aabb, &manifold);
circle.p.x += manifold.normal.x * manifold.depths[0];
circle.p.y += manifold.normal.y * manifold.depths[0];

Everything works as I expect and there is no 'jitter' when moving along the edges of the c2AABB. The same code also works for c2AABB vs c2Poly (except the problem below).

However if I do the same with the c2Poly (Note that I also have to substract this time):

c2CircletoPolyManifold(circle, poly, &manifold);
circle.p.x -= manifold.normal.x * manifold.depths[0];
circle.p.y -= manifold.normal.y * manifold.depths[0];

Then the c2Circle 'jumps' off the edges of the c2Poly (Using a c2AABB instead it works though):
peek 2017-06-20 19-21

Using just:

circle.p.x -= manifold.normal.x;
circle.p.y -= manifold.normal.y;

Works better but the movement of the c2Circle is 'jittery' along angled edges of the c2Poly (difficult to see in the recording).
peek 2017-06-20 19-23

Furthermore the c2AABB will jump around if one of its edges is moved towards a corner of the c2Poly:
peek 2017-06-20 19-18

Used c2Poly:

poly.count = 4;
poly.verts[0] = c2V(30, 30);
poly.verts[1] = c2V(130, 40);
poly.verts[2] = c2V(100, 80);
poly.verts[3] = c2V(40, 60);
c2MakePoly(&poly);

cute_sound: Pitch Artifacts (SIMD Precision Issue) - Looking for Pull Request

I am having issues with playing the following (1.2 pitch setting):
http://www.particle-space.xyz/downloads/gong.ogg

Substituting the following resolved the issue:

__m128 phase; // = _mm_atan2_ps( imag, real );
float *phasef = (float*)&phase;
float *realf = (float*)&real;
float *imagf = (float*)&imag;
for (int i=0; i<4; i++) phasef[i] = smbAtan2(imagf[i], realf[i]);

I suspect there is an issue with _mm_atan2_ps() related to the edge cases.

Ray to Poly collision broken

c2RaytoPoly collision seems to be broken if the polygon is perpendicular towards the ray. As demonstrated in below gif:

brokenraygif

(the green lines are rays currently not colliding with anything, black lines are rays colliding with the box)

tinysound SDL: only right channel works

Both Linux and Windows. I just compiled the demo with Visual Studio 2017 on Windows.
You can clearly hear it with headphones: left channel is always silent.

If change wanted.channels to 1, then both left and right have a sound, but 2 times slower than normal.

P.S. The demo can't be compiled in VS. You need to change 636 line from:

void* buf = data;

to:

char* buf = (char*)data;

Standardize IMPL vs IMPLEMENTATION define

Some headers use LIBNAME_IMPL and some use LIBNAME_IMPLEMENTATION. Sometimes they just use the lib's acronym like TS_IMPL instead of TINYSOUND_IMPLEMENTATION.

Should standardize to: LIBENAME_IMPLEMENTATION for consistency. Should document each one of these in a consistent spot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.