OpenGL is running slowly

Hey, new member here, big question. let me just go through the basic things
that I want you to know before I ask my question.

  1. Using SDL for OpenGL runs program very slow.
  2. Using GLUT for OpenGL run program fine.
  3. When SDL does OpenGL, event-handling is extremely slow.
  4. I want GLUT, because it works, but I want to use event handling of SDL.
  5. To do 4., I must open an SDL rendering context and the GLUT window.
    (keyboard handling)

That’s the basics. I am trying to port my Windows programs to Linux I’m using
GLUT to render the screen. I want SDL to handle keyboard, sound, timers, and
all that. Keyboard event handling, though, is bundled with video, so I have
to initialize video and SDL_SetVideoMode() to get keyboard handling. Is there
any way I can speed up OpenGL with SDL or get GLUT and SDL to work together?

Is there
any way I can speed up OpenGL with SDL or get GLUT
and SDL to work together?

I’ve actually found on my system that using OpenGL
runs faster for me using OpenGL… probably only
because GLUT dosn’t change the resolution on my system
even using game mode… make sure all your libGL.so
links are up to date (once I had a program that at
runtime was linking against a broken libGL.so symlink,
and instead of crashing it just never rendered. The
program never segfaulted or anything, and it WAS going
through all the render code).

If GL is slow for SDL on your linux system, it’s
probably linking to the wrong library… aka Mesa
instead of your HW specific libs. Not sure what the
problem could be for windows…

Now a quick hack to generate SDL keyboard events
without calling SDL_SetVideoMode would be to create a
GLUT handler that then pushes the events to SDL. My
sample code is incomplete and possibly buggy (I froget
how to check keyboard mod state on glut, as well as
exact parameters the funcs get passed… I’d check if
I were booted to my dev OS…linux… but I’m not :)).

But yeah, that example code:

void glut_sdl_keyboard_down( GLuint , GLuint , GLuint
key )
{
SDL_Event e;
e.type = SDL_KEYDOWN;
e.state = SDL_PRESSED;
//e.keysym.scancode = ???
e.keysym.sym = key;
//e.keysym.mod = ???
//e.keysym.unicode = ???
SDL_PushEvent(&e);
}
void glut_sdl_keyboard_up( GLuint , GLuint , GLuint
key )
{
SDL_Event e;
e.type = SDL_KEYUP;
e.state = SDL_RELEASED;
//e.keysym.scancode = ???
e.keysym.sym = key;
//e.keysym.mod = ???
//e.keysym.unicode = ???
SDL_PushEvent(&e);
}
int main( … )
{
//…
glutKeyboardFunc( glut_sdl_keyboard_down );
glutKeyboardUpFunc( glut_sdl_keyboard_up );
//…
}

This code will only generate the event stuff, but from
what I gathered that’s what you wanted, right?
Hope some/any of this helps.
-Mike__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

Hey, new member here, big question. let me just go through the basic things
that I want you to know before I ask my question.

  1. Using SDL for OpenGL runs program very slow.
  2. Using GLUT for OpenGL run program fine.
  3. When SDL does OpenGL, event-handling is extremely slow.
  4. I want GLUT, because it works, but I want to use event handling of SDL.
  5. To do 4., I must open an SDL rendering context and the GLUT window.
    (keyboard handling)

That’s the basics. I am trying to port my Windows programs to Linux I’m using
GLUT to render the screen. I want SDL to handle keyboard, sound, timers, and
all that. Keyboard event handling, though, is bundled with video, so I have
to initialize video and SDL_SetVideoMode() to get keyboard handling. Is there
any way I can speed up OpenGL with SDL or get GLUT and SDL to work together?

AFAIK the two most common mistakes that cause OpenGL to run slowly under
SDL are failure to install hardware device drivers and failure to
properly handle events. The third is failure to use sdl-config to
generate compiler and linker flags.

With a properly configured system OpenGL runs just fine under SDL. That
is, there is nothing about SDL by itself that will slow down you OpenGL
programs.

Glut and SDL try to handle pretty much all the same events. They will
each have routines trying to get the same events and access the same
hardware. Doesn’t seem likely to work. You could grab freeGlut and
hack it so sits on top of SDL. But, that would be rather silly since SDL
does everything you want all by itself. :slight_smile:

	Bob PendletonOn Sun, 2003-10-26 at 17:45, Duncan Domingue wrote:

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±--------------------------------------+