Beispiel #1
0
/*
	main - The Main Function
*/
int main (int argc, char ** argv)
{	
	glutInit(&argc,argv);

	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);

	glutCreateWindow("Practica 4 - José Zerpa");

	/* tells glut to use a particular display function to redraw */
	glutDisplayFunc(display);

	/* allow the user to quit using the right mouse button menu */
	g_iMenuId = glutCreateMenu(menufunc);
	glutSetMenu(g_iMenuId);
	glutAddMenuEntry("Quit",0);
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	glutIdleFunc(doIdle);

	/* callback for mouse button changes */
	glutMouseFunc(mousebutton);

	glutReshapeFunc(reshape);

    calcPoints();

	myinit();

	glutMainLoop();
	return 0;
}
Beispiel #2
0
void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	//Si tenemos suficientes puntos para dibujar
	if(spIndex >= 3)
	{
		//Calculamos la spline y dibujamos
		calcPoints();
		glBegin(GL_POINTS);
		glColor3f(1,1,1);
		for(int i=0; i<pIndex; i++)
		{
			glVertex3f(points[i].x, points[i].y, -1);
		}
		glEnd();
	}
	//draw the control points
	glBegin(GL_POINTS);
	glColor3f(0,1,0);
	for(int i=0; i<=spIndex; i++)
		glVertex3f(splineList[i].x, splineList[i].y, 0);
	glEnd();
	glutSwapBuffers ();

}
Beispiel #3
0
//--------------------------------------------------------------------------- 
bool Sky::initialize()
{
   AssertFatal(manager, "Must have manager here");
   SimTerrain *terrain = static_cast<SimTerrain*>(manager->findObject(SimTerrainId));
   if (terrain) {
      calcPoints();

      // initialize static texture coordinates
      textCoord[0].x = 1.0f;   textCoord[0].y = 1.0f;
      textCoord[1].x = 0.0f;   textCoord[1].y = 1.0f;
      textCoord[2].x = 0.0f;   textCoord[2].y = 0.0f;
      textCoord[3].x = 1.0f;   textCoord[3].y = 0.0f;

      // find the color of the bottom polygon by looking at the last pixel
      // in the first column of the first bitmap (all the pixels in the bottom
      // rows of all the bitmaps should be this color).  Also find the top
      // color and pass off to the sky for the background
      for (int i = 0; i < 16; i++) 
         if (textures[i] != -1) 
         {
            int ndx = textures[i];
            if (ndx >= hMaterialList->getMaterialsCount()) 
               ndx = 0;
            const GFXBitmap *bitmap = hMaterialList->getMaterial(ndx).getTextureMap();

            const UInt8* pBits = bitmap->pMipBits[0];

            hazeIndex   = pBits[bitmap->stride*(bitmap->height - 1)];
            skyIndex    = pBits[0];
            paletteKey  = bitmap->paletteIndex;
            break;
         }  

      isInitialized = true;
   } else {
      // Cant initialize until we have a terrain.
   }
   return isInitialized;
}