Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Texture position  (Read 911 times)

0 Members and 1 Guest are viewing this topic.

catalinnic

  • Newbie
  • *
  • Posts: 19
    • View Profile
Texture position
« on: August 24, 2019, 09:47:19 am »
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);
};
 
« Last Edit: August 24, 2019, 09:49:11 am by catalinnic »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture position
« Reply #1 on: August 24, 2019, 01:16:00 pm »
I'm not sure what you're asking. You should try to clarify.

And std::memcmp a sf::Texture? Are you sure? That's usually not something we do with C++ instances.
Laurent Gomila - SFML developer

catalinnic

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Texture position
« Reply #2 on: August 24, 2019, 01:18:37 pm »
about that, i gave up on that

 

anything