Window Frame messes up in Win2000

Hi Everyone,
When I set my application to draw in window mode and I drag the window to
the edge of the screen, all sorts of garbage appears all over the screen. When
I release the window my application redraws, but the garbage on the window
frame remains until I minimise and maximise the window. Is there anything I can
do to make the frame redraw itself without the minimise maximise thing?

Hi Everyone,
When I set my application to draw in window mode and I drag the window
to
the edge of the screen, all sorts of garbage appears all over the screen.
When
I release the window my application redraws, but the garbage on the window
frame remains until I minimise and maximise the window. Is there anything
I can
do to make the frame redraw itself without the minimise maximise thing?

Do you clear the framebuffer after each drawing loop ?

Well, there could be a couple of things that could lead to that.

One could be that you are updating the screen too many times =, but in
that case the graphics in the window would be flickering too

Another possible problem could be that you don’t have enough RAM and/or
Video RAM.

How much RAM is in the computer you are using?
How much Video RAM is in the computer you are using?On Sep 2, 2004, at 2:42 AM, David Moffatt wrote:

Hi Everyone,
When I set my application to draw in window mode and I drag the
window to
the edge of the screen, all sorts of garbage appears all over the
screen. When
I release the window my application redraws, but the garbage on the
window
frame remains until I minimise and maximise the window. Is there
anything I can
do to make the frame redraw itself without the minimise maximise thing?


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

Another possible problem could be that you don’t have enough RAM and/or
Video RAM.

There’s lots of RAM. The computer I wrote the game on is a P200 with 16 Meg of
RAM and it runs Win95. The Win 2000 computer has 256 Meg RAM and it has a P1.5
Gig processor.

I tried disabling the game’s updates and drawing when it looses mouse focus or
input focus, but this made no difference.

When I drag the window across the edge of the screen everything is fine, but
when I drag the window back, the part of the window that is not visible is
drawn on the other side of the desk top.

This is what it looks like when I drag it back towards the centre of the
screen. I am dragging from right to left.

www.ausgamedev.com/untitled.JPG

Jonathan Jack <jjack hightechhigh.org> writes:>

Well, there could be a couple of things that could lead to that.

One could be that you are updating the screen too many times =, but in
that case the graphics in the window would be flickering too

Another possible problem could be that you don’t have enough RAM and/or
Video RAM.

How much RAM is in the computer you are using?
How much Video RAM is in the computer you are using?

On Sep 2, 2004, at 2:42 AM, David Moffatt wrote:

Hi Everyone,
When I set my application to draw in window mode and I drag the
window to
the edge of the screen, all sorts of garbage appears all over the
screen. When
I release the window my application redraws, but the garbage on the
window
frame remains until I minimise and maximise the window. Is there
anything I can
do to make the frame redraw itself without the minimise maximise thing?


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

What flags are you passing when you init SDL video?On Sep 2, 2004, at 7:41 PM, David Moffatt wrote:

Another possible problem could be that you don’t have enough RAM
and/or
Video RAM.

There’s lots of RAM. The computer I wrote the game on is a P200 with
16 Meg of
RAM and it runs Win95. The Win 2000 computer has 256 Meg RAM and it
has a P1.5
Gig processor.

I tried disabling the game’s updates and drawing when it looses mouse
focus or
input focus, but this made no difference.

When I drag the window across the edge of the screen everything is
fine, but
when I drag the window back, the part of the window that is not
visible is
drawn on the other side of the desk top.

This is what it looks like when I drag it back towards the centre of
the
screen. I am dragging from right to left.

www.ausgamedev.com/untitled.JPG

Jonathan Jack <jjack hightechhigh.org> writes:

Well, there could be a couple of things that could lead to that.

One could be that you are updating the screen too many times =, but in
that case the graphics in the window would be flickering too

Another possible problem could be that you don’t have enough RAM
and/or
Video RAM.

