I'm completely unsure of why I'm getting this error in VS2012 when I run my program. Visual Studio seemed to direct the problem towards sf::RenderWindow Articx::window;
in Articx.cpp
Unhandled exception at 0x777122D2 (ntdll.dll) in ArticxEngine.exe: 0xC0000005: Access violation writing location 0x00000004.
Code Articx.h
#pragma once
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
class Articx
{
public:
static void Start();
private:
static void GameLoop();
static bool isExiting();
enum ScreenState {before, splash1, splash2, splash3, menu, pause, playing, exit};
static ScreenState currentState;
static sf::RenderWindow window;
};
Code Articx.cpp
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <iostream>
#include <string>
#include "Articx.h"
inline void Message(char message[]);
inline void CallError(int code, char message[]);
Articx::ScreenState Articx::currentState = Articx::before;
sf::RenderWindow Articx::window;
void Articx::Start()
{
Message("Articx Engine 1.0 Initializing...");
if(currentState != before)
return;
window.create(sf::VideoMode(800,600,32), "Articx Engine 1.0");
currentState = playing;
while (!isExiting())
{
Message("Engine Initialized");
Articx::GameLoop();
}
window.close();
}
bool Articx::isExiting()
{
if(currentState == exit)
return true;
else
return false;
}
void Articx::GameLoop()
{
sf::Event currentEvent;
while ( window.pollEvent(currentEvent) )
{
switch(currentState)
{
case Articx::playing:
{
window.clear(sf::Color(0,0,0));
window.display();
if ( currentEvent.type == sf::Event::Closed )
currentState = exit;
break;
}
}
}
window.display();
}
inline void CallError(int code, char message[])
{
std::cout << "ERROR CODE - " << code << std::endl << message << std::endl << "Will now exit..." << std::endl;
system("PAUSE");
}
inline void Message(char message[])
{
std::cout << "AX-MESSAGE: " << message << std::endl;
}
Code main.cpp
#include "Articx.h"
using namespace std;
int main(int argc, char** argv)
{
Articx::Start();
return 0;
}