OpenGL speed under windows

Hi all,

I’m new to SDL, and somewhat newish with OpenGL. Heres my question…

I’m getting about 60 fps when rotating a 500 polygon textured object.
This is on a P4 HT 2.53 GHz with a Geforce 4 MX 440 card.

I should be getting way more than that, shouldn’t I?

Also, fsaa doesn’t seem to work at all…

Thanks in advance for your help!

Here is my core display loop…

int RunGLTest( int argc, char* argv[],
int logo, int slowly, int bpp, float gamma, int noframe,
int fsaa )
{
int i;
int rgb_size[3];
int w = 640;
int h = 480;
int done = 0;
int frames;
Uint32 start_time, this_time;

 Uint32 video_flags;
 int value;


 if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
 {
     fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
     exit( 1 );
 }

 /* See if we should detect the display depth */
 if ( bpp == 0 )
 {
     if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 )
     {
         bpp = 8;
     } else
     {
         bpp = 16;  /* More doesn't seem to work */
     }
 }

 bpp = 0 ;

 /* Set the flags we want to use for setting the video mode */
 if ( logo && USE_DEPRECATED_OPENGLBLIT )
 {
     video_flags = SDL_OPENGLBLIT;
 } else
 {
     video_flags = SDL_OPENGL;
 }

 video_flags |= SDL_OPENGLBLIT ;

 for ( i=1; argv[i]; ++i )
 {
     if ( strcmp(argv[1], "-fullscreen") == 0 )
     {
         video_flags |= SDL_FULLSCREEN;
     }
 }

 if (noframe)
 {
     video_flags |= SDL_NOFRAME;
 }

 video_flags |= SDL_HWSURFACE;
 video_flags |= SDL_HWPALETTE ;
 video_flags |= SDL_HWACCEL ;

 /* Initialize the display */
 switch (bpp)
 {
     case 8:
         rgb_size[0] = 3;
         rgb_size[1] = 3;
         rgb_size[2] = 2;
         break;

     case 15:
     case 16:
         rgb_size[0] = 5;
         rgb_size[1] = 5;
         rgb_size[2] = 5;
         break;

     default:
         rgb_size[0] = 8;
         rgb_size[1] = 8;
         rgb_size[2] = 8;
         break;
 }

 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

 if ( fsaa )
 {
     SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
     SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
 }
 if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL )
 {
     fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
     SDL_Quit();
     exit(1);
 }


 printf("Screen BPP: %d\n", 

SDL_GetVideoSurface()->format->BitsPerPixel);
printf("\n");
printf( “Vendor : %s\n”, glGetString( GL_VENDOR ) );
printf( “Renderer : %s\n”, glGetString( GL_RENDERER ) );
printf( “Version : %s\n”, glGetString( GL_VERSION ) );
printf( “Extensions : %s\n”, glGetString( GL_EXTENSIONS ) );
printf("\n");

 SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
 printf( "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);

 SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
 printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n", 

rgb_size[1],value);

 SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
 printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);

 SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
 printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );

 SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
 printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );

 if ( fsaa )
 {
     SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
     printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", 

value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( “SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n”,
fsaa, value );
}

 /* Set the window manager title bar */
 SDL_WM_SetCaption( "SDL GL test", "testgl" );

 /* Set the gamma for the window */
 if ( gamma != 0.0 )
 {
     SDL_SetGamma(gamma, gamma, gamma);
 }


 glEnable( GL_DEPTH_TEST );
 glClearColor(0.0, 0.0, 0.2, 0.0); // This clear the background 

color to dark blue
glShadeModel(GL_SMOOTH); // Type of shading for the polygons
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); // Polygon
rasterization mode (polygon filled)
glEnable(GL_TEXTURE_2D); // This Enable the Texture mapping

 glViewport(0,0,w,h);

 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();

 // FOV        // Ratio                //  The farthest distance 

before it stops drawing
perspectiveGL(45.0f,(GLfloat)w/(GLfloat)h, .5f ,5000.0f);

 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();

 unsigned long totalpolys = 0 ;

 for(int x = 0; x < MAX_OBJECTS; x++)
 {
     cLoad3DS my3ds(&object[x], "spaceship.3ds", 

“spaceshiptexture.bmp”);
if(object[x].valid == false)
{
MessageBox(NULL,“Object not loaded”, “Error”,MB_OK |
MB_ICONERROR);
return 0 ;
}

     totalpolys += object[x].polygons_qty ;
 }

 printf("Total polygons: %ld\n", totalpolys) ;

 /* Loop until done. */
 start_time = SDL_GetTicks();
 frames = 0;


 // Absolute rotation values (0-359 degrees) and rotation increments 

for each frame
// double rotation_x=0, rotation_x_increment=0.1;
// double rotation_y=0, rotation_y_increment=0.05;
// double rotation_z=0, rotation_z_increment=0.03;
double rotation_x=0, rotation_x_increment=0.5;
double rotation_y=0, rotation_y_increment=0.25;
double rotation_z=0, rotation_z_increment=0.15;

 GLuint displaylist ;
 displaylist = glGenLists(1) ;

 glNewList(displaylist, GL_COMPILE) ;
 for(int x = 0; x < MAX_OBJECTS; x++)
 {
     glBindTexture(GL_TEXTURE_2D, object[x].id_texture); // We set 

the active texture
object[x].Draw(true) ;
}
glEndList() ;

 glMatrixMode(GL_MODELVIEW); // Modeling transformation
 glLoadIdentity(); // Initialize the model matrix as identity

 glTranslatef(0.0,0.0,-600); // We move the object forward (the 

model matrix is multiplied by the translation matrix)

 rotation_x = rotation_x + rotation_x_increment;
 rotation_y = rotation_y + rotation_y_increment;
 rotation_z = rotation_z + rotation_z_increment;

 while( !done )
 {
     GLenum gl_error;
     char* sdl_error;
     SDL_Event event;

     /* Do our drawing, too. */

     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This 

clear the background color to dark blue
// glMatrixMode(GL_MODELVIEW); // Modeling transformation
// glLoadIdentity(); // Initialize the model matrix as identity

// glTranslatef(0.0,0.0,-300); // We move the object forward (the
model matrix is multiplied by the translation matrix)

// rotation_x = rotation_x + rotation_x_increment;
// rotation_y = rotation_y + rotation_y_increment;
// rotation_z = rotation_z + rotation_z_increment;

     if (rotation_x > 359) rotation_x = 0;
     if (rotation_y > 359) rotation_y = 0;
     if (rotation_z > 359) rotation_z = 0;

     glRotatef(rotation_x,1.0,0.0,0.0); // Rotations of the object 

(the model matrix is multiplied by the rotation matrices)
glRotatef(rotation_y,0.0,1.0,0.0);
glRotatef(rotation_z,0.0,0.0,1.0);

     glCallList(displaylist) ;

     SDL_GL_SwapBuffers();									



     /* Check if there's a pending event. */
     while( SDL_PollEvent( &event ) )
     {
         done = HandleEvent(&event);
     }
     ++frames;

     this_time = SDL_GetTicks();
     if ( this_time >= start_time + 500)
     {
         static char name[1024] ;
         sprintf(name, "SDL GL test [polys: %ld  fps: %5.2f]", 

totalpolys,((float)frames/(this_time-start_time))*1000.0);

         start_time = this_time ;
         frames = 0 ;
         SDL_WM_SetCaption( name, "testgl" );
         printf("%s\n", name) ;
     }

 }



 /* Print out the frames per second */
 this_time = SDL_GetTicks();
 if ( this_time != start_time )
 {
     printf("%2.2f FPS\n",
         ((float)frames/(this_time-start_time))*1000.0);
 }

 if ( global_image )
 {
     SDL_FreeSurface(global_image);
     global_image = NULL;
 }
 if ( global_texture )
 {
     glDeleteTextures( 1, &global_texture );
     global_texture = 0;
 }

 /* Destroy our GL context, etc. */
 SDL_Quit( );
 return(0);

}

Your app is probably waiting on vsync and the video mode your windows
machine is running at is 60hz.

I get exactly the same case on a regular basis with fps on linux around
5 to 8 hundred, and pinned at 60 on windows. Note that this isn’t a
"bad thing" because rendering more than 60fps in a 60hz mode doesn’t
yield any additional visible frames - and could just introduce tearing.On Wed, 2004-02-18 at 10:37, Gerald wrote:

Hi all,

I’m new to SDL, and somewhat newish with OpenGL. Heres my question…

I’m getting about 60 fps when rotating a 500 polygon textured object.
This is on a P4 HT 2.53 GHz with a Geforce 4 MX 440 card.

I should be getting way more than that, shouldn’t I?

Also, fsaa doesn’t seem to work at all…

Thanks in advance for your help!

Here is my core display loop…

int RunGLTest( int argc, char* argv[],
int logo, int slowly, int bpp, float gamma, int noframe,
int fsaa )
{
int i;
int rgb_size[3];
int w = 640;
int h = 480;
int done = 0;
int frames;
Uint32 start_time, this_time;

 Uint32 video_flags;
 int value;


 if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
 {
     fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
     exit( 1 );
 }

 /* See if we should detect the display depth */
 if ( bpp == 0 )
 {
     if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 )
     {
         bpp = 8;
     } else
     {
         bpp = 16;  /* More doesn't seem to work */
     }
 }

 bpp = 0 ;

 /* Set the flags we want to use for setting the video mode */
 if ( logo && USE_DEPRECATED_OPENGLBLIT )
 {
     video_flags = SDL_OPENGLBLIT;
 } else
 {
     video_flags = SDL_OPENGL;
 }

 video_flags |= SDL_OPENGLBLIT ;

 for ( i=1; argv[i]; ++i )
 {
     if ( strcmp(argv[1], "-fullscreen") == 0 )
     {
         video_flags |= SDL_FULLSCREEN;
     }
 }

 if (noframe)
 {
     video_flags |= SDL_NOFRAME;
 }

 video_flags |= SDL_HWSURFACE;
 video_flags |= SDL_HWPALETTE ;
 video_flags |= SDL_HWACCEL ;

 /* Initialize the display */
 switch (bpp)
 {
     case 8:
         rgb_size[0] = 3;
         rgb_size[1] = 3;
         rgb_size[2] = 2;
         break;

     case 15:
     case 16:
         rgb_size[0] = 5;
         rgb_size[1] = 5;
         rgb_size[2] = 5;
         break;

     default:
         rgb_size[0] = 8;
         rgb_size[1] = 8;
         rgb_size[2] = 8;
         break;
 }

 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

 if ( fsaa )
 {
     SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
     SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
 }
 if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL )
 {
     fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
     SDL_Quit();
     exit(1);
 }


 printf("Screen BPP: %d\n", 

SDL_GetVideoSurface()->format->BitsPerPixel);
printf("\n");
printf( “Vendor : %s\n”, glGetString( GL_VENDOR ) );
printf( “Renderer : %s\n”, glGetString( GL_RENDERER ) );
printf( “Version : %s\n”, glGetString( GL_VERSION ) );
printf( “Extensions : %s\n”, glGetString( GL_EXTENSIONS ) );
printf("\n");

 SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
 printf( "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);

 SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
 printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n", 

rgb_size[1],value);

 SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
 printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);

 SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
 printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );

 SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
 printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );

 if ( fsaa )
 {
     SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
     printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", 

value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( “SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n”,
fsaa, value );
}

 /* Set the window manager title bar */
 SDL_WM_SetCaption( "SDL GL test", "testgl" );

 /* Set the gamma for the window */
 if ( gamma != 0.0 )
 {
     SDL_SetGamma(gamma, gamma, gamma);
 }


 glEnable( GL_DEPTH_TEST );
 glClearColor(0.0, 0.0, 0.2, 0.0); // This clear the background 

color to dark blue
glShadeModel(GL_SMOOTH); // Type of shading for the polygons
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); // Polygon
rasterization mode (polygon filled)
glEnable(GL_TEXTURE_2D); // This Enable the Texture mapping

 glViewport(0,0,w,h);

 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();

 // FOV        // Ratio                //  The farthest distance 

before it stops drawing
perspectiveGL(45.0f,(GLfloat)w/(GLfloat)h, .5f ,5000.0f);

 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();

 unsigned long totalpolys = 0 ;

 for(int x = 0; x < MAX_OBJECTS; x++)
 {
     cLoad3DS my3ds(&object[x], "spaceship.3ds", 

“spaceshiptexture.bmp”);
if(object[x].valid == false)
{
MessageBox(NULL,“Object not loaded”, “Error”,MB_OK |
MB_ICONERROR);
return 0 ;
}

     totalpolys += object[x].polygons_qty ;
 }

 printf("Total polygons: %ld\n", totalpolys) ;

 /* Loop until done. */
 start_time = SDL_GetTicks();
 frames = 0;


 // Absolute rotation values (0-359 degrees) and rotation increments 

for each frame
// double rotation_x=0, rotation_x_increment=0.1;
// double rotation_y=0, rotation_y_increment=0.05;
// double rotation_z=0, rotation_z_increment=0.03;
double rotation_x=0, rotation_x_increment=0.5;
double rotation_y=0, rotation_y_increment=0.25;
double rotation_z=0, rotation_z_increment=0.15;

 GLuint displaylist ;
 displaylist = glGenLists(1) ;

 glNewList(displaylist, GL_COMPILE) ;
 for(int x = 0; x < MAX_OBJECTS; x++)
 {
     glBindTexture(GL_TEXTURE_2D, object[x].id_texture); // We set 

the active texture
object[x].Draw(true) ;
}
glEndList() ;

 glMatrixMode(GL_MODELVIEW); // Modeling transformation
 glLoadIdentity(); // Initialize the model matrix as identity

 glTranslatef(0.0,0.0,-600); // We move the object forward (the 

model matrix is multiplied by the translation matrix)

 rotation_x = rotation_x + rotation_x_increment;
 rotation_y = rotation_y + rotation_y_increment;
 rotation_z = rotation_z + rotation_z_increment;

 while( !done )
 {
     GLenum gl_error;
     char* sdl_error;
     SDL_Event event;

     /* Do our drawing, too. */

     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This 

clear the background color to dark blue
// glMatrixMode(GL_MODELVIEW); // Modeling transformation
// glLoadIdentity(); // Initialize the model matrix as identity

// glTranslatef(0.0,0.0,-300); // We move the object forward (the
model matrix is multiplied by the translation matrix)

// rotation_x = rotation_x + rotation_x_increment;
// rotation_y = rotation_y + rotation_y_increment;
// rotation_z = rotation_z + rotation_z_increment;

     if (rotation_x > 359) rotation_x = 0;
     if (rotation_y > 359) rotation_y = 0;
     if (rotation_z > 359) rotation_z = 0;

     glRotatef(rotation_x,1.0,0.0,0.0); // Rotations of the object 

(the model matrix is multiplied by the rotation matrices)
glRotatef(rotation_y,0.0,1.0,0.0);
glRotatef(rotation_z,0.0,0.0,1.0);

     glCallList(displaylist) ;

     SDL_GL_SwapBuffers();									



     /* Check if there's a pending event. */
     while( SDL_PollEvent( &event ) )
     {
         done = HandleEvent(&event);
     }
     ++frames;

     this_time = SDL_GetTicks();
     if ( this_time >= start_time + 500)
     {
         static char name[1024] ;
         sprintf(name, "SDL GL test [polys: %ld  fps: %5.2f]", 

totalpolys,((float)frames/(this_time-start_time))*1000.0);

         start_time = this_time ;
         frames = 0 ;
         SDL_WM_SetCaption( name, "testgl" );
         printf("%s\n", name) ;
     }

 }



 /* Print out the frames per second */
 this_time = SDL_GetTicks();
 if ( this_time != start_time )
 {
     printf("%2.2f FPS\n",
         ((float)frames/(this_time-start_time))*1000.0);
 }

 if ( global_image )
 {
     SDL_FreeSurface(global_image);
     global_image = NULL;
 }
 if ( global_texture )
 {
     glDeleteTextures( 1, &global_texture );
     global_texture = 0;
 }

 /* Destroy our GL context, etc. */
 SDL_Quit( );
 return(0);

}


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

any possibility to set the refresh rate via SDL?
(its a pain having to play at 1024 or even higher with 60hz for example)–
regards

ionas

Use the following code to disable vsync waits in Windows:

typedef void (APIENTRY * WGLSWAPINTERVALEXT) (int);
WGLSWAPINTERVALEXT wglSwapIntervalEXT = (WGLSWAPINTERVALEXT)
wglGetProcAddress(“wglSwapIntervalEXT”);
if (wglSwapIntervalEXT) {
wglSwapIntervalEXT(0); // disable vertical synchronisation
}

