SDL.Net + Tao.openGL pauses on each call to Gl.glBegin()

I’m trying to use OpenGL in a .NET program, and everything’s fine except
that I get almost a one second pause when glBegin is called, whether it
be called directly or as part of a vertex list. I’ve been looking around
and can’t find a reason. Might anyone here have a clue?
I’m initializing openGL with:**********************
screen = Video.SetVideoModeWindowOpenGL(width, height, true);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_HWSURFACE, 1);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);
Gl.glShadeModel(Gl.GL_SMOOTH);
Gl.glClearColor(bgColorR, bgColorG, bgColorB, 0.0f);
Gl.glClearDepth(1.0);
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glDepthFunc(Gl.GL_LEQUAL);
Gl.glHint( Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST );
Gl.glViewport( 0, 0, width, height );
Gl.glMatrixMode( Gl.GL_PROJECTION );
Gl.glLoadIdentity();
Glu.gluOrtho2D(win_left_edge,win_right_edge,win_bottom_edge,win_top_edge);
Gl.glMatrixMode( Gl.GL_MODELVIEW );
Gl.glLoadIdentity();


and then I draw with this:


Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glLoadIdentity();
Gl.glTranslatef(0.0f,0.0f,0.0f);
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBegin(Gl.GL_QUADS); // Draw A Quad
Gl.glTexCoord2d(0.0, 1.0);
Gl.glVertex2i(-(int)(currentImgWidth/2),-(int)(currentImgHeight/2));
// Bottom Left
Gl.glTexCoord2d(1.0, 1.0); Gl.glVertex2i(
(int)(currentImgWidth/2),-(int)(currentImgHeight/2)); // Bottom
Right
Gl.glTexCoord2d(1.0, 0.0); Gl.glVertex2i( (int)(currentImgWidth/2),
(int)(currentImgHeight/2)); // Top Right
Gl.glTexCoord2d(0.0, 0.0); Gl.glVertex2i(-(int)(currentImgWidth/2),
(int)(currentImgHeight/2)); // Top Left
Gl.glEnd(); // Done Drawing The Quad
Gl.glFlush();

Sdl.SDL_GL_SwapBuffers();


or in one section I use glCallList, but that acts exactly the same. The
only thing i could think of is that maybe I’m missing some attributes to
set via SDL_DL_SetAttribute or something.
Also, I know that there is another way to flip the buffers via the Video
class (I forget the call right now), is there any difference between
that and SDL_GL_Swap_Buffers? If someone can help. that would be great,
this is an emergency now!

screen = Video.SetVideoModeWindowOpenGL(width, height, true);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_HWSURFACE, 1);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);

SDL_GL_SetAttribute needs to be done before SetVideoMode, and
SDL_HWSURFACE isn’t a valid attribute here.

Gl.glBegin(Gl.GL_QUADS); // Draw A Quad

This line always lags for one second?

Gl.glFlush();
Sdl.SDL_GL_SwapBuffers();

Don’t call glFlush() before SwapBuffers…SwapBuffers implies a flush, I
think.

–ryan.

Timothy Caraballo wrote:

I’m trying to use OpenGL in a .NET program, and everything’s fine
except that I get almost a one second pause when glBegin is called,
whether it be called directly or as part of a vertex list. I’ve been
looking around and can’t find a reason. Might anyone here have a clue?
I’m initializing openGL with:


screen = Video.SetVideoModeWindowOpenGL(width, height, true);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_HWSURFACE, 1);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);
Gl.glShadeModel(Gl.GL_SMOOTH);
Gl.glClearColor(bgColorR, bgColorG, bgColorB, 0.0f);
Gl.glClearDepth(1.0);
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glDepthFunc(Gl.GL_LEQUAL);
Gl.glHint( Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST );
Gl.glViewport( 0, 0, width, height );
Gl.glMatrixMode( Gl.GL_PROJECTION );
Gl.glLoadIdentity();
Glu.gluOrtho2D(win_left_edge,win_right_edge,win_bottom_edge,win_top_edge);

Gl.glMatrixMode( Gl.GL_MODELVIEW );
Gl.glLoadIdentity();


