SDL, GTK and OPENGL

Hi,

I am looking for a method to display an SDL surface using OpenGL
in a GTK widget. Having the SDL/OpenGL and the Gtk widgets in
separate windows could be enough.

I tried without success to combine the Gtk-demo (see below)
with one of the NeHe demos (lesson4).

My current non-working program is in
http://members.brabant.chello.nl/~s.chauveau/pub/gtk-demo.c
It compile and execute fine but do not display the OpenGL
surface.

The original 2 packages are
http://www.libsdl.org/projects/gtk-demo/src/gtk-demo-1.2.tar.gz
and
http://nehe.gamedev.net/tutorials/linuxsdl/lesson04.tar.gz

A funny thing happened on the way to drawGLScene…

if (glXGetCurrentContext() == NULL)
    printf ("No Context\n");

No Context
No Context
No Context
No Context
No Context
No Context
No Context
No Context
No Context

Seems your context is never getting created here. I tried following this
up by adding a vid_inited global which inits to false and set it true
after SDL_SetVideoMode returned screen, and made the draw function bail if
it was not true, before checking for context or anything. I still get the
above output, which means that screen is returning non-NULL and there is
no context.

It looks like SDL_VideoInfo does not contain a field for whether or not
SDL can create an OpenGL context or not - it should. Since it doesn’t, we
need to check that we actually got a surface back, no problem since you
already had this:

/* Verify there is a surface */
if ( ! screen )
{
    fprintf( stderr,  "Video mode set failed: %s\n", SDL_GetError( ) );
    SDL_Quit();
    exit( 1 );
}

…so I just modified it to also check for the proper flag:

if ( ! screen || !(screen->flags & SDL_OPENGL) )
{
    fprintf( stderr,  "Video mode set failed: %s\n", SDL_GetError( ) );
    SDL_Quit();
    exit( 1 );
}

No bail. And still no context. Looks like the context is either not
created or not made current. Either way, this is a bug in SDL by the
looks of it.On Thu, Oct 18, 2001 at 08:55:17PM +0000, Stephane Chauveau wrote:

I am looking for a method to display an SDL surface using OpenGL
in a GTK widget. Having the SDL/OpenGL and the Gtk widgets in
separate windows could be enough.

I tried without success to combine the Gtk-demo (see below)
with one of the NeHe demos (lesson4).

My current non-working program is in
http://members.brabant.chello.nl/~s.chauveau/pub/gtk-demo.c
It compile and execute fine but do not display the OpenGL
surface.


Joseph Carter Free software developer

Mercury, isn’t debugging X a little like finding perfectly
bugfree code in windows ??
WildCode: Debugging X is like trying to run a straight line
through a maze.
You just need to bend space-time so that the corners move around
you and you won’t have any problems. (=:]

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20011019/da19c756/attachment.pgp