How much RAM is in the computer you are using?
How much Video RAM is in the computer you are using?

On Sep 2, 2004, at 2:42 AM, David Moffatt wrote:

Hi Everyone,
When I set my application to draw in window mode and I drag the
window to
the edge of the screen, all sorts of garbage appears all over the
screen. When
I release the window my application redraws, but the garbage on the
window
frame remains until I minimise and maximise the window. Is there
anything I can
do to make the frame redraw itself without the minimise maximise
thing?


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


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

Do you clear the framebuffer after each drawing loop ?

I’m not sure how to answer this, so I’ll show you my code.

This is my creation code:

SDLScreenVideo = SDL_SetVideoMode (800, 600, 16, SDL_SWSURFACE);

Then to draw on the surface I just write to Pixels

Width = SDLScreenVideo->w;
Height = SDLScreenVideo->h;
RealWidth = SDLScreenVideo->pitch/2;
Pixels = (U16*) SDLScreenVideo->pixels;

Then to show what I’ve done, I call:

void UPDATE_RECTANGLES::Update ()
{
int i;

if (NumRects > 0)
{
	SDL_UpdateRects(SDLScreenVideo, NumRects, RectList);

	for (i=0; i<NumRects; i++)
	{
		RectList[NumRects].x = 0;
		RectList[NumRects].y = 0;
		RectList[NumRects].w = 0;
		RectList[NumRects].h = 0;
	}
}

NumRects = 0;

}

What flags are you passing when you init SDL video?

I’ve just posted a code snippet under Carlos’ reply.

This is what I use in my Windows apps:

SDL_ANYFORMAT|SDL_SWSURFACE|SDL_HWPALETTEOn Sep 2, 2004, at 7:56 PM, David Moffatt wrote:

Do you clear the framebuffer after each drawing loop ?

I’m not sure how to answer this, so I’ll show you my code.

This is my creation code:

SDLScreenVideo = SDL_SetVideoMode (800, 600, 16, SDL_SWSURFACE);

Then to draw on the surface I just write to Pixels

Width = SDLScreenVideo->w;
Height = SDLScreenVideo->h;
RealWidth = SDLScreenVideo->pitch/2;
Pixels = (U16*) SDLScreenVideo->pixels;

Then to show what I’ve done, I call:

void UPDATE_RECTANGLES::Update ()
{
int i;

if (NumRects > 0)
{
SDL_UpdateRects(SDLScreenVideo, NumRects, RectList);

  for (i=0; i<NumRects; i++)
  {
  	RectList[NumRects].x = 0;
  	RectList[NumRects].y = 0;
  	RectList[NumRects].w = 0;
  	RectList[NumRects].h = 0;
  }

}

NumRects = 0;
}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: text/enriched
Size: 1080 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040902/36e012c8/attachment.bin

This is what I use in my Windows apps:

SDL_ANYFORMAT|SDL_SWSURFACE|SDL_HWPALETTE

I just tried those flags and its behaviour is the same.

Hi,

I’m not quite sure what you’re trying to do, but wouldn’t you want to do
this in you Update()?

RectList[i].x = 0;
RectList[i].y = 0;
RectList[i].w = 0;
RectList[i].h = 0;

instead of setting RectList[NumRects] to 0 lots of times? I’m not even
sure whether this is related to your current problem, but I think this
is gonna be your future problem :wink:

Regards,
yzt

David Moffatt wrote:>

  for (i=0; i<NumRects; i++)
  {
  	RectList[NumRects].x = 0;
  	RectList[NumRects].y = 0;
  	RectList[NumRects].w = 0;
  	RectList[NumRects].h = 0;
  }

wow, maybe a DirectX bug caused by SDL or by your video card drivers… :confused:

Another possible problem could be that you don’t have enough RAM and/or
Video RAM.

There’s lots of RAM. The computer I wrote the game on is a P200 with 16
Meg of
RAM and it runs Win95. The Win 2000 computer has 256 Meg RAM and it has a
P1.5
Gig processor.

