Posted: 11th Jun 2007 3:22
Hi

For some reason, when I print text on screen, it does not delete after each loop, even with sync at the end of each loop. If I put cls at the end of each loop, everything looks jittery and flickers - not a good effect. Has it got something to do with me using DBPro 5.8?

Thanks
Posted: 11th Jun 2007 3:44
Is this 2D or 3D? If it's 3D you need to be using the "text" command anyways .
Posted: 11th Jun 2007 4:13
Well I suppose it is both 2D and 3D because, I have a viewport that is smaller than the whole screen and in the black areas surrounding it, I have the text.

Thanks
Posted: 11th Jun 2007 5:42
Ok, this is really starting to get on my nerves, I have no idea why something that is supposed to be so simple is so hard. I have been trying for about 3 hours now.
Posted: 11th Jun 2007 5:46
you need a CLS at the TOP of the do loop

if it's 3D you need to use text 5,5,"Text"

if 2D:
do
cls
print "blah"
loop

if 3D:
do
text 5,5,"text"
loop
Posted: 11th Jun 2007 6:18
Thanks!

That works with the text, but now the 3D view port is not visible.

I am really stumped now.
Posted: 11th Jun 2007 6:56
it's 3D, so don't use cls
use text 5,5,"your text here"

if that doesn't help, post some code
Posted: 11th Jun 2007 7:08
Well, now I am back to the start. The text command has the same problem aswell. Here is some code if it helps.

This is the code that draws the main text:

+ Code Snippet
For i=1 To MapNum

   If i=MapSelected
      TextEnh(Map(i).XFile,0,(10*i)-10,C_Orange)

      If Map(i).MDTFile=""
         TextEnh("Press <e> to create new MDT",0,400,C_White)
         If InKey$()="e"
            UI_CreateMDT(Map(i).XFile)
            GoSub LoadMaps
         EndIf
      Else
         TextEnh("Press <e> to delete current MDT",0,400,C_White)
         If InKey$()="e"
            UI_DeleteMDT(Map(i).MDTFile)
            GoSub LoadMaps
         EndIf
      EndIf

      TextEnh("Model File Name: "+Map(i).XFile,300,400,C_White)
      If Map(i).MDTFile=""
         TextEnh("MDT File Name: No MDT file found - press <e> to create one",300,410,C_White)
      Else
         TextEnh("MDT File Name: "+Map(i).MDTFile,300,410,C_White)
      EndIf

   Else
      TextEnh(Map(i).XFile,0,(10*i)-10,C_White)
   EndIf

Next i


This is the TextEnh function (I made this function to give the ability to colour the text in one function):

+ Code Snippet
Function TextEnh(String$,x#,y#,Color)
   Ink Color,C_Black
   Text LMargin+x#,TMargin+y#,String$
   Ink C_White,C_Black
EndFunction


Thanks!
Posted: 11th Jun 2007 10:15
set text opaque works.
Posted: 11th Jun 2007 11:29
That is good but when the previous string was longer than the new string, the end remains visible.
Posted: 11th Jun 2007 15:20
Ok, I found the cause to the problem, but I don't know the fix. What it seems to be is the use of the Set Camera View function. I did many searches and found it turns off the removal of text each loop. But, now what function do I use to replace it?
Posted: 11th Jun 2007 15:24
If there's an area on your screen that needs to be cleared, then use the BOX command to overdraw it in your background colour.
Posted: 11th Jun 2007 16:16
I don't think that DBPro is much different to DB Classic in respect to the topic being discussed. So the following might help you understand what is going on...

If you use Set Camera View to set an area of the screen then that area is 3D and the area around it is 2D.

While the Sync command refreshes the camera view it doesn't clear the 2D area. Every Sync command, any text on the 3D area is deleted and to prevent that happening in DBC you simply put your Text command on the very next line after the Sync in the main program loop. (Actually, I think this the only thing that has changed with Pro as it's no longer necessary).

The CLS command on the other hand only clears the 2D section of the screen and doesn't affect the 3D section. To prevent flickering you just need to put any text commands for the 2D part of the screen immediately after the CLS and before the Sync - and of course make sure you've used Sync On.

The answer to your point about using Set Text Opaque being of no use if the previously printed text used a longer string is quite easy to get around - just add empty space to the end of the string:

Text 20,10,"Short String (Insert Lots Of Spaces Here - They Don't Show Up On The Forum)" or...

Text 20,10,"ShortStrVar$"+"(Insert Lots Of Spaces Here - They Don't Show Up On The Forum)"

TDK_Man
Posted: 12th Jun 2007 8:58
Ah! Now I get why it is happening.

What I found was that if I put the Cls command then the text, then the
Sync, the actual 3D view becomes invisible. I have a little demo program for you to try - this is what the problem is simmilar to.

+ Code Snippet
rem Text problem demo
rem *****************
Sync On
Sync Rate 0
Set Display Mode 800,600,16
Set Camera View 420,20,780,280

rem Simple object
Make Object Box 1,10,10,10

xRot=0

rem Main loop
Do
   If Not ReturnKey()
      Cls
   EndIf
   xRot=xRot+1
   YRotate Object 1,xRot
   Text 10,10,"Notice how the 3D view is not visible"
   Text 10,20,"and this text is. Hold down <Enter> to remove the Cls"
   Text 10,30,"function from each loop."
   Text 10,60,"THIS 'DYNAMIC' TEXT WILL OVERLAP WHILE CLS IS REMOVED"
   Text 10,70,"FROM THE LOOP - THIS IS WHAT THE PROBLEM IS:"
   Text 10,80,Str$(xRot)
   Sync
Loop


Notice the problem?

If anyone can modify that code to work, then that should fix my problem. I would rather not use Set Text Opaque because it could be unreliable.

Thanks
Posted: 12th Jun 2007 10:31
Try This.

+ Code Snippet
rem Text problem demo
rem *****************
Sync On
Sync Rate 0
Set Display Mode 800,600,16
Set Camera View 420,20,780,280

load image "c:\background.png",1,1

rem Simple object
Make Object Box 1,10,10,10

xRot=0

rem Main loop
Do
`   If Not ReturnKey()
`      Cls
`   EndIf
   paste image 1,0,0,1
   xRot=xRot+1
   YRotate Object 1,xRot
   Text 10,10,"Notice how the 3D view is not visible"
   Text 10,20,"and this text is. Hold down <Enter> to remove the Cls"
   Text 10,30,"function from each loop."
   Text 10,60,"THIS 'DYNAMIC' TEXT WILL OVERLAP WHILE CLS IS REMOVED"
   Text 10,70,"FROM THE LOOP - THIS IS WHAT THE PROBLEM IS:"
   Text 10,80,Str$(xRot)
   Sync
Loop


Obviously put the png file wherever you need it.

What I have done is create an image with a transparent window in it at the location of the 3d window. pasting this image each loop clears the text but allows the 3d window to show through.