I’m new to OpenGL and I’m trying to make a shape that I’ve drawn follow my mouse. However, the shape is currently following the mouse but with an offset. I want to change this so that the shape follows directly where the mouse is. I don’t want to use external libraries such as GLUT either. This is my code for how I’m getting the mouse position. I think it is getting the mouse position in relation to the window and not the openGL window.
LRESULT CALLBACK OGLApplication::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
int windowMessageId, windowMessageEvent;
switch(message)
{
case WM_SIZE:
s_oglApplication->GetApplicationWindow()->Resize(LOWORD(lparam),HIWORD(lparam));
break;
case WM_CLOSE:
s_oglApplication->GetApplicationWindow()->DestroyOGLWindow();
break;
case WM_MOUSEMOVE:
//inform the cursor position to OGLWindow
s_oglApplication->GetApplicationWindow()->MouseMove(GET_X_LPARAM(lparam), -GET_Y_LPARAM(lparam));
break;
case WM_LBUTTONUP:
s_oglApplication->GetApplicationWindow()->MouseLBUp(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_LBUTTONDOWN:
s_oglApplication->GetApplicationWindow()->MouseLBDown(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wparam, lparam);
}