Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
- skinkairewalker
- Enthusiast
- Posts: 782
- Joined: Fri Dec 04, 2015 9:26 pm
Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
A while ago, I asked if there was a way to draw sprites/images on the screen to create a ‘user interface.’ Someone responded that it could potentially cause problems or bugs. Now I’m curious to know the reason behind this and why there are limitations when using Ogre with 2D drawing …
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
I don't know the original post, but I think there must be some kind of misunderstanding behind that.
I use native pb sprites for gui (all the time), no problems have had happened so far. I would not use the draw commands in the main loop for that, but of course I create my gui elements using those once.
Sprites and the 2d draw commands are different animals. Sprites are fast, and good for Gui, 2d drawing is slow, it's perfect to create sprites once even on the fly, but bad, if you want to update (redraw) them with every iteration of your main loop.
I use native pb sprites for gui (all the time), no problems have had happened so far. I would not use the draw commands in the main loop for that, but of course I create my gui elements using those once.
Sprites and the 2d draw commands are different animals. Sprites are fast, and good for Gui, 2d drawing is slow, it's perfect to create sprites once even on the fly, but bad, if you want to update (redraw) them with every iteration of your main loop.
- skinkairewalker
- Enthusiast
- Posts: 782
- Joined: Fri Dec 04, 2015 9:26 pm
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
I was happy to hear that, thank u!
But another thing worries me, how is the detection of a button click done for example? Wouldn't this cause a conflict with the 3D render?
But another thing worries me, how is the detection of a button click done for example? Wouldn't this cause a conflict with the 3D render?
-
- Addict
- Posts: 2345
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
That's historical information. I don't remember the exact dates so I replaced them by absurd ordinals:
200 AD: PB only had sprites. DX7 was nice, blitting was fun.
299 AD: DX9 happened.
300 AD: First contact with Ogre in PB. Mixing Ogre and sprites worked.
400 AD: Ogre and sprites didn't work like before.
500 AD: Ogre and sprites worked again.
However Ogre is a different ecosystem, it's very likely that these two things can have severe bugs from time to time. It's already impressive that Ogre works within PB screens IMHO.
200 AD: PB only had sprites. DX7 was nice, blitting was fun.
299 AD: DX9 happened.
300 AD: First contact with Ogre in PB. Mixing Ogre and sprites worked.
400 AD: Ogre and sprites didn't work like before.
500 AD: Ogre and sprites worked again.
However Ogre is a different ecosystem, it's very likely that these two things can have severe bugs from time to time. It's already impressive that Ogre works within PB screens IMHO.
bye,
Daniel
Daniel
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
I wrote a tool that Is under heavy use almost every day since 5.73.it's very likely that these two things can have severe bugs from time to time.
It is over 20k+ lines, uses sprites+3DEngine, recompiled succesfully with every new PB version and backend,
It is without a single crash, so I'm pretty confident, that it is safe.
Side note, that this program is being used on Windows, so I can not state this must be true to other operation systems.
@skinkairewalker
You have to write the behavior of every gui element, you want to use. I only uses spritetext, buttons, checkboxes and sliders.
I wanted to provide an example, so I checked my code. Unfortunately, It would be very time consuming to extract something small and useful.
As a start point for buttons:
I use the mouse commands, I save mouse position and mouse button states to variables at the beginning of the main loop.
At the end, after renderworld I iterate trough a list of buttons once to display them, I check a rectangular area if they are mouseovered, and display the corresponding sprite, and if mousebutton is pressed while mouseovered, I also set an eventvariable with the ID of the button.
I check these eventvariables inside the main loop, and trigger something if its not 0.
I render a sprite for mouse just before flipbuffers. I'm not sure, this was helpful or clear enough though.
- skinkairewalker
- Enthusiast
- Posts: 782
- Joined: Fri Dec 04, 2015 9:26 pm
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
awesome guys
thanks by u help !!

