OpenGL icon indicating copy to clipboard operation
OpenGL copied to clipboard

Missing Include Files in GLCore.h

Open gmCAD opened this issue 6 years ago • 1 comments

Should the following libraries be added to the GLCore.h?

#include "GLCore/Core/Input.h"
#include "GLCore/Core/MouseButtonCodes.h"
#include "GLCore/Core/KeyCodes.h"

In the sandbox example, I was trying to get the mouse location to highlight the box when the mouse hovered over it. I had to add these included files to get the mouse location.

gmCAD avatar Jan 18 '20 17:01 gmCAD

Looking at the OpenGL-Examples solution, you can also do it using events, which is included in GLCore.h

in OnEvent:

EventDispatcher dispatcher(event);
dispatcher.Dispatch<MouseMovedEvent>(
	[&](MouseMovedEvent& e)
	{
		// now you can use e.GetX() and e.GetY()
	});

If you just want to use Input.h to get the mouse position feel free to do so - it's your project - but to me it seems like Cherno intended for it to be used this way.

One thing I would like to add is that if the mouse is not moving the event dispatcher won't fire any MouseMovedEvents, so for an FPS controller (or something similar) I would recommend polling the mouse position each frame, but then you would have to add those three includes you mentioned.

SeppahBaws avatar Jan 18 '20 21:01 SeppahBaws