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

Author Topic: Image wont draw...  (Read 2460 times)

0 Members and 1 Guest are viewing this topic.

Christopher Jozwiak

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Blog
    • Email
Image wont draw...
« on: December 23, 2011, 11:35:54 pm »
No errors, I have my clear set too 0,255,255 and my image is black. Here's the code.

Code: [Select]
// SFMLWindow.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main()
{

sf::RenderWindow Screen(sf::VideoMode(1024, 768, 32), "SFML-Window");

while(Screen.IsOpened())
{
sf::Image image;
if(!image.LoadFromFile("sprite.png"))
return EXIT_FAILURE;

sf::Sprite sprite(image);
Screen.Draw(sprite);
Screen.Clear(sf::Color(0,255,255));
Screen.Display();


sf::Event Event;
while (Screen.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
Screen.Close();
}

}


return EXIT_SUCCESS;
}

Noob C++ Programmer.

Pyrius

  • Newbie
  • *
  • Posts: 39
    • View Profile
Image wont draw...
« Reply #1 on: December 23, 2011, 11:42:05 pm »
You're clearing the screen after you draw the sprite.

Anata

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Image wont draw...
« Reply #2 on: December 24, 2011, 12:40:17 am »
Code: [Select]
     sf::Image image;
      if(!image.LoadFromFile("sprite.png"))
         return EXIT_FAILURE;
       
      sf::Sprite sprite(image);


Not in the While.

And Clear always before your Draw

 

anything