Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've specified the pick matrix dimensions. However the hit counted gives the results for all the drawn points in that instance.

I want the hit to be those around the point of click.

Thanks in advance for helping me

What I have tried:

OpenGL gl = openGLControl.OpenGL;



int[] vp = new int[4];


//gl.Ortho2D(mousePos.X, mousePos.X + 0.1, mousePos.Y + 0.0001, mousePos.Y + 0.0001);
//gl.MatrixMode(OpenGL.GL_PROJECTION);

////gl.Ortho2D(mousePos.X, mousePos.X,1, 1);

 gl.Ortho2D(left -(top-bottom)*(aspect % 1)/2 , right+ (top - bottom) * (aspect % 1) / 2, bottom, top);
 gl.LoadIdentity();
 gl.PickMatrix(mousePos.X, mousePos.Y,0, 0, vp);
uint[] selectBuffer = new uint[100];
gl.SelectBuffer(100, selectBuffer);
gl.PushMatrix();


//int[] vp = new int[4];
//gl.GetInteger(OpenGL.GL_VIEWPORT, vp);



gl.InitNames();
gl.PushName(0);

gl.Begin(OpenGL.GL_POINTS);
gl.PointSize(20);
gl.Color(1.0f, 1.0f, 0.0f);
gl.Vertex(1.32, 0.5);



gl.End();
gl.LoadIdentity();
gl.PushName(1);

gl.Begin(OpenGL.GL_POINTS);
gl.PointSize(20);

gl.Color(1.0f, 0.8f, 0.0f);
gl.Vertex(0.55, 0.55);

gl.End();



//gl.PickMatrix(e.GetPosition(openGLControl).X, openGLControl.ActualHeight - e.GetPosition(openGLControl).Y, 4, 4, vp);
//gl.Ortho2D(left, right, bottom, top);
///

//gl.Begin(OpenGL.GL_POINTS);
//gl.PointSize(20);
//gl.Color(1.0f, 1.0f, 0.0f);
//gl.Vertex(0.5, 0.5);

//gl.End();

/////
//gl.MatrixMode(OpenGL.GL_PROJECTION);
//gl.PopMatrix();
int hits = gl.RenderMode(OpenGL.GL_RENDER);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900