Exemplo n.º 1
0
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		ScreenShot16
//Author		Paul.
//Date			Mon 21 Apr 1997
//
//Description
//
//Inputs
//
//Returns
//
//------------------------------------------------------------------------------
void Graphic::ScreenShot16()
{
//	#pragma message (__HERE__"VidRAM read outside of lock")

    TGA		screenShot;
    ULong	packedlength;

    screenShot.redScale 	= RedShift;							//PD 24Oct97
    screenShot.redMask 		= (1<<RedBits)-1;					//PD 24Oct97
    screenShot.redBits		= RedBits;							//DAW 24Oct97

    screenShot.greenScale 	= GreenShift;						//PD 24Oct97
    screenShot.greenMask	= (1<<GreenBits)-1;					//PD 24Oct97
    screenShot.greenBits	= GreenBits;						//DAW 24Oct97

    screenShot.blueScale	= BlueShift;						//PD 24Oct97
    screenShot.blueMask		= (1<<BlueBits)-1;					//PD 24Oct97
    screenShot.blueBits		= BlueBits;							//DAW 24Oct97

    ROWANSURFACEDESC rsd;
    Master()->DoLockScr(&rsd);

    screenShot.MakeHead(rsd.dwWidth,rsd.dwHeight);
    packedlength = screenShot.MakeBody(&rsd);		//logicalscreenptr,BytesPerScanLine);
    screenShot.Save(screenshotnum++,packedlength);
    if (screenshotnum>99)	screenshotnum=0;

    Master()->DoUnlockScr(&rsd);
}
void missile::tgaExplode(){
	int frame = this->explodeFrame / 10 +1;
	if (frame < 1 || frame >17){
		cout<<"invalid frame number";
		std::exit(1);
	}
	TGA tgaExplode;
	string frameNumber, fileName;
	std::stringstream ss;
	ss<<frame;
	if (frame < 10){
		frameNumber.append("0");
	}
	frameNumber.append(ss.str());
	fileName.append("data2/explode ");
	fileName.append(frameNumber);
	fileName.append(".tga");
	const char * c = fileName.c_str();
	tgaExplode.Load(c);
	glEnable(GL_BLEND); 
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);	
	glPushMatrix();
	glScalef(100,100,100);
	tgaExplode.Draw();
	glPopMatrix();
	glDisable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);	//To fix the bug with font
	explodeFrame++;
}
GLvoid cockPit(){
	glEnable(GL_BLEND); 
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);	
	tgaCockPit.Draw();
	glDisable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);	//To fix the bug with font
}
Exemplo n.º 4
0
GLuint LoadTexture( const char * filename)
{
    GLuint id;
    // Load image from tga file
    //TGA *TGAImage	= new TGA("./sphericalenvironmentmap/house2.tga");
    TGA *TGAImage	= new TGA(filename);
    //TGA *TGAImage	= new TGA("./cubicenvironmentmap/cm_right.tga");

    // Use to dimensions of the image as the texture dimensions
    uint width	= TGAImage->GetWidth();
    uint height	= TGAImage->GetHeigth();

    // The parameters for actual textures are changed

    glGenTextures(1, &id);

    glBindTexture(GL_TEXTURE_2D, id);


    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);


    // Finaly build the mipmaps
    glTexImage2D (GL_TEXTURE_2D, 0, 4, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, TGAImage->GetPixels());

    gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_RGBA, GL_UNSIGNED_BYTE, TGAImage->GetPixels());


    glEnable( GL_TEXTURE_2D );

    glBindTexture (GL_TEXTURE_2D, id);

    delete TGAImage;
    return id;
}
Exemplo n.º 5
0
bool rx_load_tga(Image& img, std::string filename, bool datapath) {

  TGA tga;
  
  if(!tga.load(filename, datapath)) {
    return false;
  }

  if(tga.getNumChannels() == 4) {
    img.setPixelFormat(RX_FMT_RGBA32);
  }
  else if(tga.getNumChannels() == 3) {
    img.setPixelFormat(RX_FMT_RGB24);
  }
  else {
    RX_ERROR(ERR_IMG_UNSUPPORTED_FORMAT);
    return false;
  }

  img.setWidth(tga.getWidth());
  img.setHeight(tga.getHeight());
  
  return img.copyPixels(tga.getPixels(), tga.getWidth(), tga.getHeight(), img.getPixelFormat());
}
Exemplo n.º 6
0
void init(void)
{
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_TEXTURE_2D);
	
	// set up lighting
	glEnable(GL_LIGHTING);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	GLfloat matSpecular[] = { 1.0, 1.0, 1.0, 1.0 };
	GLfloat matAmbience[] = { 0.3, 0.3, 0.3, 1.0 };
	GLfloat matShininess[] = { 20.0 };
	glClearColor (0.0, 0.0, 0.0, 0.0);
	glShadeModel (GL_SMOOTH);

	glMaterialfv(GL_FRONT, GL_SPECULAR, matSpecular);
	glMaterialfv(GL_FRONT, GL_SHININESS, matShininess);
	glMaterialfv(GL_FRONT, GL_AMBIENT, matAmbience);

	GLfloat lightAmbient[] = { 0.3, 0.3, 0.3, 1.0 };
	GLfloat lightDiffuse[] = { 1.0, 1.0, 1.0, 1.0 };
	GLfloat lightSpecular[] = { 1.0, 1.0, 1.0, 1.0 };

	glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse);
	glLightfv(GL_LIGHT0, GL_SPECULAR, lightSpecular);

	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glDisable(GL_LIGHTING);

	// Load all image data
	help = new TGA("images/help.tga");
	stars = new TGA("images/stars.tga");
	moon = new TGA("images/moon.tga");

	TGA* sun = new TGA("images/sun.tga");
	TGA* mercury = new TGA("images/mercury.tga");
	TGA* venus = new TGA("images/venus.tga");
	TGA* earth = new TGA("images/earth.tga");
	TGA* mars = new TGA("images/mars.tga");
	TGA* jupiter = new TGA("images/jupiter.tga");
	TGA* saturn = new TGA("images/saturn.tga");
	TGA* uranus = new TGA("images/uranus.tga");
	TGA* neptune = new TGA("images/neptune.tga");
	TGA* pluto = new TGA("images/pluto.tga");

	// Add all the planets with accurate data. Distance measured in km, time measured in earth days.
	solarSystem.addPlanet(0, 1, 500, 695500, sun->getTextureHandle()); // sun
	solarSystem.addPlanet(57910000, 88, 58.6, 2440, mercury->getTextureHandle()); // mercury
	solarSystem.addPlanet(108200000, 224.65, 243, 6052, venus->getTextureHandle()); // venus
	solarSystem.addPlanet(149600000, 365, 1, 6371, earth->getTextureHandle()); // earth
	solarSystem.addPlanet(227939100, 686, 1.03f, 3389, mars->getTextureHandle()); // mars
	solarSystem.addPlanet(778500000, 4332, 0.4139, 69911, jupiter->getTextureHandle()); // jupiter
	solarSystem.addPlanet(1433000000, 10759, 0.44375, 58232, saturn->getTextureHandle()); // saturn
	solarSystem.addPlanet(2877000000, 30685, 0.718056, 25362, uranus->getTextureHandle()); // uranus
	solarSystem.addPlanet(4503000000, 60188, 0.6713, 24622, neptune->getTextureHandle()); // neptune
	solarSystem.addPlanet(5906380000, 90616, 6.39, 1137, pluto->getTextureHandle()); // pluto

	solarSystem.addMoon(3, 7000000, 27.3, 27.3, 1738, moon->getTextureHandle()); // test moon for the earth

	// set up time
	time = 2.552f;
	timeSpeed = 0.1f;

	// reset controls
	controls.forward = false;
	controls.backward = false;
	controls.left = false;
	controls.right = false;
	controls.rollRight = false;
	controls.rollLeft = false;
	controls.pitchDown = false;
	controls.pitchUp = false;
	controls.yawLeft = false;
	controls.yawRight = false;

	timer(0);
}
Exemplo n.º 7
0
void DisplayFunc(void) 
{
    GLuint id ;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//load projection and viewing transforms
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
        
	gluPerspective(60,(GLdouble) WindowWidth/WindowHeight,0.01,10000);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(CameraRadius*cos(CameraTheta)*sin(CameraPhi),
			  CameraRadius*cos(CameraPhi),
			  CameraRadius*sin(CameraTheta)*sin(CameraPhi),
			  0,0,0,
			  0,1,0);

	glEnable(GL_DEPTH_TEST);	
	glEnable(GL_TEXTURE_2D);

		setParameters(program);
	
	// Load image from tga file
	char* tgaFile = "";
	if(texture == 0 && mapping == 0)
		tgaFile = "./planartexturemap/abstract2.tga";
	else if(texture == 1 && mapping == 0)
		tgaFile = "./sphericaltexturemap/earth2.tga";
	else if(mapping == 1)
		tgaFile = "./sphericalenvironmentmap/house2.tga";
	else
		tgaFile = "./planartexturemap/abstract2.tga";
		//tgaFile = "./planarbumpmap/abstract_gray2.tga";

	TGA *TGAImage = new TGA(tgaFile);

	// Use to dimensions of the image as the texture dimensions
	uint width	= TGAImage->GetWidth();
	uint height	= TGAImage->GetHeigth();
	
	// The parameters for actual textures are changed

	glGenTextures(1, &id);

	glBindTexture(GL_TEXTURE_2D, id);


	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);

	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);


	// Finaly build the mipmaps
	glTexImage2D (GL_TEXTURE_2D, 0, 4, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, TGAImage->GetPixels());

	gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_RGBA, GL_UNSIGNED_BYTE, TGAImage->GetPixels());

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	glEnable( GL_TEXTURE_2D );

	glBindTexture (GL_TEXTURE_2D, id); 

    delete TGAImage;
	if (object == 0)
	{
		float w = .1;
		for (float i = -20; i < 20; i += w)
			for (float j = -20; j < 20; j += w)
			{
				point v1, v2, v3, v4;
				v1.x = i;
				v1.y = j;
				v1.z = 0;
				v2.x = i+w;
				v2.y = j;
				v2.z = 0;
				v3.x = i;
				v3.y = j+w;
				v3.z = 0;
				v4.x = i+w;
				v4.y = j+w;
				v4.z = 0;
				drawTriangle(v1, v2, v3);
				drawTriangle(v2, v3, v4);
			}	
	}
	else if(object == 1)
	{
		gluQuadricTexture(quad,1);
		gluSphere(quad,2,20,20);
	}
	else if (object == 2)
		for (int i = 0; i < faces; i++)
			drawTriangle(vertList[faceList[i].v1], vertList[faceList[i].v2], vertList[faceList[i].v3]);



	//glutSolidTeapot(1);
	//setParameters(program);
	glutSwapBuffers();
}
GLvoid InitCockPit(){
	tgaCockPit.Load("data2/cockpit.tga");
}