int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowPosition(100, 100); glutInitWindowSize(winWidth, winHeight); glutCreateWindow("FPS Test"); init(); glutDisplayFunc(displayFcn); glutReshapeFunc(winReshapeFcn); // Input glutKeyboardFunc(pressNormalKey); glutKeyboardUpFunc(releaseNormalKey); glutSpecialFunc(pressSpecialKey); glutSpecialUpFunc(releaseSpecialKey); glutMotionFunc(mouseMove); glutMouseFunc(mouseButton); glutIdleFunc(animate); glutMainLoop(); return 0; }
int main(int argc, char **argv) { // Window Setup / Init glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(game.getScreenWidth(), game.getScreenHeight()); glutCreateWindow("GLUT F2D TEST"); // Game loop callback glutDisplayFunc(display); glutIdleFunc(loop); // Input callbacks glutKeyboardFunc(addKeyDown); glutKeyboardUpFunc(addKeyUp); glutSpecialFunc(addSpecialDown); glutSpecialUpFunc(addSpecialUp); glutMouseFunc(addMouseEvent); glutPassiveMotionFunc(passiveMousePos); glutReshapeFunc (reshape); init(); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
void glInit (int * pargc, char ** argv) { glutInit(pargc, argv); //window1 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(GL_WIN_SIZE_X, GL_WIN_SIZE_Y); int mainHandle = glutCreateWindow("PKgame"); glutSetWindow(mainHandle); glutKeyboardFunc(glutKeyboard); glutDisplayFunc(glutDisplay); glutReshapeFunc(ReshapeCallback); glutIdleFunc(glutIdle); glutSpecialFunc(ArrowKeyCallback); glutMouseFunc(MouseCallback); glutMotionFunc(MotionCallback); MotionCallback(0,0); // デフォルトの描画パラメータ glClearColor(0.3f, 0.4f, 0.5f, 1.0); glEnable(GL_COLOR_MATERIAL); // 光源の設定 float ambientColor[] = { 0.0f, 0.1f, 0.2f, 0.0f }; float diffuseColor[] = { 1.0f, 1.0f, 1.0f, 0.0f }; float specularColor[] = { 0.0f, 0.0f, 0.0f, 0.0f }; float position[] = { 100.0f, 100.0f, -400.0f, 1.0f }; glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColor); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseColor); glLightfv(GL_LIGHT0, GL_SPECULAR, specularColor); glLightfv(GL_LIGHT0, GL_POSITION, position); glEnable(GL_LIGHT0); glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); glutInitWindowSize(800, 600); glutCreateWindow("Model"); glutReshapeFunc(ChangeSize); glutSpecialFunc(SpecialKeys); glutKeyboardFunc( Keys ); glutDisplayFunc(RenderScene); GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); return 1; } SetupRC(); glutMainLoop(); return 0; }
int main(int argc, char ** argv) { glutInit( &argc, argv ); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_STENCIL ); glutInitWindowSize( 640, 640 ); glutInitWindowPosition( 0, 0 ); glutCreateWindow("Forward and Inverse Kinematics"); glutDisplayFunc( display ); glutReshapeFunc( reshape ); glutMouseFunc( mouse ); glutMotionFunc( motion ); glutKeyboardFunc( keyboard ); #ifdef TEST_IK glutSpecialFunc( skeyboard ); #endif glutIdleFunc( idle ); initEnvironment(); glutMainLoop(); return 0; }
int main(int argc, char ** argv) { // srand(int(time(0))); // set ball_trajectory, ball position, and paddle // position based on command line arguments paddle_y_pos = INITIAL_PADDLE_Y_POS ;//240 ball_x_pos = INITIAL_BALL_X_POS ; //100 ball_y_pos = INITIAL_BALL_Y_POS; //240 ball_x1_pos = INITIAL_BALL_X_POS ; //100 ball_y1_pos = INITIAL_BALL_Y_POS; //240 ball_trajectory = INITIAL_BALL_ANGLE ;//45 /* Initialize GLUT */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(INITIAL_WIDTH, INITIAL_HEIGHT);//640 x 480 glutInitWindowPosition(INITIAL_X_POS, INITIAL_Y_POS); glutCreateWindow(WINDOW_NAME); /* Register callback functions */ glutDisplayFunc(draw_scene); glutReshapeFunc(resize_scene); //Initialize the viewport when the window size changes. glutKeyboardFunc(key_press); //handle when the key is pressed glutMouseFunc(handle_mouse_click); //check the Mouse Button(Left, Right and Center) status(Up or Down) glutMotionFunc(handle_mouse_motion); //Check the Current mouse position when mouse moves glutSpecialFunc(special_key); //Special Keyboard Key fuction(For Arrow button and F1 to F10 button) /* Initialize GL */ glPointSize(BALL_SIZE); //BALL_SIZE = 15 /* Enter event processing loop */ glutMainLoop(); return 0; }
void App::Run(int argc, char **argv) { // Inicialização HW e App glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE /* doubleBuffering */| GLUT_RGBA /* RGBA ColorBuffer */ | GLUT_DEPTH /* ZBuffer */); // Inicialização da Janela glutInitWindowSize(this->width, this->height); glutInitWindowPosition(this->windowX, this->windowY); glutCreateWindow(this->name.c_str()); // Registo das Callback glutDisplayFunc (App::DisplayCallback); glutReshapeFunc (App::ReshapeCallback); glutKeyboardFunc (App::KeyDownCallback); glutKeyboardUpFunc(App::KeyUpCallback); glutSpecialFunc (App::SpecialKeyDownCallback); glutSpecialUpFunc (App::SpecialKeyUpCallback); // Criação/iniciação da aplicação this->CreateScene(); // InitScene this->InitGL(); glClearColor(0.1, 0.1, 0.1, 0.0); glEnable(GL_DEPTH_TEST); glutTimerFunc(this->timerMilisDelta, App::UpdateCallback, timeGetTime()); // Lançamento do GLUT Event Loop // NOTA: A aplicação fica bloqueada aqui // A partir deste ponto são chamadas as funções de update, reshape e draw glutMainLoop(); this->ClearObjects(); }
int main( int argc, char* argv[] ){ // Init. GLUT glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowSize( 500, 500); glutCreateWindow( "Two Shaders" ); // Init. GLEW glewExperimental = true; if( glewInit( ) != GLEW_OK ){ fprintf(stderr, "GLEW init failed.\n"); exit(1); } // Set OpenGL State glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LESS ); // Application specific initialization init( ); // Register callbacks with GLUT glutKeyboardFunc( keyboardCallback ); glutSpecialFunc( specialCallback ); glutDisplayFunc( displayCallback ); glutReshapeFunc( reshapeCallback ); glutTimerFunc( 16, updateCallback, 0 ); msglVersion( ); puts("Press 'h' to see a help message at any time."); glutMainLoop( ); return(0); }
int main(int argc,char **argv){ glutInitWindowPosition(0,0); glutInitWindowSize(WIDTH,HEIGHT); glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE); if(!glutCreateWindow("Laboratório 1 - Instituto de Computação - UFAL")) { fprintf(stderr,"Error opening a window.\n"); exit(-1); } init(); glutKeyboardFunc(keyboard); glutSpecialFunc(special); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return(0); }
DrawingWindow::DrawingWindow(int argc, char** argv,int width, int height, int startX, int startY, string name) { //init glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH); glutInitWindowSize(width,height); glutInitWindowPosition(startX,startY); glutCreateWindow(name.c_str()); //Sunt definite functiile care vor fi apelate direct de sistemul Windows: glutDisplayFunc(displayFunction); //functia apelata pentru afisarea continutului ferestrei aplicatiei glutReshapeFunc(reshapeFunction); //functia apelata pentru refacerea continutului ferestrei dupa o redimensionare sau dupa ce fereastra a fost (partial) acoperita //glutIdleFunc(idleFunction); //functia apelata atunci cand sistemul nu are de tratat alte evenimente glutTimerFunc(0, timerFunction, 0); glutKeyboardFunc(keyboardFunction); //functia apelata la apasarea unei taste glutSpecialFunc(specialFunction); //functia apelata la apasarea unei taste speciale glutMouseFunc(mouseFunction); //functia apelata la click de mouse glClearColor(1,1,1,1); //afiseaza fondul ferestrei aplicatiei in alb //activeaza testul de adancime pentru eliminarea partilor nevizibile in imagini glEnable(GL_DEPTH_TEST); }
int main( int argc, char **argv) { ISoundEngine* engine = createIrrKlangDevice(); if (!engine) return 0; // error starting up the engine engine->play2D("./musica/pedro.mp3", true); glutInit(&argc,argv); if(init(WIN_POSX,WIN_POSY,WIN_WIDTH,WIN_HEIGHT,"ARM Pedro Infante") == -1){ system("pause"); return -1; } glutDisplayFunc(render); glutIdleFunc(idle); glutReshapeFunc(redimensiona); glutSpecialFunc(keyboardSpec); glutKeyboardFunc(keyboard); glutMouseFunc(mouseClick); glutMotionFunc(mouseDrag); defineLuces(); defineCamaras(); creaEscena(); glutMainLoop(); return 0; }
int main(int argc,char **argv) { initialize(); // Initialize the GLUT library. glutInit(&argc,argv); // Set the initial window size and position. int width=glutGet(GLUT_SCREEN_WIDTH)>>1; int height=glutGet(GLUT_SCREEN_HEIGHT)>>1; glutInitWindowSize(width,height); glutInitWindowPosition(width>>1,height>>1); // Set the initial display mode. glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH); // Create a top-level window. glutCreateWindow(wnd_title); // Register window callbacks. glutDisplayFunc(display); glutIdleFunc(idle); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutSpecialFunc(special); // Initialize OpenGL states and any necessary data. glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // Enter the GLUT main event processing loop. glutMainLoop(); return 0; }
// Main int main(int argc,char* argv[]) { // Initialize GLUT and process user parameters glutInit(&argc,argv); // Request double buffered, true color window glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutInitWindowPosition(50, 50); // Request 500 x 500 pixel window glutInitWindowSize(500,500); // Create the window glutCreateWindow("Lorenz Attractor"); // Tell GLUT to call "display" when the scene should be drawn glutDisplayFunc(display); // Tell GLUT to call "reshape" when the window is resized glutReshapeFunc(reshape); // Tell GLUT to call "special" when an arrow key is pressed glutSpecialFunc(special); // Tell GLUT to call "key" when a key is pressed glutKeyboardFunc(key); // Tell GLUT to call "key" when a key is pressed glutMainLoop(); // Return code return 0; }
int main(int argc, char **argv) { #ifdef GLUT /* start of glut windowing and control functions */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(800, 600); glutCreateWindow("glutmech: Vulcan Gunner"); myinit(); glutDisplayFunc(display); glutReshapeFunc(myReshape); #ifdef GLUT_KEY glutKeyboardFunc(keyboard); #endif #ifdef GLUT_SPEC glutSpecialFunc(special); #endif glutMenu(); glutMainLoop(); /* end of glut windowing and control functions */ #endif return 0; /* ANSI C requires main to return int. */ }
void GlutFramework::startFramework(int argc, char *argv[]) { setInstance(); // Sets the instance to self, used in the callback wrapper functions // Initialize GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowPosition(WINDOW_X_POSITION, WINDOW_Y_POSITION); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); glutCreateWindow(title.c_str()); // Function callbacks with wrapper functions glutReshapeFunc(reshapeWrapper); glutMouseFunc(mouseButtonPressWrapper); glutMotionFunc(mouseMoveWrapper); glutDisplayFunc(displayWrapper); glutKeyboardFunc(keyboardDownWrapper); glutKeyboardUpFunc(keyboardUpWrapper); glutSpecialFunc(specialKeyboardDownWrapper); glutSpecialUpFunc(specialKeyboardUpWrapper); init(); // Initialize glutIdleFunc(runWrapper); // The program run loop glutMainLoop(); // Start the main GLUT thread }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(800, 600); glutCreateWindow("Tron Clone Client"); init(); glutIgnoreKeyRepeat(1); glutSpecialFunc(pressKey); glutSpecialUpFunc(releaseKey); glutDisplayFunc(display); glutReshapeFunc(reshape); glutIdleFunc(idle); glutKeyboardFunc(processNormalKeys); glutKeyboardUpFunc(releaseNormalKeys); glutMainLoop(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { GLenum type; glutInit(&argc, argv); if (Args(argc, argv) == GL_FALSE) { exit(1); } if (imageFileName == 0) { printf("No image file.\n"); exit(1); } glutInitWindowPosition(0, 0); glutInitWindowSize( W, H); type = GLUT_RGB | GLUT_DEPTH; type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); if (glutCreateWindow("Texture Test") == GL_FALSE) { exit(1); } Init(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(Key2); glutDisplayFunc(Draw); glutIdleFunc(Idle); glutMainLoop(); return 0; }
int main(int argc, char **argv) { glutInit(&argc, argv); //z bufor | bufor | kolory glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(200, 200); glutInitWindowSize(320, 320); glutCreateWindow("Sprê¿yna"); //register callbacks glutDisplayFunc(renderScene); glutReshapeFunc(changeSize); //tryb bezczynnoœci glutIdleFunc(renderScene); //po naciœniêciu klawisza glutKeyboardFunc(processNormalKeys); glutSpecialFunc(processSpecialKeys); //obs³uga myszy glutMouseFunc(mouseButton); glutMotionFunc(mouseMove); //OpenGL init initRendering(); //start glutMainLoop(); return 1; }
int main (int argc, char** argv){ bola.x = (LARGURA)/2; bola.y = HBARRA + RBOLA + 0.1; bola.vx = VBOLAX; bola.vy = VBOLAY; //allocate bricks bloco = (brick *)malloc(NBLOCOS*sizeof(brick)); //fillMatrix(bloco); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(LARGURA, ALTURA); glutCreateWindow("BrickGame"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutIdleFunc(idle); glutSpecialFunc(keyboard); glutSpecialUpFunc(keyboardup); fillMatrix(bloco); glutMainLoop(); }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(height, width); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); init(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMotionFunc(MotionCallback); glutMouseFunc(mouse); glutKeyboardFunc(keyboard); glutSpecialFunc(processSpecialKeys); glutCreateMenu(mainMenu); glutAddMenuEntry("UP ARROW: Zoom In", 1); glutAddMenuEntry("DOWN ARROW: Zoom Out", 2); glutAddMenuEntry("RIGHT ARROW: Move To The Right", 3); glutAddMenuEntry("LEFT ARROW: Move To The Left", 4); glutAddMenuEntry("Esc: Exit", 27); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); return 0; }
GlutWindow::GlutWindow(unsigned int const width, unsigned int const height, char const * title) { this->width = width; this->height = height; initGlut(); /* * Set up a basic window. This is not very generic, but * exactly what is needed to render a raster image transferred via * OpenCL. */ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowSize(width, height); glutInitWindowPosition(glutGet(GLUT_SCREEN_WIDTH) / 2 - width / 2, glutGet( GLUT_SCREEN_HEIGHT) / 2 - height / 2); glutWindowID = glutCreateWindow(title); glutWindows[glutWindowID] = this; glutDisplayFunc(glutWindowDisplay); glutReshapeFunc(glutWindowReshape); glutKeyboardFunc(glutKeypress); glutSpecialFunc(glutSpecialKeypress); glutMouseFunc(glutMouse); }
int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(Window_Width, Window_Height); Window_ID = glutCreateWindow(PROGRAM_TITLE); glutInitWindowPosition(0,0); glutDisplayFunc(&display); glutIdleFunc(&display); glutSpecialFunc(&keyPressControl); glutKeyboardFunc(&pressKey); glutReshapeFunc(&resize); glutMouseFunc(&mouse); init(Window_Width, Window_Height); initMap(); init(Window_Width,Window_Height); glutMainLoop(); return 1; }
/* main function - program entry point */ int main(int argc, char** argv) { glutInit(&argc, argv); //starts up GLUT glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(600, 600); glutInitWindowPosition(50, 50); glutCreateWindow("SimpleSceneGraph"); //creates the window glEnable(GL_DEPTH_TEST); glutDisplayFunc(display); //registers "display" as the display callback function glutKeyboardFunc(keyboard); glutSpecialFunc(special); glutMouseFunc(mouse); init(); glutMainLoop(); //starts the event loop return(0); //return may not be necessary on all compilers }
/** * Main entry point for GLUT based programs */ int main(int argc, char* argv[]) { gltSetWorkingDirectory(argv[0]); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); glutInitWindowSize(800, 600); glutCreateWindow("Triangle"); gltShowVersionInfo(); // Create the menu glutCreateMenu(ProcessMenu); glutAddMenuEntry("Btn1",1); glutAddMenuEntry("Btn2",2); glutAttachMenu(GLUT_RIGHT_BUTTON); glutReshapeFunc(ChangeSize); glutDisplayFunc(RenderScene); glutSpecialFunc(SpecialKeys); glutKeyboardFunc(KeyPressFunc); GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); return 1; } SetupRC(); glutMainLoop(); OnExit(); return 0; }
GlutViewer:: GlutViewer(const char* _title, int _width, int _height) : m_width(_width), m_height(_height) { #if 1 if (!curve::a.is_glut_initiated) { curve::a.is_glut_initiated = true; int c = 0; char ** v = NULL; glutInit(&c, v); } #endif // create window glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE | GLUT_ALPHA); glutInitWindowSize(_width, _height); windowID_ = glutCreateWindow(_title); windows__[windowID_] = this; // register callbacks glutDisplayFunc(display__); glutKeyboardFunc(keyboard__); glutSpecialFunc(special__); glutMouseFunc(mouse__); glutMotionFunc(motion__); glutPassiveMotionFunc(passivemotion__); glutReshapeFunc(reshape__); glutVisibilityFunc(visibility__); // create menu n_draw_modes_ = 0; menuID_ = glutCreateMenu(processmenu__); glutAttachMenu(GLUT_RIGHT_BUTTON); }
void initGL(int argc, char** argv){ // Inicialização do GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA); glutGameModeString(OGLWindow_getGameModeString()); if(glutGameModeGet(GLUT_GAME_MODE_POSSIBLE)) { OGLWindow_initGameMode(); } else // Cria Janela Normal { OGLWindow_initWindowMode(); } // Registar funções de callback glutDisplayFunc(display); glutReshapeFunc(reshape); glutIdleFunc(display); glutIgnoreKeyRepeat(1); glutKeyboardFunc(pressNormalKeys); glutKeyboardUpFunc(releaseNormalKeys); glutSpecialFunc(pressSpecialKey); glutSpecialUpFunc(releaseSpecialKey); glutMotionFunc(mouseMove); glutMouseFunc(mouseClick); // - Directly redirect GLUT mouse button events to AntTweakBar //glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT); // - Directly redirect GLUT mouse "passive" motion events to AntTweakBar (same as MouseMotion) glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT); }
int main(int artcp, char **argv) { std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> dis(1, 1000); for (int n = 0; n < 1000; ++n) { randeros[n] = dis(gen); std::cout << randeros[n] << ' '; } glutInit(&artcp, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(640, 640); glutCreateWindow("Rotating teapot"); //crear una ventana glutDisplayFunc(Display); //callback principal glutReshapeFunc(Reshape); //callback de reshape glutSpecialFunc(SpecialKeys); glutKeyboardFunc(Keyboard); Init(); // Inicializaciones glutMainLoop(); //loop del programa return 0; }
//------------------------------------------------------------------------------ void npGlutEventFuncs (void) { //! register keyboard events with GLUT glutKeyboardFunc (npGlutKeyDown); glutKeyboardUpFunc (npGlutKeyUp); glutSpecialFunc (npGlutKeyDownSpecial); glutSpecialUpFunc (npGlutKeyUpSpecial); //! register mouse events with GLUT //glutEntryFunc( npMouseEntry ); //zz only works when clicking glutMouseFunc (npMouseEvent); glutMotionFunc (npMouseMotion); glutPassiveMotionFunc( npMousePosition ); /// Apple GLUT does not support the mouse wheel #ifndef NP_OSX_ //zz-osx debug lde glutMouseWheelFunc (npMouseWheel); #endif //! register display functions with GLUT glutDisplayFunc (npGlutDrawGLScene); glutIdleFunc (npGlutDrawGLSceneIdle); glutReshapeFunc (npGLResizeScene); }
void InitGlut(int argc, char** argv, char* lessonTitle) { glutInit(&argc, argv); glutInitWindowSize(512, 512); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); gMainHandle = glutCreateWindow(lessonTitle); glutSetWindow(gMainHandle); glutDisplayFunc(RenderCallback); glutReshapeFunc(ReshapeCallback); glutIdleFunc(IdleCallback); glutKeyboardFunc(KeyboardCallback); glutKeyboardUpFunc(KeyboardUpCallback); glutSpecialFunc(SpecialCallback); glutMouseFunc(MouseCallback); glutMotionFunc(MotionCallback); MotionCallback(0,0); #ifndef LINUX glutExitFunc(ExitCallback); #endif // Setup default render states glClearColor(0.0f, 0.0f, 0.0f, 1.0); glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); glEnable(GL_CULL_FACE); // Setup lighting glEnable(GL_LIGHTING); float AmbientColor[] = { 0.0f, 0.1f, 0.2f, 0.0f }; glLightfv(GL_LIGHT0, GL_AMBIENT, AmbientColor); float DiffuseColor[] = { 0.2f, 0.2f, 0.2f, 0.0f }; glLightfv(GL_LIGHT0, GL_DIFFUSE, DiffuseColor); float SpecularColor[] = { 0.5f, 0.5f, 0.5f, 0.0f }; glLightfv(GL_LIGHT0, GL_SPECULAR, SpecularColor); float Position[] = { 100.0f, 100.0f, -400.0f, 1.0f }; glLightfv(GL_LIGHT0, GL_POSITION, Position); glEnable(GL_LIGHT0); InitShapeDisplayLists(); }
} int main(int argc, char **argv) { init_sph_system(); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutInitWindowSize(window_width, window_height); glutCreateWindow("SPH System 2D"); init(); init_menu(); glutDisplayFunc(display_func); glutReshapeFunc(reshape_func); glutIdleFunc(idle_func); glutKeyboardFunc(process_keyboard); glutSpecialFunc(special_keys); glutMouseFunc(mouse_func); glutMotionFunc(motion_func); glutMainLoop();