Skip to content

Commit

Permalink
Set currentFbo to render size in EndTextureMode
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudValensi committed Sep 13, 2021
1 parent 681bf91 commit abcee04
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2147,8 +2147,8 @@ void EndTextureMode(void)
SetupViewport(CORE.Window.render.width, CORE.Window.render.height);

// Reset current fbo to screen size
CORE.Window.currentFbo.width = CORE.Window.screen.width;
CORE.Window.currentFbo.height = CORE.Window.screen.height;
CORE.Window.currentFbo.width = CORE.Window.render.width;
CORE.Window.currentFbo.height = CORE.Window.render.height;
}

// Begin custom shader mode
Expand Down Expand Up @@ -2297,7 +2297,7 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName)

char *vShaderStr = NULL;
char *fShaderStr = NULL;

if (vsFileName != NULL) vShaderStr = LoadFileText(vsFileName);
if (fsFileName != NULL) fShaderStr = LoadFileText(fsFileName);

Expand Down Expand Up @@ -5304,18 +5304,18 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)

return 0;
}

// Register touch points count
CORE.Input.Touch.pointCount = AMotionEvent_getPointerCount(event);

for (int i = 0; (i < CORE.Input.Touch.pointCount) && (i < MAX_TOUCH_POINTS); i++)
{
// Register touch points id
CORE.Input.Touch.pointId[i] = AMotionEvent_getPointerId(event, i);

// Register touch points position
CORE.Input.Touch.position[i] = (Vector2){ AMotionEvent_getX(event, i), AMotionEvent_getY(event, i) };

// Normalize gestureEvent.position[x] for screenWidth and screenHeight
gestureEvent.position[i].x /= (float)GetScreenWidth();
gestureEvent.position[i].y /= (float)GetScreenHeight();
Expand All @@ -5329,7 +5329,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)

#if defined(SUPPORT_GESTURES_SYSTEM) // PLATFORM_ANDROID
GestureEvent gestureEvent = { 0 };

gestureEvent.pointCount = CORE.Input.Touch.pointCount;

// Register touch actions
Expand Down Expand Up @@ -5364,14 +5364,14 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
{
// Register touch points count
CORE.Input.Touch.pointCount = touchEvent->numTouches;

double canvasWidth = 0.0;
double canvasHeight = 0.0;
// NOTE: emscripten_get_canvas_element_size() returns canvas.width and canvas.height but
// we are looking for actual CSS size: canvas.style.width and canvas.style.height
//EMSCRIPTEN_RESULT res = emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);

for (int i = 0; (i < CORE.Input.Touch.pointCount) && (i < MAX_TOUCH_POINTS); i++)
{
// Register touch points id
Expand All @@ -5383,14 +5383,14 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
// Normalize gestureEvent.position[x] for CORE.Window.screen.width and CORE.Window.screen.height
CORE.Input.Touch.position[i].x *= ((float)GetScreenWidth()/(float)canvasWidth);
CORE.Input.Touch.position[i].y *= ((float)GetScreenHeight()/(float)canvasHeight);

if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) CORE.Input.Touch.currentTouchState[i] = 1;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0;
}

#if defined(SUPPORT_GESTURES_SYSTEM) // PLATFORM_WEB
GestureEvent gestureEvent = { 0 };

gestureEvent.pointCount = CORE.Input.Touch.pointCount;

// Register touch actions
Expand Down

0 comments on commit abcee04

Please sign in to comment.