2017-07-29 88 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; 

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

相關問題