Jelajahi Sumber

Small Fixes Update (1.2.1)

View CHANGELOG for description on small fixes and add-ons
raysan5 11 tahun lalu
induk
melakukan
9d27bba23f
10 mengubah file dengan 65 tambahan dan 17 penghapusan
  1. 9 1
      CHANGELOG
  2. 14 0
      release/win32-mingw/include/raylib.h
  3. TEMPAT SAMPAH
      release/win32-mingw/lib/libraylib.a
  4. 18 7
      src/core.c
  5. 1 1
      src/makefile
  6. 3 1
      src/models.c
  7. 14 0
      src/raylib.h
  8. 1 1
      src/rlgl.c
  9. 0 5
      src/rlgl.h
  10. 5 1
      src/text.c

+ 9 - 1
CHANGELOG

@@ -3,9 +3,17 @@ changelog
 
 Current Release:    raylib 1.2 (16 September 2014)
 
-NOTE: Only versions marked as 'Release' are available on release folder, updates are only available as source.
+NOTE: Only versions marked as 'Release' are available in installer, updates are only available as source.
 NOTE: Current Release includes all previous updates.
 
+---------------------------------------------------------------
+Update:     raylib 1.2.1 (17 October 2014) (Small Fixes Update)
+---------------------------------------------------------------
+[core] Added function SetupFlags() to preconfigure raylib Window
+[core] Corrected bug on fullscreen mode
+[rlgl] rlglDrawmodel() - Added rotation on Y axis
+[text] MeasureTextEx() - Corrected bug on measures for default font
+
 -----------------------------------------------
 Release:     raylib 1.2 (16 September 2014)
 -----------------------------------------------

+ 14 - 0
release/win32-mingw/include/raylib.h

@@ -64,6 +64,11 @@
 //#define PLATFORM_ANDROID      // Android device
 //#define PLATFORM_RPI          // Raspberry Pi
 
+// Security check in case no PLATFORM_* defined
+#if !defined(PLATFORM_DESKTOP) && !defined(PLATFORM_ANDROID) && !defined(PLATFORM_RPI)
+    #define PLATFORM_DESKTOP
+#endif
+
 #if defined(PLATFORM_ANDROID)
     #include <android_native_app_glue.h>    // Defines android_app struct
 #endif
@@ -78,6 +83,13 @@
 #define DEG2RAD (PI / 180.0f)
 #define RAD2DEG (180.0f / PI)
 
+// raylib Config Flags
+#define FLAG_FULLSCREEN_MODE    1
+#define FLAG_SHOW_LOGO          2
+#define FLAG_SHOW_MOUSE_CURSOR  4
+#define FLAG_CENTERED_MODE      8
+#define FLAG_MSAA_4X_HINT      16
+
 // Keyboard Function Keys 
 #define KEY_SPACE            32
 #define KEY_ESCAPE          256
@@ -300,6 +312,8 @@ int GetHexValue(Color color);                               // Returns hexadecim
 int GetRandomValue(int min, int max);                       // Returns a random value between min and max (both included)
 Color Fade(Color color, float alpha);                       // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
 
+void SetupFlags(char flags);                                // Enable some window configurations
+
 void ShowLogo(void);                                        // Activates raylib logo at startup
 
 //------------------------------------------------------------------------------------

TEMPAT SAMPAH
release/win32-mingw/lib/libraylib.a


+ 18 - 7
src/core.c

@@ -162,9 +162,10 @@ static Matrix downscaleView;                // Matrix to downscale view (in case
 
 #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
 static const char *windowTitle;             // Window text title...
+static char configFlags = 0;
 
 static bool customCursor = false;           // Tracks if custom cursor has been set
-static bool cursorOnScreen = false;         // Tracks if cursor is inside client area
+static bool cursorOnScreen = true;          // Tracks if cursor is inside client area
 static Texture2D cursor;                    // Cursor texture
 
 static Vector2 mousePosition;
@@ -592,6 +593,16 @@ Color Fade(Color color, float alpha)
     return (Color){color.r, color.g, color.b, color.a*alpha};
 }
 
