2017-07-29 20 views

答えて

0

2つのオプションがあります。

  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; 

残りはあなた次第です。

関連する問題