medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit c0a9502070252a3311e7da6389f15cc86f7f59fc
parent 3a5090c5ba3dce61eab09ee77367df4f3335591f
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Nov  5 21:37:36 +0200

OS X fixes - tested this time!

Diffstat:
darwin_audio_output.cc | 15+++++++++------
gl.cc | 2--
main.cc | 2+-
platform_audio_output.cc | 2++
queue.h | 4++--
terrain_manager.cc | 12++++++------
unix_thread.h | 4++++
7 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/darwin_audio_output.cc b/darwin_audio_output.cc @@ -1,6 +1,7 @@ #include <AudioToolbox/AudioToolbox.h> #include "intrinsics.h" +#include "log.h" #include "platform_audio_output.h" void audio_output_init() { } @@ -22,9 +23,11 @@ static OSStatus audio_output_callback( } void audio_output_open( AudioOutputDevice * device, AudioOutputCallback callback ) { + device->callback = callback; + AudioComponentDescription desc = { }; desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_RemoteIO; + desc.componentSubType = kAudioUnitSubType_DefaultOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; device->component = AudioComponentFindNext( NULL, &desc ); @@ -32,11 +35,11 @@ void audio_output_open( AudioOutputDevice * device, AudioOutputCallback callback FATAL( "AudioComponentFindNext" ); } - if( AudioComponentInstanceNew( component, &unit ) ) { + if( AudioComponentInstanceNew( device->component, &device->unit ) ) { FATAL( "AudioComponentInstanceNew" ); } - AudioUnitInitialize( unit ); + AudioUnitInitialize( device->unit ); const int rate = 44100; const int channels = 1; @@ -50,15 +53,15 @@ void audio_output_open( AudioOutputDevice * device, AudioOutputCallback callback stream_format.mBytesPerPacket = channels * 2; stream_format.mBytesPerFrame = channels * 2; - AudioUnitSetProperty( unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &stream_format, sizeof( stream_format ) ); + AudioUnitSetProperty( device->unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &stream_format, sizeof( stream_format ) ); AURenderCallbackStruct cb = { }; cb.inputProc = audio_output_callback; cb.inputProcRefCon = device; - AudioUnitSetProperty( unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &cb, sizeof( AURenderCallbackStruct ) ); + AudioUnitSetProperty( device->unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &cb, sizeof( AURenderCallbackStruct ) ); - AudioOutputUnitStart( unit ); + AudioOutputUnitStart( device->unit ); } void audio_output_close( AudioOutputDevice * device ) { diff --git a/gl.cc b/gl.cc @@ -13,7 +13,6 @@ #define YELLOW "\x1b[1;32m" #define GREEN "\x1b[1;33m" -#if !defined( __APPLE__ ) static const char * type_string( GLenum type ) { switch( type ) { case GL_DEBUG_TYPE_ERROR: @@ -69,7 +68,6 @@ static void gl_debug_output_callback( ASSERT( 0 ); } } -#endif static void glfw_error_callback( int code, const char * message ) { WARN( "GLFW error %d: %s", code, message ); diff --git a/main.cc b/main.cc @@ -87,7 +87,7 @@ int main( int argc, char ** argv ) { #endif #if !STATIC_GAME -#if PLATFORM_LINUX +#if PLATFORM_UNIX const char * game_library_path = argc == 2 ? argv[ 1 ] : "./hm.so"; #elif PLATFORM_WINDOWS const char * game_library_path = argc == 2 ? argv[ 1 ] : "./hm.dll"; diff --git a/platform_audio_output.cc b/platform_audio_output.cc @@ -2,6 +2,8 @@ #if PLATFORM_LINUX #include "linux_audio_output.cc" +#elif PLATFORM_OSX +#include "darwin_audio_output.cc" #else #error new platform #endif diff --git a/queue.h b/queue.h @@ -54,7 +54,7 @@ public: } bool dequeue( T * x ) { - return q.dequeue( x ); + return q->dequeue( x ); } private: @@ -69,7 +69,7 @@ public: } bool enqueue( const T & x ) { - return q.dequeue( x ); + return q->dequeue( x ); } private: diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -399,7 +399,7 @@ void terrain_render( TerrainManager * tm, glm::mat4 V, glm::mat4 VP, float sun, const GPUTileData & gpu_tile_data = tm->gpu_tiles[ tx ][ ty ]; // TODO: move this into terrain_prepare_render? const Heightmap * hm = &tm->decompressed_tiles[ tx ][ ty ].heightmap; - const OffsetHeightmap ohm = { *hm, tx * TILE_SIZE, ty * TILE_SIZE }; + const OffsetHeightmap ohm = { *hm, checked_cast< float >( tx * TILE_SIZE ), checked_cast< float >( ty * TILE_SIZE ) }; gpubtt_init( tm->arena, &tm->gpubtts[ tx ][ ty ], @@ -424,11 +424,11 @@ void terrain_render( TerrainManager * tm, glm::mat4 V, glm::mat4 VP, float sun, /* start lighting */ float tbo1[ 15 ] = { - 500, 1500 + 500 * sin( current_time + 3.14 * 1 / 5 ), 15, - 600, 1500 + 500 * sin( current_time + 3.14 * 2 / 5 ), 15, - 700, 1500 + 500 * sin( current_time + 3.14 * 3 / 5 ), 15, - 800, 1500 + 500 * sin( current_time + 3.14 * 4 / 5 ), 15, - 900, 1500 + 500 * sin( current_time + 3.14 * 5 / 5 ), 15, + 500, float( 1500 + 500 * sin( current_time + 3.14 * 1 / 5 ) ), 15, + 600, float( 1500 + 500 * sin( current_time + 3.14 * 2 / 5 ) ), 15, + 700, float( 1500 + 500 * sin( current_time + 3.14 * 3 / 5 ) ), 15, + 800, float( 1500 + 500 * sin( current_time + 3.14 * 4 / 5 ) ), 15, + 900, float( 1500 + 500 * sin( current_time + 3.14 * 5 / 5 ) ), 15, }; renderer_tb_data( tm->point_light_origins, tbo1, sizeof( tbo1 ) ); diff --git a/unix_thread.h b/unix_thread.h @@ -29,6 +29,10 @@ inline u64 thread_getid() { return checked_cast< u64 >( pthread_self() ); #elif PLATFORM_OPENBSD return checked_cast< u64 >( getthrid() ); +#elif PLATFORM_OSX + u64 id; + pthread_threadid_np( NULL, &id ); + return id; #else #error new platform #endif