void ourInit( int Width, int Height ) { ourBuildTextures(); // Color to clear color buffer to. glClearColor(0.1f, 0.1f, 0.1f, 0.0f); // Depth to clear depth buffer to; type of test. glClearDepth(1.0); glDepthFunc(GL_LESS); // Enables Smooth Color Shading; try GL_FLAT for (lack of) fun. glShadeModel(GL_SMOOTH); // Load up the correct perspective matrix; using a callback directly. cbResizeScene(Width,Height); // Set up a light, turn it on. glLightfv(GL_LIGHT1, GL_POSITION, Light_Position); glLightfv(GL_LIGHT1, GL_AMBIENT, Light_Ambient); glLightfv(GL_LIGHT1, GL_DIFFUSE, Light_Diffuse); glEnable (GL_LIGHT1); // A handy trick -- have surface material mirror the color. glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }
// Does everything needed before losing control to the main // OpenGL event loop. void ourInit(int Width, int Height) { int n,i; struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; JSAMPROW row_pointer[1]; unsigned long location = 0; cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); for (n = 0; n<NUM_PIC; n++) { jpeg_stdio_src(&cinfo, fd[n]); jpeg_read_header(&cinfo, 0); cinfo.scale_num = 1; cinfo.scale_denom = SCALE; jpeg_start_decompress(&cinfo); wid[n] = cinfo.output_width; hei[n] = cinfo.output_height; dep[n] = cinfo.num_components; //should always be 3 image[n] = (unsigned char *) malloc(wid[n] * hei[n] * dep[n]); row_pointer[0] = (unsigned char *) malloc(wid[n] * dep[n]); /* read one scan line at a time */ while( cinfo.output_scanline < cinfo.output_height ) { jpeg_read_scanlines( &cinfo, row_pointer, 1 ); for( i=0; i< (wid[n] * dep[n]); i++) image[n][location++] = row_pointer[0][i]; } location = 0; fclose(fd[n]); jpeg_finish_decompress(&cinfo); } jpeg_destroy_decompress(&cinfo); ourBuildTextures(); // Color to clear color buffer to. glClearColor(0.1f, 0.1f, 0.1f, 0.0f); // Depth to clear depth buffer to; type of test. glClearDepth(1.0); glDepthFunc(GL_LESS); // Enables Smooth Color Shading; try GL_FLAT for (lack of) fun. glShadeModel(GL_SMOOTH); // Load up the correct perspective matrix; using a callback directly. cbResizeScene(Width,Height); // Set up a light, turn it on. glLightfv(GL_LIGHT1, GL_POSITION, Light_Position); glLightfv(GL_LIGHT1, GL_AMBIENT, Light_Ambient); glLightfv(GL_LIGHT1, GL_DIFFUSE, Light_Diffuse); glEnable (GL_LIGHT1); // A handy trick -- have surface material mirror the color. glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }
void cbKeyPressed(unsigned char key, int x, int y) { int tmp; double tmpd; switch (key) { case 'Q': case 'q': case 27: glutDestroyWindow(window_id); // exit(1); break; // force entropy changes case 'a': ff_io_entropy_change(); break; case 'd': Lx *= 1.05; Ly *= 1.05; Lz *= 1.05; break; case 'D': Lx /= 1.05; Ly /= 1.05; Lz /= 1.05; break; case 'V': case 'v': show_m = show_m ? 0 : 1; show_sphere = show_sphere ? 0 : 1; break; case 'M': case 'm': show_m = show_m?0:1; break; case 'X': case 'x': show_cube = show_cube ? 0 : 1; break; case '5': show_steric = show_steric?0:1; break; case 'O': case 'o': show_droplet = show_droplet?0:1; break; case 'B': case 'b': show_b = show_b?0:1; break; case 'R': case 'r': if (BmanY == 0) {BmanY = BmanX; BmanX = 0;} else if (BmanX == 0) {BmanX = -BmanY; BmanY = 0;} break; case 'l': ff_io_load(0); break; case 'L': ff_io_load(100); break; case 'S': case 's': show_sphere = show_sphere?0:1; break; case 'T': case 't': T += 1; break; case 'C': case 'c': T -= 1; break; case 'P': case 'p': projection_type = projection_type ? 0 : 1; cbResizeScene(window_width, window_height); break; case 'E': case 'e': show_bext = show_bext?0:1; break; case 'N': case 'n': out<<"step ="<<step << " V_oleic = " << v_oleic<<" V_car = "<<v_car<<" Bmanz ="<<BmanZ; GetScreenShot(out.str()); out.str(""); out.flush(); break; case 'z': addPosition(x_rot, y_rot, space_k, projection_type); break; case 'Z': delPosition(); break; case 'f': ChangePosition(); break; case '0': ff_pieces_coord_info(); BmanX = BmanY = BmanZ = 0; break; case '1': if (manual_field_control) { BmanX += 10; } break; case '2': if (manual_field_control) { BmanY += 10; } break; case '3': if (manual_field_control) { BmanZ += 10; } break; case '4': cout << eta_car0 << "-----" << eta_car << "-----------" << eta_oleic <<"------------" <<T<< endl; T += 10; break; case 'i':case 'I': show_info = show_info?0:1; break; case '9': Lx /= 2; Ly /= 2; Lz /= 2; break; case ' ': time_go = time_go?0:1; ActiveWindow(); break; case '[': scaling_cube /= 1.05; break; case ']': scaling_cube *= 1.05; break; case ',': gr_quality --; break; case '.': gr_quality ++; break; case 'g': gr_x0 -= 0.05; break; case 'h': gr_x0 += 0.05; break; case 'j': gr_y0 -= 0.05; break; case 'k': gr_y0 += 0.05; break; case ';': gr_z0 -= 0.05; break; case '\'': gr_z0 += 0.05; break; case 'u': dt *= 1.1; break; case 'y': dt /= 1.1; break; default: printf ("KP: No action assigned for %c.\n", key); break; } }
void ourInit(int Width, int Height) { int n,i,j; loadOffsets(); struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; JSAMPROW row_pointer[1]; unsigned long location = 0; cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); for (i = 0; i<2; i++) for (n = 0; n<NUM_PIC[i]; n++) { jpeg_stdio_src(&cinfo, fd[i][n]); jpeg_read_header(&cinfo, 0); cinfo.scale_num = 1; cinfo.scale_denom = SCALE; jpeg_start_decompress(&cinfo); wid[i][n] = cinfo.output_width; hei[i][n] = cinfo.output_height; dep[i][n] = cinfo.num_components; //should always be 3 image[i][n] = (unsigned char *) malloc(wid[i][n] * hei[i][n] * dep[i][n]); row_pointer[0] = (unsigned char *) malloc(wid[i][n] * dep[i][n]); /* read one scan line at a time */ while( cinfo.output_scanline < cinfo.output_height ) { jpeg_read_scanlines( &cinfo, row_pointer, 1 ); for( j=0; j< (wid[i][n] * dep[i][n]); j++) image[i][n][location++] = row_pointer[0][j]; } location = 0; fclose(fd[i][n]); jpeg_finish_decompress(&cinfo); } jpeg_destroy_decompress(&cinfo); ourBuildTextures(); // Color to clear color buffer to. glClearColor(0.1f, 0.1f, 0.1f, 0.0f); // Depth to clear depth buffer to; type of test. glClearDepth(1.0); glDepthFunc(GL_LESS); // Enables Smooth Color Shading; try GL_FLAT for (lack of) fun. glShadeModel(GL_SMOOTH); // Load up the correct perspective matrix; using a callback directly. cbResizeScene(Width,Height); // Set up a light, turn it on. glLightfv(GL_LIGHT1, GL_POSITION, Light_Position); glLightfv(GL_LIGHT1, GL_AMBIENT, Light_Ambient); // glLightfv(GL_LIGHT1, GL_DIFFUSE, Light_Diffuse); glEnable (GL_LIGHT1); // A handy trick -- have surface material mirror the color. glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); glutSetCursor(GLUT_CURSOR_NONE); glEnable(GL_TEXTURE_RECTANGLE_ARB); glDisable(GL_LIGHTING); glEnable(GL_LIGHTING); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // If we're blending, we don't want z-buffering. glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); }