summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorRay <[email protected]>2017-08-25 01:53:15 +0200
committerGitHub <[email protected]>2017-08-25 01:53:15 +0200
commitc074783861994fb9f3bcc618b776a41dc57b50d0 (patch)
tree63fdca2144cd13f6a537e76d6a3f8712ae106ead /src/core.c
parent910b4b5d53d9a904070807de5e8a66edadd939e3 (diff)
parent0fc1323c80c2501c36741c05fd771ac1d001d049 (diff)
downloadraylib-c074783861994fb9f3bcc618b776a41dc57b50d0.tar.gz
raylib-c074783861994fb9f3bcc618b776a41dc57b50d0.zip
Merge pull request #346 from raysan5/develop
Integrate Develop branch
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c258
1 files changed, 95 insertions, 163 deletions
diff --git a/src/core.c b/src/core.c
index 07f3bb07..78c0a7ef 100644
--- a/src/core.c
+++ b/src/core.c
@@ -109,6 +109,10 @@
#include "external/gif.h" // Support GIF recording
#endif
+#if defined(__linux__) || defined(PLATFORM_WEB)
+ #define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext.
+#endif
+
#include <stdio.h> // Standard input / output lib
#include <stdlib.h> // Required for: malloc(), free(), rand(), atexit()
#include <stdint.h> // Required for: typedef unsigned long long int uint64_t, used by hi-res timer
@@ -328,7 +332,6 @@ static char configFlags = 0; // Configuration flags (bit based)
static bool showLogo = false; // Track if showing logo at init is enabled
#if defined(SUPPORT_GIF_RECORDING)
-static GifWriter gifWriter;
static int gifFramesCounter = 0;
static bool gifRecording = false;
#endif
@@ -409,7 +412,7 @@ static void *GamepadThread(void *arg); // Mouse reading thread
// Initialize window and OpenGL context
void InitWindow(int width, int height, const char *title)
{
- TraceLog(INFO, "Initializing raylib (v1.7.0)");
+ TraceLog(LOG_INFO, "Initializing raylib (v1.8.0)");
// Store window title (could be useful...)
windowTitle = title;
@@ -472,7 +475,7 @@ void InitWindow(int width, int height, const char *title)
// Initialize Android activity
void InitWindow(int width, int height, void *state)
{
- TraceLog(INFO, "Initializing raylib (v1.7.0)");
+ TraceLog(LOG_INFO, "Initializing raylib (v1.8.0)");
app_dummy();
@@ -488,19 +491,19 @@ void InitWindow(int width, int height, void *state)
int orientation = AConfiguration_getOrientation(app->config);
- if (orientation == ACONFIGURATION_ORIENTATION_PORT) TraceLog(INFO, "PORTRAIT window orientation");
- else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TraceLog(INFO, "LANDSCAPE window orientation");
+ if (orientation == ACONFIGURATION_ORIENTATION_PORT) TraceLog(LOG_INFO, "PORTRAIT window orientation");
+ else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TraceLog(LOG_INFO, "LANDSCAPE window orientation");
// TODO: Automatic orientation doesn't seem to work
if (width <= height)
{
AConfiguration_setOrientation(app->config, ACONFIGURATION_ORIENTATION_PORT);
- TraceLog(WARNING, "Window set to portraid mode");
+ TraceLog(LOG_WARNING, "Window set to portraid mode");
}
else
{
AConfiguration_setOrientation(app->config, ACONFIGURATION_ORIENTATION_LAND);
- TraceLog(WARNING, "Window set to landscape mode");
+ TraceLog(LOG_WARNING, "Window set to landscape mode");
}
//AConfiguration_getDensity(app->config);
@@ -514,7 +517,7 @@ void InitWindow(int width, int height, void *state)
InitAssetManager(app->activity->assetManager);
- TraceLog(INFO, "Android app initialized successfully");
+ TraceLog(LOG_INFO, "Android app initialized successfully");
// Wait for window to be initialized (display and context)
while (!windowReady)
@@ -538,7 +541,7 @@ void CloseWindow(void)
#if defined(SUPPORT_GIF_RECORDING)
if (gifRecording)
{
- GifEnd(&gifWriter);
+ GifEnd();
gifRecording = false;
}
#endif
@@ -593,7 +596,7 @@ void CloseWindow(void)
pthread_join(gamepadThreadId, NULL);
#endif
- TraceLog(INFO, "Window closed successfully");
+ TraceLog(LOG_INFO, "Window closed successfully");
}
// Check if KEY_ESCAPE pressed or Close icon pressed
@@ -633,7 +636,7 @@ void ToggleFullscreen(void)
#endif
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
- TraceLog(WARNING, "Could not toggle to windowed mode");
+ TraceLog(LOG_WARNING, "Could not toggle to windowed mode");
#endif
}
@@ -674,9 +677,9 @@ void SetWindowMonitor(int monitor)
if ((monitor >= 0) && (monitor < monitorCount))
{
glfwSetWindowMonitor(window, monitors[monitor], 0, 0, screenWidth, screenHeight, GLFW_DONT_CARE);
- TraceLog(INFO, "Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
+ TraceLog(LOG_INFO, "Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
}
- else TraceLog(WARNING, "Selected monitor not found");
+ else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif
}
@@ -806,8 +809,8 @@ void EndDrawing(void)
{
// Get image data for the current frame (from backbuffer)
// NOTE: This process is very slow... :(
- unsigned char *screenData = rlglReadScreenPixels(screenWidth, screenHeight);
- GifWriteFrame(&gifWriter, screenData, screenWidth, screenHeight, 10, 8, false);
+ unsigned char *screenData = rlReadScreenPixels(screenWidth, screenHeight);
+ GifWriteFrame(screenData, screenWidth, screenHeight, 10, 8, false);
free(screenData); // Free image data
}
@@ -882,7 +885,7 @@ void Begin3dMode(Camera camera)
// Setup perspective projection
float aspect = (float)screenWidth/(float)screenHeight;
- double top = 0.01*tan(camera.fovy*PI/360.0);
+ double top = 0.01*tan(camera.fovy*0.5*DEG2RAD);
double right = top*aspect;
// NOTE: zNear and zFar values are important when computing depth buffer values
@@ -892,8 +895,8 @@ void Begin3dMode(Camera camera)
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
// Setup Camera view
- Matrix cameraView = MatrixLookAt(camera.position, camera.target, camera.up);
- rlMultMatrixf(MatrixToFloat(cameraView)); // Multiply MODELVIEW matrix by view matrix (camera)
+ Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
+ rlMultMatrixf(MatrixToFloat(matView)); // Multiply MODELVIEW matrix by view matrix (camera)
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
}
@@ -909,8 +912,6 @@ void End3dMode(void)
rlMatrixMode(RL_MODELVIEW); // Get back to modelview matrix
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
- //rlTranslatef(0.375, 0.375, 0); // HACK to ensure pixel-perfect drawing on OpenGL (after exiting 3D mode)
-
rlDisableDepthTest(); // Disable DEPTH_TEST for 2D
}
@@ -974,50 +975,21 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
// Store values in a vector
Vector3 deviceCoords = { x, y, z };
- TraceLog(DEBUG, "Device coordinates: (%f, %f, %f)", deviceCoords.x, deviceCoords.y, deviceCoords.z);
+ TraceLog(LOG_DEBUG, "Device coordinates: (%f, %f, %f)", deviceCoords.x, deviceCoords.y, deviceCoords.z);
- // Calculate projection matrix (from perspective instead of frustum)
- Matrix matProj = MatrixPerspective(camera.fovy, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
+ // Calculate projection matrix from perspective
+ Matrix matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
// Calculate view matrix from camera look at
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
- // Do I need to transpose it? It seems that yes...
- // NOTE: matrix order may be incorrect... In OpenGL to get world position from
- // camera view it just needs to get inverted, but here we need to transpose it too.
- // For example, if you get view matrix, transpose and inverted and you transform it
- // to a vector, you will get its 3d world position coordinates (camera.position).
- // If you don't transpose, final position will be wrong.
- MatrixTranspose(&matView);
-
-//#define USE_RLGL_UNPROJECT
-#if defined(USE_RLGL_UNPROJECT) // OPTION 1: Use rlglUnproject()
-
- Vector3 nearPoint = rlglUnproject((Vector3){ deviceCoords.x, deviceCoords.y, 0.0f }, matProj, matView);
- Vector3 farPoint = rlglUnproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
-
-#else // OPTION 2: Compute unprojection directly here
-
- // Calculate unproject matrix (multiply projection matrix and view matrix) and invert it
- Matrix matProjView = MatrixMultiply(matProj, matView);
- MatrixInvert(&matProjView);
-
- // Calculate far and near points
- Quaternion qNear = { deviceCoords.x, deviceCoords.y, 0.0f, 1.0f };
- Quaternion qFar = { deviceCoords.x, deviceCoords.y, 1.0f, 1.0f };
-
- // Multiply points by unproject matrix
- QuaternionTransform(&qNear, matProjView);
- QuaternionTransform(&qFar, matProjView);
-
- // Calculate normalized world points in vectors
- Vector3 nearPoint = { qNear.x/qNear.w, qNear.y/qNear.w, qNear.z/qNear.w};
- Vector3 farPoint = { qFar.x/qFar.w, qFar.y/qFar.w, qFar.z/qFar.w};
-#endif
+ // Unproject far/near points
+ Vector3 nearPoint = rlUnproject((Vector3){ deviceCoords.x, deviceCoords.y, 0.0f }, matProj, matView);
+ Vector3 farPoint = rlUnproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
// Calculate normalized direction vector
- Vector3 direction = VectorSubtract(farPoint, nearPoint);
- VectorNormalize(&direction);
+ Vector3 direction = Vector3Subtract(farPoint, nearPoint);
+ Vector3Normalize(&direction);
// Apply calculated vectors to ray
ray.position = camera.position;
@@ -1030,11 +1002,10 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
Vector2 GetWorldToScreen(Vector3 position, Camera camera)
{
// Calculate projection matrix (from perspective instead of frustum
- Matrix matProj = MatrixPerspective(camera.fovy, (double)GetScreenWidth()/(double)GetScreenHeight(), 0.01, 1000.0);
+ Matrix matProj = MatrixPerspective(camera.fovy*DEG2RAD, (double)GetScreenWidth()/(double)GetScreenHeight(), 0.01, 1000.0);
// Calculate view matrix from camera look at (and transpose it)
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
- MatrixTranspose(&matView);
// Convert world position vector to quaternion
Quaternion worldPos = { position.x, position.y, position.z, 1.0f };
@@ -1066,7 +1037,7 @@ void SetTargetFPS(int fps)
if (fps < 1) targetTime = 0.0;
else targetTime = 1.0/(double)fps;
- TraceLog(INFO, "Target time per frame: %02.03f milliseconds", (float)targetTime*1000);
+ TraceLog(LOG_INFO, "Target time per frame: %02.03f milliseconds", (float)targetTime*1000);
}
// Returns current FPS
@@ -1095,45 +1066,6 @@ float *ColorToFloat(Color color)
return buffer;
}
-// Converts Vector3 to float array
-float *VectorToFloat(Vector3 vec)
-{
- static float buffer[3];
-
- buffer[0] = vec.x;
- buffer[1] = vec.y;
- buffer[2] = vec.z;
-
- return buffer;
-}
-
-// NOTE: Returned vector is a transposed version of the Matrix struct,
-// it should be this way because, despite raymath use OpenGL column-major convention,
-// Matrix struct memory alignment and variables naming are not coherent
-float *MatrixToFloat(Matrix mat)
-{
- static float buffer[16];
-
- buffer[0] = mat.m0;
- buffer[1] = mat.m4;
- buffer[2] = mat.m8;
- buffer[3] = mat.m12;
- buffer[4] = mat.m1;
- buffer[5] = mat.m5;
- buffer[6] = mat.m9;
- buffer[7] = mat.m13;
- buffer[8] = mat.m2;
- buffer[9] = mat.m6;
- buffer[10] = mat.m10;
- buffer[11] = mat.m14;
- buffer[12] = mat.m3;
- buffer[13] = mat.m7;
- buffer[14] = mat.m11;
- buffer[15] = mat.m15;
-
- return buffer;
-}
-
// Returns a Color struct from hexadecimal value
Color GetColor(int hexValue)
{
@@ -1198,11 +1130,11 @@ void SetConfigFlags(char flags)
void TakeScreenshot(const char *fileName)
{
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
- unsigned char *imgData = rlglReadScreenPixels(renderWidth, renderHeight);
+ unsigned char *imgData = rlReadScreenPixels(renderWidth, renderHeight);
SavePNG(fileName, imgData, renderWidth, renderHeight, 4); // Save image as PNG
free(imgData);
- TraceLog(INFO, "Screenshot taken: %s", fileName);
+ TraceLog(LOG_INFO, "Screenshot taken: %s", fileName);
#endif
}
@@ -1301,7 +1233,7 @@ void StorageSaveValue(int position, int value)
// If file doesn't exist, create a new storage data file
if (!storageFile) storageFile = fopen(path, "wb");
- if (!storageFile) TraceLog(WARNING, "Storage data file could not be created");
+ if (!storageFile) TraceLog(LOG_WARNING, "Storage data file could not be created");
else
{
// Get file size
@@ -1309,7 +1241,7 @@ void StorageSaveValue(int position, int value)
int fileSize = ftell(storageFile); // Size in bytes
fseek(storageFile, 0, SEEK_SET);
- if (fileSize < (position*4)) TraceLog(WARNING, "Storage position could not be found");
+ if (fileSize < (position*4)) TraceLog(LOG_WARNING, "Storage position could not be found");
else
{
fseek(storageFile, (position*4), SEEK_SET);
@@ -1338,7 +1270,7 @@ int StorageLoadValue(int position)
// Try open existing file to append data
FILE *storageFile = fopen(path, "rb");
- if (!storageFile) TraceLog(WARNING, "Storage data file could not be found");
+ if (!storageFile) TraceLog(LOG_WARNING, "Storage data file could not be found");
else
{
// Get file size
@@ -1346,7 +1278,7 @@ int StorageLoadValue(int position)
int fileSize = ftell(storageFile); // Size in bytes
rewind(storageFile);
- if (fileSize < (position*4)) TraceLog(WARNING, "Storage position could not be found");
+ if (fileSize < (position*4)) TraceLog(LOG_WARNING, "Storage position could not be found");
else
{
fseek(storageFile, (position*4), SEEK_SET);
@@ -1672,7 +1604,7 @@ Vector2 GetTouchPosition(int index)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
if (index < MAX_TOUCH_POINTS) position = touchPosition[index];
- else TraceLog(WARNING, "Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
+ else TraceLog(LOG_WARNING, "Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
if ((screenWidth > displayWidth) || (screenHeight > displayHeight))
{
@@ -1713,7 +1645,7 @@ static void InitGraphicsDevice(int width, int height)
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
glfwSetErrorCallback(ErrorCallback);
- if (!glfwInit()) TraceLog(ERROR, "Failed to initialize GLFW");
+ if (!glfwInit()) TraceLog(LOG_ERROR, "Failed to initialize GLFW");
// NOTE: Getting video modes is not implemented in emscripten GLFW3 version
#if defined(PLATFORM_DESKTOP)
@@ -1749,7 +1681,7 @@ static void InitGraphicsDevice(int width, int height)
if (configFlags & FLAG_MSAA_4X_HINT)
{
glfwWindowHint(GLFW_SAMPLES, 4); // Enables multisampling x4 (MSAA), default is 0
- TraceLog(INFO, "Trying to enable MSAA x4");
+ TraceLog(LOG_INFO, "Trying to enable MSAA x4");
}
//glfwWindowHint(GLFW_RED_BITS, 8); // Framebuffer red color component bits
@@ -1802,7 +1734,7 @@ static void InitGraphicsDevice(int width, int height)
}
}
- TraceLog(WARNING, "Closest fullscreen videomode: %i x %i", displayWidth, displayHeight);
+ TraceLog(LOG_WARNING, "Closest fullscreen videomode: %i x %i", displayWidth, displayHeight);
// NOTE: ISSUE: Closest videomode could not match monitor aspect-ratio, for example,
// for a desired screen size of 800x450 (16:9), closest supported videomode is 800x600 (4:3),
@@ -1841,17 +1773,17 @@ static void InitGraphicsDevice(int width, int height)
if (!window)
{
glfwTerminate();
- TraceLog(ERROR, "GLFW Failed to initialize Window");
+ TraceLog(LOG_ERROR, "GLFW Failed to initialize Window");
}
else
{
- TraceLog(INFO, "Display device initialized successfully");
+ TraceLog(LOG_INFO, "Display device initialized successfully");
#if defined(PLATFORM_DESKTOP)
- TraceLog(INFO, "Display size: %i x %i", displayWidth, displayHeight);
+ TraceLog(LOG_INFO, "Display size: %i x %i", displayWidth, displayHeight);
#endif
- TraceLog(INFO, "Render size: %i x %i", renderWidth, renderHeight);
- TraceLog(INFO, "Screen size: %i x %i", screenWidth, screenHeight);
- TraceLog(INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
+ TraceLog(LOG_INFO, "Render size: %i x %i", renderWidth, renderHeight);
+ TraceLog(LOG_INFO, "Screen size: %i x %i", screenWidth, screenHeight);
+ TraceLog(LOG_INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
}
glfwSetWindowSizeCallback(window, WindowSizeCallback); // NOTE: Resizing not allowed by default!
@@ -1875,7 +1807,7 @@ static void InitGraphicsDevice(int width, int height)
#if defined(PLATFORM_DESKTOP)
// Load OpenGL 3.3 extensions
// NOTE: GLFW loader function is passed as parameter
- rlglLoadExtensions(glfwGetProcAddress);
+ rlLoadExtensions(glfwGetProcAddress);
#endif
// Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS)
@@ -1883,7 +1815,7 @@ static void InitGraphicsDevice(int width, int height)
if (configFlags & FLAG_VSYNC_HINT)
{
glfwSwapInterval(1);
- TraceLog(INFO, "Trying to enable VSYNC");
+ TraceLog(LOG_INFO, "Trying to enable VSYNC");
}
#endif // defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
@@ -1911,7 +1843,7 @@ static void InitGraphicsDevice(int width, int height)
{
samples = 4;
sampleBuffer = 1;
- TraceLog(INFO, "Trying to enable MSAA x4");
+ TraceLog(LOG_INFO, "Trying to enable MSAA x4");
}
const EGLint framebufferAttribs[] =
@@ -2019,7 +1951,7 @@ static void InitGraphicsDevice(int width, int height)
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
{
- TraceLog(ERROR, "Unable to attach EGL rendering context to EGL surface");
+ TraceLog(LOG_ERROR, "Unable to attach EGL rendering context to EGL surface");
}
else
{
@@ -2027,11 +1959,11 @@ static void InitGraphicsDevice(int width, int height)
//eglQuerySurface(display, surface, EGL_WIDTH, &renderWidth);
//eglQuerySurface(display, surface, EGL_HEIGHT, &renderHeight);
- TraceLog(INFO, "Display device initialized successfully");
- TraceLog(INFO, "Display size: %i x %i", displayWidth, displayHeight);
- TraceLog(INFO, "Render size: %i x %i", renderWidth, renderHeight);
- TraceLog(INFO, "Screen size: %i x %i", screenWidth, screenHeight);
- TraceLog(INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
+ TraceLog(LOG_INFO, "Display device initialized successfully");
+ TraceLog(LOG_INFO, "Display size: %i x %i", displayWidth, displayHeight);
+ TraceLog(LOG_INFO, "Render size: %i x %i", renderWidth, renderHeight);
+ TraceLog(LOG_INFO, "Screen size: %i x %i", screenWidth, screenHeight);
+ TraceLog(LOG_INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
}
#endif // defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
@@ -2082,7 +2014,7 @@ static void SetupFramebufferSize(int displayWidth, int displayHeight)
// Calculate renderWidth and renderHeight, we have the display size (input params) and the desired screen size (global var)
if ((screenWidth > displayWidth) || (screenHeight > displayHeight))
{
- TraceLog(WARNING, "DOWNSCALING: Required screen size (%ix%i) is bigger than display size (%ix%i)", screenWidth, screenHeight, displayWidth, displayHeight);
+ TraceLog(LOG_WARNING, "DOWNSCALING: Required screen size (%ix%i) is bigger than display size (%ix%i)", screenWidth, screenHeight, displayWidth, displayHeight);
// Downscaling to fit display with border-bars
float widthRatio = (float)displayWidth/(float)screenWidth;
@@ -2113,12 +2045,12 @@ static void SetupFramebufferSize(int displayWidth, int displayHeight)
renderWidth = displayWidth;
renderHeight = displayHeight;
- TraceLog(WARNING, "Downscale matrix generated, content will be rendered at: %i x %i", renderWidth, renderHeight);
+ TraceLog(LOG_WARNING, "Downscale matrix generated, content will be rendered at: %i x %i", renderWidth, renderHeight);
}
else if ((screenWidth < displayWidth) || (screenHeight < displayHeight))
{
// Required screen size is smaller than display size
- TraceLog(INFO, "UPSCALING: Required screen size: %i x %i -> Display size: %i x %i", screenWidth, screenHeight, displayWidth, displayHeight);
+ TraceLog(LOG_INFO, "UPSCALING: Required screen size: %i x %i -> Display size: %i x %i", screenWidth, screenHeight, displayWidth, displayHeight);
// Upscaling to fit display with border-bars
float displayRatio = (float)displayWidth/(float)displayHeight;
@@ -2164,7 +2096,7 @@ static void InitTimer(void)
{
baseTime = (uint64_t)now.tv_sec*1000000000LLU + (uint64_t)now.tv_nsec;
}
- else TraceLog(WARNING, "No hi-resolution timer available");
+ else TraceLog(LOG_WARNING, "No hi-resolution timer available");
#endif
previousTime = GetTime(); // Get time as double
@@ -2394,7 +2326,7 @@ static void PollInputEvents(void)
// NOTE: Never close window, native activity is controlled by the system!
if (app->destroyRequested != 0)
{
- //TraceLog(INFO, "Closing Window...");
+ //TraceLog(LOG_INFO, "Closing Window...");
//windowShouldClose = true;
//ANativeActivity_finish(app->activity);
}
@@ -2428,7 +2360,7 @@ static void SwapBuffers(void)
// GLFW3 Error Callback, runs on GLFW3 error
static void ErrorCallback(int error, const char *description)
{
- TraceLog(WARNING, "[GLFW3 Error] Code: %i Decription: %s", error, description);
+ TraceLog(LOG_WARNING, "[GLFW3 Error] Code: %i Decription: %s", error, description);
}
// GLFW3 Srolling Callback, runs on mouse wheel
@@ -2454,10 +2386,10 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
{
if (gifRecording)
{
- GifEnd(&gifWriter);
+ GifEnd();
gifRecording = false;
- TraceLog(INFO, "End animated GIF recording");
+ TraceLog(LOG_INFO, "End animated GIF recording");
}
else
{
@@ -2466,10 +2398,10 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
// NOTE: delay represents the time between frames in the gif, if we capture a gif frame every
// 10 game frames and each frame trakes 16.6ms (60fps), delay between gif frames should be ~16.6*10.
- GifBegin(&gifWriter, FormatText("screenrec%03i.gif", screenshotCounter), screenWidth, screenHeight, (int)(GetFrameTime()*10.0f), 8, false);
+ GifBegin(FormatText("screenrec%03i.gif", screenshotCounter), screenWidth, screenHeight, (int)(GetFrameTime()*10.0f), 8, false);
screenshotCounter++;
- TraceLog(INFO, "Begin animated GIF recording: %s", FormatText("screenrec%03i.gif", screenshotCounter));
+ TraceLog(LOG_INFO, "Begin animated GIF recording: %s", FormatText("screenrec%03i.gif", screenshotCounter));
}
}
else
@@ -2554,7 +2486,7 @@ static void CharCallback(GLFWwindow *window, unsigned int key)
{
lastKeyPressed = key;
- //TraceLog(INFO, "Char Callback Key pressed: %i\n", key);
+ //TraceLog(LOG_INFO, "Char Callback Key pressed: %i\n", key);
}
// GLFW3 CursorEnter Callback, when cursor enters the window
@@ -2623,15 +2555,15 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
case APP_CMD_START:
{
//rendering = true;
- TraceLog(INFO, "APP_CMD_START");
+ TraceLog(LOG_INFO, "APP_CMD_START");
} break;
case APP_CMD_RESUME:
{
- TraceLog(INFO, "APP_CMD_RESUME");
+ TraceLog(LOG_INFO, "APP_CMD_RESUME");
} break;
case APP_CMD_INIT_WINDOW:
{
- TraceLog(INFO, "APP_CMD_INIT_WINDOW");
+ TraceLog(LOG_INFO, "APP_CMD_INIT_WINDOW");
if (app->window != NULL)
{
@@ -2688,18 +2620,18 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
} break;
case APP_CMD_GAINED_FOCUS:
{
- TraceLog(INFO, "APP_CMD_GAINED_FOCUS");
+ TraceLog(LOG_INFO, "APP_CMD_GAINED_FOCUS");
appEnabled = true;
//ResumeMusicStream();
} break;
case APP_CMD_PAUSE:
{
- TraceLog(INFO, "APP_CMD_PAUSE");
+ TraceLog(LOG_INFO, "APP_CMD_PAUSE");
} break;
case APP_CMD_LOST_FOCUS:
{
//DrawFrame();
- TraceLog(INFO, "APP_CMD_LOST_FOCUS");
+ TraceLog(LOG_INFO, "APP_CMD_LOST_FOCUS");
appEnabled = false;
//PauseMusicStream();
} break;
@@ -2713,22 +2645,22 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
contextRebindRequired = true;
- TraceLog(INFO, "APP_CMD_TERM_WINDOW");
+ TraceLog(LOG_INFO, "APP_CMD_TERM_WINDOW");
} break;
case APP_CMD_SAVE_STATE:
{
- TraceLog(INFO, "APP_CMD_SAVE_STATE");
+ TraceLog(LOG_INFO, "APP_CMD_SAVE_STATE");
} break;
case APP_CMD_STOP:
{
- TraceLog(INFO, "APP_CMD_STOP");
+ TraceLog(LOG_INFO, "APP_CMD_STOP");
} break;
case APP_CMD_DESTROY:
{
// TODO: Finish activity?
//ANativeActivity_finish(app->activity);
- TraceLog(INFO, "APP_CMD_DESTROY");
+ TraceLog(LOG_INFO, "APP_CMD_DESTROY");
} break;
case APP_CMD_CONFIG_CHANGED:
{
@@ -2737,7 +2669,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
// Check screen orientation here!
- TraceLog(INFO, "APP_CMD_CONFIG_CHANGED");
+ TraceLog(LOG_INFO, "APP_CMD_CONFIG_CHANGED");
} break;
default: break;
}
@@ -2845,11 +2777,11 @@ static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const Emscripte
if (e->isFullscreen)
{
- TraceLog(INFO, "Canvas scaled to fullscreen. ElementSize: (%ix%i), ScreenSize(%ix%i)", e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight);
+ TraceLog(LOG_INFO, "Canvas scaled to fullscreen. ElementSize: (%ix%i), ScreenSize(%ix%i)", e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight);
}
else
{
- TraceLog(INFO, "Canvas scaled to windowed. ElementSize: (%ix%i), ScreenSize(%ix%i)", e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight);
+ TraceLog(LOG_INFO, "Canvas scaled to windowed. ElementSize: (%ix%i), ScreenSize(%ix%i)", e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight);
}
// TODO: Depending on scaling factor (screen vs element), calculate factor to scale mouse/touch input
@@ -2882,7 +2814,7 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
{
emscripten_exit_pointerlock();
emscripten_get_pointerlock_status(&plce);
- //if (plce.isActive) TraceLog(WARNING, "Pointer lock exit did not work!");
+ //if (plce.isActive) TraceLog(LOG_WARNING, "Pointer lock exit did not work!");
}
toggleCursorLock = false;
@@ -3008,7 +2940,7 @@ static void InitKeyboard(void)
if (ioctl(STDIN_FILENO, KDGKBMODE, &defaultKeyboardMode) < 0)
{
// NOTE: It could mean we are using a remote keyboard through ssh!
- TraceLog(WARNING, "Could not change keyboard mode (SSH keyboard?)");
+ TraceLog(LOG_WARNING, "Could not change keyboard mode (SSH keyboard?)");
}
else
{
@@ -3043,7 +2975,7 @@ static void ProcessKeyboard(void)
// Fill all read bytes (looking for keys)
for (int i = 0; i < bufferByteCount; i++)
{
- TraceLog(DEBUG, "Bytes on keysBuffer: %i", bufferByteCount);
+ TraceLog(LOG_DEBUG, "Bytes on keysBuffer: %i", bufferByteCount);
//printf("Key(s) bytes: ");
//for (int i = 0; i < bufferByteCount; i++) printf("0x%02x ", keysBuffer[i]);
@@ -3104,7 +3036,7 @@ static void ProcessKeyboard(void)
else if (keysBuffer[i] == 0x7f) currentKeyState[259] = 1; // raylib KEY_BACKSPACE
else
{
- TraceLog(DEBUG, "Pressed key (ASCII): 0x%02x", keysBuffer[i]);
+ TraceLog(LOG_DEBUG, "Pressed key (ASCII): 0x%02x", keysBuffer[i]);
// Translate lowercase a-z letters to A-Z
if ((keysBuffer[i] >= 97) && (keysBuffer[i] <= 122))
@@ -3142,7 +3074,7 @@ static void InitMouse(void)
// NOTE: We can use /dev/input/mice to read from all available mice
if ((mouseStream = open(DEFAULT_MOUSE_DEV, O_RDONLY|O_NONBLOCK)) < 0)
{
- TraceLog(WARNING, "Mouse device could not be opened, no mouse available");
+ TraceLog(LOG_WARNING, "Mouse device could not be opened, no mouse available");
}
else
{
@@ -3150,8 +3082,8 @@ static void InitMouse(void)
int error = pthread_create(&mouseThreadId, NULL, &MouseThread, NULL);
- if (error != 0) TraceLog(WARNING, "Error creating mouse input event thread");
- else TraceLog(INFO, "Mouse device initialized successfully");
+ if (error != 0) TraceLog(LOG_WARNING, "Error creating mouse input event thread");
+ else TraceLog(LOG_INFO, "Mouse device initialized successfully");
}
}
@@ -3221,7 +3153,7 @@ static void InitTouch(void)
{
if ((touchStream = open(DEFAULT_TOUCH_DEV, O_RDONLY|O_NONBLOCK)) < 0)
{
- TraceLog(WARNING, "Touch device could not be opened, no touchscreen available");
+ TraceLog(LOG_WARNING, "Touch device could not be opened, no touchscreen available");
}
else
{
@@ -3229,8 +3161,8 @@ static void InitTouch(void)
int error = pthread_create(&touchThreadId, NULL, &TouchThread, NULL);
- if (error != 0) TraceLog(WARNING, "Error creating touch input event thread");
- else TraceLog(INFO, "Touch device initialized successfully");
+ if (error != 0) TraceLog(LOG_WARNING, "Error creating touch input event thread");
+ else TraceLog(LOG_INFO, "Touch device initialized successfully");
}
}
@@ -3332,7 +3264,7 @@ static void InitGamepad(void)
if ((gamepadStream[i] = open(gamepadDev, O_RDONLY|O_NONBLOCK)) < 0)
{
// NOTE: Only show message for first gamepad
- if (i == 0) TraceLog(WARNING, "Gamepad device could not be opened, no gamepad available");
+ if (i == 0) TraceLog(LOG_WARNING, "Gamepad device could not be opened, no gamepad available");
}
else
{
@@ -3343,8 +3275,8 @@ static void InitGamepad(void)
{
int error = pthread_create(&gamepadThreadId, NULL, &GamepadThread, NULL);
- if (error != 0) TraceLog(WARNING, "Error creating gamepad input event thread");
- else TraceLog(INFO, "Gamepad device initialized successfully");
+ if (error != 0) TraceLog(LOG_WARNING, "Error creating gamepad input event thread");
+ else TraceLog(LOG_INFO, "Gamepad device initialized successfully");
}
}
}
@@ -3378,7 +3310,7 @@ static void *GamepadThread(void *arg)
// Process gamepad events by type
if (gamepadEvent.type == JS_EVENT_BUTTON)
{
- TraceLog(DEBUG, "Gamepad button: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
+ TraceLog(LOG_DEBUG, "Gamepad button: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
if (gamepadEvent.number < MAX_GAMEPAD_BUTTONS)
{
@@ -3391,7 +3323,7 @@ static void *GamepadThread(void *arg)
}
else if (gamepadEvent.type == JS_EVENT_AXIS)
{
- TraceLog(DEBUG, "Gamepad axis: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
+ TraceLog(LOG_DEBUG, "Gamepad axis: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
if (gamepadEvent.number < MAX_GAMEPAD_AXIS)
{