| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 
 |  
GLuint LoadPlanisphere(char *image_path, SDL_Surface *planisphere) {
 
	GLuint gl_id;
 
	Uint32 rmask, gmask, bmask, amask;
 
	if((planisphere = IMG_Load(image_path)) == NULL)
		return -1;
 
	/* change l'ordre des bytes, reellement utile que si on charge du bitmap */
	#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    		rmask = 0xff000000;
    		gmask = 0x00ff0000;
    		bmask = 0x0000ff00;
    		amask = 0x000000ff;
	#else
    		rmask = 0x000000ff;
    		gmask = 0x0000ff00;
    		bmask = 0x00ff0000;
		amask = 0xff000000;
	#endif
 
	SDL_PixelFormat format = *(planisphere->format);
    	format.BitsPerPixel = SCREEN_DEPTH;
    	format.BytesPerPixel = 4;
    	format.Rmask = rmask;
    	format.Gmask = gmask;
    	format.Bmask = bmask;
    	format.Amask = amask;
 
	planisphere = SDL_ConvertSurface(planisphere, &format, SDL_SWSURFACE);
 
	glGenTextures(1, &gl_id);
 
        glEnable(GL_TEXTURE_2D);
 
        glBindTexture(GL_TEXTURE_2D, gl_id);
 
        glTexImage2D(GL_TEXTURE_2D, 0, 4, planisphere->w, planisphere->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, planisphere->pixels);
 
	// ci dessous : fonctionne correctement !
	// fprintf(stderr, "planisphere->w : %d, planisphere->h : %d", planisphere->w, planisphere->h);
 
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
	glDisable(GL_TEXTURE_2D);
 
   	return gl_id;
} | 
Partager