void glutmenustatefunc(GLUTmenuStateFCB menuStateFunc) { if (menuStateFunc == (GLUTmenuStateFCB) glutnull_) { glutMenuStateFunc(NULL); } else { glutMenuStateFunc(fortranMenuStateWrapper); fortranMenuStateFunc = menuStateFunc; } }
static VALUE glut_MenuStateFunc(VALUE self, VALUE callback) { menustate_func = rb_glut_check_callback(self, callback); if (NIL_P(menustate_func)) glutMenuStateFunc(NULL); else glutMenuStateFunc(glut_MenuStateFuncCallback0); return Qnil; }
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 }
void muiInit(void) { int winNum = glutGetWindow(); Window win; if (winNum >= numWins) { numWins = winNum; winList = (Window) realloc(winList, numWins * sizeof(WindowRec)); } win = &winList[glutGetWindow()-1]; win->mui_xorg = glutGet(GLUT_WINDOW_X); win->mui_yorg = glutGet(GLUT_WINDOW_Y); win->mui_xsize = glutGet(GLUT_WINDOW_WIDTH); win->mui_ysize = glutGet(GLUT_WINDOW_HEIGHT);; win->mbleft = 0; /* The "uilist = 1" is for compatibility with GLUT 3.5's MUI implementation that was hardwired to support a single window only with UI list 1. */ win->uilist = 1; glutKeyboardFunc(mui_keyboard); glutMouseFunc(mui_mouse); glutReshapeFunc(mui_Reshape); glutMotionFunc(mui_glutmotion); glutPassiveMotionFunc(mui_glutpassivemotion); glutDisplayFunc(mui_drawgeom); glutMenuStateFunc(mui_menufunc); }
/* * Class: gruenewa_opengl_GLUT__ * Method: glutMenuStateFunc * Signature: (Lscala/Function1;)V */ JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutMenuStateFunc (JNIEnv * jenv, jobject jobj, jobject arg1) { if(jvm == NULL) { (*jenv)->GetJavaVM(jenv, &jvm); } // fixme remove old obj if exists glutMenuStateFunc_obj = (*jenv)->NewGlobalRef(jenv, arg1); return glutMenuStateFunc(glutMenuStateFuncCallback); }
int main(int argc, char **argv) { qobj = gluNewQuadric(); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); win1 = glutCreateWindow("sphere"); glutEntryFunc(enter_leave); init(); glutDisplayFunc(display_win1); glutCreateMenu(it); glutAddMenuEntry("toggle draw mode", 1); glutAddMenuEntry("exit", 2); glutAddMenuEntry("new menu entry", 3); glutAddMenuEntry("motion", 4); glutAttachMenu(GLUT_LEFT_BUTTON); glutCreateMenu(it); glutAddMenuEntry("yes", 1); glutAddMenuEntry("no", 2); glutAttachMenu(GLUT_RIGHT_BUTTON); win2 = glutCreateWindow("second window"); glutEntryFunc(enter_leave); glutKeyboardFunc(keyboard); glutSpecialFunc(special); glutMouseFunc(mouse); #if 0 glutMotionFunc(motion); #endif glutVisibilityFunc(visible); init(); light_diffuse[1] = 1; light_diffuse[2] = 1; glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glutDisplayFunc(display); submenu1 = glutCreateMenu(it); glutAddMenuEntry("submenu a", 666); glutAddMenuEntry("submenu b", 777); submenu2 = glutCreateMenu(it); glutAddMenuEntry("submenu 1", 25); glutAddMenuEntry("submenu 2", 26); glutAddSubMenu("submenuXXX", submenu1); glutCreateMenu(it); glutAddSubMenu("submenu", submenu2); glutAddMenuEntry("stop motion", 5); glutAddMenuEntry("delayed stop motion", 6); glutAddSubMenu("submenu", submenu2); glutAttachMenu(GLUT_LEFT_BUTTON); glutMenuStateFunc(menustate); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
void time6(int value) { if (value != 6) { printf("FAIL: time6 expected 6\n"); exit(1); } glutMenuStateFunc(mstatus); glutMenuStatusFunc(mstatus2); glutCreateMenu(menu2); glutAddMenuEntry("name", 46); glutAttachMenu(GLUT_LEFT_BUTTON); glutAttachMenu(GLUT_MIDDLE_BUTTON); glutAttachMenu(GLUT_RIGHT_BUTTON); printf("Pop up menu with any mouse button and select the item\n"); }
void InitGraphics( ) { glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowPosition( 0, 0 ); glutInitWindowSize( INIT_WINDOW_SIZE, INIT_WINDOW_SIZE ); MainWindow = glutCreateWindow( WINDOWTITLE ); glutSetWindowTitle( WINDOWTITLE ); glClearColor( BACKCOLOR[0], BACKCOLOR[1], BACKCOLOR[2], BACKCOLOR[3] ); // setup the callback routines: glutSetWindow( MainWindow ); glutDisplayFunc( Display ); glutReshapeFunc( Resize ); glutKeyboardFunc( Keyboard ); glutMouseFunc( MouseButton ); glutMotionFunc( MouseMotion ); glutPassiveMotionFunc( NULL ); glutVisibilityFunc( Visibility ); glutEntryFunc( NULL ); glutSpecialFunc( NULL ); glutSpaceballMotionFunc( NULL ); glutSpaceballRotateFunc( NULL ); glutSpaceballButtonFunc( NULL ); glutButtonBoxFunc( NULL ); glutDialsFunc( NULL ); glutTabletMotionFunc( NULL ); glutTabletButtonFunc( NULL ); glutMenuStateFunc( NULL ); glutTimerFunc( 0, NULL, 0 ); #ifdef WIN32 GLenum err = glewInit(); if( err != GLEW_OK ) { fprintf( stderr, "glewInit Error\n" ); } #endif }
///////////////////////////////////////////////////////// // createMess // ///////////////////////////////////////////////////////// bool gemglutwindow :: create(void) { if(m_window) { error("window already made!"); return false; } #ifdef FREEGLUT // display list sharing (with FreeGLUT) if(s_windowmap.size()>0) { std::map<int,gemglutwindow*>::iterator it = s_windowmap.begin(); gemglutwindow*other=NULL; other=it->second; if(other && other->makeCurrent()) { glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT ); } } #endif unsigned int mode=GLUT_RGB | GLUT_DEPTH; if(2==m_buffer) mode|=GLUT_DOUBLE; else mode|=GLUT_SINGLE; glutInitDisplayMode(mode); #ifdef FREEGLUT // glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutSetOption(GLUT_INIT_WINDOW_X, m_xoffset); glutSetOption(GLUT_INIT_WINDOW_Y, m_yoffset); glutSetOption(GLUT_INIT_WINDOW_WIDTH, m_width); glutSetOption(GLUT_INIT_WINDOW_HEIGHT, m_height); #endif m_window=glutCreateWindow(m_title.c_str()); s_windowmap[m_window]=this; glutReshapeWindow(m_width, m_height); glutPositionWindow(m_xoffset, m_yoffset); glutCloseFunc (&closeCb); glutKeyboardFunc(&keyboardCb); glutSpecialFunc(&specialCb); glutReshapeFunc(&reshapeCb); glutKeyboardUpFunc(&keyboardupCb); glutSpecialUpFunc(&specialupCb); glutJoystickFunc(&joystickCb, 20); glutMenuStateFunc(&menustateCb); glutMenuStatusFunc(&menustatusCb); glutWindowStatusFunc(&windowstatusCb); #if (defined GLUT_HAS_MULTI) && (GLUT_HAS_MULTI > 0) glutMultiEntryFunc(multiEntryCb); glutMultiButtonFunc(multiButtonCb); glutMultiMotionFunc(multiMotionCb); glutMultiPassiveFunc(multiPassivemotionCb); #else glutEntryFunc(&entryCb); glutMouseFunc(&mouseCb); glutMotionFunc(&motionCb); glutPassiveMotionFunc(&passivemotionCb); #endif // glutNameFunc(&nameCb); glutDisplayFunc (&displayCb); glutVisibilityFunc(&visibleCb); if(!createGemWindow()) { destroyMess(); return false; } titleMess(m_title); fullscreenMess(m_fullscreen); dispatch(); return true; }
int main(int argc, char **argv) { int win, menu; int marray[NUM]; int warray[NUM]; int i, j; GLint isIndex; glutInit(&argc, argv); glutInitWindowPosition(10, 10); glutInitWindowSize(200, 200); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); win = glutCreateWindow("test2"); glGetIntegerv(GL_INDEX_MODE, &isIndex); if (isIndex != 0) { printf("FAIL: window should be RGBA\n"); exit(1); } glutSetWindow(win); glutDisplayFunc(display); menu = glutCreateMenu(menuSelect); glutSetMenu(menu); glutReshapeFunc(NULL); glutReshapeFunc(NULL); glutKeyboardFunc(NULL); glutKeyboardFunc(NULL); glutMouseFunc(NULL); glutMouseFunc(NULL); glutMotionFunc(NULL); glutMotionFunc(NULL); glutVisibilityFunc(NULL); glutVisibilityFunc(NULL); glutMenuStateFunc(NULL); glutMenuStateFunc(NULL); glutMenuStatusFunc(NULL); glutMenuStatusFunc(NULL); glutSpecialFunc(NULL); glutSpecialFunc(NULL); glutSpaceballMotionFunc(NULL); glutSpaceballMotionFunc(NULL); glutSpaceballRotateFunc(NULL); glutSpaceballRotateFunc(NULL); glutSpaceballButtonFunc(NULL); glutSpaceballButtonFunc(NULL); glutButtonBoxFunc(NULL); glutButtonBoxFunc(NULL); glutDialsFunc(NULL); glutDialsFunc(NULL); glutTabletMotionFunc(NULL); glutTabletMotionFunc(NULL); glutTabletButtonFunc(NULL); glutTabletButtonFunc(NULL); for (i = 0; i < NUM; i++) { marray[i] = glutCreateMenu(menuSelect); warray[i] = glutCreateWindow("test"); glutDisplayFunc(display); for (j = 0; j < i; j++) { glutAddMenuEntry("Hello", 1); glutAddSubMenu("Submenu", menu); } if (marray[i] != glutGetMenu()) { printf("FAIL: current menu not %d\n", marray[i]); exit(1); } if (warray[i] != glutGetWindow()) { printf("FAIL: current window not %d\n", warray[i]); exit(1); } glutDisplayFunc(NeverVoid); glutVisibilityFunc(NeverValue); glutHideWindow(); } for (i = 0; i < NUM; i++) { glutDestroyMenu(marray[i]); glutDestroyWindow(warray[i]); } glutTimerFunc(500, timer, 42); head = glutGet(GLUT_ELAPSED_TIME); glutIdleFunc(idle); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
int main(int argc, char** argv) { glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE);/*sets the initial display mode .Bit mask to select an RGBA mode window.Bit mask to select a double buffered window.Bit mask to select a window with a depth buffer*/ glutInitWindowPosition(0, 0); glutInitWindowSize(640, 480); glutInit(&argc, argv);/*Initializes GLUT and should be called before any OpenGL functions: glutInit( ) takes the arguement from main( ) and can use them in an implmementation-dependent manner.*/ glutCreateWindow("fountain effect"); glutDisplayFunc(display); glutReshapeFunc(reshape);/*sets the reshape callback for the current window. The reshape callback is triggered when a window is reshaped. */ #ifdef SCREEN_SAVER_MODE glutPassiveMotionFunc(ss_passive); glutKeyboardFunc(ss_keyboard); glutMouseFunc(ss_mouse); glutSetCursor(GLUT_CURSOR_NONE); glutFullScreen(); #else glutMotionFunc(motion); glutMouseFunc(mouse); glutKeyboardFunc(keyboard); #endif glutMenuStateFunc(menustate); glutCreateMenu(menu); glutAddMenuEntry("Particle", 0); glutAddMenuEntry("", 0); glutAddMenuEntry("[t] fountain type", 'f'); glutAddMenuEntry("[s] Collision spheres", 's'); glutAddMenuEntry("[-] Less flow", '-'); glutAddMenuEntry("[+] More flow", '+'); glutAddMenuEntry("[k] Smaller points", 'k'); glutAddMenuEntry("[c] Larger points", 'c'); glutAddMenuEntry("[l] Toggle points/lines", 'l'); glutAddMenuEntry("[#] Toggle name on/off", '#'); glutAddMenuEntry("[~] Toggle fullscreen on/off", '~'); glutAddMenuEntry("", 0); glutAddMenuEntry("Use the numeric keypad to move the spheres", 0); glutAddMenuEntry("[z] Change active sphere", 0); glutAddMenuEntry("", 0); glutAddMenuEntry("[Esc] Quit", 27); glutAttachMenu(GLUT_RIGHT_BUTTON); if (argc > 1) { if (strcmp(argv[1], "-h") == 0) { fprintf(stderr, "%s [particles] [flow] [speed%]\n", argv[0]); exit(0); } sscanf(argv[1], "%d", &num_particles); if (argc > 2) sscanf(argv[2], "%f", &flow); if (argc > 3) sscanf(argv[3], "%f", &slow_down); } particles = (PSparticle*)malloc(sizeof(PSparticle) * num_particles); glutVisibilityFunc(visible);/*sets the visibility callback for the current window. The visibility callback for a window is called when the visibility of a window changes.*/ glutMainLoop();/*enters the GLUT event processing loop.*/ return 0; }
///////////////////////////////////////////////////////// // createMess // ///////////////////////////////////////////////////////// bool gemglutwindow :: create(void) { if(m_window) { error("window already made!"); return false; } #ifdef FREEGLUT // display list sharing (with FreeGLUT) if(s_windowmap.size()>0) { std::map<int,gemglutwindow*>::iterator it = s_windowmap.begin(); gemglutwindow*other=NULL; other=it->second; if(other && other->makeCurrent()) { glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT ); } } #endif unsigned int mode=GLUT_RGB | GLUT_DEPTH; if(2==m_buffer) mode|=GLUT_DOUBLE; else mode|=GLUT_SINGLE; glutInitDisplayMode(mode); m_window=glutCreateWindow(m_title.c_str()); s_windowmap[m_window]=this; glutDisplayFunc (&gemglutwindow::displayCb); glutVisibilityFunc(&gemglutwindow::visibleCb); glutCloseFunc (&gemglutwindow::closeCb); #ifdef FREEGLUT glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); #endif glutKeyboardFunc(&gemglutwindow::keyboardCb); glutSpecialFunc(&gemglutwindow::specialCb); glutReshapeFunc(&gemglutwindow::reshapeCb); glutMouseFunc(&gemglutwindow::mouseCb); glutMotionFunc(&gemglutwindow::motionCb); glutPassiveMotionFunc(&gemglutwindow::passivemotionCb); glutEntryFunc(&gemglutwindow::entryCb); glutKeyboardUpFunc(&gemglutwindow::keyboardupCb); glutSpecialUpFunc(&gemglutwindow::specialupCb); glutJoystickFunc(&gemglutwindow::joystickCb, 20); glutMenuStateFunc(&gemglutwindow::menustateCb); glutMenuStatusFunc(&gemglutwindow::menustatusCb); glutWindowStatusFunc(&gemglutwindow::windowstatusCb); // glutNameFunc(&gemglutwindow::nameCb); if(!createGemWindow()) { destroyMess(); return false; } titleMess(m_title); fullscreenMess(m_fullscreen); dispatch(); return true; }
void InitGraphics( ) { //init proj7 data // As the data range for X is (-36.65 , 36.65) // Y is -22.65 to 22.65 // 2D map is (-1,1) and (-1,1) // Shrink them by 50 times would fit the size FILE *fp = fopen("proj07.dat","r"); int npts; for (int i = 0; i < 68; i++) { fscanf(fp, "%d", &npts); Outlines[i] = new Linestrip(npts); for (int j = 0; j < npts; j++) { fscanf(fp, "%f %f", &Outlines[i]->pts[j].x, &Outlines[i]->pts[j].y); Outlines[i]->pts[j].x = Outlines[i]->pts[j].x / 36.65; Outlines[i]->pts[j].y = Outlines[i]->pts[j].y / 22.65; } } // setup the display mode: // ( *must* be done before call to glutCreateWindow( ) ) // ask for color, double-buffering, and z-buffering: glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH ); // set the initial window configuration: glutInitWindowPosition( 0, 0 ); glutInitWindowSize( INIT_WINDOW_SIZE, INIT_WINDOW_SIZE ); // open the window and set its title: MainWindow = glutCreateWindow( WINDOWTITLE ); glutSetWindowTitle( WINDOWTITLE ); // setup the clear values: glClearColor( BACKCOLOR[0], BACKCOLOR[1], BACKCOLOR[2], BACKCOLOR[3] ); // setup the callback functions: // DisplayFunc -- redraw the window // ReshapeFunc -- handle the user resizing the window // KeyboardFunc -- handle a keyboard input // MouseFunc -- handle the mouse button going down or up // MotionFunc -- handle the mouse moving with a button down // PassiveMotionFunc -- handle the mouse moving with a button up // VisibilityFunc -- handle a change in window visibility // EntryFunc -- handle the cursor entering or leaving the window // SpecialFunc -- handle special keys on the keyboard // SpaceballMotionFunc -- handle spaceball translation // SpaceballRotateFunc -- handle spaceball rotation // SpaceballButtonFunc -- handle spaceball button hits // ButtonBoxFunc -- handle button box hits // DialsFunc -- handle dial rotations // TabletMotionFunc -- handle digitizing tablet motion // TabletButtonFunc -- handle digitizing tablet button hits // MenuStateFunc -- declare when a pop-up menu is in use // TimerFunc -- trigger something to happen a certain time from now // IdleFunc -- what to do when nothing else is going on glutSetWindow( MainWindow ); glutDisplayFunc( Display ); glutReshapeFunc( Resize ); glutKeyboardFunc( Keyboard ); glutMouseFunc( MouseButton ); glutMotionFunc( MouseMotion ); glutPassiveMotionFunc( NULL ); glutVisibilityFunc( Visibility ); glutEntryFunc( NULL ); glutSpecialFunc( NULL ); glutSpaceballMotionFunc( NULL ); glutSpaceballRotateFunc( NULL ); glutSpaceballButtonFunc( NULL ); glutButtonBoxFunc( NULL ); glutDialsFunc( NULL ); glutTabletMotionFunc( NULL ); glutTabletButtonFunc( NULL ); glutMenuStateFunc( NULL ); glutTimerFunc( 0, NULL, 0 ); // DO NOT SET THE GLUT IDLE FUNCTION HERE !! // glutIdleFunc( NULL ); // let glui take care of it in InitGlui( ) }
void InitGraphics( ) { // request the display modes: // ask for red-green-blue-alpha color, double-buffering, and z-buffering: glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH ); // set the initial window configuration: glutInitWindowPosition( 0, 0 ); glutInitWindowSize( INIT_WINDOW_SIZE, INIT_WINDOW_SIZE ); // open the window and set its title: MainWindow = glutCreateWindow( WINDOWTITLE ); glutSetWindowTitle( WINDOWTITLE ); // set the framebuffer clear values: glClearColor( BACKCOLOR[0], BACKCOLOR[1], BACKCOLOR[2], BACKCOLOR[3] ); // setup the callback functions: // DisplayFunc -- redraw the window // ReshapeFunc -- handle the user resizing the window // KeyboardFunc -- handle a keyboard input // MouseFunc -- handle the mouse button going down or up // MotionFunc -- handle the mouse moving with a button down // PassiveMotionFunc -- handle the mouse moving with a button up // VisibilityFunc -- handle a change in window visibility // EntryFunc -- handle the cursor entering or leaving the window // SpecialFunc -- handle special keys on the keyboard // SpaceballMotionFunc -- handle spaceball translation // SpaceballRotateFunc -- handle spaceball rotation // SpaceballButtonFunc -- handle spaceball button hits // ButtonBoxFunc -- handle button box hits // DialsFunc -- handle dial rotations // TabletMotionFunc -- handle digitizing tablet motion // TabletButtonFunc -- handle digitizing tablet button hits // MenuStateFunc -- declare when a pop-up menu is in use // TimerFunc -- trigger something to happen a certain time from now // IdleFunc -- what to do when nothing else is going on glutSetWindow( MainWindow ); glutDisplayFunc( Display ); glutReshapeFunc( Resize ); glutKeyboardFunc( Keyboard ); glutMouseFunc( MouseButton ); glutMotionFunc( MouseMotion ); glutPassiveMotionFunc( NULL ); glutVisibilityFunc( Visibility ); glutEntryFunc( NULL ); glutSpecialFunc( NULL ); glutSpaceballMotionFunc( NULL ); glutSpaceballRotateFunc( NULL ); glutSpaceballButtonFunc( NULL ); glutButtonBoxFunc( NULL ); glutDialsFunc( NULL ); glutTabletMotionFunc( NULL ); glutTabletButtonFunc( NULL ); glutMenuStateFunc( NULL ); glutTimerFunc( -1, NULL, 0 ); glutIdleFunc( Animate ); //project3 unsigned char *BmpToTexture(char *filename, int *widthp, int *heightp); unsigned char *Texture; int Width, Height; Texture = BmpToTexture("worldtex.bmp", &Width, &Height); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(1, &TEX); glBindTexture(GL_TEXTURE_2D, TEX); glTexImage2D(GL_TEXTURE_2D, 0, 3, Width, Height, 0, GL_RGB, GL_UNSIGNED_BYTE, Texture); // init glew (a window must be open to do this): #ifdef WIN32 GLenum err = glewInit( ); if( err != GLEW_OK ) { fprintf( stderr, "glewInit Error\n" ); } else fprintf( stderr, "GLEW initialized OK\n" ); fprintf( stderr, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); #endif }
void InitGraphics( void ) { // setup the display mode: // ( *must* be done before call to glutCreateWindow( ) ) // ask for color, double-buffering, and z-buffering: glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH ); // set the initial window configuration: glutInitWindowPosition( 0, 0 ); glutInitWindowSize( INIT_WINDOW_SIZE, INIT_WINDOW_SIZE ); // open the window and set its title: MainWindow = glutCreateWindow( WINDOWTITLE ); glutSetWindowTitle( WINDOWTITLE ); // setup the clear values: glClearColor( BACKCOLOR[0], BACKCOLOR[1], BACKCOLOR[2], BACKCOLOR[3] ); // setup the callback routines: // DisplayFunc -- redraw the window // ReshapeFunc -- handle the user resizing the window // KeyboardFunc -- handle a keyboard input // MouseFunc -- handle the mouse button going down or up // MotionFunc -- handle the mouse moving with a button down // PassiveMotionFunc -- handle the mouse moving with a button up // VisibilityFunc -- handle a change in window visibility // EntryFunc -- handle the cursor entering or leaving the window // SpecialFunc -- handle special keys on the keyboard // SpaceballMotionFunc -- handle spaceball translation // SpaceballRotateFunc -- handle spaceball rotation // SpaceballButtonFunc -- handle spaceball button hits // ButtonBoxFunc -- handle button box hits // DialsFunc -- handle dial rotations // TabletMotionFunc -- handle digitizing tablet motion // TabletButtonFunc -- handle digitizing tablet button hits // MenuStateFunc -- declare when a pop-up menu is in use // TimerFunc -- trigger something to happen a certain time from now // IdleFunc -- what to do when nothing else is going on glutSetWindow( MainWindow ); glutDisplayFunc( Display ); glutReshapeFunc( Resize ); glutKeyboardFunc( Keyboard ); glutMouseFunc( MouseButton ); glutMotionFunc( MouseMotion ); glutPassiveMotionFunc( NULL ); glutVisibilityFunc( Visibility ); glutEntryFunc( NULL ); glutSpecialFunc( NULL ); glutSpaceballMotionFunc( NULL ); glutSpaceballRotateFunc( NULL ); glutSpaceballButtonFunc( NULL ); glutButtonBoxFunc( NULL ); glutDialsFunc( NULL ); glutTabletMotionFunc( NULL ); glutTabletButtonFunc( NULL ); glutMenuStateFunc( NULL ); BuildSamples(); //this breaks it for some reason. but we don't use it so whatever // DO NOT SET THE GLUT IDLE FUNCTION HERE !! // glutIdleFunc( NULL ); // let glui take care of it in InitGlui( ) }
void helper_glutMenuStateFunc(IScriptFunction * scriptFunction) { getCurrentCallbackData()->menuState.reset(scriptFunction); glutMenuStateFunc(&callback_glutMenuStateFunc); }
void InitGraphics( ) { //init proj2 data for (int i = 0; i < NX; i++) { for (int j = 0; j < NY; j++) { for (int k = 0; k < NZ; k++) { Nodes[i][j][k].x = -1. + 2. * (float)i / (float)(NX - 1); Nodes[i][j][k].y = -1. + 2. * (float)j / (float)(NY - 1); Nodes[i][j][k].z = -1. + 2. * (float)k / (float)(NZ - 1); Nodes[i][j][k].t = Temperature(Nodes[i][j][k].x, Nodes[i][j][k].y, Nodes[i][j][k].z); } } } //init proj3 data for (int i = 0; i < NX; i++) { for (int j = 0; j < NY; j++) { for (int k = 0; k < NZ; k++) { float hsv[3], rgb[3]; hsv[0] = 240. - 240.*((Nodes[i][j][k].t - TEMPMIN) / (TEMPMAX - TEMPMIN)); hsv[1] = 1.; hsv[2] = 1.; HsvRgb(hsv, rgb); Nodes[i][j][k].rgb[0] = rgb[0]; Nodes[i][j][k].rgb[1] = rgb[1]; Nodes[i][j][k].rgb[2] = rgb[2]; Nodes[i][j][k].rad = sqrt(SQR(Nodes[i][j][k].x) + SQR(Nodes[i][j][k].y) + SQR(Nodes[i][j][k].z)); if (i == 0) Nodes[i][j][k].dTdx = (Nodes[i + 1][j][k].t - Nodes[i][j][k].t) / (Nodes[i + 1][j][k].x - Nodes[i][j][k].x); else if (i + 1 == NX) Nodes[i][j][k].dTdx = (Nodes[i][j][k].t - Nodes[i - 1][j][k].t) / (Nodes[i][j][k].x - Nodes[i - 1][j][k].x); else Nodes[i][j][k].dTdx = (Nodes[i + 1][j][k].t - Nodes[i - 1][j][k].t) / (Nodes[i + 1][j][k].x - Nodes[i - 1][j][k].x); if (j == 0) Nodes[i][j][k].dTdy = (Nodes[i][j + 1][k].t - Nodes[i][j][k].t) / (Nodes[i][j + 1][k].y - Nodes[i][j][k].y); else if (j + 1 == NY) Nodes[i][j][k].dTdy = (Nodes[i][j][k].t - Nodes[i][j - 1][k].t) / (Nodes[i][j][k].y - Nodes[i][j - 1][k].y); else Nodes[i][j][k].dTdy = (Nodes[i][j + 1][k].t - Nodes[i][j - 1][k].t) / (Nodes[i][j + 1][k].y - Nodes[i][j - 1][k].y); if (k == 0) Nodes[i][j][k].dTdz = (Nodes[i][j][k + 1].t - Nodes[i][j][k].t) / (Nodes[i][j][k + 1].z - Nodes[i][j][k].z); else if (k + 1 == NZ) Nodes[i][j][k].dTdz = (Nodes[i][j][k].t - Nodes[i][j][k - 1].t) / (Nodes[i][j][k].z - Nodes[i][j][k - 1].z); else Nodes[i][j][k].dTdz = (Nodes[i][j][k + 1].t - Nodes[i][j][k - 1].t) / (Nodes[i][j][k + 1].z - Nodes[i][j][k - 1].z); Nodes[i][j][k].grad = sqrt(SQR(Nodes[i][j][k].dTdx) + SQR(Nodes[i][j][k].dTdy) + SQR(Nodes[i][j][k].dTdz)); } } } // setup the display mode: // ( *must* be done before call to glutCreateWindow( ) ) // ask for color, double-buffering, and z-buffering: glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH ); // set the initial window configuration: glutInitWindowPosition( 0, 0 ); glutInitWindowSize( INIT_WINDOW_SIZE, INIT_WINDOW_SIZE ); // open the window and set its title: MainWindow = glutCreateWindow( WINDOWTITLE ); glutSetWindowTitle( WINDOWTITLE ); // setup the clear values: glClearColor( BACKCOLOR[0], BACKCOLOR[1], BACKCOLOR[2], BACKCOLOR[3] ); // setup the callback functions: // DisplayFunc -- redraw the window // ReshapeFunc -- handle the user resizing the window // KeyboardFunc -- handle a keyboard input // MouseFunc -- handle the mouse button going down or up // MotionFunc -- handle the mouse moving with a button down // PassiveMotionFunc -- handle the mouse moving with a button up // VisibilityFunc -- handle a change in window visibility // EntryFunc -- handle the cursor entering or leaving the window // SpecialFunc -- handle special keys on the keyboard // SpaceballMotionFunc -- handle spaceball translation // SpaceballRotateFunc -- handle spaceball rotation // SpaceballButtonFunc -- handle spaceball button hits // ButtonBoxFunc -- handle button box hits // DialsFunc -- handle dial rotations // TabletMotionFunc -- handle digitizing tablet motion // TabletButtonFunc -- handle digitizing tablet button hits // MenuStateFunc -- declare when a pop-up menu is in use // TimerFunc -- trigger something to happen a certain time from now // IdleFunc -- what to do when nothing else is going on glutSetWindow( MainWindow ); glutDisplayFunc( Display ); glutReshapeFunc( Resize ); glutKeyboardFunc( Keyboard ); glutMouseFunc( MouseButton ); glutMotionFunc( MouseMotion ); glutPassiveMotionFunc( NULL ); glutVisibilityFunc( Visibility ); glutEntryFunc( NULL ); glutSpecialFunc( NULL ); glutSpaceballMotionFunc( NULL ); glutSpaceballRotateFunc( NULL ); glutSpaceballButtonFunc( NULL ); glutButtonBoxFunc( NULL ); glutDialsFunc( NULL ); glutTabletMotionFunc( NULL ); glutTabletButtonFunc( NULL ); glutMenuStateFunc( NULL ); glutTimerFunc( 0, NULL, 0 ); // DO NOT SET THE GLUT IDLE FUNCTION HERE !! // glutIdleFunc( NULL ); // let glui take care of it in InitGlui( ) }