Procházet zdrojové kódy

Some code tweaks

pull/19/head
raysan5 před 10 roky
rodič
revize
5104567a24
6 změnil soubory, kde provedl 33 přidání a 22 odebrání
  1. +0
    -1
      src/audio.c
  2. +2
    -2
      src/core.c
  3. +28
    -16
      src/models.c
  4. +1
    -1
      src/raylib.h
  5. +1
    -1
      src/rlgl.c
  6. +1
    -1
      src/utils.c

+ 0
- 1
src/audio.c Zobrazit soubor

@ -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);

+ 2
- 2
src/core.c Zobrazit soubor

@ -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();

+ 28
- 16
src/models.c Zobrazit soubor

@ -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]);

+ 1
- 1
src/raylib.h Zobrazit soubor

@ -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

+ 1
- 1
src/rlgl.c Zobrazit soubor

@ -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"

+ 1
- 1
src/utils.c Zobrazit soubor

@ -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 (o">!pUncomp)
if (n">pUncomp == NULL)
{
TraceLog(WARNING, "Out of memory while decompressing data");
}

Načítá se…
Zrušit
Uložit