示例#1
0
void
TextureLoader::load( const std::string& _path,
					 const FILE_FORMAT _fileFormat )
{
	// argument checks
	if ( _path.empty() )
		GEM_ERROR( "Path argument is empty." );


	// always create new
	if ( isLoaded_ )
		clear();


	// local variables
	FILE_FORMAT fileFormat = _fileFormat;
	std::string path = _path;


	// split path
	std::string dir, name, ext;
	splitPath( path, &dir, &name, &ext );


	// Tell the user that we are trying to load the file
	GEM_CONSOLE( "Loading texture " + name + (ext.empty() ? "" : ".") + ext );


	// Determine file format from extension
	if ( fileFormat == FILE_FORMAT_NONE )
	{
		if ( ext == "bmp" )
		{
			fileFormat = FILE_FORMAT_BMP;
		}
		else if ( ext == "pfm" )
		{
			fileFormat = FILE_FORMAT_PFM;
		}
		else if ( ext == "dds" )
		{
			fileFormat = FILE_FORMAT_DDS;
		}
	}


	// activate the right file loader depending on file type
	try
	{
		switch ( fileFormat )
		{
		case FILE_FORMAT_BMP:
			loadBMP( path );
			break;
		case FILE_FORMAT_PFM:
			loadPFM( path );
			break;
		case FILE_FORMAT_DDS:
			loadDDS( path );
			break;
		default:
			GEM_THROW( "Unsupported file type ." + ext );
			break;
		}
	}
	catch( const std::exception& e )
	{
		clear();
		GEM_ERROR( e.what() );
	}


	// we got this far, so we are ok to setup member variables
	path_ = path;
	fileFormat_ = fileFormat;
	isLoaded_ = true;
}
示例#2
0
void Table::drawTable() {
	glPushMatrix();
	glColor3f(1.0, 1.0, 1.0);

	Image* image = loadBMP("res/wood.bmp");
	GLuint	_textureId = Texture::loadTexture(image);
	delete image;

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, _textureId);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glBegin(GL_QUADS);
	glDisable(GL_COLOR_MATERIAL);
	GLfloat param[4] = { 0.992157, 0.941176, 0.807843, 1.0 };
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, param);
	glMaterialf(GL_FRONT, GL_SHININESS, 0);
	//Front
	glNormal3f(0.0f, 0.0f, 1.0f);
	glTexCoord2f(0.0f, -0.2f);
	glVertex3f(-6.0f, -0.5f, 9.0f);
	glTexCoord2f(1.0f, -0.2f);
	glVertex3f(6.0f, -0.5f, 9.0f);
	glTexCoord2f(1.0f, 0.0f);
	glVertex3f(6.0f, 0.0f, 9.0f);
	glTexCoord2f(0.0f, 0.0f);
	glVertex3f(-6.0f, 0.0f, 9.0f);

	//Right
	glNormal3f(1.0f, 0.0f, 0.0f);
	glTexCoord2f(1.2f, 1.0f);
	glVertex3f(6.0f, -0.5f, -9.0f);
	glTexCoord2f(1.0f, 1.0f);
	glVertex3f(6.0f, 0.0f, -9.0f);
	glTexCoord2f(1.0f, 0.0f);
	glVertex3f(6.0f, 0.0f, 9.0f);
	glTexCoord2f(1.2f, 0.0f);
	glVertex3f(6.0f, -0.5f, 9.0f);

	//Back
	glNormal3f(0.0f, 0.0f, -1.0f);
	glTexCoord2f(0.0f, 1.2f);
	glVertex3f(-6.0f, -0.5f, -9.0f);
	glTexCoord2f(1.0f, 1.2f);
	glVertex3f(6.0f, -0.5f, -9.0f);
	glTexCoord2f(1.0f, 1.0f);
	glVertex3f(6.0f, 0.0f, -9.0f);
	glTexCoord2f(0.0f, 1.0f);
	glVertex3f(-6.0f, 0.0f, -9.0f);

	//Left
	glNormal3f(-1.0f, 0.0f, 0.0f);
	glTexCoord2f(2.2f, 2.2f);
	glVertex3f(-6.0f, -0.5f, -9.0f);
	glTexCoord2f(0.0f, 1.0f);
	glVertex3f(-6.0f, 0.0f, -9.0f);
	glTexCoord2f(1.0f, 0.0f);
	glVertex3f(-6.0f, 0.0f, 9.0f);
	glTexCoord2f(0.0f, 2.2f);
	glVertex3f(-6.0f, -0.5f, 9.0f);

	//Top
	glNormal3f(0.0f, 1.0f, 0.0f);
	glTexCoord2f(1.0f, 0.0f);
	glVertex3f(6.0f, 0.0f, 9.0f);
	glTexCoord2f(0.0f, 0.0f);
	glVertex3f(-6.0f, 0.0f, 9.0f);
	glTexCoord2f(0.0f, 1.0f);
	glVertex3f(-6.0f, 0.0f, -9.0f);
	glTexCoord2f(1.0f, 1.0f);
	glVertex3f(6.0f, 0.0f, -9.0f);

	//Bottom
	glNormal3f(0.0f, -1.0f, 0.0f);
	glTexCoord2f(1.2f, 0.0f);
	glVertex3f(6.0f, -0.5f, 9.0f);
	glTexCoord2f(2.2f, 0.0f);
	glVertex3f(-6.0f, -0.5f, 9.0f);
	glTexCoord2f(2.2f, 1.0f);
	glVertex3f(-6.0f, -0.5f, -9.0f);
	glTexCoord2f(1.2f, 1.0f);
	glVertex3f(6.0f, -0.5f, -9.0f);


	param[0] = 0;
	param[1] = 0;
	param[2] = 0;
	param[3] = 0;
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, param);
	glEnable(GL_COLOR_MATERIAL);
	glEnd();
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();
	//front right leg
	drawLeg(3.0f, 7.0f);

	//front left leg
	drawLeg(-4.0f, 7.0f);

	//back right leg
	drawLeg(3.0f, -6.0f);

	//back left leg
	drawLeg(-4.0f, -6.0f);
}
示例#3
0
void Initialize() {
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
    
    Image* image = loadBMP("bricks.bmp");
    _textureBrick = loadTexture(image);
    image = loadBMP("door0.bmp");
    _textureDoor = loadTexture(image);
    image = loadBMP("grass.bmp");
    _textureGrass = loadTexture(image);
    image = loadBMP("grassmatroofing.bmp");
    _textureRoof = loadTexture(image);
    image = loadBMP("trim.bmp");
    _textureWindow = loadTexture(image);
    image = loadBMP("sky.bmp");
    _textureSky = loadTexture(image);
    image = loadBMP("wallpaper1.bmp");
    _textureWall1 = loadTexture(image);
    image = loadBMP("wallpaper1windows.bmp");
    _textureWall1w = loadTexture(image);
    image = loadBMP("wallpaper2.bmp");
    _textureWall2 = loadTexture(image);
    image = loadBMP("wallpaper2windows.bmp");
    _textureWall2w = loadTexture(image);
    image = loadBMP("wallpaper3.bmp");
    _textureWall3 = loadTexture(image);
    image = loadBMP("wallpaper3windows.bmp");
    _textureWall3w = loadTexture(image);
    image = loadBMP("wallpaper4.bmp");
    _textureWall4 = loadTexture(image);
    image = loadBMP("wallpaper4windows.bmp");
    _textureWall4w = loadTexture(image);
    image = loadBMP("wallpaper5.bmp");
    _textureWall5 = loadTexture(image);
    image = loadBMP("wallpaper5windows.bmp");
    _textureWall5w = loadTexture(image);
    image = loadBMP("wall1.bmp");
    _textureWall6 = loadTexture(image);
    image = loadBMP("wall1windows.bmp");
    _textureWall6w = loadTexture(image);
    image = loadBMP("wall2.bmp");
    _textureWall7 = loadTexture(image);
    image = loadBMP("wall2windows.bmp");
    _textureWall7w = loadTexture(image);
    image = loadBMP("wall3.bmp");
    _textureWall8 = loadTexture(image);
    image = loadBMP("roofing.bmp");
    _textureRoofing1 = loadTexture(image);
    image = loadBMP("roofing2.bmp");
    _textureRoofing2 = loadTexture(image);
    image = loadBMP("flooring.bmp");
    _textureFloor1 = loadTexture(image);
    image = loadBMP("flooring2.bmp");
    _textureFloor2 = loadTexture(image);
    image = loadBMP("water.bmp");
    _textureWater = loadTexture(image);
    image = loadBMP("stonepath.bmp");
    _textureStonePath = loadTexture(image);
    image = loadBMP("fence.bmp");
    _textureFence = loadTexture(image);
    image = loadBMP("tree.bmp");
    _textureTree = loadTexture(image);
    image = loadBMP("ocean.bmp");
    _textureOcean = loadTexture(image);

    delete image;
}
示例#4
0
ImageLoader::ImageLoader(const char *fileName)
{
	reset();
	loadBMP(fileName);
}
示例#5
0
bool Bitmap::loadImage(const char* filename)
{
	if (extensionUpper(filename) == "BMP") return loadBMP(filename);
	if (extensionUpper(filename) == "EXR") return loadEXR(filename);
	return false;
}
示例#6
0
void initRendering() {
	
	Image* image = loadBMP("Metal.bmp");
	_textureId[0] = loadTexture(image);
	delete image;
	image = loadBMP("Land.bmp");
	_textureId[1] = loadTexture(image);
	delete image;
	image = loadBMP("Heli.bmp");
	_textureId[2] = loadTexture(image);
	delete image;
	image = loadBMP("Building1.bmp");
	_btextureId[0] = loadTexture(image);
	delete image;
	image = loadBMP("Building2.bmp");
	_btextureId[1] = loadTexture(image);
	delete image;
	image = loadBMP("Building3.bmp");
	_btextureId[2] = loadTexture(image);
	delete image;
	image = loadBMP("Building4.bmp");
	_btextureId[3] = loadTexture(image);
	delete image;
	image = loadBMP("Sky1.bmp");
	_stextureId[0] = loadTexture(image);
	delete image;
	image = loadBMP("Sky2.bmp");
	_stextureId[1] = loadTexture(image);
	delete image;
	image = loadBMP("Sky3.bmp");
	_stextureId[2] = loadTexture(image);
	delete image;
	image = loadBMP("Sidewalk.bmp");
	_swtextureId = loadTexture(image);
	delete image;
	image = loadBMP("Lightning.bmp");
	_ltextureId = loadTexture(image);
	delete image;
}
示例#7
0
image::image(const uint8_t* data, unsigned size) {
  if(0);
  else if(data[0] == 'B' && data[1] == 'M') loadBMP(data, size);
  else if(data[1] == 'P' && data[2] == 'N' && data[3] == 'G') loadPNG(data, size);
}
示例#8
0
int main()
{
	int res, i, j;
	clock_t t_inicial,t_final;
	char namedest[80];

	t_inicial=clock();

	strcpy(namedest,strtok(filename,"."));
	
	strcat(filename,".bmp");
	strcat(namedest,"_P.bmp");
	printf("Archivo fuente %s\n",filename);
	printf("Archivo destino %s\n",namedest);

	res=loadBMP(filename,&imagenfte);

	if(res==-1)
	{
		fprintf(stderr,"Error al abrir imagen\n");
		exit(1);
	}
	
	printf("Procesando imagen de: Renglones = %d, Columnas = %d\n",imagenfte.infoheader.rows,imagenfte.infoheader.cols);
	
	//start paralelizar
	printf("Paralelizando usando %i threads\n", NTHREADS);
	threadID = (int *) malloc(sizeof(int)*NTHREADS);
	
	memcpy(&imagendst, &imagenfte, sizeof(IMAGE)-sizeof(PIXEL *));
	int imageRows = (&imagenfte)->infoheader.rows;
	int imageCols = (&imagenfte)->infoheader.cols;
	int status=0;
	(&imagendst)->pixel=(PIXEL *)malloc(sizeof(PIXEL)*imageRows*imageCols);
	
	int pids[NTHREADS];
	char *stack;
	stack = malloc(STACK_SIZE*NTHREADS);
	
	for(i=1;i<NTHREADS+1;i++)
	{
		//printf("Creando thread %i\n", i-1);
		threadID[i-1] = i-1;
		//printf("Thread %i creado\n", threadID[i-1]);
		pids[i-1] = clone(processBMP,stack + STACK_SIZE*i,CLONE_FS|CLONE_FILES|CLONE_VM,(void*)&threadID[i-1]);
	}

	for(j=0;j<NTHREADS;j++)
	{
		waitpid(pids[j], &status, __WALL);
	}
	
	//end paralelizar
	
	res=saveBMP(namedest,&imagendst);
	if(res==-1)
	{
		fprintf(stderr,"Error al escribir imagen\n");
		exit(1);
	}
	t_final=clock();
	
	printf("Tiempo %3.6f segundos\n",((float) t_final- (float)t_inicial)/CLOCKS_PER_SEC);
}
示例#9
0
static void DrawBox(){
	int i;




	glPushMatrix();
	  glTranslatef(0,-1,-3);
	glPushMatrix();
	
	glRotatef(angle, 0, 1, 0);
	//glColor3f(1, 1, 0);

	Image* img = loadBMP("günes.bmp");
	_textureId = loadTexture(img);
	delete img;

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	sphere = gluNewQuadric();
	gluQuadricDrawStyle(sphere, GLU_FILL);
	gluQuadricTexture(sphere, GL_TRUE);
	gluQuadricNormals(sphere, GLU_SMOOTH);
	glBindTexture(GL_TEXTURE_2D, _textureId);

	gluSphere(sphere, 0.5, 20, 20);


	glPopMatrix();
	glPushMatrix();

	glColor3f(0.5,0.5,0.5);
glPointSize(1.0);
glBegin(GL_POINTS); 
for(i = 1; i < 360; i++) {
 float   x = distance * sin(((float)i) * 3.14 / 180);
  float  z = distance * cos(((float)i) * 3.14 / 180);
 glVertex3f(x,0,z); 
}
glEnd();

		glPopMatrix();
	glPushMatrix();

	glTranslatef(distance*(cos(-angle1*PI/180)),0.0,distance*(sin(-angle1*PI/180)));
	glPushMatrix();
	glRotatef(10*angle1, 0, 1, 0);


		Image* img1 = loadBMP("earth.bmp");
	_textureId = loadTexture(img1);
	delete img1;

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	sphere = gluNewQuadric();
	gluQuadricDrawStyle(sphere, GLU_FILL);
	gluQuadricTexture(sphere, GL_TRUE);
	gluQuadricNormals(sphere, GLU_SMOOTH);
	glBindTexture(GL_TEXTURE_2D, _textureId);

	gluSphere(sphere, 0.2, 20, 20);




	glPopMatrix();
	glPushMatrix();

		glColor3f(0.5,0.5,0.5);
glPointSize(1.0);
glBegin(GL_POINTS); 
for(i = 1; i < 360; i++) {
 float   x = 0.3 * sin(((float)i) * 3.14 / 180);
  float  z = 0.3 * cos(((float)i) * 3.14 / 180);
 glVertex3f(x,0,z); 
}
glEnd();

		glPopMatrix();


	
	glTranslatef(0.3*(cos(-angle*PI/180)),0.0,0.3*(sin(-angle*PI/180)));
	//glColor3f(0, 1, 0);

	Image* img2 = loadBMP("moon.bmp");
	_textureId = loadTexture(img2);
	delete img2;

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	sphere = gluNewQuadric();
	gluQuadricDrawStyle(sphere, GLU_FILL);
	gluQuadricTexture(sphere, GL_TRUE);
	gluQuadricNormals(sphere, GLU_SMOOTH);
	glBindTexture(GL_TEXTURE_2D, _textureId);
	
	glRotatef(30*angle1, 0, 1, 0);
	gluSphere(sphere, 0.05, 20, 20);


   //glutSolidSphere(0.05,20,20);

	glPopMatrix();
	glPushMatrix();

			glColor3f(0.5,0.5,0.5);
glPointSize(1.0);
glBegin(GL_POINTS); 
for(i = 1; i < 360; i++) {
 float   x = 2 * sin(((float)i) * 3.14 / 180);
  float  z = 2 * cos(((float)i) * 3.14 / 180);
 glVertex3f(x,0,z); 
}
glEnd();

   glPopMatrix();

	glTranslatef(2*(cos(angle1*PI/180)),0.0,2*(sin(angle1*PI/180)));
	glPushMatrix();
	glRotatef(angle, 0, 1, 0);
	// glColor3f(1, 0, 0);
	
	 Image* img3 = loadBMP("venus.bmp");
	_textureId = loadTexture(img3);
	delete img3;

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	sphere = gluNewQuadric();
	gluQuadricDrawStyle(sphere, GLU_FILL);
	gluQuadricTexture(sphere, GL_TRUE);
	gluQuadricNormals(sphere, GLU_SMOOTH);
	glBindTexture(GL_TEXTURE_2D, _textureId);
	
	glRotatef(30*angle1, 0, 1, 0);
	gluSphere(sphere, 0.05, 20, 20);
	 
	// glutSolidSphere(0.05,20,20);
    

	glPopMatrix();
	glPushMatrix();


	glColor3f(0.5,0.5,0.5);
glPointSize(1.0);
glBegin(GL_POINTS); 
for(i = 1; i < 360; i++) {
 float   x = 0.3 * sin(((float)i) * 3.14 / 180);
  float  z = 0.3 * cos(((float)i) * 3.14 / 180);
 glVertex3f(x,0,z); 
}
glEnd();

   glPopMatrix();
   glPushMatrix();



	glTranslatef(0.3*(cos(-angle*PI/180)),0.0,0.3*(sin(-angle*PI/180)));
	glRotatef(10*angle1, 0, 1, 0);
	// glColor3f(1, 1, 0);
	 Image* img4 = loadBMP("mars.bmp");
	_textureId = loadTexture(img4);
	delete img4;

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	sphere = gluNewQuadric();
	gluQuadricDrawStyle(sphere, GLU_FILL);
	gluQuadricTexture(sphere, GL_TRUE);
	gluQuadricNormals(sphere, GLU_SMOOTH);
	glBindTexture(GL_TEXTURE_2D, _textureId);
	
	glRotatef(30*angle1, 0, 1, 0);
	gluSphere(sphere, 0.05, 20, 20);




	
	glPopMatrix();
	glPushMatrix();


	glColor3f(0.5,0.5,0.5);
glPointSize(1.0);
glBegin(GL_POINTS); 
for(i = 1; i < 360; i++) {
 float   x = 0.5 * sin(((float)i) * 3.14 / 180);
  float  z = 0.5 * cos(((float)i) * 3.14 / 180);
 glVertex3f(x,0,z); 
}
glEnd();

   glPopMatrix();

	glTranslatef(0.5*(cos(angle*PI/180)),0.0,0.5*(sin(angle*PI/180)));
	glRotatef(10*angle1, 0, 1, 0);
	 glColor3f(1, 0.9, 0);


	glutSolidSphere(0.03,20,20);
	
	glPopMatrix();


glPopMatrix();

}
示例#10
0
void GLWidget::initializeGL(){
    //glewInit();
    glEnable( GL_DEPTH_TEST);
    glFrontFace( GL_CCW);
    glShadeModel( GL_SMOOTH);
    glEnable( GL_NORMALIZE);
    setLighting( true);
    init3dEng();
    setQuaternion( 1);
    //m_trackBalls = TrackBall(0.0f, QVector3D(0, 1, 0), TrackBall::Plane);
    m_trackBalls = TrackBall(0.0f, QVector3D(0, 1, 0), TrackBall::Sphere);

    //-- sun Light
    sun1.isOn = true;
    sun1.mat.ambi.set( .3, .3, .3, 1.);
    sun1.mat.diff.set( .7, .7, .7, 1.);
    sun1.pos.set( -.5, 1, .5, 0.);
    sun2.isOn = true;
    sun2.mat.ambi.set( .3, .3, .3, 1.);
    sun2.mat.diff.set( .7, .7, .7, 1.);
    sun2.pos.set(  .5, -1, -.5, 0.);

    //-- bulb Light
    bulb.isOn = false;
    bulb.mat.ambi.set( .3, .3, .3, 1.);
    bulb.mat.diff.set( .7, .7, .7, 1.);
    bulb.mat.spec.set( 1., 1., 1., 1.);
    bulb.att.set( 1.0, .01, .0003);

    Texture2d *tex;
    GLubyte *textureImage; //added by sai
     tex = loadBMP( "lap.bmp");
    //bool success = loadPngImage("lap.png",256,256,true,&textureImage);
    //tex = loadBMP( "tex3.bmp");
    //stoma.Load3ds( "stomach.3ds");
    stoma.LoadBIN("mesh.bin");
    stoma.smooth = 1;
     stoma.bindTexture( tex);
    //stoma.bindTexture(&textureImage);
    //stoma.rotate( -90, 0, 0);
    //stoma.scale( Vector3f( .3, .3, .3));
    //stoma.scale( Vector3f( .003, .003, .003));
    stoma.col.set( .6, .6, .2);
    stoma.calcBoundingCube();
    stoma.calcGraph();
    //glTranslatef(0,-160.0,0.0);
stoma.drawGraph();
    skele.Load3ds( "skeleton.3ds");
    skele.smooth = 1;
    skele.col.set( .7, .7, .7);
    skele.calcBoundingCube();
    //stoma += -((skele.cubeBoundMin+skele.cubeBoundMax)/2.0);
    stoma += -((stoma.cubeBoundMin+stoma.cubeBoundMax)/2.0);
    skele += -((skele.cubeBoundMin+skele.cubeBoundMax)/2.0);
    skele.updateDisplayList();
    stoma.lap();
    stoma.saveBIN( "mappedmesh.bin");
    //tex = loadBMP( "lapatlas.bmp");
    //stoma.bindTexture( tex);

    stoma.updateDisplayList();
    skele.isHidden = true;

    model.LoadBIN( "mesh.bin");
    model.col.set( .8, .4, .4);
    model.scale( Vector3f(.1));
    model.calcBoundingCube();
    model += -((model.cubeBoundMin+model.cubeBoundMax)/2.0);
    model.updateDisplayList();
    model.isHidden = true;

    m_mouseClick = 0;
    camS = 0.1;
    camM = 1.0;				// camera zoom
    camT = 0.0; camP = 0.0; // camera theta and phi
    aspectRatio = 1.0;
    freeCam.pos.set( 45., 0., 0.);
    //freeCam.pos.set( 0., 0., -50.);
    freeCam.cnear = 0.01;
    freeCam.cfar = 2000.0;
    freeCam.ang = 45.0/camM;
    freeCam.eye.set( 0., 0., 0.);
    //freeCam.eye = freeCam.pos + Vector3f( sin(camP)*cos(camT), sin(camT), cos(camP)*cos(camT));

    printf("Done\n");
}
示例#11
0
void initRendering()
{
    GLuint i=0;
    GLfloat ambientLight[] = {0.2f, 0.2f, 0.2f, 1.0f};
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);
    
  //  GLfloat directedLight[] = {0.9f, 0.9f, 0.9f, 1.0f};
  //  GLfloat directedLightPos[] = {-10.0f, 15.0f, 20.0f, 0.0f};
  //  glLightfv(GL_LIGHT0, GL_DIFFUSE, directedLight);
  //  glLightfv(GL_LIGHT0, GL_POSITION, directedLightPos);
    glEnable(GL_DEPTH_TEST);

    
    //glEnable(GL_TEXTURE_2D);
    
    //glClearColor(1.0,1.0,1.0,1.0);
    
    // glEnable(GL_COLOR_MATERIAL);
    glGenTextures(17, texName); //Make room for our texture
    Image* image;

    image = loadBMP("estrellas.bmp");loadTexture(image,i++);
    image = loadBMP("map.bmp");loadTexture(image,i++);
    image = loadBMP("Mapamundi.bmp");loadTexture(image,i++);
    image = loadBMP("pin2.bmp");loadTexture(image,i++); //ARREGLAR
    image = loadBMP("america.bmp");loadTexture(image,i++);
    image = loadBMP("asia.bmp");loadTexture(image,i++);
    image = loadBMP("europa.bmp");loadTexture(image,i++);
    image = loadBMP("africa.bmp");loadTexture(image,i++);
    image = loadBMP("blocks.bmp");loadTexture(image,i++);
    image = loadBMP("madera.bmp");loadTexture(image,i++);
    image = loadBMP("water.bmp");loadTexture(image,i++);
    image = loadBMP("instrucciones.bmp");loadTexture(image,i++);
