Removed useless spaces

This commit is contained in:
raysan5 2015-02-02 00:53:49 +01:00
parent dc52c8f769
commit b9e53cd135
6 changed files with 60 additions and 56 deletions

View file

@ -49,7 +49,7 @@
#if defined(PLATFORM_RPI) #if defined(PLATFORM_RPI)
// NOTE: On RPI should be lower to avoid frame-stalls // NOTE: On RPI should be lower to avoid frame-stalls
#define MUSIC_BUFFER_SIZE 4096*2 // PCM data buffer (short) - 16Kb (RPI) #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... // 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 #define MUSIC_BUFFER_SIZE 4096*8 // PCM data buffer (short) - 64Kb
#endif #endif
@ -201,7 +201,7 @@ Sound LoadSound(char *fileName)
// Attach sound buffer to source // Attach sound buffer to source
alSourcei(source, AL_BUFFER, buffer); 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); TraceLog(INFO, "[%s] Sound file loaded successfully (SampleRate: %i, BitRate: %i, Channels: %i)", fileName, wave.sampleRate, wave.bitsPerSample, wave.channels);
// Unallocate WAV data // Unallocate WAV data
@ -283,7 +283,7 @@ Sound LoadSoundFromRES(const char *rresName, int resId)
FILE *rresFile = fopen(rresName, "rb"); FILE *rresFile = fopen(rresName, "rb");
if (rresFile == NULL) if (rresFile == NULL)
{ {
TraceLog(WARNING, "[%s] rRES raylib resource file could not be opened", rresName); 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 // Attach sound buffer to source
alSourcei(source, AL_BUFFER, buffer); 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); TraceLog(INFO, "[%s] Sound loaded successfully from resource (SampleRate: %i, BitRate: %i, Channels: %i)", rresName, wave.sampleRate, wave.bitsPerSample, wave.channels);
// Unallocate WAV data // Unallocate WAV data
@ -584,7 +584,7 @@ void ResumeMusicStream(void)
// Resume music playing... if music available! // Resume music playing... if music available!
ALenum state; ALenum state;
alGetSourcei(currentMusic.source, AL_SOURCE_STATE, &state); alGetSourcei(currentMusic.source, AL_SOURCE_STATE, &state);
if (state == AL_PAUSED) if (state == AL_PAUSED)
{ {
TraceLog(INFO, "Resuming music stream"); 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); int samplesObtained = stb_vorbis_get_samples_short_interleaved(oggFile, info.channels, wave.data, totalSamplesLength);
TraceLog(DEBUG, "[%s] Samples obtained: %i", fileName, samplesObtained); 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); TraceLog(INFO, "[%s] OGG file loaded successfully (SampleRate: %i, BitRate: %i, Channels: %i)", fileName, wave.sampleRate, wave.bitsPerSample, wave.channels);
stb_vorbis_close(oggFile); stb_vorbis_close(oggFile);

View file

@ -452,22 +452,22 @@ void DrawQuad(Vector3 vertices[4], Vector2 textcoords[4], Vector3 normals[4], Co
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
rlColor4ub(colors[0].r, colors[0].g, colors[0].b, colors[0].a); rlColor4ub(colors[0].r, colors[0].g, colors[0].b, colors[0].a);
rlNormal3f(normals[0].x, normals[0].y, normals[0].z); 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); rlVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);
rlColor4ub(colors[1].r, colors[1].g, colors[1].b, colors[1].a); rlColor4ub(colors[1].r, colors[1].g, colors[1].b, colors[1].a);
rlNormal3f(normals[1].x, normals[1].y, normals[1].z); 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); rlVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);
rlColor4ub(colors[2].r, colors[2].g, colors[2].b, colors[2].a); rlColor4ub(colors[2].r, colors[2].g, colors[2].b, colors[2].a);
rlNormal3f(normals[2].x, normals[2].y, normals[2].z); 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); rlVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);
rlColor4ub(colors[3].r, colors[3].g, colors[3].b, colors[3].a); rlColor4ub(colors[3].r, colors[3].g, colors[3].b, colors[3].a);
rlNormal3f(normals[3].x, normals[3].y, normals[3].z); 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); rlVertex3f(vertices[3].x, vertices[3].y, vertices[3].z);
rlEnd(); rlEnd();
} }
@ -1144,17 +1144,19 @@ void UnloadModel(Model model)
free(model.mesh.texcoords); free(model.mesh.texcoords);
free(model.mesh.normals); free(model.mesh.normals);
} }
rlDeleteBuffers(model.vboId[0]); rlDeleteBuffers(model.vboId[0]);
rlDeleteBuffers(model.vboId[1]); rlDeleteBuffers(model.vboId[1]);
rlDeleteBuffers(model.vboId[2]); rlDeleteBuffers(model.vboId[2]);
rlDeleteVertexArrays(model.vaoId); rlDeleteVertexArrays(model.vaoId);
rlDeleteTextures(model.textureId);
rlDeleteShader(model.shaderId);
} }
void SetModelTexture(Model *model, Texture2D texture) 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; 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 // Draw a model with extended parameters
void DrawModelEx(Model model, Vector3 position, Vector3 rotation, Vector3 scale, Color tint) 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); 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 // Bottom-left corner for texture and quad
rlTexCoord2f((float)sourceRec.x / texture.width, (float)sourceRec.y / texture.height); rlTexCoord2f((float)sourceRec.x / texture.width, (float)sourceRec.y / texture.height);
rlVertex3f(a.x, a.y, a.z); rlVertex3f(a.x, a.y, a.z);
// Top-left corner for texture and quad // Top-left corner for texture and quad
rlTexCoord2f((float)sourceRec.x / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height); rlTexCoord2f((float)sourceRec.x / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
rlVertex3f(d.x, d.y, d.z); rlVertex3f(d.x, d.y, d.z);
// Top-right corner for texture and quad // Top-right corner for texture and quad
rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height); rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
rlVertex3f(c.x, c.y, c.z); rlVertex3f(c.x, c.y, c.z);
@ -1301,7 +1305,7 @@ static VertexData LoadOBJ(const char *fileName)
FILE *objFile; FILE *objFile;
objFile = fopen(fileName, "rt"); objFile = fopen(fileName, "rt");
if (objFile == NULL) if (objFile == NULL)
{ {
TraceLog(WARNING, "[%s] OBJ file could not be opened", fileName); 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) // Get min and max vertex to construct bounds (AABB)
Vector3 minVertex = tempVertices[0]; Vector3 minVertex = tempVertices[0];
Vector3 maxVertex = tempVertices[0]; Vector3 maxVertex = tempVertices[0];
for (int i = 1; i < tempVertices.Count; i++) for (int i = 1; i < tempVertices.Count; i++)
{ {
minVertex = Vector3.Min(minVertex, tempVertices[i]); minVertex = Vector3.Min(minVertex, tempVertices[i]);
maxVertex = Vector3.Max(maxVertex, tempVertices[i]); maxVertex = Vector3.Max(maxVertex, tempVertices[i]);
} }
bounds = new BoundingBox(minVertex, maxVertex); bounds = new BoundingBox(minVertex, maxVertex);
*/ */
return false; return false;

View file

@ -498,7 +498,7 @@ Matrix MatrixRotate(float angle, float x, float y, float z)
float c = cosf(angle*DEG2RAD); // cosine float c = cosf(angle*DEG2RAD); // cosine
float s = sinf(angle*DEG2RAD); // sine float s = sinf(angle*DEG2RAD); // sine
float c1 = 1.0f - c; // 1 - c float c1 = 1.0f - c; // 1 - c
float m0 = result.m0, m4 = result.m4, m8 = result.m8, m12 = result.m12, 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, m1 = result.m1, m5 = result.m5, m9 = result.m9, m13 = result.m13,
m2 = result.m2, m6 = result.m6, m10 = result.m10, m14 = result.m14; m2 = result.m2, m6 = result.m6, m10 = result.m10, m14 = result.m14;

View file

@ -202,7 +202,7 @@ SpriteFont LoadSpriteFont(const char *fileName)
Image image = LoadImage(fileName); Image image = LoadImage(fileName);
// At this point we have a pixel array with all the data... // At this point we have a pixel array with all the data...
#if defined(PLATFORM_RPI) || defined(PLATFORM_WEB) #if defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
ConvertToPOT(&image, MAGENTA); ConvertToPOT(&image, MAGENTA);
#endif #endif
@ -216,7 +216,7 @@ SpriteFont LoadSpriteFont(const char *fileName)
spriteFont.numChars = numChars; spriteFont.numChars = numChars;
spriteFont.texture = LoadTextureFromImage(image, false); // Convert loaded image to OpenGL texture spriteFont.texture = LoadTextureFromImage(image, false); // Convert loaded image to OpenGL texture
UnloadImage(image); UnloadImage(image);
} }
@ -565,7 +565,7 @@ static SpriteFont LoadRBMF(const char *fileName)
TraceLog(INFO, "[%s] rBMF file loaded correctly as SpriteFont", fileName); TraceLog(INFO, "[%s] rBMF file loaded correctly as SpriteFont", fileName);
} }
fclose(rbmfFile); fclose(rbmfFile);
free(rbmfFileData); // Now we can free loaded data from RAM memory 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) static SpriteFont LoadTTF(const char *fileName, int fontSize)
{ {
SpriteFont font; SpriteFont font;
Image image; Image image;
image.width = 512; image.width = 512;
image.height = 512; image.height = 512;
image.pixels = (Color *)malloc(image.width*image.height*sizeof(Color)); image.pixels = (Color *)malloc(image.width*image.height*sizeof(Color));
unsigned char *ttfBuffer = (unsigned char *)malloc(1 << 25); unsigned char *ttfBuffer = (unsigned char *)malloc(1 << 25);
// TODO: Load TTF and generate bitmap font and chars data -> REVIEW! // TODO: Load TTF and generate bitmap font and chars data -> REVIEW!
stbtt_packedchar chardata[128]; // Num characters: 128 (?) -> 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! unsigned char *tempBitmap = (unsigned char *)malloc(image.width*image.height*sizeof(unsigned char)); // One channel bitmap returned!
// REFERENCE // REFERENCE
/* /*
typedef struct typedef struct
@ -601,15 +601,15 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize)
float xoff2,yoff2; float xoff2,yoff2;
} stbtt_packedchar; } stbtt_packedchar;
*/ */
stbtt_pack_context pc; stbtt_pack_context pc;
FILE *ttfFile = fopen(fileName, "rb"); FILE *ttfFile = fopen(fileName, "rb");
fread(ttfBuffer, 1, 1<<25, ttfFile); fread(ttfBuffer, 1, 1<<25, ttfFile);
stbtt_PackBegin(&pc, tempBitmap, image.width, image.height, 0, 1, NULL); stbtt_PackBegin(&pc, tempBitmap, image.width, image.height, 0, 1, NULL);
//stbtt_PackSetOversampling(&pc, 1, 1); //stbtt_PackSetOversampling(&pc, 1, 1);
//stbtt_PackFontRange(&pc, ttfBuffer, 0, fontSize, 32, 95, chardata[0]+32); //stbtt_PackFontRange(&pc, ttfBuffer, 0, fontSize, 32, 95, chardata[0]+32);
stbtt_PackSetOversampling(&pc, 2, 2); // Better results 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_PackFontRange(&pc, ttfBuffer, 0, fontSize, 32, 95, chardata[2]+32);
stbtt_PackEnd(&pc); stbtt_PackEnd(&pc);
free(ttfBuffer); free(ttfBuffer);
// Now we have image data in tempBitmap and chardata filled... // Now we have image data in tempBitmap and chardata filled...
for (int i = 0; i < 512*512; i++) for (int i = 0; i < 512*512; i++)
{ {
image.pixels[i].r = tempBitmap[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].b = tempBitmap[i];
image.pixels[i].a = 255; image.pixels[i].a = 255;
} }
free(tempBitmap); free(tempBitmap);
// REFERENCE EXAMPLE // REFERENCE EXAMPLE
/* /*
//To draw, provide *text, posX, posY //To draw, provide *text, posX, posY
//stbtt_aligned_quad letter; //stbtt_aligned_quad letter;
//stbtt_GetPackedQuad(chardata[0], BITMAP_W, BITMAP_H, *text++, &posX, &posY, &letter, font ? 0 : integer_align); //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) void print(float x, float y, int fontNum, char *text)
{ {
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
@ -651,14 +651,14 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize)
} }
glEnd(); glEnd();
} }
print(100,160, 0, "This is a test"); print(100,160, 0, "This is a test");
*/ */
font.numChars = 95; font.numChars = 95;
font.charSet = (Character *)malloc(font.numChars*sizeof(Character)); font.charSet = (Character *)malloc(font.numChars*sizeof(Character));
font.texture = LoadTextureFromImage(image, false); font.texture = LoadTextureFromImage(image, false);
//stbtt_aligned_quad letter; //stbtt_aligned_quad letter;
//int x = 0, y = 0; //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].w = chardata[i + 32].x1 - chardata[i + 32].x0;
font.charSet[i].h = chardata[i + 32].y1 - chardata[i + 32].y0; font.charSet[i].h = chardata[i + 32].y1 - chardata[i + 32].y0;
} }
UnloadImage(image); UnloadImage(image);
return font; return font;
} }