Marc

Gerald wrote:> Hi all,

I’m new to SDL, and somewhat newish with OpenGL. Heres my question…

I’m getting about 60 fps when rotating a 500 polygon textured object.
This is on a P4 HT 2.53 GHz with a Geforce 4 MX 440 card.

I should be getting way more than that, shouldn’t I?

Also, fsaa doesn’t seem to work at all…

Thanks in advance for your help!

Here is my core display loop…

int RunGLTest( int argc, char* argv[],
int logo, int slowly, int bpp, float gamma, int noframe,
int fsaa )
{
int i;
int rgb_size[3];
int w = 640;
int h = 480;
int done = 0;
int frames;
Uint32 start_time, this_time;

Uint32 video_flags;
int value;


if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
    fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
    exit( 1 );
}

/* See if we should detect the display depth */
if ( bpp == 0 )
{
    if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 )
    {
        bpp = 8;
    } else
    {
        bpp = 16;  /* More doesn't seem to work */
    }
}

bpp = 0 ;

/* Set the flags we want to use for setting the video mode */
if ( logo && USE_DEPRECATED_OPENGLBLIT )
{
    video_flags = SDL_OPENGLBLIT;
} else
{
    video_flags = SDL_OPENGL;
}

video_flags |= SDL_OPENGLBLIT ;

for ( i=1; argv[i]; ++i )
{
    if ( strcmp(argv[1], "-fullscreen") == 0 )
    {
        video_flags |= SDL_FULLSCREEN;
    }
}

if (noframe)
{
    video_flags |= SDL_NOFRAME;
}

video_flags |= SDL_HWSURFACE;
video_flags |= SDL_HWPALETTE ;
video_flags |= SDL_HWACCEL ;

/* Initialize the display */
switch (bpp)
{
    case 8:
        rgb_size[0] = 3;
        rgb_size[1] = 3;
        rgb_size[2] = 2;
        break;

    case 15:
    case 16:
        rgb_size[0] = 5;
        rgb_size[1] = 5;
        rgb_size[2] = 5;
        break;

    default:
        rgb_size[0] = 8;
        rgb_size[1] = 8;
        rgb_size[2] = 8;
        break;
}

SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

if ( fsaa )
{
    SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
    SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
}
if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL )
{
    fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
    SDL_Quit();
    exit(1);
}


printf("Screen BPP: %d\n", 

SDL_GetVideoSurface()->format->BitsPerPixel);
printf("\n");
printf( “Vendor : %s\n”, glGetString( GL_VENDOR ) );
printf( “Renderer : %s\n”, glGetString( GL_RENDERER ) );
printf( “Version : %s\n”, glGetString( GL_VERSION ) );
printf( “Extensions : %s\n”, glGetString( GL_EXTENSIONS ) );
printf("\n");

SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
printf( "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);

SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n", 

rgb_size[1],value);

SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);

SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );

SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );

if ( fsaa )
{
    SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
    printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", 

value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( “SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n”,
fsaa, value );
}

/* Set the window manager title bar */
SDL_WM_SetCaption( "SDL GL test", "testgl" );

/* Set the gamma for the window */
if ( gamma != 0.0 )
{
    SDL_SetGamma(gamma, gamma, gamma);
}


glEnable( GL_DEPTH_TEST );
glClearColor(0.0, 0.0, 0.2, 0.0); // This clear the background color 

to dark blue
glShadeModel(GL_SMOOTH); // Type of shading for the polygons
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); // Polygon rasterization
mode (polygon filled)
glEnable(GL_TEXTURE_2D); // This Enable the Texture mapping

glViewport(0,0,w,h);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// FOV        // Ratio                //  The farthest distance 

before it stops drawing
perspectiveGL(45.0f,(GLfloat)w/(GLfloat)h, .5f ,5000.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

unsigned long totalpolys = 0 ;

for(int x = 0; x < MAX_OBJECTS; x++)
{
    cLoad3DS my3ds(&object[x], "spaceship.3ds", 

“spaceshiptexture.bmp”);
if(object[x].valid == false)
{
MessageBox(NULL,“Object not loaded”, “Error”,MB_OK |
MB_ICONERROR);
return 0 ;
}

    totalpolys += object[x].polygons_qty ;
}

printf("Total polygons: %ld\n", totalpolys) ;

/* Loop until done. */
start_time = SDL_GetTicks();
frames = 0;


// Absolute rotation values (0-359 degrees) and rotation increments 

for each frame
// double rotation_x=0, rotation_x_increment=0.1;
// double rotation_y=0, rotation_y_increment=0.05;
// double rotation_z=0, rotation_z_increment=0.03;
double rotation_x=0, rotation_x_increment=0.5;
double rotation_y=0, rotation_y_increment=0.25;
double rotation_z=0, rotation_z_increment=0.15;

GLuint displaylist ;
displaylist = glGenLists(1) ;

glNewList(displaylist, GL_COMPILE) ;
for(int x = 0; x < MAX_OBJECTS; x++)
{
    glBindTexture(GL_TEXTURE_2D, object[x].id_texture); // We set 

the active texture
object[x].Draw(true) ;
}
glEndList() ;

glMatrixMode(GL_MODELVIEW); // Modeling transformation
glLoadIdentity(); // Initialize the model matrix as identity

glTranslatef(0.0,0.0,-600); // We move the object forward (the model 

matrix is multiplied by the translation matrix)

rotation_x = rotation_x + rotation_x_increment;
rotation_y = rotation_y + rotation_y_increment;
rotation_z = rotation_z + rotation_z_increment;

while( !done )
{
    GLenum gl_error;
    char* sdl_error;
    SDL_Event event;

    /* Do our drawing, too. */

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This 

clear the background color to dark blue
// glMatrixMode(GL_MODELVIEW); // Modeling transformation
// glLoadIdentity(); // Initialize the model matrix as identity

// glTranslatef(0.0,0.0,-300); // We move the object forward (the
model matrix is multiplied by the translation matrix)

// rotation_x = rotation_x + rotation_x_increment;
// rotation_y = rotation_y + rotation_y_increment;
// rotation_z = rotation_z + rotation_z_increment;

    if (rotation_x > 359) rotation_x = 0;
    if (rotation_y > 359) rotation_y = 0;
    if (rotation_z > 359) rotation_z = 0;

    glRotatef(rotation_x,1.0,0.0,0.0); // Rotations of the object 

(the model matrix is multiplied by the rotation matrices)
glRotatef(rotation_y,0.0,1.0,0.0);
glRotatef(rotation_z,0.0,0.0,1.0);

    glCallList(displaylist) ;

    SDL_GL_SwapBuffers();                                   



    /* Check if there's a pending event. */
    while( SDL_PollEvent( &event ) )
    {
        done = HandleEvent(&event);
    }
    ++frames;

    this_time = SDL_GetTicks();
    if ( this_time >= start_time + 500)
    {
        static char name[1024] ;
        sprintf(name, "SDL GL test [polys: %ld  fps: %5.2f]", 

totalpolys,((float)frames/(this_time-start_time))*1000.0);

        start_time = this_time ;
        frames = 0 ;
        SDL_WM_SetCaption( name, "testgl" );
        printf("%s\n", name) ;
    }

}



/* Print out the frames per second */
this_time = SDL_GetTicks();
if ( this_time != start_time )
{
    printf("%2.2f FPS\n",
        ((float)frames/(this_time-start_time))*1000.0);
}

if ( global_image )
{
    SDL_FreeSurface(global_image);
    global_image = NULL;
}
if ( global_texture )
{
    glDeleteTextures( 1, &global_texture );
    global_texture = 0;
}

/* Destroy our GL context, etc. */
SDL_Quit( );
return(0);

}


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

'lo Gerald,

I’m getting about 60 fps when rotating a 500 polygon textured object.
This is on a P4 HT 2.53 GHz with a Geforce 4 MX 440 card.

If your monitor is set to 60Hz, then that’s probably the reason. You
might then want to deselect the refresh sync in your graphic card
prefs, if possible. (not guaranted to work though, AFAIR)

video_flags |= SDL_OPENGLBLIT ;

AFAIK this will slow down your app. I’ve only ever used SDL_OPENGL
alone, though.

On a “recent” PC I get up to 700 fps with a program of mine that
displays around 2000 triangles.On 18/02/2004, Gerald, you wrote:


