소스 검색

Manually review previous PR

Ray San 7 년 전
부모
커밋
53ad53d051
6개의 변경된 파일36개의 추가작업 그리고 32개의 파일을 삭제
  1. 10 11
      src/core.c
  2. 6 8
      src/raylib.h
  3. 8 4
      src/raymath.h
  4. 6 0
      src/rlgl.c
  5. 4 6
      src/rlgl.h
  6. 2 3
      src/textures.c

+ 10 - 11
src/core.c

@@ -153,9 +153,8 @@
     //#define GLFW_DLL          // Using GLFW DLL on Windows -> No, we use static version!
     
     #if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
-    // NOTE: Those functions require linking with winmm library
-    unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
-    unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
+    __stdcall unsigned int timeBeginPeriod(unsigned int uPeriod);
+    __stdcall unsigned int timeEndPeriod(unsigned int uPeriod);
     #endif
 #endif
 
@@ -352,7 +351,7 @@ extern void UnloadDefaultFont(void);        // [Module: text] Unloads default fo
 static void InitGraphicsDevice(int width, int height);  // Initialize graphics device
 static void SetupFramebufferSize(int displayWidth, int displayHeight);
 static void InitTimer(void);                            // Initialize timer
-       double GetTime(void);                            // Returns time since InitTimer() was run
+static double GetTime(void);                            // Returns time since InitTimer() was run
 static void Wait(float ms);                             // Wait for some milliseconds (stop program execution)
 static bool GetKeyStatus(int key);                      // Returns if a key has been pressed
 static bool GetMouseButtonStatus(int button);           // Returns if a mouse button has been pressed
@@ -413,7 +412,7 @@ static void *GamepadThread(void *arg);                  // Mouse reading thread
 #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
 // Initialize window and OpenGL context
 // NOTE: data parameter could be used to pass any kind of required data to the initialization
