SFML community forums
Help => Graphics => Topic started by: Rexona for men on October 25, 2011, 02:03:39 pm
-
Hello guys
I got an access Violation while loading an Image.
Here is the Error code:
Unbehandelte Ausnahme bei 0x10189024 (sfml-graphics-d.dll) in SFML Game.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0xcccccd00.
( In English: Unhandled Exception in Game.exe, Access Violation reading at position)
And here some of the source code (which isnt well designed atm =P)
void Game::InitBackground ()
{
I_Background->LoadFromFile ("Graphic/background.tga");// here it chrashes
// just some tests with random numbers
S_Background->SetImage (*I_Background);
S_Background->Resize (800, 600);
S_Background->SetPosition (0.0, 0.0);
S_Background->SetCenter (0.0, 0.0);
}
This should be the critical part as the debugger "told" me.
Additional the declaraton of class Game:
class Game
{
public:
Game (unsigned width, unsigned height, unsigned pixelformat);
~Game ();
void InitGame ();
void RenderProcedure ();
private:
void InitBackground ();
sf::RenderWindow* Window;
sf::Image* I_Background;
sf::Sprite* S_Background;
};
And Another question:
Which picture formats do SFMl support?
Cant find somethin about this in the documentation.
-
By the way, Libaries should be correctly linked.
The folder Graphic is in the same folder as the code datas.
-
Your pointers are probably not initialized properly.
But you don't need pointers at all, anyway. Just get rid of them ;)
Which picture formats do SFMl support?
It's listed there:
http://www.sfml-dev.org/features.php
-
Problems seems to be solved and thx for the list, I didnt think about it =P
However, now I have a new Problem.
After first creating, even before clearing, the window is closed immediatly.
(Probably just a stupid mistake by me =S)
Here the reworked sourece code of the memberfunctions of Game
#include "Game.hpp"
Game::Game ()
{
// do nothing atm
}
Game::~Game ()
{
// do nothing atm
}
void Game::InitGame ()
{
sf::RenderWindow (sf::VideoMode (800, 600, 32), "Game");
InitBackground ();
}
void Game::RenderProcedure ()
{
while (Window.IsOpened () )
{
sf::Event Event;
while (Window.GetEvent (Event) )
{
if (Event.Type == sf::Event::Closed)
Window.Close ();
}
Window.Clear ();
Window.Draw (S_Background);
Window.Display ();
}
}
void Game::InitBackground ()
{
I_Background.LoadFromFile ("background.tga");
S_Background.SetImage (I_Background);
S_Background.Resize (800, 600);
S_Background.SetPosition (0.0, 0.0);
S_Background.SetCenter (0.0, 0.0);
}
-
sf::RenderWindow (sf::VideoMode (800, 600, 32), "Game")
You're calling the constructor of RenderWindow but without creating an instance of it. The consequence is that a new window is created and destroyed immediately. I think you want to call Window.Create(...) instead.
-
Yeah thx =D
Now all is working fine