B3D style scaling window

BlitzMax Forums/BlitzMax Programming/B3D style scaling window

QuickSilva(Posted 2008) [#1]
Is there a way to create a window in BMax that behaves in the same way that a scaled one would in B3D using the following command,

Graphics 640,480,32,3

Ideally, I want something that automatically scales the content of the window when resized.

Thanks for any help,

Jason.


ImaginaryHuman(Posted 2008) [#2]
If you use MaxGUI you can do it pretty easily - as you resize the window the attached canvas resizes also and the graphics are automatically scaled. Without MaxGUI is somewhat more difficult.


QuickSilva(Posted 2008) [#3]
I`ve tried with MaxGui but the canvas stays the same size when I adjust the window. Do I need to resize the canvas myself in code?

Please could you provide a simple example? Thanks.

Jason.


Brucey(Posted 2008) [#4]
as you resize the window the attached canvas resizes also and the graphics are automatically scaled.

I wouldn't have thought so.

On the Size event, you need to reset the viewport to the new dimensions. But this won't scale anything for you. You would need to calculate the 1:1 scale of the original dimensions to whatever was current, and then maybe call SetScale. (although SetScale isn't a true scaling function).


jsp(Posted 2008) [#5]
I`ve tried with MaxGui but the canvas stays the same size when I adjust the window. Do I need to resize the canvas myself in code?



The canvas can be resized by MaxGui automatically -> SetGadgetLayout
Your graphics need to be scaled by you, check out the Redraw() function



Edit: Removed the background window


Rone(Posted 2008) [#6]
Instead of using maxGui, you can also change
Local style = WS_VISIBLE | WS_CAPTION | WS_SYSMENU
to
Local style = WS_OVERLAPPEDWINDOW |WS_VISIBLE 
in "d3d7graphics.bmx".
Same window styles must be used in "bbGLGraphicsCreateGraphics" in glgraphics.win32.c


kfprimm(Posted 2008) [#7]
?Win32
Local style=GetWindowLongA(GetActiveWindow(),GWL_STYLE)
SetWindowLongA GetActiveWindow(),GWL_STYLE,style|WS_SIZEBOX
?

Just insert that after you call Graphics. After that, you will need to reset the projection matrix each frame in case the user resizes the window.


kfprimm(Posted 2008) [#8]

That will allow the OpenGL to emulate Blitz3D's scalable window. All you have to do is copy and paste it into the bottom of you source file. I attempted to get the D3D7 driver to work but couldn't.


QuickSilva(Posted 2008) [#9]
Thanks everyone, problem solved.

Jason.