Problem starting out with SDL and OpenGL

Started by
2 comments, last by Sisyphos 12 years, 11 months ago
I worked through most of Lazy Foos Tutorials on SDL without problems and am now trying to get the last one to work: Using SDL with OpenGL 2.1

However, I can't even get the sample code to compile. I'm using Visual Studio 2010 and this is what I get:

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


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.
Advertisement

I worked through most of Lazy Foos Tutorials on SDL without problems and am now trying to get the last one to work: Using SDL with OpenGL 2.1

However, I can't even get the sample code to compile. I'm using Visual Studio 2010 and this is what I get:

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


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.





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)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
sfml is the library you should be using. It runs on top of OpenGL, and it's a 2D library. It's very slick, and you can use the underlying OpenGL as well.

sfml-dev.org

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

*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.

This topic is closed to new replies.

Advertisement