I tried disabling the game’s updates and drawing when it looses mouse
focus or
input focus, but this made no difference.

When I drag the window across the edge of the screen everything is fine,
but
when I drag the window back, the part of the window that is not visible is
drawn on the other side of the desk top.

This is what it looks like when I drag it back towards the centre of the
screen. I am dragging from right to left.

www.ausgamedev.com/untitled.JPG

Jonathan Jack <jjack hightechhigh.org> writes:

Well, there could be a couple of things that could lead to that.

One could be that you are updating the screen too many times =, but in
that case the graphics in the window would be flickering too

Another possible problem could be that you don’t have enough RAM and/or
Video RAM.

How much RAM is in the computer you are using?
How much Video RAM is in the computer you are using?

Hi Everyone,
When I set my application to draw in window mode and I drag the
window to
the edge of the screen, all sorts of garbage appears all over the
screen. When
I release the window my application redraws, but the garbage on the
window
frame remains until I minimise and maximise the window. Is there
anything I can
do to make the frame redraw itself without the minimise maximise
thing?> > On Sep 2, 2004, at 2:42 AM, David Moffatt wrote:


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


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

Does this problem occur with any other publicly available (popular if
possible) SDL application? Or any of the tests that come with the SDL
source?On Sep 2, 2004, at 5:42 AM, David Moffatt wrote:

Hi Everyone,
When I set my application to draw in window mode and I drag the
window to
the edge of the screen, all sorts of garbage appears all over the
screen. When
I release the window my application redraws, but the garbage on the
window
frame remains until I minimise and maximise the window. Is there
anything I can
do to make the frame redraw itself without the minimise maximise thing?


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

David Moffatt wrote:

Do you clear the framebuffer after each drawing loop ?

I’m not sure how to answer this, so I’ll show you my code.

This is my creation code:

SDLScreenVideo = SDL_SetVideoMode (800, 600, 16, SDL_SWSURFACE);

Then to draw on the surface I just write to Pixels

This looks like you don’t actually clear the screen (the ‘framebuffer’) before each frame.
Thus, each one is just drawn over the top of the other, so pixels you don’t set keep their values from the previous frame.
Minimizing and restoring the window erases the surface, hence providing a tempory fix for the problem.

You should do this before you lock the surface for the pixel modifications (you are remembering to lock, right?):

SDL_FillRect(SDLScreenVideo, NULL, SDL_MapRGB(SDLScreenVideo->format, , , ));

Replace , , and with the colour components of the background you want.
So for a black background:

SDL_FillRect(SDLScreenVideo, NULL, SDL_MapRGB(SDLScreenVideo->format, 0, 0, 0));

Chris E.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040903/03b78b95/attachment.pgp

instead of setting RectList[NumRects] to 0 lots of times? I’m not even
sure whether this is related to your current problem, but I think this
is gonna be your future problem

Thanks Yaser, I didn’t see that one. I just fixed it but it didn’t help my
window problem.

I tried clearing the frame buffer and locking the surface before drawing on it
but I had no luck.

For some reason it seems to be drawing the areas that are not visible (in the
window) on the desk top starting at (0,0). Its as if there is a wrap around
occuring somewhere. I hope this rings a bell with one of the writers of the SDL
source.

David Moffatt wrote:

I tried clearing the frame buffer and locking the surface before drawing on it
but I had no luck.

For some reason it seems to be drawing the areas that are not visible (in the
window) on the desk top starting at (0,0). Its as if there is a wrap around
occuring somewhere. I hope this rings a bell with one of the writers of the SDL
source.

Can we see your drawing code?
-------------- next part --------------
A non-text attachment was scrubbed…
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040903/8d770ea2/attachment.pgp

David Moffatt wrote:

I tried clearing the frame buffer and locking the surface before drawing on it
but I had no luck.