and then I draw with this:


Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glLoadIdentity();
Gl.glTranslatef(0.0f,0.0f,0.0f);
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBegin(Gl.GL_QUADS); // Draw A Quad
Gl.glTexCoord2d(0.0, 1.0);
Gl.glVertex2i(-(int)(currentImgWidth/2),-(int)(currentImgHeight/2));
// Bottom Left
Gl.glTexCoord2d(1.0, 1.0); Gl.glVertex2i(
(int)(currentImgWidth/2),-(int)(currentImgHeight/2)); // Bottom
Right
Gl.glTexCoord2d(1.0, 0.0); Gl.glVertex2i( (int)(currentImgWidth/2),
(int)(currentImgHeight/2)); // Top Right
Gl.glTexCoord2d(0.0, 0.0); Gl.glVertex2i(-(int)(currentImgWidth/2),
(int)(currentImgHeight/2)); // Top Left
Gl.glEnd(); // Done Drawing The Quad
Gl.glFlush();

Sdl.SDL_GL_SwapBuffers();


or in one section I use glCallList, but that acts exactly the same.
The only thing i could think of is that maybe I’m missing some
attributes to set via SDL_DL_SetAttribute or something.
Also, I know that there is another way to flip the buffers via the
Video class (I forget the call right now), is there any difference
between that and SDL_GL_Swap_Buffers? If someone can help. that would
be great, this is an emergency now!


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

As far as I can tell, there arn’t many taoists out there, so we really
need to help each other when we can.
I can’t replicate the issue on my end – not in my own code, nor with
the code you presented here – but our .NET environments may differ.
Are you using Mono or the Microsoft framework? What version?
Can you provide a full code example that demonstrates the problem (not
just out-of-context code snippets)? You may be doing something odd
outside of the code you presented here.

You may want also to post this to the Tao mailing list. Please post some
more of the code to provide a better context for the problem.

tao-list at lists.ximian.com
http://www.mono-project.com/Tao

Dave-------------------

Message: 4
Date: Wed, 12 Oct 2005 18:22:20 -0400
From: Timothy Caraballo
Subject: [SDL] SDL.Net + Tao.openGL pauses on each call to
Gl.glBegin()
To: SDL at libsdl.org
Message-ID: <434D8C9C.2020605 at pixelpod.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I’m trying to use OpenGL in a .NET program, and everything’s fine except
that I get almost a one second pause when glBegin is called, whether it
be called directly or as part of a vertex list. I’ve been looking around
and can’t find a reason. Might anyone here have a clue?
I’m initializing openGL with:


screen = Video.SetVideoModeWindowOpenGL(width, height, true);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_HWSURFACE, 1);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);
Gl.glShadeModel(Gl.GL_SMOOTH);
Gl.glClearColor(bgColorR, bgColorG, bgColorB, 0.0f);
Gl.glClearDepth(1.0);
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glDepthFunc(Gl.GL_LEQUAL);
Gl.glHint( Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST );
Gl.glViewport( 0, 0, width, height );
Gl.glMatrixMode( Gl.GL_PROJECTION );
Gl.glLoadIdentity();

Glu.gluOrtho2D(win_left_edge,win_right_edge,win_bottom_edge,win_top_edge);

Gl.glMatrixMode( Gl.GL_MODELVIEW );
Gl.glLoadIdentity();


and then I draw with this:


Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glLoadIdentity();
Gl.glTranslatef(0.0f,0.0f,0.0f);
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBegin(Gl.GL_QUADS); // Draw A Quad
Gl.glTexCoord2d(0.0, 1.0);
Gl.glVertex2i(-(int)(currentImgWidth/2),-(int)(currentImgHeight/2));
// Bottom Left
Gl.glTexCoord2d(1.0, 1.0); Gl.glVertex2i(
(int)(currentImgWidth/2),-(int)(currentImgHeight/2)); // Bottom
Right
Gl.glTexCoord2d(1.0, 0.0); Gl.glVertex2i( (int)(currentImgWidth/2),
(int)(currentImgHeight/2)); // Top Right
Gl.glTexCoord2d(0.0, 0.0); Gl.glVertex2i(-(int)(currentImgWidth/2),
(int)(currentImgHeight/2)); // Top Left
Gl.glEnd(); // Done Drawing The Quad
Gl.glFlush();

Sdl.SDL_GL_SwapBuffers();


or in one section I use glCallList, but that acts exactly the same. The
only thing i could think of is that maybe I’m missing some attributes to
set via SDL_DL_SetAttribute or something.
Also, I know that there is another way to flip the buffers via the Video
class (I forget the call right now), is there any difference between
that and SDL_GL_Swap_Buffers? If someone can help. that would be great,
this is an emergency now!