Help with drawing

Started by
7 comments, last by Jedyte 21 years, 8 months ago
Hello, I just wrote a small testprogram to test out my scrolling and sprite movement for my shooter game. But there is a strange phenomenon when drawing. It seems that every now and then and sort of invisble row slowly rolls down the screen, shaking the graphics within. I think maybe it has something to do with the vertical retrace of the monitor, but I'm using a double blit-technique so I thought that would eliminate it. Instead of drowning you in my code, I made a small zip at http://www.jedyte.be/test/MGBasic.zip with the demo program. Could anyone please check it out? I think the error I'm talking about is clearly visible. PS. Just to be sure: this is no source code, just a little demo executable. Tnx, Jedyte [edited by - Jedyte on August 16, 2002 8:45:56 AM] [edited by - Jedyte on August 17, 2002 4:08:09 AM]
And the price we paid was the price men have always paid for achieving paradise in this life -- we went soft, we lost our edge. - "Muad'Dib: Conversations" by the Princess Irulan
Advertisement
Hmm...a lot of people don''t like going to the trouble of downloading a zip file, opening it, figuring out what is relevant, and reading it (including me). Maybe you should post the section of your code that actually does the work of drawing to the screen, plus possibly your main loop.

Twilight Dragon
Win32 API Programmer
www.freewebz.com/j-world
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
Nono, it's not source code, this is an demo program!

Like I said, I don't want anyone to wade through lines and lines of code. It wouldn't do any good, because the coding is done right (used it in previous games). I think it's a technical problem caused by the added scrolling. So what I am asking is can anyone run the demo, and recognize the problem by looking at the distortions in the graphics and then maybe know what the problem is.

But maybe it's not a bad idea to give some rough code...

  // some gameloop variabelesBitMap buffer(SWIDTH, SHEIGHT); // double bufferbool go = true;Map m; // this is the map that scrolls as the backgroundint yScrollOffset = m.height() * m.blockHeight() - SHEIGHT;int xScrollOffset = 0; // not used, only vert. scrolling nowwhile(go)	{	// update scrolling	if(yScrollOffset > 0)	{		yScrollOffset -= 2;	}	else yScrollOffset = 0;        // update map	m.updateAnimations();        // Rendering        buffer.clear();	m.drawMap(buffer, LEVEL_LAYER, SWIDTH, SHEIGHT, xScrollOffset, yScrollOffset);        // blit the double bufer to the screen        buffer.blit();}   


[edited by - Jedyte on August 17, 2002 4:16:08 AM]

[edited by - Jedyte on August 17, 2002 4:16:57 AM]
And the price we paid was the price men have always paid for achieving paradise in this life -- we went soft, we lost our edge. - "Muad'Dib: Conversations" by the Princess Irulan
checked it, and I didnt find any drawing bug you descriped.
Thanx for checking it out.

Weird, the bug is very visible here on two different computers (although less visible on the slower one). Maybe it has something to do with my monitors?

And the price we paid was the price men have always paid for achieving paradise in this life -- we went soft, we lost our edge. - "Muad'Dib: Conversations" by the Princess Irulan
quote:Original post by Jedyte
I think maybe it has something to do with the vertical retrace of the monitor, but I''m using a double blit-technique so I thought that would eliminate it.

Double buffering doesn''t eliminate tearing, no. It just makes it less likely to happen. I''d say that''s what you''ve probably got here. If V-sync is disabled in your graphics card settings, re-enable it.



[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
quote:Original post by Kylotan
Double buffering doesn''t eliminate tearing, no. It just makes it less likely to happen.


Then is there a way to eliminate it?
And the price we paid was the price men have always paid for achieving paradise in this life -- we went soft, we lost our edge. - "Muad'Dib: Conversations" by the Princess Irulan
Only by turning on v-sync.
Just few questions ...

Do you need to rebuild your map at every frame ?? Is there any information that you could keep for a while, and update the map when it really changes ?

Also do you really need the clear buffer function ? If building your map make the whole map to be cleared, maybe you could avoid it...

Well, if you can, try to display the frame rate of your application, it could help you to find speed problems. If you know how to profile your functions (to check their speed, then you will probably find which one slows down your application)



__________________________



Bruno Wieckowski
Lead Programmer
Exood4 Studios

This topic is closed to new replies.

Advertisement