//    image = loadBMP("instrucciones1.bmp");loadTexture(image,i++);
//    image = loadBMP("jugar1.bmp");loadTexture(image,i++);
//    image = loadBMP("salir1.bmp");loadTexture(image,i++);
//    image = loadBMP("instrucciones2.bmp");loadTexture(image,i++);
//    image = loadBMP("jugar2.bmp");loadTexture(image,i++);
//    image = loadBMP("salir2.bmp");loadTexture(image,i++);
//    
    delete image;
}
//constructor loads the bitmap when it is created
Bitmap::Bitmap(char *file){
    reset();
    loadBMP(file);
}
示例#13
0
文件: Game.c 项目: Lobz/RKE-Gunther
int Game(SDL_Surface *screen){
	int i, j;
	bool quit = false;
	SDL_Event event;
	SDL_Surface *clipboard = NULL;

	GameBoard board;
	Object objetos[255];
	Terrain terrenos[255];

	Jogador jogador;
	SDL_Rect *pos = NULL;
	SDL_Surface* clipboard_jogador;

	loadTerrainDefinitions(terrenos,"terreno.dat");
	loadObjectDefinitions(objetos, "objects.dat");
	rke_carrega_jogador(&jogador, TILE_WIDTH, TILE_HEIGHT);

	clipboard_jogador = loadBMP("navio.bmp");
	pos = loadBoard(&board,objetos,"level1.lvl");

	jogador.x = pos->x;
	jogador.y = pos->y;
	jogador.direcao = E;
	jogador.hp = 1000;
	jogador.poder_flecha=3;
	jogador.poder_bomba=10;
	jogador.bombas=5;

	free(pos);

	screen = SDL_GetVideoSurface();
	SDL_FillRect(screen, NULL, 0x000000);

	while(!quit)
	{
		for (i = 0; i < BOARD_HEIGHT ; i++)
		{
			for (j = 0; j < BOARD_WIDTH; j++)
			{
				applyClipToBoard(screen, clipboard, j, i, terrenos[(int)board.scenario[i][j]].retangulo);
				if ((int)(board.objects[i][j])) applyClipToBoard(screen, clipboard, j, i, objetos[(int)board.objects[i][j]].clip);
			}
		}

		applyClipToBoard(screen, clipboard_jogador, jogador.y, jogador.x, jogador.retangulo[jogador.direcao]);

		SDL_Flip(screen);

		while(SDL_PollEvent(&event))
		{
			if(event.type == SDL_QUIT)
			{
				quit = 1;
			}
			else
			{
				if(event.type == SDL_KEYDOWN)
				{
					switch (event.key.keysym.sym)
					{
						case SDLK_ESCAPE:
							quit = 1;
							break;
						case SDLK_UP:
							rke_move_jogador(&jogador, board, terrenos, objetos, -1, 0);
							break;
						case SDLK_DOWN:
							rke_move_jogador(&jogador, board, terrenos, objetos,  1, 0);
							break;
						case SDLK_LEFT:
							rke_move_jogador(&jogador, board, terrenos, objetos,  0, -1);
							break;
						case SDLK_RIGHT:
							rke_move_jogador(&jogador, board, terrenos, objetos,  0,  1);
							break;
						case SDLK_SPACE:
							rke_jogador_atira(&jogador, board, terrenos, objetos, FLECHA);
							break;
						case SDLK_RETURN:
							rke_jogador_atira(&jogador, board, terrenos, objetos, BOMBA);
							break;
						default:
							break;
					}
				}
			}
		}
	}

	SDL_FillRect(screen, NULL, 0x000000);
	return QUIT;
}
示例#14
0
void Table::drawLeg(float xOffset, float zOffset) {

	Image* image = loadBMP("res/wood2.bmp");
	GLuint	_textureId = Texture::loadTexture(image);
	delete image;
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, _textureId);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glBegin(GL_QUADS);

	//Front
	glNormal3f(0.0f, 0.0f, 1.0f);
	glTexCoord2f(0.0f, 1.0f);
	glVertex3f(xOffset + 0.0f, -0.5f, zOffset + 0.0f);
	glTexCoord2f(0.25f, 1.0f);
	glVertex3f(xOffset + 1.0f, -0.5f, zOffset + 0.0f);
	glTexCoord2f(0.25f, 0.0f);
	glVertex3f(xOffset + 1.0f, -6.0f, zOffset + 0.0f);
	glTexCoord2f(0.0f, 0.0f);
	glVertex3f(xOffset + 0.0f, -6.0f, zOffset + 0.0f);

	//Back
	glNormal3f(0.0f, 0.0f, -1.0f);
	glTexCoord2f(0.75f, 1.0f);
	glVertex3f(xOffset + 0.0f, -0.5f, zOffset + -1.0f);
	glTexCoord2f(0.5f, 1.0f);
	glVertex3f(xOffset + 1.0f, -0.5f, zOffset + -1.0f);
	glTexCoord2f(0.5f, 0.0f);
	glVertex3f(xOffset + 1.0f, -6.0f, zOffset + -1.0f);
	glTexCoord2f(0.75f, 0.0f);
	glVertex3f(xOffset + 0.0f, -6.0f, zOffset + -1.0f);

	//Left
	glNormal3f(-1.0f, 0.0f, 0.0f);
	glTexCoord2f(1.0f, 1.0f);
	glVertex3f(xOffset + 0.0f, -0.5f, zOffset + 0.0f);
	glTexCoord2f(0.75f, 1.0f);
	glVertex3f(xOffset + 0.0f, -0.5f, zOffset + -1.0f);
	glTexCoord2f(0.75f, 0.0f);
	glVertex3f(xOffset + 0.0f, -6.0f, zOffset + -1.0f);
	glTexCoord2f(1.0f, 0.0f);
	glVertex3f(xOffset + 0.0f, -6.0f, zOffset + 0.0f);

	//Right
	glNormal3f(1.0f, 0.0f, 0.0f);
	glTexCoord2f(0.0f, 1.0f);
	glVertex3f(xOffset + 1.0f, -0.5f, zOffset + 0.0f);
	glTexCoord2f(0.5f, 1.0f);
	glVertex3f(xOffset + 1.0f, -0.5f, zOffset + -1.0f);
	glTexCoord2f(0.5f, 0.0f);
	glVertex3f(xOffset + 1.0f, -6.0f, zOffset + -1.0f);
	glTexCoord2f(0.25f, 0.0f);
	glVertex3f(xOffset + 1.0f, -6.0f, zOffset + 0.0f);

	//Bottom
	glNormal3f(0.0f, -1.0f, 0.0f);
	glVertex3f(xOffset + 0.0f, -6.0f, zOffset + -1.0f);
	glVertex3f(xOffset + 0.0f, -6.0f, zOffset + 0.0f);
	glVertex3f(xOffset + 1.0f, -6.0f, zOffset + 0.0f);
	glVertex3f(xOffset + 1.0f, -6.0f, zOffset + -1.0f);

	glEnd();
	glDisable(GL_TEXTURE_2D);
}
示例#15
0
Textures::Textures(const char* path){
    memset(&bmpinfo,0,sizeof(bmpinfo));
    loadBMP(path);
}
示例#16
0
void Model::loadImage() {
	Image* image = loadBMP("Metal.bmp");
	_textureId = loadTexture(image);
	delete image;
}
示例#17
0
int main ()
{
    
    printf ("\n\n\n\t\t*** APERTURA PROGRAMMA ***");

    printf ("\n\n  Caricamento database in corso...");

    t_database database;
    carica_database (&database);
    
    char ok1=0;
    do {
        
        printf("\n\n\n\n\t1 Aggiungere nuove immagini al database\n\t2 Elaborare immagini presenti nel database\n\t3 Visualizzare database\n\t4 Uscire dal programma");
        printf("\n\n  Selezionare un'opzione, digitando il numero corrispondente: ");
        scanf(" %c",&ok1);
        
        
        if (ok1=='1'){
            aggiungi_immagini (&database);
            goto pippo;
        }
        
        else if (ok1=='3'){
            stampa_database(database);
            goto pippo;
        }
        
        else if (ok1=='4')
            goto pippo;
        
        else if (ok1=='2'){
            
            int i,j;
            char ok2=0, img_scelta[DIMMAX_NomeImmagine];
            do{
                do {
                    printf("\n\n\n\n\n  Inserire il nome dell'immagine su cui lavorare (filename.bmp): ");
                    scanf("%s", img_scelta);
                } while (strstr(img_scelta, ".bmp")==NULL || loadBMP(img_scelta, &img_controlli));
                
                
                for (i=0; i<database.nro_paz; i++) {
                    for (j=0; j<database.pazienti[i].nro_img; j++)
                        if(strcmp(img_scelta, database.pazienti[i].immagini[j].filename)==0){
                            ok2=1;
                            break;
                        }
                    
                    if(ok2)
                        break;
                }
                
                if(!ok2)
                    printf("\n\n  ATTENZIONE: Immagine non ancora presente nel database!");
                
            }while (!ok2);
            
            
            printf("\n\n  L'immagine selezionata appartiene al paziente %s %s,\n  nato il %.2d.%.2d.%.4d", database.pazienti[i].cognome, database.pazienti[i].nome, database.pazienti[i].nascita.giorno, database.pazienti[i].nascita.mese, database.pazienti[i].nascita.anno);
            
            printf("\n\n  Immagini del paziente:\n");
            
            int k;
            for (k=0; k<database.pazienti[i].nro_img; k++)
                printf("\n\tNome: %s\t\tacquisita in data %.2d.%.2d.%.4d\n", database.pazienti[i].immagini[k].filename, database.pazienti[i].immagini[k].importazione.giorno, database.pazienti[i].immagini[k].importazione.mese, database.pazienti[i].immagini[k].importazione.anno);
            
            char ok3;
            do {
                printf("\n\n\t\t*** POSSIBILI OPZIONI ***\n\n\n  a: Numero di livelli di grigio presenti nell'immagine\n  b: Distribuzione dei livelli di grigio\n  c: Riduzione livelli di grigio a 10\n  d: Definizione del contorno della parte informativa dell'immagine\n  e: Calcolo dell'area della parte informativa dell'immagine\n  f: Calcolo dell'area totale di zone molto scure e molto chiare\n     all'interno dela parte informativa dell'immagine\n  g: Calcolo della variazione delle due aree rispetto all'immagine successiva\n  h: Calcolo della variazione delle due aree rispetto ad un'immagine a scelta\n\n  q: Torna al menu principale \n\n");
                
                char car_scelta;
                
                do{
                    printf("\n  Quale caratteristica dell'immagine vuoi analizzare tra quelle sopra elencate?\n  Inserisci la lettera corrispondente: ");
                    scanf(" %c", &car_scelta);
                    
                    if (car_scelta=='q')
                        goto pippo;
                    
                }while((car_scelta<'a')||(car_scelta>'h'));
                
                switch (car_scelta) {
                    case 'a':
                        Funz_a(img_scelta);
                        break;
                        
                    case 'b':
                        Funz_b(img_scelta);
                        break;
                        
                    case 'c':
                        Funz_c(img_scelta);
                        break;
                        
                    case 'd':
                        Funz_d(img_scelta);
                        break;
                        
                    case 'e':
                        Funz_e(img_scelta);
                        break;
                        
                    case 'f':
                        Funz_f(img_scelta);
                        break;
                        
                    case 'g':
                        Funz_g(img_scelta,&database);
                        break;
                        
                    case 'h':
                        Funz_h(img_scelta,&database);
                        break;
                }
                
                
                do{
                    printf("\n\n  Vuoi eseguire altre operazioni sull'immagine %s? Y=sì, N=no: ", img_scelta);
                    scanf(" %c",&ok3);
                } while (ok3!='Y' && ok3!='y' && ok3!='N' && ok3!='n');
                
                printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
            } while (ok3=='Y' || ok3=='y');
            
            char save; 
            do
            {   printf ("\n\n\n  Salvare nel database le modifiche apportate? Y=si, N=no: ");
                scanf (" %c", &save);
            } while ( save!='y' && save!='Y' && save!='n' && save!='N');
            
            if ( save=='y' || save=='Y' )
            {
                printf ("\n\n  Salvataggio database in corso...");
                salva_database (database);
                printf ("\n  Salvataggio completato!\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
            }
        }
        
        
        
    pippo:
        NULL;
        
    } while (ok1!='4');
    
    printf("\n\n\t\t*** CHIUSURA PROGRAMMA ***\n\n\n\n");
    
    return 0;
}