thanks for posting this exercise.
the code works in version 3.72 also in v 3.90 from the purebasic museum in 2002, 2003
i make one step to make it run in PB v5.31 , but can't display the text normally, it is displayed at the upper of the screen. hope the sprites and memory functions experts help.
i haven't used SetMeshData since PB automatically pump the info to the mesh every time we use MeshVertexPosition or MeshVertexTextureCoordinate or MeshFace ... then FinishMesh(#True)
the SetMeshData are suitable with huge data.
the code needs the picture car2.bmp from the above file
needs v5.31, and runs partially
PS: the code are corrected for the mesh construction, but still not works correctly
PS2:note UserBuffer(0) are important: from the pb372 doc: it Changes the default rendering buffer (usually the screen) to the given #Sprite. but whats its replacement in 531?
Code: Select all
;
;
; stars war scroller
; by R.JAMES (VIRTUALYS)
;
; Virtualys for U
InitEngine3D()
InitSprite()
InitKeyboard()
Structure car
x.w
y.w
EndStructure
ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0)-5, 0, 0, 0)
;OpenScreen(640, 480, 16, "")
;CreateSprite(0,512,1,#PB_Sprite_Memory)
CreateSprite(0,512,1)
;LoadSprite(1, "car2.bmp", #PB_Sprite_Memory)
LoadSprite(1, "car2.bmp")
Dim pos.car(130)
u=0
For j=0 To 3
For i=0 To 25
pos(u)\x=i*24
pos(u)\y=j*24
u+1
Next i
Next j
StartDrawing(SpriteOutput(0))
adr.l = DrawingBuffer()
pix = DrawingBufferPitch()
StopDrawing()
CreateTexture(0, 512, 512)
CreateMaterial(0, TextureID(0))
DisableMaterialLighting(0, 1)
MaterialBlendingMode(0, 1)
Fog(RGB(0, 0, 0), 1, 100, 430)
CreateMesh(1, #PB_Mesh_TriangleList , #PB_Mesh_Static )
; constructing the mesh
MeshVertexPosition(-50,-50,0)
MeshVertexTextureCoordinate(0, 1)
MeshVertexPosition(50,-50,0)
MeshVertexTextureCoordinate(1, 1)
MeshVertexPosition(50,50,0)
MeshVertexTextureCoordinate(1, 0)
MeshVertexPosition(-50,50,0)
MeshVertexTextureCoordinate(0, 0)
MeshFace(0, 1, 2)
MeshFace(2, 3, 0)
FinishMesh(#True)
CreateEntity(1, MeshID(1), MaterialID(0))
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 260)
CameraFOV(0, 30)
ScaleEntity(1, 1, 3, 1)
RotateEntity(1, 0, -70, 0)
;RotateEntity(1, 0, 0, 90)
StartDrawing(TextureOutput(0))
adr2.l = DrawingBuffer()
StopDrawing()
AmbientColor(RGB(255, 255, 255))
Dim t$(40)
t$(0)="Episode I"
t$(1)=" "
t$(2)="STARWARS SCROLLER"
t$(3)=" "
t$(4)=" "
t$(5)=" "
t$(6)="Par R.James"
t$(7)="(VIRTUALYS)"
t$(8)="Graphix:"
t$(9)="VIRTUALYS"
t$(10)=" "
t$(11)=" "
t$(12)="Feel this scroll...."
t$(13)=" "
t$(14)=" "
t$(15)="See U soon!"
t$(16)=" "
t$(17)="Greets to:"
t$(18)="Frederic Laboureur"
t$(19)=" "
t$(20)="and all the rest..."
t$(21)=" "
t$(22)=" "
t$(23)="vv vv ssssss"
t$(24)="vv vv ss "
t$(25)=" vv vv ss "
t$(26)=" vv vv ssssss "
t$(27)=" vv vv ss"
t$(28)=" v v ss"
t$(29)=" vv ssssss"
t$(30)=" "
t$(31)=" "
t$(32)=" bye! bye!"
t$(33)=" "
t$(34)=" "
t$(35)=" ............"
t$(36)=" ............"
t$(37)=" ............"
t$(38)=" "
t$(39)=" "
t$(40)=" "
txt=0
Repeat
WindowEvent()
;FlipBuffers()
;ClearScreen(RGB(0, 0, 0))
ExamineKeyboard()
t + 1
If t > 2
t = 1
StartDrawing(TextureOutput(0))
CopyMemory(adr2 + pix, adr2, 511 * pix)
CopyMemory(adr, adr2+511*pix, pix)
StopDrawing()
EndIf
g.f + 0.5
If g > =24
g = 0
txt=txt+1
If txt>40
txt=0
EndIf
EndIf
;UserBuffer(0)
For i=0 To Len(t$(txt))-1
s=(Asc(Mid(t$(txt),i+1,1))-32)
ClipSprite(1,pos(s)\x,pos(s)\y,24,24)
xx=256-(((Len(t$(txt)))*24)/2)
DisplaySprite(1,xx+i*24,-g)
Next i
;UseBuffer(-1)
;RotateEntity(1, 0, 1,0,#PB_Relative)
FlipBuffers()
RenderWorld()
Until KeyboardPushed(#PB_Key_Escape)
End
DataSection
Point:
Data.f -50,-50,0
Data.f 50,-50,0
Data.f 50,50,0
Data.f -50,50,0
Texturecoord:
Data.f 0.0, 1.0
Data.f 1.0, 1.0
Data.f 1.0, 0.0
Data.f 0.0, 0.0
Face:
Data.w 0,1,2
Data.w 2,3,0
EndDataSection
for those who want doc about some 3.72 functions here it is:
Code: Select all
This is doc for PB v3.72
SetMeshData()
Syntax
SetMeshData(#Mesh, Type, Data, DataLength)
Description
Set a specific data to a #Mesh. 'Data' is the memory address of the data to be set in the #Mesh. 'DataLength' is the length its data, depending of its type. This command is mainly used in combination with CreateMesh().
'Type' can be one of the following values:
#PB_Mesh_Vertices : 'Data' is an array of vertices, 'DataLength' is the number of elements
#PB_Mesh_Triangles : 'Data' is an array of triangles, each triangle vertex is an index of the vertices array. The array @LineBreak
need to be of 'word' type (.w). 'DataLength' is the number of elements
#PB_Mesh_UVCoordinates: 'Data' is an array of UVCoordinates, 'DataLength' is the number of elements
#PB_Mesh_Normals : 'Data' is an array of Normals, 'DataLength' is the number of elements
#PB_Mesh_Colors : 'Data' is an array of Colors, 'DataLength' is the number of elements
==================================================================================
DrawingBufferPitch()
Syntax
Result = DrawingBufferPitch()
Description
Returns the real length of one line, in bytes, of the current buffer. This is need when accessing the video memory directly to go from line to line.
====================================================================================
DrawingBuffer()
Syntax
MemoryAddress = DrawingBuffer()
Description
Returns the MemoryAddress of the drawing buffer. It can be directory in video memory if the output is a ScreenOutput() or SpriteOutput() and allows very fast pixel manipulation. If the 'MemoryAddress' is 0, then the direct memory access isn't available. This commands is for advanced programmers only. To get more informations about the buffer, the following commands are available: DrawingBufferPixelFormat() and DrawingBufferPitch().
====================================================================================
UseBuffer()
Syntax
UseBuffer(#Sprite)
Description
Changes the default rendering buffer (usually the screen) to the given #Sprite. This means than all following DisplaySprite() like commands will be rendered on the #Sprite. To get back on the main screen buffer, use a -1 #Sprite value.
=====================================================================================