Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Simple Directmedia Layer

Name: Anonymous 2007-09-06 10:54 ID:hcGcMf+v

I use C++ and SDL to make a 2D Sidescroller Game.
But I have problems with the "Tearing", it looks fucking ugly when move sprites.
I already activated "SDL_DOUBLEBUF" and "SDL_FULLSCREEN".
I also switched "Doublebuffering" on, at my graphics card configs.
I even tried "SDL_SWSURFACE"(software renderer) instead of "SDL_HWSURFACE"(hardware renderer).
And of cource I use SDL_Flip instead of SDL_Update.

What am I doing wrong?

Name: Anonymous 2007-09-06 10:56 ID:imfj5abl

how about fixing the vsync

Name: Anonymous 2007-09-06 10:57 ID:imfj5abl

Apologies SDL_Flip should wait for vsync.

Name: Anonymous 2007-09-06 10:58 ID:hcGcMf+v

>2
Shouldn't the tearing go away when I do a small pause in the main loop?

Name: Anonymous 2007-09-06 11:00 ID:hcGcMf+v

I tried that but still the tearing :(

Name: Anonymous 2007-09-06 11:03 ID:hcGcMf+v

Hmm, or I should start using OpenGL for the rendering.

Name: Anonymous 2007-09-06 11:05 ID:czuzdG0e

Please post some sample code that illustrates the problem. Make sure it is the minimum amount of code required for us to look into it for you. That will help.

Name: Anonymous 2007-09-06 11:26 ID:hcGcMf+v

>7
I copy pasted it here
http://paste.dprogramming.com/dpeecgk5

It's just a SDL sample Project, I added the moving block which is tearing on the screen when I run it.

Name: Anonymous 2007-09-06 11:34 ID:2LLz91VS

>>1
You need to enable VSync. Or even better, triple buffering. Maybe SDL_Flip does that.

>>4
No. You need VSync or triple buffering.

>>6
You don't have to, if you don't need OpenGL's features.

Name: Anonymous 2007-09-06 11:36 ID:hcGcMf+v

_Here is a shorter version_


SDL_Init( SDL_INIT_VIDEO )

SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);

SDL_Surface* bmp = SDL_LoadBMP("white.bmp");


...


//Here the coordinates of the block will be changed each frame so it is moving
//dstrect.x += 1; etc...


...


// DRAWING STARTS HERE

        // clear screen
        SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));

        // draw bitmap
        SDL_BlitSurface(bmp, 0, screen, &dstrect);

        // DRAWING ENDS HERE

        // finally, update the screen :)
        SDL_Flip(screen);
    } // end main loop


...

Name: Anonymous 2007-09-06 11:41 ID:hcGcMf+v

>9

So, how do I manage then, that the renderer is waiting until the graphics are drawn to the surface?
Doublebuffering seems not to work for me.
How can I realize a Vsync rendering, without Doublebuffering? Does that work?

Name: Anonymous 2007-09-06 11:42 ID:czuzdG0e

How does it compare when you initialise video mode with SDL_HWSURFACE? Double buffering doesn't work on software surfaces.

You should also check the SDL_Surface.flags after initialising to see if it actually took notice of your double buffering flag.

Name: Anonymous 2007-09-06 11:45 ID:hcGcMf+v

>12
Tried SDL_SWSURFACE. Didn't remove the tearing.

Will check the flags.

Name: Anonymous 2007-09-06 11:48 ID:czuzdG0e

>>13
SDL_HWSURFACE

HW HW HW HW HW HW HW HW HW HW HW HW HW HW HW HW HW HW HW HW HW !!

Name: Anonymous 2007-09-06 11:57 ID:hcGcMf+v

>14
whooops, yeah i meant HW sry!! Didn't work like I said.

But, I checked the flags and:

SDL_HWSURFACE
and SDL_DOUBLEBUF
didn't work to initialize!!

