Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBC] Drawing Program

Author
Message
Brazos
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 27th Jun 2009 01:49
Gravtiy17
15
Years of Service
User Offline
Joined: 19th Jun 2009
Location:
Posted: 27th Jun 2009 05:07
When I debug this, the screen just starts blinking, I think there might be a bug
Brazos
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 27th Jun 2009 16:28
Gravitiy17 it works fine on my computer. Has anyone else ran this and had a problem?
Brazos
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 28th Jun 2009 22:38
I'm adding a screen shot to show what can be done with this drawing program.

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Jun 2009 08:22
@Brazos
There is a lot of flickering. Maybe try using an offscreen bitmap to refresh/redraw all of the areas of the screen, then copy that bitmap over to bitmap 0 so the whole visible screen refreshes at once instead of in sections. I think the constant get and paste images all on the main screen is slowing things down and we are able to see all of the refreshes as flickering screen updates. Drawing on an offscreen bitmap is alos a lot faster than drawing to the main bitmap (screen 0).

Enjoy your day.
Brazos
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 1st Jul 2009 16:10
@ Latch
That's odd..it runs very smoothly on my computer. I want to do what you suggested but I'm not sure how I would rearrange my code to make that happen.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 1st Jul 2009 20:01 Edited at: 1st Jul 2009 20:02
this is some code i use to see which bits might be taking longer than other parts
first bit makes up 50 time memory slots

then to put a start counter where you want it to start counting to see how long it takes then put the end counter to store the time taken
then just use a for next loop to print out the values.



Dark Physics makes any hot drink go cold.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Jul 2009 03:22
@Brazos
There are a few things I think may be going on here.

You are using sync on: backdrop on when you are only working in 2d. I'm guesing you are using that because it automatically clears the screen as you go. However, it may be the cause of flickering on other computers.

There is a file that lives in the same directory as DB.exe. It is called Setup.ini . If you open the file, there is a setting labeled blitflipmode. For most modern computers this setting should be

blitflipmode=1

This helps to control how the screen is redrawn between 2d and 3d, and since you are invoking 3d with the backdrop on command, others are seeing the flickering of the redraw when their blitflipmode=1 . It is likely that you either do not have a Setup.ini file or your blitflipmode=0 in which case you aren't seeing the flickering.

If you were distributing an executable, you would also want to distribute a copy of the setup.ini with the settings you have so that that your app behaves the same on a different computer. This mainly affects how the drawing is done between 2d and 3d and agin, because you are using backdrop on, you are invoking 3d.

Check out this link:
Getting Started with DBC

and read through the attachment of how to optimize DBC, which includes a section on the Setup.ini .

I set the blitflipmode=0 and the flashing stopped, except for the drawing cursor; but normally I have it set to 1.

As far as drawing on a background bitmap, I modified your program slightly. I remmed out the backdrop on and used a cls in the mainloop. I also added a line at the end of your Setup subroutine and added a line to the bottom of your main loop.

By creating the bitmap in the setup, the current drawing surface is set to that bitmap unless I change the surface with SET CURRENT BITMAP . In the main loop, I just copy from the background bitmap to bitmap 0 : Copy bitmap 1,0 . Because I eliminated backdrop on , I can run the app without flickering regardless of my setup.ini settings.



Enjoy your day.
Brazos
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 2nd Jul 2009 06:24
Thanks for looking into this Latch. Your help is greatly appreciated. I want the flashing drawing cursor, the eraser and the selection square to show. This way I know the exact location of each of them before I click. With the way you changed the code my "ghost drawing cursor/eraser/selection square have all disappeared. They were there to help with exact placement of each tool before clicking mouse. How do I get them to show with your changes? The code for them is still there, but they aren't.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Jul 2009 07:04
The easy way: just comment out or delete the CREATE BITMAP command at the end of SETUP ; and also COPY BITMAP 1,0 at the end of the main DO LOOP

Enjoy your day.
Brazos
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 2nd Jul 2009 18:36 Edited at: 3rd Jul 2009 00:45
That worked, thanks.

[edit]
I kept the bitmap 1 and added a copy bitmap 1,0 to those areas I wanted to keep. Thanks again.

Login to post a reply

Server time is: 2024-11-22 01:52:53
Your offset time is: 2024-11-22 01:52:53