- skinkairewalker
- Enthusiast
- Posts: 782
- Joined: Fri Dec 04, 2015 9:26 pm
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
This worries me because I imagine the following situation: what if I want to create a text chat? From what I've seen in the documentation, the only way to create interfaces with text is through 'DrawText' (am I right?).miso wrote: Wed Oct 16, 2024 11:30 am
Sprites and the 2d draw commands are different animals. Sprites are fast, and good for Gui, 2d drawing is slow, it's perfect to create sprites once even on the fly, but bad, if you want to update (redraw) them with every iteration of your main loop.
Or does DrawText avoid this context of slowness?
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
I have to go to work now, but I can extract tonight my textout() function into an example, because it is small. There are multiple solutions for a chat though. You might draw all the text onto a sprite with drawtext, display that, and redraw only when new message arrives,
- pf shadoko
- Enthusiast
- Posts: 386
- Joined: Thu Jul 09, 2015 9:07 am
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
look forward to the next version of PB
It should bring a new sprite-based UI (so 3D compatible)
It should bring a new sprite-based UI (so 3D compatible)
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
@pf shadoko
Great news
@skinkairewalker
After casting Bigby's compressing hands on my code, the result looks like a mess. The important part is just three small function though, setfontimport(), readsystemfontdata() and textout(). There are a couple of much better examples on the forum than mine. Works with or without the ogre engine. DirectX was not tested, I only use the default Opengl subsystem.
Great news

@skinkairewalker
After casting Bigby's compressing hands on my code, the result looks like a mess. The important part is just three small function though, setfontimport(), readsystemfontdata() and textout(). There are a couple of much better examples on the forum than mine. Works with or without the ogre engine. DirectX was not tested, I only use the default Opengl subsystem.
Code: Select all
EnableExplicit
DeclareModule sys
#Target_Width=1366 : #Target_Height=768 : #APP_NAME="COMMANDER 64 Print example"
#USED_CHARACTERS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[{]};:',<.>/?"+Chr(34)
#ERROR_1="No valid desktop found.":#ERROR_2="Desktop resolution must be at least 1366*768."
#ERROR_3="Could not initialize the sound device.":#ERROR_4="Could not initialize the Sprite Environment."
#ERROR_5="Could not initialize the keyboard input device.":#ERROR_6="Could not initialize the mouse input device."
#ERROR_7="Could not open the graphic screen.":#ERROR_8="Could not set the 3D environment."
#c64_Color_Black=0:#c64_Color_White=1:#c64_Color_Red=2:#c64_Color_Cyan=3:#c64_Color_Violet=4:#C64_Color_Purple=4:#c64_Color_Green=5
#c64_Color_Blue=6:#c64_Color_Yellow=7:#c64_Color_Orange=8:#c64_Color_Brown=9:#c64_Color_LightRed=10:#c64_Color_DarkGrey=11
#c64_Color_Grey=12:#c64_Color_LightGreen=13:#c64_Color_LightBlue=14:#c64_Color_LightGray=15:#c64_Color_Cull=16
Structure colorstructure : r.i : g.i : b.i : a.i : EndStructure
Declare Init():Declare Update():Declare Critical_Error(message.s):Declare setfontimport():Declare readsystemfontdata()
Declare textout(x.i,y.i,text.s,color.i):Declare createC64Desktopsprite():Declare fillc64hardwarepal():Declare.i c64color(color.i)
Declare createc64mouse():Declare Predate()
Global DISPLAY_Count.i,maindisplay_h.i=0,mainwindow_h.i,c64_Cursorsprite.i,c64_desktopsprite.i,CONTROLLER_Count.i
Global c64_mousesprite.i,maincamera_h.i
Global Dim sysfont(370):Global Dim fontimport.i(370):Global Dim c64palette.colorstructure(16):Global Dim sprite2d(64,64):Global Dim spritemask2d(64,64)
EndDeclareModule
Module sys
Procedure fillc64Hardwarepal():Define j
Restore petskii_colors
For j= 0 To 16 : Read.a c64palette(j)\r : Read.a c64palette(j)\g : Read.a c64palette(j)\b : c64palette(j)\a=255 :Next j :c64palette(16)\a=0
EndProcedure
Procedure.i c64color(color.i)
If color<0 Or color>16 : ProcedureReturn RGB(0,0,0) : EndIf
ProcedureReturn RGB(c64palette(color)\r,c64palette(color)\g,c64palette(color)\b)
EndProcedure
Procedure.i c64colorAlpha(color.i)
If color<0 Or color>16 : ProcedureReturn RGBA(0,0,0,0) : EndIf
ProcedureReturn RGBA(c64palette(color)\r,c64palette(color)\g,c64palette(color)\b,255)
EndProcedure
Procedure Init()
DISPLAY_Count = ExamineDesktops(): If DISPLAY_Count<1 : Critical_Error(#ERROR_1) : EndIf
;If DesktopWidth(maindisplay_h)<#Target_Width Or DesktopHeight(maindisplay_h)<#Target_Height : Critical_Error(#ERROR_2) : EndIf
If Not InitSound(): Critical_Error(#ERROR_3):EndIf :If Not InitEngine3D() : Critical_Error(#ERROR_8):EndIf
If Not InitSprite(): Critical_Error(#ERROR_4):EndIf
If Not InitKeyboard(): Critical_Error(#ERROR_5):EndIf : If Not InitMouse(): Critical_Error(#ERROR_6):EndIf
CONTROLLER_Count=InitJoystick()
setfontimport():fillc64hardwarepal()
mainwindow_h = OpenWindow(#PB_Any,(DesktopWidth(0)-#Target_Width)*0.5,(DesktopHeight(0)-#Target_Height)*0.5,#Target_Width,#Target_Height,#APP_NAME)
If Not OpenWindowedScreen(WindowID(mainwindow_h),0,0,WindowWidth(mainwindow_h),WindowHeight(mainwindow_h),1,0,0,#PB_Screen_WaitSynchronization) : Critical_Error(#ERROR_7): EndIf
SetFrameRate(60):readsystemfontdata():createc64desktopsprite():createc64mouse()
EndProcedure
Procedure update()
DisplayTransparentSprite(c64_mousesprite,WindowMouseX(mainwindow_h),WindowMouseY(mainwindow_h))
EndProcedure
Procedure PreDate(): Define windoweventstatus.i,j.i
Repeat : windoweventstatus=WindowEvent()
If windoweventstatus=#PB_Event_CloseWindow:End:EndIf
Until windoweventstatus=0
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape):End:EndIf
ReleaseMouse(#False)
ExamineMouse()
EndProcedure
Procedure Critical_Error(message.s) : MessageRequester("Critical Error!",message.s, #PB_MessageRequester_Error) : End : EndProcedure
Procedure setfontimport() :Define i.i : For i = 1 To Len(sys::#USED_CHARACTERS) :fontImport(Asc(Mid(sys::#USED_CHARACTERS,i,1)))=1 : Next i : EndProcedure
Procedure create_c64_cursor()
c64_cursorsprite=CreateSprite(-1,16,24,#PB_Sprite_AlphaBlending):StartDrawing(SpriteOutput(c64_cursorsprite)):Box(1,1,14,22,RGBA(255,255,255,255)):StopDrawing()
EndProcedure
Procedure readsystemfontdata() : Define sprline.a,x.i,i.i,j.i
Restore petskii_font
For x= 1 To 370
If fontimport(x)=1
sysfont(x)=CreateSprite(-1,8,12,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(sysfont(x)))
DrawingMode(#PB_2DDrawing_AllChannels)
;You can replace all these shennanigens with a single drawtext(0,0,chr(x),rgba(255,255,255,255),rgba(0,0,0,0)) using your favorite truetype font
;sprite and font sizes matter, this example has just this monospace font.
;-----------------------------------------------------------------------------------------------------------------------------------------------
For j=0 To 11
Read.a sprline
For i=0 To 7
If sprline&%1 :Plot(i,j,RGBA(255,255,255,255)): Else : Plot(i,j,RGBA(0,0,0,0)) : EndIf
sprline>>1
Next i
Next j
;-----------------------------------------------------------------------------------------------------------------------------------------------
StopDrawing()
ZoomSprite(sysfont(x),16,24)
EndIf
Next x
EndProcedure
Procedure textout(x,y,text.s,color.i) : Define.i textlength,i,character
textlength.i = Len(text.s)
For i = 1 To textlength
character.i = Asc(Mid(text.s,i,1))
If IsSprite(sysfont(character))
DisplayTransparentSprite(sysfont(character),(x+((i-1) * 16)),(y),255,color.i)
EndIf
Next i
EndProcedure
Procedure createc64desktopsprite()
c64_desktopsprite=CreateSprite(-1,#Target_Width,#Target_Height,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(c64_desktopsprite))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,#Target_Width,#Target_Height,RGBA(0,136,255,255))
Box(#Target_Height*0.1,#Target_Height*0.1,#Target_Width-(#Target_Height*0.2),#Target_Height*0.8,RGBA(0,0,0,0))
StopDrawing()
EndProcedure
Procedure createc64mouse()
c64_mousesprite=CreateSprite(-1,16,16,#PB_Sprite_AlphaBlending)
Restore mcursor_type_0:
For i=0 To 15
Read.u myunicodecharacter : Read.u myunicodecharacter2
For j =15 To 0 Step -1
sys::spritemask2d(i,j)=myunicodecharacter&%1 : sys::sprite2d(i,j)=myunicodecharacter2&%1
myunicodecharacter>>1 : myunicodecharacter2>>1
Next j
Next i
StartDrawing(SpriteOutput(c64_mousesprite))
DrawingMode(#PB_2DDrawing_AllChannels)
For i=0 To 15
For j =0 To 15
If spritemask2d(i,j)=1
Plot(i,j,c64colorAlpha(sprite2d(i,j)))
spritemask2d(i,j)=0 : sprite2d(i,j)=0
EndIf
Next j
Next i
StopDrawing()
ZoomSprite(c64_mousesprite,64,64)
SpriteQuality(0)
EndProcedure
DataSection
petskii_font:
Data.a $00,$00,$38,$38,$38,$38,$38,$38,$00,$38,$00,$00,$00,$00,$EE,$EE,$EE,$00,$00,$00,$00,$00,$00,$00,$00,$00,$EE,$EE,$EE,$FF,$EE,$FF,$EE,$EE,$00,$00,$00,$00,$38,$38,$FC,$0E,$7C,$E0,$7E,$38,$00,$00
Data.a $00,$00,$CE,$CE,$EE,$70,$38,$1C,$EE,$E6,$00,$00,$00,$00,$7C,$7C,$EE,$7C,$3C,$EE,$EE,$FC,$00,$00,$00,$00,$E0,$E0,$70,$38,$00,$00,$00,$00,$00,$00,$00,$00,$70,$70,$38,$1C,$1C,$1C,$38,$70,$00,$00
Data.a $00,$00,$1C,$1C,$38,$70,$70,$70,$38,$1C,$00,$00,$00,$00,$00,$00,$EE,$7C,$FF,$7C,$EE,$00,$00,$00,$00,$00,$00,$00,$38,$38,$FE,$38,$38,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$38,$38,$1C,$00
Data.a $00,$00,$00,$00,$00,$00,$FE,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$38,$38,$00,$00,$00,$00,$00,$00,$C0,$E0,$70,$38,$1C,$0E,$00,$00,$00,$00,$7C,$7C,$EE,$FE,$FE,$EE,$EE,$7C,$00,$00
Data.a $00,$00,$38,$38,$38,$3C,$38,$38,$38,$FE,$00,$00,$00,$00,$7C,$7C,$EE,$E0,$70,$1C,$0E,$FE,$00,$00,$00,$00,$7C,$7C,$EE,$E0,$78,$E0,$EE,$7C,$00,$00,$00,$00,$E0,$E0,$F0,$F8,$EE,$FE,$E0,$E0,$00,$00
Data.a $00,$00,$FE,$FE,$0E,$7E,$E0,$E0,$EE,$7C,$00,$00,$00,$00,$7C,$7C,$EE,$0E,$7E,$EE,$EE,$7C,$00,$00,$00,$00,$FE,$FE,$EE,$70,$38,$38,$38,$38,$00,$00,$00,$00,$7C,$7C,$EE,$EE,$7C,$EE,$EE,$7C,$00,$00
Data.a $00,$00,$7C,$7C,$EE,$EE,$FC,$E0,$EE,$7C,$00,$00,$00,$00,$38,$38,$38,$00,$00,$00,$38,$38,$00,$00,$00,$00,$38,$38,$38,$00,$00,$00,$38,$38,$1C,$00,$00,$00,$F0,$F0,$38,$1C,$0E,$1C,$38,$F0,$00,$00
Data.a $00,$00,$00,$00,$00,$FE,$00,$FE,$00,$00,$00,$00,$00,$00,$1E,$1E,$38,$70,$E0,$70,$38,$1E,$00,$00,$00,$00,$7C,$7C,$EE,$E0,$70,$38,$00,$38,$00,$00,$00,$00,$7C,$7C,$EE,$FE,$FE,$0E,$CE,$7C,$00,$00
Data.a $00,$00,$38,$38,$7C,$EE,$FE,$EE,$EE,$EE,$00,$00,$00,$00,$7E,$7E,$EE,$EE,$7E,$EE,$EE,$7E,$00,$00,$00,$00,$7C,$7C,$EE,$0E,$0E,$0E,$EE,$7C,$00,$00,$00,$00,$3E,$3E,$7E,$EE,$EE,$EE,$7E,$3E,$00,$00
Data.a $00,$00,$FE,$FE,$0E,$0E,$3E,$0E,$0E,$FE,$00,$00,$00,$00,$FE,$FE,$0E,$0E,$3E,$0E,$0E,$0E,$00,$00,$00,$00,$7C,$7C,$EE,$0E,$FE,$EE,$EE,$7C,$00,$00,$00,$00,$EE,$EE,$EE,$EE,$FE,$EE,$EE,$EE,$00,$00
Data.a $00,$00,$7C,$7C,$38,$38,$38,$38,$38,$7C,$00,$00,$00,$00,$F8,$F8,$70,$70,$70,$70,$7E,$3C,$00,$00,$00,$00,$EE,$EE,$7E,$3E,$1E,$3E,$7E,$EE,$00,$00,$00,$00,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$FE,$00,$00
Data.a $00,$00,$CE,$CE,$FE,$FE,$FE,$CE,$CE,$CE,$00,$00,$00,$00,$EE,$EE,$FE,$FE,$FE,$FE,$EE,$EE,$00,$00,$00,$00,$7C,$7C,$EE,$EE,$EE,$EE,$EE,$7C,$00,$00,$00,$00,$7E,$7E,$EE,$EE,$7E,$0E,$0E,$0E,$00,$00
Data.a $00,$00,$7C,$7C,$EE,$EE,$EE,$EE,$7C,$F0,$00,$00,$00,$00,$7E,$7E,$EE,$EE,$7E,$3E,$7E,$EE,$00,$00,$00,$00,$7C,$7C,$EE,$0E,$7C,$E0,$EE,$7C,$00,$00,$00,$00,$FE,$FE,$38,$38,$38,$38,$38,$38,$00,$00
Data.a $00,$00,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$7C,$00,$00,$00,$00,$EE,$EE,$EE,$EE,$EE,$EE,$7C,$38,$00,$00,$00,$00,$CE,$CE,$CE,$CE,$FE,$FE,$FE,$CE,$00,$00,$00,$00,$EE,$EE,$EE,$7C,$38,$7C,$EE,$EE,$00,$00
Data.a $00,$00,$EE,$EE,$EE,$EE,$7C,$38,$38,$38,$00,$00,$00,$00,$FE,$FE,$E0,$70,$38,$1C,$0E,$FE,$00,$00,$00,$00,$7C,$7C,$1C,$1C,$1C,$1C,$1C,$7C,$00,$00,$00,$00,$7C,$7C,$70,$70,$70,$70,$70,$7C,$00,$00
Data.a $00,$00,$38,$38,$7C,$FE,$38,$38,$38,$38,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$FF,$00,$00,$00,$00,$00,$00,$00,$7C,$E0,$FC,$EE,$FC,$00,$00,$00,$00,$00,$00,$0E,$0E,$7E,$EE,$EE,$7E,$00,$00
Data.a $00,$00,$00,$00,$00,$7C,$0E,$0E,$0E,$7C,$00,$00,$00,$00,$00,$00,$E0,$E0,$FC,$EE,$EE,$FC,$00,$00,$00,$00,$00,$00,$00,$7C,$EE,$FE,$0E,$7C,$00,$00,$00,$00,$00,$00,$F0,$38,$FC,$38,$38,$38,$00,$00
Data.a $00,$00,$00,$00,$00,$FC,$EE,$EE,$FC,$E0,$7E,$00,$00,$00,$0E,$0E,$0E,$7E,$EE,$EE,$EE,$EE,$00,$00,$00,$00,$38,$38,$00,$3C,$38,$38,$38,$7C,$00,$00,$00,$00,$00,$00,$70,$00,$70,$70,$70,$70,$3C,$00
Data.a $00,$00,$0E,$0E,$0E,$0E,$7E,$3E,$7E,$EE,$00,$00,$00,$00,$3C,$3C,$38,$38,$38,$38,$38,$7C,$00,$00,$00,$00,$00,$00,$00,$EE,$FE,$FE,$FE,$CE,$00,$00,$00,$00,$00,$00,$00,$7E,$EE,$EE,$EE,$EE,$00,$00
Data.a $00,$00,$00,$00,$00,$7C,$EE,$EE,$EE,$7C,$00,$00,$00,$00,$00,$00,$00,$7E,$EE,$EE,$7E,$0E,$0E,$00,$00,$00,$00,$00,$00,$FC,$EE,$EE,$FC,$E0,$E0,$00,$00,$00,$00,$00,$00,$7E,$EE,$0E,$0E,$0E,$00,$00
Data.a $00,$00,$00,$00,$00,$FC,$0E,$7C,$E0,$7E,$00,$00,$00,$00,$00,$00,$38,$FE,$38,$38,$38,$F0,$00,$00,$00,$00,$00,$00,$00,$EE,$EE,$EE,$EE,$FC,$00,$00,$00,$00,$00,$00,$00,$EE,$EE,$EE,$7C,$38,$00,$00
Data.a $00,$00,$00,$00,$00,$CE,$FE,$FE,$FC,$FC,$00,$00,$00,$00,$00,$00,$00,$EE,$7C,$38,$7C,$EE,$00,$00,$00,$00,$00,$00,$00,$EE,$EE,$EE,$FC,$70,$3E,$00,$00,$00,$00,$00,$00,$FE,$70,$38,$1C,$FE,$00,$00
Data.a $00,$00,$F0,$F0,$38,$38,$1E,$38,$38,$F0,$00,$00,$00,$00,$1E,$1E,$38,$38,$F0,$38,$38,$1E,$00,$00
petskii_colors:
Data.a $01,$01,$01,$FF,$FF,$FF,$88,$00,$00,$AA,$FF,$EE,$CC,$44,$CC,$00,$CC,$55,$00,$00,$AA,$EE,$EE,$77,$DD,$88,$55,$66,$44,$00,$FF,$77,$77,$33,$33,$33,$77,$77,$77,$AA,$FF,$66,$00,$88,$FF,$BB,$BB,$BB
Data.a $00,$00,$00
mcursor_type_0:
Data.a $F8,$FF,$00,$00,$F8,$FF,$F0,$7F,$FF,$7F,$F0,$1F,$FF,$1F,$FE,$07,$FF,$07,$CE,$01,$CF,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
Data.a $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
EndDataSection
EndModule
;_____________________________MAIN PROGRAM_________________________
sys::init()
sys::maincamera_h = CreateCamera(-1,0,0,100,100)
CameraBackColor(sys::maincamera_h,sys::c64color(sys::#c64_Color_Blue))
Define cubemesh_h.i,cubeentity_h.i
cubemesh_h = CreateCube(-1,100)
cubeentity_h = CreateEntity(-1,MeshID(cubemesh_h),#PB_Material_None,0,0,0)
MoveCamera(sys::maincamera_h,0,0,500)
Repeat
sys::preDate()
RotateEntity(cubeentity_h,0,0.5,0,#PB_Relative)
RenderWorld()
DisplayTransparentSprite(sys::c64_desktopsprite,0,0)
sys::textout(80,80,"Press Escape to quit.",sys::c64color(sys::#c64_Color_LightBlue))
sys::textout(80,100,"Ready.",sys::c64color(sys::#c64_Color_LightBlue))
sys::textout(80,660,FormatDate("%hh:%ii:%ss", Date()),sys::c64color(sys::#c64_Color_LightBlue))
sys::textout(780,660,"Mem " + Str(MemoryStatus(#PB_System_FreePhysical)/(1024*1024)) + " MByte / " + Str(MemoryStatus(#PB_System_TotalPhysical)/(1024*1024))+" MByte",sys::c64color(sys::#c64_Color_LightBlue))
sys::Update()
FlipBuffers()
Delay(1)
ForEver
;_________________________MAIN PROGRAM END__________________________
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
I might or might not found a bug. I removed a lot of things I belived to be unnecessary. As a result, in the procedure createc64mouse() myunicodecharacter and myunicodecharacter2 had been left undefined, It runs For me (PB 6.12 LTS X64 Windows), EnableExplicit did Not raise an error.
It compiles + runs...
It compiles + runs...
- skinkairewalker
- Enthusiast
- Posts: 782
- Joined: Fri Dec 04, 2015 9:26 pm
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
This is awesome, thank you very much for the code example, I'll test it out right now !!miso wrote: Fri Oct 18, 2024 11:06 pm @skinkairewalker
After casting Bigby's compressing hands on my code, the result looks like a mess. The important part is just three small function though, setfontimport(), readsystemfontdata() and textout(). There are a couple of much better examples on the forum than mine. Works with or without the ogre engine. DirectX was not tested, I only use the default Opengl subsystem.
I didn't want to read this, now I'm too excited...pf shadoko wrote: Fri Oct 18, 2024 6:49 pm look forward to the next version of PB
It should bring a new sprite-based UI (so 3D compatible)
- skinkairewalker
- Enthusiast
- Posts: 782
- Joined: Fri Dec 04, 2015 9:26 pm
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
@miso
I noticed the following issue: when running the code with DPI aware enabled, and the line of code: OpenWindowedScreen with the parameter [ AutoStretch = True ], the 3D screen does not fully occupy the screen... as shown in the screenshot below >
AutoStretch = True + DPI Aware = True https://prnt.sc/Lq9xqM2joymq
What could be causing this? Could it be a bug???
As expected, if I disable DPI awareness, the 3D screen goes back to occupying 100% of the window... The issue is: if I enable AutoStretch = True, I would expect the 3D screen to occupy 100% of the window, but it doesn't! And this seems strange to me!
AutoStretch = False + DPI Aware = False https://prnt.sc/sT6Ee9wzjJYB
I noticed the following issue: when running the code with DPI aware enabled, and the line of code: OpenWindowedScreen with the parameter [ AutoStretch = True ], the 3D screen does not fully occupy the screen... as shown in the screenshot below >
AutoStretch = True + DPI Aware = True https://prnt.sc/Lq9xqM2joymq
What could be causing this? Could it be a bug???
As expected, if I disable DPI awareness, the 3D screen goes back to occupying 100% of the window... The issue is: if I enable AutoStretch = True, I would expect the 3D screen to occupy 100% of the window, but it doesn't! And this seems strange to me!
AutoStretch = False + DPI Aware = False https://prnt.sc/sT6Ee9wzjJYB
Re: Why is using 2D sprites render with 3D objects render in PureBasic so ‘unstable’?
@skinkairewalker
Sorry for the late reply.
Yes, I also met with that. For me, its not so important, I would not want to resize the window of a game.
(normally I use fullscreen borderless window, and I do not resize it)
Sorry for the late reply.
Yes, I also met with that. For me, its not so important, I would not want to resize the window of a game.
(normally I use fullscreen borderless window, and I do not resize it)