Advertisement
Guest User

chatBOBO

a guest
Nov 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. //au tout début avec les variables
  2.  
  3. GLuint texture1;
  4. GLuint texture2;
  5. unsigned char *loadImage(const char *fichier);
  6.  
  7. //dans le main
  8. glGenTextures(1, &texture1) ;
  9. glBindTexture(GL_TEXTURE_2D, texture1) ;
  10. unsigned char *data = loadJpegImage("./texture_chat.jpg");
  11. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data) ;
  12. glBindTexture(GL_TEXTURE_2D, texture1);
  13. glEnable(GL_TEXTURE_2D);
  14.  
  15. glGenTextures(2, &texture2) ;
  16. glBindTexture(GL_TEXTURE_2D, texture2) ;
  17. data = loadJpegImage("./texture.jpg");
  18. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data) ;
  19.  
  20. //a la fin en tant que fonction
  21. unsigned char *loadImage(const char *nomfichier)
  22. {
  23. struct jpeg_decompress_struct cinfo;
  24. struct jpeg_error_mgr jerr;
  25. FILE *file;
  26. unsigned char *ligne;
  27. cinfo.err = jpeg_std_error(&jerr);
  28. jpeg_create_decompress(&cinfo);
  29.  
  30. file = fopen(nomfichier,"rb");
  31.  
  32.  
  33. cinfo.err = jpeg_std_error(&jerr);
  34. jpeg_create_decompress(&cinfo);
  35. jpeg_stdio_src(&cinfo, file);
  36. jpeg_read_header(&cinfo, TRUE);
  37.  
  38. //*width = cinfo.image_width;
  39. //*height = cinfo.image_height ;
  40. ligne=image;
  41. while (cinfo.output_scanline<cinfo.output_height)
  42. {
  43. ligne=image+3*256*cinfo.output_scanline;
  44. jpeg_read_scanlines(&cinfo,&ligne,1);
  45.  
  46. }
  47. jpeg_finish_decompress(&cinfo);
  48. jpeg_destroy_decompress(&cinfo);
  49. return ligne ;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement