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.

DarkBASIC Professional Discussion / [DBP] Cls is not working

Author
Message
rolo99
15
Years of Service
User Offline
Joined: 4th Feb 2009
Location:
Posted: 16th Nov 2009 23:56 Edited at: 17th Nov 2009 03:30
Can someone explane why cls is not clearing the screen every time i click the mouse button to draw a new box.




I just found out that it will not work with Vista 32 Home Premium, It works in XP and Win7 Though.
General Jackson
User Banned
Posted: 17th Nov 2009 00:57
Put it in a code snippet and we can study it better (I can anyways)

Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Nov 2009 01:36
Did he post a blank message or is he on post approval?

General Jackson
User Banned
Posted: 17th Nov 2009 01:53
He must be on approval, cuz the message WAS there...

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Nov 2009 04:09
Yup - on approval. I approved it then he edited the post which put it back into pending...

TDK

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 17th Nov 2009 08:18
It works fine for me using vista x32.

Only I'd put the sync after the endif.

Your signature has been erased by a mod because we're sadistic losers with nothing better to do. (joke)
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 17th Nov 2009 08:28
Quote: "Only I'd put the sync after the endif."

Well since there's nothing else being rendered there's no need to refresh the screen while nothing happens, thus improving performance if you think about it on a larger scale... But then again in a *real* something is always bound to happen.

And this is the sort of thing I've been having fun with as well, DBP will, at random not always work correctly on some windows installations. But when you try it on a different computer it just works fine. Like on XP I could never get a loading screen to display while loading models, on other PC's it looked fine though.


EDP Map Editor[2D]
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 17th Nov 2009 12:44
Put the cls after the endif, works fine then.

Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 17th Nov 2009 12:48
Sorry, change the original cls to cls 0 and then add a second cls,(without the 0), after the endif.

Digger412
16
Years of Service
User Offline
Joined: 12th Jun 2007
Location:
Posted: 17th Nov 2009 13:14
I normally do doubles, like cls:cls. That's always solved my problems.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2009 13:29
Quote: "Sorry, change the original cls to cls 0 and then add a second cls,(without the 0), after the endif."


Surely you won't see anything then?

The code doesn't work for me either (Vista Home Premium 64 bit) - and it baffles me too.

This does work - but why the "backdrop on" command should be necessary I really don't know.



