Search code examples
c++sdlsfml

Access violation on c++ graphics library


I'm trying to get a project started which will have a basic Graphical display for representing some data. For it, I was initially going to use SFML as I have already used it and had a lot of success.

However, after repeating the tutorial I've used before in previous projects from http://gamecodeschool.com/sfml/building-your-first-sfml-game-project/ to get the basic linkages/compiler settings set up, I'm getting an error on the window.display() the line saying it is an access violation. I've scoured the web and looked through all sorts of answers and have double checked to no avail:

  1. Using the debug library
  2. Using the 32-bit version.
  3. Correct Linker Inputs

I gave up and decided to try SDL, however after also following a tutorial to the T where the supplied test code worked which initialized all modules, i tried some basic game loop code (draws a rectangle to the screen) and got another access violation in an almost identical fashion on the SDL_RenderPresent(renderer), aka same function for rendering in the SDL version as SFML.

I, therefore, think there is some underlying issue that is meaning anytime I try to update the screen my computer is throwing an error. The only thing that has changed since I last used SFML is that I'm now using a monitor connected to my laptop via a dock, but I don't see how that could affect things.

Anyone had any experience with this?

Code of two situations below:

EDIT SFML:

#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);

while (window.isOpen())
{
    sf::Event event;
    while (window.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            window.close();
    }

    window.clear();
    window.draw(shape);
    window.display();
}

return 0;}

SDL: Over 150 lines but I have copied it straight from http://headerphile.com/sdl2/sdl2-part-3-drawing-rectangles/ (bottom of the page)


Solution

  • So after looking into the dll that was causing the issue ig9icd32.dll , It appeared to be an OPENGL component. So I reinstalled the graphics drivers and everything appears to be working!