Merge remote-tracking branch 'upstream/develop' into staging-linux-gitignore

This commit is contained in:
RDR8 2017-03-21 11:19:34 -05:00
commit 314e1e0fd5
3 changed files with 56 additions and 24 deletions

View File

@ -29,13 +29,15 @@
* Windowing and input system configured for HTML5 (run on browser), code converted from C to asm.js
* using emscripten compiler. OpenGL ES 2.0 required for direct translation to WebGL equivalent code.
*
* #define LOAD_DEFAULT_FONT (defined by default)
* #define SUPPORT_DEFAULT_FONT (default)
* Default font is loaded on window initialization to be available for the user to render simple text.
* NOTE: If enabled, uses external module functions to load default raylib font (module: text)
*
* #define INCLUDE_CAMERA_SYSTEM / SUPPORT_CAMERA_SYSTEM
* #define SUPPORT_CAMERA_SYSTEM
* Camera module is included (camera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
*
* #define INCLUDE_GESTURES_SYSTEM / SUPPORT_GESTURES_SYSTEM
* #define SUPPORT_GESTURES_SYSTEM
* Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag
*
* #define SUPPORT_MOUSE_GESTURES
* Mouse gestures are directly mapped like touches and processed by gestures system.
@ -68,6 +70,14 @@
*
**********************************************************************************************/
// Default supported features
//-------------------------------------
#define SUPPORT_DEFAULT_FONT
#define SUPPORT_MOUSE_GESTURES
#define SUPPORT_CAMERA_SYSTEM
#define SUPPORT_GESTURES_SYSTEM
//-------------------------------------
#include "raylib.h"
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
@ -77,10 +87,12 @@
#define RAYMATH_EXTERN_INLINE // Compile raymath functions as static inline (remember, it's a compiler hint)
#include "raymath.h" // Required for: Vector3 and Matrix functions
#define GESTURES_IMPLEMENTATION
#include "gestures.h" // Gestures detection functionality
#if defined(SUPPORT_GESTURES_SYSTEM)
#define GESTURES_IMPLEMENTATION
#include "gestures.h" // Gestures detection functionality
#endif
#if !defined(PLATFORM_ANDROID)
#if defined(SUPPORT_CAMERA_SYSTEM) && !defined(PLATFORM_ANDROID)
#define CAMERA_IMPLEMENTATION
#include "camera.h" // Camera system functionality
#endif
@ -147,8 +159,6 @@
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
#define STORAGE_FILENAME "storage.data"
#if defined(PLATFORM_RPI)
// Old device inputs system
#define DEFAULT_KEYBOARD_DEV STDIN_FILENO // Standard input
@ -168,7 +178,7 @@
#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad)
#define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad)
#define LOAD_DEFAULT_FONT // Load default font on window initialization (module: text)
#define STORAGE_FILENAME "storage.data"
//----------------------------------------------------------------------------------
// Types and Structures Definition
@ -266,7 +276,10 @@ static int lastGamepadButtonPressed = -1; // Register last gamepad button pres
static int gamepadAxisCount = 0; // Register number of available gamepad axis
static Vector2 mousePosition; // Mouse position on screen
#if defined(SUPPORT_GESTURES_SYSTEM)
static Vector2 touchPosition[MAX_TOUCH_POINTS]; // Touch position on screen
#endif
#if defined(PLATFORM_DESKTOP)
static char **dropFilesPath; // Store dropped files paths as strings
@ -284,7 +297,7 @@ static bool showLogo = false; // Track if showing logo at init is
//----------------------------------------------------------------------------------
// Other Modules Functions Declaration (required by core)
//----------------------------------------------------------------------------------
#if defined(LOAD_DEFAULT_FONT)
#if defined(SUPPORT_DEFAULT_FONT)
extern void LoadDefaultFont(void); // [Module: text] Loads default font on InitWindow()
extern void UnloadDefaultFont(void); // [Module: text] Unloads default font from GPU memory
#endif
@ -366,7 +379,7 @@ void InitWindow(int width, int height, const char *title)
// Init graphics device (display device and OpenGL context)
InitGraphicsDevice(width, height);
#if defined(LOAD_DEFAULT_FONT)
#if defined(SUPPORT_DEFAULT_FONT)
// Load default font
// NOTE: External function (defined in module: text)
LoadDefaultFont();
@ -478,7 +491,7 @@ void InitWindow(int width, int height, void *state)
// Close Window and Terminate Context
void CloseWindow(void)
{
#if defined(LOAD_DEFAULT_FONT)
#if defined(SUPPORT_DEFAULT_FONT)
UnloadDefaultFont();
#endif
@ -2071,9 +2084,11 @@ static bool GetMouseButtonStatus(int button)
// Poll (store) all input events
static void PollInputEvents(void)
{
#if defined(SUPPORT_GESTURES_SYSTEM)
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures();
#endif
// Reset last key pressed registered
lastKeyPressed = -1;
@ -2303,8 +2318,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
{
currentMouseState[button] = action;
#define ENABLE_MOUSE_GESTURES
#if defined(ENABLE_MOUSE_GESTURES)
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent;
@ -2335,8 +2349,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
// GLFW3 Cursor Position Callback, runs on mouse move
static void MouseCursorPosCallback(GLFWwindow *window, double x, double y)
{
#define ENABLE_MOUSE_GESTURES
#if defined(ENABLE_MOUSE_GESTURES)
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent;
@ -2466,7 +2479,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
// Init graphics device (display device and OpenGL context)
InitGraphicsDevice(screenWidth, screenHeight);
#if defined(LOAD_DEFAULT_FONT)
#if defined(SUPPORT_DEFAULT_FONT)
// Load default font
// NOTE: External function (defined in module: text)
LoadDefaultFont();

View File

@ -251,7 +251,7 @@ static Matrix projection;
static Matrix *currentMatrix;
static int currentMatrixMode;
static DrawMode currentDrawMode;
static int currentDrawMode;
static float currentDepth = -1.0f;

View File

@ -10,7 +10,7 @@
* Selected desired fileformats to be supported for loading. Some of those formats are
* supported by default, to remove support, just comment unrequired #define in this module
*
* #define INCLUDE_DEFAULT_FONT / SUPPORT_DEFAULT_FONT
* #define SUPPORT_DEFAULT_FONT
*
* DEPENDENCIES:
* stb_truetype - Load TTF file and rasterize characters data
@ -37,6 +37,11 @@
*
**********************************************************************************************/
// Default supported features
//-------------------------------------
#define SUPPORT_DEFAULT_FONT
//-------------------------------------
#include "raylib.h"
#include <stdlib.h> // Required for: malloc(), free()
@ -61,8 +66,6 @@
#define MAX_FORMATTEXT_LENGTH 64
#define MAX_SUBTEXT_LENGTH 64
#define BIT_CHECK(a,b) ((a) & (1 << (b)))
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
@ -71,8 +74,10 @@
//----------------------------------------------------------------------------------
// Global variables
//----------------------------------------------------------------------------------
#if defined(SUPPORT_DEFAULT_FONT)
static SpriteFont defaultFont; // Default font provided by raylib
// NOTE: defaultFont is loaded on InitWindow and disposed on CloseWindow [module: core]
#endif
//----------------------------------------------------------------------------------
// Other Modules Functions Declaration (required by text)
@ -89,14 +94,21 @@ static SpriteFont LoadRBMF(const char *fileName); // Load a rBMF font file (ra
static SpriteFont LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load spritefont from TTF data
#if defined(SUPPORT_DEFAULT_FONT)
extern void LoadDefaultFont(void);
extern void UnloadDefaultFont(void);
#endif
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
#if defined(SUPPORT_DEFAULT_FONT)
// Load raylib default font
extern void LoadDefaultFont(void)
{
#define BIT_CHECK(a,b) ((a) & (1 << (b)))
// NOTE: Using UTF8 encoding table for Unicode U+0000..U+00FF Basic Latin + Latin-1 Supplement
// http://www.utf8-chartable.de/unicode-utf8-table.pl
@ -241,16 +253,23 @@ extern void LoadDefaultFont(void)
TraceLog(INFO, "[TEX ID %i] Default font loaded successfully", defaultFont.texture.id);
}
// Unload raylib default font
extern void UnloadDefaultFont(void)
{
UnloadTexture(defaultFont.texture);
free(defaultFont.chars);
}
#endif // SUPPORT_DEFAULT_FONT
// Get the default font, useful to be used with extended parameters
SpriteFont GetDefaultFont()
{
#if defined(SUPPORT_DEFAULT_FONT)
return defaultFont;
#else
SpriteFont font = { 0 };
return font;
#endif
}
// Load SpriteFont from file into GPU memory (VRAM)
@ -345,7 +364,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount,
void UnloadSpriteFont(SpriteFont spriteFont)
{
// NOTE: Make sure spriteFont is not default font (fallback)
if (spriteFont.texture.id != defaultFont.texture.id)
if (spriteFont.texture.id != GetDefaultFont().texture.id)
{
UnloadTexture(spriteFont.texture);
free(spriteFont.chars);
@ -360,7 +379,7 @@ void UnloadSpriteFont(SpriteFont spriteFont)
void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
{
// Check if default font has been loaded
if (defaultFont.texture.id != 0)
if (GetDefaultFont().texture.id != 0)
{
Vector2 position = { (float)posX, (float)posY };
@ -471,7 +490,7 @@ int MeasureText(const char *text, int fontSize)
Vector2 vec = { 0.0f, 0.0f };
// Check if default font has been loaded
if (defaultFont.texture.id != 0)
if (GetDefaultFont().texture.id != 0)
{
int defaultFontSize = 10; // Default Font chars height in pixel
if (fontSize < defaultFontSize) fontSize = defaultFontSize;