Skip to content
Open
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
9 changes: 9 additions & 0 deletions samples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ static void ScrollCallback( GLFWwindow* window, double dx, double dy )
return;
}

double xd, yd;
glfwGetCursorPos( window, &xd, &yd );
b2Vec2 ps = { float( xd ), float( yd ) };
b2Vec2 pwBefore = ConvertScreenToWorld( &s_context.camera, ps );

if ( dy > 0 )
{
s_context.camera.zoom /= 1.1f;
Expand All @@ -386,6 +391,10 @@ static void ScrollCallback( GLFWwindow* window, double dx, double dy )
{
s_context.camera.zoom *= 1.1f;
}

b2Vec2 pwAfter = ConvertScreenToWorld( &s_context.camera, ps );
b2Vec2 delta = pwAfter - pwBefore;
s_context.camera.center -= delta;
}

static void UpdateUI()
Expand Down