SFML community forums
Help => General => Topic started by: MadMartin on July 30, 2008, 02:35:58 pm
-
Hi everybody,
today I started to make a skeleton for any applications I'm going to create. It's a very simple Application class:
Header:
#ifndef H_APPLICATION
#define H_APPLICATION
#include <SFML/Graphics.hpp>
class Application {
public:
int Run();
private:
bool InitApp();
sf::RenderWindow MainWindow;
};
#endif
Implementation:
#include "Application.h"
int Application::Run(){
if (!InitApp()){
return -1;
}
while (MainWindow.IsOpened()){
// Process events
sf::Event Event;
while (MainWindow.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
MainWindow.Close();
}
// Display window contents on screen
MainWindow.Display();
}
return 0;
};
bool Application::InitApp() {
MainWindow.Create(sf::VideoMode(640, 480), "TheEye");
return true;
};
main.cpp
#include "Application.h"
int main() {
Application TheApp;
return TheApp.Run();
}
As you see, I'd like to seperate initialisation, event handling etc in seperate methods of my class Application. Straight OOP.
My Problem now is a exception that occurs just after closing the window in Release mode.
Error message is A buffer overrun has occurred in TheEye.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.
The program breaks at line 298 in the file gs_report.c from Microsoft.
Any ideas how to solve this? CRT is dynamically linked, Unicode enabled, I'm using sfml-main-d.lib, sfml-window-d.lib and sfml-graphics-d.lib in Debug mode and sfml-main.lib, sfml-window.lib and sfml-graphics.lib in Release mode.
greetings
Martin
-
Did you try disabling Unicode ?
Did you try dynamic / static SFML libraries ?
You don't mix release and debug libraries ?
-
Ok, tried out you suggestions:
- Unicode makes no difference
- no mix up in libraries
Then I switched to static linking, had to add sfml-system.lib and now it works without errors. But it won't work with dynamic linking though.
That is not bad, I don't care if I need to deploy the DLLs and I don't care about the file size. Nonetheless I'm curious what's the problem at this very point.
By the way: Should I link to the CRT statically or dynamically when using SFML? Or link the same way I did to SFML? Or does it make no difference whether I use dynamic or static linking?