+// Enable some window configurations (SetWindowFlags()?)
+// TODO: Review function name and usage
+void SetupFlags(char flags)
+{
+    configFlags = flags;
+
+    if (configFlags & FLAG_SHOW_LOGO) showLogo = true;
+    if (configFlags & FLAG_FULLSCREEN_MODE) fullscreen = true;
+}
+
 // Activates raylib logo at startup
 void ShowLogo(void)
 {
@@ -892,7 +903,7 @@ static void InitDisplay(int width, int height)
     //glfwWindowHint(GLFW_RED_BITS, 8);           // Bit depths of color components for default framebuffer
     //glfwWindowHint(GLFW_REFRESH_RATE, 0);       // Refresh rate for fullscreen window
     //glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);    // Default OpenGL API to use. Alternative: GLFW_OPENGL_ES_API
-    //glfwWindowHint(GLFW_AUX_BUFFERS, 0);          // Number of auxiliar buffers
+    //glfwWindowHint(GLFW_AUX_BUFFERS, 0);        // Number of auxiliar buffers
 
     // NOTE: When asking for an OpenGL context version, most drivers provide highest supported version 
     // with forward compatibility to older OpenGL versions.
@@ -914,7 +925,7 @@ static void InitDisplay(int width, int height)
         // NOTE: This function use and modify global module variables: screenWidth/screenHeight and renderWidth/renderHeight and downscaleView
         SetupFramebufferSize(displayWidth, displayHeight);
 
-        window = glfwCreateWindow(screenWidth, screenHeight, windowTitle, glfwGetPrimaryMonitor(), NULL);
+        window = glfwCreateWindow(renderWidth, renderHeight, windowTitle, glfwGetPrimaryMonitor(), NULL);
     }
     else
     {
@@ -946,7 +957,7 @@ static void InitDisplay(int width, int height)
 
     glfwMakeContextCurrent(window);
 
-    //glfwSwapInterval(0);            // Disables GPU v-sync (if set), so frames are not limited to screen refresh rate (60Hz -> 60 FPS)
+    //glfwSwapInterval(0);          // Disables GPU v-sync (if set), so frames are not limited to screen refresh rate (60Hz -> 60 FPS)
                                     // If not set, swap interval uses GPU v-sync configuration
                                     // Framerate can be setup using SetTargetFPS()
 
@@ -1144,11 +1155,11 @@ static void CursorEnterCallback(GLFWwindow *window, int enter)
 static void WindowSizeCallback(GLFWwindow *window, int width, int height)
 {
     // If window is resized, graphics device is re-initialized (but only ortho mode)
-    rlglInitGraphics(0, 0, width, height);
+    rlglInitGraphics(renderOffsetX, renderOffsetY, renderWidth, renderHeight);
 
     // Window size must be updated to be used on 3D mode to get new aspect ratio (Begin3dMode())
-    screenWidth = width;
-    screenHeight = height;
+    //screenWidth = width;
+    //screenHeight = height;
 
     // TODO: Update render size?
 

+ 1 - 1
src/makefile

@@ -33,7 +33,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
     GRAPHICS = GRAPHICS_API_OPENGL_ES2
 else
     # define raylib graphics api to use (on Windows desktop, OpenGL 1.1 by default)
-    GRAPHICS = GRAPHICS_API_OPENGL_11
+    GRAPHICS ?= GRAPHICS_API_OPENGL_11
     #GRAPHICS = GRAPHICS_API_OPENGL_33  # Uncomment to use OpenGL 3.3
 endif
 

+ 3 - 1
src/models.c

@@ -448,7 +448,7 @@ void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, fl
 // Draw a plane
 void DrawPlane(Vector3 centerPos, Vector2 size, Vector3 rotation, Color color)
 {
-    // NOTE: QUADS usage require defining a texture
+    // NOTE: QUADS usage require defining a texture on OpenGL 3.3+
     rlEnableTexture(1);    // Default white texture
 
     // NOTE: Plane is always created on XZ ground and then rotated
@@ -1145,6 +1145,7 @@ void DrawModelWires(Model model, Vector3 position, float scale, Color color)
 }
 
 // Draw a billboard
+// TODO: Math review...
 void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint)
 {
     // NOTE: Billboard size will maintain texture aspect ratio, size will be billboard width
@@ -1188,6 +1189,7 @@ void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size,
 }
 
 // Draw a billboard (part of a texture defined by a rectangle)
+// TODO: Math review...
 void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint)
 {
     // NOTE: Billboard size will maintain sourceRec aspect ratio, size will represent billboard width

+ 14 - 0
src/raylib.h

@@ -64,6 +64,11 @@
 //#define PLATFORM_ANDROID      // Android device
 //#define PLATFORM_RPI          // Raspberry Pi
 
+// Security check in case no PLATFORM_* defined
+#if !defined(PLATFORM_DESKTOP) && !defined(PLATFORM_ANDROID) && !defined(PLATFORM_RPI)
+    #define PLATFORM_DESKTOP
+#endif
+
 #if defined(PLATFORM_ANDROID)
     #include <android_native_app_glue.h>    // Defines android_app struct
 #endif
@@ -78,6 +83,13 @@
 #define DEG2RAD (PI / 180.0f)
 #define RAD2DEG (180.0f / PI)
 
+// raylib Config Flags
+#define FLAG_FULLSCREEN_MODE    1
+#define FLAG_SHOW_LOGO          2
+#define FLAG_SHOW_MOUSE_CURSOR  4
+#define FLAG_CENTERED_MODE      8
+#define FLAG_MSAA_4X_HINT      16
+
 // Keyboard Function Keys 
 #define KEY_SPACE            32
 #define KEY_ESCAPE          256
@@ -300,6 +312,8 @@ int GetHexValue(Color color);                               // Returns hexadecim
 int GetRandomValue(int min, int max);                       // Returns a random value between min and max (both included)
 Color Fade(Color color, float alpha);                       // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
 
+void SetupFlags(char flags);                                // Enable some window configurations
+
 void ShowLogo(void);                                        // Activates raylib logo at startup
 
 //------------------------------------------------------------------------------------

+ 1 - 1
src/rlgl.c

@@ -1092,7 +1092,7 @@ void rlglDrawModel(Model model, Vector3 position, Vector3 rotation, Vector3 scal
     rlPushMatrix();
         rlTranslatef(position.x, position.y, position.z);
         rlScalef(scale.x, scale.y, scale.z);
-        //rlRotatef(rotation, 0, 1, 0);
+        rlRotatef(rotation.y, 0, 1, 0);
 
         // TODO: If rotate in multiple axis, get rotation matrix and use rlMultMatrix()
 

+ 0 - 5
src/rlgl.h

@@ -52,11 +52,6 @@
     #define GRAPHICS_API_OPENGL_11
 #endif
 
-// Security check in case no GRAPHICS_API_OPENGL_* defined
-#if !defined(GRAPHICS_API_OPENGL_11) && !defined(GRAPHICS_API_OPENGL_33) && !defined(GRAPHICS_API_OPENGL_ES2)
-    #define GRAPHICS_API_OPENGL_11
-#endif
-
 // Security check in case multiple GRAPHICS_API_OPENGL_* defined
 #if defined(GRAPHICS_API_OPENGL_11)
     #if defined(GRAPHICS_API_OPENGL_33)

+ 5 - 1
src/text.c

@@ -340,7 +340,11 @@ int MeasureText(const char *text, int fontSize)
 {
     Vector2 vec;
 
-    vec = MeasureTextEx(defaultFont, text, fontSize, 1);
+    int defaultFontSize = 10;   // Default Font chars height in pixel
+    if (fontSize < defaultFontSize) fontSize = defaultFontSize;
+    int spacing = fontSize / defaultFontSize;
+
+    vec = MeasureTextEx(defaultFont, text, fontSize, spacing);
 
     return (int)vec.x;
 }