void SampleGLView::AttachedToWindow(void) { BGLView::AttachedToWindow(); LockGL(); gInit(); gReshape(width, height); UnlockGL(); MakeFocus(); }
void TutGLView::FrameResized( float width, float height ) { // When the view is resized (it follows the window, since we created // it with B_FOLLOW_ALL_SIDES), we need to tell OpenGL that it's // rendering into a new size/shape. LockGL(); BGLView::FrameResized( width, height ); gReshape( width, height ); UnlockGL(); Render(); }
void SampleGLView::FrameResized(float newWidth, float newHeight) { BGLView::FrameResized(newWidth, newHeight); LockGL(); width = newWidth; height = newHeight; gReshape(width,height); UnlockGL(); Render(); }
void TutGLView::AttachedToWindow( void ) { // Make keyboard/mouse input go to this view when its window has // focus (that'll stay in effect until another view calls MakeFocus() // or the user puts the focus on a control... which won't happen in // this app because there are no other views and no controls). MakeFocus(); // Initialize OpenGL; gInit() sets things up, gReshape() makes sure // OpenGL knows about the view's size/shape. LockGL(); BGLView::AttachedToWindow(); gInit(); BRect r = Bounds(); gReshape( r.IntegerWidth(), r.IntegerHeight() ); UnlockGL(); }
void glutMainLoop() { char buffer[10]={0}; char pressed = 0; int i; XAllowEvents(dpy, AsyncBoth, CurrentTime); while (gRunning) { while (XPending(dpy) > 0) { XEvent event; XNextEvent(dpy, &event); switch (event.type) { case ClientMessage: if (event.xclient.data.l[0] == (signed)wmDeleteMessage) // quit! gRunning = 0; break; case Expose: break; // Update event! Should do draw here. case ConfigureNotify: if (gReshape) gReshape(event.xconfigure.width, event.xconfigure.height); else { glViewport(0, 0, event.xconfigure.width, event.xconfigure.height); } animate = 1; break; case KeyPress: case KeyRelease: if (event.type == KeyPress) { if ((gKey)){ gKey(event.xkey.keycode, event.xkey.x, event.xkey.y,event.xkey.state & ShiftMask ? 1 : 0); gKeymap[(int)buffer[0]] = 1; } } else { if (gKeyUp) gKeyUp(buffer[0], 0, 0,0); gKeymap[(int)buffer[0]] = 0;} break; case ButtonPress: gButtonPressed[event.xbutton.button] = 1; if (gMouseFunc != NULL) gMouseFunc(GLUT_LEFT_BUTTON, GLUT_DOWN, event.xbutton.x, event.xbutton.y); break; case ButtonRelease: gButtonPressed[event.xbutton.button] = 0; if (gMouseFunc != NULL) gMouseFunc(GLUT_LEFT_BUTTON, GLUT_UP, event.xbutton.x, event.xbutton.y); break; case MotionNotify: pressed = 0; for (i = 0; i < 5; i++) if (gButtonPressed[i]) pressed = 1; if (pressed && gMouseDragged) gMouseDragged(event.xbutton.x, event.xbutton.y); else if (gMouseMoved) gMouseMoved(event.xbutton.x, event.xbutton.y); break; default: break; } } if (animate) { animate = 0; if (gDisplay) gDisplay(); else printf("No display function!\n"); } else if (gIdle) gIdle(); checktimers(); } glXMakeCurrent(dpy, None, NULL); glXDestroyContext(dpy, ctx); XDestroyWindow(dpy, win); XCloseDisplay(dpy); }
virtual void AttachedToWindow(void) { BGLView::AttachedToWindow(); game_ = new GL::Game(NULL, NULL); gReshape(Frame().Width(), Frame().Height()); Render(); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int x = LOWORD(lParam); int y = HIWORD(lParam); switch (message) { case WM_LBUTTONUP: if (gMouseFunc != NULL) gMouseFunc(GLUT_LEFT_BUTTON, GLUT_UP, x, y); break; case WM_LBUTTONDOWN: if (gMouseFunc != NULL) gMouseFunc(GLUT_LEFT_BUTTON, GLUT_DOWN, x, y); break; case WM_RBUTTONUP: if (gMouseFunc != NULL) gMouseFunc(GLUT_RIGHT_BUTTON, GLUT_UP, x, y); break; case WM_RBUTTONDOWN: if (gMouseFunc != NULL) gMouseFunc(GLUT_RIGHT_BUTTON, GLUT_DOWN, x, y); break; case WM_MOUSEMOVE: if (gMouseMoved != NULL) gMouseMoved(x, y); break; case WM_CREATE: return 0; case WM_CLOSE: PostQuitMessage( 0 ); return 0; case WM_DESTROY: return 0; case WM_KEYDOWN: doKeyboardEvent(wParam, lParam, gKey, gSpecialKey, 1); return 0; case WM_KEYUP: doKeyboardEvent(wParam, lParam, gKeyUp, gSpecialKeyUp, 0); return 0; case WM_SIZE: if (gReshape != NULL) gReshape(LOWORD(lParam), HIWORD(lParam)); break; case WM_PAINT: // Don't have Windows fighting us while resize! gDisplay(); break; case WM_ERASEBKGND: return 1; break; default: return DefWindowProc( hWnd, message, wParam, lParam ); } return 0; }