Using SDL/OpenGL, need help.
Here's what I have:
Code:
#include<iostream> Code:
kornerr@darkstar:~/cpp$ g++ -o SDLtry SDLtry.cpp What's wrong? Thanks. |
You have to link it with libSDL.so with the -lSDL flag.
|
Thanks, kjordan.
|
I think I've made all what described at Cone3D prorgamming "GFX with SDL"
in the 3rd chapter. I've made only little change - instead of ints used as bools I've used bools itself. Well, now I can't run an app. I get "Fatal signal: Segmentation Fault (SDL Parachute Deployed)" when DrawScene tries to "SDL_Flip (screen)". When I comment the string with Flip, app works. Can changing ints to bools make the app fail? (probably not) If not, what can be wrong? The downloaded source works just fine. Thanks. |
Possibly, I'm pretty sure SDL is written in C where theres no such thing as a true bool. If you change your bools back to ints and it works then you've isolated the problem ;)
|
Are you changing the ints to bools on callback functions? Callback functions usually have to have a specifically defined prototype, and if you are changing the prototype of those, bad things can happen.
|
You won't believe. I've changed all files according to the tutorial. And in main () I found a redeclaration of
SDL_Surface *screen, which was declared above all funcs in the same file. I can only wonder why compiler couldn't see redeclaration. Because it was a pointer? Seems very strange to me. Thanks for help anyway. |
Code:
kornerr@darkstar:~/cpp/SDL/1GL$ make I have "glu.h" in the same dir where "gl.h" is. What should I do? Thanks. |
GLU.h is not the library, it is the header file. There is a big difference. The .h files just store a bunch of declarations for stuff that is compiled as object code in the library, which is linked at runtime. (In this case by using -lGLU.)
So, the file that it is saying it cannot find is NOT glu.h, but rather libGLU.so... Try to find that file in /usr/lib, /usr/local/lib, or /usr/X11/lib. If it is in /usr/X11R6/lib, you may have to add that path to the library search path by including -L/usr/X11R6/lib. If you can't find it in any of those paths, try to find it with locate or find. If you don't find it, you may not have it installed on your system, so look for the OpenGL development library package for whatever distro you use. |
Thanks, deiussum.
|
|
The problem appears to be that you are not calling the draw function until is_active is true. When you first start up the window, that seems to stay false until you do something like switch to another window and switch back. If you do that, everything displays just fine. I haven't used SDL enough to know much about the SDL_ACTIVEEVENT that you are using to set is_active to true, but I didn't do that at all for the few SDL OpenGL apps I have written...
Here's an example of the SDL message processing loop of one of my own SDL apps: Code:
bool bRun = true; |
Unfortunately, problem is not in event handling.
I've changed code a bit to make sure DrawGLScene is executed. code screenshot I even commented all event handling and did just Code:
- - - Any suggestions? Thanks. ~~~Edit~~~ Now the first link works, sorry for few minutes. |
Well, on my system it definitely IS the event handling that isn't working correctly. I commented out if (is_active) and it works like a charm...
What video card and drivers are you using? |
Drv: NVIDIA-Linux-x86-1.0-7664-pkg1.run
Card: gf4mx440 Lib: SDL-1.2.8 |
All times are GMT -5. The time now is 02:38 PM. |