2017-07-29 90 views

回答

0

你有两个选择。

  1. 使用GLControl在Windows窗体内嵌入OpenTK上下文。这里的缺点是没有按钮可以放在OpenTK窗口中,但根据你的目标,这可能不成问题。

  2. 自己和测试渲染一个按钮用于该区域内的鼠标印刷机。

选项2将更多的工作,但显然更多功能,如果你开始你会学到很多东西。

要得到光标位置...

int mouseX = System.Windows.Forms.Cursor.Position.X; 
int mouseY = System.Windows.Forms.Cursor.Position.Y; 

要检查鼠标按下...

MouseState mouseState = OpenTK.Input.Mouse.GetState(); 
bool leftMouseDown = mouseState.IsButtonDown(MouseButton.Left); 
bool rightMouseDown = mouseState.IsButtonDown(MouseButton.Right); 

,并以每像素坐标绘制四...

float x1 = (float)x * 2/screenWidth - 1; 
float x2 = (float)(x + buttonWidth) * 2/screenWidth - 1; 
float y1 = (float)y * 2/screenHeight - 1; 
float y2 = (float)(y + buttonHeight) * 2/screenHeight - 1; 

剩下的就是给你我的朋友。

相关问题