//------------------------------------------------------------------------------ int main(int argc, char ** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA |GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(1024, 1024); glutCreateWindow("OpenSubdiv test"); std::string str; if (argc > 1) { std::ifstream ifs(argv[1]); if (ifs) { std::stringstream ss; ss << ifs.rdbuf(); ifs.close(); str = ss.str(); g_defaultShapes.push_back(SimpleShape(str.c_str(), argv[1], kCatmark)); } } initializeShapes(); int smenu = glutCreateMenu(modelMenu); for(int i = 0; i < (int)g_defaultShapes.size(); ++i){ glutAddMenuEntry( g_defaultShapes[i].name.c_str(), i); } int lmenu = glutCreateMenu(levelMenu); for(int i = 1; i < 8; ++i){ char level[16]; sprintf(level, "Level %d\n", i); glutAddMenuEntry(level, i); } // Register Osd compute kernels OpenSubdiv::OsdCpuKernelDispatcher::Register(); OpenSubdiv::OsdGlslKernelDispatcher::Register(); #if OPENSUBDIV_HAS_OPENCL OpenSubdiv::OsdClKernelDispatcher::Register(); #endif #if OPENSUBDIV_HAS_CUDA OpenSubdiv::OsdCudaKernelDispatcher::Register(); // Note: This function randomly crashes with linux 5.0-dev driver. // cudaGetDeviceProperties overrun stack..? cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); #endif int kmenu = glutCreateMenu(kernelMenu); int nKernels = OpenSubdiv::OsdKernelDispatcher::kMAX; for(int i = 0; i < nKernels; ++i) if(OpenSubdiv::OsdKernelDispatcher::HasKernelType( OpenSubdiv::OsdKernelDispatcher::KernelType(i))) glutAddMenuEntry(getKernelName(i), i); glutCreateMenu(menu); glutAddSubMenu("Level", lmenu); glutAddSubMenu("Model", smenu); glutAddSubMenu("Kernel", kmenu); glutAttachMenu(GLUT_RIGHT_BUTTON); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMouseFunc(mouse); glutKeyboardFunc(keyboard); glutMotionFunc(motion); glewInit(); initGL(); const char *filename = NULL; for (int i = 1; i < argc; ++i) { if (!strcmp(argv[i], "-d")) g_level = atoi(argv[++i]); else if (!strcmp(argv[i], "-c")) g_repeatCount = atoi(argv[++i]); else filename = argv[i]; } glGenBuffers(1, &g_indexBuffer); modelMenu(0); glutIdleFunc(idle); glutMainLoop(); quit(); }
int main(int ac, char **av) { float fogcolor[4]={0.025,0.025,0.025,1.0}; fprintf(stderr,"Teapot V1.2\nWritten by David Bucciarelli ([email protected])\n"); /* if(!SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS)) { fprintf(stderr,"Error setting the process class.\n"); return 0; } if(!SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL)) { fprintf(stderr,"Error setting the process priority.\n"); return 0; } */ glutInitWindowPosition(0,0); glutInitWindowSize(WIDTH,HEIGHT); glutInit(&ac,av); glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE); glutCreateWindow("Teapot"); reshape(WIDTH,HEIGHT); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); glEnable(GL_FOG); glFogi(GL_FOG_MODE,GL_EXP2); glFogfv(GL_FOG_COLOR,fogcolor); glFogf(GL_FOG_DENSITY,0.04); #ifdef FX glHint(GL_FOG_HINT,GL_NICEST); #endif glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); calcposobs(); inittextures(); initlight(); #ifndef FX glDisable(GL_TEXTURE_2D); usetex=0; #endif initdlists(); glClearColor(fogcolor[0],fogcolor[1],fogcolor[2],fogcolor[3]); glutReshapeFunc(reshape); glutDisplayFunc(draw); glutKeyboardFunc(key); glutSpecialFunc(special); glutIdleFunc(draw); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
int main(int argc, char** argv) { getInputSegments(); //initialize the path planner glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB); glutInitWindowSize(640, 480); if (argc < 2) { usage(1); } grid.load(argv[1]); if (grid.empty()) { std::cerr << "Error loading grid: " << argv[1] << "\n"; exit(1); } glutCreateWindow("Biped plan demo"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMouseFunc(mouse); glutMotionFunc(motion); glClearColor(1,1,1,1); glViewport(0, 0, 640, 480); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, 640, 0, 480, 1, -1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glGenTextures(1, &grid_texture); glBindTexture(GL_TEXTURE_2D, grid_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); std::vector<unsigned char> rgbbuf(grid.nx() * grid.ny() * 4); int offs = 0; for (size_t y=0; y<grid.ny(); ++y) { for (size_t x=0; x<grid.nx(); ++x) { rgbbuf[offs++] = grid(x,y); rgbbuf[offs++] = grid(x,y); rgbbuf[offs++] = grid(x,y); rgbbuf[offs++] = 255; } } glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, grid.nx(), grid.ny(), 0, GL_RGBA, GL_UNSIGNED_BYTE, &(rgbbuf[0])); quadric = gluNewQuadric(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); searchTrajectory(); glutMainLoop(); return 0; }
int main(int argc, char* argv[]){ TiXmlDocument doc; TiXmlElement *root=NULL; TiXmlNode *node=NULL; TiXmlAttribute *attr=NULL; const char *tag=NULL; int M_Visual, M_Camera, M_Luzes, M_Texturas, M_ViewFrustum; if(argc!=2){ printf("ERRO!! Número de argumentos errado, falta XML de input!\n"); return 1; } if(doc.LoadFile(argv[1])){ //if(doc.LoadFile("sistema_solar.xml")){ root=doc.RootElement(); cena=root->FirstChild("cena"); if (cena) { // inicializaÁ„o glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100, 100); glutInitWindowSize(1100, 800); glutCreateWindow("Galaxy 3D ®"); // pÙr registo de funÁıes aqui glutDisplayFunc(renderScene); glutReshapeFunc(changeSize); glutIdleFunc(renderScene); // funções do teclado e rato if((node=root->FirstChild("cameras"))){ for (node=node->FirstChild(); node; node=node->NextSibling()) { tag=node->Value(); if(strcmp("camera", tag)==0 && (attr=node->ToElement()->FirstAttribute())){ if (strcmp(attr->Name(), "tipo")==0) { if(strcmp(attr->Value(), "fps")==0){ preDefinicoes_FPS(node); glutKeyboardFunc(teclado_normal_fps); glutSpecialFunc(teclado_especial_fps); glutMouseFunc(rato_fps); glutMotionFunc(mov_rato_fps); tipo_camera=2; }else if (strcmp(attr->Value(), "explorador")==0){ preDefinicoes_Explorador(node); glutKeyboardFunc(teclado_normal_explorador); glutSpecialFunc(teclado_especial_explorador); glutMouseFunc(rato_explorador); glutMotionFunc(mov_rato_explorador); tipo_camera=1; } } } } }else{ //Caso não esteja definida nenhuma camera, o modo explorador fica activo por defeito glutKeyboardFunc(teclado_normal_explorador); glutSpecialFunc(teclado_especial_explorador); glutMouseFunc(rato_explorador); glutMotionFunc(mov_rato_explorador); tipo_camera=1; } //Luzes if((node=root->FirstChild("luzes"))){ glEnable(GL_LIGHTING); preparaLuzes(node); } //MENU M_Visual=glutCreateMenu(front_menu); glutAddMenuEntry("GL POINT",1); glutAddMenuEntry("GL LINE",2); glutAddMenuEntry("GL FILL",3); M_Camera=glutCreateMenu(front_menu); glutAddMenuEntry("Modo Explorador",4); glutAddMenuEntry("Modo FPS",5); M_Luzes=glutCreateMenu(front_menu); glutAddMenuEntry("Ligar",6); glutAddMenuEntry("Desligar",7); M_Texturas=glutCreateMenu(front_menu); glutAddMenuEntry("Ligar",8); glutAddMenuEntry("Desligar",9); M_ViewFrustum=glutCreateMenu(front_menu); glutAddMenuEntry("Ligar",10); glutAddMenuEntry("Desligar",11); glutAddMenuEntry("Desenhar Limites",12); glutAddMenuEntry("Não Desenhar Limites",13); glutCreateMenu(front_menu); glutAddSubMenu("Visualização",M_Visual); glutAddSubMenu("Camera",M_Camera); glutAddSubMenu("Luz",M_Luzes); glutAddSubMenu("Texturas",M_Texturas); glutAddSubMenu("ViewFrustumCulling",M_ViewFrustum); //Activar pop-up Menus <<<<---------<<<<------<<<<---------<<<<------ glutAttachMenu(GLUT_RIGHT_BUTTON); //Callback do GLEW - Tem de estar depois de todos os callbacks do GLUT glewInit(); ilInit(); //Activar Buffers glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); // alguns settings para OpenGL glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); glClearColor(0.0f,0.0f,0.0f,0.0f); //Carregar todas as estruturas para correr o Motor3D e prepara o Picking prepara_MotorXML(cena); initPickingCena(cena); // entrar no ciclo do GLUT glutMainLoop(); } else printf("Falhou!! Sem tag 'cena' no XML!\n"); } else printf("Falhou!! Não fez load do ficheiro!\n"); return 0; }
int main(int argc, char ** argv) { TsvReader myReader; /* Read the graph from a file */ AdjacencyList * list; m_animation = Animation::Read("bin/animation/real.anim"); if(pre_defined_graph) { std::cout << "Animation Read... Reading Graph" << std::endl; if( argc == 1 ) list = myReader.readGraph("datasets/marvel_social_2.tsv"); else list = myReader.readGraph(std::string(argv[1])); std::cout << "Graph Read... Converting Graph" << std::endl; /* Convert the graph */ m_graph = GraphFactory::createGraph(list); std::cout << "Graph Converted... Initialising Layout" << std::endl; } else { bool m_blah = true; if(m_blah) { std::cout << "BLAH" << std::endl; list = myReader.readGraph("bin/animation/edges"); std::cout << "BLAH" << std::endl; m_graph = GraphFactory::createGraph(list); std::cout << "BLAH" << std::endl; } else { m_graph = new Graph(); m_graph->m_size = 100; } std::cout << "Animation Read... Initialising Layout" << std::endl; } m_state = GraphLayout::generateLayout(m_graph, 0.5f); std::cout << "Layout Initialised... Initialising OpenGL" << std::endl; glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT); // Set the initial Window's width and height glutInitWindowPosition(50, 50); // Position the initial Window's top-left corner glutCreateWindow("Meatballs, Spaghetti and Cheese Sauce"); // Create window with the given title glutDisplayFunc(Display); glutReshapeFunc(Reshape); glEnable(GL_DEPTH_TEST); glClearColor(0.0, 0.0, 0.0, 1.0); Camera::get()->init(); glPointSize(10.0f); glutCreateMenu(Menu); glutAddMenuEntry("Toggle Edges", 1); glutAttachMenu(GLUT_RIGHT_BUTTON); /* */ std::cout << "OpenGL Initialised... Starting Simulation" << std::endl; m_last_update = GetTimeMillis(); glutMainLoop(); return 0; }
/*------------------------------------------------------------*/ void init( int argc, char **argv ) { int c_menu, d_menu, f_menu, b_menu; // Set things up. // Initialize glut glutInit( &argc, argv ); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB ); glutInitWindowSize( DEFAULT_WIDTH, DEFAULT_HEIGHT ); glutInitWindowPosition( INIT_X, INIT_Y ); mainWin = glutCreateWindow( WINDOW_TITLE ); // Setup the callback functions. glutReshapeFunc( reshapeMain ); glutDisplayFunc( displayMain ); glutMouseFunc( mouseMain ); glutMotionFunc( motionMain ); // Create the color submenu. c_menu = glutCreateMenu( colorMenu ); glutAddMenuEntry( "Black", COLOR_BLACK ); glutAddMenuEntry( "White", COLOR_WHITE ); glutAddMenuEntry( "Red", COLOR_RED ); glutAddMenuEntry( "Green", COLOR_GREEN ); glutAddMenuEntry( "Blue", COLOR_BLUE ); glutAddMenuEntry( "Yellow", COLOR_YELLOW ); glutAddMenuEntry( "Purple", COLOR_PURPLE ); glutAddMenuEntry( "Orange", COLOR_ORANGE ); glutAddMenuEntry( "Custom...", COLOR_CUSTOM ); // setup the object menu d_menu = glutCreateMenu( drawMenu ); glutAddMenuEntry( "Rectangle", MENU_RECTANGLE ); glutAddMenuEntry( "Square", OBJ_SQUARE ); glutAddMenuEntry( "Ellipse", MENU_ELLIPSE ); glutAddMenuEntry( "Super Ellispse", MENU_SUPER_E ); glutAddMenuEntry( "Circle", MENU_CIRCLE ); // Set up the fill sub menu f_menu = glutCreateMenu( fillMenu ); glutAddMenuEntry( "Fill On", MENU_YES ); glutAddMenuEntry( "Fill Off", MENU_NO ); b_menu = glutCreateMenu( backMenu ); glutAddMenuEntry( "Black", COLOR_BLACK ); glutAddMenuEntry( "White", COLOR_WHITE ); glutAddMenuEntry( "Red", COLOR_RED ); glutAddMenuEntry( "Green", COLOR_GREEN ); glutAddMenuEntry( "Blue", COLOR_BLUE ); glutAddMenuEntry( "Yellow", COLOR_YELLOW ); glutAddMenuEntry( "Purple", COLOR_PURPLE ); glutAddMenuEntry( "Orange", COLOR_ORANGE ); glutAddMenuEntry( "Custom...", COLOR_CUSTOM ); // Create the main menu controls glutCreateMenu( handleMenu ); glutAddSubMenu( "Draw Object", d_menu ); glutAddSubMenu( "Draw Color", c_menu ); glutAddSubMenu( "Set Fill", f_menu ); glutAddSubMenu( "Change Background", b_menu ); glutAddMenuEntry( "Edit Mode", MENU_EDIT ); glutAddMenuEntry( "Delete Mode", MENU_DELETE ); glutAddMenuEntry( "Clear All", MENU_CLEAR ); glutAddMenuEntry( "Swap Buffers", MENU_SWAP ); glutAddMenuEntry( "Exit", MENU_EXIT ); glutAttachMenu( GLUT_RIGHT_BUTTON ); // Set the options for drawing. options.type = OBJ_RECTANGLE; options.r = 1.0; options.g = 0.0; options.b = 0.0; options.isFilled = 0; // Current program state p_state = ADD_OBJ; // set the initial clearing color glClearColor( DEFAULT_R, DEFAULT_G, DEFAULT_B, DEFAULT_ALPHA ); // attempt to change the camera angle so that drawn objects start showing up. }
int main(int argc, char * argv[]) { // inicjalizacja biblioteki GLUT glutInit(&argc, argv); // inicjalizacja bufora ramki glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); // rozmiary g³ównego okna programu glutInitWindowSize(500, 500); // utworzenie g³ównego okna programu #ifdef WIN32 glutCreateWindow("Mg³a odleg³oœciowa"); #else glutCreateWindow("Mgla odleglosciowa"); #endif // do³¹czenie funkcji generuj¹cej scenê 3D glutDisplayFunc(DisplayScene); // do³¹czenie funkcji wywo³ywanej przy zmianie rozmiaru okna glutReshapeFunc(Reshape); // do³¹czenie funkcji obs³ugi klawiatury glutKeyboardFunc(Keyboard); // do³¹czenie funkcji obs³ugi klawiszy funkcyjnych i klawiszy kursora glutSpecialFunc(SpecialKeys); // obs³uga przycisków myszki glutMouseFunc(MouseButton); // obs³uga ruchu kursora myszki glutMotionFunc(MouseMotion); // utworzenie menu podrêcznego glutCreateMenu(Menu); // utworzenie podmenu - aspekt obrazu int MenuAspect = glutCreateMenu(Menu); glutAddMenuEntry("Aspekt obrazu - ca³e okno", FULL_WINDOW); glutAddMenuEntry("Aspekt obrazu 1:1", ASPECT_1_1); // utworzenie podmenu - Rodzaj mg³y int MenuFogMode = glutCreateMenu(Menu); glutAddMenuEntry("GL_LINEAR", GL_LINEAR); glutAddMenuEntry("GL_EXP", GL_EXP); glutAddMenuEntry("GL_EXP2", GL_EXP2); // utworzenie podmenu - GL_FOG_HINT int MenuFogHint = glutCreateMenu(Menu); glutAddMenuEntry("GL_FASTEST", GL_FASTEST); glutAddMenuEntry("GL_DONT_CARE", GL_DONT_CARE); glutAddMenuEntry("GL_NICEST", GL_NICEST); // menu g³ówne glutCreateMenu(Menu); glutAddSubMenu("Rodzaj mg³y", MenuFogMode); glutAddSubMenu("GL_FOG_HINT", MenuFogHint); glutAddSubMenu("Aspekt obrazu", MenuAspect); glutAddMenuEntry("Wyjœcie", EXIT); // okreœlenie przycisku myszki obs³uguj¹cej menu podrêczne glutAttachMenu(GLUT_RIGHT_BUTTON); // wprowadzenie programu do obs³ugi pêtli komunikatów glutMainLoop(); return 0; }
// ---------------------------------------------------------------------------- int main(int argc, char **argv) { struct aiLogStream stream; glutInitWindowSize(900,600); glutInitWindowPosition(100,100); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInit(&argc, argv); glutCreateWindow("Assimp - Very simple OpenGL sample"); glutDisplayFunc(display); glutReshapeFunc(reshape); // get a handle to the predefined STDOUT log stream and attach // it to the logging system. It will be active for all further // calls to aiImportFile(Ex) and aiApplyPostProcessing. stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL); aiAttachLogStream(&stream); // ... exactly the same, but this stream will now write the // log file to assimp_log.txt stream = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"assimp_log.txt"); aiAttachLogStream(&stream); // the model name can be specified on the command line. we try to locate // one of the more expressive test models from the repository. if( 0 != loadasset( argc >= 2 ? argv[1] : "../../test/models-nonbsd/X/dwarf.x")) { if( argc != 1 || 0 != loadasset( "../../../../test/models-nonbsd/X/dwarf.x") && 0 != loadasset( "../../test/models/X/Testwuson.X")) { return -1; } } glClearColor(0.1f,0.1f,0.1f,1.f); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // Uses default lighting parameters glEnable(GL_DEPTH_TEST); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glEnable(GL_NORMALIZE); // XXX docs say all polygons are emitted CCW, but tests show that some aren't. if(getenv("MODEL_IS_BROKEN")) glFrontFace(GL_CW); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glutGet(GLUT_ELAPSED_TIME); glutMainLoop(); // cleanup - calling 'aiReleaseImport' is important, as the library // keeps internal resources until the scene is freed again. Not // doing so can cause severe resource leaking. aiReleaseImport(scene); // We added a log stream to the library, it's our job to disable it // again. This will definitely release the last resources allocated // by Assimp. aiDetachAllLogStreams(); return 0; }
int main(int argc, char ** argv) { unsigned int displayMode; #ifdef __APPLE__ GLint VBL = 1; #endif glutInit(&argc, argv); configuration.windowX = 2; configuration.windowY = 28; configuration.windowWidth = 800; configuration.windowHeight = 600; configuration.windowTitle = "GLUTShell"; configuration.displayMode.doubleBuffer = true; configuration.displayMode.depthBuffer = false; configuration.displayMode.stencilBuffer = false; configuration.displayMode.accumBuffer = false; configuration.displayMode.multisample = false; GLUTTarget_configure(argc, (const char **) argv, &configuration); displayMode = GLUT_RGBA; if (configuration.displayMode.doubleBuffer) { displayMode |= GLUT_DOUBLE; } if (configuration.displayMode.depthBuffer) { displayMode |= GLUT_DEPTH; } if (configuration.displayMode.stencilBuffer) { displayMode |= GLUT_STENCIL; } if (configuration.displayMode.accumBuffer) { displayMode |= GLUT_ACCUM; } if (configuration.displayMode.multisample) { displayMode |= GLUT_MULTISAMPLE; } glutInitDisplayMode(displayMode); glutInitWindowPosition(configuration.windowX, configuration.windowY); glutInitWindowSize(configuration.windowWidth, configuration.windowHeight); glutCreateWindow(configuration.windowTitle); glutReshapeFunc(reshapeFunc); glutDisplayFunc(displayFunc); glutKeyboardFunc(keyDownFunc); glutKeyboardUpFunc(keyUpFunc); glutSpecialFunc(specialDownFunc); glutSpecialUpFunc(specialUpFunc); glutMouseFunc(mouseFunc); glutMotionFunc(motionFunc); glutPassiveMotionFunc(motionFunc); #ifdef __APPLE__ CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL); #endif GLGraphics_init(GL_API_VERSION_DESKTOP_1); Target_init(argc, argv); return EXIT_SUCCESS; }
int doMain (int argc, char **argv) { OSG::osgInit(argc,argv); // GLUT init glutInit(&argc, argv); glutInitDisplayMode( GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE); glutInitWindowSize(800, 800); int winid = glutCreateWindow("OpenSG"); glutKeyboardFunc(key); glutVisibilityFunc(vis); glutReshapeFunc(reshape); glutDisplayFunc(display); glutMouseFunc(mouse); glutMotionFunc(motion); glutIdleFunc(display); // OSG OSG::SceneFileHandler::the()->print(); // create the graph // beacon for camera and light OSG::NodeUnrecPtr b1n = OSG::Node::create(); OSG::GroupUnrecPtr b1 = OSG::Group::create(); fprintf(stderr, "Create b1n %p %d %d \n", b1n.get(), b1n->getRefCount(), b1n->getWeakRefCount()); b1n->setCore( b1 ); // transformation OSG::NodeUnrecPtr t1n = OSG::Node::create(); OSG::TransformUnrecPtr t1 = OSG::Transform::create(); t1n->setCore (t1 ); t1n->addChild(b1n); fprintf(stderr, "Create t1n %p %d %d \n", t1n.get(), t1n->getRefCount(), t1n->getWeakRefCount()); cam_trans = t1; // light OSG::NodeUnrecPtr dlight = OSG::Node::create(); OSG::DirectionalLightUnrecPtr dl = OSG::DirectionalLight::create(); { dlight->setCore(dl); dl->setAmbient( .3f, .3f, .3f, 1 ); dl->setDiffuse( .8f, .8f, .8f, .8f ); dl->setDirection(0,0,1); dl->setBeacon( b1n); } fprintf(stderr, "Create dlight %p %d %d \n", dlight.get(), dlight->getRefCount(), dlight->getWeakRefCount()); hdrroot = OSG::Node::create(); hdrroot->editVolume().setInfinite(); hdrroot->editVolume().setStatic (); createHDRCore(hdrroot); // root root = OSG::Node:: create(); OSG::GroupUnrecPtr gr1 = OSG::Group::create(); root->setCore(gr1); hdrroot->addChild(root); root->addChild(t1n ); root->addChild(dlight); fprintf(stderr, "Create root %p %d %d \n", root.get(), root->getRefCount(), root->getWeakRefCount()); // Load the file OSG::NodeUnrecPtr file = NULL; if(argc > 1) { file = OSG::SceneFileHandler::the()->read(argv[1], NULL); } if(file == NULL) { std::cerr << "Couldn't load file, ignoring" << std::endl; // file = makeBox(2.f, 2.f, 2.f, 2, 2, 2); file = OSG::makeSphere(4, 2.0); } OSG::NodeUnrecPtr pCubeRoot = OSG::Node::create(); OSG::CubeMapGeneratorUnrecPtr pCubeGen = OSG::CubeMapGenerator::create(); pCubeRoot->addChild(file); pCubeRoot->setCore(pCubeGen); // pCubeRoot->setCore(Group::create()); OSG::NodeUnrecPtr pCubeSceneRoot = OSG::Node::create(); OSG::VisitSubTreeUnrecPtr pCubeVisit = OSG::VisitSubTree::create(); pCubeSceneRoot->setCore(pCubeVisit); pCubeVisit->setSubTreeRoot(root); pCubeGen->setRoot (pCubeSceneRoot); pCubeGen->setTextureFormat(GL_RGB32F_ARB ); pCubeGen->setSize (512, 512 ); pCubeGen->setTexUnit (3); OSG::NodeUnrecPtr pAnimRoot = setupAnim(); scene_trans = OSG::Transform::create(); OSG::NodeUnrecPtr sceneTrN = OSG::Node::create(); scene_trans->editMatrix()[3][2] = -50.f; sceneTrN->setCore (scene_trans); sceneTrN->addChild(pCubeRoot ); sceneTrN->addChild(pAnimRoot ); OSG::Thread::getCurrentChangeList()->commitChanges(); OSG::Vec3f min,max; sceneTrN->updateVolume(); sceneTrN->getVolume().getBounds(min, max); std::cout << "Volume: from " << min << " to " << max << std::endl; dlight->addChild(sceneTrN); // Camera cam = OSG::PerspectiveCamera::create(); { cam->setBeacon( b1n ); cam->setFov( OSG::osgDegree2Rad( 90 ) ); cam->setNear( 0.1f ); cam->setFar( 100000 ); } // Background OSG::SkyBackgroundUnrecPtr bkgnd = OSG::SkyBackground::create(); { OSG::ImageUnrecPtr pBackImg = OSG::ImageFileHandler::the()->read("data/grace_cross.chdr"); OSG::TextureObjChunkUnrecPtr pBackTex = OSG::TextureObjChunk::create(); pBackTex->setImage (pBackImg ); pBackTex->setInternalFormat(GL_RGB32F_ARB ); pBackTex->setWrapS (GL_CLAMP_TO_EDGE); pBackTex->setWrapT (GL_CLAMP_TO_EDGE); bkgnd->setBackTexture (pBackTex); bkgnd->setFrontTexture (pBackTex); bkgnd->setLeftTexture (pBackTex); bkgnd->setRightTexture (pBackTex); bkgnd->setTopTexture (pBackTex); bkgnd->setBottomTexture(pBackTex); } // Viewport vp = OSG::Viewport::create(); { vp->setCamera( cam ); vp->setBackground( bkgnd ); vp->setRoot( hdrroot ); // vp->setRoot( root ); vp->setSize( 0,0, 1,1 ); } // Window OSG::GLUTWindowUnrecPtr gwin; GLint glvp[4]; glGetIntegerv(GL_VIEWPORT, glvp); gwin = OSG::GLUTWindow::create(); { gwin->setGlutId(winid); gwin->setSize( glvp[2], glvp[3] ); win = gwin; win->addPort( vp ); win->init(); } // Action rentravact = OSG::RenderAction::create(); rentravact->setVolumeDrawing(true); // rentravact->setFrustumCulling(false); // tball OSG::Vec3f pos; pos.setValues(min[0] + ((max[0] - min[0]) * 0.5), min[1] + ((max[1] - min[1]) * 0.5), max[2] + ( max[2] - min[2] ) * 1.5 ); float scale = (max[2] - min[2] + max[1] - min[1] + max[0] - min[0]) / 6; OSG::Pnt3f tCenter(min[0] + (max[0] - min[0]) / 2, min[1] + (max[1] - min[1]) / 2, min[2] + (max[2] - min[2]) / 2); fprintf(stderr, "Startpos : %f %f %f\n", pos[0], pos[1], pos[2]); tball.setMode (OSG::Trackball::OSGObject); tball.setStartPosition (pos, true ); tball.setSum (true ); tball.setTranslationMode (OSG::Trackball::OSGFree ); tball.setTranslationScale(scale ); tball.setRotationCenter (tCenter ); fprintf(stderr, "Create b1n %p %d %d \n", b1n.get(), b1n->getRefCount(), b1n->getWeakRefCount()); fprintf(stderr, "Create t1n %p %d %d \n", t1n.get(), t1n->getRefCount(), t1n->getWeakRefCount()); fprintf(stderr, "Create dlight %p %d %d \n", dlight.get(), dlight->getRefCount(), dlight->getWeakRefCount()); fprintf(stderr, "Create hdrroot %p %d %d \n", hdrroot.get(), hdrroot->getRefCount(), hdrroot->getWeakRefCount()); fprintf(stderr, "Create root %p %d %d \n", root.get(), root->getRefCount(), root->getWeakRefCount()); return 0; }
int main(int argc, char* argv[]) { /****************************************/ /* Initialize GLUT and create window */ /****************************************/ glutInit(&argc, argv); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowPosition( 50, 50 ); glutInitWindowSize( 300, 300 ); main_window = glutCreateWindow( "GLUI Example 3" ); glutDisplayFunc( myGlutDisplay ); glutReshapeFunc( myGlutReshape ); glutKeyboardFunc( myGlutKeyboard ); glutMotionFunc( myGlutMotion ); glutMouseFunc( myGlutMouse ); /****************************************/ /* Set up OpenGL lights */ /****************************************/ glEnable(GL_LIGHTING); glEnable( GL_NORMALIZE ); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient); glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse); glLightfv(GL_LIGHT1, GL_POSITION, light1_position); /****************************************/ /* Enable z-buferring */ /****************************************/ glEnable(GL_DEPTH_TEST); /****************************************/ /* Here's the GLUI code */ /****************************************/ printf( "GLUI version: %3.2f\n", GLUI_Master.get_version() ); glui = GLUI_Master.create_glui( "GLUI", 0, 400, 50 ); /* name, flags, x, and y */ new GLUI_StaticText( glui, "GLUI Example 3" ); obj_panel = new GLUI_Panel(glui, "Object" ); /***** Control for the object type *****/ GLUI_Panel *type_panel = new GLUI_Panel( obj_panel, "Type" ); radio = new GLUI_RadioGroup(type_panel,&obj_type,4,control_cb); new GLUI_RadioButton( radio, "Sphere" ); new GLUI_RadioButton( radio, "Torus" ); new GLUI_RadioButton( radio, "Teapot" ); checkbox = new GLUI_Checkbox(obj_panel, "Wireframe", &wireframe, 1, control_cb ); spinner = new GLUI_Spinner( obj_panel, "Segments:", &segments); spinner->set_int_limits( 3, 60 ); spinner->set_alignment( GLUI_ALIGN_RIGHT ); scale_spinner = new GLUI_Spinner( obj_panel, "Scale:", &scale); scale_spinner->set_float_limits( .2f, 4.0 ); scale_spinner->set_alignment( GLUI_ALIGN_RIGHT ); new GLUI_Separator( obj_panel ); edittext = new GLUI_EditText( obj_panel, "Text:", text ); edittext->set_w( 150 ); /******** Add some controls for lights ********/ GLUI_Panel *light0 = new GLUI_Panel( glui, "Light 1" ); GLUI_Panel *light1 = new GLUI_Panel( glui, "Light 2" ); new GLUI_Checkbox( light0, "Enabled", &light0_enabled, LIGHT0_ENABLED_ID, control_cb ); light0_spinner = new GLUI_Spinner( light0, "Intensity:", &light0_intensity, LIGHT0_INTENSITY_ID, control_cb ); light0_spinner->set_float_limits( 0.0, 1.0 ); new GLUI_Checkbox( light1, "Enabled", &light1_enabled, LIGHT1_ENABLED_ID, control_cb ); light1_spinner = new GLUI_Spinner( light1, "Intensity:", &light1_intensity, LIGHT1_INTENSITY_ID, control_cb ); light1_spinner->set_float_limits( 0.0, 1.0 ); light1_spinner->disable(); /* Disable this light initially */ /****** Add a grayed-out counter *****/ GLUI_EditText *counter_edittext = new GLUI_EditText( glui, "Count:", &counter ); counter_edittext->disable(); /****** Button to Open Command Line Window ******/ open_console_btn = new GLUI_Button(glui, "Open Console", OPEN_CONSOLE_ID, pointer_cb); /****** A 'quit' button *****/ new GLUI_Button(glui, "Quit", 0,(GLUI_Update_CB)exit ); /**** Link windows to GLUI, and register idle callback ******/ glui->set_main_gfx_window( main_window ); /* We register the idle callback with GLUI, not with GLUT */ GLUI_Master.set_glutIdleFunc( myGlutIdle ); /**** Regular GLUT main loop ****/ glutMainLoop(); return EXIT_SUCCESS; }
int main (int argc, char** argv) { // Initialize GLUT glutInit(&argc, argv); //glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); // Initialize GLFW if ( !glfwInit()) { std::cerr << "Failed to initialize GLFW! I'm out!" << std::endl; exit(-1); } // Use OpenGL 3.2 core profile /* glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); */ // Open a window and attach an OpenGL rendering context to the window surface if( !glfwOpenWindow(500, 500, 8, 8, 8, 0, 0, 0, GLFW_WINDOW)) { std::cerr << "Failed to open a window! I'm out!" << std::endl; glfwTerminate(); exit(-1); } // Register a callback function for window resize events glfwSetWindowSizeCallback( window_resized ); // Register a callback function for keyboard pressed events glfwSetKeyCallback(keyboard); // Print the OpenGL version int major, minor, rev; glfwGetGLVersion(&major, &minor, &rev); std::cout << "OpenGL - " << major << "." << minor << "." << rev << std::endl; // Initialize GLEW glewExperimental = GL_TRUE; if(glewInit() != GLEW_OK) { std::cerr << "Failed to initialize GLEW! I'm out!" << std::endl; glfwTerminate(); exit(-1); } // Create a rendering loop int running = GL_TRUE; while(running) { // Display scene display(); // Pool for events glfwPollEvents(); // Check if the window was closed running = glfwGetWindowParam(GLFW_OPENED); } // Terminate GLFW glfwTerminate(); return 0; }
int main(int argc, char *argv[]) { // inicjalizacja biblioteki GLUT glutInit(&argc, argv); // inicjalizacja bufora ramki glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); // rozmiary głównego okna programu glutInitWindowSize(550, 550); // utworzenie głównego okna programu glutCreateWindow("Kompresja tekstur"); // dołączenie funkcji generującej scenę 3D glutDisplayFunc(DisplayScene); // dołączenie funkcji wywoływanej przy zmianie rozmiaru okna glutReshapeFunc(Reshape); // utworzenie podmenu - Tekstura int MenuTexture = glutCreateMenu(Menu); glutAddMenuEntry("lena.tga (kompresja)", TEXTURE_LENA); glutAddMenuEntry("lena.tga (bez kompresji)", TEXTURE_LENA_UNC); glutAddMenuEntry("lena_gray.tga (kompresja)", TEXTURE_LENA_GRAY); glutAddMenuEntry("lena_gray.tga (bez kompresji)", TEXTURE_LENA_GRAY_UNC); // utworzenie podmenu - GL_TEXTURE_COMPRESSION_HINT int MenuTextureCompressionHint = glutCreateMenu(Menu); glutAddMenuEntry("GL_FASTEST", TEXTURE_COMPRESSION_FASTEST); glutAddMenuEntry("GL_DONT_CARE", TEXTURE_COMPRESSION_DONT_CARE); glutAddMenuEntry("GL_NICEST", TEXTURE_COMPRESSION_NICEST); // utworzenie podmenu - Aspekt obrazu int MenuAspect = glutCreateMenu(Menu); #ifdef WIN32 glutAddMenuEntry("Aspekt obrazu - całe okno", FULL_WINDOW); #else glutAddMenuEntry("Aspekt obrazu - cale okno", FULL_WINDOW); #endif glutAddMenuEntry("Aspekt obrazu 1:1", ASPECT_1_1); // menu główne glutCreateMenu(Menu); glutAddSubMenu("Tekstura", MenuTexture); glutAddSubMenu("GL_TEXTURE_COMPRESSION_HINT", MenuTextureCompressionHint); glutAddSubMenu("Aspekt obrazu", MenuAspect); #ifdef WIN32 glutAddMenuEntry("Wyjście", EXIT); #else glutAddMenuEntry("Wyjscie", EXIT); #endif // określenie przycisku myszki obsługującego menu podręczne glutAttachMenu(GLUT_RIGHT_BUTTON); // utworzenie tekstur GenerateTextures(); // sprawdzenie i przygotowanie obsługi wybranych rozszerzeń ExtensionSetup(); // wprowadzenie programu do obsługi pętli komunikatów glutMainLoop(); return 0; }
int main(int argc, char *argv[]) { string s; fileName = new char[50]; cout << "Enter file name: " ; cin >> fileName; s = fileName; s = "Matrix Results For " + s; fileOut = &s[0]; int matrixRows=-1,matrixCols=-1,matrixHeights=-1; //set matrix number of rows and columns //or set numX, numY, numZ for 3-person game if necessary ifstream inFile(fileName); //ifstream inFile(&s[0]); if(!inFile.is_open()) { cout << "File does not exist or is corrupted." << endl; system("PAUSE"); exit(0); } ofstream outFile(fileOut); if(!inFile.eof()); inFile >> matrixRows; if(!inFile.eof()); inFile >> matrixCols; if(!inFile.eof()); inFile >> matrixHeights; inFile.close(); if(matrixRows == -1 || matrixCols == -1) { cout << "File does not exist or have invalid matrix information." << endl; system("Pause"); return EXIT_SUCCESS; } nPerson = baseMatrix::checkNPersonGame(fileName, matrixRows, matrixCols); zeroSum = baseMatrix::check2PersonZeroSum(fileName, matrixRows, matrixCols); //initialize payoff matrix if(!nPerson) { if(zeroSum) { payoffMatrix *Matrix = payoffMatrix::createGame(fileName, matrixRows, matrixCols); pom = Matrix; outFile << pom->getValue() << endl; pom->writeSolutions(outFile); } else { pom = payoffMatrix::createGameNzs(fileName, matrixRows, matrixCols); outFile << pom->getValueNzs() << endl; for(int i=1; i<=2; i++) { payoffMatrix* pmzs = pom->getZeroSumSubGame(i); outFile << "/////////////////////////////////////////////"<<endl; if(i==2) outFile << "Rose's equalizing game: " << endl; if(i==1) outFile << "Colin's equalizing game: " << endl; outFile << pmzs->getValue() << endl; pmzs->writeSolutions(outFile); } } } else { pomn = payoffMatrixN::createGame(fileName, matrixRows, matrixCols, matrixHeights); outFile << pomn->getValue() << endl; //if the game is zero sum n person game if(pomn->IsZeroSum()) { for(int i=1; i<=3; i++) { //switch it to 2 person zero sum pom = pomn->get2PersonGame(i); outFile << "///////////////////////////////////////////////" << endl; if(i==1) outFile << "Rose's Game:" << endl; if(i==2) outFile << "Colin's Game:" << endl; if(i==3) outFile << "Larry's Game:" << endl; if(pom!=(payoffMatrix*)NULL) { //now solve the 2 person zero sum game outFile << pom->getValue() << endl; pom->writeSolutions(outFile); } } } //case of non zero sum n person game else { for(int i=1; i<=3; i++) { //first switch it to 2 person non zero sum game //using the idea of coalition pom = pomn->get2PersonGameNzs(i); if(pom != (payoffMatrix*)NULL) { payoffMatrix* pmzs; if(i==1) outFile << "Rose's prudential game: " << endl; if(i==2) outFile << "Colin's prudential game: " << endl; if(i==3) outFile << "Larry's prudential game: " << endl; outFile << pom->getValueNzs() << endl; for(int j=1; j<=2; j++) { if(i==1 && j==2) outFile << "Rose's equalizing game against Colin and Larry: " << endl; if(i==1 && j==1) outFile << "Colin and Larry's equalizing game against Rose: " << endl; if(i==2 && j==2) outFile << "Colin's equalizing game against Rose and Larry: " << endl; if(i==2 && j==1) outFile << "Rose and Larry's equalizing game against Colin: " << endl; if(i==3 && j==2) outFile << "Larry's equalizing game against Rose and Colin: " << endl; if(i==3 && j==1) outFile << "Rose and Colin's equalizing game against Larry: " << endl; //get the prudential strategy game solution pmzs = pom->getZeroSumSubGame(j); outFile << pmzs->getValue() << endl; pmzs->writeSolutions(outFile); } } } } } /*---------------------------------------------------------------------------------*/ //initialize visualization object pointer to default to the flow diagram if(!nPerson) { if(zeroSum) v = new Flow(); else v = new FlowNzs(); } else v = new Flow3D(); //OpenGL loop glutInit(&argc, argv); //initialize the proper rendering mode for either 2D or 3D if(!nPerson) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); else glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowPosition(100,100); glutInitWindowSize(WIDTH,HEIGHT); glutCreateWindow("Game Theory"); init(); glutDisplayFunc(display); glutCreateMenu(myMenu); //change the menu accordingly to whether a 2-person or n-person game is loaded if(!nPerson) { if(zeroSum) { if(pom->Envelopable()) glutAddMenuEntry("Envelope", 1); glutAddMenuEntry("Flow", 2); } } else { glutAddMenuEntry("Flow3D", 1); } glutAttachMenu(GLUT_RIGHT_BUTTON); glutKeyboardFunc(my_keyboard); //this is for 3D only if(nPerson) { glutMotionFunc(mouse_dragged); glutMouseFunc(mouse); } glutMainLoop(); outFile.close(); system("PAUSE"); return EXIT_SUCCESS; }
int main(int argc, char** argv) { // initialize glut glutInit(&argc, argv); // specify the display mode to be RGBA, depth buffer and double buffering glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE ); // define the size glutInitWindowSize(1024,576); // create the window and set title glutCreateWindow("OpenGL - Anaglyph"); // callbacks glutDisplayFunc(display_func); glutKeyboardFunc(keyboard_func); glutReshapeFunc(resize_func); glutIdleFunc(idle_func); glutMouseFunc(mouse_func); glutMotionFunc(motion_func); int draw_mode_menu = glutCreateMenu(handle_draw_mode_menu); glutAddMenuEntry("Wireframe",App::WIREFRAME); glutAddMenuEntry("Solid",App::SOLID); int model_menu = glutCreateMenu(handle_model_menu); glutAddMenuEntry("Teapot",App::TEAPOT); glutAddMenuEntry("Box",App::BOX); glutAddMenuEntry("Table",App::TABLE); int separation_menu = glutCreateMenu(handle_separation_menu); glutAddMenuEntry("Red/Green",App::RED_GREEN); glutAddMenuEntry("Red/Cyan",App::RED_CYAN); glutAddMenuEntry("Full Color/No 3D",App::FULL_COLOR); int cameraOutput_menu = glutCreateMenu(handle_camera_output_menu); glutAddMenuEntry("None",0); glutAddMenuEntry("Panel",1); glutAddMenuEntry("Scene",2); glutAddMenuEntry("Panel+Scene",3); int cameraFilter_menu = glutCreateMenu(handle_camera_filter_menu); glutAddMenuEntry("Base image",RealCamera::BASE_IMAGE); glutAddMenuEntry("Tracked Cyan",RealCamera::TRACKED_CYAN); glutAddMenuEntry("Tracked Red",RealCamera::TRACKED_RED); glutCreateMenu(handle_main_menu); glutAddSubMenu("Model Type",model_menu); glutAddSubMenu("Draw Mode",draw_mode_menu); glutAddSubMenu("Eye Separation Filter",separation_menu); glutAddSubMenu("Camera Output To",cameraOutput_menu); glutAddSubMenu("Camera Filter",cameraFilter_menu); glutAddMenuEntry("Toggle Animation",MENU_ANIMATION); glutAddMenuEntry("Toggle Lighting",MENU_LIGHTING); glutAddMenuEntry("Toggle centered Projection",MENU_CENTERED_PROJECTION); glutAddMenuEntry("Kill Background",MENU_KILL_BACKGROUND); glutAddMenuEntry("Calibrate Position",MENU_CALIBRATE_POSITION); glutAttachMenu(GLUT_RIGHT_BUTTON); // setup application main_app.setup(); // print out some information about program control std::cout << "Usage\n" << "Right mouse button opens context menu for some settings.\n" << "Key \'q\' quits application\n"; // enter the main loop glutMainLoop(); return 0; }
//------------------------------------------------- // main program loop //------------------------------------------------- int main(int argc, char** argv) { //--------------------------------------------------------------------------- // TO DO: Change this file name to change the .obj model that is loaded // Optional: read in the file name from the command line > proj1_mesh myfile.obj //-------------------------------------------------------------------------- meshOBJ = std::string("/home/pj/Desktop/Fall_2015/proj1_mesh/src/mainsrc/mysphere.obj"); vertexShader = std::string("kernels/default.vert"); fragmentShader = std::string("kernels/phong.frag"); normalMap = std::string("/home/pj/Desktop/Fall_2015/New Folder/proj1_mesh/data/images/cactus.jpeg"); displacementMap= std::string("/home/pj/Desktop/Fall_2015/New Folder/proj1_mesh/data/images/Body.png"); // // Initialize GLUT. // glutInit(&argc, argv); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowPosition(20, 20); glutInitWindowSize(640, 480); glutCreateWindow("proj1_mesh"); // // Initialize GLEW. // #ifndef __APPLE__ glewInit(); if(!GLEW_VERSION_2_0) { printf("Your graphics card or graphics driver does\n" "\tnot support OpenGL 2.0, trying ARB extensions\n"); if(!GLEW_ARB_vertex_shader || !GLEW_ARB_fragment_shader) { printf("ARB extensions don't work either.\n"); printf("\tYou can try updating your graphics drivers.\n" "\tIf that does not work, you will have to find\n"); printf("\ta machine with a newer graphics card.\n"); exit(1); } } #endif // Be sure to initialize GLUT (and GLEW for this assignment) before // initializing your application. Setup(); glutDisplayFunc(DisplayCallback); glutReshapeFunc(ReshapeCallback); glutSpecialFunc(SpecialKeyCallback); glutKeyboardFunc(KeyCallback); glutMouseFunc(MouseCallback); glutMotionFunc(MouseMotionCallback); glutIdleFunc(DisplayCallback); glutMainLoop(); // Cleanup code should be called here. CleanUp(); return 0; }
int main(int argc, char** argv) { char glutGamemode[32]; char cparam_name[] = "Data/camera_para.dat"; char vconf[] = ""; char patt_name[] = "Data/patt.hiro"; char movieFileName[] = "Data/sample.mov"; char *movieURI; // // Library inits. // glutInit(&argc, argv); // // Video setup. // if (!setupCamera(cparam_name, vconf, &gCparamLT, &gARHandle, &gAR3DHandle)) { ARLOGe("main(): Unable to set up AR camera.\n"); exit(-1); } // // Graphics setup. // // Set up GL context(s) for OpenGL to draw into. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); if (!windowed) { if (windowRefresh) sprintf(glutGamemode, "%ix%i:%i@%i", windowWidth, windowHeight, windowDepth, windowRefresh); else sprintf(glutGamemode, "%ix%i:%i", windowWidth, windowHeight, windowDepth); glutGameModeString(glutGamemode); glutEnterGameMode(); } else { glutInitWindowSize(windowWidth, windowHeight); glutCreateWindow(argv[0]); } // Setup ARgsub_lite library for current OpenGL context. if ((gArglSettings = arglSetupForCurrentContext(&(gCparamLT->param), arVideoGetPixelFormat())) == NULL) { ARLOGe("main(): arglSetupForCurrentContext() returned error.\n"); cleanup(); exit(-1); } arglSetupDebugMode(gArglSettings, gARHandle); arUtilTimerReset(); // Load marker(s). if (!setupMarker(patt_name, &gPatt_id, gARHandle, &gARPattHandle)) { ARLOGe("main(): Unable to set up AR marker.\n"); cleanup(); exit(-1); } // // Movie loading. // // In this example, we load a movie via a file URI, but other URIs allowed // by the QuickTime module would also be fine. // Movie relative path is in "movieFileName". Get a file:// URI for it. movieURI = arUtilGetFileURI(movieFileName); if (!movieURI) { ARLOGe("Error: Unable to construct URI for movie file '%s'.\n", movieFileName); cleanup(); exit(-1); } // Now open the movie. if (!setupMovie(movieURI)) { ARLOGe("Error: Unable to open movie at URI '%s'.\n", movieURI); free(movieURI); cleanup(); exit(-1); } free(movieURI); // We're finished with movieURI, so free it. // Register GLUT event-handling callbacks. // NB: mainLoop() is registered by Visibility. glutDisplayFunc(Display); glutReshapeFunc(Reshape); glutVisibilityFunc(Visibility); glutKeyboardFunc(Keyboard); glutMainLoop(); return (0); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); glutInit(&argc, argv); google::InitGoogleLogging(argv[0]); namespace fs = boost::filesystem; namespace po = boost::program_options; const string home_directory = QDir::homePath().toStdString(); cout << "Home dir: " << home_directory << endl; po::options_description desc("Options"); desc.add_options() ("settings_file", po::value<string>()->required(), "Input settings file") ("model_file", po::value<string>()->default_value(home_directory + "/Data/Multilinear/blendshape_core.tensor"), "Multilinear model file") ("id_prior_file", po::value<string>()->default_value(home_directory + "/Data/Multilinear/blendshape_u_0_aug.tensor"), "Identity prior file") ("exp_prior_file", po::value<string>()->default_value(home_directory + "/Data/Multilinear/blendshape_u_1_aug.tensor"), "Expression prior file") ("template_mesh_file", po::value<string>()->default_value(home_directory + "/Data/Multilinear/template.obj"), "Template mesh file") ("contour_points_file", po::value<string>()->default_value(home_directory + "/Data/Multilinear/contourpoints.txt"), "Contour points file") ("landmarks_file", po::value<string>()->default_value(home_directory + "/Data/Multilinear/landmarks_73.txt"), "Landmarks file") ("direct_multi_recon", "Use direct multi-recon") ("no_selection", "Disable selection") ("no_failure_detection", "Disable feature points failure detection") ("no_progressive", "Diable progressive reconstruction"); po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if(vm.count("help")) { cout << desc << endl; return 1; } // nothing to do after successful parsing command line arguments } catch(po::error& e) { cerr << "Error: " << e.what() << endl; cerr << desc << endl; return 1; } const string model_filename(vm["model_file"].as<string>()); const string id_prior_filename(vm["id_prior_file"].as<string>()); const string exp_prior_filename(vm["exp_prior_file"].as<string>()); const string template_mesh_filename(vm["template_mesh_file"].as<string>()); const string contour_points_filename(vm["contour_points_file"].as<string>()); const string landmarks_filename(vm["landmarks_file"].as<string>()); const string settings_filename(vm["settings_file"].as<string>()); BasicMesh mesh(template_mesh_filename); auto landmarks = LoadIndices(landmarks_filename); auto contour_indices = LoadContourIndices(contour_points_filename); // Create reconstructor and load the common resources MultiImageReconstructor<Constraint2D> recon; recon.LoadModel(model_filename); recon.LoadPriors(id_prior_filename, exp_prior_filename); recon.SetMesh(mesh); recon.SetContourIndices(contour_indices); recon.SetIndices(landmarks); recon.SetSelectionState(!vm.count("no_selection")); recon.SetFailureDetectionState(!vm.count("no_failure_detection")); recon.SetProgressiveReconState(!vm.count("no_progressive")); recon.SetDirectMultiRecon(vm.count("direct_multi_recon")); // Parse the setting file and load image related resources fs::path settings_filepath(settings_filename); vector<pair<string, string>> image_points_filenames = ParseSettingsFile(settings_filename); for(auto& p : image_points_filenames) { fs::path image_filename = settings_filepath.parent_path() / fs::path(p.first); fs::path pts_filename = settings_filepath.parent_path() / fs::path(p.second); cout << "[" << image_filename << ", " << pts_filename << "]" << endl; auto image_points_pair = LoadImageAndPoints(image_filename.string(), pts_filename.string(), false); recon.AddImagePointsPair(image_filename.string(), image_points_pair); } { boost::timer::auto_cpu_timer t("Reconstruction finished in %w seconds.\n"); recon.Reconstruct(); } //return a.exec(); return 0; }
int main(int argc, char* argv[]) { /****************************************/ /* Initialize GLUT and create window */ /****************************************/ glutInit(&argc, argv); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowPosition( 50, 50 ); glutInitWindowSize( 300, 300 ); main_window = glutCreateWindow( "GLUI Example 4" ); glutDisplayFunc( myGlutDisplay ); glutReshapeFunc( myGlutReshape ); glutKeyboardFunc( myGlutKeyboard ); glutMotionFunc( myGlutMotion ); glutMouseFunc( myGlutMouse ); /****************************************/ /* Set up OpenGL lights */ /****************************************/ glEnable(GL_LIGHTING); glEnable( GL_NORMALIZE ); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient); glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse); glLightfv(GL_LIGHT1, GL_POSITION, light1_position); /****************************************/ /* Enable z-buferring */ /****************************************/ glEnable(GL_DEPTH_TEST); /****************************************/ /* Here's the GLUI code */ /****************************************/ printf( "GLUI version: %3.2f\n", GLUI_Master.get_version() ); glui = GLUI_Master.create_glui( "GLUI", 0, 400, 50 ); /* name, flags, x, and y */ /*** Add invisible panel to hold rest of controls ***/ GLUI_Panel *panel1 = glui->add_panel( "", GLUI_PANEL_NONE ); obj_panel = glui->add_panel_to_panel( panel1, "Objects" ); /***** Control for object params *****/ checkbox = glui->add_checkbox_to_panel( obj_panel, "Wireframe", &wireframe, 1, control_cb ); spinner = glui->add_spinner_to_panel( obj_panel, "Segments:", GLUI_SPINNER_INT, &segments); spinner->set_int_limits( 3, 60 ); spinner->set_alignment( GLUI_ALIGN_RIGHT ); GLUI_Spinner *scale_spinner = glui->add_spinner_to_panel( obj_panel, "Scale:", GLUI_SPINNER_FLOAT, &scale); scale_spinner->set_float_limits( .2f, 4.0 ); scale_spinner->set_alignment( GLUI_ALIGN_RIGHT ); GLUI_Panel *panel2 = glui->add_panel_to_panel( obj_panel, "", GLUI_PANEL_NONE ); glui->add_checkbox_to_panel( panel2, "Sphere", &show_sphere ); glui->add_column_to_panel( panel2 ); glui->add_checkbox_to_panel( panel2, "Torus", &show_torus ); /*** Start a new column in this panel ***/ glui->add_column_to_panel(panel1, false); /* 'false' means don't draw bar */ /******** Add some controls for lights ********/ GLUI_Panel *light0 = glui->add_panel_to_panel( panel1, "Light 1" ); GLUI_Panel *light1 = glui->add_panel_to_panel( panel1, "Light 2" ); glui->add_checkbox_to_panel( light0, "Enabled", &light0_enabled, LIGHT0_ENABLED_ID, control_cb ); light0_spinner = glui->add_spinner_to_panel( light0, "Intensity:", GLUI_SPINNER_FLOAT, &light0_intensity, LIGHT0_INTENSITY_ID, control_cb ); light0_spinner->set_float_limits( 0.0, 1.0 ); glui->add_checkbox_to_panel( light1, "Enabled", &light1_enabled, LIGHT1_ENABLED_ID, control_cb ); light1_spinner = glui->add_spinner_to_panel( light1, "Intensity:", GLUI_SPINNER_FLOAT, &light1_intensity, LIGHT1_INTENSITY_ID, control_cb ); light1_spinner->set_float_limits( 0.0, 1.0 ); light1_spinner->disable(); /* Disable this light initially */ /****** A 'quit' button *****/ glui->add_button( "Quit", 0,(GLUI_Update_CB)exit ); /**** Link windows to GLUI, and register idle callback ******/ glui->set_main_gfx_window( main_window ); /**** We register the idle callback with GLUI, *not* with GLUT ****/ GLUI_Master.set_glutIdleFunc( myGlutIdle ); /**** Regular GLUT main loop ****/ glutMainLoop(); }
int init(int argc, char **argv) //initialization function { printf("Beginning initialization\n"); vectorUp.x=0; //assign the up vector to (0,1,0) vectorUp.y=1; vectorUp.z=0; cameraDefault.location.x=0; //set up a default camera cameraDefault.location.y=0; cameraDefault.location.z=5; cameraDefault.target.x=0; cameraDefault.target.y=0; cameraDefault.target.z=-1; cameraCurrent = &cameraDefault; //set the default camera as the current camera windowTitle = (char*) &defaultTitle; //set the window title to be the default windowMain.x = 50; //set up initial window shape windowMain.y = 50; windowMain.width = 640; windowMain.height = 480; ratio = 1.0 * windowMain.width / windowMain.height; xRot = 0; yRot = 0; zRot = 0; stateFullScreen = 0; //default is to start in window mode //to start in fullscreen mode do NOT //change this value, instead call //toggleFullScreen() after the window //has been created frame = 0; //set up counters timebase = 0; //GLUT initialization follows, don't worry about it glutInit(&argc, argv); glutInitWindowPosition(windowMain.x, windowMain.y); glutInitWindowSize(windowMain.width, windowMain.height); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); printf("Creating window \"%s\"\n", windowTitle); glutCreateWindow(windowTitle); glutDisplayFunc(draw); glutIdleFunc(draw); glutReshapeFunc(resize); glutKeyboardFunc(normalKey); glutSpecialFunc(specialKey); glutMouseFunc(mouse); glutMotionFunc(mouseActive); glutPassiveMotionFunc(mousePassive); glutEntryFunc(mouseEntry); //initialize timers time = glutGet(GLUT_ELAPSED_TIME); timepassed = 0; //initialize quadratics quadratic = gluNewQuadric(); gluQuadricNormals(quadratic, GLU_SMOOTH); printf("Initialization complete\n"); return 1; }
main(int argc, char *argv[]) { int texcomps; static GLfloat splane[4] = {1.f/200.f, 0.f, 0.f, .5f}; static GLfloat rplane[4] = {0, 1.f/200.f, 0, .5f}; static GLfloat tplane[4] = {0, 0, 1.f/200.f, .5f}; static GLfloat lightpos[4] = {150., 150., 150., 1.f}; glutInit(&argc, argv); glutInitWindowSize(winWidth, winHeight); if(argc > 1) { char *args = argv[1]; GLboolean done = GL_FALSE; while(!done) { switch(*args) { case 's': /* single buffer */ printf("Single Buffered\n"); dblbuf = GL_FALSE; break; case '-': /* do nothing */ break; case 0: done = GL_TRUE; break; } args++; } } if(dblbuf) glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE); else glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH); (void)glutCreateWindow("volume rendering demo"); glutDisplayFunc(redraw); glutReshapeFunc(reshape); glutMouseFunc(mouse); glutMotionFunc(motion); glutKeyboardFunc(key); /* Initialize OpenGL State */ /* draw a perspective scene */ #if 0 glMatrixMode(GL_PROJECTION); /* cube, 300 on a side */ glFrustum(-150., 150., -150., 150., 300., 600.); glMatrixMode(GL_MODELVIEW); /* look at scene from (0, 0, 450) */ gluLookAt(0., 0., 450., 0., 0., 0., 0., 1., 0.); #else glMatrixMode(GL_PROJECTION); /* cube, 300 on a side */ glOrtho(-150., 150., -150., 150., -150., 150.); glMatrixMode(GL_MODELVIEW); #endif glEnable(GL_DEPTH_TEST); #ifdef GL_EXT_texture3D glEnable(GL_TEXTURE_3D_EXT); #endif glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_S, GL_OBJECT_PLANE, splane); glTexGenfv(GL_T, GL_OBJECT_PLANE, tplane); glTexGenfv(GL_R, GL_OBJECT_PLANE, rplane); #ifdef GL_EXT_texture3D /* to avoid boundary problems */ glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_R_EXT, GL_CLAMP); #endif glEnable(GL_CLIP_PLANE0); glEnable(GL_CLIP_PLANE1); glEnable(GL_CLIP_PLANE2); glEnable(GL_CLIP_PLANE3); glEnable(GL_CLIP_PLANE4); glEnable(GL_CLIP_PLANE5); glDisable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, lightpos); tex3ddata = loadtex3d(&texwid, &texht, &texdepth, &texcomps); slices = texht; #ifdef GL_EXT_texture3D glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage3DEXT(GL_TEXTURE_3D_EXT, 0, GL_LUMINANCE_ALPHA, texwid, texht, texdepth, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex3ddata); #endif /* make a display list containing a sphere */ glNewList(SPHERE, GL_COMPILE); { static GLfloat lightpos[] = {150.f, 150.f, 150.f, 1.f}; static GLfloat material[] = {1.f, .5f, 1.f, 1.f}; GLUquadricObj *qobj = gluNewQuadric(); glPushAttrib(GL_LIGHTING_BIT); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, lightpos); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, material); gluSphere(qobj, 20.f, 20, 20); gluDeleteQuadric(qobj); glPopAttrib(); } glEndList(); key('?', 0, 0); /* print usage message */ CHECK_ERROR("end of main"); if(!glutExtensionSupported("GL_EXT_texture3d")) { fprintf(stderr, "volume: requires OpenGL texture 3D extension to operate correctly.\n"); } hasBlendColor = glutExtensionSupported("GL_EXT_blend_color"); if(!hasBlendColor) { fprintf(stderr, "volume: needs OpenGL blend color extension to attenuate.\n"); } glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
int doMain(int argc, char **argv) { // // This might be necessary depending on the // used platform to ensure that the corresponding // libraries get loaded. // OSG::preloadSharedObject("OSGFileIO"); OSG::preloadSharedObject("OSGImageFileIO"); OSG::preloadSharedObject("OSGContribPLY"); OSG::osgInit(argc,argv); // GLUT init glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL | GLUT_DOUBLE); glutCreateWindow("OpenSG"); glutReshapeFunc(reshape); glutDisplayFunc(display); glutIdleFunc(display); glutMouseFunc(mouse); glutMotionFunc(motion); glutKeyboardFunc(keyboard); OSG::PassiveWindowRefPtr pwin=OSG::PassiveWindow::create(); pwin->init(); // create the SimpleSceneManager helper mgr = OSG::SimpleSceneManager::create(); // create the window and initial camera/viewport mgr->setWindow(pwin); // // for storing clipplane beacon we use a container // collection attachment which we attach to the scene // node. Otherwise the scene could not be saved correctly, // as the beacons would be lost. // container = OSG::ContainerCollection::create(); // // Implementation details: // For each clip plane we provide a ClipPlaneChunk, the plane geometry, // the plane transform core and at least a plane color conveniently in // a vector of type VecClipPlaneDetailsT. The next function call // initializes this data structure. // createClipPlaneDetails(); // // The scene // scene = OSG::Node::create(); scene->setCore(OSG::Group::create()); scene->addAttachment(container); // // A place for accessing the box and torus. // vecGeometries.push_back(NULL); vecGeometries.push_back(NULL); // // Build concrete clipping planes and update the clip plane details. // ClipPlaneData data1; ClipPlaneData data2; data1._equation = OSG::Vec4f(0,0,1,0); data1._enabled = true; data2._equation = OSG::Vec4f(1,0,0,0); data2._enabled = false; vecClipPlaneData.push_back(data1); vecClipPlaneData.push_back(data2); updateClipPlanes(vecClipPlaneData); keyboard('3',-1,-1); keyboard('4',-1,-1); // tell the manager what to manage mgr->setRoot(scene); // show the whole scene mgr->showAll(); mgr->redraw(); pwin->dumpExtensions(); return 0; }
int main(int argc, char **argv) { g_error = 0.01f; if ( argc == 2 ) { g_error = atof( argv[1] ); } if ( g_error < 0.001 ) { g_error = 0.001f; } OSG::osgInit(argc,argv); // GLUT init glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); int winid = glutCreateWindow("OpenSG"); glutReshapeFunc(reshape); glutDisplayFunc(display); glutIdleFunc(display); glutMouseFunc(mouse); glutMotionFunc(motion); glutKeyboardFunc(keyboard); { OSG::GLUTWindowRefPtr gwin = OSG::GLUTWindow::create(); gwin->setGlutId(winid); gwin->init(); // create the scene OSG::NodeRefPtr scene; scene = makeScene( ); if ( scene == NULL ) { std::cerr<<"makeScene returned NullFC, exiting..."<<std::endl; return -1; } // create the SimpleSceneManager helper mgr = OSG::SimpleSceneManager::create(); // create the window and initial camera/viewport mgr->setWindow( gwin ); // tell the manager what to manage mgr->setRoot ( scene ); // show the whole scene mgr->showAll(); mgr->redraw(); OSG::SolidBackgroundRefPtr bgr = OSG::SolidBackground::create(); bgr->setColor( OSG::Color3f( 0.7f, 0.7f, 0.7f )); mgr->getWindow()->getPort(0)->setBackground( bgr ); } // GLUT main loop glutMainLoop(); return 0; }
int main(int argc, string argv[]) { glutInit(&argc, argv); initparam(argv, defv); instr = stropen(getparam("in"), "r"); refscale = getdparam("refscale"); if (! strnull(getparam("colordata"))) { /* color data wanted? */ if (getbparam("dopcolor")) error("%s: colordata precludes dopcolor\n", getargv0()); if (! scanopt(PhiTag "," SmoothTag "," RhoTag "," EntFuncTag "," UinternTag "," UdotIntTag "," UdotRadTag "," UdotVisTag "," TauTag "," BirthTag "," DeathTag "," AuxTag, getparam("colordata"))) error("%s: %s unknown\n", getargv0(), getparam("colordata")); bodytags[1] = getparam("colordata"); /* replace key w/ field... */ butbind[2] = COLORMAP; } else if (getbparam("dopcolor")) { dopcolor = TRUE; bodytags[1] = VelTag; /* replace key w/ velocity */ butbind[2] = COLORMAP; } if (! strnull(getparam("vectordata"))) { if (! scanopt(VelTag "," AccTag "," AuxVecTag, getparam("vectordata"))) error("%s: %s unknown\n", getargv0(), getparam("vectordata")); if (! (streq(getparam("vectordata"), VelTag) && dopcolor)) bodytags[2] = getparam("vectordata"); butbind[2] = VSCALE; } maxfast = getiparam("maxfast"); if (sscanf(getparam("defcolors"), "%x,%x", &pcolor, &bcolor) != 2) error("%s: can't scan defcolor parameter\n", getargv0()); if (sscanf(getparam("viewsize"), "%ix%i", &wscreen, &hscreen) != 2) error("%s: can't scan viewsize parameter\n", getargv0()); layout_body(bodytags, Precision, NDIM); if (! strnull(getparam("colordata"))) { scalaroff = streq(bodytags[1], PhiTag) ? PhiField.offset : streq(bodytags[1], SmoothTag) ? SmoothField.offset : streq(bodytags[1], RhoTag) ? RhoField.offset : streq(bodytags[1], EntFuncTag) ? EntFuncField.offset : streq(bodytags[1], UinternTag) ? UinternField.offset : streq(bodytags[1], UdotIntTag) ? UdotIntField.offset : streq(bodytags[1], UdotRadTag) ? UdotRadField.offset : streq(bodytags[1], UdotVisTag) ? UdotVisField.offset : streq(bodytags[1], TauTag) ? TauField.offset : streq(bodytags[1], BirthTag) ? BirthField.offset : streq(bodytags[1], DeathTag) ? DeathField.offset : streq(bodytags[1], AuxTag) ? AuxField.offset : -1; assert(scalaroff != -1); } if (! strnull(getparam("vectordata"))) { vectoroff = streq(getparam("vectordata"), VelTag) ? VelField.offset : streq(getparam("vectordata"), AccTag) ? AccField.offset : streq(getparam("vectordata"), AuxVecTag) ? AuxVecField.offset : -1; assert(vectoroff != -1); } if (! getdata()) error("%s: no data in input file\n", getargv0()); initgraphics(argv[0]); glutMainLoop(); return (0); }
// The main program. int main(int argc, char **argv) { const int winWidth = 1024; // The nominal window width. const int winHeight = 1024; // The nominal window height. // Initialize the GLUT library. // The function glutInit must be called before any other use of the // GLUT library is made. glutInit(&argc, argv); // Specify the type of display mode to be used for new windows. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); // Set the nominal size for new windows. // Note that this value does not have to be respected. glutInitWindowSize(winWidth, winHeight); // Create a new window with the same name as the command name. // On many systems, the window name customarily appears in the // title bar window decoration added by the window manager. glutCreateWindow(argv[0]); // Register a display callback function. glutDisplayFunc(display); // Register a reshape callback function. glutReshapeFunc(reshape); // Register a keyboard callback function. glutKeyboardFunc(keyboard); // Set the clear color. glClearColor(0.0, 0.0, 0.0, 0.0); //new........................................ // Set the color of diffuse light for light 0. glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); // Enable light 0. glEnable(GL_LIGHT0); // Enable lighting calculations. glEnable(GL_LIGHTING); // Have front material parameters track the current color. glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); //</new........................................ // Enable hidden object removal. glEnable(GL_DEPTH_TEST); // Do not render faces that are not visible. // For example, the back side of faces will not be rendered. glEnable(GL_CULL_FACE); // Interpolate color/normal values across faces. glShadeModel(GL_SMOOTH); // Specify the orientation of front-facing faces. glFrontFace(GL_CCW); // Register a timer callback function. glutTimerFunc(framePeriod, timer, 0); // Enter the GLUT event processing loop. // Note: The function glutMainLoop never returns. glutMainLoop(); // This line is never reached. return 0; }
int main(int argc, char* argv[]) { printf ("\n"); printf (" ===================================\n"); printf (" CHAI 3D\n"); printf (" Dynamic Meshes Demo\n"); printf (" Copyright 2006\n"); printf (" ===================================\n"); printf ("\n"); printf ("Press the spacebar to drop additional bunnies from the sky"); printf ("\n"); // create a new world world = new cWorld(); // set background color world->setBackgroundColor(0.2f,0.2f,0.2f); // create a camera camera = new cCamera(world); world->addChild(camera); ode_world = dWorldCreate(); space = dSimpleSpaceCreate(0); contactgroup = dJointGroupCreate (0); dWorldSetGravity (ode_world,0,0,-0.5); dWorldSetCFM (ode_world,1e-5); dCreatePlane (space,0,0,1,0); memset (obj,0,sizeof(obj)); ode_collision_callback = nearCallback; ode_collision_callback_data = 0; // position a camera camera->set( cVector3d(6.0,0,3.0), cVector3d (0.0, 0.0, 0.0), cVector3d (0.0, 0.0, 1.0)); // Create a light source and attach it to the camera light = new cLight(world); light->setEnabled(true); light->setPos(cVector3d(2,0.5,1)); light->setDir(cVector3d(-2,0.5,1)); camera->addChild(light); // create a cursor and add it to the world. cursor = new cMeta3dofPointer(world, 0); world->addChild(cursor); cursor->setPos(0.0, 0.0, 0.0); // set up a nice-looking workspace for the cursor so it fits nicely with our // cube models we will be building cursor->setWorkspace(4.0,4.0,4.0); // set the diameter of the ball representing the cursor cursor->setRadius(0.05); // Replace the proxy with our custom ODE proxy default_proxy = (cProxyPointForceAlgo*)(cursor->m_pointForceAlgos[0]); cursor->m_pointForceAlgos.clear(); // set up the device cursor->initialize(); // open communication to the device cursor->start(); // start haptic timer callback timer.set(0, hapticsLoop, NULL); // drop a mesh from the sky Sleep(1000); create_mesh_flag = 1; // initialize the GLUT windows glutInit(&argc, argv); glutInitWindowSize(512, 512); glutInitWindowPosition(0, 0); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow(argv[0]); glutDisplayFunc(draw); glutKeyboardFunc(key); glutReshapeFunc(resizeWindow); glutSetWindowTitle("CHAI 3D"); // create a mouse menu glutCreateMenu(setOther); glutAddMenuEntry("Full Screen", OPTION_FULLSCREEN); glutAddMenuEntry("Window Display", OPTION_WINDOWDISPLAY); glutAttachMenu(GLUT_RIGHT_BUTTON); // update display glutTimerFunc(30, updateDisplay, 0); // start main graphic rendering loop glutMainLoop(); return 0; }
int main(int argc, char **argv) { static_assert(std::is_pod<FVector3>::value, "FVector must be a POD!"); static_assert(std::is_pod<Oscillator>::value, "Oscillator must be a POD!"); // initialize GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); glutCreateWindow("Fountain"); // textures std::unique_ptr<Texture> pebbleTexture(new Texture); std::unique_ptr<Texture> basinTexture(new Texture); std::unique_ptr<Texture> groundTexture(new Texture); std::unique_ptr<Texture[]> skyTextures(new Texture[SKY_BOX_FACES]); pebbleTexture->load("resource/pebbles.bmp"); basinTexture->load("resource/wall.bmp"); groundTexture->load("resource/grass.bmp"); skyTextures[SKY_FRONT].load("resource/skybox/front.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_RIGHT].load("resource/skybox/right.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_LEFT].load("resource/skybox/left.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_BACK].load("resource/skybox/back.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_UP].load("resource/skybox/up.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_DOWN].load("resource/skybox/down.bmp", GL_CLAMP_TO_EDGE); // initialize the scene skybox.initialize(-SKY_BOX_SIZE, SKY_BOX_SIZE, -SKY_BOX_SIZE, SKY_BOX_SIZE, -SKY_BOX_SIZE, SKY_BOX_SIZE, std::move(skyTextures)); pool.initialize(OSCILLATORS_NUM_X, OSCILLATORS_NUM_Z, POOL_HEIGHT, OSCILLATOR_DISTANCE, OSCILLATOR_WEIGHT, OSCILLATOR_DAMPING, OSCILLATOR_SPLASH, POOL_TEX_REPEAT_X, POOL_TEX_REPEAT_Z, std::move(pebbleTexture)); fountain.initialize(initializers[0]); basin.initialize(BASIN_BORDER_HEIGHT + POOL_HEIGHT, BASIN_BORDER_WIDTH, BASIN_INNER_X, BASIN_INNER_Z, std::move(basinTexture)); ground.initialize(-GROUND_SIZE, GROUND_SIZE, -GROUND_SIZE, GROUND_SIZE, std::move(groundTexture), GROUND_TEX_REPEAT); // place the fountain in the center of the pool fountain.center.set(BASIN_INNER_X / 2.0f, POOL_HEIGHT, BASIN_INNER_Z / 2.0f); // initialize camera: FVector3 cposition, crotation; cposition.set(CAMERA_POSITION[0], CAMERA_POSITION[1], CAMERA_POSITION[2]); camera.move(cposition); crotation.set(CAMERA_ROTATION[0], CAMERA_ROTATION[1], CAMERA_ROTATION[2]); camera.rotate(crotation); // enable vertex array glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); // solid rendering glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_DEPTH_TEST); // lighting glLightfv(GL_LIGHT1, GL_AMBIENT, LIGHT_AMBIENT_1); glLightfv(GL_LIGHT1, GL_DIFFUSE, LIGHT_DIFFUSE_1); glLightfv(GL_LIGHT1, GL_POSITION, LIGHT_POSITION_1); glEnable(GL_LIGHT1); glLightfv(GL_LIGHT2, GL_AMBIENT, LIGHT_AMBIENT_2); glLightfv(GL_LIGHT2, GL_DIFFUSE, LIGHT_DIFFUSE_2); glLightfv(GL_LIGHT2, GL_POSITION, LIGHT_POSITION_2); glEnable(GL_LIGHT2); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); // settings glClearColor(0.0, 0.0, 0.0, 0.0); glFrontFace(GL_CCW); // orientation should be the front face glShadeModel(GL_SMOOTH); // blending glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // seed srand((unsigned)time(NULL)); printf("1 - 8:\tChange the shape of the fountain\n"); printf("f:\tToggle fullscreen\n"); printf("c:\tSwitch between mouse mode / keyboard mode\n"); printf("----------- Keyboard Mode -----------------\n"); printf("up, down:\tMove camera forward / backword\n"); printf("left, right:\tTurn camera right / left\n"); printf("r, v:\tTurn camera up / down\n"); printf("w, s:\tMove camera up / down\n"); printf("a, d:\tMove camera left / right\n"); printf("----------- Mouse Mode -----------------\n"); printf("Mouse move:\tRotate camera\n"); printf("Mouse scroll:\tMove forward / backward\n"); printf("ESC:\tExit\n"); // register callbacks glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyDown); glutPassiveMotionFunc(mouseMove); glutSpecialFunc(spKeyDown); glutMouseFunc(mouseButton); glutIdleFunc(idle); // hide cursor glutSetCursor(GLUT_CURSOR_NONE); // start glutMainLoop(); return 0; }
int main(int argc, char **argv) { int minify_menu, rate_menu; glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("mjkwarp"); #ifdef GL_EXT_texture_filter_anisotropic hasTextureFilterAnisotropic = glutExtensionSupported("GL_EXT_texture_filter_anisotropic"); #endif #ifdef GL_EXT_texture_lod_bias { GLfloat maxLodBias; hasTextureLodBias = glutExtensionSupported("GL_EXT_texture_lod_bias"); glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &maxLodBias); printf("max texture lod bias = %f\n", maxLodBias); } #endif glutDisplayFunc(redraw); glutKeyboardFunc(keyboard); glMatrixMode(GL_PROJECTION); gluPerspective( /* field of view in degree */ 40.0, /* aspect ratio */ 1.0, /* Z near */ 1.0, /* Z far */ 70.0); glMatrixMode(GL_MODELVIEW); gluLookAt(0.0, 0.0, 5.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 positive Y direction */ depth = mjk_depth; width = mjk_width; height = mjk_height; bits = mjk_image; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, depth, width, height, GL_RGB, GL_UNSIGNED_BYTE, bits); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glEnable(GL_TEXTURE_2D); glutVisibilityFunc(visibility); minify_menu = glutCreateMenu(minify_select); glutAddMenuEntry("Nearest", GL_NEAREST); glutAddMenuEntry("Linear", GL_LINEAR); glutAddMenuEntry("Nearest mipmap nearest", GL_NEAREST_MIPMAP_NEAREST); glutAddMenuEntry("Linear mipmap nearest", GL_LINEAR_MIPMAP_NEAREST); glutAddMenuEntry("Nearest mipmap linear", GL_NEAREST_MIPMAP_LINEAR); glutAddMenuEntry("Linear mipmap linear", GL_LINEAR_MIPMAP_LINEAR); rate_menu = glutCreateMenu(rate_select); glutAddMenuEntry(" 2/sec", 500); glutAddMenuEntry(" 6/sec", 166); glutAddMenuEntry("10/sec", 100); glutAddMenuEntry("20/sec", 50); glutAddMenuEntry("30/sec", 33); glutAddMenuEntry("60/sec", 16); glutCreateMenu(menu_select); #ifdef GL_EXT_texture_filter_anisotropic if (hasTextureFilterAnisotropic) { glutAddMenuEntry("Toggle anisotropic filtering", 4); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } #endif #ifdef GL_EXT_texture_lod_bias if (hasTextureLodBias) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } #endif glutAddMenuEntry("Toggle spinning", 1); glutAddMenuEntry("Toggle scaling", 2); glutAddMenuEntry("Switch mode", 3); glutAddSubMenu("Minimum frame rate", rate_menu); glutAddSubMenu("Minify modes", minify_menu); glutAddMenuEntry("Quit", 666); glutAttachMenu(GLUT_RIGHT_BUTTON); menu_select(3); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
int main(int argc, char** argv) { std::cout << "Initial number of atoms: " << numberOfAtoms << std::endl; std::cout << "Initial steps per frame: " << numberOfSteps << std::endl; srand(time(NULL)); generateAtoms(atomTable, numberOfAtoms, diameter, atomMass); glutInit(&argc, argv); // Initialize GLUT glutInitWindowSize(width, height); // Set the window's initial width & height glutCreateWindow("Klaster atomowy"); // Create a window with the given title float mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; float mat_shininess[] = { 90.0 }; float light_position[] = { 1., 1., 1., 0.0 }; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glutDisplayFunc(display); // Register display callback handler for window re-paint glutReshapeFunc(reshape); glutTimerFunc(1, update, 0); glutMouseFunc(handleMouseButton); // process mouse button push/release int atomMenu = glutCreateMenu(processMenuEvents); glutAddMenuEntry("2", 20); glutAddMenuEntry("5", 21); glutAddMenuEntry("10", 22); glutAddMenuEntry("15", 23); glutAddMenuEntry("20", 24); glutAddMenuEntry("50", 25); glutAddMenuEntry("100", 26); int stepMenu = glutCreateMenu(processMenuEvents); glutAddMenuEntry("1", 30); glutAddMenuEntry("5", 31); glutAddMenuEntry("10", 32); glutAddMenuEntry("30", 33); glutAddMenuEntry("50", 34); glutAddMenuEntry("100", 35); glutAddMenuEntry("1000", 36); int readMenu = glutCreateMenu(processMenuEvents); glutAddMenuEntry("Random", 40); glutAddMenuEntry("5", 41); glutAddMenuEntry("10", 42); glutAddMenuEntry("15", 43); glutAddMenuEntry("20", 44); glutAddMenuEntry("2D", 45); glutCreateMenu(processMenuEvents); glutAddMenuEntry("Pause (Space Bar)", 0); glutAddMenuEntry("Monte Carlo (Enter)", 1); glutAddMenuEntry("System evolution over time", 2); glutAddMenuEntry("Reset", 3); glutAddMenuEntry("Save to file", 4); glutAddMenuEntry("Enable/disable axes", 5); glutAddMenuEntry("Enable/disable rotate", 6); //glutAddMenuEntry("Read", 7); glutAddSubMenu("Read from file", readMenu); glutAddSubMenu("Number of atoms", atomMenu); glutAddSubMenu("Number of steps per frame", stepMenu); glutAttachMenu(GLUT_RIGHT_BUTTON); //pliku.open("Energy.txt"); /* pliku2.open("1500.txt"); double tempu = 1500; for(int i=1; i <=20000;i++){ pliku2 << i << " " << tempu << std::endl; tempu = tempu * exp(-0.0002); } pliku2.close(); */ glutMainLoop(); // Enter the infinitely event-processing loop //pliku.close(); }
############################################################################################################################ */ int main (int argc, char **argv) { /* **************************************************************************************************************************** */ /* Pointeurs vers l'application */ glutInit(&argc, argv); /* Activation des buffers : Double buffer RGBA color Depth buffer */ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); /* Création de la fenêtre */ glutInitWindowSize(1024, 768); /* Positionnement de la fenêtre */ glutInitWindowPosition(100, 100); /* Ouverture de la fenêtre */ glutCreateWindow("TD_Animation_3D"); /* Spécification de la fontion de dessin */ glutDisplayFunc(display); /* Spécification de la fontion de redimensionnement */ glutReshapeFunc(reshape); /* Spécification des fontions de gestion du clavier */ glutKeyboardFunc(keyboardDown); glutKeyboardUpFunc(keyboardUp); glutSpecialFunc(keyboardSpecDown); glutSpecialUpFunc(keyboardSpecUp); /* Spécification des fontions de gestion de la souris */ glutMouseFunc(mouse); glutMotionFunc(motion); /* Spécification de la fonction de mise-à-jour */ glutIdleFunc(timeTick); /* **************************************************************************************************************************** */ /* Affichage des fonctions clavier */ HelpMessage(); /* **************************************************************************************************************************** */ /* Intitialisation des paramètres de l'affichage et de la fenêtre */ GLInit(); /* Intitialisation des paramètres du squelette */ SkeletInit(); /* Intitialisation de la scène cinématique */ IKInit(); /* **************************************************************************************************************************** */ /* Lancement de la boucle OpenGL */ glutMainLoop(); /* **************************************************************************************************************************** */ return 0;