For some reason it seems to be drawing the areas that are not visible (in the
window) on the desk top starting at (0,0). Its as if there is a wrap around
occuring somewhere. I hope this rings a bell with one of the writers of the SDL
source.

You are updating the rectangles where things have disappeared from, aren’t you?

Chris E.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040903/01db0928/attachment.pgp

Can we see your drawing code?

Sure. Here are some relevant snippets.

// **************************************************************************
SCREEN_STRUCT is the class that points to the relevant SDL surface data:
// **************************************************************************

class SCREEN_STRUCT
{
public:
U16ptr Pixels;
int Width, Height, RealWidth;
};

// **************************************************************************
This is the drawing manager class I put this here so you could see how the
SCREEN_STRUCT class is initialised in DRAWING_MANAGER::PrepareDrawing
// **************************************************************************

class DRAWING_MANAGER : public SCREEN_STRUCT

void DRAWING_MANAGER::PrepareDrawing ()// prep and end drawing
{
// SDL_LockSurface (SDLScreenVideo);

Width = SDLScreenVideo->w;
Height = SDLScreenVideo->h;
RealWidth = SDLScreenVideo->pitch/2;
Pixels = (U16*) SDLScreenVideo->pixels;

}

// **************************************************************************
In GRAPHIC::NormalBlit, Image has the pixels that we want to draw and these
pixels are drawn to SCREEN_STRUCT’s Pixels
// **************************************************************************

void GRAPHIC::NormalBlit (SCREEN_STRUCT* screen, int x, int y)
{
if ((y<ClipRect.top) || (x<ClipRect.left) || (y+Height >
ClipRect.bottom) || (x+Width > ClipRect.right))
{
NormalBlitClipped (screen, x, y);
return;
}

// This is the normal unclipped drawing

U16ptr image = Image, sc = screen->Pixels;
int  scwid = screen->Width;
int h = Height, w = Width;

sc += y*scwid+x;

// AsmFuncPtr = &Memcpy16Bit;

while (h--)
{
	(*AsmFuncPtr)(sc, image, w);
	sc+=scwid, image+=w;
}

}

// **************************************************************************
This is the horizontal line by line drawing routine that AsmFuncPtr is pointing
at. I hope you know ASM (I don’t). This was taken from a book by Mickey Kawick.
Perhaps the problem is here?
// **************************************************************************

void __fastcall Memcpy16Bit ( U16* dest, U16* source, int num )
{
if (num < 1) return;

int test1 = (int) dest;
if (test1&2)// to handle a misalligned destination address
{
	*dest++ = *source++;
	if (num < 2) return;
	num--;
	if (!(num&1))
	{
		_asm
		{
			mov   ecx, num    // how many copies
			mov   edi, dest   // to where
			shr   ecx, 1
			mov   esi, source    // set source
			rep   movsd
		}				
	}
	else
	{
		_asm
		{
			mov   ecx, num    // how many copies
			mov   edi, dest   // to where
			shr   ecx, 1
			mov   esi, source    // set source

			rep   movsd
		}
		*(dest+num-1) = *(source+num-1);
	}
	return;
}

if (num&1) *dest++ = *source++;	// 1 too many for movsd
if (num < 2) return;

_asm
{
	mov   ecx, num    // how many copies
	mov   edi, dest   // to where
	shr   ecx, 1
	mov   esi, source    // set source

	rep   movsd
}

}

Carlos Alvarez <citrouille wanadoo.fr> writes:

wow, maybe a DirectX bug caused by SDL or by your video card drivers… :confused:

No I’ve run other windowed SDL programs and they work fine. I’m sure its
something I have done.

You are updating the rectangles where things have disappeared from, aren’t
you?

No what I meant was the part of the window that is off the edge of the desk top
and should not be visible on the computer screen is being drawn on the desk top
starting at 0,0. It seems as if my app is using the desk top as a drawing
surface as well as the window.