Sign in to follow this  
Sisyphos

Problem starting out with SDL and OpenGL

Recommended Posts

I worked through most of Lazy Foos Tutorials on SDL without problems and am now trying to get the last one to work: [url="http://lazyfoo.net/SDL_tutorials/lesson36/index.php"]Using SDL with OpenGL 2.1[/url]

However, I can't even get the [url="http://lazyfoo.net/downloads/index.php?file=SDLTut_lesson36"]sample code[/url] to compile. I'm using Visual Studio 2010 and this is what I get:

[code]1>main.obj : error LNK2019: unresolved external symbol __imp__glGetError@0 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glOrtho@48 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glColor4f@16 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _SDL_main[/code]

Probably overlooking something really simple here. I tried searching whether I missed something I should have set up, but so far no luck.



On a related note, is OpenGL the way to go for 2D games with SDL or are there alternatives? (not looking to get into 3D just yet) I have read that the SDL renderer is rather slow, so I imagine I want some sort of hardware acceleration in any case.

On the other hand I'm not looking for a full blown engine, though; I need some programming practice and making a simple engine with a basic game (more of a tech demo) seems like a good place to start.



Thanks for any help.

Share this post


Link to post
Share on other sites
[quote name='Sisyphos' timestamp='1305916108' post='4813564']
I worked through most of Lazy Foos Tutorials on SDL without problems and am now trying to get the last one to work: [url="http://lazyfoo.net/SDL_tutorials/lesson36/index.php"]Using SDL with OpenGL 2.1[/url]

However, I can't even get the [url="http://lazyfoo.net/downloads/index.php?file=SDLTut_lesson36"]sample code[/url] to compile. I'm using Visual Studio 2010 and this is what I get:

[code]1>main.obj : error LNK2019: unresolved external symbol __imp__glGetError@0 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glOrtho@48 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glColor4f@16 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _SDL_main[/code]

Probably overlooking something really simple here. I tried searching whether I missed something I should have set up, but so far no luck.



On a related note, is OpenGL the way to go for 2D games with SDL or are there alternatives? (not looking to get into 3D just yet) I have read that the SDL renderer is rather slow, so I imagine I want some sort of hardware acceleration in any case.

Thanks for any help.



[/quote]

make sure opengl32.lib is linked with your project.

SDL 1.2 has a fairly slow 2D renderer, SDL 1.3 however has hardware acceleration for 2D aswell.

the "fairly slow" 2D renderer is fast enough for most 2D games, it just doesn't use hardware acceleration which makes some operations (realtime scaling/rotating/etc of sprites for example) a bit expensive. (This isn't necessarily a big problem as you can do those things in advance and cache the resulting sprites), (We had realtime 3D graphics done in software on ~100 mhz pentiums without any hardware acceleration, a modern machine won't break a sweat if you throw some 2D rendering at it, even if its a software renderer)

Share this post


Link to post
Share on other sites
*slaps head* I knew it had to be some stupid oversight like this (though in my defense the other tutorials always stated if there was something new to be linked). Thanks :)


SDL 1.3 sounds good, but a quick search reveals it's still in Beta. How stable/complete is it at this time?

And it's just those realtime manipulations I thought of. It seems tedious to prepare sprites compared to manipulating the objects directly. The OpenGL library looks pretty tedious (i.e. complex) in its own right, though, so we shall see :D



Edit: I'll be looking into sfml as well, thanks for the suggestion.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this