Browse Source

[split] Fix compilation for web (and desktop) (#3329)

* Fix compilation for web

* Remove EM_ASM_INT from core_input_gestures_web example

* Fix raymath undefined symbols for desktop and web

* Remove raylib_opengl_interop from examples Makefile

* Revert previous commit (8651c78)

* Fix TraceLog for web and desktop
pull/3338/head
ubkp 1 year ago
committed by GitHub
parent
commit
7840e75a0b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 21 deletions
  1. +9
    -17
      examples/core/core_input_gestures_web.c
  2. +0
    -1
      src/rcore.c
  3. +6
    -3
      src/rcore.h

+ 9
- 17
examples/core/core_input_gestures_web.c View File

@ -135,7 +135,7 @@ void Update(void)
}
}
}
int fillLog = 0; // Gate variable to be used to allow or not the gesture log to be filled
if (currentGesture !=0)
{
@ -156,16 +156,16 @@ void Update(void)
fillLog = 1;
}
}
if (fillLog) // If one of the conditions from logMode was met, fill the gesture log
{
previousGesture = currentGesture;
gestureColor = GetGestureColor(currentGesture);
if (gestureLogIndex <= 0) gestureLogIndex = GESTURE_LOG_SIZE;
gestureLogIndex--;
// Copy the gesture respective name to the gesture log array
TextCopy(gestureLog[gestureLogIndex], GetGestureName(currentGesture));
TextCopy(gestureLog[gestureLogIndex], GetGestureName(currentGesture));
}
// Handle protractor
@ -182,14 +182,14 @@ void Update(void)
{
currentAngleDegrees = 0.0f;
}
float currentAngleRadians = ((currentAngleDegrees +90.0f)*PI/180); // Convert the current angle to Radians
finalVector = (Vector2){ (angleLength*sinf(currentAngleRadians)) + protractorPosition.x, (angleLength*cosf(currentAngleRadians)) + protractorPosition.y }; // Calculate the final vector for display
// Handle touch and mouse pointer points
//--------------------------------------------------------------------------------------
#define MAX_TOUCH_COUNT 32
Vector2 touchPosition[MAX_TOUCH_COUNT] = { 0 };
Vector2 mousePosition = {0, 0};
if (currentGesture != GESTURE_NONE)
@ -204,7 +204,7 @@ void Update(void)
// Draw
//--------------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw common
@ -235,7 +235,7 @@ void Update(void)
// Draw gesture log
//--------------------------------------------------------------------------------------
DrawText("Log", gestureLogPosition.x, gestureLogPosition.y, 20, BLACK);
// Loop in both directions to print the gesture log array in the inverted order (and looping around if the index started somewhere in the middle)
for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1) % GESTURE_LOG_SIZE) DrawText(gestureLog[ii], gestureLogPosition.x, gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
Color logButton1Color, logButton2Color;
@ -286,7 +286,7 @@ void Update(void)
DrawCircleV(touchPosition[i], 50.0f, Fade(gestureColor, 0.5f));
DrawCircleV(touchPosition[i], 5.0f, gestureColor);
}
if (touchCount == 2) DrawLineEx(touchPosition[0], touchPosition[1], ((currentGesture == 512)? 8 : 12), gestureColor);
}
else
@ -308,14 +308,6 @@ int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
#if defined( PLATFORM_WEB )
// Using Emscripten EM_ASM_INT macro, get the page canvas width
const int canvasWidth = EM_ASM_INT( return document.getElementById('canvas').getBoundingClientRect().width; );
if (canvasWidth > 400) screenWidth = canvasWidth;
else screenWidth = 400; // Set a minimum width for the screen
#endif
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures web");
//--------------------------------------------------------------------------------------

+ 0
- 1
src/rcore.c View File

@ -109,7 +109,6 @@
#define RLGL_IMPLEMENTATION
#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
#define RAYMATH_IMPLEMENTATION // Define external out-of-line implementation
#include "raymath.h" // Vector3, Quaternion and Matrix functionality
#if defined(SUPPORT_GESTURES_SYSTEM)

+ 6
- 3
src/rcore.h View File

@ -7,9 +7,10 @@
#include <time.h> // Required for: time() [Used in InitTimer()]
#include <math.h> // Required for: tan() [Used in BeginMode3D()], atan2f() [Used in LoadVrStereoConfig()]
#define SUPPORT_TRACELOG
#include "utils.h" // Required for: TRACELOG() macros
#if defined(PLATFORM_DESKTOP)
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3
// NOTE: Already provided by rlgl implementation (on glad.h)
#include "GLFW/glfw3.h" // GLFW3 library: Windows, OpenGL context and Input management
@ -21,12 +22,14 @@
/*
Status:
InitWindow: DRM,
InitWindow: DRM,
*/
#include "raylib.h"
#include "rlgl.h"
#define RAYMATH_IMPLEMENTATION
#include "raymath.h"
@ -256,4 +259,4 @@ typedef struct CoreData {
extern CoreData CORE;
#endif
#endif

Loading…
Cancel
Save