aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2014-10-17 21:11:58 +0200
committerraysan5 <raysan5@gmail.com>2014-10-17 21:11:58 +0200
commit9d27bba23f08e7749fd98c8b56b5fe34786926fd (patch)
tree86ca65c923fc56535d14b1e8c6bf933808518e4e /src
parent063e26c521dba1af582906df1e5b96fa37c82a16 (diff)
downloadraylib-9d27bba23f08e7749fd98c8b56b5fe34786926fd.tar.gz
raylib-9d27bba23f08e7749fd98c8b56b5fe34786926fd.zip
Small Fixes Update (1.2.1)
View CHANGELOG for description on small fixes and add-ons
Diffstat (limited to 'src')
-rw-r--r--src/core.c25
-rw-r--r--src/makefile2
-rw-r--r--src/models.c4
-rw-r--r--src/raylib.h14
-rw-r--r--src/rlgl.c2
-rw-r--r--src/rlgl.h5
-rw-r--r--src/text.c6
7 files changed, 42 insertions, 16 deletions
diff --git a/src/core.c b/src/core.c
index d4919960..1ccbb6f9 100644
--- a/src/core.c
+++ b/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?
diff --git a/src/makefile b/src/makefile
index 6f0179ab..69e7862b 100644
--- a/src/makefile
+++ b/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
diff --git a/src/models.c b/src/models.c
index ab6abb55..d69322a8 100644
--- a/src/models.c
+++ b/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
diff --git a/src/raylib.h b/src/raylib.h
index 4de67ba2..5257de58 100644
--- a/src/raylib.h
+++ b/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
//------------------------------------------------------------------------------------
diff --git a/src/rlgl.c b/src/rlgl.c
index 8f8d67e7..8f1a66a8 100644
--- a/src/rlgl.c
+++ b/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()
diff --git a/src/rlgl.h b/src/rlgl.h
index 7c8eb74b..3e9cba0e 100644
--- a/src/rlgl.h
+++ b/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)
diff --git a/src/text.c b/src/text.c
index b42d7d11..3ca237b9 100644
--- a/src/text.c
+++ b/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;
}