3
\$\begingroup\$

Hi I started today to make an OpenGL program, I made the shader class, mesh class and texture class. When I tried to test it, it stopped working. After a little debug with Visual Studio(thanks Microsoft for this useful tool). It showed me that my problem is:

glGenVertexArrays(1, &m_vao);

I use glew. I searched on internet, and I found that glewExperimental needs to be GL_TRUE, so I init it like this:

glewExperimental = GL_TRUE;
GLenum error = glewInit();
if (error != GLEW_OK)
    std::cerr << "Glew: " << glewGetErrorString(error);

nothing changed.

Error given by Visual Studio:

Exception thrown at 0x00000000 in DirtyCraft.exe: 0xC0000005: Access violation executing location 0x00000000. occurred

I do use Glew 2.0.0, 32-bits, SDL2.

If you need any additional information, feel free to request them.

\$\endgroup\$
  • \$\begingroup\$ (1) what graphics hardware have you? (2) did you call glewInit before or after creating your GL context? \$\endgroup\$ – Maximus Minimus Jul 31 '17 at 18:16
  • \$\begingroup\$ I have a gtx 950, and glewInit is called after context creation, it's the last part of the window constructor \$\endgroup\$ – Laceanu George Jul 31 '17 at 18:42
  • \$\begingroup\$ Thanks. Are you able to create shaders and buffers or do you crash on those too? Rearrange some code if necessary. Right now it seems as though you're not getting a hardware-accelerated GL context. \$\endgroup\$ – Maximus Minimus Jul 31 '17 at 20:13
  • \$\begingroup\$ I'm not at my pc, but it could be a problem of linking? \$\endgroup\$ – Laceanu George Jul 31 '17 at 22:01
  • \$\begingroup\$ Btw, shaders works, not tested them, but I saw compile errors. \$\endgroup\$ – Laceanu George Jul 31 '17 at 22:01
1
\$\begingroup\$

The Window that holds the rendering must be opened first. Also, you need to call glew first before calling any opengl functions.

\$\endgroup\$
  • 1
    \$\begingroup\$ thank you, but I solved. Somehow glDrawElements was messing up something in glew, so I reinstalled glew \$\endgroup\$ – Laceanu George Aug 9 '17 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.