Please remove “.ARGL.invalid” from my email when replying.
Incoming HTML mails are automatically deleted.

wow thats awesome (:

thanks for the snippet, ive always wondered how to do that.

i just tried it out and now i have a question.

in my main loop it keeps track of the time between frames and uses this
number to multiply by all the physics math as well as controlling mouse
look.

when i turned of vsync it made the time between frames go so low (it was
reporting like 4 miliseconds) that it was too small to multiply by the mouse
values or something…when i moved the mouse it would move a very small
amount only some of the time and be relaly jerky.

is there a better way to handle mouse look at high fps than by rotating by
mousemotion*time between frames?

Thank!
Alan> ----- Original Message -----

From: marc@solcon.nl (M.A. Oude Kotte)
To:
Sent: Thursday, February 19, 2004 4:53 PM
Subject: Re: [SDL] OpenGL speed under windows

Use the following code to disable vsync waits in Windows:

typedef void (APIENTRY * WGLSWAPINTERVALEXT) (int);
WGLSWAPINTERVALEXT wglSwapIntervalEXT = (WGLSWAPINTERVALEXT)
wglGetProcAddress(“wglSwapIntervalEXT”);
if (wglSwapIntervalEXT) {
wglSwapIntervalEXT(0); // disable vertical synchronisation
}

Marc

Gerald wrote:

Hi all,

I’m new to SDL, and somewhat newish with OpenGL. Heres my question…

I’m getting about 60 fps when rotating a 500 polygon textured object.
This is on a P4 HT 2.53 GHz with a Geforce 4 MX 440 card.

I should be getting way more than that, shouldn’t I?

Also, fsaa doesn’t seem to work at all…

Thanks in advance for your help!

Here is my core display loop…

int RunGLTest( int argc, char* argv[],
int logo, int slowly, int bpp, float gamma, int noframe,
int fsaa )
{
int i;
int rgb_size[3];
int w = 640;
int h = 480;
int done = 0;
int frames;
Uint32 start_time, this_time;

Uint32 video_flags;
int value;


if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
    fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
    exit( 1 );
}

/* See if we should detect the display depth */
if ( bpp == 0 )
{
    if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 )
    {
        bpp = 8;
    } else
    {
        bpp = 16;  /* More doesn't seem to work */
    }
}

bpp = 0 ;

/* Set the flags we want to use for setting the video mode */
if ( logo && USE_DEPRECATED_OPENGLBLIT )
{
    video_flags = SDL_OPENGLBLIT;
} else
{
    video_flags = SDL_OPENGL;
}

video_flags |= SDL_OPENGLBLIT ;

for ( i=1; argv[i]; ++i )
{
    if ( strcmp(argv[1], "-fullscreen") == 0 )
    {
        video_flags |= SDL_FULLSCREEN;
    }
}

if (noframe)
{
    video_flags |= SDL_NOFRAME;
}

video_flags |= SDL_HWSURFACE;
video_flags |= SDL_HWPALETTE ;
video_flags |= SDL_HWACCEL ;

/* Initialize the display */
switch (bpp)
{
    case 8:
        rgb_size[0] = 3;
        rgb_size[1] = 3;
        rgb_size[2] = 2;
        break;

    case 15:
    case 16:
        rgb_size[0] = 5;
        rgb_size[1] = 5;
        rgb_size[2] = 5;
        break;

    default:
        rgb_size[0] = 8;
        rgb_size[1] = 8;
        rgb_size[2] = 8;
        break;
}

SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

if ( fsaa )
{
    SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
    SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
}
if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL )
{
    fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
    SDL_Quit();
    exit(1);
}


printf("Screen BPP: %d\n",

SDL_GetVideoSurface()->format->BitsPerPixel);
printf("\n");
printf( “Vendor : %s\n”, glGetString( GL_VENDOR ) );
printf( “Renderer : %s\n”, glGetString( GL_RENDERER ) );
printf( “Version : %s\n”, glGetString( GL_VERSION ) );
printf( “Extensions : %s\n”, glGetString( GL_EXTENSIONS ) );
printf("\n");

SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
printf( "SDL_GL_RED_SIZE: requested %d, got %d\n",

rgb_size[0],value);

SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n",

rgb_size[1],value);

SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n",

rgb_size[2],value);

SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );

SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );

if ( fsaa )
{
    SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
    printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n",

value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( “SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n”,
fsaa, value );
}

/* Set the window manager title bar */
SDL_WM_SetCaption( "SDL GL test", "testgl" );

/* Set the gamma for the window */
if ( gamma != 0.0 )
{
    SDL_SetGamma(gamma, gamma, gamma);
}


glEnable( GL_DEPTH_TEST );
glClearColor(0.0, 0.0, 0.2, 0.0); // This clear the background color

to dark blue
glShadeModel(GL_SMOOTH); // Type of shading for the polygons
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); // Polygon rasterization
mode (polygon filled)
glEnable(GL_TEXTURE_2D); // This Enable the Texture mapping

glViewport(0,0,w,h);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// FOV        // Ratio                //  The farthest distance

before it stops drawing
perspectiveGL(45.0f,(GLfloat)w/(GLfloat)h, .5f ,5000.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

unsigned long totalpolys = 0 ;

for(int x = 0; x < MAX_OBJECTS; x++)
{
    cLoad3DS my3ds(&object[x], "spaceship.3ds",

“spaceshiptexture.bmp”);
if(object[x].valid == false)
{
MessageBox(NULL,“Object not loaded”, “Error”,MB_OK |
MB_ICONERROR);
return 0 ;
}

    totalpolys += object[x].polygons_qty ;
}

printf("Total polygons: %ld\n", totalpolys) ;

/* Loop until done. */
start_time = SDL_GetTicks();
frames = 0;


// Absolute rotation values (0-359 degrees) and rotation increments

for each frame
// double rotation_x=0, rotation_x_increment=0.1;
// double rotation_y=0, rotation_y_increment=0.05;
// double rotation_z=0, rotation_z_increment=0.03;
double rotation_x=0, rotation_x_increment=0.5;
double rotation_y=0, rotation_y_increment=0.25;
double rotation_z=0, rotation_z_increment=0.15;

GLuint displaylist ;
displaylist = glGenLists(1) ;

glNewList(displaylist, GL_COMPILE) ;
for(int x = 0; x < MAX_OBJECTS; x++)
{
    glBindTexture(GL_TEXTURE_2D, object[x].id_texture); // We set

the active texture
object[x].Draw(true) ;
}
glEndList() ;

glMatrixMode(GL_MODELVIEW); // Modeling transformation
glLoadIdentity(); // Initialize the model matrix as identity

glTranslatef(0.0,0.0,-600); // We move the object forward (the model

matrix is multiplied by the translation matrix)

rotation_x = rotation_x + rotation_x_increment;
rotation_y = rotation_y + rotation_y_increment;
rotation_z = rotation_z + rotation_z_increment;

while( !done )
{
    GLenum gl_error;
    char* sdl_error;
    SDL_Event event;

    /* Do our drawing, too. */

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This

clear the background color to dark blue
// glMatrixMode(GL_MODELVIEW); // Modeling transformation
// glLoadIdentity(); // Initialize the model matrix as identity

// glTranslatef(0.0,0.0,-300); // We move the object forward (the
model matrix is multiplied by the translation matrix)

// rotation_x = rotation_x + rotation_x_increment;
// rotation_y = rotation_y + rotation_y_increment;
// rotation_z = rotation_z + rotation_z_increment;

    if (rotation_x > 359) rotation_x = 0;
    if (rotation_y > 359) rotation_y = 0;
    if (rotation_z > 359) rotation_z = 0;

    glRotatef(rotation_x,1.0,0.0,0.0); // Rotations of the object

(the model matrix is multiplied by the rotation matrices)
glRotatef(rotation_y,0.0,1.0,0.0);
glRotatef(rotation_z,0.0,0.0,1.0);

    glCallList(displaylist) ;

    SDL_GL_SwapBuffers();



    /* Check if there's a pending event. */
    while( SDL_PollEvent( &event ) )
    {
        done = HandleEvent(&event);
    }
    ++frames;

    this_time = SDL_GetTicks();
    if ( this_time >= start_time + 500)
    {
        static char name[1024] ;
        sprintf(name, "SDL GL test [polys: %ld  fps: %5.2f]",

totalpolys,((float)frames/(this_time-start_time))*1000.0);

        start_time = this_time ;
        frames = 0 ;
        SDL_WM_SetCaption( name, "testgl" );
        printf("%s\n", name) ;
    }

}



