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

Author Topic: [SOLVED] SFML 1.6 w/ VB 2011 Beta - Cannot Draw Sprite  (Read 1918 times)

0 Members and 1 Guest are viewing this topic.

Insider55

  • Newbie
  • *
  • Posts: 2
    • View Profile
[SOLVED] SFML 1.6 w/ VB 2011 Beta - Cannot Draw Sprite
« on: May 14, 2012, 09:24:30 pm »
Hello all,
I'm almost to my final straw with SFML. I can't get it to work! As soon as I clear up one error, another pops up! I can't wait to get started using it, but I can't with all these errors.

In the beginning, I got an error whenever I closed a RenderWindow, something about the stack around the VideoMode object being corrupted. However, I rectified this after I followed a tutorial to recompile the vb2008 version of SFML for newer versions.

But now, I have two issues. First, my RenderWindow has odd symbols at the top of it instead of the title I set in the constructor. Second, when I try to set the image of a sprite or to draw the sprite, I get this error:
Code: [Select]
Unhandled exception at 0x6FFB576E (msvcp110.dll) in sfml-sandbox.exe: 0xC0000005: Access violation reading location 0x0025E000.Just before this error is thrown, the console behind my RenderWindow is spewing thousands of lines of meaningless ASCII symbols.

Here is some information about my system, including the code I used:

OS: Windows 7 Home
IDE: Microsoft Visual C++ 2011 Beta (although I've tried the same with 2010)
SFML: 1.6; I rebuilt the entire library using the newer version of C++

Code:
Code: [Select]
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
using namespace sf;

int main() {
VideoMode v(800,600);
RenderWindow w(v,"Test");

Image face;
if (!face.LoadFromFile("HappyFace.png")) {
return 1;
}

Sprite faceSprite;
faceSprite.SetImage(face);

while (w.IsOpened()) {
Event e;
while (w.GetEvent(e)) {
if (e.Type == Event::Closed) {
w.Close();
}
}
w.Clear(Color(0,255,255));
w.Draw(faceSprite);
w.Display();
}

return 0;
}

Thank you in advance for your help! :)


EDIT:
After commenting out the "while" loop of my code, I realized that an error is also thrown when I do faceSpirte.SetImage(face);
I don't know which section of code is causing this, although I would guess it is the first.
« Last Edit: May 21, 2012, 02:46:07 am by Insider55 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML 1.6 w/ VB 2011 Beta - Cannot Draw Sprite
« Reply #1 on: May 14, 2012, 10:56:10 pm »
Use the debug libraries in debug mode, don't mix debug and release.
Laurent Gomila - SFML developer

Insider55

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SFML 1.6 w/ VB 2011 Beta - Cannot Draw Sprite
« Reply #2 on: May 21, 2012, 02:45:46 am »
Thanks for your help. With your help and a little messing around with where I put my image file, my problem was fixed, and now I'm learning SFML without issues.

Thanks again!! :D