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

Author Topic: Problems with repeated textures in a big rectangle shape  (Read 1273 times)

0 Members and 1 Guest are viewing this topic.

Carlmycol

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Problems with repeated textures in a big rectangle shape
« on: March 19, 2015, 12:47:05 am »
Hello mates,

I'm using SFML to make a basic platformer game, so I can learn some concepts of the library. I run my application I get something beautiful, just look at 1.png (in attached files). When I move the app. to another PC, it doesn't run as well as it run in my laptop (2.png)

I'm trying to see where is my error, or how can I solve this... I think, there are driver problems in the PC... But that's only a conjeture... I hope you guys can give me a hand of help here...

Here is a part of my code:

// main.cpp
#include <iostream>
#include <Box2D/Box2D.h>
#include <SFML/Graphics.hpp>
..

int main() {
......
       
        std::vector<Block> bloques;
        // Este vector de bloques va a contener plataformas y objetos
        sf::Texture grass;
        grass.loadFromFile("grass.png");
        grass.setRepeated(true);
        grass.setSmooth(true);

        bloques.push_back(Block(world, 3000.0f, 50.0f, sf::Vector2f(-200, height - 50.0f), .5f, false, 0, 0, &grass));
        //Esto es un suelo!


        sf::Texture bricks;
        bricks.loadFromFile("bricks.jpg");
        bricks.setRepeated(true);
        bricks.setSmooth(true);

        bloques.push_back(Block(world, 400.0f, 49.0f, sf::Vector2f(300, 300), .5f, false, .5f, 0, &bricks));
        bloques.push_back(Block(world, 400.0f, 49.0f, sf::Vector2f(850, 100), .5f, false, .5f, 0, &bricks));
        // Inicializamos algunas plataformas

        //Agregamos un objeto dinamico...
        sf::Texture box;
        box.loadFromFile("box.png");
        box.setSmooth(true);
        bloques.push_back(Block(world, 100.0f, 100.0f, sf::Vector2f(450, 150), .5f, true, .5f,  0.0f, &box));


        // Game loop
        while (App.isOpen())
        {

.....
                App.clear();
.....

                // Dibuja objetos
                for (int i = 0; i < int(bloques.size()); i++)
                {
                        App.draw( bloques[i].GetShape() );
                }

......
                App.display();

 ......

        }



        return 0;
}

 


And this is the block.cpp (only the constructor and getShape())
Block::Block(b2World *world, float width, float height, sf::Vector2f position, float mu, bool dynamic, float density, float e, sf::Texture *t)
{

        rectangle = sf::RectangleShape( sf::Vector2f(width, height) );
        rectangle.setPosition(position);
        rectangle.setTexture(t);
        rectangle.setTextureRect(sf::IntRect(0, 0, width, height));


        ........


}

sf::Shape & Block::GetShape()
{
        return rectangle;
}

 

The variable "rectangle" is a part of the class "Block". Thanks in advance!

Greetings!
« Last Edit: March 19, 2015, 01:01:27 pm by Carlmycol »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: Problems with repeated textures in a big rectangle shape
« Reply #1 on: March 19, 2015, 09:44:48 am »
There's a high probability that nobody will answer, since posting a lot of code with a very vague error description is most of the time not useable information.

You've the full code and executable, as welk as a PC that creates the issue, thus use a debugger and find out what's going wrong.

Did you update the driver of the PC's GPU as well?
What are the specs of the PC?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Carlmycol

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Problems with repeated textures in a big rectangle shape
« Reply #2 on: March 19, 2015, 01:00:47 pm »
Hi eXpl0it3r,

What extra information should I give about this issue?

I don't have the compiler working in that computer since it is a family PC. It's an intel core 2 duo with the default gpu (express chipset family). I sent the app to a friend and runs perfectly.

I'm really sorry for my bad english, please tell me if I do grammatical and orthographic errors.

Greetings!

 

anything