aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio.c12
-rw-r--r--src/models.c30
-rw-r--r--src/raymath.c2
-rw-r--r--src/text.c46
-rw-r--r--src/textures.c12
-rw-r--r--src/utils.c14
6 files changed, 60 insertions, 56 deletions
diff --git a/src/audio.c b/src/audio.c
index bd168158..0e07b8d0 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -49,7 +49,7 @@
#if defined(PLATFORM_RPI)
// NOTE: On RPI should be lower to avoid frame-stalls
#define MUSIC_BUFFER_SIZE 4096*2 // PCM data buffer (short) - 16Kb (RPI)
-#else
+#else
// NOTE: On HTML5 (emscripten) this is allocated on heap, by default it's only 16MB!...just take care...
#define MUSIC_BUFFER_SIZE 4096*8 // PCM data buffer (short) - 64Kb
#endif
@@ -201,7 +201,7 @@ Sound LoadSound(char *fileName)
// Attach sound buffer to source
alSourcei(source, AL_BUFFER, buffer);
-
+
TraceLog(INFO, "[%s] Sound file loaded successfully (SampleRate: %i, BitRate: %i, Channels: %i)", fileName, wave.sampleRate, wave.bitsPerSample, wave.channels);
// Unallocate WAV data
@@ -283,7 +283,7 @@ Sound LoadSoundFromRES(const char *rresName, int resId)
FILE *rresFile = fopen(rresName, "rb");
- if (rresFile == NULL)
+ if (rresFile == NULL)
{
TraceLog(WARNING, "[%s] rRES raylib resource file could not be opened", rresName);
}
@@ -378,7 +378,7 @@ Sound LoadSoundFromRES(const char *rresName, int resId)
// Attach sound buffer to source
alSourcei(source, AL_BUFFER, buffer);
-
+
TraceLog(INFO, "[%s] Sound loaded successfully from resource (SampleRate: %i, BitRate: %i, Channels: %i)", rresName, wave.sampleRate, wave.bitsPerSample, wave.channels);
// Unallocate WAV data
@@ -584,7 +584,7 @@ void ResumeMusicStream(void)
// Resume music playing... if music available!
ALenum state;
alGetSourcei(currentMusic.source, AL_SOURCE_STATE, &state);
-
+
if (state == AL_PAUSED)
{
TraceLog(INFO, "Resuming music stream");
@@ -875,7 +875,7 @@ static Wave LoadOGG(char *fileName)
int samplesObtained = stb_vorbis_get_samples_short_interleaved(oggFile, info.channels, wave.data, totalSamplesLength);
TraceLog(DEBUG, "[%s] Samples obtained: %i", fileName, samplesObtained);
-
+
TraceLog(INFO, "[%s] OGG file loaded successfully (SampleRate: %i, BitRate: %i, Channels: %i)", fileName, wave.sampleRate, wave.bitsPerSample, wave.channels);
stb_vorbis_close(oggFile);
diff --git a/src/models.c b/src/models.c
index bb172203..dfe521d6 100644
--- a/src/models.c
+++ b/src/models.c
@@ -452,22 +452,22 @@ void DrawQuad(Vector3 vertices[4], Vector2 textcoords[4], Vector3 normals[4], Co
rlBegin(RL_QUADS);
rlColor4ub(colors[0].r, colors[0].g, colors[0].b, colors[0].a);
rlNormal3f(normals[0].x, normals[0].y, normals[0].z);
- rlTexCoord2f(textcoords[0].x, textcoords[0].y);
+ rlTexCoord2f(textcoords[0].x, textcoords[0].y);
rlVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);
-
+
rlColor4ub(colors[1].r, colors[1].g, colors[1].b, colors[1].a);
rlNormal3f(normals[1].x, normals[1].y, normals[1].z);
- rlTexCoord2f(textcoords[1].x, textcoords[1].y);
+ rlTexCoord2f(textcoords[1].x, textcoords[1].y);
rlVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);
rlColor4ub(colors[2].r, colors[2].g, colors[2].b, colors[2].a);
rlNormal3f(normals[2].x, normals[2].y, normals[2].z);
- rlTexCoord2f(textcoords[2].x, textcoords[2].y);
+ rlTexCoord2f(textcoords[2].x, textcoords[2].y);
rlVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);
rlColor4ub(colors[3].r, colors[3].g, colors[3].b, colors[3].a);
rlNormal3f(normals[3].x, normals[3].y, normals[3].z);
- rlTexCoord2f(textcoords[3].x, textcoords[3].y);
+ rlTexCoord2f(textcoords[3].x, textcoords[3].y);
rlVertex3f(vertices[3].x, vertices[3].y, vertices[3].z);
rlEnd();
}
@@ -1144,17 +1144,19 @@ void UnloadModel(Model model)
free(model.mesh.texcoords);
free(model.mesh.normals);
}
-
+
rlDeleteBuffers(model.vboId[0]);
rlDeleteBuffers(model.vboId[1]);
rlDeleteBuffers(model.vboId[2]);
rlDeleteVertexArrays(model.vaoId);
+ rlDeleteTextures(model.textureId);
+ rlDeleteShader(model.shaderId);
}
void SetModelTexture(Model *model, Texture2D texture)
{
- if (texture.id <= 0) model->textureId = 1; // Default white texture (use mesh color)
+ if (texture.id <= 0) model->textureId = whiteTexture; // Default white texture (use mesh color)
else model->textureId = texture.id;
}
@@ -1170,6 +1172,8 @@ void DrawModel(Model model, Vector3 position, float scale, Color tint)
// Draw a model with extended parameters
void DrawModelEx(Model model, Vector3 position, Vector3 rotation, Vector3 scale, Color tint)
{
+ // NOTE: Rotation must be provided in degrees, it's converted to radians inside rlglDrawModel()
+
rlglDrawModel(model, position, rotation, scale, tint, false);
}
@@ -1262,11 +1266,11 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vec
// Bottom-left corner for texture and quad
rlTexCoord2f((float)sourceRec.x / texture.width, (float)sourceRec.y / texture.height);
rlVertex3f(a.x, a.y, a.z);
-
+
// Top-left corner for texture and quad
rlTexCoord2f((float)sourceRec.x / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
rlVertex3f(d.x, d.y, d.z);
-
+
// Top-right corner for texture and quad
rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
rlVertex3f(c.x, c.y, c.z);
@@ -1301,7 +1305,7 @@ static VertexData LoadOBJ(const char *fileName)
FILE *objFile;
objFile = fopen(fileName, "rt");
-
+
if (objFile == NULL)
{
TraceLog(WARNING, "[%s] OBJ file could not be opened", fileName);
@@ -1547,15 +1551,15 @@ bool CheckCollisionBoxes(Vector3 minBBox1, Vector3 maxBBox1, Vector3 minBBox2, V
{
/*
// Get min and max vertex to construct bounds (AABB)
- Vector3 minVertex = tempVertices[0];
+ Vector3 minVertex = tempVertices[0];
Vector3 maxVertex = tempVertices[0];
-
+
for (int i = 1; i < tempVertices.Count; i++)
{
minVertex = Vector3.Min(minVertex, tempVertices[i]);
maxVertex = Vector3.Max(maxVertex, tempVertices[i]);
}
-
+
bounds = new BoundingBox(minVertex, maxVertex);
*/
return false;
diff --git a/src/raymath.c b/src/raymath.c
index ed45ee92..df098c6a 100644
--- a/src/raymath.c
+++ b/src/raymath.c
@@ -498,7 +498,7 @@ Matrix MatrixRotate(float angle, float x, float y, float z)
float c = cosf(angle*DEG2RAD); // cosine
float s = sinf(angle*DEG2RAD); // sine
float c1 = 1.0f - c; // 1 - c
-
+
float m0 = result.m0, m4 = result.m4, m8 = result.m8, m12 = result.m12,
m1 = result.m1, m5 = result.m5, m9 = result.m9, m13 = result.m13,
m2 = result.m2, m6 = result.m6, m10 = result.m10, m14 = result.m14;
diff --git a/src/text.c b/src/text.c
index c2340af5..0018363a 100644
--- a/src/text.c
+++ b/src/text.c
@@ -202,7 +202,7 @@ SpriteFont LoadSpriteFont(const char *fileName)
Image image = LoadImage(fileName);
// At this point we have a pixel array with all the data...
-
+
#if defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
ConvertToPOT(&image, MAGENTA);
#endif
@@ -216,7 +216,7 @@ SpriteFont LoadSpriteFont(const char *fileName)
spriteFont.numChars = numChars;
spriteFont.texture = LoadTextureFromImage(image, false); // Convert loaded image to OpenGL texture
-
+
UnloadImage(image);
}
@@ -565,7 +565,7 @@ static SpriteFont LoadRBMF(const char *fileName)
TraceLog(INFO, "[%s] rBMF file loaded correctly as SpriteFont", fileName);
}
-
+
fclose(rbmfFile);
free(rbmfFileData); // Now we can free loaded data from RAM memory
@@ -578,20 +578,20 @@ static SpriteFont LoadRBMF(const char *fileName)
static SpriteFont LoadTTF(const char *fileName, int fontSize)
{
SpriteFont font;
-
+
Image image;
image.width = 512;
image.height = 512;
image.pixels = (Color *)malloc(image.width*image.height*sizeof(Color));
-
+
unsigned char *ttfBuffer = (unsigned char *)malloc(1 << 25);
-
+
// TODO: Load TTF and generate bitmap font and chars data -> REVIEW!
-
+
stbtt_packedchar chardata[128]; // Num characters: 128 (?) -> REVIEW!
-
+
unsigned char *tempBitmap = (unsigned char *)malloc(image.width*image.height*sizeof(unsigned char)); // One channel bitmap returned!
-
+
// REFERENCE
/*
typedef struct
@@ -601,15 +601,15 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize)
float xoff2,yoff2;
} stbtt_packedchar;
*/
-
+
stbtt_pack_context pc;
-
+
FILE *ttfFile = fopen(fileName, "rb");
-
+
fread(ttfBuffer, 1, 1<<25, ttfFile);
stbtt_PackBegin(&pc, tempBitmap, image.width, image.height, 0, 1, NULL);
-
+
//stbtt_PackSetOversampling(&pc, 1, 1);
//stbtt_PackFontRange(&pc, ttfBuffer, 0, fontSize, 32, 95, chardata[0]+32);
stbtt_PackSetOversampling(&pc, 2, 2); // Better results
@@ -618,11 +618,11 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize)
//stbtt_PackFontRange(&pc, ttfBuffer, 0, fontSize, 32, 95, chardata[2]+32);
stbtt_PackEnd(&pc);
-
+
free(ttfBuffer);
// Now we have image data in tempBitmap and chardata filled...
-
+
for (int i = 0; i < 512*512; i++)
{
image.pixels[i].r = tempBitmap[i];
@@ -630,15 +630,15 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize)
image.pixels[i].b = tempBitmap[i];
image.pixels[i].a = 255;
}
-
+
free(tempBitmap);
-
+
// REFERENCE EXAMPLE
/*
//To draw, provide *text, posX, posY
//stbtt_aligned_quad letter;
//stbtt_GetPackedQuad(chardata[0], BITMAP_W, BITMAP_H, *text++, &posX, &posY, &letter, font ? 0 : integer_align);
-
+
void print(float x, float y, int fontNum, char *text)
{
glEnable(GL_TEXTURE_2D);
@@ -651,14 +651,14 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize)
}
glEnd();
}
-
+
print(100,160, 0, "This is a test");
*/
-
+
font.numChars = 95;
font.charSet = (Character *)malloc(font.numChars*sizeof(Character));
font.texture = LoadTextureFromImage(image, false);
-
+
//stbtt_aligned_quad letter;
//int x = 0, y = 0;
@@ -673,8 +673,8 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize)
font.charSet[i].w = chardata[i + 32].x1 - chardata[i + 32].x0;
font.charSet[i].h = chardata[i + 32].y1 - chardata[i + 32].y0;
}
-
+
UnloadImage(image);
-
+
return font;
} \ No newline at end of file
diff --git a/src/textures.c b/src/textures.c
index f701c380..e8bf6088 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -187,7 +187,7 @@ Image LoadImageFromRES(const char *rresName, int resId)
FILE *rresFile = fopen(rresName, "rb");
- if (rresFile == NULL)
+ if (rresFile == NULL)
{
TraceLog(WARNING, "[%s] rRES raylib resource file could not be opened", rresName);
}
@@ -296,7 +296,7 @@ Image LoadImageFromRES(const char *rresName, int resId)
Texture2D LoadTexture(const char *fileName)
{
Texture2D texture;
-
+
// Init texture to default values
texture.id = 0;
texture.width = 0;
@@ -340,7 +340,7 @@ Texture2D LoadTexture(const char *fileName)
else
{
Image image = LoadImage(fileName);
-
+
if (image.pixels != NULL)
{
#if defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
@@ -399,9 +399,9 @@ Texture2D LoadTextureFromImage(Image image, bool genMipmaps)
Texture2D CreateTexture(Image image, bool genMipmaps)
{
Texture2D texture;
-
+
texture = LoadTextureFromImage(image, genMipmaps);
-
+
TraceLog(INFO, "Created texture id: %i", texture.id);
return texture;
@@ -589,7 +589,7 @@ static ImageEx LoadDDS(const char *fileName)
ImageEx image;
ddsHeader header;
-
+
image.data = NULL;
image.width = 0;
image.height = 0;
diff --git a/src/utils.c b/src/utils.c
index dd08f5f8..8e42e533 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -235,18 +235,18 @@ void TraceLog(int msgType, const char *text, ...)
}
// Initialize asset manager from android app
-void InitAssetManager(AAssetManager *manager)
+void InitAssetManager(AAssetManager *manager)
{
assetManager = manager;
}
// Replacement for fopen
-FILE *android_fopen(const char *fileName, const char *mode)
+FILE *android_fopen(const char *fileName, const char *mode)
{
if (mode[0] == 'w') return NULL;
AAsset *asset = AAssetManager_open(assetManager, fileName, 0);
-
+
if(!asset) return NULL;
return funopen(asset, android_read, android_write, android_seek, android_close);
@@ -292,24 +292,24 @@ int GetNextPOT(int num)
// Module specific Functions Definition
//----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
-static int android_read(void *cookie, char *buf, int size)
+static int android_read(void *cookie, char *buf, int size)
{
return AAsset_read((AAsset *)cookie, buf, size);
}
-static int android_write(void *cookie, const char *buf, int size)
+static int android_write(void *cookie, const char *buf, int size)
{
TraceLog(ERROR, "Can't provide write access to the APK");
return EACCES;
}
-static fpos_t android_seek(void *cookie, fpos_t offset, int whence)
+static fpos_t android_seek(void *cookie, fpos_t offset, int whence)
{
return AAsset_seek((AAsset *)cookie, offset, whence);
}
-static int android_close(void *cookie)
+static int android_close(void *cookie)
{
AAsset_close((AAsset *)cookie);
return 0;