00001
00009 #include <stdio.h>
00010 #include <stdlib.h>
00011 #include <string.h>
00012
00013
00014
00015 #include "SDL.h"
00016 #include "SDL_OpenGL.h"
00017
00018 #include "main.h"
00019
00020
00021 #include "math.h"
00022 #include "mex.h"
00023
00024
00025
00026
00027 #include "oGL_graphics/graphics_relative.h"
00028 #include "oGL_graphics/solid_objects.h"
00029
00030
00031
00032
00033 #include "string.h"
00034
00035
00036 #include "hydro_source/hydro_includes.h"
00037
00038
00039
00040
00041 #include "CVODEincludes.h"
00042
00043
00044
00045 #include "timing/timing.h"
00046
00047
00048 #include "f.h"
00049
00050
00051
00052
00053
00054 static GLboolean should_rotate = GL_TRUE;
00055
00056
00057
00058
00059
00060
00061 float rot1 = 0.0f;
00062 float rot2 = 0.0f;
00063
00064 int goLoop = 1;
00065
00066 ODE_data f_dats;
00067 ODE_data *f_dat = &f_dats;
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00079
00084 void quit_tutorial( int code )
00085 {
00086 joystick_close();
00087 SDL_Quit( );
00088 close_font();
00089
00090
00091 free_wave_variables();
00092 solver_free(f_dat);
00093 delete f_dat->state;
00094 Boat_delete();
00095 exit( code );
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00109
00112 int main( int argc, char* argv[] )
00113 {
00114 int width = 640;
00115 int height = 480;
00116
00117
00118 parameters Par;
00119 parameters *P = &Par;
00120 joy_parameters jPar;
00121 joy_parameters *jP = &jPar;
00122 datas dat;
00123 datas *d = &dat;
00124
00125
00126
00127
00128
00129 int kk;
00130
00131 double *state = new double[STATENUM];
00132 char* flag;
00133 char def_flag[] = "";
00134 char output_flag[] = "output";
00135 long tLength;
00136
00137 float Time;
00138 double time;
00139 bool go=1;
00140
00141 read_arguments_from_file(P, jP, state, &time);
00142 pass_joy_parameters(jP);
00143
00144
00145
00146 f_dat->d = d;
00147 f_dat->P = P;
00148
00149
00150 f_dat->state = state;
00151
00152 fprintf( stderr, "state: \n");
00153 for (kk=0; kk<12; kk++) fprintf( stderr,"%f \n", float(state[kk]));
00154
00155
00156
00157 f_dat->time_param = time;
00158
00159
00160 data_init(d);
00161 data_update_state(d, state);
00162 data_update_param(d, P);
00163
00164
00165 solver_init(f_dat);
00166
00167 wave_init();
00168
00169 Boat_create(d);
00170
00171
00172
00173 setup_SDL(width, height);
00174
00175 kk = joystick_init();
00176
00177
00178 setup_opengl( width, height );
00179
00180 setup_font();
00181
00182
00183 while( getCallibatingPhase() )
00184 {
00185 process_events( );
00186 kk = DrawGLScene(d);
00187 SDL_GL_SwapBuffers();
00188 do_on_keystate(d);
00189 }
00190
00191 tic();
00192
00193 while( go )
00194 {
00195
00196 process_events( );
00197 Time = toc();
00198 solve_ODE(f_dat, Time);
00199
00200
00201 kk = DrawGLScene(d);
00202 SDL_GL_SwapBuffers();
00203 do_on_keystate(d);
00204 if ((f_dat->time_param != 0.0) && (d->t > f_dat->time_param)) go=0;
00205 }
00206
00207
00208 kk = write_results_to_file();
00209
00210 quit_tutorial( 0 );
00211
00212 return 0;
00213 }
00214
00215