-void InitRLWindow(int width, int height, void *data)
+void InitWindow(int width, int height, void *data)
 {
     TraceLog(LOG_INFO, "Initializing raylib (v1.9-dev)");
 
@@ -477,7 +476,7 @@ void InitRLWindow(int width, int height, void *data)
 #if defined(PLATFORM_ANDROID)
 // Initialize window and OpenGL context (and Android activity)
 // NOTE: data parameter could be used to pass any kind of required data to the initialization
-void InitRLWindow(int width, int height, void *data)
+void InitWindow(int width, int height, void *data)
 {
     TraceLog(LOG_INFO, "Initializing raylib (v1.9-dev)");
 
@@ -538,7 +537,7 @@ void InitRLWindow(int width, int height, void *data)
 #endif
 
 // Close window and unload OpenGL context
-void CloseRLWindow(void)
+void CloseWindow(void)
 {
 #if defined(SUPPORT_GIF_RECORDING)
     if (gifRecording)
@@ -715,7 +714,7 @@ int GetScreenHeight(void)
 }
 
 // Show mouse cursor
-void ShowRLCursor()
+void ShowCursor()
 {
 #if defined(PLATFORM_DESKTOP)
     #if defined(__linux__)
@@ -728,7 +727,7 @@ void ShowRLCursor()
 }
 
 // Hides mouse cursor
-void HideRLCursor()
+void HideCursor()
 {
 #if defined(PLATFORM_DESKTOP)
     #if defined(__linux__)
@@ -1135,7 +1134,7 @@ void SetConfigFlags(char flags)
 // Takes a screenshot of current screen (saved a .png)
 void TakeScreenshot(const char *fileName)
 {
-#if (defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)) && defined(SUPPORT_SAVE_PNG)
+#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
     unsigned char *imgData = rlReadScreenPixels(renderWidth, renderHeight);
     SavePNG(fileName, imgData, renderWidth, renderHeight, 4); // Save image as PNG
     free(imgData);
@@ -2120,7 +2119,7 @@ static void InitTimer(void)
 }
 
 // Get current time measure (in seconds) since InitTimer()
-double GetTime(void)
+static double GetTime(void)
 {
 #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
     return glfwGetTime();

+ 6 - 8
src/raylib.h

@@ -682,8 +682,8 @@ extern "C" {            // Prevents name mangling of functions
 //------------------------------------------------------------------------------------
 
 // Window-related functions
-RLAPI void InitRLWindow(int width, int height, void *data);       // Initialize window and OpenGL context
-RLAPI void CloseRLWindow(void);                                   // Close window and unload OpenGL context
+RLAPI void InitWindow(int width, int height, void *data);         // Initialize window and OpenGL context
+RLAPI void CloseWindow(void);                                     // Close window and unload OpenGL context
 RLAPI bool WindowShouldClose(void);                               // Check if KEY_ESCAPE pressed or Close icon pressed
 RLAPI bool IsWindowMinimized(void);                               // Check if window has been minimized (or lost focus)
 RLAPI void ToggleFullscreen(void);                                // Toggle fullscreen mode (only PLATFORM_DESKTOP)
@@ -696,8 +696,8 @@ RLAPI int GetScreenWidth(void);                                   // Get current
 RLAPI int GetScreenHeight(void);                                  // Get current screen height
 
 // Cursor-related functions
-RLAPI void ShowRLCursor(void);                                    // Shows cursor
-RLAPI void HideRLCursor(void);                                    // Hides cursor
+RLAPI void ShowCursor(void);                                      // Shows cursor
+RLAPI void HideCursor(void);                                      // Hides cursor
 RLAPI bool IsCursorHidden(void);                                  // Check if cursor is not visible
 RLAPI void EnableCursor(void);                                    // Enables cursor (unlock cursor)
 RLAPI void DisableCursor(void);                                   // Disables cursor (lock cursor)
@@ -722,9 +722,7 @@ RLAPI Matrix GetCameraMatrix(Camera camera);                      // Returns cam
 RLAPI void SetTargetFPS(int fps);                                 // Set target FPS (maximum)
 RLAPI int GetFPS(void);                                           // Returns current FPS
 RLAPI float GetFrameTime(void);                                   // Returns time in seconds for last frame drawn
-
-RLAPI double GetTime(void);                                       // Return time in seconds
-
+//RLAPI double GetCurrentTime(void);                                // Return current time in seconds
 
 // Color-related functions
 RLAPI int GetHexValue(Color color);                               // Returns hexadecimal value for a Color
@@ -1049,7 +1047,7 @@ RLAPI void SetShaderValuei(Shader shader, int uniformLoc, const int *value, int
 RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat);       // Set shader uniform value (matrix 4x4)
 RLAPI void SetMatrixProjection(Matrix proj);                              // Set a custom projection matrix (replaces internal projection matrix)
 RLAPI void SetMatrixModelview(Matrix view);                               // Set a custom modelview matrix (replaces internal modelview matrix)
-RLAPI Matrix GetMatrixModelview();
+RLAPI Matrix GetMatrixModelview();                                        // Get internal modelview matrix
 
 // Texture maps generation (PBR)
 // NOTE: Required shaders should be provided

+ 8 - 4
src/raymath.h

@@ -227,13 +227,15 @@ RMDEF float Clamp(float value, float min, float max)
 //----------------------------------------------------------------------------------
 
 // Vector with components value 0.0f
-RMDEF Vector2 Vector2Zero(void) { 
+RMDEF Vector2 Vector2Zero(void) 
+{ 
     Vector2 tmp = {0.0f, 0.0f};
     return tmp;
 }
 
 // Vector with components value 1.0f
-RMDEF Vector2 Vector2One(void) { 
+RMDEF Vector2 Vector2One(void) 
+{ 
     Vector2 tmp = {1.0f, 1.0f};
     return tmp;
 }
@@ -312,13 +314,15 @@ RMDEF void Vector2Normalize(Vector2 *v)
 //----------------------------------------------------------------------------------
 
 // Vector with components value 0.0f
-RMDEF Vector3 Vector3Zero(void) { 
+RMDEF Vector3 Vector3Zero(void) 
+{ 
     Vector3 tmp = { 0.0f, 0.0f, 0.0f };
     return tmp; 
 }
 
 // Vector with components value 1.0f
-RMDEF Vector3 Vector3One(void) { 
+RMDEF Vector3 Vector3One(void) 
+{ 
     Vector3 tmp = { 1.0f, 1.0f, 1.0f };
     return tmp; 
 }

+ 6 - 0
src/rlgl.c

@@ -1293,6 +1293,12 @@ int rlGetVersion(void)
 #endif
 }
 
+// Set debug marker
+void rlSetDebugMarker(const char *text)
+{
+    if(debugMarkerSupported) glInsertEventMarkerEXT(0, text);   // 0 terminated string
+}
+
 // Load OpenGL extensions
 // NOTE: External loader function could be passed as a pointer
 void rlLoadExtensions(void *loader)

+ 4 - 6
src/rlgl.h

@@ -422,6 +422,7 @@ void rlglClose(void);                           // De-inititialize rlgl (buffers
 void rlglDraw(void);                            // Update and Draw default buffers (lines, triangles, quads)
 
 int rlGetVersion(void);                         // Returns current OpenGL version
+void rlDebugSetMarker(const char *text);        // Set debug marker for analysis
 void rlLoadExtensions(void *loader);            // Load OpenGL extensions
 Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view);  // Get world coordinates from screen coordinates
 
@@ -440,9 +441,6 @@ void rlUpdateMesh(Mesh mesh, int buffer, int numVertex);            // Update ve
 void rlDrawMesh(Mesh mesh, Material material, Matrix transform);    // Draw a 3d mesh with material and transform
 void rlUnloadMesh(Mesh *mesh);                                      // Unload mesh data from CPU and GPU
 
-// Debug Marker for Analysis
-void rlSetMarker(const char *text);
-
 // NOTE: There is a set of shader related functions that are available to end user,
 // to avoid creating function wrappers through core module, they have been directly declared in raylib.h
 
@@ -462,9 +460,9 @@ int GetShaderLocation(Shader shader, const char *uniformName);              // G
 void SetShaderValue(Shader shader, int uniformLoc, const float *value, int size); // Set shader uniform value (float)
 void SetShaderValuei(Shader shader, int uniformLoc, const int *value, int size);  // Set shader uniform value (int)
 void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat);       // Set shader uniform value (matrix 4x4)
-void SetMatrixProjection(Matrix proj);                              // Set a custom projection matrix (replaces internal projection matrix)
-void SetMatrixModelview(Matrix view);                               // Set a custom modelview matrix (replaces internal modelview matrix)
-Matrix GetMatrixModelview();
+void SetMatrixProjection(Matrix proj);                  // Set a custom projection matrix (replaces internal projection matrix)
+void SetMatrixModelview(Matrix view);                   // Set a custom modelview matrix (replaces internal modelview matrix)
+Matrix GetMatrixModelview();                            // Get internal modelview matrix            
 
 
 // Texture maps generation (PBR)

+ 2 - 3
src/textures.c

@@ -554,13 +554,12 @@ void UpdateTexture(Texture2D texture, const void *pixels)
 // Save image to a PNG file
 void SaveImageAs(const char* fileName, Image image)
 {
-#if (defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)) && defined(SUPPORT_SAVE_PNG)
-    unsigned char* imgData = (unsigned char*)GetImageData(image); // this works since Color is just a container for the RGBA values
+    // NOTE: Getting Color array as RGBA unsigned char values
+    unsigned char* imgData = (unsigned char*)GetImageData(image);
     SavePNG(fileName, imgData, image.width, image.height, 4);
     free(imgData);
 
     TraceLog(LOG_INFO, "Image saved: %s", fileName);
-#endif
 }
 
 // Convert image data to desired format