3 Replies - 579 Views - Last Post: 24 April 2013 - 08:01 AM Rate Topic: -----

#1 B0rn2c0de  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 11-April 13

sprites displayed as white rectangles

Posted 21 April 2013 - 12:21 PM

hey guyz i am using sfml nd visual studio 2008 express nd i dont know why but any spite i display gets displayed only as white rectangle , no texture .. rest all the functions are working fine ... heres my code
 #include <SFML/Graphics.hpp>
#include <iostream>
#include "stdafx.h"
int main()
{
sf::Vector2<float> v1 ;
sf::Texture text ;
text.loadFromFile("Actor1.png");
sf::Sprite sprite;
sprite.setTexture(text);
sprite.setOrigin(3,4);
sprite.setTextureRect(sf::IntRect(10, 10, 50, 30));

    sf::RenderWindow window(sf::VideoMode(640, 480), "SFML works!");
	    while (window.isOpen())
    {   sf::Event x;
        while (window.pollEvent(x))
        {
			if (x.type == sf::Event::Closed)
			{window.close();}
			if(x.type == sf::Event::MouseMoved)
			{sprite.setPosition(x.mouseMove.x,x.mouseMove.y);}
			
        }
        window.clear();
        window.draw(sprite);
        window.display();
		
		}

    return 0;
}




i have already checked the file destination and it was correct
thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: sprites displayed as white rectangles

#2 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,303
  • Joined: 22-October 08

Re: sprites displayed as white rectangles

Posted 22 April 2013 - 12:24 AM

Hi, I'm no expert at SFML but shouldn't you it be in this order:

sprite.setTextureRect(sf::IntRect(10, 10, 50, 30));
sprite.setTextutre(text);



Also, are those co-ordinates even correct corresponding to your Actor1.png image?
Was This Post Helpful? 0
  • +
  • -

#3 B0rn2c0de  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 11-April 13

Re: sprites displayed as white rectangles

Posted 22 April 2013 - 03:30 AM

Nopes tried it dosent work nd any ways even if i dont use that settexturerec() function the image is still displayed as a white rectangle .. Just the difference is that if i dont use it there is a big white rectangle .. If i do there is a small corresponding to the coordinates specified
Was This Post Helpful? 0
  • +
  • -

#4 B0rn2c0de  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 11-April 13

Re: sprites displayed as white rectangles

Posted 24 April 2013 - 08:01 AM

ok .. so i checked on google and it said there that my texturee was no longer in memory .. thats why this happens ,, but why does my texture goes out of memory .. what can i do to fix it ??
guyzz please help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1