Drag object based on mouse selection

So i was wondering what exactly i would need to do in order to select a object with the mouse then take and check if the moue is down and then move that selected object. Now i have done some research. I found to make the selection work you use a selection buffer then that gets the objects information like its position. So what i was thinking i could do is take that position data and make it equal to the mouses position based on where its at on the screen when the user is dragging it across the screen. Would this sort of implementation work?

Ok so with a bit more reading iam not sure but is the buffer selection depreciated?

I did a bit more searching to find out about ray casting. But not sure where to find out how to even implement it does any one know of any resources.

Hey man. I’m also new to the whole OpenGL thing, but I’m working on something similar to what you need so I figured I share with my design (altho it’s incomplete now).

You can assign a specific color value to the object, and render the objects with controls attached to them to a texture or a frame buffer (this is the part I’m trying to figure out how to do), then you get the mouse position and read the pixel value at that pixel. Then you use this color value as key to see if any of the objects with controls are in the map of the current scene.

So basically give object has unique value of 200, so you assign a “control” color of (0,0,200/255) to the object, then when you render, you render the object with its “control” value elsewhere and if the mouse looks at a pixel with color of (0,0,200/255) then you pull the object with key of 200 from the map, and call something like object->enable(), which basically sets the value at its control pointer to 1. Then your main application sees that this object is being looked at, and you can do all sorts of things with it.