Some code tweaks
This commit is contained in:
parent
2968ba9938
commit
5104567a24
6 changed files with 33 additions and 22 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
44
src/models.c
44
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]);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue