Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GLuint texture[meshes_number]; // 1 mesh = 1 texture
- int globalcounter=0;
- //Then I create the following function:
- void GeneratePlusBindTextures (&scene){
- (for every mesh on current scene) {
- (if current mesh has got a not null Qimage texture){
- glEnable(GL_TEXTURE_2D);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glGenTextures(1, &texture[globalcounter]); // Create The Texture
- glBindTexture(GL_TEXTURE_2D, texture[globalcounter]);
- glTexImage2D(GL_TEXTURE_2D, 0, 3, 256 , 256 , 0, GL_RGB, GL_UNSIGNED_BYTE, p.Mat().GetTexture()->Data() );
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
- glDisable(GL_TEXTURE_2D);
- globalcounter++;
- }
- }
- //where p.Mat().GetTexture()->Data() returns an uchar pointer to qImage fist byte.
- //After having filled the texture array,I use the draw method:
- void draw()
- {
- glBindTexture(GL_TEXTURE_2D, textures[somevalue]);
- // Any drawing here will use somevalue texture
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement