Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: OpenGL SFML GLEW Setup Not Working Access Violation Exception

  1. #1
    Newbie Newbie
    Join Date
    Jan 2014

    OpenGL SFML GLEW Setup Not Working Access Violation Exception

    I am currently attempting to get started with OpenGL using SFML and GLEW. The problem I am having is with GLEW.

    The code is as follows:

    Code :
    #include <GL/glew.h>
    #include <SFML/Window.hpp>
    #include <SFML/OpenGL.hpp>
    int main()
    	//Initialize Glew
    	glewExperimental = GL_TRUE;
    	GLuint vertexBuffer;
    	glGenBuffers(1, &vertexBuffer); //*
    	printf("%u\n", vertexBuffer);
        // create the window
        sf::Window window(sf::VideoMode::getDesktopMode(), "IsoWars", sf::Style::Fullscreen, sf::ContextSettings(32));
        // load resources, initialize the OpenGL states, ...
        // run the main loop
        bool running = true;
        while (running)
            // clear the buffers
            // draw...
            // end the current frame (internally swaps the front and back buffers)
            // handle events
            sf::Event event;
            while (window.pollEvent(event))
    			switch (event.type)
    			case sf::Event::Closed:
                    // end the program
                    running = false;
    			case sf::Event::KeyPressed:
    				switch (event.key.code)
    				case sf::Keyboard::Escape:
    					running = false;
        // release resources...
        return 0;

    The call to 'glGenBuffers(1, &vertexBuffer);' gives an access violation similar to this (which the forum wont let me post):

    http colon slash slash s54.photobucket dot com/user/azoundria/media/unhandledexception_zps3908c912.png.html

    If I comment that out, the program runs fine. I need to get GLEW working/configured properly.

    I'm using Microsoft Visual C++ 2010. Here is my configuration (again sorry - the forum wont let me post images properly):

    http colon slash slash s54.photobucket dot com/user/azoundria/media/linkerinput_zps35c5db14.png.html

    http colon slash slash s54.photobucket dot com/user/azoundria/media/linker-input_zpsd8404d4a.png.html

    http colon slash slash s54.photobucket dot com/user/azoundria/media/additionalinclude_zpsa32e9b3a.png.html

    http colon slash slash s54.photobucket dot com/user/azoundria/media/additionallibrary_zps941fe777.png.html

    My system is 64 bit. I've tried both glew32.dlls that come with it, and both glew32s.dlls (with the GLEW_STATIC #defined). Does anyone know what I've done wrong in the setup?

  2. #2
    Intern Newbie
    Join Date
    Nov 2002
    First, open your window to get a valid opengl context.
    Then,initialize glew and then you should be able to start making opengl calls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts