Пример #1
0
util::Array2D<loaders::pixel_t> loaders::loadBitmap(const std::string& filename) {
	std::vector<char> data = loadRawData(filename);

	BmpFileHeader fh = newFileHeader((unsigned char*)data.data(), data.size());
	BmpDib dib = loadBitmapDib((unsigned char*)data.data()+14, data.size()-14);

	return loadBmp(((unsigned char*)data.data())+fh.pixelOffset, dib);
}
Пример #2
0
void scene::setHud(long data, char *filename, char *pMask)
{
	long width;
	long height;
	long *sprite;
	long *mask;

	sprite = loadBmp(filename, width, height);
	if (pMask != NULL)
		mask = loadBmp(pMask, width, height);
	else
		mask = NULL;
	((image *) data)->setParams(sprite, width, height, mask);
	delete []sprite;
	if (pMask != NULL)
		delete []mask;
}
Пример #3
0
void scene::setSprite(long data, char *filename, char *pMask, float scale)
{
	long width;
	long height;
	long *sprite;
	long *mask;

	sprite = loadBmp(filename, width, height);
	if (pMask != NULL)
		mask = loadBmp(pMask, width, height);
	else
		mask = NULL;
	((mesh *) data)->setSprite(sprite, width, height, mask, scale);
	delete []sprite;
	if (pMask != NULL)
		delete []mask;
}
Пример #4
0
int main(int argc, char** argv) {
    int y,x;
    char tmp;
    FILE *filePtr;
    imm=loadBmp("testR1.bmp");
    saveBmp(imm,"testSave.bmp");
    printf("START\n");
    
    return (EXIT_SUCCESS);
}
Пример #5
0
void scene::setTexture(long data, char *filename, long mapDir, bool skybox)
{
	long width;
	long height;
	long *texture;

	texture = loadBmp(filename, width, height);
	((mesh *) data)->setTexture(texture, width, height, mapDir, skybox);
	delete []texture;
}
Пример #6
0
void SimpleSparkle::init(const char *texture) {
    int mw = env->getMatrixWidth(), mh = env->getMatrixHeight();
    xd = 4.0 / mw;
    yd = 2.0 / mh;
    count = mw * mh;

 RGBAbmp *pic = loadBmp(texture);
  glGenTextures(1, &particleTex);
  glBindTexture(GL_TEXTURE_2D, particleTex);
  int textureType = GL_RGB;
  if (pic->bpp == 32) 
  textureType = GL_RGBA ;
  gluBuild2DMipmaps(GL_TEXTURE_2D, pic->bpp/8, pic->width, 
                                    pic->height, textureType, GL_UNSIGNED_BYTE, pic->data);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);	
  delete pic->data;
  delete pic;

  
  vertexArray = (GLfloat*)malloc(sizeof(GLfloat) * 2 * mw * mh) ;
  vel = (GLfloat*)malloc(sizeof(GLfloat) * 2 * mw * mh) ;
  colorArray  = (GLfloat*)malloc(sizeof(GLfloat) * 4 * count) ;
  for (int i = 0; i < mh; ++i )
      for (int t = 0; t < mw; ++t ) {
        int vidx = (i*mw+t)*2;
        vertexArray[vidx] = t*xd - 2.0 +  ((((float)rand()/RAND_MAX)*variance)-variance*0.5);
        vertexArray[vidx+1] =  i * yd - 1.0 + ((((float)rand()/RAND_MAX)*variance)-variance*0.5);
        vel[vidx] = 0.0;
        vel[vidx+1] = 0.0;
        int cidx = (i*mw+t)*4;
        colorArray[cidx] = 1.0;
        colorArray[cidx+1] = 1.0;
        colorArray[cidx+2] = 1.0;
        colorArray[cidx+3] = 0.0;
      }
        
  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_COLOR_ARRAY);
  
  glVertexPointer(2, GL_FLOAT,0, vertexArray);
  glColorPointer(4, GL_FLOAT,0, colorArray);
}
Пример #7
0
bool CTexture::Load(char *path){
	FILE* fp;
	fopen_s(&fp,path, "rb");
	if(!fp) {
		printf("ファイルが読み込めません[%s]",path);
		m_bufID=0;
		return false;
	}
	unsigned char crc[4];
	fread(crc,4,1,fp);
	if(crc[0]==0x42 && crc[1]==0x4D) {
		fclose(fp);
		return loadBmp(path);
	}else {
//	if(crc[1]==0x50 && crc[2]==0x4E && crc[3]==0x47) {
		fclose(fp);
		return loadPng(path);
	}
	
	
}
void initEffect()
{
	originalImage = loadBmp("../images/OldSkool.bmp");
}
Пример #9
0
CatchSparksEffect::CatchSparksEffect(EffectSettings *conf)
    : Effect()
{
  flowerCount = conf->getIntegerOrDefault("flowercount", 30);
  blossomCount = conf->getIntegerOrDefault("blossomcount", 3);
  sparkCount = conf->getIntegerOrDefault("sparkcount", 30);
  blossomsize = conf->getFloatOrDefault("blossomsize", 12.0);
  sparksize = conf->getFloatOrDefault("sparksize", 10.0);

  xd = 4.0 / env->getMatrixWidth();
  yd = 2.0 / env->getMatrixHeight();

  Flower::setSparkCount(sparkCount);
  Flower::setBlossomCount(blossomCount);
  Flower::setAreaDetector(&detector);
  Flower::setxyd(xd, yd);
  flowers = new Flower[flowerCount];

  int verticesTotal = flowerCount * (blossomCount + sparkCount);
  vertices = new GLfloat[2 * verticesTotal];
  colors = new GLfloat[4 * verticesTotal];

  for ( int i = 0; i < verticesTotal; ++i) {
    vertices[2*i] = 0.0;
    vertices[2*i+1] = 0.0;
    colors[4*i] = 1.0;
    colors[4*i+1] = 1.0;
    colors[4*i+2] = 1.0;
    colors[4*i+3] = 1.0;
  }

  unsigned int sparkoffset = blossomCount * 2 * flowerCount; // sparks are stored behind blossoms
  for (unsigned int i = 0; i < flowerCount; ++i) {
    flowers[i].setBlossomPointers(vertices + i * 2 * blossomCount, colors + i * 4 * blossomCount);
    flowers[i].setSparksPointers(vertices + sparkoffset + i * 2 * sparkCount, colors + 2*sparkoffset + i * 4 * sparkCount);
    flowers[i].reset();
  }

  RGBAbmp *pic = loadBmp("data/blossom.bmp");

  glGenTextures(1, &blossomTex);
  glBindTexture(GL_TEXTURE_2D, blossomTex);
  int textureType = GL_RGB;
  if (pic->bpp == 32) 
  textureType = GL_RGBA ;
  gluBuild2DMipmaps(GL_TEXTURE_2D, pic->bpp/8, pic->width, 
                                    pic->height, textureType, GL_UNSIGNED_BYTE, pic->data);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);	
  delete pic->data;
  delete pic;

  pic = loadBmp("data/whiteflare.bmp");

  glGenTextures(1, &sparkTex);
  glBindTexture(GL_TEXTURE_2D, sparkTex);
  if (pic->bpp == 32) 
  textureType = GL_RGBA ;
  gluBuild2DMipmaps(GL_TEXTURE_2D, pic->bpp/8, pic->width, 
                                    pic->height, textureType, GL_UNSIGNED_BYTE, pic->data);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);	
  delete pic->data;
  delete pic;

  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_COLOR_ARRAY);

  glVertexPointer(2, GL_FLOAT,0, vertices);
  glColorPointer(4, GL_FLOAT,0, colors);

  glColor3f(1.0, 1.0, 1.0);
  glEnable(GL_TEXTURE_2D);
  glEnable( GL_BLEND );
  glBlendFunc( GL_SRC_ALPHA, GL_DST_ALPHA );
  // This is how will our point sprite's size will be modified by 
  // distance from the viewer
  float quadratic[] =  { 1.0f, 0.0f, 0.01f };
  glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic );

  glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 1.0f );
  glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, 100.0f );

  // Specify point sprite texture coordinate replacement mode for each 
  // texture unit
  glTexEnvf( 0x8861, 0x8862, GL_TRUE );

    glEnable( 0x8861 );
}
void initEffect()
{
	originalImage = loadBmp("../images/OldSkool.bmp");
	filteredImage = new Image(ScreenWidth, ScreenHeight);
}
Пример #11
0
void createParticle()
{
    IMG_particle[0] = loadBmp("media/particle.png");
}
Пример #12
0
void* launch_graphic(void * client_void){ //Main de test (Bruno)

	Client* client = (Client*) client_void;
	Process* process = client->process;
	pthread_t threadDisplay;
	ScreenInfo* screenInfo = malloc(sizeof(ScreenInfo));
	bool quit = false;
	if(SDL_Init(SDL_INIT_VIDEO) == -1){
		fprintf(stderr, "Erreur initialisation de la vidéo : %s\n", SDL_GetError());
		exit(EXIT_FAILURE);//
	}
	else{
		SDL_Window* window = NULL;

		//Création d'une fenêtre en pleine écran à la résolution de l'ordinateur
		window = SDL_CreateWindow("Network Of Swag", SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,WIDTH,HEIGHT, SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE);

		if(window){
			int selectedItem = 0;
			SDL_Event event;
			loadBmp();

			/*if(client->logo){
				//POUR LE TROLL
				SDL_Surface* yogurt = SDL_LoadBMP("./client/src/graphic/image/projet_reseau_logo.bmp");
				SDL_Rect logo = {310, 195, 375, 413};
				SDL_BlitSurface(yogurt,NULL,SDL_GetWindowSurface(window), &logo);
				SDL_UpdateWindowSurface(window);
				sleep(2);
			}*/



			Player* player = process->player; //Player temporaire pour les test
			/*block stone, iron;
			stone.type = STONE;
			iron.type = IRON;
			addBlockToInv(player,iron); //Ajout de bloc pour tester la barre d'inventaire
			addBlockToInv(player,stone);

			printMap(window,map,27,37,selectedItem,player); //Print de test

			printPlayer(window, 550, 51);  //Only for test
			SDL_UpdateWindowSurface(window); //Only for test*/
			screenInfo->win = window;
			screenInfo->process = process;
			screenInfo->selectedItem = &selectedItem;
			screenInfo->isClosed = &(client->isClosed);
			pthread_create(&threadDisplay, NULL, displayOnScreen, screenInfo);

			while(client->isClosed == false){
				//Boucle principale
				quit = waitEvent(event,window,&selectedItem,player,process->map,client->cn); // Gére les évenements
				if(quit){
					client->isClosed = true;
				}
			}

			pthread_join(threadDisplay, NULL);
			freeBmp();
			SDL_DestroyWindow(window);
		}
		else{
			fprintf(stderr, "Erreur création de la fenêtre : %s\n", SDL_GetError());
			exit(-1);
		}
	}

	SDL_Quit();
	#ifdef DEBUG
	printf("Close Graphic\n");
	#endif
	pthread_exit(NULL);
}