浏览代码

Merge pull request #1 from raysan5/master

Update
Berni8k 6 年之前
父节点
当前提交
464a559020
共有 5 个文件被更改,包括 26 次插入13 次删除
  1. 1 2
      examples/models/models_yaw_pitch_roll.c
  2. 0 3
      src/Makefile
  3. 3 2
      src/audio.c
  4. 1 1
      src/core.c
  5. 21 5
      src/rlgl.h

+ 1 - 2
examples/models/models_yaw_pitch_roll.c

@@ -5,8 +5,7 @@
 *   This example has been created using raylib 1.8 (www.raylib.com)
 *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
 *
-*   Example based on Berni work on Raspberry Pi:
-*   http://forum.raylib.com/index.php?p=/discussion/124/line-versus-triangle-drawing-order
+*   Example based on Berni work on Raspberry Pi.
 *
 *   Copyright (c) 2017 Ramon Santamaria (@raysan5)
 *

+ 0 - 3
src/Makefile

@@ -342,9 +342,6 @@ endif
 INCLUDE_PATHS = -I. -Iexternal/glfw/include
 
 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-    ifeq ($(PLATFORM_OS),WINDOWS)
-        INCLUDE_PATHS += -Iexternal
-    endif
     ifeq ($(PLATFORM_OS),BSD)
         INCLUDE_PATHS += -I/usr/local/include
         LDFLAGS += -L. -Lsrc -L/usr/local/lib -L$(RAYLIB_RELEASE_PATH)

+ 3 - 2
src/audio.c

@@ -1158,8 +1158,9 @@ Music LoadMusicStream(const char *fileName)
             
             music->stream = InitAudioStream(music->ctxMp3.sampleRate, 32, music->ctxMp3.channels);
             
-            // TODO: It seems the total number of samples is not obtained correctly...
-            music->totalSamples = (unsigned int)music->ctxMp3.framesRemaining*music->ctxMp3.channels;
+            // TODO: There is not an easy way to compute the total number of samples available
+            // in an MP3, frames size could be variable... we tried with a 60 seconds music... but crashes...
+            music->totalSamples = 60*music->ctxMp3.sampleRate*music->ctxMp3.channels;
             music->samplesLeft = music->totalSamples;
             music->ctxType = MUSIC_AUDIO_MP3;
             music->loopCount = -1;                       // Infinite loop by default

+ 1 - 1
src/core.c

@@ -125,7 +125,7 @@
 #include <ctype.h>          // Required for: tolower() [Used in IsFileExtension()]
 #include <sys/stat.h>       // Required for stat() [Used in GetLastWriteTime()]
 
-#if defined(_WIN32) && defined(_MSC_VER)
+#if defined(PLATFORM_DESKTOP) && defined(_WIN32) && defined(_MSC_VER)
     #include "external/dirent.h"    // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()]
 #else
     #include <dirent.h>             // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()]

+ 21 - 5
src/rlgl.h

@@ -1506,9 +1506,17 @@ void rlDeleteTextures(unsigned int id)
 void rlDeleteRenderTextures(RenderTexture2D target)
 {
 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
-    if (target.id > 0) glDeleteFramebuffers(1, &target.id);
     if (target.texture.id > 0) glDeleteTextures(1, &target.texture.id);
-    if (target.depth.id > 0) glDeleteTextures(1, &target.depth.id);
+    if (target.depth.id > 0) 
+    {
+#if defined(GRAPHICS_API_OPENGL_ES2)
+        glDeleteRenderbuffers(1, &target.depth.id);
+#elif defined(GRAPHICS_API_OPENGL_33)
+        glDeleteTextures(1, &target.depth.id);
+#endif
+    }
+
+    if (target.id > 0) glDeleteFramebuffers(1, &target.id);
 
     TraceLog(LOG_INFO, "[FBO ID %i] Unloaded render texture data from VRAM (GPU)", target.id);
 #endif
@@ -2171,7 +2179,7 @@ void rlUnloadTexture(unsigned int id)
 // Load a texture to be used for rendering (fbo with color and depth attachments)
 RenderTexture2D rlLoadRenderTexture(int width, int height)
 {
-    RenderTexture2D target;
+    RenderTexture2D target = { 0 };
 
     target.id = 0;
 
@@ -2251,8 +2259,16 @@ RenderTexture2D rlLoadRenderTexture(int width, int height)
             default: break;
         }
 
-        glDeleteTextures(1, &target.texture.id);
-        glDeleteTextures(1, &target.depth.id);
+        if (target.texture.id > 0) glDeleteTextures(1, &target.texture.id);
+        if (target.depth.id > 0) 
+        {
+#if defined(GRAPHICS_API_OPENGL_ES2)
+            glDeleteRenderbuffers(1, &target.depth.id);
+#elif defined(GRAPHICS_API_OPENGL_33)
+            glDeleteTextures(1, &target.depth.id);
+#endif
+        }
+        
         glDeleteFramebuffers(1, &target.id);
     }
     else TraceLog(LOG_INFO, "[FBO ID %i] Framebuffer object created successfully", target.id);