I have made some updates
You can now align AA text with the align parameter of 'Text AA'
0=Left align
1=Center
2=Right align
Also 3d line should work when you change the camera view. Just remember to set the 3d line viewport to the same as the camera view.
set camera view 256,192,768,576
set view 256,192,768,576
Here is the demo program updated with these changes
Rem Project: Text3D
Rem Created: 12/04/2005 23:51:59
Rem ***** Main Source File *****
set display mode 1024,768,32:sync on:autocam off:backdrop on:color backdrop 0
`Get pointer to D3DDevice
Load Dll "DBProSetupDebug.dll", 1
CID=Call Dll(1, "?GetDirect3DDevice@@YAPAUIDirect3DDevice9@@XZ")
Rem Set Direct3d device to enable D3D operations
SetDX9Device CID
set text font "Arial"
set text size 15
set font 2,"Arial",15,0,0
do
text 0,0,"D3D Extras dll - Demonstation"
text 0,15,"(1) Antialiased text vs Normal text"
text 0,30,"(2) Antialiased text vs Normal text using multiple fonts"
text 0,45,"(3) 3D Text"
text 0,60,"(4) 3D Line Drawing"
text 0,75,"(ESC) Quit Demo"
text 0,105,"Press a key to select a demo"
text 0,750,"Written By Jason Clogg (2005)"
StartText
text AA 2,512,300,1,"Example of AA text alignment"
text AA 2,512,360,0,"0=Left Aligned"
text AA 2,512,380,1,"1=Centered"
text AA 2,512,400,2,"2=Right Aligned"
EndText
line 512,350,512,430
if inkey$()="1" then gosub AntiVsText
if inkey$()="2" then gosub AntiVsTextMulti
if inkey$()="3" then gosub TextMesh
if inkey$()="4" then gosub 3DLineDraw
`if upper$(inkey$())="Q" then end
sync
loop
AntiVsText:
Rem Set Font for Antialiased Text and 3D Text commands - Format is Font number Font Name,size,bold(0 or 1),italic(0 or 1)
set font 1,"Arial",9,0,0
set font 2,"Arial",15,0,0
set text font "Arial"
set text size 15
textmode=1
do
if textmode=1
text 0,0,"Normal Text Text - FPS="+str$(screen fps())
text 0,15,"Press space to toggle test, 'q' to quit to menu"
for i=1 to 200
text rnd(1000),rnd(600)+50,"Test Text String"
next i
else
StartText
text AA 1,0,0,0,"Antialiased Text Text - FPS="+str$(screen fps())
text AA 1,0,15,0,"Press space to toggle test, 'q' to quit to menu,'i' toggle information"
if showinfo=1
text AA 1,0,45,0,"To use the dll text commands you should do the following :-"
text AA 1,0,75,0,"Set the font to use"
text AA 1,0,105,0,"Set the draw colour"
text AA 1,0,135,0,"Start text drawing mode"
text AA 1,0,165,0,"draw the text"
text AA 1,0,195,0,"End text drawing mode"
draw color 255,0,0,100
text AA 1,150,75,0,"Set Font "+chr$(34)+"Arial"+chr$(34)+",9,0,0"
text AA 1,150,105,0,"draw color 255,255,255,100"
text AA 1,150,135,0,"StartText"
text AA 1,150,165,0,"text AA 1,0,0,0,"+chr$(34)+"Hello World"+chr$(34)
text AA 1,150,195,0,"EndText"
draw color 100,100,100,100
text AA 1,150,90,0,"Set Font FontName$,height in pixels,bold(0-no,1-yes),italic(0-no,1-yes)"
text AA 1,150,120,0,"draw color Red(0-255),Green(0-255),Blue(0-255),Alpha(0-100)"
text AA 1,150,180,0,"text AA font number,x,y,alignment,text$"
draw color 255,255,255,100
text AA 1,0,225,0,"Always set your fonts up outside the main loop."
text AA 1,0,240,0,"There can be multiple 'StartText' 'EndText' pairs"
text AA 1,0,255,0,"in a loop but there must not be any image or sprite"
text AA 1,0,270,0,"display commands between 'StartText' and 'EndText'."
text AA 1,0,285,0,"The more of these pairs in your loop the slower it gets!"
xrnd=500:xmin=500
else
draw color 255,255,255,100
xrnd=1000:xmin=0
endif
for i=1 to 200
text AA 2,rnd(xrnd)+xmin,rnd(600)+50,0,"Test Text String"
next i
EndText
endif
rem Perform Text drawing to screen EndText dummyval. Not sure how to set up function
rem with no parameters or return code
if spacekey()=1
if spacepressed=0
spacepressed=1
if textmode=1 then textmode=0 else textmode=1
endif
else
spacepressed=0
endif
if upper$(inkey$())="I"
if Ipressed=0
Ipressed=1
if showinfo=1 then showinfo=0 else showinfo=1
endif
else
Ipressed=0
endif
if upper$(inkey$())="Q"
set text font "Arial"
set text size 15
ink rgb(255,255,255),0
return
endif
sync
loop
return
AntiVsTextMulti:
set font 1,"Arial",9,0,0
set font 2,"Tahoma",15,0,0
set font 3,"Comic Sans MS",25,0,0
draw color 255,0,0,100
ink rgb(255,0,0),0
textmode=1
do
if textmode=1
set text font "Arial"
set text size 15
text 0,0,"Normal Text Text - FPS="+str$(screen fps())
text 0,15,"Press space to toggle test, 'q' to quit to menu"
for i=1 to 5
set text font "Tahoma"
set text size 25
text rnd(1000),rnd(600)+50,"Test Text String"
set text font "Comic Sans MS"
set text size 42
text rnd(1000),rnd(600)+50,"Test Text String"
next i
else
StartText
text AA 1,0,0,0,"Antialiased Text Text - FPS="+str$(screen fps())
text AA 1,0,15,0,"Press space to toggle test, 'q' to quit to menu"
for i=1 to 200
text AA 2,rnd(1000),rnd(600)+50,0,"Test Text String"
text AA 3,rnd(1000),rnd(600)+50,0,"Test Text String"
next i
EndText
endif
if spacekey()=1
if spacepressed=0
spacepressed=1
if textmode=1 then textmode=0 else textmode=1
endif
else
spacepressed=0
endif
if upper$(inkey$())="Q"
set text font "Arial"
set text size 15
ink rgb(255,255,255),0
return
endif
sync
loop
return
TextMesh:
cls
do
text$=InputText(0,0,"Enter text to be converted to a mesh : ","Text3D")
font$=InputText(0,0,"Enter font to use : ","Arial")
depth#=val(InputText(0,0,"Enter object depth : ",".1"))
quality=val(InputText(0,0,"Enter object quality(0-high,1-medium,2-low) : ","0"))
alignment=val(InputText(0,0,"Enter mesh alignment(0-left,1-center,2-right,3-font origin : ","1"))
set font 1,font$,15,0,0
ret=Text3D("Text3D.x",text$,depth#,quality,alignment)
if ret=0
set text font "Arial"
set text size 15
return
endif
load object "Text3D.x",1
position object 1,0,0,0
color object 1,rgb(255,0,0)
ca#=0
while spacekey()=0
text 0,0,"3D Text Demonstration - FPS="+str$(screen fps())+" - polygons="+str$(statistic(1))
text 0,15,"Press Space to create another object"
text 0,30,"Press 'q' to quit to menu"
cx#=cos(ca#)*5
cz#=sin(ca#)*5
position camera cx#,2,cz#
point camera 0,0,0
ca#=ca#+.1
if upper$(inkey$())="Q"
set text font "Arial"
set text size 15
ink rgb(255,255,255),0
delete object 1
return
endif
sync
endwhile
delete object 1
loop
return
3DLineDraw:
cls
ca#=0
for i=1 to 20
if object exist(i+100)=0 then make object sphere i+100,.5
hide object i+100
next i
zpos#=50
x=0
y=0
set text opaque
do
color backdrop rgb(10,10,10)
set camera view 256,192,768,576
set view 256,192,768,576
text 0,0,"3D Line Demonstration - FPS="+str$(screen fps())
text 0,15,"Press 'q' to quit to menu"
cx#=cos(ca#)*zpos#
cz#=sin(ca#)*zpos#
position camera cx#,2,cz#
point camera 0,0,0
ca#=ca#+.1
randomize 0
x1#=rnd(20)-5
y1#=rnd(20)-5
z1#=rnd(20)-5
for i=1 to 20
x2#=rnd(20)-5
y2#=rnd(20)-5
z2#=rnd(20)-5
position object i+100,x1#,y1#,z1#
show object i+100
draw color rnd(255),rnd(255),rnd(255),rnd(100)
Line3d x1#,y1#,z1#,x2#,y2#,z2#
x1#=x2#
y1#=y2#
z1#=z2#
next i
if zpos#=>50 then zmove#=-.01
if zpos#=<-50 then zmove#=.01
zpos#=zpos#+zmove#
if upper$(inkey$())="Q"
for i=1 to 20
hide object i+100
next i
set camera view 0,0,screen width(),screen height()
cls 0
set text font "Arial"
set text size 15
ink rgb(255,255,255),0
return
endif
sync
loop
return
function InputText(x,y,Message$,default$)
text$=default$
clear entry buffer
do
text x,y,Message$+text$
buf$=entry$():clear entry buffer
for i=1 to len(buf$)
select asc(mid$(buf$,i))
case 8
text$=left$(text$,len(text$)-1)
endcase
case 13
exitfunction text$
endcase
case default
text$=text$+mid$(buf$,i)
endcase
endselect
next i
sync
loop
endfunction ""
Don't forget to download the attached dll.
Enjoy,
Cloggy