using SDL - but cant recognise opengl

Started by
1 comment, last by mounty0 17 years, 2 months ago
I've setup SDL under Visual Studio 03 to use with OpenGL, and I can include the SDL.h and SDL_opengl.h headers alright, but when I try to run OpenGL commands the compiler doesnt recognise them and gives the 'unresolved external symbol' error, and I cant really figure out why. I setup SDL by: Copied SDL.lib and SDLmain.lib to Microsoft Visual Studio .NET 2003\Vc7\lib Copied the SDL .h files in the zip's include folder to Microsoft Visual Studio .NET 2003\Vc7\Include\SDL Copied SDL.dll to Windows\System32 Set the Project Properties --> Cplusplus --> Code Generation --> Runtime Library to: Multi-threaded DLL Set the Project Properties --> Linker --> Input --> Additional Dependencies to: SDL.lib SDLmain.lib I can compile this code ok:

#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"

int main(int argc, char* args[]) 
{
    SDL_Init(SDL_INIT_EVERYTHING);	
    SDL_Quit();
	
    return 0; 
}


But when I try to include an OpenGL command I get the 'unresolved external symbol' error:

#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"

void initOpenGL()
{
    glClearColor(0,0,0,0);
}

int main(int argc, char* args[]) 
{
    SDL_Init(SDL_INIT_EVERYTHING); 	
    SDL_Quit();

    return 0; 
}


Would anyone have any ideas what might be the problem, as none of the guides I read mentioned anything additional being required to get SDL_opengl up and running. Thanks all
Advertisement
Firstly SDL_Init(SDL_INIT_EVERYTHING) doesnt actually set up OpenGL, to do that oyu need to set a screen mode using:
SDL_SetVideoMode(width, height, bpp, SDL_OPENGL);

And also SDL.lib doesnt include the openGL lib. You will need to link openGL too, usually its called opengl32.lib (if not you may have to google for its name).
ahh ok I see, I stuck opengl32.lib into 'Additional Dependencies' with the other libraries and it compiles now, thanks much ;)

This topic is closed to new replies.

Advertisement