View file

@ -187,7 +187,7 @@ Image LoadImageFromRES(const char *rresName, int resId)
FILE *rresFile = fopen(rresName, "rb"); FILE *rresFile = fopen(rresName, "rb");
if (rresFile == NULL) if (rresFile == NULL)
{ {
TraceLog(WARNING, "[%s] rRES raylib resource file could not be opened", rresName); 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 LoadTexture(const char *fileName)
{ {
Texture2D texture; Texture2D texture;
// Init texture to default values // Init texture to default values
texture.id = 0; texture.id = 0;
texture.width = 0; texture.width = 0;
@ -340,7 +340,7 @@ Texture2D LoadTexture(const char *fileName)
else else
{ {
Image image = LoadImage(fileName); Image image = LoadImage(fileName);
if (image.pixels != NULL) if (image.pixels != NULL)
{ {
#if defined(PLATFORM_RPI) || defined(PLATFORM_WEB) #if defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
@ -399,9 +399,9 @@ Texture2D LoadTextureFromImage(Image image, bool genMipmaps)
Texture2D CreateTexture(Image image, bool genMipmaps) Texture2D CreateTexture(Image image, bool genMipmaps)
{ {
Texture2D texture; Texture2D texture;
texture = LoadTextureFromImage(image, genMipmaps); texture = LoadTextureFromImage(image, genMipmaps);
TraceLog(INFO, "Created texture id: %i", texture.id); TraceLog(INFO, "Created texture id: %i", texture.id);
return texture; return texture;
@ -589,7 +589,7 @@ static ImageEx LoadDDS(const char *fileName)
ImageEx image; ImageEx image;
ddsHeader header; ddsHeader header;
image.data = NULL; image.data = NULL;
image.width = 0; image.width = 0;
image.height = 0; image.height = 0;

View file

@ -235,18 +235,18 @@ void TraceLog(int msgType, const char *text, ...)
} }
// Initialize asset manager from android app // Initialize asset manager from android app
void InitAssetManager(AAssetManager *manager) void InitAssetManager(AAssetManager *manager)
{ {
assetManager = manager; assetManager = manager;
} }
// Replacement for fopen // 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; if (mode[0] == 'w') return NULL;
AAsset *asset = AAssetManager_open(assetManager, fileName, 0); AAsset *asset = AAssetManager_open(assetManager, fileName, 0);
if(!asset) return NULL; if(!asset) return NULL;
return funopen(asset, android_read, android_write, android_seek, android_close); return funopen(asset, android_read, android_write, android_seek, android_close);
@ -292,24 +292,24 @@ int GetNextPOT(int num)
// Module specific Functions Definition // Module specific Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID) #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); 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"); TraceLog(ERROR, "Can't provide write access to the APK");
return EACCES; 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); return AAsset_seek((AAsset *)cookie, offset, whence);
} }
static int android_close(void *cookie) static int android_close(void *cookie)
{ {
AAsset_close((AAsset *)cookie); AAsset_close((AAsset *)cookie);
return 0; return 0;