aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2015-01-18 10:57:30 +0100
committerraysan5 <raysan5@gmail.com>2015-01-18 10:57:30 +0100
commit5104567a24021fb07e62f941b4b9e64f4bda56e7 (patch)
treeefbe8719ae383edd60b08d0969377218e275430a /src
parent2968ba9938792753a876deb3e2584f3361c60b4d (diff)
downloadraylib-5104567a24021fb07e62f941b4b9e64f4bda56e7.tar.gz
raylib-5104567a24021fb07e62f941b4b9e64f4bda56e7.zip
Some code tweaks
Diffstat (limited to 'src')
-rw-r--r--src/audio.c1
-rw-r--r--src/core.c4
-rw-r--r--src/models.c44
-rw-r--r--src/raylib.h2
-rw-r--r--src/rlgl.c2
-rw-r--r--src/utils.c2
6 files changed, 33 insertions, 22 deletions
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");
}