Got SACN transmitting over the network and set it up for blumen lumen
This commit is contained in:
parent
a77d97a31f
commit
4d9f28dc6e
|
@ -0,0 +1,15 @@
|
|||
led_strip_count 12
|
||||
|
||||
led_strip { 0, 0, 0, INTERPOLATE_POINTS, (0.000000, 1.000000, 0.000000), (0.000000, 0.050000, 1.000000), 70 }
|
||||
led_strip { 0, 1, 0, INTERPOLATE_POINTS, (0.500000, 0.866025, 0.000000), (0.025000, 0.043301, 1.000000), 70 }
|
||||
led_strip { 0, 2, 0, INTERPOLATE_POINTS, (0.866025, 0.499999, 0.000000), (0.043301, 0.024999, 1.000000), 70 }
|
||||
led_strip { 0, 3, 0, INTERPOLATE_POINTS, (1.000000, -0.000000, 0.000000), (0.050000, -0.000000, 1.000000), 70 }
|
||||
led_strip { 0, 4, 0, INTERPOLATE_POINTS, (0.866025, -0.500000, 0.000000), (0.043301, -0.025000, 1.000000), 70 }
|
||||
led_strip { 0, 5, 0, INTERPOLATE_POINTS, (0.500000, -0.866025, 0.000000), (0.025000, -0.043301, 1.000000), 70 }
|
||||
led_strip { 0, 6, 0, INTERPOLATE_POINTS, (-0.000000, -1.000000, 0.000000), (-0.000000, -0.050000, 1.000000), 70 }
|
||||
led_strip { 0, 7, 0, INTERPOLATE_POINTS, (-0.500000, -0.866025, 0.000000), (-0.025000, -0.043301, 1.000000), 70 }
|
||||
led_strip { 0, 8, 0, INTERPOLATE_POINTS, (-0.866025, -0.499999, 0.000000), (-0.043301, -0.024999, 1.000000), 70 }
|
||||
led_strip { 0, 9, 0, INTERPOLATE_POINTS, (-1.000000, 0.000000, 0.000000), (-0.050000, 0.000000, 1.000000), 70 }
|
||||
led_strip { 0, 10, 0, INTERPOLATE_POINTS, (-0.866025, 0.499999, 0.000000), (-0.043301, 0.024999, 1.000000), 70 }
|
||||
led_strip { 0, 11, 0, INTERPOLATE_POINTS, (-0.499999, 0.866025, 0.000000), (-0.024999, 0.043301, 1.000000), 70 }
|
||||
END_OF_ASSEMBLY_FILE
|
|
@ -0,0 +1,21 @@
|
|||
// NOTE(Peter): stuff this in a function and itll print out the code needed to generate a blumen
|
||||
// TODO(Peter): Modify this when you get actual blumen measurements
|
||||
MakeStringBuffer(Buffer, 256);
|
||||
v3 InnerVectors[12];
|
||||
v3 OuterVectors[12];
|
||||
for (s32 i = 0; i < 12; i++)
|
||||
{
|
||||
r32 Theta = ((r32)i / 12.0f) * 2 * PI;
|
||||
|
||||
v3 Direction = v3{GSSin(Theta), GSCos(Theta), 0};
|
||||
|
||||
InnerVectors[i] = Direction;
|
||||
OuterVectors[i] = v3{Direction.x * 0.05f, Direction.y * 0.05f, 1};
|
||||
|
||||
PrintF(&Buffer, "led_strip { 0, %d, 0, INTERPOLATE_POINTS, (%f, %f, %f), (%f, %f, %f), 70 }\n",
|
||||
i,
|
||||
InnerVectors[i].x, InnerVectors[i].y, InnerVectors[i].z,
|
||||
OuterVectors[i].x, OuterVectors[i].y, OuterVectors[i].z);
|
||||
NullTerminate(&Buffer);
|
||||
OutputDebugStringA(Buffer.Memory);
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
#define STRING_BUILDER_ARRAY_BUFFER_SIZE 32
|
||||
|
||||
struct string_array
|
||||
{
|
||||
string** Buckets;
|
||||
s32 BucketSize;
|
||||
s32 BucketCount;
|
||||
s32 Used;
|
||||
free_list FreeList;
|
||||
};
|
||||
|
||||
internal string*
|
||||
GetEntryAtIndex (s32 Index, string_array Buffer)
|
||||
{
|
||||
string* Result = 0;
|
||||
if (Buffer.Buckets)
|
||||
{
|
||||
bucket_index BucketIndex = GetBucketIndexForIndex(Index, Buffer.BucketSize);
|
||||
Result = Buffer.Buckets[BucketIndex.Bucket] + BucketIndex.IndexInBucket;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
internal s32
|
||||
PushElement (string Data, string_array* Buffer)
|
||||
{
|
||||
s32 Result = -1;
|
||||
|
||||
if (Buffer->Used >= Buffer->BucketSize * Buffer->BucketCount)
|
||||
{
|
||||
Buffer->Buckets = (string**)GrowBuffer(Buffer->BucketSize, sizeof(string), &Buffer->BucketCount, (void**)Buffer->Buckets);
|
||||
}
|
||||
|
||||
s32 Index = Buffer->Used++;
|
||||
s32 BucketIndex = Index / Buffer->BucketSize;
|
||||
s32 IndexInBucket = Index % Buffer->BucketSize;
|
||||
|
||||
Buffer->Buckets[BucketIndex][IndexInBucket] = Data;
|
||||
Result = Index;
|
||||
return Result;
|
||||
}
|
||||
|
||||
struct string_builder
|
||||
{
|
||||
string_array Buffer;
|
||||
s32 BufferElementSize;
|
||||
};
|
||||
|
||||
internal string_builder
|
||||
InitStringBuilder(s32 BufferSize)
|
||||
{
|
||||
string_builder Result = {};
|
||||
Result.BufferElementSize = BufferSize;
|
||||
Result.Buffer.BucketSize = STRING_BUILDER_ARRAY_BUFFER_SIZE;
|
||||
Result.Buffer.FreeList.Next = &Result.Buffer.FreeList;
|
||||
return Result;
|
||||
}
|
||||
|
||||
internal void
|
||||
GrowStringBuilder (string_builder* StringBuilder)
|
||||
{
|
||||
string NewSegment = {};
|
||||
NewSegment.Memory = (char*)malloc(StringBuilder->BufferElementSize * sizeof(char));
|
||||
NewSegment.Max = StringBuilder->BufferElementSize;
|
||||
|
||||
PushElement(NewSegment, &StringBuilder->Buffer);
|
||||
}
|
||||
|
||||
internal void
|
||||
StringBuilderPrintF (string_builder* StringBuilder, char* Format, ...)
|
||||
{
|
||||
string Addition = {};
|
||||
Addition.Max = 2048;
|
||||
Addition.Memory = (char*)malloc(Addition.Max * sizeof(char));
|
||||
|
||||
va_list Args;
|
||||
va_start(Args, Format);
|
||||
Addition.Length = PrintFArgsList(Addition.Memory, Addition.Max, Format, Args);
|
||||
|
||||
s32 CharsCopied = 0;
|
||||
while (CharsCopied < Addition.Length)
|
||||
{
|
||||
s32 StringBuilderTailIndex = StringBuilder->Buffer.Used - 1;
|
||||
string* LastString = GetEntryAtIndex(StringBuilderTailIndex, StringBuilder->Buffer);
|
||||
if (!LastString || LastString->Length >= LastString->Max)
|
||||
{
|
||||
GrowStringBuilder(StringBuilder);
|
||||
StringBuilderTailIndex = StringBuilder->Buffer.Used - 1;
|
||||
LastString = GetEntryAtIndex(StringBuilderTailIndex, StringBuilder->Buffer);
|
||||
}
|
||||
|
||||
while (CharsCopied < Addition.Length && LastString->Length < LastString->Max)
|
||||
{
|
||||
LastString->Memory[LastString->Length++] = Addition.Memory[CharsCopied++];
|
||||
}
|
||||
}
|
||||
|
||||
free(Addition.Memory);
|
||||
}
|
|
@ -88,7 +88,6 @@ struct send_sacn_job_data
|
|||
{
|
||||
|
||||
platform_socket_handle SendSocket;
|
||||
platform_get_send_address* GetSendAddress;
|
||||
platform_send_to* SendTo;
|
||||
dmx_buffer_list* DMXBuffers;
|
||||
};
|
||||
|
@ -99,7 +98,6 @@ SACNSendDMXBufferListJob (s32 ThreadID, void* JobData)
|
|||
DEBUG_TRACK_FUNCTION;
|
||||
|
||||
send_sacn_job_data* Data = (send_sacn_job_data*)JobData;
|
||||
platform_get_send_address* GetSendAddress = Data->GetSendAddress;
|
||||
platform_socket_handle SendSocket = Data->SendSocket;
|
||||
platform_send_to* SendTo = Data->SendTo;
|
||||
|
||||
|
@ -109,10 +107,11 @@ SACNSendDMXBufferListJob (s32 ThreadID, void* JobData)
|
|||
dmx_buffer Buffer = DMXBufferAt->Buffer;
|
||||
|
||||
u_long V4SendAddress = SACNGetUniverseSendAddress(Buffer.Universe);
|
||||
platform_network_address_handle SendAddress = GetSendAddress(
|
||||
AF_INET,
|
||||
HostToNetU16(DEFAULT_STREAMING_ACN_PORT),
|
||||
HostToNetU32(V4SendAddress));
|
||||
|
||||
platform_network_address SendAddress = {};
|
||||
SendAddress.Family = AF_INET;
|
||||
SendAddress.Port = DEFAULT_STREAMING_ACN_PORT;
|
||||
SendAddress.Address = V4SendAddress;
|
||||
|
||||
SendTo(SendSocket, SendAddress, (const char*)Buffer.Base, Buffer.TotalSize, 0);
|
||||
|
||||
|
@ -195,10 +194,14 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
|||
{
|
||||
app_state* State = (app_state*)Context.MemoryBase;
|
||||
u8* MemoryCursor = Context.MemoryBase + sizeof(app_state);
|
||||
s32 PermanentStorageSize = Megabytes(32);
|
||||
s32 TransientStorageSize = Context.MemorySize - PermanentStorageSize;
|
||||
s32 PermanentStorageSize = Context.MemorySize; //Megabytes(32);
|
||||
//s32 TransientStorageSize = Context.MemorySize - PermanentStorageSize;
|
||||
State->Permanent = BootstrapArenaIntoMemory(MemoryCursor, PermanentStorageSize);
|
||||
State->Transient = BootstrapArenaIntoMemory(MemoryCursor + PermanentStorageSize, TransientStorageSize);
|
||||
//State->Transient = BootstrapArenaIntoMemory(MemoryCursor + PermanentStorageSize, TransientStorageSize);
|
||||
|
||||
u8* TransientMemory = Context.PlatformAlloc(Megabytes(32));
|
||||
InitMemoryArena(&State->TransientMemory, TransientMemory, Megabytes(32), Context.PlatformAlloc);
|
||||
State->Transient = &State->TransientMemory;
|
||||
|
||||
InitMemoryArena(&State->SACNMemory, 0, 0, Context.PlatformAlloc);
|
||||
|
||||
|
@ -293,7 +296,7 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
|||
State->AssemblyList.FreeList.Next = &State->AssemblyList.FreeList;
|
||||
State->ActiveAssemblyIndecies.BucketSize = 32;
|
||||
#if 1
|
||||
char Path[] = "radialumia.fold";
|
||||
char Path[] = "blumen_lumen.fold";
|
||||
LoadAssembly(State, Context, Path);
|
||||
#endif
|
||||
|
||||
|
@ -382,6 +385,7 @@ CreateDMXBuffers(assembly Assembly, s32 BufferHeaderSize, memory_arena* Arena)
|
|||
Head->Next = NewBuffer;
|
||||
Head = NewBuffer;
|
||||
|
||||
u8* DestChannel = Head->Buffer.Base + BufferHeaderSize;
|
||||
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
||||
LEDIdx < LEDUniverseRange.RangeOnePastLast;
|
||||
LEDIdx++)
|
||||
|
@ -389,8 +393,11 @@ CreateDMXBuffers(assembly Assembly, s32 BufferHeaderSize, memory_arena* Arena)
|
|||
led LED = Assembly.LEDs[LEDIdx];
|
||||
pixel Color = Assembly.Colors[LED.Index];
|
||||
|
||||
s32 DestinationStartChannel = LEDIdx * 3;
|
||||
*((pixel*)(Head->Buffer.Base + DestinationStartChannel)) = Color;
|
||||
|
||||
DestChannel[0] = Color.R;
|
||||
DestChannel[1] = Color.G;
|
||||
DestChannel[2] = Color.B;
|
||||
DestChannel += 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,6 +417,96 @@ UPDATE_AND_RENDER(UpdateAndRender)
|
|||
|
||||
HandleInput(State, InputQueue, Mouse);
|
||||
|
||||
r32 GreenSize = 20.0f;
|
||||
r32 BlueSize = 25.0f;
|
||||
r32 RedSize = 25.0f;
|
||||
|
||||
State->GreenIter += Context.DeltaTime * 45;
|
||||
State->BlueIter += Context.DeltaTime * 25;
|
||||
State->RedIter += Context.DeltaTime * -35;
|
||||
|
||||
|
||||
|
||||
#define PATTERN_THREE
|
||||
|
||||
#ifdef PATTERN_ONE
|
||||
array_entry_handle TestAssemblyHandle = *GetElementAtIndex(0, State->ActiveAssemblyIndecies);
|
||||
assembly TestAssembly = *GetElementWithHandle(TestAssemblyHandle, State->AssemblyList);
|
||||
for (s32 Range = 0; Range < TestAssembly.LEDUniverseMapCount; Range++)
|
||||
{
|
||||
leds_in_universe_range LEDUniverseRange = TestAssembly.LEDUniverseMap[Range];
|
||||
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
||||
LEDIdx < LEDUniverseRange.RangeOnePastLast;
|
||||
LEDIdx++)
|
||||
{
|
||||
led LED = TestAssembly.LEDs[LEDIdx];
|
||||
TestAssembly.Colors[LED.Index].R = 255;
|
||||
TestAssembly.Colors[LED.Index].B = 255;
|
||||
TestAssembly.Colors[LED.Index].G = 255;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PATTERN_TWO
|
||||
if (State->GreenIter > 2 * PI * 100) { State->GreenIter = 0; }
|
||||
r32 SinAdjusted = 0.5f + (GSSin(State->GreenIter * 0.01f) * .5f);
|
||||
u8 Brightness = (u8)(GSClamp01(SinAdjusted) * 255);
|
||||
|
||||
array_entry_handle TestAssemblyHandle = *GetElementAtIndex(0, State->ActiveAssemblyIndecies);
|
||||
assembly TestAssembly = *GetElementWithHandle(TestAssemblyHandle, State->AssemblyList);
|
||||
for (s32 Range = 0; Range < TestAssembly.LEDUniverseMapCount; Range++)
|
||||
{
|
||||
leds_in_universe_range LEDUniverseRange = TestAssembly.LEDUniverseMap[Range];
|
||||
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
||||
LEDIdx < LEDUniverseRange.RangeOnePastLast;
|
||||
LEDIdx++)
|
||||
{
|
||||
led LED = TestAssembly.LEDs[LEDIdx];
|
||||
TestAssembly.Colors[LED.Index].R = Brightness;
|
||||
TestAssembly.Colors[LED.Index].B = Brightness;
|
||||
TestAssembly.Colors[LED.Index].G = Brightness;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PATTERN_THREE
|
||||
if(State->GreenIter > 100 + GreenSize) { State->GreenIter = -GreenSize; }
|
||||
if(State->BlueIter > 100 + BlueSize) { State->BlueIter = -BlueSize; }
|
||||
if(State->RedIter < 0 - RedSize) { State->RedIter = 100 + RedSize; }
|
||||
|
||||
array_entry_handle TestAssemblyHandle = *GetElementAtIndex(0, State->ActiveAssemblyIndecies);
|
||||
assembly TestAssembly = *GetElementWithHandle(TestAssemblyHandle, State->AssemblyList);
|
||||
for (s32 Range = 0; Range < TestAssembly.LEDUniverseMapCount; Range++)
|
||||
{
|
||||
leds_in_universe_range LEDUniverseRange = TestAssembly.LEDUniverseMap[Range];
|
||||
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
||||
LEDIdx < LEDUniverseRange.RangeOnePastLast;
|
||||
LEDIdx++)
|
||||
{
|
||||
led LED = TestAssembly.LEDs[LEDIdx];
|
||||
u8 Red = 0;
|
||||
u8 Green = 0;
|
||||
u8 Blue = 0;
|
||||
|
||||
r32 GreenDistance = GSAbs(LED.Position.z - State->GreenIter);
|
||||
r32 GreenBrightness = GSClamp(0.0f, GreenSize - GreenDistance, GreenSize) / GreenSize;
|
||||
Green = (u8)(GreenBrightness * 255);
|
||||
|
||||
r32 BlueDistance = GSAbs(LED.Position.z - State->BlueIter);
|
||||
r32 BlueBrightness = GSClamp(0.0f, BlueSize - BlueDistance, BlueSize) / BlueSize;
|
||||
Blue = (u8)(BlueBrightness * 255);
|
||||
|
||||
r32 RedDistance = GSAbs(LED.Position.z - State->RedIter);
|
||||
r32 RedBrightness = GSClamp(0.0f, RedSize - RedDistance, RedSize) / RedSize;
|
||||
Red = (u8)(RedBrightness * 255);
|
||||
|
||||
TestAssembly.Colors[LED.Index].R = Red;
|
||||
TestAssembly.Colors[LED.Index].B = Blue;
|
||||
TestAssembly.Colors[LED.Index].G = Green;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Update Visuals Here
|
||||
|
||||
s32 HeaderSize = State->NetworkProtocolHeaderSize;
|
||||
|
@ -424,7 +521,6 @@ UPDATE_AND_RENDER(UpdateAndRender)
|
|||
|
||||
DEBUG_IF(GlobalDebugServices->Interface.SendSACNData)
|
||||
{
|
||||
|
||||
switch (State->NetworkProtocol)
|
||||
{
|
||||
case NetworkProtocol_SACN:
|
||||
|
@ -441,7 +537,6 @@ UPDATE_AND_RENDER(UpdateAndRender)
|
|||
|
||||
send_sacn_job_data* Job = PushStruct(State->Transient, send_sacn_job_data);
|
||||
Job->SendSocket = State->SACN.SendSocket;
|
||||
Job->GetSendAddress = Context.PlatformGetSendAddress;
|
||||
Job->SendTo = Context.PlatformSendTo;
|
||||
Job->DMXBuffers = DMXBuffers;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ enum network_protocol
|
|||
struct app_state
|
||||
{
|
||||
memory_arena* Permanent;
|
||||
memory_arena TransientMemory;
|
||||
memory_arena* Transient;
|
||||
memory_arena SACNMemory;
|
||||
|
||||
|
@ -59,6 +60,10 @@ struct app_state
|
|||
|
||||
bitmap_font* Font;
|
||||
interface_config Interface;
|
||||
|
||||
r32 GreenIter;
|
||||
r32 BlueIter;
|
||||
r32 RedIter;
|
||||
};
|
||||
|
||||
internal void OpenColorPicker(app_state* State, v4* Address);
|
||||
|
|
|
@ -140,7 +140,6 @@ struct context
|
|||
platform_get_font_info* PlatformGetFontInfo;
|
||||
platform_draw_font_codepoint* PlatformDrawFontCodepoint;
|
||||
platform_get_socket_handle* PlatformGetSocketHandle;
|
||||
platform_get_send_address* PlatformGetSendAddress;
|
||||
platform_set_socket_option* PlatformSetSocketOption;
|
||||
platform_send_to* PlatformSendTo;
|
||||
platform_close_socket* PlatformCloseSocket;
|
||||
|
|
|
@ -47,7 +47,6 @@ node_struct_member MemberList_sin_wave_data[] = {
|
|||
|
||||
node_struct_member MemberList_multiply_patterns_data[] = {
|
||||
{ MemberType_NODE_COLOR_BUFFER, "ALEDs", (u64)&((multiply_patterns_data*)0)->ALEDs, IsInputMember },
|
||||
{ MemberType_NODE_COLOR_BUFFER, "BLEDs", (u64)&((multiply_patterns_data*)0)->BLEDs, IsInputMember },
|
||||
{ MemberType_NODE_COLOR_BUFFER, "ResultLEDs", (u64)&((multiply_patterns_data*)0)->ResultLEDs, IsOutputMember},
|
||||
};
|
||||
|
||||
|
@ -83,8 +82,8 @@ node_specification NodeSpecifications[] = {
|
|||
{ NodeType_VectorValue, "VectorValue", 11, MemberList_vector_data, 32, 5, false},
|
||||
{ NodeType_MultiplyNodeProc, "MultiplyNodeProc", 16, MemberList_multiply_data, 12, 3, false},
|
||||
{ NodeType_AddNodeProc, "AddNodeProc", 11, MemberList_add_data, 48, 3, false},
|
||||
{ NodeType_SinWave, "SinWave", 7, MemberList_sin_wave_data, 20, 4, false},
|
||||
{ NodeType_MultiplyPatterns, "MultiplyPatterns", 16, MemberList_multiply_patterns_data, 60, 3, false},
|
||||
{ NodeType_SinWave, "SinWave", 7, MemberList_sin_wave_data, 16, 4, false},
|
||||
{ NodeType_MultiplyPatterns, "MultiplyPatterns", 16, MemberList_multiply_patterns_data, 40, 2, false},
|
||||
{ NodeType_OutputNode, "OutputNode", 10, MemberList_output_node_data, 20, 1, false},
|
||||
{ NodeType_SolidColorProc, "SolidColorProc", 14, MemberList_solid_color_data, 36, 2, false},
|
||||
{ NodeType_VerticalColorFadeProc, "VerticalColorFadeProc", 21, MemberList_vertical_color_fade_data, 44, 4, false},
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
//
|
|
@ -87,6 +87,13 @@ typedef PLATFORM_GET_FILE_PATH(platform_get_file_path);
|
|||
#define PLATFORM_GET_GPU_TEXTURE_HANDLE(name) s32 name(u8* Memory, s32 Width, s32 Height)
|
||||
typedef PLATFORM_GET_GPU_TEXTURE_HANDLE(platform_get_gpu_texture_handle);
|
||||
|
||||
struct platform_network_address
|
||||
{
|
||||
s32 Family;
|
||||
u16 Port;
|
||||
u32 Address;
|
||||
};
|
||||
|
||||
typedef s32 platform_socket_handle;
|
||||
typedef s32 platform_network_address_handle;
|
||||
|
||||
|
@ -99,7 +106,7 @@ typedef PLATFORM_GET_SEND_ADDRESS_HANDLE(platform_get_send_address);
|
|||
#define PLATFORM_SET_SOCKET_OPTION(name) s32 name(platform_socket_handle SocketHandle, s32 Level, s32 Option, const char* OptionValue, s32 OptionLength)
|
||||
typedef PLATFORM_SET_SOCKET_OPTION(platform_set_socket_option);
|
||||
|
||||
#define PLATFORM_SEND_TO(name) s32 name(platform_socket_handle SocketHandle, platform_network_address_handle AddressHandle, const char* Buffer, s32 BufferLength, s32 Flags)
|
||||
#define PLATFORM_SEND_TO(name) s32 name(platform_socket_handle SocketHandle, platform_network_address Address, const char* Buffer, s32 BufferLength, s32 Flags)
|
||||
typedef PLATFORM_SEND_TO(platform_send_to);
|
||||
|
||||
#define PLATFORM_CLOSE_SOCKET(name) void name(platform_socket_handle SocketHandle)
|
||||
|
|
|
@ -330,8 +330,8 @@ SACNGetUniverseSendAddress(s32 Universe)
|
|||
u8 MulticastAddressBuffer[4] = {};
|
||||
MulticastAddressBuffer[0] = 239;
|
||||
MulticastAddressBuffer[1] = 255;
|
||||
MulticastAddressBuffer[2] = (u8)(Universe & 0xff00); // high bit
|
||||
MulticastAddressBuffer[3] = (u8)((Universe & 0x00ff) >> 8); // low bit
|
||||
MulticastAddressBuffer[2] = (u8)((Universe & 0xff00) >> 8); // high bit
|
||||
MulticastAddressBuffer[3] = (u8)((Universe & 0x00ff)); // low bit
|
||||
|
||||
u_long V4Address = (u_long)UpackB4(MulticastAddressBuffer);
|
||||
return V4Address;
|
||||
|
|
|
@ -158,41 +158,6 @@ PLATFORM_GET_SOCKET_HANDLE(Win32GetSocketHandle)
|
|||
return (platform_socket_handle)NewSocketIndex;
|
||||
}
|
||||
|
||||
#define NETWORK_ADDRESS_DICTIONARY_GROW_SIZE 32
|
||||
s32 Win32NetworkAddressHandleMax;
|
||||
s32 Win32NetworkAddressHandleCount;
|
||||
sockaddr_in* NetworkAddressValues;
|
||||
|
||||
PLATFORM_GET_SEND_ADDRESS_HANDLE(Win32GetSendAddress)
|
||||
{
|
||||
if (Win32NetworkAddressHandleCount >= Win32NetworkAddressHandleMax)
|
||||
{
|
||||
s32 NewDictionaryMax = Win32NetworkAddressHandleMax + NETWORK_ADDRESS_DICTIONARY_GROW_SIZE;
|
||||
s32 NewDictionaryDataSize = NewDictionaryMax * sizeof(sockaddr_in);
|
||||
u8* DictionaryMemory = Win32Alloc(NewDictionaryDataSize);
|
||||
Assert(DictionaryMemory);
|
||||
|
||||
sockaddr_in* NewValues = (sockaddr_in*)(DictionaryMemory);
|
||||
if (NetworkAddressValues)
|
||||
{
|
||||
GSMemCopy(NetworkAddressValues, NewValues, sizeof(win32_socket) * NewDictionaryMax);
|
||||
Win32Free((u8*)NetworkAddressValues, sizeof(win32_socket) * Win32NetworkAddressHandleCount);
|
||||
}
|
||||
NetworkAddressValues = NewValues;
|
||||
|
||||
Win32NetworkAddressHandleMax = NewDictionaryMax;
|
||||
}
|
||||
|
||||
Assert(Win32NetworkAddressHandleCount < Win32NetworkAddressHandleMax);
|
||||
s32 NewAddressIndex = Win32NetworkAddressHandleCount++;
|
||||
|
||||
NetworkAddressValues[NewAddressIndex].sin_family = AddressFamily;
|
||||
NetworkAddressValues[NewAddressIndex].sin_port = HostToNetU16(Port);
|
||||
NetworkAddressValues[NewAddressIndex].sin_addr.s_addr = HostToNetU32(Address);
|
||||
|
||||
return (platform_network_address_handle)NewAddressIndex;
|
||||
}
|
||||
|
||||
PLATFORM_SET_SOCKET_OPTION(Win32SetSocketOption)
|
||||
{
|
||||
s32 SocketIndex = (s32)SocketHandle;
|
||||
|
@ -211,10 +176,12 @@ PLATFORM_SEND_TO(Win32SendTo)
|
|||
s32 SocketIndex = (s32)SocketHandle;
|
||||
Assert(SocketIndex < Win32SocketHandleCount);
|
||||
|
||||
s32 AddressIndex = (s32)AddressHandle;
|
||||
Assert(AddressIndex < Win32NetworkAddressHandleCount);
|
||||
sockaddr_in SockAddress = {};
|
||||
SockAddress.sin_family = Address.Family;
|
||||
SockAddress.sin_port = HostToNetU16(Address.Port);
|
||||
SockAddress.sin_addr.s_addr = HostToNetU32(Address.Address);
|
||||
|
||||
s32 LengthSent = sendto(SocketValues[SocketIndex].Socket, Buffer, BufferLength, Flags, (sockaddr*)&NetworkAddressValues[AddressIndex], sizeof(sockaddr_in));
|
||||
s32 LengthSent = sendto(SocketValues[SocketIndex].Socket, Buffer, BufferLength, Flags, (sockaddr*)&SockAddress, sizeof(sockaddr_in));
|
||||
|
||||
if (LengthSent == SOCKET_ERROR)
|
||||
{
|
||||
|
@ -233,7 +200,6 @@ PLATFORM_CLOSE_SOCKET(Win32CloseSocket)
|
|||
closesocket(SocketValues[SocketIndex].Socket);
|
||||
}
|
||||
|
||||
|
||||
HDC FontDrawingDC;
|
||||
HBITMAP FontBitmap;
|
||||
HFONT CurrentFont;
|
||||
|
@ -606,7 +572,6 @@ INT NCmdShow
|
|||
Context.PlatformGetFilePath = Win32SystemDialogueOpenFile;
|
||||
Context.PlatformGetGPUTextureHandle = Win32GetGPUTextureHandle;
|
||||
Context.PlatformGetSocketHandle = Win32GetSocketHandle;
|
||||
Context.PlatformGetSendAddress = Win32GetSendAddress;
|
||||
Context.PlatformSetSocketOption = Win32SetSocketOption;
|
||||
Context.PlatformSendTo = Win32SendTo;
|
||||
Context.PlatformCloseSocket = Win32CloseSocket;
|
||||
|
|
Loading…
Reference in New Issue