Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //au tout début avec les variables
- GLuint texture1;
- GLuint texture2;
- unsigned char *loadImage(const char *fichier);
- //dans le main
- glGenTextures(1, &texture1) ;
- glBindTexture(GL_TEXTURE_2D, texture1) ;
- unsigned char *data = loadJpegImage("./texture_chat.jpg");
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data) ;
- glBindTexture(GL_TEXTURE_2D, texture1);
- glEnable(GL_TEXTURE_2D);
- glGenTextures(2, &texture2) ;
- glBindTexture(GL_TEXTURE_2D, texture2) ;
- data = loadJpegImage("./texture.jpg");
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data) ;
- //a la fin en tant que fonction
- unsigned char *loadImage(const char *nomfichier)
- {
- struct jpeg_decompress_struct cinfo;
- struct jpeg_error_mgr jerr;
- FILE *file;
- unsigned char *ligne;
- cinfo.err = jpeg_std_error(&jerr);
- jpeg_create_decompress(&cinfo);
- file = fopen(nomfichier,"rb");
- cinfo.err = jpeg_std_error(&jerr);
- jpeg_create_decompress(&cinfo);
- jpeg_stdio_src(&cinfo, file);
- jpeg_read_header(&cinfo, TRUE);
- //*width = cinfo.image_width;
- //*height = cinfo.image_height ;
- ligne=image;
- while (cinfo.output_scanline<cinfo.output_height)
- {
- ligne=image+3*256*cinfo.output_scanline;
- jpeg_read_scanlines(&cinfo,&ligne,1);
- }
- jpeg_finish_decompress(&cinfo);
- jpeg_destroy_decompress(&cinfo);
- return ligne ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement