Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/core/core_2d_camera_mouse_zoom.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ int main(void)
camera.target = Vector2Add(camera.target, delta);
}

Vector2 renderScale = { (float)GetRenderWidth()/GetScreenWidth(), (float)GetRenderHeight()/GetScreenHeight() };

if (zoomMode == 0)
{
// Zoom based on mouse wheel
Expand All @@ -66,7 +68,7 @@ int main(void)
Vector2 mouseWorldPos = GetScreenToWorld2D(GetMousePosition(), camera);

// Set the offset to where the mouse is, mouse is scaled to viewport space, but offset is in unscaled pixels
camera.offset = Vector2Multiply(GetMousePosition(), GetWindowScaleDPI());
camera.offset = Vector2Multiply(GetMousePosition(), renderScale);

// Set the target to match, so that the camera maps the world space point
// under the cursor to the screen space point under the cursor at any zoom
Expand All @@ -87,7 +89,7 @@ int main(void)
Vector2 mouseWorldPos = GetScreenToWorld2D(GetMousePosition(), camera);

// Set the offset to where the mouse is, mouse is scaled to viewport space, but offset is in unscaled pixels
camera.offset = Vector2Multiply(GetMousePosition(), GetWindowScaleDPI());
camera.offset = Vector2Multiply(GetMousePosition(), renderScale);

// Set the target to match, so that the camera maps the world space point
// under the cursor to the screen space point under the cursor at any zoom
Expand Down
5 changes: 2 additions & 3 deletions examples/core/core_2d_camera_split_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
********************************************************************************************/

#include "raylib.h"
#include "raymath.h"

#define PLAYER_SIZE 40

Expand All @@ -40,13 +39,13 @@ int main(void)

Camera2D camera1 = { 0 };
camera1.target = (Vector2){ player1.x, player1.y };
camera1.offset = Vector2Multiply((Vector2){ 200.0f, 200.0f }, GetWindowScaleDPI());
camera1.offset = (Vector2){ 200.0f, 200.0f };
camera1.rotation = 0.0f;
camera1.zoom = 1.0f;

Camera2D camera2 = { 0 };
camera2.target = (Vector2){ player2.x, player2.y };
camera2.offset = Vector2Multiply((Vector2){ 200.0f, 200.0f }, GetWindowScaleDPI());
camera2.offset = (Vector2){ 200.0f, 200.0f };
camera2.rotation = 0.0f;
camera2.zoom = 1.0f;

Expand Down
3 changes: 1 addition & 2 deletions examples/textures/textures_magnifying_glass.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "raylib.h"

#include "rlgl.h" // Required for: rlSetBlendFactorsSeparate()
#include "raymath.h" // Required for: Vector2Multiply()

//------------------------------------------------------------------------------------
// Program main entry point
Expand Down Expand Up @@ -47,7 +46,7 @@ int main(void)
// Set magnifying glass zoom
camera.zoom = 2;
// Offset by half the size of the magnifying glass to counteract drawing the texture centered on the mouse position
camera.offset = Vector2Multiply((Vector2){ 128, 128 }, GetWindowScaleDPI());
camera.offset = (Vector2){ 128, 128 };

SetTargetFPS(60);
//--------------------------------------------------------------------------------------
Expand Down
Loading