Search code examples
c++openglsdl-2glewunresolved-external

Where is glClear and glClearColor defined using GLEW and SDL2?


I'm using windows 10, vs 2019, GLEW 2.1.0, and SDL2. I'm pretty sure that I have everything linked. I've triple checked.

I have all the version information and stuff like that set, since I'm following lazyfoo's tutorial

I keep getting an error, however, where glClear and glClearColor are unresolved external symbols. I've narrowed down the issue to not including a file that I should (currently GL/glew.h, GL/glu.h, SDL.h, SDL_opengl.h). Does anyone know which file glClear is defined(not just declared) in?

I've tried going over my linker settings to no avail. Searching the internet yields no help after 3 hours, and I've found out that the files I include only declare glClearColor and glClear.


Solution

  • glClear and glClearColor are not extension functions but rather core GL 1.1 functionality, so GLEW doesn't wrap it. On windows, you need to link with opengl32 (or get function pointer it in runtime via e.g. SDL_GL_GetProcAddress, which could get both core and extension functions).