Implement VertexStructs in C, fix incorrect declaration of ReadFile/WriteFile, add C99 typedefs for integer types

This commit is contained in:
UnknownShadow200 2017-05-11 22:54:19 +10:00
parent 0e78857604
commit d8efb47df7
5 changed files with 33 additions and 3 deletions

View file

@ -220,6 +220,7 @@
<ClCompile Include="TextureRec.c" />
<ClCompile Include="Vector3I.c" />
<ClCompile Include="Vectors.c" />
<ClCompile Include="VertexStructs.c" />
<ClCompile Include="WinPlatform.c" />
<ClCompile Include="World.c" />
<ClCompile Include="WorldEnv.c" />

View file

@ -236,5 +236,8 @@
<ClCompile Include="EventHandler.c">
<Filter>Source Files\Events</Filter>
</ClCompile>
<ClCompile Include="VertexStructs.c">
<Filter>Source Files\Math</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -4,7 +4,7 @@
Copyright 2017 ClassicalSharp | Licensed under BSD-3
*/
#if _MSC_VER
typedef unsigned __int8 UInt8;
typedef unsigned __int16 UInt16;
typedef unsigned __int32 UInt32;
@ -14,6 +14,20 @@ typedef signed __int8 Int8;
typedef signed __int16 Int16;
typedef signed __int32 Int32;
typedef signed __int64 Int64;
#elif (__STDC_VERSION__ >= 199901L)
#include <stdint.h>
typedef uint8_t UInt8;
typedef uint16_t UInt16;
typedef uint32_t UInt32;
typedef uint64_t UInt64;
typedef int8_t Int8;
typedef int16_t Int16;
typedef int32_t Int32;
typedef int64_t Int64;
#else
#error "I didn't add typedefs for this compiler. You'll need to define them in Typedefs.h!'"
#endif
typedef float Real32;
typedef double Real64;

View file

@ -0,0 +1,12 @@
#include "VertexStructs.h"
void VertexP3C4b_Set(VertexP3fC4b* target, Real32 x, Real32 y, Real32 z, FastColour col) {
target->X = x; target->Y = y; target->Z = z;
target->Colour = col;
}
void VertexP3fT2fC4b_Set(VertexP3fT2fC4b* target, Real32 x, Real32 y, Real32 z,
Real32 u, Real32 v, FastColour col) {
target->X = x; target->Y = y; target->Z = z;
target->Colour = col; target->U = u; target->V = v;
}

View file

@ -65,12 +65,12 @@ ReturnCode Platform_FileCreate(void** file, String path) {
}
ReturnCode Platform_FileRead(void* file, UInt8* buffer, UInt32 count, UInt32* bytesRead) {
BOOL success = ReadFile((HANDLE)file, buffer, count, &bytesRead, NULL);
BOOL success = ReadFile((HANDLE)file, buffer, count, bytesRead, NULL);
return success ? 0 : GetLastError();
}
ReturnCode Platform_FileWrite(void* file, UInt8* buffer, UInt32 count, UInt32* bytesWritten) {
BOOL success = WriteFile((HANDLE)file, buffer, count, &bytesWritten, NULL);
BOOL success = WriteFile((HANDLE)file, buffer, count, bytesWritten, NULL);
return success ? 0 : GetLastError();
}