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

Author Topic: Attempting to use GLEW and glCreateProgram, but getting Access Violations  (Read 2280 times)

0 Members and 1 Guest are viewing this topic.

Clairvoire

  • Newbie
  • *
  • Posts: 29
    • AOL Instant Messenger - Clairvoire
    • View Profile
    • http://clairvoire.deviantart.com
I am trying to #include extlibs/headers/GL/glew.h that came with SFML, but haven't quite got it to work out. 

If I link against glew.lib and run my program, I get warnings for
Commons.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewCreateProgram imported
And after creating the SFML render window instance, if the program uses glCreateProgram(), it'll get an access violation for trying to access a NULL address.

I've read that this may be because I am not calling glewInit(), but I have also read that I should not do this when using SFML because it already does it. 

I guess my question is, is there anything special I must do to use both GLEW and SFML, while statically linking to both of them?


Clairvoire

  • Newbie
  • *
  • Posts: 29
    • AOL Instant Messenger - Clairvoire
    • View Profile
    • http://clairvoire.deviantart.com
Re: Attempting to use GLEW and glCreateProgram, but getting Access Violations
« Reply #1 on: November 21, 2014, 03:13:08 pm »
I think I solved this finally! 

I got rid of the warning by updating both my code and sfml with the current GLEW library. 

I had to get glewInit() to be called to fix the access violation.  However, SFML calls it internally, in a structure that ensures it's only called once, but only if it itself does it.  (I can't call this from my code since it's not visible, the funciton is sf::priv::ensureExtensionsInit()) 

And it doesn't seem that merely creating a RenderWindow calls this.  So, what I did was after creating a window, I called sf::RenderWindow::ResetGLState(), which seems to make the call for me.  So now everything works as it should