/* Print out the frames per second */
this_time = SDL_GetTicks();
if ( this_time != start_time )
{
    printf("%2.2f FPS\n",
        ((float)frames/(this_time-start_time))*1000.0);
}

if ( global_image )
{
    SDL_FreeSurface(global_image);
    global_image = NULL;
}
if ( global_texture )
{
    glDeleteTextures( 1, &global_texture );
    global_texture = 0;
}

/* Destroy our GL context, etc. */
SDL_Quit( );
return(0);

}


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


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

This is sort of a repetition, but worth mentioning again, I think.
You’re still only showing 60 fps, you’re just generating hundreds of
frames that aren’t seen.

vsync is a ‘good thing’. Not a ‘bad thing’. The only reason you’d want
to shut this off (that I know of) is if you need more logic steps then
visual - which most apps don’t need. Even if you DO, you could do two
logic steps per frame, or 8… or 50… it ain’t gonna matter because
those 8 or 50 additional frames can’t be seen, even if you draw them.

Doing this will make an otherwise low CPU app pin the processor, which
is also a ‘bad thing’, because where your app used to sleep for the
sync, it’s now busy filling and emptying the GL framebuffer for nothing.On Thu, 2004-02-19 at 20:24, Alan Wolfe wrote:

wow thats awesome (:

thanks for the snippet, ive always wondered how to do that.

i just tried it out and now i have a question.

in my main loop it keeps track of the time between frames and uses this
number to multiply by all the physics math as well as controlling mouse
look.

when i turned of vsync it made the time between frames go so low (it was
reporting like 4 miliseconds) that it was too small to multiply by the mouse
values or something…when i moved the mouse it would move a very small
amount only some of the time and be relaly jerky.

is there a better way to handle mouse look at high fps than by rotating by
mousemotion*time between frames?

Thank!
Alan

----- Original Message -----
From: “M.A. Oude Kotte”
To:
Sent: Thursday, February 19, 2004 4:53 PM
Subject: Re: [SDL] OpenGL speed under windows

Use the following code to disable vsync waits in Windows:

typedef void (APIENTRY * WGLSWAPINTERVALEXT) (int);
WGLSWAPINTERVALEXT wglSwapIntervalEXT = (WGLSWAPINTERVALEXT)
wglGetProcAddress(“wglSwapIntervalEXT”);
if (wglSwapIntervalEXT) {
wglSwapIntervalEXT(0); // disable vertical synchronisation
}

Marc

Gerald wrote:

Hi all,

I’m new to SDL, and somewhat newish with OpenGL. Heres my question…

I’m getting about 60 fps when rotating a 500 polygon textured object.
This is on a P4 HT 2.53 GHz with a Geforce 4 MX 440 card.

I should be getting way more than that, shouldn’t I?

Also, fsaa doesn’t seem to work at all…

Thanks in advance for your help!

Here is my core display loop…

int RunGLTest( int argc, char* argv[],
int logo, int slowly, int bpp, float gamma, int noframe,
int fsaa )
{
int i;
int rgb_size[3];
int w = 640;
int h = 480;
int done = 0;
int frames;
Uint32 start_time, this_time;

Uint32 video_flags;
int value;


if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
    fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
    exit( 1 );
}

/* See if we should detect the display depth */
if ( bpp == 0 )
{
    if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 )
    {
        bpp = 8;
    } else
    {
        bpp = 16;  /* More doesn't seem to work */
    }
}

bpp = 0 ;

/* Set the flags we want to use for setting the video mode */
if ( logo && USE_DEPRECATED_OPENGLBLIT )
{
    video_flags = SDL_OPENGLBLIT;
} else
{
    video_flags = SDL_OPENGL;
}

video_flags |= SDL_OPENGLBLIT ;

for ( i=1; argv[i]; ++i )
{
    if ( strcmp(argv[1], "-fullscreen") == 0 )
    {
        video_flags |= SDL_FULLSCREEN;
    }
}

if (noframe)
{
    video_flags |= SDL_NOFRAME;
}

video_flags |= SDL_HWSURFACE;
video_flags |= SDL_HWPALETTE ;
video_flags |= SDL_HWACCEL ;

/* Initialize the display */
switch (bpp)
{
    case 8:
        rgb_size[0] = 3;
        rgb_size[1] = 3;
        rgb_size[2] = 2;
        break;

    case 15:
    case 16:
        rgb_size[0] = 5;
        rgb_size[1] = 5;
        rgb_size[2] = 5;
        break;

    default:
        rgb_size[0] = 8;
        rgb_size[1] = 8;
        rgb_size[2] = 8;
        break;
}

SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

if ( fsaa )
{
    SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
    SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
}
if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL )
{
    fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
    SDL_Quit();
    exit(1);
}


printf("Screen BPP: %d\n",

SDL_GetVideoSurface()->format->BitsPerPixel);
printf("\n");
printf( “Vendor : %s\n”, glGetString( GL_VENDOR ) );
printf( “Renderer : %s\n”, glGetString( GL_RENDERER ) );
printf( “Version : %s\n”, glGetString( GL_VERSION ) );
printf( “Extensions : %s\n”, glGetString( GL_EXTENSIONS ) );
printf("\n");

SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
printf( "SDL_GL_RED_SIZE: requested %d, got %d\n",

rgb_size[0],value);

SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n",

rgb_size[1],value);

SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n",

rgb_size[2],value);

SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );

SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );

if ( fsaa )
{
    SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
    printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n",

value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( “SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n”,
fsaa, value );
}

/* Set the window manager title bar */
SDL_WM_SetCaption( "SDL GL test", "testgl" );

/* Set the gamma for the window */
if ( gamma != 0.0 )
{
    SDL_SetGamma(gamma, gamma, gamma);
}


glEnable( GL_DEPTH_TEST );
glClearColor(0.0, 0.0, 0.2, 0.0); // This clear the background color

to dark blue
glShadeModel(GL_SMOOTH); // Type of shading for the polygons
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); // Polygon rasterization
mode (polygon filled)
glEnable(GL_TEXTURE_2D); // This Enable the Texture mapping

glViewport(0,0,w,h);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// FOV        // Ratio                //  The farthest distance

before it stops drawing
perspectiveGL(45.0f,(GLfloat)w/(GLfloat)h, .5f ,5000.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

unsigned long totalpolys = 0 ;

for(int x = 0; x < MAX_OBJECTS; x++)
{
    cLoad3DS my3ds(&object[x], "spaceship.3ds",

“spaceshiptexture.bmp”);
if(object[x].valid == false)
{
MessageBox(NULL,“Object not loaded”, “Error”,MB_OK |
MB_ICONERROR);
return 0 ;
}

    totalpolys += object[x].polygons_qty ;
}

printf("Total polygons: %ld\n", totalpolys) ;

/* Loop until done. */
start_time = SDL_GetTicks();
frames = 0;


// Absolute rotation values (0-359 degrees) and rotation increments

for each frame
// double rotation_x=0, rotation_x_increment=0.1;
// double rotation_y=0, rotation_y_increment=0.05;
// double rotation_z=0, rotation_z_increment=0.03;
double rotation_x=0, rotation_x_increment=0.5;
double rotation_y=0, rotation_y_increment=0.25;
double rotation_z=0, rotation_z_increment=0.15;

GLuint displaylist ;
displaylist = glGenLists(1) ;

glNewList(displaylist, GL_COMPILE) ;
for(int x = 0; x < MAX_OBJECTS; x++)
{
    glBindTexture(GL_TEXTURE_2D, object[x].id_texture); // We set

the active texture
object[x].Draw(true) ;
}
glEndList() ;

glMatrixMode(GL_MODELVIEW); // Modeling transformation
glLoadIdentity(); // Initialize the model matrix as identity

glTranslatef(0.0,0.0,-600); // We move the object forward (the model

matrix is multiplied by the translation matrix)

rotation_x = rotation_x + rotation_x_increment;
rotation_y = rotation_y + rotation_y_increment;
rotation_z = rotation_z + rotation_z_increment;

while( !done )
{
    GLenum gl_error;
    char* sdl_error;
    SDL_Event event;

    /* Do our drawing, too. */

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This

clear the background color to dark blue
// glMatrixMode(GL_MODELVIEW); // Modeling transformation
// glLoadIdentity(); // Initialize the model matrix as identity

// glTranslatef(0.0,0.0,-300); // We move the object forward (the
model matrix is multiplied by the translation matrix)

