Hello, I have a huge image to load (5320x2880) and i want to load only the tiles and I don't know how set texture position, weirdly i read that OpenGL is capable to do that, how I can do that without touching OpenGL's functions? For more clarity this is what I have now:
#include "Big_rect.hpp"
#include <memory.h>
bool Big_rect::Load_from_file(const std::string& File_name)
{
sf::Image Image;
Image.loadFromFile(File_name);
sf::Vector2u Texture_size = Image.getSize();
for(uint i = 0; i < Texture_size.y; i += 32)
for (uint j = 0; j < Texture_size.x; j += 32)
{
/* code */
// When the texturing will happen
}
}
sf::Texture* Big_rect::Acquire_big_texture(sf::Image Big_image, sf::IntRect Big_texture_int_rect)
{
sf::Texture* tex;
tex->loadFromImage(Big_image, Big_texture_int_rect);
for(Big_texture_iter = Big_texture.begin(); Big_texture_iter != Big_texture.end(); Big_texture_iter++)
if(memcmp(*Big_texture_iter, tex, sizeof(sf::Texture)) == 0)
return *Big_texture_iter;
return tex;
}
and the header:
struct Big_rect: sf::RectangleShape
{
bool Load_from_file(const std::string& File_name);
std::vector< sf::Texture* > Big_texture;
std::vector< sf::Texture* >::iterator Big_texture_iter;
private:
sf::Texture* Acquire_big_texture(sf::Image Big_image, sf::IntRect Big_texture_int_rect);
};