Generally 'OpenScreen' ---- sucks imho.
There are too many variables to take into account when using it. Screen minimizing..pausing...etc..
Here is another option with OpenWindowedScreen(), which gives you a lot more leverage.
Since the window title is 'panorama' - I did this. Tested on windows 7, 8.1, 10.
Code: Select all
;Created by DK_PETER
;Keys:
;key 1 and 2 - Change Weather
;Return - Hide weather
;Space - Load image
UseJPEGImageDecoder()
UsePNGImageDecoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()
If InitEngine3D(#PB_Engine3D_DebugLog) = 0
MessageRequester("Engine3D", "Error..Init failed..Examine Ogre.log for clues.")
End
EndIf
If InitSprite() = 0
End
EndIf
If InitKeyboard() = 0
End
EndIf
If InitMouse() = 0
End
EndIf
Structure _Object
id.i
ma.i
ms.i
tx.i[2]
EndStructure
Structure _par
id.i
ma.i[2]
tx.i[2]
EndStructure
Declare.i FlipImg(img.i)
Declare.i SetNewMaterial()
Declare.i CreateBase()
Declare.i Atmos(Index.i)
Global ob._Object, pa._par, win.i, Scr.i, ret.i, mx.f, my.f
ExamineDesktops()
w = DesktopWidth(0)
h = DesktopHeight(0)
Win = OpenWindow(#PB_Any, 0, 0, w, h, "Panorama", #PB_Window_ScreenCentered|#PB_Window_BorderLess)
scr = OpenWindowedScreen(WindowID(win), 0, 0, w, h)
CreateCamera(0, 0, 0, 100, 100)
CameraFOV(0, 100)
ret = CreateBase()
Repeat
Repeat
ev = WindowEvent()
Until ev = 0
ExamineMouse()
mx = MouseDeltaX()*0.05
my = MouseDeltaY()*0.05 ;Change these for change in camera rotation
RotateCamera(0, -my, -mx, 0, #PB_Relative)
RenderWorld()
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Space)
ReleaseMouse(1)
ret = SetNewMaterial()
ReleaseMouse(0)
EndIf
If KeyboardReleased(#PB_Key_1)
ret = Atmos(0)
ElseIf KeyboardReleased(#PB_Key_2)
ret = Atmos(1)
ElseIf KeyboardReleased(#PB_Key_Return)
ret = atmos(2)
EndIf
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
End
Procedure.i CreateBase()
Protected img.i, fimg.i, fn = LoadFont(#PB_Any, "Sans Serif", 24)
img = CreateImage(#PB_Any, 1024, 1024)
StartDrawing(ImageOutput(img))
Box(0, 0, 1024, 1024, $FFFFFF)
DrawingMode(#PB_2DDrawing_Transparent)
If IsFont(fn) : DrawingFont(FontID(fn)) : EndIf
DrawText(512 - TextWidth("NOT LOADED!")/2, 512 - TextHeight("N")/2, "NOT LOADED!", $777777)
DrawText(513 - TextWidth("NOT LOADED!")/2, 513 - TextHeight("N")/2, "NOT LOADED!", $444444)
DrawText(512 - TextWidth("PRESS SPACE FOR IMAGE")/2, 540 - TextHeight("N")/2, "PRESS SPACE FOR IMAGE", $FF99FF)
StopDrawing()
fimg = FlipImg(img)
ob\tx[0] = CreateTexture(#PB_Any, 1024, 1024, "Base")
StartDrawing(TextureOutput(ob\tx[0]))
DrawImage(ImageID(fimg), 0, 0)
StopDrawing()
ob\ma = CreateMaterial(#PB_Any, TextureID(ob\tx[0]))
MaterialFilteringMode(ob\ma, #PB_Material_Anisotropic, 8)
MaterialCullingMode(ob\ma, #PB_Material_NoCulling)
ob\ms = CreateSphere(#PB_Any, 50, 50, 50)
ob\id = CreateEntity(#PB_Any,MeshID(ob\ms), MaterialID(ob\ma), 0, 0, 0)
FreeImage(img) : FreeImage(fimg)
EndProcedure
Procedure.i SetNewMaterial()
Protected fil.s, img.i, fimg.i
fil = OpenFileRequester("Select new Image", "", "All images (*.bmp;*.png;*.jpg;*.tga;*.tif)|*.bmp;*.png;*.jpg;*.tif;*.tga|Bitmap (*.bmp)|*.bmp|PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|TGA(*.tga)|*.tga|TIFF (*.tif)|*tif", 0)
If fil <> ""
img = LoadImage(#PB_Any, fil)
If IsImage(img)
fimg = FlipImg(img)
ob\tx[1] = CreateTexture(#PB_Any, ImageWidth(fimg), ImageHeight(fimg), "")
StartDrawing(TextureOutput(ob\tx[1]))
DrawImage(ImageID(fimg), 0, 0)
StopDrawing()
FreeMaterial(ob\ma)
ob\ma = CreateMaterial(#PB_Any, TextureID(ob\tx[1]))
MaterialFilteringMode(ob\ma,#PB_Material_Anisotropic, 8)
MaterialCullingMode(ob\ma, #PB_Material_NoCulling)
SetEntityMaterial(ob\id, MaterialID(ob\ma))
EndIf
FreeImage(img) : FreeImage(fimg)
Else
FreeMaterial(ob\ma)
ob\ma = CreateMaterial(#PB_Any, TextureID(ob\tx[0]))
MaterialFilteringMode(ob\ma, #PB_Material_Anisotropic, 8)
MaterialCullingMode(ob\ma, #PB_Material_NoCulling)
SetEntityMaterial(ob\id, MaterialID(ob\ma))
EndIf
ProcedureReturn #True
EndProcedure
;Flip the image to display correctly
Procedure.i FlipImg(img.i)
Protected ww.i, hh.i, fimg.i
ww = ImageWidth(img)
hh = ImageHeight(img)
fimg = CreateImage(#PB_Any, ww, hh, 32)
StartVectorDrawing(ImageVectorOutput(fimg))
ResetCoordinates()
MovePathCursor(ww, 0)
FlipCoordinatesX(180)
DrawVectorImage(ImageID(img), 255)
StopVectorDrawing()
ProcedureReturn fimg
EndProcedure
Procedure.i Atmos(Index.i)
If IsParticleEmitter(pa\id) = 0
With pa
\id = CreateParticleEmitter(#PB_Any, 50, 50, 50, #PB_Particle_Point, 0, 45, 0)
ParticleTimeToLive(\id, 3, 5)
ParticleEmitterDirection(\id, 0, -1, 0)
ParticleEmissionRate(\id, 2000)
ParticleSpeedFactor(\id, 0.6)
\tx[0] = CreateTexture(#PB_Any, 20, 20, "snow")
StartDrawing(TextureOutput(\tx[0]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($FFFFFF) : BackColor($CCCCCC)
CircularGradient(10, 10, 9)
Circle(10, 10, 9)
StopDrawing()
\tx[1] = CreateTexture(#PB_Any, 20, 20, "rain")
StartDrawing(TextureOutput(\tx[1]))
Box(0, 0, 20, 20, $B87777)
StopDrawing()
\ma[0] = CreateMaterial(#PB_Any, TextureID(\tx[0]))
MaterialBlendingMode(\ma[0], #PB_Material_Add)
MaterialFilteringMode(\ma[0], #PB_Material_Anisotropic, 6)
\ma[1] = CreateMaterial(#PB_Any, TextureID(\tx[1]))
MaterialBlendingMode(\ma[1], #PB_Material_Add)
MaterialFilteringMode(\ma[1], #PB_Material_Anisotropic, 6)
EndWith
EndIf
Select Index
Case 0
ParticleVelocity(pa\id, #PB_Particle_MinimumVelocity, 3)
ParticleVelocity(pa\id, #PB_Particle_Velocity, 7)
ParticleVelocity(pa\id, #PB_Particle_MaximumVelocity,10)
ParticleSize(pa\id, 0.1, 0.1)
ParticleMaterial(pa\id, MaterialID(pa\ma[0]))
HideParticleEmitter(pa\id, #False)
Case 1
ParticleVelocity(pa\id, #PB_Particle_MinimumVelocity, 27)
ParticleVelocity(pa\id, #PB_Particle_Velocity, 47)
ParticleVelocity(pa\id, #PB_Particle_MaximumVelocity, 70)
ParticleSize(pa\id, 0.003, 1)
ParticleMaterial(pa\id, MaterialID(pa\ma[1]))
HideParticleEmitter(pa\id, #False)
Default
HideParticleEmitter(pa\id, #True)
EndSelect
EndProcedure