:(

Name: Anonymous 2007-09-06 12:36 ID:czuzdG0e

>>15

What does SDL_GetVideoInfo tell you? Paste result here please.

Name: Anonymous 2007-09-06 13:04 ID:hcGcMf+v

>16
dunno if i did it right.

hw_available: 0
wm_available: 1
UnusedBits1: 0
UnusedBits2: 0
blit_hw: 0
blit_hw_CC: 0
blit_hw_A: 0
blit_fill: 0
UnusedBits3: 0
video_mem: 0

How do I use SDL_VideoInfo accurate?

Name: Anonymous 2007-09-06 13:19 ID:Plf4L6DF

Just a shot in the dark, but is there a way to enable v-synching? with sdl?

Name: Anonymous 2007-09-06 13:21 ID:hcGcMf+v

>18
SDL_DOUBLEBUF should do that.

Name: Anonymous 2007-09-06 13:26 ID:hcGcMf+v

hw_available IS 0
    Is it possible to create hardware surfaces?
wm_available IS 1
    Is there a window manager available
blit_hw IS 0
    Are hardware to hardware blits accelerated?
blit_hw_CC IS 0
    Are hardware to hardware colorkey blits accelerated?
blit_hw_A IS 0
    Are hardware to hardware alpha blits accelerated?
blit_sw IS 0
    Are software to hardware blits accelerated?
blit_sw_CC IS 0
    Are software to hardware colorkey blits accelerated?
blit_sw_A IS 0
    Are software to hardware alpha blits accelerated?
blit_fill IS 0
    Are color fills accelerated?
video_mem IS 0
    Total amount of video memory in Kilobytes
vfmt (would take too long)
    Pixel format of the video device


Name: Anonymous 2007-09-06 13:29 ID:hcGcMf+v

>>20
So why doesn't the hardware support work?
I got directX and DirectX compatible games work just fine.

Name: Anonymous 2007-09-06 14:03 ID:Heaven

SDL is shit. Use OpenGL.

Name: Anonymous 2007-09-06 14:40 ID:czuzdG0e

Wow, well that's a bit fucked. What hardware are you using anyway?

Name: Anonymous 2007-09-06 21:56 ID:hcGcMf+v

>>23
Geforce 4 TI

Name: Anonymous 2007-09-07 4:42 ID:sL9ajs4K

>>24
Aaaand what display driver?

Name: Anonymous 2007-09-07 11:58 ID:i0hnqPHc

>>When I reinstall my system I just download the newest nvidia driver.
I'm downloading 94.24_forceware_winxp_international_whql.exe.
Maybe it works with this.

Name: Anonymous 2007-09-07 12:04 ID:i0hnqPHc

Damn, what is this??
It says, the drivers are not compatible with any hardware I got.

Name: Anonymous 2007-09-07 12:11 ID:i0hnqPHc

I checked and right now I'm using the 93.71 driver of nvidia.
But can't install the new forceware crap version.
Maybe I should look out for some older drivers.

Name: Anonymous 2007-09-07 14:37 ID:i0hnqPHc

YAY!! I finally found something that works. (After hours of google)

Before I SDL_Init() the video mode, I have to wright
SDL_putenv("SDL_VIDEODRIVER=directx");

Looks like it forces SDL to use DirectX, and so my Hardwaremode is finally enabled, and no shitty tearing anymore.

But still, would be good to know what that so is.
Does someone have an idea?

Name: Anonymous 2007-09-07 14:46 ID:Heaven

I have a vague idea that nobody cares.

Name: Anonymous 2007-09-07 16:37 ID:Heaven

>>29
actually, SDL just uses getenv() to read SDL_VIDEODRIVER and works from that.

Name: Anonymous 2007-09-07 16:46 ID:PbToaT9G

Nice

Name: Anonymous 2007-09-07 16:48 ID:Lbq18bDr

>>30
I do care, I'll look into that choice of video drivers for my own SDL-based stuff. Thanks Anon.

Name: Anonymous 2010-11-14 3:52

Name: Anonymous 2010-12-24 4:47

Name: Anonymous 2011-02-03 5:25

Don't change these.
Name: Email:
Entire Thread Thread List