// rotation_x = rotation_x + rotation_x_increment;
// rotation_y = rotation_y + rotation_y_increment;
// rotation_z = rotation_z + rotation_z_increment;

    if (rotation_x > 359) rotation_x = 0;
    if (rotation_y > 359) rotation_y = 0;
    if (rotation_z > 359) rotation_z = 0;

    glRotatef(rotation_x,1.0,0.0,0.0); // Rotations of the object

(the model matrix is multiplied by the rotation matrices)
glRotatef(rotation_y,0.0,1.0,0.0);
glRotatef(rotation_z,0.0,0.0,1.0);

    glCallList(displaylist) ;

    SDL_GL_SwapBuffers();



    /* Check if there's a pending event. */
    while( SDL_PollEvent( &event ) )
    {
        done = HandleEvent(&event);
    }
    ++frames;

    this_time = SDL_GetTicks();
    if ( this_time >= start_time + 500)
    {
        static char name[1024] ;
        sprintf(name, "SDL GL test [polys: %ld  fps: %5.2f]",

totalpolys,((float)frames/(this_time-start_time))*1000.0);

        start_time = this_time ;
        frames = 0 ;
        SDL_WM_SetCaption( name, "testgl" );
        printf("%s\n", name) ;
    }

}



/* Print out the frames per second */
this_time = SDL_GetTicks();
if ( this_time != start_time )
{
    printf("%2.2f FPS\n",
        ((float)frames/(this_time-start_time))*1000.0);
}

if ( global_image )
{
    SDL_FreeSurface(global_image);
    global_image = NULL;
}
if ( global_texture )
{
    glDeleteTextures( 1, &global_texture );
    global_texture = 0;
}

/* Destroy our GL context, etc. */
SDL_Quit( );
return(0);

}


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


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


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

You’re probably measuring the time in milliseconds (10e-03). In stead,
you could use microseconds (10e-06). Both Linux and Windows have
functions for that.

Marc

Alan Wolfe wrote:> wow thats awesome (:

thanks for the snippet, ive always wondered how to do that.

i just tried it out and now i have a question.

in my main loop it keeps track of the time between frames and uses this
number to multiply by all the physics math as well as controlling mouse
look.

when i turned of vsync it made the time between frames go so low (it was
reporting like 4 miliseconds) that it was too small to multiply by the mouse
values or something…when i moved the mouse it would move a very small
amount only some of the time and be relaly jerky.

is there a better way to handle mouse look at high fps than by rotating by
mousemotion*time between frames?

Thank!
Alan

----- Original Message -----
From: “M.A. Oude Kotte” <@M.A_Oude_Kotte>
To:
Sent: Thursday, February 19, 2004 4:53 PM
Subject: Re: [SDL] OpenGL speed under windows

Use the following code to disable vsync waits in Windows:

typedef void (APIENTRY * WGLSWAPINTERVALEXT) (int);
WGLSWAPINTERVALEXT wglSwapIntervalEXT = (WGLSWAPINTERVALEXT)
wglGetProcAddress(“wglSwapIntervalEXT”);
if (wglSwapIntervalEXT) {
wglSwapIntervalEXT(0); // disable vertical synchronisation
}

Marc

Gerald wrote:

Hi all,

I’m new to SDL, and somewhat newish with OpenGL. Heres my question…

I’m getting about 60 fps when rotating a 500 polygon textured object.
This is on a P4 HT 2.53 GHz with a Geforce 4 MX 440 card.

I should be getting way more than that, shouldn’t I?

Also, fsaa doesn’t seem to work at all…

Thanks in advance for your help!

Here is my core display loop…

int RunGLTest( int argc, char* argv[],
int logo, int slowly, int bpp, float gamma, int noframe,
int fsaa )
{
int i;
int rgb_size[3];
int w = 640;
int h = 480;
int done = 0;
int frames;
Uint32 start_time, this_time;

Uint32 video_flags;
int value;

if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
fprintf(stderr,“Couldn’t initialize SDL: %s\n”,SDL_GetError());
exit( 1 );
}

/* See if we should detect the display depth /
if ( bpp == 0 )
{
if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 )
{
bpp = 8;
} else
{
bpp = 16; /
More doesn’t seem to work */
}
}

bpp = 0 ;

/* Set the flags we want to use for setting the video mode */
if ( logo && USE_DEPRECATED_OPENGLBLIT )
{
video_flags = SDL_OPENGLBLIT;
} else
{
video_flags = SDL_OPENGL;
}

video_flags |= SDL_OPENGLBLIT ;

for ( i=1; argv[i]; ++i )
{
if ( strcmp(argv[1], “-fullscreen”) == 0 )
{
video_flags |= SDL_FULLSCREEN;
}
}

if (noframe)
{
video_flags |= SDL_NOFRAME;
}

video_flags |= SDL_HWSURFACE;
video_flags |= SDL_HWPALETTE ;
video_flags |= SDL_HWACCEL ;

/* Initialize the display */
switch (bpp)
{
case 8:
rgb_size[0] = 3;
rgb_size[1] = 3;
rgb_size[2] = 2;
break;

   case 15:
   case 16:
       rgb_size[0] = 5;
       rgb_size[1] = 5;
       rgb_size[2] = 5;
       break;

   default:
       rgb_size[0] = 8;
       rgb_size[1] = 8;
       rgb_size[2] = 8;
       break;

}

SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

if ( fsaa )
{
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
}
if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL )
{
fprintf(stderr, “Couldn’t set GL mode: %s\n”, SDL_GetError());
SDL_Quit();
exit(1);
}

printf(“Screen BPP: %d\n”,
SDL_GetVideoSurface()->format->BitsPerPixel);
printf("\n");
printf( “Vendor : %s\n”, glGetString( GL_VENDOR ) );
printf( “Renderer : %s\n”, glGetString( GL_RENDERER ) );
printf( “Version : %s\n”, glGetString( GL_VERSION ) );
printf( “Extensions : %s\n”, glGetString( GL_EXTENSIONS ) );
printf("\n");

SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
printf( “SDL_GL_RED_SIZE: requested %d, got %d\n”,

rgb_size[0],value);

SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
printf( “SDL_GL_GREEN_SIZE: requested %d, got %d\n”,
rgb_size[1],value);

SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
printf( “SDL_GL_BLUE_SIZE: requested %d, got %d\n”,

rgb_size[2],value);

SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
printf( “SDL_GL_DEPTH_SIZE: requested %d, got %d\n”, bpp, value );

SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
printf( “SDL_GL_DOUBLEBUFFER: requested 1, got %d\n”, value );

if ( fsaa )
{
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
printf( “SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n”,
value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( “SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n”,
fsaa, value );
}

/* Set the window manager title bar */
SDL_WM_SetCaption( “SDL GL test”, “testgl” );

/* Set the gamma for the window */
if ( gamma != 0.0 )
{
SDL_SetGamma(gamma, gamma, gamma);
}

glEnable( GL_DEPTH_TEST );
glClearColor(0.0, 0.0, 0.2, 0.0); // This clear the background color
to dark blue
glShadeModel(GL_SMOOTH); // Type of shading for the polygons
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); // Polygon rasterization
mode (polygon filled)
glEnable(GL_TEXTURE_2D); // This Enable the Texture mapping

glViewport(0,0,w,h);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// FOV // Ratio // The farthest distance
before it stops drawing
perspectiveGL(45.0f,(GLfloat)w/(GLfloat)h, .5f ,5000.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

unsigned long totalpolys = 0 ;

for(int x = 0; x < MAX_OBJECTS; x++)
{
cLoad3DS my3ds(&object[x], “spaceship.3ds”,
“spaceshiptexture.bmp”);
if(object[x].valid == false)
{
MessageBox(NULL,“Object not loaded”, “Error”,MB_OK |
MB_ICONERROR);
return 0 ;
}

   totalpolys += object[x].polygons_qty ;

}

printf(“Total polygons: %ld\n”, totalpolys) ;

/* Loop until done. */
start_time = SDL_GetTicks();
frames = 0;

// Absolute rotation values (0-359 degrees) and rotation increments
for each frame
// double rotation_x=0, rotation_x_increment=0.1;
// double rotation_y=0, rotation_y_increment=0.05;
// double rotation_z=0, rotation_z_increment=0.03;
double rotation_x=0, rotation_x_increment=0.5;
double rotation_y=0, rotation_y_increment=0.25;
double rotation_z=0, rotation_z_increment=0.15;

GLuint displaylist ;
displaylist = glGenLists(1) ;

glNewList(displaylist, GL_COMPILE) ;
for(int x = 0; x < MAX_OBJECTS; x++)
{
glBindTexture(GL_TEXTURE_2D, object[x].id_texture); // We set
the active texture
object[x].Draw(true) ;
}
glEndList() ;

glMatrixMode(GL_MODELVIEW); // Modeling transformation
glLoadIdentity(); // Initialize the model matrix as identity

glTranslatef(0.0,0.0,-600); // We move the object forward (the model
matrix is multiplied by the translation matrix)

