I know this has been asked before but the last post I could find was a number of years ago;
Resizing the viewport with autostretch, and having it reflect the new screen dimensions rather than stretching the contents - The fact we can't do this without workarounds is a bit of a pitfall, especially when your application has loaded a metric tonne of sprites, which loading them all again each time a resize window is called is unacceptable.
My OpenGL is highly rusty, but even when I attempt a workaround by trying to resize it directly with API calls, it's failing..
Can we expect this to be something that can and will be implemented? At risk of sounding petty .. all the others are doing it~
Thanks
ResizeScreen(..)
ResizeScreen(..)
Thanks!
Re: ResizeScreen(..)
Ungetestet!
Faktor Native Auflösung -> neue Auflösung.
-> glScalef(FactorX,FactorY,1)
-> glTranslate(ScreenCenterX * FactorX,ScreenCenterY * FactorY,0)
Faktor Native Auflösung -> neue Auflösung.
-> glScalef(FactorX,FactorY,1)
-> glTranslate(ScreenCenterX * FactorX,ScreenCenterY * FactorY,0)
Re: ResizeScreen(..)
What would this be applied to? The screen? A snippet would be greatMijikai wrote:Ungetestet!
Faktor Native Auflösung -> neue Auflösung.
-> glScalef(FactorX,FactorY,1)
-> glTranslate(ScreenCenterX * FactorX,ScreenCenterY * FactorY,0)
Was wäre das für? Der Bildschirm? Eine Probe wäre toll
Thanks!
Re: ResizeScreen(..)
Just did a Test here is the Code
Code: Select all
EnableExplicit
;TestWindow ScreenResize OpenGL
;PureBasic 5.62 (x64)
;by mijikai
Procedure.i TestSprite(Width.i,Height.i,Color.i = $FF00FF)
Protected Sprite.i
Sprite = CreateSprite(#PB_Any,Width,Height)
If IsSprite(Sprite)
If StartDrawing(SpriteOutput(Sprite))
Box(0,0,Width,Height,Color)
StopDrawing()
ProcedureReturn Sprite
EndIf
FreeSprite(Sprite)
EndIf
EndProcedure
Procedure.i TestWindow(Width.i,Height.i,Title.s = #Null$)
Protected Window.i
Protected WindowHandle.i
Protected WindowFlags.i
Protected WindowMsg.i
Protected Sprite.i
Protected FactorX.f
Protected FactorY.f
Protected OffsetX.f
Protected OffsetY.f
WindowFlags|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget
WindowFlags|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget
If InitSprite()
Window = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,WindowFlags)
If Window
WindowHandle = WindowID(Window)
WindowBounds(window,Width,Height,#PB_Ignore,#PB_Ignore)
If OpenWindowedScreen(WindowHandle,#Null,#Null,Width,Height,#True,#Null,#Null)
FactorX = 1
FactorY = 1
Sprite = TestSprite(32,32)
glLoadIdentity_()
glOrtho_(0,Width,Height,0,0,1)
glMatrixMode_(#GL_MODELVIEW)
Repeat
Repeat
WindowMsg = WindowEvent()
Select WindowMsg
Case #PB_Event_SizeWindow
FactorX = Width / WindowWidth(Window)
FactorY = Height / WindowHeight(Window)
OffsetX = (WindowWidth(Window) - Width) / 2
OffsetY = (WindowHeight(Window) - Height) / 2
Case #PB_Event_CloseWindow
Break 2
EndSelect
Until WindowMsg = #Null
ClearScreen(#Null)
glLoadIdentity_()
glScalef_(FactorX,FactorY,0)
glTranslatef_(OffsetX,OffsetY,1)
DisplaySprite(Sprite,150,80)
FlipBuffers()
ForEver
EndIf
CloseWindow(Window)
EndIf
EndIf
EndProcedure
TestWindow(320,200,"TestWindow")
End
Re: ResizeScreen(..)
Mijikai wrote:Just did a Test here is the Code
Code: Select all
EnableExplicit ;TestWindow ScreenResize OpenGL ;PureBasic 5.62 (x64) ;by mijikai Procedure.i TestSprite(Width.i,Height.i,Color.i = $FF00FF) Protected Sprite.i Sprite = CreateSprite(#PB_Any,Width,Height) If IsSprite(Sprite) If StartDrawing(SpriteOutput(Sprite)) Box(0,0,Width,Height,Color) StopDrawing() ProcedureReturn Sprite EndIf FreeSprite(Sprite) EndIf EndProcedure Procedure.i TestWindow(Width.i,Height.i,Title.s = #Null$) Protected Window.i Protected WindowHandle.i Protected WindowFlags.i Protected WindowMsg.i Protected Sprite.i Protected FactorX.f Protected FactorY.f Protected OffsetX.f Protected OffsetY.f WindowFlags|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget WindowFlags|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget If InitSprite() Window = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,WindowFlags) If Window WindowHandle = WindowID(Window) WindowBounds(window,Width,Height,#PB_Ignore,#PB_Ignore) If OpenWindowedScreen(WindowHandle,#Null,#Null,Width,Height,#True,#Null,#Null) FactorX = 1 FactorY = 1 Sprite = TestSprite(32,32) glLoadIdentity_() glOrtho_(0,Width,Height,0,0,1) glMatrixMode_(#GL_MODELVIEW) Repeat Repeat WindowMsg = WindowEvent() Select WindowMsg Case #PB_Event_SizeWindow FactorX = Width / WindowWidth(Window) FactorY = Height / WindowHeight(Window) OffsetX = (WindowWidth(Window) - Width) / 2 OffsetY = (WindowHeight(Window) - Height) / 2 Case #PB_Event_CloseWindow Break 2 EndSelect Until WindowMsg = #Null ClearScreen(#Null) glLoadIdentity_() glScalef_(FactorX,FactorY,0) glTranslatef_(OffsetX,OffsetY,1) DisplaySprite(Sprite,150,80) FlipBuffers() ForEver EndIf CloseWindow(Window) EndIf EndIf EndProcedure TestWindow(320,200,"TestWindow") End
Incredible Thank you so much. Working perfectly on Linux x64 (Though fires a " [WARNING] GLib-GObject (CRITICAL): g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed", but we'll just ignore that haha)
Thanks!
Re: ResizeScreen(..)
+1Env wrote: Can we expect this to be something that can and will be implemented? At risk of sounding petty .. all the others are doing it~
Thanks
I would also love to have more 2D functions (like shader support, particles, layers, animation, screen in screen, timing...).
I personally think Audio (dsp, fft, synthesis...) and 2D are niche areas that could really push the popularity of PureBasic.
Its also nice to have modern web functions but thats expected nowdays and nothing that stands out.
Re: ResizeScreen(..)
Just to confirm the solution above does not work with Engine3D - though there is an outstanding bug which was reported at least 4 years ago where the screen doesn't auto-stretch.
The latest bug post I found was here: viewtopic.php?f=4&t=66508 but it affects Linux (and I assume Mac) too
A huge shame because I'm using Engine3D to handle sprites using Eddy & Papala's work
The latest bug post I found was here: viewtopic.php?f=4&t=66508 but it affects Linux (and I assume Mac) too
A huge shame because I'm using Engine3D to handle sprites using Eddy & Papala's work
Thanks!