Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. GLuint texture[meshes_number];            // 1 mesh = 1 texture
  2. int globalcounter=0;               
  3.  
  4. //Then I create the following function:
  5.  
  6. void GeneratePlusBindTextures (&scene){
  7.  
  8. (for every mesh on current scene) {
  9.     (if current mesh has got a not null Qimage texture){
  10.         glEnable(GL_TEXTURE_2D);
  11.         glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  12.         glGenTextures(1, &texture[globalcounter]);                  // Create The Texture
  13.         glBindTexture(GL_TEXTURE_2D, texture[globalcounter]);
  14.         glTexImage2D(GL_TEXTURE_2D, 0, 3, 256 , 256 , 0, GL_RGB, GL_UNSIGNED_BYTE, p.Mat().GetTexture()->Data() );
  15.         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
  16.         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
  17.         glDisable(GL_TEXTURE_2D);
  18.         globalcounter++;
  19.     }
  20. }
  21.  
  22. //where p.Mat().GetTexture()->Data() returns an uchar pointer to qImage fist byte.
  23. //After having filled the texture array,I use the draw method:
  24.  
  25. void draw()
  26. {
  27.    glBindTexture(GL_TEXTURE_2D, textures[somevalue]);
  28.    // Any drawing here will use somevalue texture
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement