Help again... Double Buffer...

Started by
6 comments, last by pimple 20 years ago
http://www.mvhsbreakers.com/junk/walk.exe Hi everyone, and I'm sorry for all of the posts in the last few days... I'm trying to port one of my projects into C++, and I'm having some difficulties doing a few things that i was able to do very easily in C#... (btw, I'm using C++ Builder) first, in C# i was able to turn on my double buffer in one line of code:

private void InitializeComponent()
{
			// 

			// WinForm

			// 

			(...)

			SetStyle(ControlStyles.DoubleBuffer, true);
now, i've done a very extensive search on google for assistance with this, but i just haven't had the luck... any help would be greatly appreciated... oh, i don't even know if the way i'm drawing my sprites onto the screen is any good, so any advice on that would also be appreciated... i've got a timer, an imageList and a paintBox on my form... every time the timer ticks, i draw the first image on the imageList onto the paintBox, and every time the timer ticks again, i print the next image from the list (onto the paintBox)... also, at the beginning of every onTimer call, i "repaint" the paintBox... that way, when i move my character (imageList) into a new position, the old one isn't printed with it... so that's about it... it flickers too much, and i'm wondering if that's cuz i don't have the double buffer turned on or something... thanks! [edited by - pimple on April 11, 2004 1:11:21 PM]
---Current project - Duck Hunt 2: Free at Last!http://www.duckhunt2.cjb.net
Advertisement
[link] [/link] == < a href="http..." >link< /a >

Why are you switching C# -> C++?

Are you using DirectX? Direct Draw? Direct3D? Which version?
I''m not sure that a ''paintBox'' exists in standard C++ or MFC. What sort of control are you using for it?

There''s a set of double-buffering commands in the Win32 API (SwapBuffers() being the important one) but I believe they''re meant for OpenGL only.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

hi again... um... i''m switching to C++ because, well, there''s a couple of reasons actually... first, i''d been reading books and teaching myself soem c++ for some two years... then i started writing commandline games and pretty much just starting to program games... then i went to school last fall, and i took a cs class... much to my surprise, they taught C#... i hadn''t really heard much about C# up until then...

well, so since we were using C# for our projects, i decided to start using it primarily... i learned a lot in that class, specially things i hadn''t learned previously using C++... so then i decided to stick to C#, since i realized i was more confortable using it rather than C++...

anyhoo, so i got this tile based game going, and i''m just trying to port it to C++ so people can play it if they don''t have the .net framework... not only that, but i just wanted to get back to C++ a little bit... i guess i miss it for some reason o_O

anyhoo, i''m not using openGL, directX or any other graphics library... just straight C++ (and whatever is in C++ builder), just because that''s how i wrote my original game (in C# builder)...

about the paintBox... well, i don''t really know much about it myself... i''m only using it because i thought it''d be better to use a paintbox canvas to print my images, rather than using the form itself... so like i said, when the timer ticks, i refresh the paintbox, and draw the imagelist:

imgSprite->DrawOverlay(pbScreen->Canvas, X, Y, A, 1);
// A = spriteIndex; "animation"

o_O

thanks...
---Current project - Duck Hunt 2: Free at Last!http://www.duckhunt2.cjb.net
well generally speaking to program games with any real speed you cant use MFC or GDI or what ever comes with your average c++ compiler. Most people choose one of the following : openGL, directX, SDL, or allegro. i would myself recommend allegro to start with (www.allegro.cc). its great for 2d games, it has extra stuff for 3d and it has an openGL extension for when you want to fully get into 3d.

[edited by - vaneger on April 11, 2004 10:22:18 PM]
cool... so yeah, thanks all of you guys for all of the replies... i guess i''m just gonna go ahead and do some reading on openGl or something... thanks again and have a great day!
---Current project - Duck Hunt 2: Free at Last!http://www.duckhunt2.cjb.net
quote:Original post by pimple
http://www.mvhsbreakers.com/junk/walk.exe

Hi everyone, and I''m sorry for all of the posts in the last few days... I''m trying to port one of my projects into C++, and I''m having some difficulties doing a few things that i was able to do very easily in C#... (btw, I''m using C++ Builder)

first, in C# i was able to turn on my double buffer in one line of code:

private void InitializeComponent(){			// 			// WinForm			// 			(...)			SetStyle(ControlStyles.DoubleBuffer, true);


now, i''ve done a very extensive search on google for assistance with this, but i just haven''t had the luck... any help would be greatly appreciated... oh, i don''t even know if the way i''m drawing my sprites onto the screen is any good, so any advice on that would also be appreciated...

i''ve got a timer, an imageList and a paintBox on my form... every time the timer ticks, i draw the first image on the imageList onto the paintBox, and every time the timer ticks again, i print the next image from the list (onto the paintBox)... also, at the beginning of every onTimer call, i "repaint" the paintBox... that way, when i move my character (imageList) into a new position, the old one isn''t printed with it...

so that''s about it... it flickers too much, and i''m wondering if that''s cuz i don''t have the double buffer turned on or something...

thanks!

[edited by - pimple on April 11, 2004 1:11:21 PM]



Well just to warn you, using the DoubleBuffer property of those components really does not help very much. You will be much better off drawing to an offscreen bitmap, and then to the form, or paintbox. I have tested that property and I have always had flicker present.

Another important note is that if you are using BCB 6, offscreen double buffering still does not fix the flicker. I have heard from many people it can''t be overcome. Has to do with some botched code or something, I don''t know. Fortunately for me I have BCB 5!
^^

well, on my games written in C#, i use that property for the double buffer and i also always use this:

SetStyle(ControlStyles.AllPaintingInWmPaint, true);

i don''t know, my game doesn''t flicker one bit, but maybe it''s because of the latter property being set to true...
---Current project - Duck Hunt 2: Free at Last!http://www.duckhunt2.cjb.net

This topic is closed to new replies.

Advertisement