/**
 *\file		Picking.H
 *
 *\brief	OpenGL Picking.
 *
 *\author	Xianming Chen
 *
 *\date		15 Aug 2004
 *		
 */


#ifndef _PICKING_H
#define _PICKING_H

#include <GL/glut.h>

class Picking 
{
    enum { invalid_selected_id = -1 };   
    enum { hit_buff_sz = 1024 };
    int selected_id;

    GLuint selectBuf[hit_buff_sz];
    int processHits(int hits);

public:
    Picking() : selected_id(invalid_selected_id)                          { }

    /* Pick a rectangle area of (x, y, width, height) in the given viewport. Return picked object name id. */
    int operator() (int x, int y, double width=2, double height=2);

    int GetSelected()                                                     { return selected_id; }
    void UnSelect()                                                       { selected_id = invalid_selected_id; }
};

#endif

