static void registerCallbacks () { glutIdleFunc(gst_glut_IdleFunc); glutKeyboardFunc(gst_glut_KeyboardFunc); glutSpecialFunc(gst_glut_SpecialFunc); glutReshapeFunc(gst_glut_ReshapeFunc); glutVisibilityFunc(gst_glut_VisibilityFunc); glutDisplayFunc(gst_glut_DisplayFunc); glutMouseFunc(gst_glut_MouseFunc); glutMotionFunc(gst_glut_MotionFunc); glutPassiveMotionFunc(gst_glut_PassiveMotionFunc); glutEntryFunc(gst_glut_EntryFunc); glutKeyboardUpFunc(gst_glut_KeyboardUpFunc); glutSpecialUpFunc(gst_glut_SpecialUpFunc); glutMenuStateFunc(gst_glut_MenuStateFunc); glutMenuStatusFunc(gst_glut_MenuStatusFunc); glutOverlayDisplayFunc(gst_glut_OverlayDisplayFunc); glutWindowStatusFunc(gst_glut_WindowStatusFunc); glutSpaceballMotionFunc(gst_glut_SpaceballMotionFunc); glutSpaceballRotateFunc(gst_glut_SpaceballRotateFunc); glutSpaceballButtonFunc(gst_glut_SpaceballButtonFunc); glutButtonBoxFunc(gst_glut_ButtonBoxFunc); glutDialsFunc(gst_glut_DialsFunc); glutTabletMotionFunc(gst_glut_TabletMotionFunc); glutTabletButtonFunc(gst_glut_TabletButtonFunc); glutWMCloseFunc(gst_glut_WMCloseFunc); #if 0 glutJoystickFunc(gst_glut_JoystickFunc); glutMouseWheelFunc(gst_glut_MouseWheelFunc); glutCloseFunc(gst_glut_CloseFunc); glutMenuDestroyFunc(gst_glut_MenuDestroyFunc); #endif }
int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("zoomdino"); glutDisplayFunc(redraw); glutMouseFunc(mouse); glutMotionFunc(motion); glutCreateMenu(controlLights); glutAddMenuEntry("Toggle right light", 1); glutAddMenuEntry("Toggle left light", 2); glutAttachMenu(GLUT_RIGHT_BUTTON); makeDinosaur(); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); defaultProjection(); gluLookAt(0.0, 0.0, 30.0, /* eye is at (0,0,30) */ 0.0, 0.0, 0.0, /* center is at (0,0,0) */ 0.0, 1.0, 0.); /* up is in postivie Y direction */ glPushMatrix(); /* dummy push so we can pop on model recalc */ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1); glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05); glLightfv(GL_LIGHT1, GL_POSITION, lightOnePosition); glLightfv(GL_LIGHT1, GL_DIFFUSE, lightOneColor); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glutInitDisplayMode(GLUT_SINGLE | GLUT_INDEX); overlaySupport = glutLayerGet(GLUT_OVERLAY_POSSIBLE); if (overlaySupport) { glutEstablishOverlay(); glutHideOverlay(); transparent = glutLayerGet(GLUT_TRANSPARENT_INDEX); glClearIndex(transparent); red = (transparent + 1) % glutGet(GLUT_WINDOW_COLORMAP_SIZE); white = (transparent + 2) % glutGet(GLUT_WINDOW_COLORMAP_SIZE); glutSetColor(red, 1.0, 0.0, 0.0); /* Red. */ glutSetColor(white, 1.0, 1.0, 1.0); /* White. */ glutOverlayDisplayFunc(redrawOverlay); glutReshapeFunc(reshape); glutSetWindowTitle("zoomdino with rubber-banding"); glutAddMenuEntry("------------------", 0); glutAddMenuEntry("Reset projection", 3); glutAddMenuEntry("------------------", 0); glutAddMenuEntry("Fancy rubber-banding", 4); glutAddMenuEntry("Simple rubber-banding", 5); glutAddMenuEntry("------------------", 0); glutAddMenuEntry("Show help", 6); } else { printf("Sorry, no whizzy zoomdino overlay usage!\n"); } glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
void main_menu(int option) { switch (option) { case 1: if (glutLayerGet(GLUT_HAS_OVERLAY)) { independent = 1; glutOverlayDisplayFunc(overlay_display); } break; case 2: if (glutLayerGet(GLUT_HAS_OVERLAY)) { independent = 0; glutOverlayDisplayFunc(NULL); } break; case 666: exit(0); break; } }
int main(int argc, char **argv) { glutInitWindowSize(350, 350); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow("Overlay Sphere Positioning Demo"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMouseFunc(mouse); glutMotionFunc(motion); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); /* Solid spheres benefit greatly from back face culling. */ setupMatrices(); /* Read back matrices for use by gluUnProject. */ glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); /* Set up lighting. */ glLightfv(GL_LIGHT0, GL_POSITION, lightPos); glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmb); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiff); glLightfv(GL_LIGHT0, GL_SPECULAR, lightSpec); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glutInitDisplayMode(GLUT_INDEX | GLUT_SINGLE); if (glutLayerGet(GLUT_OVERLAY_POSSIBLE) == 0) { printf("oversphere: no overlays supported; aborting.\n"); exit(1); } glutEstablishOverlay(); glutHideOverlay(); glutOverlayDisplayFunc(overlayDisplay); /* Find transparent and opaque index. */ transparent = glutLayerGet(GLUT_TRANSPARENT_INDEX); opaque = (transparent + 1) % glutGet(GLUT_WINDOW_COLORMAP_SIZE); /* Draw overlay sphere as an outline. */ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); /* Make sure overlay clears to transparent. */ glClearIndex(transparent); /* Set up overlay matrices same as normal plane. */ setupMatrices(); glutMainLoop(); return 0; }
/* * Class: gruenewa_opengl_GLUT__ * Method: glutOverlayDisplayFunc * Signature: (Lscala/Function0;)V */ JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutOverlayDisplayFunc (JNIEnv * jenv, jobject jobj, jobject arg1) { if(jvm == NULL) { (*jenv)->GetJavaVM(jenv, &jvm); } // fixme remove old obj if exists glutOverlayDisplayFunc_obj = (*jenv)->NewGlobalRef(jenv, arg1); return glutOverlayDisplayFunc(glutOverlayDisplayFuncCallback); }
/* GLUT child thread function. * The argument of the function is ignored. * The function takes the allocated values for 'glut_window_properties' and * 'glut_window_title' from the thread creator, uses them, and then frees them. */ static void *glut_thread_func(void *arg) { struct glut_window_properties_t *properties = glut_window_properties; char *title = glut_window_title; /* Detach thread. Parent does not need to 'pthread_join' the child to * release its resources. */ pthread_detach(pthread_self()); /* Configure host window properties */ glutInitWindowPosition(properties->x, properties->y); glutInitWindowSize(properties->width, properties->height); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); /* Create window */ glutCreateWindow(title); /* Host window callbacks */ glutIdleFunc(glut_idle_func); glutDisplayFunc(glut_display_func); glutOverlayDisplayFunc(glut_overlay_display_func); glutReshapeFunc(glut_reshape_func); glutKeyboardFunc(glut_keyboard_func); glutMouseFunc(glut_mouse_func); glutMotionFunc(glut_motion_func); glutPassiveMotionFunc(glut_passive_motion_func); glutVisibilityFunc(glut_visibility_func); glutEntryFunc(glut_entry_func); glutSpecialFunc(glut_special_func); glutSpaceballRotateFunc(glut_spaceball_rotate_func); glutSpaceballButtonFunc(glut_spaceball_button_func); glutButtonBoxFunc(glut_button_box_func); glutDialsFunc(glut_dials_func); glutTabletMotionFunc(glut_tablet_motion_func); glutTabletButtonFunc(glut_tablet_button_func); /* Resize guest frame buffer */ glut_frame_buffer_resize(properties->width, properties->height); /* Free input arguments */ free(properties); free(title); glut_window_properties = NULL; glut_window_title = NULL; /* Host GLUT main loop */ glutMainLoop(); /* Function never returns */ return NULL; }
static void display2(void) { static int been_here = 0; if (glutLayerGet(GLUT_NORMAL_DAMAGED) != 0) { printf("FAIL: normal damage not expected\n"); exit(1); } if (glutLayerGet(GLUT_OVERLAY_DAMAGED) != 0) { printf("FAIL: overlay damage not expected\n"); exit(1); } if (been_here) { glutPostOverlayRedisplay(); } else { glutOverlayDisplayFunc(display_overlay); glutDisplayFunc(display_normal); damage_expectation = 0; glutPostOverlayRedisplay(); glutPostRedisplay(); } }
void helper_glutOverlayDisplayFunc(IScriptFunction * scriptFunction) { getCurrentCallbackData()->overlayDisplay.reset(scriptFunction); glutOverlayDisplayFunc(&callback_glutOverlayDisplayFunc); }