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.

Dark GDK / Question about how the engine draws...

Author
Message
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 29th Dec 2004 23:48
I was involved in an earlier discussion about hovering the mouse over some text and getting it to change color. Should have been pretty simple except that I did not (and still do not know) how redraw occurs....
I was trying to print the mouse position to the screen with something simple like:

sprintf(strTxt,"X=%d Y= %d",dbMouseX(),dbMouseY());
dbSetCursor ( 0,0 ) ;
dbPrint(strTxt);

What I saw happen was it quickly overdrawing the text and making it unreadable.
The way I 'fixed' this was to load any object which caused redraws to occur correctly all over the screen. It seems that of a small object does not cover the whole screen, something like invalidaterect() would be called with just the rectangle of the object and not the whole screen. This should not have allowed me to see my text being drawn correctly...
Any insight? Just curious, as invaliding the whole screen seems inefficient in a game environment.... I may also be completely off base
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 30th Dec 2004 00:07 Edited at: 30th Dec 2004 00:08
Se dbDrawToFront/Back about why this happens.

You would be better off using dbText though, along with setting text to opaque.

Beware the Christmas... The fattener... The drunkard...
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 30th Dec 2004 00:58
How do I set the text to opaque? Take a look at the following code. The display line becomes garbled because it is not clearing before redrawing the text. I am not saying this is a bug, I just do not understand what is going on 'under the hood'

thanx
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 30th Dec 2004 02:18 Edited at: 30th Dec 2004 02:19
Quote: "How do I set the text to opaque? "

Its detailed in the help file.

See the enclosed program



Beware the Christmas... The fattener... The drunkard...
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 30th Dec 2004 02:57
Thanks. That solved the problem....
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 30th Dec 2004 03:08
Quote: "You would be better off using dbText though"


Why? Is it a performance issue bacause you need to call dbSetCursor() first when calling dbPrint()? Or something more subtle that I have not run across yet?
thanx
PearsoE
19
Years of Service
User Offline
Joined: 2nd Sep 2004
Location:
Posted: 30th Dec 2004 06:05
Just curious how strText is defined in you example. I've found that if you define an array that is to small it can cause unusual results as you describe when dbPrint is called.
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 30th Dec 2004 06:59
strTxt is an array of 50:
char strTxt[50];
I would suspect that either dbPrint() or dbText() will act strange if you index past the end of the character array... One of the features/dangers of C/C++. You can do whatever you want, but with that power comes great danger You index to the 51st element and anything from weird characters appearing to a crash....
Dragonslayer
20
Years of Service
User Offline
Joined: 4th Nov 2003
Location: New Lenox Illinois U.S.A.
Posted: 30th Dec 2004 07:21
Roujesky
That was me Dragonslayer I wanted to make a menu with yellow text and then when you placed the mouse over the menu item it turned blue and then when you clicked it maybe it would change to a lighter blue. I still have not gotten it to work right, actually I kind of forgot about it with the holidays and all. If someone knows how to do this post some code here so we can see how it's done!!!

THANKS
Dragonslayer
PearsoE
19
Years of Service
User Offline
Joined: 2nd Sep 2004
Location:
Posted: 30th Dec 2004 09:11
In my testing it seems you would need to add a dbCLS(); at the top of your loop before the dbPrint() otherwise as you move the mouse around and the values change they begin to overwrite since the engine is not clearing the screen. Oddly enough though if you are displaying any 3D objects you don't need the dbCLS(). When 3D objects are displayed the engine is clearing the screen for you inbetween frames. See the attached samples.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 30th Dec 2004 09:39
Quote: "Why? Is it a performance issue bacause you need to call dbSetCursor() first when calling dbPrint()?"

Mainly because with dbText you position the cursor and print text in one go.

Beware the Christmas... The fattener... The drunkard...
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 30th Dec 2004 10:57
Dragonslayer:
I posted some code that works with the Y axis. I do not know how to get it to work along with the X axis. The text could be of variable length so it is dificult for me to think of a way to do a hit test on it.....

PearsoE:
That is exactly what I saw too. I sort of danced around that above, but your example demonstrates it exactly.

This demonstrates that redraws do not occur on every frame. That is good for performance, but what has me scratching my head is that when an object is redrawn, the whole window seems to be redrawn, in effect, the whole window is invalidated rather than just a rect surrounding the object is invalidated which causes just a partial redraw, which is more efficient.

I, probably so not understand what is going on....
Gen
19
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 12th Jan 2005 12:11 Edited at: 12th Jan 2005 12:17
I dont have Dark SDK so the commands might not be exact, but you should get the idea.



Hope that helped.

Soon to come...
Dark IDE, New IDE for DarkBASIC Pro!
Two plug-ins, A Time/Date and New File commands.

Login to post a reply

Server time is: 2024-04-18 09:28:02
Your offset time is: 2024-04-18 09:28:02