This sounds like a question for IanM or Dark Coder.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Nov 2009 14:02
I see a blank screen initially when I run the code (no sync, so I don't see the initial box). Then when I press the mousebutton, the screen is cleared and the box is immediately drawn at the mouse position.

What's wrong with that? It's what I expect to see when I run the code. What is everyone else seeing?


If I add a SYNC after the SYNC RATE command, then another SYNC after the initial BOX command, then I see the initial box too.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2009 14:43
Quote: "What's wrong with that?"


Nothing - except it doesn't work on all systems.

The original code works fine on my laptop (Windows XP) but doesn't work on my Vista machine - the boxes are not cleared despite the cls. But my posted code does work on both machines. So something odd is going on.

Any ideas why the addition of the backdrop on command should make a difference on Vista? Looks like one of those obscure 2D/3D/back buffer issues to me.
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 17th Nov 2009 15:14
[Surely you won't see anything then?]
You wouldn't expect so, but just as you added backdrop on to get it to work, I added the extra cls to get it to work. Also similar to IanM to get the initial box to show, I added sync:sync just after the initial box position line..... And it then works as the writer intended...but how and why ????

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2009 16:04
Post the code you are using, the system you have, and tell us what you see. At the moment I'm not all sure where you're putting all these cls's.
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 17th Nov 2009 16:29
np



Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 17th Nov 2009 16:36
I am using W7.
With the initial code, the 1st white box does not appear until I mouseclick. Then 2 boxes show, the initial box plus a 2nd where i click on the screen. If i click again a third box is placed where i click but the earlier two boxes remain, etc etc.
Adding the double sync, adding a second cls, and modifying one of them to include a number, e.g cls 0, somehow allows the program to work correctly. BTW, the second cls doesn't actually do anything except enables the first cls to work.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2009 16:59
So it seems like something has changed with Vista and W7.

Quote: "adding a second cls"


That's weird. I'll try your snippet again when I'm back on my Vista machine - but on my XP laptop it seems to work at first sight until I realise that the square moves around with the mouse even if I don't click. How is that happening?
Globbits
15
Years of Service
User Offline
Joined: 30th Jan 2009
Location: Cambridge
Posted: 17th Nov 2009 17:25
Just tried all three code snippits on Vista Home Premium 32 bit. They all worked although the last one with the cls after the endif seemed a lot slower to draw. Could this be to do with 64 bit Windows?
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Nov 2009 17:51
Can someone with the problem change their 'CLS 0' to 'CLS RGB(0,0,0)' and see if that fixes the problem?

Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 17th Nov 2009 18:08
Cls Rgb(0,0,0) doesn't fix the problem using W7. I can simply change the cls 0 to cls 255 and i know it works because the screen changes colour.
i'm not sure now that the cls is the problem. I'm trying to find an old program i wrote which had a similar type of problem. I recall the problem was to do with using a single "IF" statement in a loop. It was only when i added a 2nd "IF" statement that it worked correctly. I will try to find and post with proof if this is the case.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2009 19:20 Edited at: 17th Nov 2009 19:21
Quote: "Can someone with the problem change their 'CLS 0' to 'CLS RGB(0,0,0)' and see if that fixes the problem?"


I get the problem with the original code which doesn't have a "cls 0". The code snippet posted by Juney a few posts back seems to run differently now on my XP laptop - for some reason it runs very slowly with a lot of fan cooling until I remove the second cls and I can't reproduce the behaviour I reported just now.

On my Vista machine the situation is beginning to get confused. The following code works (except for the missing initial box before clicking):



I've tried the following cls pairs (see above snippet for their locations in the code) with the following results:

cls/cls fails
cls 0/cls works
cls/cls 0 works
cls 0/cls 0 fails
cls rgb(0,0,0)/cls rgb(0,0,0) fails
cls 0/cls rgb(0,0,0) works
cls rgb(0,0,0)/cls 0 works

The above seem to be relevant to IanM's question. Is he on to something?

Why should cls 0 be so different from cls rgb(0, 0, 0)??


The Help file seems to suggest that there are two different "cls" commands. Here's what it says about "cls" without the extra colour parameter:

Quote: "This command differs from the CLS found in the Basic2D command set which will paint the screen with a specified color."


Of course that could just be poor wording.

What exactly is rendered to, or cleared from, the screen - and in precisely what order? The 2D and 3D commands are rendered differently in some way that is obscure to me - for example, 3D rendering goes to "bitmap 0" but 2D rendering such as text and boxes go somewhere else but still appear on the screen at the same time. How is this? Isn't there a common screen memory somewhere that we can access, copy and save, etc?

rolo99 seems to have posted a good one here.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Nov 2009 20:36
Quote: "for some reason it runs very slowly with a lot of fan cooling"

Because you are filling the backbuffer over and over at high speed. Is that your older/slower machine?

Quote: "The above seem to be relevant to IanM's question. Is he on to something?
Why should cls 0 be so different from cls rgb(0, 0, 0)??"



... and no, I'm not sure that I am on to something to be honest. I didn't see what I hoped to see from your results, but I do have another avenue to think about.

Shame I can't reproduce the problem myself - I hate having to do the psychic debugging thing.

You could also try replacing all of the CLS commands you are using with a single BOX command like so:


Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2009 21:06
I'll try that - but I'm supposed to be watching the spaghetti at the moment.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2009 21:21 Edited at: 17th Nov 2009 22:11
Yes, that works - and you only need one of them, doesn't matter which, for example



So it seems something strange is happening to the cls command(s).

Quote: "but I'm supposed to be watching the spaghetti at the moment"


Just realised it's macaroni.

And it's ready now.

Edit Forgot to add:

Quote: "Is that your older/slower machine?"


My oldish laptop - not my ancient PC (untested). The tests reported earlier in this post are on the new Vista machine.
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Nov 2009 23:03
I tried the code at work where it's 64 bit Visa and it worked fine. The only code that didn't work well was the code with double CLSes. Using 0 or RGB(0,0,0) didn't matter either way.

rolo99
15
Years of Service
User Offline
Joined: 4th Feb 2009
Location:
Posted: 17th Nov 2009 23:07
Thank you everyone for answering so promptly. I was just getting ready to stop using dark basic altogether because it seems no matter what I try when dealing with graphics, It is like I am trying to reinvent the wheel. I thought dark basic was going to be as easy as commodore 64 basic but I was wrong. But since I have all of this support to help me, I am going to finish my first game in this language. I might switch to dark GDK on the next one so I can use classes. Thank you, Thank You, Thank You everyone.

also, here is a real kiccker in Dark Basic, try to put "Set Display Mode 800,600,32" into a subroutine and try to compile it. I could not get it to work.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2009 23:43
This is beginning to sound like a graphics card issue. I've just retrieved one of my old projects from my old PC (XP) and run it on both my laptop (XP) and my new PC (Vista). Runs perfectly on both old machines - but fails on the new one. The thing it has in common with the present issue it that it makes extensive use of colour, bitmaps, cls and dwords. I haven't identified the precise point where things go wrong but it seems that pixels which ought to be initialised to a specific colour haven't been - or, alternatively, pixels which should be read as one colour aren't.

I'm fairly sure I posted another problem along these lines recently but can't recall offhand ( ) what it was about - and that was thought to be a GFX card problem.

The GFX card on my new Vista machine is an nVidia GTX 285 which most of the time is working perfectly.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 17th Nov 2009 23:43
Is this not a double buffering issue? Where you cls then sync and it actually draws the previous frame not the current one?

Your signature has been erased by a mod because we're sadistic losers with nothing better to do. (joke)
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2009 23:46
Quote: "Is this not a double buffering issue?"


If it was why should it vary from machine to machine? Does your theory explain the results I reported earlier?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2009 00:23
Just done some more testing. I've fixed the other project I was talking about by inserting the line

set bitmap format 21

before any bitmap commands. Interestingly, I did not have to do this on my old machines but I do on my new (Vista + nVidia GTX 285) machine.

On my old machines I only had to use the command ONCE - thereafter it seemed to be permanently set as suggested by the DBPro Help file (my emphasis):

Quote: "SET BITMAP FORMAT
This command will set any future bitmap created to the following format."


This no longer seems to be true. I've had to insert that line (now that I've remembered ) into a number of my programs.

Seems to be unrelated to the present issue though.
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 18th Nov 2009 01:33
I'm using the same machine, but after the latest beta update to DBPro, I've had to put in the SET BITMAP FORMAT where I didn't have to have it before.

pcRaider
16
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 18th Nov 2009 05:21
Windws7 emulates WindowsXp.
WindwsVista emulates WindowsXp.
WindowsXp is WindowsXp,
And WindowsXp emulates Windows98.

Therefore,
On WindowsVista, software of Windows98 does not work.

Because, in DBP, a code of Windows98 is included
Lee must remove a code of Windows98.

Compatibility of WindowsXp is unfinished.
As for it, an old compiler code does not work.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 18th Nov 2009 05:22 Edited at: 18th Nov 2009 05:29
None of this really explains the problem from machine to machine, but it might be useful.

Quote: "This does work - but why the "backdrop on" command should be necessary I really don't know."


The backdrop should be off by default unless any 3D drawing takes place. Sync might turn the backdrop on with some graphics cards is my best guess.
Edit: Or maybe you were asking why it was necessary in the first place, not if it should be necessary to force it on? My bad.

Quote: "Why should cls 0 be so different from cls rgb(0, 0, 0)??"


0 is zero, while RGB(0,0,0) is Red = 0, Green = 0, Blue = 0, Alpha = 255. If the Alpha channel was 0, the "black" would be completely transparent.
Using IanM's Matrix Utilities;
RGB(0,0,0) is equal to RGB(255,0,0,0)

Quote: "set bitmap format 21"


32 bit ARGB format vs 24 bit RGB formats might explain a few of the differences on different machines if the graphics card gets to choose the default bitmap format.


Open MMORPG: It's your game!
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 18th Nov 2009 11:25
Quote: "for some reason it runs very slowly"


You can move the 2nd cls to directly after the 1st cls 0 in the "If/endif" structure, i.e cls 0 : cls
This is a little more logical as you would only fill the back buffer after a mouseclick, not continuously.
Still doesn't explain why cls on its own fails to work though.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2009 12:13 Edited at: 18th Nov 2009 12:57
Quote: "I'm using the same machine, but after the latest beta update to DBPro, I've had to put in the SET BITMAP FORMAT where I didn't have to have it before."


Interesting - but might not be the whole story. Both of my machines have U7.5, but possibly not the same beta. I'll check and report back.

Edit Doesn't seem to be a recent upgrade issue - the problem is the same on my Vista machine with U7.5b1, U7.5b2, and U7.1. I haven't checked earlier upgrades. (The earlier tests reported above were done with U7.5b2 on the Vista PC and U7.5b1 on the XP laptop.)
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Nov 2009 19:47
Can one of you guys with the problem try the following:
Create a link to the exe with a problem.
Right-click the link and select 'properties'.
Click on the 'compatibility' tab.
Click on the tick-box 'disable desktop composition'.
Click OK.
Double-click on the link to run your exe.

Does that fix it or have no effect?

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Nov 2009 21:26 Edited at: 18th Nov 2009 21:28
Has no effect. or should that be

Edit

Here's the exe file in case you want to try it yourself.

Attachments

Login to view attachments
French gui
19
Years of Service
User Offline
Joined: 11th May 2004
Location: France
Posted: 19th Nov 2009 00:17
Rofl, this works:

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Nov 2009 00:40
You've missed the point of this thread. Read it again.
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Nov 2009 01:18 Edited at: 19th Nov 2009 05:57
That .exe works fine so it's good that it doesn't effect the compiling. I did forget to mention that the Vista I used it on didn't have the latest update for Darkbasic Pro. I'm going to go back there tonight, update, and try the code again.

Edit: After updating Darkbasic Pro to 7.4 it still worked as it should.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Nov 2009 11:05
Quote: "Edit: After updating Darkbasic Pro to 7.4 it still worked as it should."


But not on some machines - it works fine on my laptop (ATI Mobility Radeon Xpress 200, XP) but doesn't on my main PC (nVidia GTX 285, Vista 64 bit). Other peopl in this thread have reported similar difficulties.

Could everyone list their OS and GFX card specs and the result of running that exe file I posted yesterday?

The exe works if you see just one square which moves where you click the mouse. It fails if you see a trail of squares when you move and click the mouse.

I don't think the problem has anything to do with recent DBPro upgrades (I had the same problems with U7.5b1, U7.5b2, and U7.1 as I indicated yesterday).
French gui
19
Years of Service
User Offline
Joined: 11th May 2004
Location: France
Posted: 19th Nov 2009 11:43
Quote: "You've missed the point of this thread. Read it again."


Why? Cls command is buggy, and you were asking why backdrop on command is needed (I'm wondering too). The code I've posted doesn't use this command but just a print command. Without it the box leaves trails, with it it works (try it). Just adding something to this strangeness...
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Nov 2009 11:58
Quote: "You've missed the point of this thread. Read it again."


Quote: "The code I've posted doesn't use this command but just a print command. Without it the box leaves trails, with it it works (try it). Just adding something to this strangeness..."


You're quite right! What I meant to say of course was:

I've missed the point of your post. I'll read it again when I'm awake.



I should know by now that my posts get strangely unreliable as the Witching Hour approaches.

I'm sure there's a good reason for this well-documented phenomenon.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 19th Nov 2009 17:23 Edited at: 19th Nov 2009 17:26
Troubleshooting 101. Take things out, or put them in, one at a time until you find the problem.

Test 1: Remove Set Display Mode


Test 2: Remove Sync commands


I can't think of anything else to remove that could be causing the issue.

For adding a solution in, I would suggest GG's solution.

Test3: Add set bitmap format 21



Can someone test these?

Edit: If it seems like I missed reading the last few posts, I did. I have read them now and will try the other solutions posted.


Open MMORPG: It's your game!
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 19th Nov 2009 17:34
@Green Gandalf. Your exe works fine on my machine. Windows Vista 64. NVidia GeForce 8500 GT.

@French Gui. Your solution works as well. There is an issue with where the Sync command is within the If condition set. If this code is used in a larger project, the Sync command will probably need to be used before the Loop command as well. This would cause the Sync to be called twice when the mouse button is pressed.


Open MMORPG: It's your game!
French gui
19
Years of Service
User Offline
Joined: 11th May 2004
Location: France
Posted: 19th Nov 2009 17:35
Nope , doesn't work for me. (AMD Athlon 7550 dual core 2,50Ghz 3Go Ram
Video card Geforce 9500GT, Vista basic )
French gui
19
Years of Service
User Offline
Joined: 11th May 2004
Location: France
Posted: 19th Nov 2009 17:39 Edited at: 19th Nov 2009 17:48
I think Lee knows about a trouble with the cls command as in FPSC source code, he has an intensive use of this kind of horror:


Note that on my old laptop with XP everything works well (like rolo99 said)
Adrian
20
Years of Service
User Offline
Joined: 11th Nov 2003
Location: My Living Room
Posted: 19th Nov 2009 23:18 Edited at: 19th Nov 2009 23:23
Just a thought:
Some graphics cards allow you to override the Vertical Refresh rate in some programs (called performance mode as opposed to Quality. I used this sometimes in DB Classic to make my programs run faster.)
Could this have something to do with it?

The .exe prog works ok on my 64 bit Windows 7 machine with ATI HD 3600 card
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Nov 2009 00:25
Quote: "The .exe prog works ok on my 64 bit Windows 7 machine with ATI HD 3600 card"


I wonder whether this is another one of those ATI vs nVidia issues?

Login to post a reply

Server time is: 2024-05-06 16:34:46
Your offset time is: 2024-05-06 16:34:46