Exemple #1
0
void MyGLWidget::initializeGL()
{

    glEnable(GL_DEPTH_TEST);                                // Activate depth comparisons and update depth buffer

    glEnable(GL_CULL_FACE);                                 // Draw Front or Back?

    glDepthFunc(GL_LEQUAL);                                 // Specify the depth buffer

    //glShadeModel(GL_SMOOTH);                                // !Deprecated GL_FLAT or GL_SMOOTH (interpolated)

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);      // Are there Interpretations? Set hint!

    glClearDepth(1.0f);                                     // Clear value for depth buffer (used by glClear)

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);                   // Clear values used by glClear (Color-Buffer)();

    loadModel();
    initializeTextures();
    initalizeBuffer();
    initalizeShader();
    initializePlanets();

    attrVertices  = shaderProgram.attributeLocation("vert");     // #version 130
    attrTexCoords = shaderProgram.attributeLocation("texCoord"); // #version 130


    // Aktiviere die Verwendung der Attribute-Arrays
    shaderProgram.enableAttributeArray(attrVertices);
    shaderProgram.enableAttributeArray(attrTexCoords);


    // Laden der
    // Ein paar Hilfsvariablen - die 8 steht für
    // 4 Eckpunktkoordinaten + 4 Texturkoordinaten
    int offset = 0 ;
    size_t stride = 8 * sizeof(GLfloat);
    shaderProgram.setAttributeBuffer(attrVertices,GL_FLOAT,offset,4,stride);
    offset += 4*sizeof(GLfloat);
    shaderProgram.setAttributeBuffer(attrTexCoords,GL_FLOAT,offset,4,stride);


    // Lokalisiere bzw. definierte die Schnittstelle für die Matritzen
    // Die Matrix kann direkt übergeben werden, da setUniformValue für diesen Typ überladen ist.
    unifMatrixPerspective = shaderProgram.uniformLocation("perspectiveMatrix");
    Q_ASSERT(unifMatrixPerspective >= 0) ;
    unifMatrixModel = shaderProgram.uniformLocation("modelMatrix");
    Q_ASSERT(unifMatrixModel >= 0) ;
    unifMatrixView = shaderProgram.uniformLocation("viewlMatrix");
    Q_ASSERT(unifMatrixView >= 0) ;

    //qTex->bind();

}
void main (int argc, char** argv)
{
    glutInit (&argc, argv);    
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize (900, 900);   
    glutInitWindowPosition (0, 0);    
	glutCreateWindow ("20133265 CHA DONG MIN, Solar System");  
	glClearColor(0.0, 0.0, 0.0, 1.0);
	initializePlanets();	//행성 준비

    glutDisplayFunc (MyDisplay);   
	glutKeyboardFunc(MyKeyboard);
	//glutTimerFunc(40, MyTimer, 1);
	glutSpecialFunc(MyspecialKey);
	glutReshapeFunc(MyReshape);  
    glutIdleFunc(MyIdle);
    glutMainLoop();    
}
Exemple #3
0
void setupDomain( struct domain * theDomain ){

   srand(theDomain->rank);
   rand();

   int Nr = theDomain->Nr;
   int Nz = theDomain->Nz;
   int * Np = theDomain->Np;
   theDomain->theCells = (struct cell **) malloc( Nr*Nz*sizeof(struct cell *) );
   int jk;
   for( jk=0 ; jk<Nr*Nz ; ++jk ){
      theDomain->theCells[jk] = (struct cell *) malloc( Np[jk]*sizeof(struct cell) );
   }

   setPlanetParams( theDomain );
   int Npl = theDomain->Npl;
   theDomain->thePlanets = (struct planet *) malloc( Npl*sizeof(struct planet) );
   initializePlanets( theDomain->thePlanets );

   double num_tools = num_diagnostics();
   theDomain->num_tools = num_tools;
   theDomain->theTools.t_avg = 0.0;
   theDomain->theTools.Qr = (double *) malloc( Nr*num_tools*sizeof(double) );
   int i;
   for( i=0 ; i<Nr*num_tools ; ++i ) theDomain->theTools.Qr[i] = 0.0;

   double Pmax = theDomain->theParList.phimax;
   for( jk=0 ; jk<Nr*Nz ; ++jk ){
      double p0 = Pmax*(double)rand()/(double)RAND_MAX;
      double dp = Pmax/(double)Np[jk];
      for( i=0 ; i<Np[jk] ; ++i ){
         double phi = p0+dp*(double)i;
         if( phi > Pmax ) phi -= Pmax;
         theDomain->theCells[jk][i].piph = phi;
         theDomain->theCells[jk][i].dphi = dp;
      }
   }

   theDomain->t       = theDomain->theParList.t_min;
   theDomain->t_init  = theDomain->theParList.t_min;
   theDomain->t_fin   = theDomain->theParList.t_max;
   theDomain->phi_max = theDomain->theParList.phimax;

   theDomain->N_rpt = theDomain->theParList.NumRepts;
   theDomain->N_snp = theDomain->theParList.NumSnaps;
   theDomain->N_chk = theDomain->theParList.NumChecks;

   theDomain->count_steps = 0;
   theDomain->final_step  = 0;
   theDomain->check_plz   = 0;

   theDomain->nrpt=-1;
   theDomain->nsnp=-1;
   theDomain->nchk=-1;

   theDomain->theFaces_1 = NULL;
   theDomain->theFaces_2 = NULL;
   theDomain->N_ftracks_r = get_num_rzFaces( Nr , Nz , 1 );
   theDomain->N_ftracks_z = get_num_rzFaces( Nr , Nz , 2 );

   theDomain->fIndex_r = (int *) malloc( (theDomain->N_ftracks_r+1)*sizeof(int) );
   theDomain->fIndex_z = (int *) malloc( (theDomain->N_ftracks_z+1)*sizeof(int) );

   setICparams( theDomain );
   setHydroParams( theDomain );
   setGeometryParams( theDomain );
   setRiemannParams( theDomain );
   setHlldParams( theDomain );
   setDiskParams( theDomain );
   setOmegaParams( theDomain );

}