00001 #include <stdlib.h> 00002 #include "glos.h" 00003 #include <GL/gl.h> 00004 #include <GL/glu.h> 00005 #include <GL/glut.h> 00006 #include <string.h> 00007 #include "vuColour31a.h" 00008 #include "vuSimpleTypes.h" 00009 #include "vuTFunc/vuTFDesignSpec.h" 00010 00011 #include "Volume.h" 00012 #include "VolSet.h" 00013 #include "TorstensFilters.h" 00014 #include "SimpleDefs.h" 00015 #include "specfvr.h" 00016 00017 vu1112118 g_Renderer; 00018 vuColour31a g_Light; 00019 00020 void InitOpenGL(void) 00021 { 00022 glClearColor(0.8,0.8,0.8,0); 00023 glShadeModel(GL_FLAT); 00024 } 00025 00026 void Display(void) 00027 { 00028 g_Renderer.render(); 00029 glutSwapBuffers(); 00030 } 00031 00032 void Reshape(int w, int h) 00033 { 00034 g_Renderer.resize(w,h); 00035 } 00036 00037 void Keyboard(unsigned char key, int x, int y) 00038 { 00039 if(!g_Renderer.keyboard(key, x, y)) { 00040 switch(key) 00041 { 00042 case 'b' : g_Light *= 0.5; 00043 g_Renderer.setLight(g_Light); 00044 break; 00045 case 'g': g_Light *= 2; 00046 g_Renderer.setLight(g_Light); 00047 break; 00048 } 00049 } 00050 glutPostRedisplay(); 00051 } 00052 00053 int main(int argc, char** argv) 00054 { 00055 if (argc < 2 || argc > 4) { 00056 cerr << "Usage : " << argv[0] << " <filename> <oversample> <zero pad>\n"; 00057 return -1; 00058 } 00059 00060 vuTFDesignSpec tf(32,256); 00061 if(!tf.loadTF("frog.spec.tf")) 00062 cout << "Couldn't load frog" << endl; 00063 tf.generateFunction(); 00064 g_Light = vuColour31a(tf.getLightNode(0).col); 00065 g_Renderer.setLight(g_Light); 00066 g_Renderer.setTransferFunc(tf); 00067 00068 float oversample = 1.0; 00069 if (argc > 2) oversample = atof(argv[2]); 00070 if (oversample < 1.0) oversample = 1.0; 00071 g_Renderer.setOversample(oversample); 00072 00073 float zeroPad = 1.0; 00074 if (argc > 3) 00075 zeroPad= atof(argv[3]); 00076 if (zeroPad < 1.0) zeroPad = ROOT_TWO; 00077 g_Renderer.setZeroPad(zeroPad); 00078 00079 cout << "Zero pad: " << zeroPad << endl; 00080 cout << "Oversample: " << oversample << endl; 00081 00082 g_Renderer.setFileName(argv[1]); 00083 bool isread = g_Renderer.read(); 00084 cout << "reading " << (isread?"successful":"failed")<<endl; 00085 if(!isread) return -1; 00086 00087 glutInit(&argc, argv); 00088 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); 00089 glutInitWindowSize(500, 500); 00090 glutCreateWindow("SpectralFVR"); 00091 00092 InitOpenGL(); 00093 00094 glutDisplayFunc(Display); 00095 glutReshapeFunc(Reshape); 00096 glutKeyboardFunc(Keyboard); 00097 00098 g_Renderer.resize(500,500); 00099 cout<<"resized!"<< endl; 00100 glutMainLoop(); 00101 00102 cout <<"after the looop"; 00103 00104 return 0; 00105 }