mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Fix sounds not working
This commit is contained in:
parent
3fbf254f16
commit
8922b377d2
@ -250,7 +250,7 @@ static void Sounds_Play(uint8_t type, struct Soundboard* board) {
|
|||||||
int i, volume;
|
int i, volume;
|
||||||
ReturnCode res;
|
ReturnCode res;
|
||||||
|
|
||||||
if (type == SOUND_NONE || !Audio_SoundsVolume == 0) return;
|
if (type == SOUND_NONE || !Audio_SoundsVolume) return;
|
||||||
snd = Soundboard_PickRandom(board, type);
|
snd = Soundboard_PickRandom(board, type);
|
||||||
if (!snd) return;
|
if (!snd) return;
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ static void Sounds_Play(uint8_t type, struct Soundboard* board) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
l = Audio_GetFormat(output->Handle);
|
l = Audio_GetFormat(output->Handle);
|
||||||
if (l->Channels == 0 || AudioFormat_Eq(l, &fmt)) {
|
if (!l->Channels || AudioFormat_Eq(l, &fmt)) {
|
||||||
Sounds_PlayRaw(output, snd, &fmt, volume); return;
|
Sounds_PlayRaw(output, snd, &fmt, volume); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
28
src/Bitmap.c
28
src/Bitmap.c
@ -507,7 +507,7 @@ ReturnCode Png_Decode(Bitmap* bmp, struct Stream* stream) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------PNG encoder--------------------------------------------------------*
|
*------------------------------------------------------PNG encoder--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static void Png_Filter(uint8_t filter, uint8_t* cur, uint8_t* prior, uint8_t* best, int lineLen) {
|
static void Png_Filter(uint8_t filter, const uint8_t* cur, const uint8_t* prior, uint8_t* best, int lineLen) {
|
||||||
/* 3 bytes per pixel constant */
|
/* 3 bytes per pixel constant */
|
||||||
uint8_t a, b, c;
|
uint8_t a, b, c;
|
||||||
int i, p, pa, pb, pc;
|
int i, p, pa, pb, pc;
|
||||||
@ -562,16 +562,25 @@ static void Png_Filter(uint8_t filter, uint8_t* cur, uint8_t* prior, uint8_t* be
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Png_EncodeRow(const BitmapCol* src, uint8_t* cur, uint8_t* prior, uint8_t* best, int lineLen) {
|
static void Png_MakeRow(const BitmapCol* src, uint8_t* dst, int lineLen, bool alpha) {
|
||||||
uint8_t* dst = cur;
|
uint8_t* end = dst + lineLen;
|
||||||
|
|
||||||
|
if (alpha) {
|
||||||
|
for (; dst < end; src++, dst += 4) {
|
||||||
|
dst[0] = src->R; dst[1] = src->G; dst[2] = src->B; dst[3] = src->A;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (; dst < end; src++, dst += 3) {
|
||||||
|
dst[0] = src->R; dst[1] = src->G; dst[2] = src->B;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Png_EncodeRow(const uint8_t* cur, const uint8_t* prior, uint8_t* best, int lineLen) {
|
||||||
|
uint8_t* dst;
|
||||||
int bestFilter, bestEstimate = Int32_MaxValue;
|
int bestFilter, bestEstimate = Int32_MaxValue;
|
||||||
int x, filter, estimate;
|
int x, filter, estimate;
|
||||||
|
|
||||||
for (x = 0; x < lineLen; x += 3) {
|
|
||||||
dst[0] = src->R; dst[1] = src->G; dst[2] = src->B;
|
|
||||||
src++; dst += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
dst = best + 1;
|
dst = best + 1;
|
||||||
/* NOTE: Waste of time trying the PNG_NONE filter */
|
/* NOTE: Waste of time trying the PNG_NONE filter */
|
||||||
for (filter = PNG_FILTER_SUB; filter <= PNG_FILTER_PAETH; filter++) {
|
for (filter = PNG_FILTER_SUB; filter <= PNG_FILTER_PAETH; filter++) {
|
||||||
@ -645,7 +654,8 @@ ReturnCode Png_Encode(Bitmap* bmp, struct Stream* stream, Png_RowSelector select
|
|||||||
uint8_t* prev = (y & 1) == 0 ? prevLine : curLine;
|
uint8_t* prev = (y & 1) == 0 ? prevLine : curLine;
|
||||||
uint8_t* cur = (y & 1) == 0 ? curLine : prevLine;
|
uint8_t* cur = (y & 1) == 0 ? curLine : prevLine;
|
||||||
|
|
||||||
Png_EncodeRow(src, cur, prev, bestLine, lineSize);
|
Png_MakeRow(src, cur, lineSize, false); /* TODO: alpha */
|
||||||
|
Png_EncodeRow(cur, prev, bestLine, lineSize);
|
||||||
/* +1 for filter byte */
|
/* +1 for filter byte */
|
||||||
if ((res = Stream_Write(&zlStream, bestLine, lineSize + 1))) return res;
|
if ((res = Stream_Write(&zlStream, bestLine, lineSize + 1))) return res;
|
||||||
}
|
}
|
||||||
|
@ -386,13 +386,6 @@ static struct ModelTex* textures_head;
|
|||||||
|
|
||||||
#define Model_RetSize(x,y,z) static Vector3 P = { (x)/16.0f,(y)/16.0f,(z)/16.0f }; *size = P;
|
#define Model_RetSize(x,y,z) static Vector3 P = { (x)/16.0f,(y)/16.0f,(z)/16.0f }; *size = P;
|
||||||
#define Model_RetAABB(x1,y1,z1, x2,y2,z2) static struct AABB BB = { (x1)/16.0f,(y1)/16.0f,(z1)/16.0f, (x2)/16.0f,(y2)/16.0f,(z2)/16.0f }; *bb = BB;
|
#define Model_RetAABB(x1,y1,z1, x2,y2,z2) static struct AABB BB = { (x1)/16.0f,(y1)/16.0f,(z1)/16.0f, (x2)/16.0f,(y2)/16.0f,(z2)/16.0f }; *bb = BB;
|
||||||
#define BoxDesc_Dim(p1, p2) p1 < p2 ? p2 - p1 : p1 - p2
|
|
||||||
|
|
||||||
#define BoxDesc_Tex(x, y) x,y
|
|
||||||
#define BoxDesc_Dims(x1,y1,z1,x2,y2,z2) BoxDesc_Dim(x1,x2), BoxDesc_Dim(y1,y2), BoxDesc_Dim(z1,z2)
|
|
||||||
#define BoxDesc_Bounds(x1,y1,z1,x2,y2,z2) x1/16.0f,y1/16.0f,z1/16.0f, x2/16.0f,y2/16.0f,z2/16.0f
|
|
||||||
#define BoxDesc_Rot(x, y, z) x/16.0f,y/16.0f,z/16.0f
|
|
||||||
#define BoxDesc_Box(x1,y1,z1,x2,y2,z2) BoxDesc_Dims(x1,y1,z1,x2,y2,z2), BoxDesc_Bounds(x1,y1,z1,x2,y2,z2)
|
|
||||||
|
|
||||||
static void Models_ContextLost(void* obj) {
|
static void Models_ContextLost(void* obj) {
|
||||||
Gfx_DeleteVb(&Model_Vb);
|
Gfx_DeleteVb(&Model_Vb);
|
||||||
|
@ -125,6 +125,14 @@ struct BoxDesc {
|
|||||||
float RotX,RotY,RotZ; /* Rotation origin point */
|
float RotX,RotY,RotZ; /* Rotation origin point */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define BoxDesc_Dim(p1, p2) p1 < p2 ? p2 - p1 : p1 - p2
|
||||||
|
/* Macros for making initialising a BoxDesc easier to understand. See Model.c for how these get used. */
|
||||||
|
#define BoxDesc_Tex(x, y) x,y
|
||||||
|
#define BoxDesc_Dims(x1,y1,z1,x2,y2,z2) BoxDesc_Dim(x1,x2), BoxDesc_Dim(y1,y2), BoxDesc_Dim(z1,z2)
|
||||||
|
#define BoxDesc_Bounds(x1,y1,z1,x2,y2,z2) x1/16.0f,y1/16.0f,z1/16.0f, x2/16.0f,y2/16.0f,z2/16.0f
|
||||||
|
#define BoxDesc_Rot(x, y, z) x/16.0f,y/16.0f,z/16.0f
|
||||||
|
#define BoxDesc_Box(x1,y1,z1,x2,y2,z2) BoxDesc_Dims(x1,y1,z1,x2,y2,z2), BoxDesc_Bounds(x1,y1,z1,x2,y2,z2)
|
||||||
|
|
||||||
/* Builds a box model assuming the follow texture layout:
|
/* Builds a box model assuming the follow texture layout:
|
||||||
let SW = sides width, BW = body width, BH = body height
|
let SW = sides width, BW = body width, BH = body height
|
||||||
*********************************************************************************************
|
*********************************************************************************************
|
||||||
|
@ -74,6 +74,7 @@ int main(int argc, char** argv) {
|
|||||||
argsCount = Platform_GetCommandLineArgs(argc, argv, args);
|
argsCount = Platform_GetCommandLineArgs(argc, argv, args);
|
||||||
/* NOTE: Make sure to comment this out before pushing a commit */
|
/* NOTE: Make sure to comment this out before pushing a commit */
|
||||||
/* String rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565"); */
|
/* String rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565"); */
|
||||||
|
/* String rawArgs = String_FromConst("UnknownShadow200"); */
|
||||||
/* argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4); */
|
/* argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4); */
|
||||||
|
|
||||||
Platform_SetWorkingDir();
|
Platform_SetWorkingDir();
|
||||||
|
48
src/Stream.c
48
src/Stream.c
@ -364,7 +364,7 @@ void Stream_ReadonlyBuffered(struct Stream* s, struct Stream* source, void* data
|
|||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-------------------------------------------------CRC32Stream/ReadU32-----------------------------------------------------*
|
*-----------------------------------------------------CRC32Stream---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static ReturnCode Stream_Crc32Write(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
static ReturnCode Stream_Crc32Write(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
|
||||||
struct Stream* source;
|
struct Stream* source;
|
||||||
@ -388,6 +388,48 @@ void Stream_WriteonlyCrc32(struct Stream* s, struct Stream* source) {
|
|||||||
s->Meta.CRC32.CRC32 = 0xFFFFFFFFUL;
|
s->Meta.CRC32.CRC32 = 0xFFFFFFFFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*-------------------------------------------------Read/Write primitives---------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
uint16_t Stream_GetU16_LE(const uint8_t* data) {
|
||||||
|
return (uint16_t)(data[0] | (data[1] << 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t Stream_GetU16_BE(const uint8_t* data) {
|
||||||
|
return (uint16_t)((data[0] << 8) | data[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Stream_GetU32_LE(const uint8_t* data) {
|
||||||
|
return (uint32_t)(
|
||||||
|
(uint32_t)data[0] | ((uint32_t)data[1] << 8) |
|
||||||
|
((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Stream_GetU32_BE(const uint8_t* data) {
|
||||||
|
return (uint32_t)(
|
||||||
|
((uint32_t)data[0] << 24) | ((uint32_t)data[1] << 16) |
|
||||||
|
((uint32_t)data[2] << 8) | (uint32_t)data[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stream_SetU16_LE(uint8_t* data, uint16_t value) {
|
||||||
|
data[0] = (uint8_t)(value ); data[1] = (uint8_t)(value >> 8 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stream_SetU16_BE(uint8_t* data, uint16_t value) {
|
||||||
|
data[0] = (uint8_t)(value >> 8 ); data[1] = (uint8_t)(value );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stream_SetU32_LE(uint8_t* data, uint32_t value) {
|
||||||
|
data[0] = (uint8_t)(value ); data[1] = (uint8_t)(value >> 8 );
|
||||||
|
data[2] = (uint8_t)(value >> 16); data[3] = (uint8_t)(value >> 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stream_SetU32_BE(uint8_t* data, uint32_t value) {
|
||||||
|
data[0] = (uint8_t)(value >> 24); data[1] = (uint8_t)(value >> 16);
|
||||||
|
data[2] = (uint8_t)(value >> 8 ); data[3] = (uint8_t)(value);
|
||||||
|
}
|
||||||
|
|
||||||
ReturnCode Stream_ReadU32_LE(struct Stream* s, uint32_t* value) {
|
ReturnCode Stream_ReadU32_LE(struct Stream* s, uint32_t* value) {
|
||||||
uint8_t data[4]; ReturnCode res;
|
uint8_t data[4]; ReturnCode res;
|
||||||
if ((res = Stream_Read(s, data, 4))) return res;
|
if ((res = Stream_Read(s, data, 4))) return res;
|
||||||
@ -400,6 +442,7 @@ ReturnCode Stream_ReadU32_BE(struct Stream* s, uint32_t* value) {
|
|||||||
*value = Stream_GetU32_BE(data); return 0;
|
*value = Stream_GetU32_BE(data); return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------Read/Write strings-----------------------------------------------------*
|
*--------------------------------------------------Read/Write strings-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -429,6 +472,9 @@ ReturnCode Stream_ReadLine(struct Stream* s, String* text) {
|
|||||||
/* Handle \r\n or \n line endings */
|
/* Handle \r\n or \n line endings */
|
||||||
if (cp == '\r') continue;
|
if (cp == '\r') continue;
|
||||||
if (cp == '\n') return 0;
|
if (cp == '\n') return 0;
|
||||||
|
|
||||||
|
/* ignore byte order mark */
|
||||||
|
if (cp == 0xFEFF) continue;
|
||||||
String_Append(text, Convert_UnicodeToCP437(cp));
|
String_Append(text, Convert_UnicodeToCP437(cp));
|
||||||
}
|
}
|
||||||
return readAny ? 0 : ERR_END_OF_STREAM;
|
return readAny ? 0 : ERR_END_OF_STREAM;
|
||||||
|
58
src/Stream.h
58
src/Stream.h
@ -70,51 +70,29 @@ CC_API void Stream_ReadonlyBuffered(struct Stream* s, struct Stream* source, voi
|
|||||||
/* Wraps another Stream, calculating a running CRC32 as data is written. */
|
/* Wraps another Stream, calculating a running CRC32 as data is written. */
|
||||||
/* To get the final CRC32, xor it with 0xFFFFFFFFUL */
|
/* To get the final CRC32, xor it with 0xFFFFFFFFUL */
|
||||||
void Stream_WriteonlyCrc32(struct Stream* s, struct Stream* source);
|
void Stream_WriteonlyCrc32(struct Stream* s, struct Stream* source);
|
||||||
|
|
||||||
|
/* Reads a little-endian 16 bit unsigned integer from memory. */
|
||||||
|
uint16_t Stream_GetU16_LE(const uint8_t* data);
|
||||||
|
/* Reads a big-endian 16 bit unsigned integer from memory. */
|
||||||
|
uint16_t Stream_GetU16_BE(const uint8_t* data);
|
||||||
|
/* Reads a little-endian 32 bit unsigned integer from memory. */
|
||||||
|
uint32_t Stream_GetU32_LE(const uint8_t* data);
|
||||||
|
/* Reads a big-endian 32 bit unsigned integer from memory. */
|
||||||
|
uint32_t Stream_GetU32_BE(const uint8_t* data);
|
||||||
|
|
||||||
|
/* Writes a little-endian 16 bit unsigned integer to memory. */
|
||||||
|
void Stream_SetU16_LE(uint8_t* data, uint16_t value);
|
||||||
|
/* Writes a big-endian 16 bit unsigned integer to memory. */
|
||||||
|
void Stream_SetU16_BE(uint8_t* data, uint16_t value);
|
||||||
|
/* Writes a little-endian 32 bit unsigned integer to memory. */
|
||||||
|
void Stream_SetU32_LE(uint8_t* data, uint32_t value);
|
||||||
|
/* Writes a big-endian 32 bit unsigned integer to memory. */
|
||||||
|
void Stream_SetU32_BE(uint8_t* data, uint32_t value);
|
||||||
/* Reads a little-endian 32 bit unsigned integer from the stream. */
|
/* Reads a little-endian 32 bit unsigned integer from the stream. */
|
||||||
ReturnCode Stream_ReadU32_LE(struct Stream* s, uint32_t* value);
|
ReturnCode Stream_ReadU32_LE(struct Stream* s, uint32_t* value);
|
||||||
/* Reads a big-endian 32 bit unsigned integer from the stream. */
|
/* Reads a big-endian 32 bit unsigned integer from the stream. */
|
||||||
ReturnCode Stream_ReadU32_BE(struct Stream* s, uint32_t* value);
|
ReturnCode Stream_ReadU32_BE(struct Stream* s, uint32_t* value);
|
||||||
|
|
||||||
/* Reads a little-endian 16 bit unsigned integer from memory. */
|
|
||||||
static CC_INLINE uint16_t Stream_GetU16_LE(const uint8_t* data) {
|
|
||||||
return (uint16_t)(data[0] | (data[1] << 8));
|
|
||||||
}
|
|
||||||
/* Reads a big-endian 16 bit unsigned integer from memory. */
|
|
||||||
static CC_INLINE uint16_t Stream_GetU16_BE(const uint8_t* data) {
|
|
||||||
return (uint16_t)((data[0] << 8) | data[1]);
|
|
||||||
}
|
|
||||||
/* Reads a little-endian 32 bit unsigned integer from memory. */
|
|
||||||
static CC_INLINE uint32_t Stream_GetU32_LE(const uint8_t* data) {
|
|
||||||
return (uint32_t)(
|
|
||||||
(uint32_t)data[0] | ((uint32_t)data[1] << 8) |
|
|
||||||
((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 24));
|
|
||||||
}
|
|
||||||
/* Reads a big-endian 32 bit unsigned integer from memory. */
|
|
||||||
static CC_INLINE uint32_t Stream_GetU32_BE(const uint8_t* data) {
|
|
||||||
return (uint32_t)(
|
|
||||||
((uint32_t)data[0] << 24) | ((uint32_t)data[1] << 16) |
|
|
||||||
((uint32_t)data[2] << 8) | (uint32_t)data[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Writes a little-endian 16 bit unsigned integer to memory. */
|
|
||||||
static CC_INLINE void Stream_SetU16_LE(uint8_t* data, uint16_t value) {
|
|
||||||
data[0] = (uint8_t)(value ); data[1] = (uint8_t)(value >> 8 );
|
|
||||||
}
|
|
||||||
/* Writes a big-endian 16 bit unsigned integer to memory. */
|
|
||||||
static CC_INLINE void Stream_SetU16_BE(uint8_t* data, uint16_t value) {
|
|
||||||
data[0] = (uint8_t)(value >> 8 ); data[1] = (uint8_t)(value );
|
|
||||||
}
|
|
||||||
/* Writes a little-endian 32 bit unsigned integer to memory. */
|
|
||||||
static CC_INLINE void Stream_SetU32_LE(uint8_t* data, uint32_t value) {
|
|
||||||
data[0] = (uint8_t)(value ); data[1] = (uint8_t)(value >> 8 );
|
|
||||||
data[2] = (uint8_t)(value >> 16); data[3] = (uint8_t)(value >> 24);
|
|
||||||
}
|
|
||||||
/* Writes a big-endian 32 bit unsigned integer to memory. */
|
|
||||||
static CC_INLINE void Stream_SetU32_BE(uint8_t* data, uint32_t value) {
|
|
||||||
data[0] = (uint8_t)(value >> 24); data[1] = (uint8_t)(value >> 16);
|
|
||||||
data[2] = (uint8_t)(value >> 8 ); data[3] = (uint8_t)(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reads a line of UTF8 encoded character from the stream. */
|
/* Reads a line of UTF8 encoded character from the stream. */
|
||||||
/* NOTE: Reads one byte at a time. May want to use Stream_ReadonlyBuffered. */
|
/* NOTE: Reads one byte at a time. May want to use Stream_ReadonlyBuffered. */
|
||||||
CC_API ReturnCode Stream_ReadLine(struct Stream* s, String* text);
|
CC_API ReturnCode Stream_ReadLine(struct Stream* s, String* text);
|
||||||
|
@ -142,7 +142,7 @@ Vector3 Vector3_GetDirVector(float yawRad, float pitchRad) {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
struct Matrix Matrix_Identity = {
|
const struct Matrix Matrix_Identity = {
|
||||||
1.0f, 0.0f, 0.0f, 0.0f,
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
0.0f, 1.0f, 0.0f, 0.0f,
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
0.0f, 0.0f, 1.0f, 0.0f,
|
0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
@ -188,7 +188,7 @@ void Matrix_Scale(struct Matrix* result, float x, float y, float z) {
|
|||||||
result->Row0.X = x; result->Row1.Y = y; result->Row2.Z = z;
|
result->Row0.X = x; result->Row1.Y = y; result->Row2.Z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix_Mul(struct Matrix* result, struct Matrix* left, struct Matrix* right) {
|
void Matrix_Mul(struct Matrix* result, const struct Matrix* left, const struct Matrix* right) {
|
||||||
/* Originally from http://www.edais.co.uk/blog/?p=27 */
|
/* Originally from http://www.edais.co.uk/blog/?p=27 */
|
||||||
float
|
float
|
||||||
lM11 = left->Row0.X, lM12 = left->Row0.Y, lM13 = left->Row0.Z, lM14 = left->Row0.W,
|
lM11 = left->Row0.X, lM12 = left->Row0.Y, lM13 = left->Row0.Z, lM14 = left->Row0.W,
|
||||||
|
@ -11,7 +11,7 @@ typedef struct Vector3_ { float X, Y, Z; } Vector3;
|
|||||||
typedef struct Vector3I_ { int X, Y, Z; } Vector3I;
|
typedef struct Vector3I_ { int X, Y, Z; } Vector3I;
|
||||||
struct Vector4 { float X, Y, Z, W; };
|
struct Vector4 { float X, Y, Z, W; };
|
||||||
struct Matrix { struct Vector4 Row0, Row1, Row2, Row3; };
|
struct Matrix { struct Vector4 Row0, Row1, Row2, Row3; };
|
||||||
extern struct Matrix Matrix_Identity;
|
extern const struct Matrix Matrix_Identity;
|
||||||
|
|
||||||
Vector3 Vector3_Create1(float value);
|
Vector3 Vector3_Create1(float value);
|
||||||
Vector3 Vector3_Create3(float x, float y, float z);
|
Vector3 Vector3_Create3(float x, float y, float z);
|
||||||
@ -62,14 +62,21 @@ Vector3 Vector3_GetDirVector(float yawRad, float pitchRad);
|
|||||||
NOTE: This is not an identity function. Returned pitch is always within [-90, 90] degrees.*/
|
NOTE: This is not an identity function. Returned pitch is always within [-90, 90] degrees.*/
|
||||||
/*void Vector3_GetHeading(Vector3 dir, float* yawRad, float* pitchRad);*/
|
/*void Vector3_GetHeading(Vector3 dir, float* yawRad, float* pitchRad);*/
|
||||||
|
|
||||||
void Matrix_RotateX(struct Matrix* result, float angle);
|
/* Returns a matrix representing a counter-clockwise rotation around X axis. */
|
||||||
void Matrix_RotateY(struct Matrix* result, float angle);
|
CC_API void Matrix_RotateX(struct Matrix* result, float angle);
|
||||||
void Matrix_RotateZ(struct Matrix* result, float angle);
|
/* Returns a matrix representing a counter-clockwise rotation around Y axis. */
|
||||||
void Matrix_Translate(struct Matrix* result, float x, float y, float z);
|
CC_API void Matrix_RotateY(struct Matrix* result, float angle);
|
||||||
void Matrix_Scale(struct Matrix* result, float x, float y, float z);
|
/* Returns a matrix representing a counter-clockwise rotation around Z axis. */
|
||||||
|
CC_API void Matrix_RotateZ(struct Matrix* result, float angle);
|
||||||
|
/* Returns a matrix representing a translation to the given coordinates. */
|
||||||
|
CC_API void Matrix_Translate(struct Matrix* result, float x, float y, float z);
|
||||||
|
/* Returns a matrix representing a scaling by the given factors. */
|
||||||
|
CC_API void Matrix_Scale(struct Matrix* result, float x, float y, float z);
|
||||||
|
|
||||||
#define Matrix_MulBy(dst, right) Matrix_Mul(dst, dst, right)
|
#define Matrix_MulBy(dst, right) Matrix_Mul(dst, dst, right)
|
||||||
void Matrix_Mul(struct Matrix* result, struct Matrix* left, struct Matrix* right);
|
/* Multiplies two matrices together. */
|
||||||
|
/* NOTE: result can be the same pointer as left or right. */
|
||||||
|
CC_API void Matrix_Mul(struct Matrix* result, const struct Matrix* left, const struct Matrix* right);
|
||||||
|
|
||||||
void Matrix_Orthographic(struct Matrix* result, float width, float height, float zNear, float zFar);
|
void Matrix_Orthographic(struct Matrix* result, float width, float height, float zNear, float zFar);
|
||||||
void Matrix_OrthographicOffCenter(struct Matrix* result, float left, float right, float bottom, float top, float zNear, float zFar);
|
void Matrix_OrthographicOffCenter(struct Matrix* result, float left, float right, float bottom, float top, float zNear, float zFar);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user