Problems with SDL_OPENGL

Good day!

I try the new release of SDL and get a mysterious SEGFAULT. I running
XFree-4.3 with “trident” driver at 1024x768 with 24bpp and SDL-1.2.7. Simple
program below give me segfault after adding flag SDL_OPENGL:

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

#define WIDTH 1024
#define HEIGHT 768
#define BPP 24

/**

  • Start point.
    */

int main(int argn,char** arg,char** anv)
{
int result = SDL_Init(SDL_INIT_VIDEO) ;
if(result==-1)
{
printf(“Cannot initialize SDL. Aborting.\n”);
exit(-1) ;
}
SDL_Surface* primary = SDL_SetVideoMode(WIDTH,HEIGHT,BPP,SDL_FULLSCREEN |
SDL_DOUBLEBUF | SDL_OPENGL) ;
if(primary==NULL)
{
printf(“Cannot set video mode. Aborting.\n”) ;
exit(-1) ;
}

SDL_Surface* img = IMG_Load("./data/images/button_options_selected.png");
if(img==NULL)
{
    printf("Cannot load picture.Aborting.")     		;
    SDL_Quit()                  	    	    				;
}

SDL_Rect imgrect                               			;
SDL_Rect scrrect                                			;

imgrect.x = 0                                   				;
imgrect.y = 0                                   				;
imgrect.w = 100                         	    				;
imgrect.h = 100                          	    				;

scrrect.x = 0                                   				;
scrrect.y = 0                                   				;
scrrect.w = 100                                 				;
scrrect.h = 100                         	    				;	  	 

SDL_BlitSurface(img,&imgrect,primary,&scrrect)  ;

SDL_Flip(primary) 				    ;         
sleep(3) ;
return 0                                        ;

}

Without SDL_OPENGL flag it works well, but with it it crashes 100% cases. I
add following printf’s to SDL_video.c :

339a340,349

printf(“Successfully returning from SDL_ListModes…\n”);
printf(“Modes so far encountered at adress %p :\n”,modes);
if( modes == (SDL_Rect **)0 ) {
printf("\tMode array equal to 0. No sizes possible…\n");
} else {
if(( modes == (SDL_Rect **)-1))
{
printf("\tMode array equal to -1. Any size possible…\n");
}
}
400a411
printf("\tMode %i : modes[i]->w = %i modes[i]->h =
%i\n",i,sizes[i]->w,sizes[i]->h);

In functions SDL_ListModes and SDL_VideoModeOk. Output is following :

Successfully returning from SDL_ListModes…
Modes so far encountered at adress (nil) :
Mode array equal to 0. No sizes possible…
Successfully returning from SDL_ListModes…
Modes so far encountered at adress (nil) :
Mode array equal to 0. No sizes possible…
Successfully returning from SDL_ListModes…
Modes so far encountered at adress 0x80fe6e8 :

As I far as I understand, SEGFAULT come when SDL_VideoModeOk trying to get
access to element of “sizes” array. If somebody could point me, where is the
rake, it would be great.

Thanks in advance…–
With best regards,
Vadik Mironov

Small addition.

Today I ran this program on Suse with XFree 4.3.0, gcc 3.3.2 , SDL 1.2.5 , 

with nvidia driver 5336. Also segfault happens, seems to be the same as on
previous machine.
Without SDL_OPENGL flag it works well as expected except resolution 1024x768.
With this resolution screen flickers and tons of horizontal stripes appeared
for a moment in random positions and in a random time. I unroll driver to
4496 but effect the same. Wait for any suggestions.
Maybe I made a mistake?

Thank you.–
With best regards,
Vadik Mironov

Excuse me, everybody. All problems solved after reading documentation.
Shame on me…–
With best regards,
Vadik Mironov