diff --git a/src/audio.c b/src/audio.c index 40c24895..5963c11b 100644 --- a/src/audio.c +++ b/src/audio.c @@ -865,7 +865,6 @@ static Wave LoadOGG(char *fileName) TraceLog(DEBUG, "[%s] Total samples calculated: %i", fileName, totalSamples); - //short *data wave.data = malloc(sizeof(short)*totalSamplesLength); int samplesObtained = stb_vorbis_get_samples_short_interleaved(oggFile, info.channels, wave.data, totalSamplesLength); diff --git a/src/core.c b/src/core.c index 26b1dd6d..574de334 100644 --- a/src/core.c +++ b/src/core.c @@ -261,7 +261,7 @@ static void CommandCallback(struct android_app *app, int32_t cmd); // // Initialize Window and Graphics Context (OpenGL) void InitWindow(int width, int height, const char *title) { - TraceLog(INFO, "Initializing raylib..."); + TraceLog(INFO, "Initializing raylib (v1.2.2)"); // Store window title (could be useful...) windowTitle = title; @@ -300,7 +300,7 @@ void InitWindow(int width, int height, const char *title) // Android activity initialization void InitWindow(int width, int height, struct android_app *state) { - TraceLog(INFO, "Initializing raylib..."); + TraceLog(INFO, "Initializing raylib (v1.2.2)"); app_dummy(); diff --git a/src/models.c b/src/models.c index f61f79f5..bb172203 100644 --- a/src/models.c +++ b/src/models.c @@ -686,10 +686,13 @@ Model LoadModel(const char *fileName) Model model = rlglLoadModel(vData); // Upload vertex data to GPU // Now that vertex data is uploaded to GPU, we can free arrays - // NOTE: Despite vertex data is useless on OpenGL 3.3 or ES2, we will keep it... - //free(vData.vertices); - //free(vData.texcoords); - //free(vData.normals); + // NOTE: We don't need CPU vertex data on OpenGL 3.3 or ES2 + if (rlGetVersion() != OPENGL_11) + { + free(vData.vertices); + free(vData.texcoords); + free(vData.normals); + } return model; } @@ -803,10 +806,13 @@ Model LoadHeightmap(Image heightmap, float maxHeight) Model model = rlglLoadModel(vData); // Now that vertex data is uploaded to GPU, we can free arrays - // NOTE: Despite vertex data is useless on OpenGL 3.3 or ES2, we will keep it... - //free(vData.vertices); - //free(vData.texcoords); - //free(vData.normals); + // NOTE: We don't need CPU vertex data on OpenGL 3.3 or ES2 + if (rlGetVersion() != OPENGL_11) + { + free(vData.vertices); + free(vData.texcoords); + free(vData.normals); + } return model; } @@ -1118,10 +1124,13 @@ Model LoadCubicmap(Image cubesmap) Model model = rlglLoadModel(vData); // Now that vertex data is uploaded to GPU, we can free arrays - // NOTE: Despite vertex data is useless on OpenGL 3.3 or ES2, we will keep it... - //free(vData.vertices); - //free(vData.texcoords); - //free(vData.normals); + // NOTE: We don't need CPU vertex data on OpenGL 3.3 or ES2 + if (rlGetVersion() != OPENGL_11) + { + free(vData.vertices); + free(vData.texcoords); + free(vData.normals); + } return model; } @@ -1129,10 +1138,13 @@ Model LoadCubicmap(Image cubesmap) // Unload 3d model from memory void UnloadModel(Model model) { - free(model.mesh.vertices); - free(model.mesh.texcoords); - free(model.mesh.normals); - + if (rlGetVersion() == OPENGL_11) + { + free(model.mesh.vertices); + free(model.mesh.texcoords); + free(model.mesh.normals); + } + rlDeleteBuffers(model.vboId[0]); rlDeleteBuffers(model.vboId[1]); rlDeleteBuffers(model.vboId[2]); diff --git a/src/raylib.h b/src/raylib.h index 69966069..14590d04 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -312,7 +312,6 @@ void SetExitKey(int key); // Set a custom key #endif int GetScreenWidth(void); // Get current screen width int GetScreenHeight(void); // Get current screen height -int GetKeyPressed(void); // Get latest key pressed void ClearBackground(Color color); // Sets Background Color void BeginDrawing(void); // Setup drawing canvas to start drawing @@ -342,6 +341,7 @@ bool IsKeyPressed(int key); // Detect if a key has b bool IsKeyDown(int key); // Detect if a key is being pressed bool IsKeyReleased(int key); // Detect if a key has been released once bool IsKeyUp(int key); // Detect if a key is NOT being pressed +int GetKeyPressed(void); // Get latest key pressed bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed diff --git a/src/rlgl.c b/src/rlgl.c index 50ef1efd..2b3dfc5f 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1682,7 +1682,7 @@ static GLuint LoadSimpleShader(void) char fShaderStr[] = " #version 110 \n" // NOTE: Equivalent to version 100 on ES2 #elif defined(GRAPHICS_API_OPENGL_ES2) char fShaderStr[] = " #version 100 \n" // NOTE: Must be defined this way! 110 doesn't work! - "precision mediump float; \n" // WebGL, required for emscripten + "precision mediump float; \n" // precision required for OpenGL ES2 (WebGL) #endif "uniform sampler2D texture0; \n" "varying vec2 fragTexCoord; \n" diff --git a/src/utils.c b/src/utils.c index c3c20b47..dd08f5f8 100644 --- a/src/utils.c +++ b/src/utils.c @@ -79,7 +79,7 @@ unsigned char *DecompressData(const unsigned char *data, unsigned long compSize, pUncomp = (mz_uint8 *)malloc((size_t)uncompSize); // Check correct memory allocation - if (!pUncomp) + if (pUncomp == NULL) { TraceLog(WARNING, "Out of memory while decompressing data"); }