rotation_x = rotation_x + rotation_x_increment;
rotation_y = rotation_y + rotation_y_increment;
rotation_z = rotation_z + rotation_z_increment;

while( !done )
{
GLenum gl_error;
char* sdl_error;
SDL_Event event;

   /* Do our drawing, too. */

   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This

clear the background color to dark blue
// glMatrixMode(GL_MODELVIEW); // Modeling transformation
// glLoadIdentity(); // Initialize the model matrix as identity

// glTranslatef(0.0,0.0,-300); // We move the object forward (the
model matrix is multiplied by the translation matrix)

// rotation_x = rotation_x + rotation_x_increment;
// rotation_y = rotation_y + rotation_y_increment;
// rotation_z = rotation_z + rotation_z_increment;

   if (rotation_x > 359) rotation_x = 0;
   if (rotation_y > 359) rotation_y = 0;
   if (rotation_z > 359) rotation_z = 0;

   glRotatef(rotation_x,1.0,0.0,0.0); // Rotations of the object

(the model matrix is multiplied by the rotation matrices)
glRotatef(rotation_y,0.0,1.0,0.0);
glRotatef(rotation_z,0.0,0.0,1.0);

   glCallList(displaylist) ;

   SDL_GL_SwapBuffers();



   /* Check if there's a pending event. */
   while( SDL_PollEvent( &event ) )
   {
       done = HandleEvent(&event);
   }
   ++frames;

   this_time = SDL_GetTicks();
   if ( this_time >= start_time + 500)
   {
       static char name[1024] ;
       sprintf(name, "SDL GL test [polys: %ld  fps: %5.2f]",

totalpolys,((float)frames/(this_time-start_time))*1000.0);

       start_time = this_time ;
       frames = 0 ;
       SDL_WM_SetCaption( name, "testgl" );
       printf("%s\n", name) ;
   }

}

/* Print out the frames per second */
this_time = SDL_GetTicks();
if ( this_time != start_time )
{
printf("%2.2f FPS\n",
((float)frames/(this_time-start_time))*1000.0);
}

if ( global_image )
{
SDL_FreeSurface(global_image);
global_image = NULL;
}
if ( global_texture )
{
glDeleteTextures( 1, &global_texture );
global_texture = 0;
}

/* Destroy our GL context, etc. */
SDL_Quit( );
return(0);
}


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


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


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

Jimmy (2004-02-21 00:07):

vsync is a ‘good thing’. Not a ‘bad thing’. The only reason you’d want
to shut this off (that I know of) is if you need more logic steps then
visual - which most apps don’t need. Even if you DO, you could do two
logic steps per frame, or 8… or 50… it ain’t gonna matter because
those 8 or 50 additional frames can’t be seen, even if you draw them.

for sure there is use for this, quite a lot! - in many cases - just
think about indepentend sound and gfx output (maybe you listen
faster/slower than you see things) or indeptendent mouse input.

but the solution is NOT to disable v_sync but to implement threads and
internal timing.

imho.–
best regards
ionas

i talked to someone and i found out not all mice are as responsive as
others.

according to them some mice operate at like 60fps and others can be as low
as 15.

the person who had the problem in my game uses a wireless mouse so i can
imagine it wouldnt update as often and having not as many updates could
account for whats happenin to this person.

kinda sucks, i guess you have to do interpolationi n this case and make the
mouse movement be kinda lagged.

sucks :P> ----- Original Message -----

From: marc@solcon.nl (M.A. Oude Kotte)
To:
Sent: Friday, February 20, 2004 4:33 PM
Subject: Re: [SDL] OpenGL speed under windows

You’re probably measuring the time in milliseconds (10e-03). In stead,
you could use microseconds (10e-06). Both Linux and Windows have
functions for that.

Marc

Alan Wolfe wrote:

wow thats awesome (:

thanks for the snippet, ive always wondered how to do that.

i just tried it out and now i have a question.

in my main loop it keeps track of the time between frames and uses this
number to multiply by all the physics math as well as controlling mouse
look.

when i turned of vsync it made the time between frames go so low (it was
reporting like 4 miliseconds) that it was too small to multiply by the
mouse

values or something…when i moved the mouse it would move a very small
amount only some of the time and be relaly jerky.

is there a better way to handle mouse look at high fps than by rotating
by

mousemotion*time between frames?

Thank!
Alan

----- Original Message -----
From: “M.A. Oude Kotte”
To:
Sent: Thursday, February 19, 2004 4:53 PM
Subject: Re: [SDL] OpenGL speed under windows

Use the following code to disable vsync waits in Windows:

typedef void (APIENTRY * WGLSWAPINTERVALEXT) (int);
WGLSWAPINTERVALEXT wglSwapIntervalEXT = (WGLSWAPINTERVALEXT)
wglGetProcAddress(“wglSwapIntervalEXT”);
if (wglSwapIntervalEXT) {
wglSwapIntervalEXT(0); // disable vertical synchronisation
}

Marc

Gerald wrote:

Hi all,

I’m new to SDL, and somewhat newish with OpenGL. Heres my question…

I’m getting about 60 fps when rotating a 500 polygon textured object.
This is on a P4 HT 2.53 GHz with a Geforce 4 MX 440 card.

I should be getting way more than that, shouldn’t I?

Also, fsaa doesn’t seem to work at all…

Thanks in advance for your help!

Here is my core display loop…

int RunGLTest( int argc, char* argv[],
int logo, int slowly, int bpp, float gamma, int noframe,
int fsaa )
{
int i;
int rgb_size[3];
int w = 640;
int h = 480;
int done = 0;
int frames;
Uint32 start_time, this_time;

Uint32 video_flags;
int value;

if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
fprintf(stderr,“Couldn’t initialize SDL: %s\n”,SDL_GetError());
exit( 1 );
}

/* See if we should detect the display depth /
if ( bpp == 0 )
{
if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 )
{
bpp = 8;
} else
{
bpp = 16; /
More doesn’t seem to work */
}
}

bpp = 0 ;

/* Set the flags we want to use for setting the video mode */
if ( logo && USE_DEPRECATED_OPENGLBLIT )
{
video_flags = SDL_OPENGLBLIT;
} else
{
video_flags = SDL_OPENGL;
}

video_flags |= SDL_OPENGLBLIT ;

for ( i=1; argv[i]; ++i )
{
if ( strcmp(argv[1], “-fullscreen”) == 0 )
{
video_flags |= SDL_FULLSCREEN;
}
}

if (noframe)
{
video_flags |= SDL_NOFRAME;
}

video_flags |= SDL_HWSURFACE;
video_flags |= SDL_HWPALETTE ;
video_flags |= SDL_HWACCEL ;

/* Initialize the display */
switch (bpp)
{
case 8:
rgb_size[0] = 3;
rgb_size[1] = 3;
rgb_size[2] = 2;
break;

   case 15:
   case 16:
       rgb_size[0] = 5;
       rgb_size[1] = 5;
       rgb_size[2] = 5;
       break;

   default:
       rgb_size[0] = 8;
       rgb_size[1] = 8;
       rgb_size[2] = 8;
       break;

}

SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

if ( fsaa )
{
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
}
if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL )
{
fprintf(stderr, “Couldn’t set GL mode: %s\n”, SDL_GetError());
SDL_Quit();
exit(1);
}

printf(“Screen BPP: %d\n”,
SDL_GetVideoSurface()->format->BitsPerPixel);
printf("\n");
printf( “Vendor : %s\n”, glGetString( GL_VENDOR ) );
printf( “Renderer : %s\n”, glGetString( GL_RENDERER ) );
printf( “Version : %s\n”, glGetString( GL_VERSION ) );
printf( “Extensions : %s\n”, glGetString( GL_EXTENSIONS ) );
printf("\n");

SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
printf( “SDL_GL_RED_SIZE: requested %d, got %d\n”,

rgb_size[0],value);

SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
printf( “SDL_GL_GREEN_SIZE: requested %d, got %d\n”,
rgb_size[1],value);

SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
printf( “SDL_GL_BLUE_SIZE: requested %d, got %d\n”,

rgb_size[2],value);

SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
printf( “SDL_GL_DEPTH_SIZE: requested %d, got %d\n”, bpp, value );

SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
printf( “SDL_GL_DOUBLEBUFFER: requested 1, got %d\n”, value );

if ( fsaa )
{
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
printf( “SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n”,
value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( “SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n”,
fsaa, value );
}

/* Set the window manager title bar */
SDL_WM_SetCaption( “SDL GL test”, “testgl” );

/* Set the gamma for the window */
if ( gamma != 0.0 )
{
SDL_SetGamma(gamma, gamma, gamma);
}

glEnable( GL_DEPTH_TEST );
glClearColor(0.0, 0.0, 0.2, 0.0); // This clear the background
color

to dark blue
glShadeModel(GL_SMOOTH); // Type of shading for the polygons
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); // Polygon
rasterization

mode (polygon filled)
glEnable(GL_TEXTURE_2D); // This Enable the Texture mapping

glViewport(0,0,w,h);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// FOV // Ratio // The farthest distance
before it stops drawing
perspectiveGL(45.0f,(GLfloat)w/(GLfloat)h, .5f ,5000.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

unsigned long totalpolys = 0 ;

for(int x = 0; x < MAX_OBJECTS; x++)
{
cLoad3DS my3ds(&object[x], “spaceship.3ds”,
“spaceshiptexture.bmp”);
if(object[x].valid == false)
{
MessageBox(NULL,“Object not loaded”, “Error”,MB_OK |
MB_ICONERROR);
return 0 ;
}

   totalpolys += object[x].polygons_qty ;

}

printf(“Total polygons: %ld\n”, totalpolys) ;

/* Loop until done. */
start_time = SDL_GetTicks();
frames = 0;

// Absolute rotation values (0-359 degrees) and rotation increments
for each frame
// double rotation_x=0, rotation_x_increment=0.1;
// double rotation_y=0, rotation_y_increment=0.05;
// double rotation_z=0, rotation_z_increment=0.03;
double rotation_x=0, rotation_x_increment=0.5;
double rotation_y=0, rotation_y_increment=0.25;
double rotation_z=0, rotation_z_increment=0.15;

GLuint displaylist ;
displaylist = glGenLists(1) ;

glNewList(displaylist, GL_COMPILE) ;
for(int x = 0; x < MAX_OBJECTS; x++)
{
glBindTexture(GL_TEXTURE_2D, object[x].id_texture); // We set
the active texture
object[x].Draw(true) ;
}
glEndList() ;

glMatrixMode(GL_MODELVIEW); // Modeling transformation
glLoadIdentity(); // Initialize the model matrix as identity

glTranslatef(0.0,0.0,-600); // We move the object forward (the
model

matrix is multiplied by the translation matrix)

rotation_x = rotation_x + rotation_x_increment;
rotation_y = rotation_y + rotation_y_increment;
rotation_z = rotation_z + rotation_z_increment;

while( !done )
{
GLenum gl_error;
char* sdl_error;
SDL_Event event;

   /* Do our drawing, too. */

   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This

clear the background color to dark blue
// glMatrixMode(GL_MODELVIEW); // Modeling transformation
// glLoadIdentity(); // Initialize the model matrix as identity

// glTranslatef(0.0,0.0,-300); // We move the object forward
(the

model matrix is multiplied by the translation matrix)

// rotation_x = rotation_x + rotation_x_increment;
// rotation_y = rotation_y + rotation_y_increment;
// rotation_z = rotation_z + rotation_z_increment;

   if (rotation_x > 359) rotation_x = 0;
   if (rotation_y > 359) rotation_y = 0;
   if (rotation_z > 359) rotation_z = 0;

   glRotatef(rotation_x,1.0,0.0,0.0); // Rotations of the object

(the model matrix is multiplied by the rotation matrices)
glRotatef(rotation_y,0.0,1.0,0.0);
glRotatef(rotation_z,0.0,0.0,1.0);

   glCallList(displaylist) ;

   SDL_GL_SwapBuffers();



   /* Check if there's a pending event. */
   while( SDL_PollEvent( &event ) )
   {
       done = HandleEvent(&event);
   }
   ++frames;

   this_time = SDL_GetTicks();
   if ( this_time >= start_time + 500)
   {
       static char name[1024] ;
       sprintf(name, "SDL GL test [polys: %ld  fps: %5.2f]",

totalpolys,((float)frames/(this_time-start_time))*1000.0);

       start_time = this_time ;
       frames = 0 ;
       SDL_WM_SetCaption( name, "testgl" );
       printf("%s\n", name) ;
   }

}

/* Print out the frames per second */
this_time = SDL_GetTicks();
if ( this_time != start_time )
{
printf("%2.2f FPS\n",
((float)frames/(this_time-start_time))*1000.0);
}

if ( global_image )
{
SDL_FreeSurface(global_image);
global_image = NULL;
}
if ( global_texture )
{
glDeleteTextures( 1, &global_texture );
global_texture = 0;
}

/* Destroy our GL context, etc. */
SDL_Quit( );
return(0);
}


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


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


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


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

i talked to someone and i found out not all mice are as responsive
as others.

according to them some mice operate at like 60fps and others can be
as low as 15.

Up to 200 fps is common, actually, though the default is usually 60
fps.

the person who had the problem in my game uses a wireless mouse so

Uh oh…!

i can imagine it wouldnt update as often and having not as many
updates could account for whats happenin to this person.

Right. IMHO, wireless (and optical) mice have been toys until quite
recently. Useless for FPS games, and too inaccurate and/or "nervous"
for serious desktop use. The last generation is a great improvement,
though.

I’d recommend the Logitech MX700. The frame rate and resolution of
that one is on par with that of serious wire + ball mice, but the
best part is that it just won’t lose tracking, no matter what.

kinda sucks, i guess you have to do interpolationi n this case and
make the mouse movement be kinda lagged.

Yep.

It might be possible to do some form of extrapolation to avoid or
eliminate the lag, but I suspect it’ll amplify any jitter and other
noise you get as an extra bonus…

Kalmann predictors, maybe?

However, there is no way of eliminating the latency that is caused by
the low frame rate itself. There just is no new information available
until the next mouse move event arrives, no matter what the user
does.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Saturday 21 February 2004 23.43, Alan Wolfe wrote:

i talked to someone and i found out not all mice are as responsive as
others.

according to them some mice operate at like 60fps and others can be as low
as 15.

It actually depends on both your connection type (PS/2, serial, or USB) and
your OS settings.

On Windows, the default refresh rate for a PS/2 mouse is 40hz, but I’ve seen
people push that up to 200hz (theoretically – in practice this makes a
refresh rate of around 120hz) – this setting is in the Registry as
"HKEY_LOCAL_MACHINE\Software\Logitech\MouseWare\CurrentVersion\Technical\PS2
ReportRate", experiment away. Serial, I believe, has a maximum refresh rate
of somewhere around 40hz (hardware limitation), and USB depends mostly on
the hardware (though, I’m sure some of them have ways to control the refresh
rate).

I’m not familiar enough with the PS/2 settings in Linux, so I can’t name a
default, or how you would set them. The Serial and USB comments are still
valid for Linux, though.


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.580 / Virus Database: 367 - Release Date: 2/6/2004

----- Original Message -----
From: atrix2@cox.net (atrix2)
To:
Sent: Saturday, February 21, 2004 10:43 PM
Subject: Re: [SDL] OpenGL speed under windows

That depends, if your screen’s refresh rate is set to 60hz then 60fps is
your maximum :)On Wed, 2004-02-18 at 15:37, Gerald wrote:

Hi all,

I’m new to SDL, and somewhat newish with OpenGL. Heres my question…

I’m getting about 60 fps when rotating a 500 polygon textured object.
This is on a P4 HT 2.53 GHz with a Geforce 4 MX 440 card.

I should be getting way more than that, shouldn’t I?