void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity(); gluLookAt(0, 0, 20 + zoomValue, 0, 0, 0, 0, 1, 0); // multiply current matrix with arcball matrix glMultMatrixf( arcball.get() ); GLUquadric *sphere = gluNewQuadric(); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); calculateFPS(); _time_inter = diff_seconds(); animateObject(); //draw_sun(); if (mode==0) { moebius(); glutPostRedisplay(); } else { glCallList(MOEBIUS); glutPostRedisplay(); } drawFPS(); glutPostRedisplay(); glutSwapBuffers(); }
int main(int argc,char** argv) { diff_seconds(); srand(time(NULL)); glutInit(&argc, argv); glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE |GLUT_RGB); glutInitWindowSize (900,600); glutInitWindowPosition (240, 40); glutCreateWindow ("E16 - Partikelsystem"); glutKeyboardFunc(keyboard); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); init(); glutDisplayFunc(display); glutIdleFunc(idle); glEnable(GL_DEPTH_TEST); /********************************************/ cg_context = cgCreateContext(); checkForCgError("creating context"); cg_vertex_profile = cgGLGetLatestProfile(CG_GL_VERTEX); cgGLSetOptimalOptions(cg_vertex_profile); checkForCgError("selecting vertex profile"); cg_vertex_program = cgCreateProgramFromFile(cg_context, CG_SOURCE, "vertex.cg", cg_vertex_profile, "more_complex_vertex_shader", NULL); checkForCgError("creating vertex program from file"); cgGLLoadProgram(cg_vertex_program); checkForCgError("loading vertex program"); /**************************************************/ cg_parameter_vertex_velocity = cgGetNamedParameter(cg_vertex_program, "Texture0"); cg_parameter_vertex_time = cgGetNamedParameter(cg_vertex_program, "Texture1"); glutMainLoop(); return 0; }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); cgGLBindProgram(cg_vertex_program); checkForCgError("binding vertex program"); cgGLEnableProfile(cg_vertex_profile); checkForCgError("enabling vertex profile"); // parameter //cgGLSetParameter1f(cg_parameter_vertex_scale_factor, 0.7); //cgGLSetParameter1f(cg_parameter_vertex_rotation, rotation); // Zeit die seit dem rendern des letzten Bildes vergangen ist: cgGLEnableTextureParameter(cg_parameter_vertex_time); t = diff_seconds(); glVertex2f(0.0f, 0.0f); glTexCoord1f(Particle->t); cgGLDisableTextureParameter(cg_parameter_vertex_time); // Berechnung der Framerate mit Hilfe der Zeitmessungsfunktion: frames++; timer += t; if (timer > 1.0) { printf("Frames per second: %i\n", frames); timer -= 1.0; frames = 0; printf("Number of particles: %d\n", water_list.size()); } //cgGLEnableTextureParameter(cg_parameter_vertex_velocity); drawParticles(water_list,water_tex); //glVertex2f(0.0f, 0.0f); //glTexCoord3fv(Particle->velocity); //cgGLDisableTextureParameter(cg_parameter_vertex_velocity); cgGLDisableProfile(cg_vertex_profile); checkForCgError("disabling vertex profile"); glutSwapBuffers(); }
int main(int argc, char** argv) { if (argc < 2) { fprintf(stderr, "Error! Usage:\n\t%s <RING_LIST_CAPACITY>\n", argv[0]); exit(-1); } int capacity = atoi(argv[1]); if (capacity == 0) { fprintf(stderr, "Error! <RING_LIST_CAPACITY> must be an integer bigger than 0.\n"); exit(-1); } RingList *list = ringlist_new(capacity); int option, response; long long int param; struct timespec start, stop; double elapsed_time; do { printf(" (1) Print RingList\n (2) Insert new value\n (3) Remove by index\n (4) Remove by value\n (5) Binary search \n (6) Interpolation search \n (7) Get by index \n (8) Fill untill the range \n (0) Exit\n"); printf("Your option: "); scanf("%d", &option); printf("----------------------------------\n"); switch(option) { case 1: ringlist_print(list); break; case 2: printf("Value = "); scanf("%lld", ¶m); ringlist_insert(list, param); break; case 3: printf("Index = "); scanf("%lld", ¶m); ringlist_remove_byindex(list, param); break; case 4: printf("Value = "); scanf("%lld", ¶m); ringlist_remove_byvalue(list, param); break; case 5: printf("Value = "); scanf("%lld", ¶m); clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &start); response = ringlist_bsearch(list, param); if (response == ERROR_NOT_FOUND) printf("'%lld' not found.\n", param); else printf("list[%d] = %lld\n", response, param); printf("list[%d] = %lld\n", response, param); clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &stop); elapsed_time = diff_seconds(start, stop); printf("Binary search time = %lf sec\n", elapsed_time); break; case 6: printf("Value = "); scanf("%lld", ¶m); clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &start); response = ringlist_interpolsearch(list, param); if (response == ERROR_NOT_FOUND) printf("'%lld' not found.\n", param); else printf("list[%d] = %lld\n", response, param); clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &stop); elapsed_time = diff_seconds(start, stop); printf("Interpolation search time = %lf sec\n", elapsed_time); break; case 7: printf("Index = "); scanf("%lld", ¶m); response = ringlist_get(list, param); printf("list[%lld] = %d\n", param, response); break; case 8: printf("Range = "); scanf("%lld", ¶m); ringlist_fill(list, param); break; } printf("----------------------------------\n"); /* #ifdef TARGET_OS_MAC system("clear"); #elif defined __linux__ system("clear"); #elif defined _WIN32 || defined _WIN64 system("cls"); #endif */ } while (option != 0); return 0; }