Public Group

#### Archived

This topic is now archived and is closed to further replies.

# Help again... Double Buffer...

This topic is 5237 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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]

##### Share on other sites

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

Are you using DirectX? Direct Draw? Direct3D? Which version?

##### Share on other sites
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.

##### Share on other sites
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...

##### Share on other sites
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]

##### Share on other sites
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!

##### Share on other sites
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!

##### Share on other sites
^^

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...

1. 1
2. 2
frob
15
3. 3
4. 4
5. 5
Rutin
12

• 12
• 12
• 58
• 14
• 15
• ### Forum Statistics

• Total Topics
632115
• Total Posts
3004200

×