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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Mathhead200

Pages: [1]
1
General / Simple SFML program, doesn't display or terminate correctly
« on: April 07, 2011, 07:19:40 pm »
Where can I download SFML verson 2.0?
From the looks of the download page it's still a beta verson.
Can someone give me a link?

Are there any other possible explanations, in my code alone? (i.e. Maybe it's not a bug.)

2
General / Simple SFML program, doesn't display or terminate correctly
« on: April 07, 2011, 06:29:24 am »
Okay, it displays correctly now. I was under the impression that the Window::Draw method would add the sprites to some sort of rsc list in the window, and then Window::Display would show them.
Thanks for clearing that up.

I'm still having the termination problem. Do you think it has anything to do with the ~Sprite deconstructor?

3
General / Simple SFML program, doesn't display or terminate correctly
« on: April 06, 2011, 10:43:44 pm »
The code compiles using cl.exe (VC++) fine, and run correctly if I omit lines 22-26 (from Sprite(me) to Draw(you)); however, when I run the program, the sprites don't display, and when I close the window I see the 'Goodbye!' message but then the program doesn't close correctly (i.e. 'windows is checking for a solution to your problem...')

This is the first SFML program I've written using sprites, can someone explain where (or what) the problem is?

Code: [Select]

#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

using namespace std;
using namespace sf;

int main()
{
RenderWindow window( VideoMode(400, 300), "Hello SFML", Style::Titlebar | Style::Resize | Style::Close );
Event e;

//initialize two sprites
const int WIDTH = 32, HEIGHT = 32;
Image myImg( WIDTH, HEIGHT, Color(0, 0, 0, 0) ),
yourImg( WIDTH, HEIGHT, Color(0, 0, 0, 0) );
for( int i = 0; i < WIDTH && i < HEIGHT; i++ ) {
myImg.SetPixel( i, i, Color(200, 0, 0) );
yourImg.SetPixel( WIDTH - 1 - i, i, Color(0, 200, 200) );
}
Sprite me(myImg), you(yourImg);
me.SetPosition(0.f, 0.f);
you.SetPosition( (float)WIDTH, (float)HEIGHT );
window.Draw(me);
window.Draw(you);

//display the window
do {
window.Clear( Color(255, 255, 255) );
window.Display();
while( window.GetEvent(e) ) {
switch(e.Type) {
case Event::Closed:
window.Close();
break;
case Event::KeyPressed: {
Key::Code k = e.Key.Code;
if( k == Key::Return )
cout << endl;
else if( k == Key::F1 ) {
window.Capture().SaveToFile("screenshot.png");
cout << "Screenshot, saved to file: screenshot.png" << endl;
} else if( ('a' <= k && k <= 'z') || ('A' <= k && k <= 'Z') || ('0' <= k && k <= '9') )
cout << (char)e.Key.Code;
break;
} case Event::MouseButtonPressed:
if( e.MouseButton.Button == Mouse::Left )
cout << "Framerate = " << 1.0 / window.GetFrameTime() << endl;
break;
}
}
Sleep(0.25f);
} while( window.IsOpened() );

cout << "\nGoodbye!\n";
return 0;
}


Pages: [1]
anything