Advertisement

How to test SDL

Started by November 26, 2001 05:13 PM
3 comments, last by ma0 22 years, 10 months ago
Hi.. I''m new to game programming, so I''m testing a little bit SDL. Unfortunately It''s difficult to find a good Tutorial/Documentation (see putpixel problem..is it slow or fast?) To test my GeforceMX on Linux mdk8.1 I''ve tried this piece of code: [..] screen = SDL_SetVideoMode(1024, 768,32,SDL_FULLSCREEN|SDL_HWSURFACE|SDL_DOUBLEBUF); [..] gettimeofday(&t1,0); for (int i=0;i<100;i++) { quadrato.x=random_pos(974);quadrato.y=random_pos(718); SDL_FillRect(screen,&quadrato,blu); SDL_Flip(screen); //SDL_UpdateRects(screen,1,&quadrato); SDL_BlitSurface(image,NULL,screen,NULL); //SDL_UpdateRects(screen,1,&quadrato); SDL_Flip(screen); [...] I want to put some rectangles on random positions, then I''ll delete it simply rewriting the whole image (it isn''t stupid?)(24rect per sec.) I''ve tried other way to do it but I''ve always found a problem. The rectangles flickers, even if I use the double buffer.. why? I''ve tried to see if I have some problem with X: const SDL_VideoInfo *vi; vi = SDL_GetVideoInfo(); if (vi->hw_available) cout << vi->hw_available << "It is possible to create hardware surfaces.\n"; [and other IF for wm_available,vi->blit_hw,... ] And only wm_available answered yes! Even the amount of video mem said 0! Does Xfree4.2 has some problem? Does I have to install the general Binaries X servers from Nvidia web site? Any help/doc/tutorial/simpleC++ code is appreciated :-) Ma0 ps. Why there isn''t a good web site with all the interesting question/answer and some piece of code & documentation? The Sdl site is very poor (like my English)
In a recent thread was some of your questions answered. It does not seems to be possible to allocate video memory if you are not running as root. OpenGL is a much better alternative.
If "the general Binaries X servers from Nvidia web site" is the display drivers should you install them for hw supported OpenGL. Does not Cone3D has SDL tutorials?
Advertisement
May I suggest the book entitled " Programming Linux games " by John R. Hall from No Starch Press it has quite a complete section about SDL programming starting with very simple examples.

If you declare the surface with the SDL_HWSURFACE|SDL_DOUBLEBUF flag you don''t need to Update the rectangle AND flip.
As I understant, flipping applies to a double buffered hardware surface and the fast equivalent of the SDL_UpdateRects for a system ram surface.

I hope this helps.
I''ve tried to run my app as root, but it doesn''t work..

>If you declare the surface with the SDL_HWSURFACE|SDL_DOUBLEBUF flag you don''t need to Update the rectangle AND flip.

The problem is that if Linux isn''t able to acces the HW, it uses the SWSURFACE (this can be confusing..)

Now I know what''s the problem but I dont know HOW to solve it! :-)

If I try to set the
SDL_VIDEODRIVER=''dga'' ; export SDL_VIDEODRIVER
It doesnt work (parachute open :-)
Even if I try some easier examples.. I don''t know if it''s a Nvidia problem or if it''s a Mandrake8.1 problem..
I tried DGA (DGA-2) with Allegro and it runs but is unstable. I do not know about SDL but Allegro is calling the old mode for just DGA and the new one for DGA-2. You can not get into old DGA mode if you have DGA-2.

This topic is closed to new replies.

Advertisement