SFML community forums

Help => Graphics => Topic started by: nagimar on October 27, 2020, 08:47:25 pm

Title: Problem with sf::Image
Post by: nagimar on October 27, 2020, 08:47:25 pm
Hi! I want to get the pixels of 6 framebuffer textures, and load them to a cubemap texture.

So I use the copyToImage function and then I load the 6 images to my cubemap like this :

images.clear();
                        for (unsigned int m = 0; m < 6; m++) {
                            math::Vec3f target = reflectView.getPosition() + dirs[m];
                            reflectView.lookAt(target.x, target.y, target.z);
                            std::vector<Entity*> visibleReflEntities = World::getEntitiesInRect(reflectView.getViewVolume(), expression);
                            std::vector<Entity*> copy;
                            for (unsigned int j = 0; j < visibleReflEntities.size(); j++)  {
                                if (visibleReflEntities[j]->getRootEntity() != reflectEntity) {
                                    copy.push_back(visibleReflEntities[j]);
                                }
                            }
                            pplls[m]->loadEntitiesOnComponent(copy);
                            pplls[m]->setView(reflectView);
                            pplls[m]->clear();
                            pplls[m]->drawNextFrame();
                            images.push_back(pplls[m]->getFrameBufferTexture().copyToImage());                          
                        }
                        int width = view.getSize().x;
                        int height = view.getSize().y;
                        cubeMapTex.createCubeMap(width, height, images);
 

When I display image pixels it seems to be good but when I want to pass the image pixels to the cubemaps textures, those textures are empty.

I used gDEBUgger to see what's happening and, it displays the pointer to image's pixels in the glTexImage2D function, but it doesn't fill the texture because the texture is empty when I display it in the gDEBugger view.

It seems there is a problem with the getPixelsPtr() function when I copy FBO texture to image.

Isn't there another way to do to copy my FBO textures to my cube map ? It doesn't seems to be a good way of doing this.
Title: Re: Problem with sf::Image
Post by: nagimar on October 27, 2020, 09:48:55 pm
I didn't see it earlier but I've a GL_INVALID_OPERATION error while calling glTexImage2D, it'll be hard to debug because gl doesn't gives a lot of information about this error...

EDIT : I had to enable GL_TEXTURE_CUBE_MAP before loading the texture but now I've another error : GL_INVALID_VALUE.
 
Title: Re: Problem with sf::Image
Post by: nagimar on October 27, 2020, 11:04:34 pm
Problem solved I had to create cube map textures with the same width and height because it's a cube!

I'm so stupid sometimes hahahaha. ;D