- OpenGLスレ Part20
591 :デフォルトの名無しさん[sage]:2014/04/27(日) 15:00:46.63 ID:vp8B5YyM - GLFW3でマウスドラッグ中に頂点を描画したいのですが上手くいきません
static void cursorpos_callback( GLFWwindow* window, double xpos, double ypos ){ if ( glfwGetMouseButton( aWrap->getWindow(), GLFW_MOUSE_BUTTON_LEFT ) ){ std::cout << xpos << ", " << ypos << std::endl ; glBegin( GL_LINES ); glColor3d( 0,0,0 ); glVertex2d( 10, 10 ) ; glVertex2d( 100, 100 ) ; glEnd(); glFlush(); } } このコールバックを、 glfwSetCursorPosCallback( window, cursorpos_callback ); これで登録したんですが、ウィンドウに描画されないんです std::coutの出力は端末に出るんですが
| - OpenGLスレ Part20
592 :591[sage]:2014/04/27(日) 15:02:00.96 ID:vp8B5YyM - if ( glfwGetMouseButton( aWrap->getWindow(), GLFW_MOUSE_BUTTON_LEFT )
これは if ( glfwGetMouseButton( window, GLFW_MOUSE_BUTTON_LEFT ) これの間違いでした
| - OpenGLスレ Part20
593 :591[sage]:2014/04/27(日) 15:09:01.83 ID:vp8B5YyM - 色々おかしかった…何度もごめん
static void cursorpos_callback( GLFWwindow* win, double xpos, double ypos ){ if ( glfwGetMouseButton( g_window, GLFW_MOUSE_BUTTON_LEFT ) ){ std::cout << xpos << ", " << ypos << std::endl ; glBegin( GL_LINES ); glColor3d( 0,0,0 ); glVertex2d( 10, 10 ) ; glVertex2d( 100, 100 ) ; glEnd(); glFlush(); } } int main() { ... glfwSetCursorPosCallback( g_window, cursorpos_callback ); ... }
| - OpenGLスレ Part20
594 :591[sage]:2014/04/27(日) 15:25:07.51 ID:vp8B5YyM - main関数内のループで↓を回したら描画されました
コールバックで上手くいかなかった理由はわからんです double xpos, ypos; glfwGetCursorPos( g_window, &xpos, &ypos ); glBegin( GL_LINES ); glVertex2d( 0, 0 ); glVertex2d( xpos, ypos ); glEnd();
|
|