Change Resolution

BlitzPlus Forums/BlitzPlus Beginners Area/Change Resolution

blicek(Posted 2014) [#1]
Hello

I have a problem with changing the resolution in BB, IE.: I have a project I run it through for example. I want key pressure resolution has changed, for example: from 1280 x 1024 to 800 x 600.
As possible using, for example:

Goto or
Gosub?

advance for your reply


doebi(Posted 2014) [#2]
Hi,

First use code beneath, than change it for your purpose.
Call the function in your main program :

If SetDisplay("Doebi Tile Maker",512,384,16,False) = 0 End
sw=GraphicsWidth() : sh=GraphicsHeight() : sd=GraphicsDepth()

; Set Graphics Mode
Global ScreenWidth = sw ;'1024
Global ScreenHeight = sh ;'768
Graphics ScreenWidth, ScreenHeight , sd , 2 ; 256 , 2

Grtz Doebi



PS : Here's the function :

; set program display graphics
Function SetDisplay(title$="BlitzPlus Example",w=640,h=480,d=16,full=0,driver=1)
Local xo=160
If FileType("logo.jpg")=0 Then xo=0
win = CreateWindow(title$,307,322,xo+164,182,Desktop(),1)
; Graphics Mode
Label1 = CreateLabel("Graphics Mode",xo+36,8,74,14,win,0)
Combo1 = CreateComboBox(xo+8,26,138,100,win,0)
AddGadgetItem Combo1,"Choose Resolution..."
For g=1 To CountGfxModes()
mode$=Str$(GfxModeWidth(g))+" x "+Str$(GfxModeHeight(g))+" "+Str$(GfxModeDepth(g))+"Bit"

AddGadgetItem Combo1,mode$
If w=GfxModeWidth(g) And h=GfxModeHeight(g) And d=GfxModeDepth(g)
SelectGadgetItem Combo1,g
EndIf

Next
If SelectedGadgetItem(Combo1)=-1 Then SelectGadgetItem Combo1,0
; Graphics Driver
Label2 = CreateLabel("Graphics Driver",xo+36,52,74,14,win,0)
Combo2 = CreateComboBox(xo+8,70,138,100,win,0)
For g=1 To CountGfxDrivers()
AddGadgetItem Combo2,GfxDriverName$(g)
Next
If driver<1 Then driver=1
If driver>CountGfxDrivers() Then driver=CountGfxDrivers()
SelectGadgetItem Combo2,driver-1
; FullScreen / Windowed
RadioButton1 = CreateButton("FullScreen",xo+4,98,76,20,win,3)
RadioButton2 = CreateButton("Windowed",xo+80,98,70,20,win,3)
SetButtonState RadioButton1,full=True
SetButtonState RadioButton2,full=False
; Start Button
Button = CreateButton("Start",xo+4,120,140,26,win,0)
; Graphic Image
If xo>0
panel = CreatePanel(16,14,128,128,win)
SetPanelImage panel,"logo.jpg"
EndIf

; await user response
Repeat
Select WaitEvent()
Case Event_KeyStroke ; key stroke
If EventData()=27 Exit
If EventData()=13
If SelectedGadgetItem(Combo1)=0
Notify "Please choose a Graphics mode"
Else
startflag=True : Exit
EndIf
EndIf
Case Event_WindowClose ; [x] close window
Exit
Case Event_GadgetAction ; gadget event
If EventSource()=Button
If SelectedGadgetItem(Combo1)=0
Notify "Please choose a graphics mode"
Else
startflag=True : Exit
EndIf
EndIf
End Select
Forever

; read combobox selections
g=SelectedGadgetItem(Combo1)
GFXDriver=SelectedGadgetItem(Combo2)+1
If g>0
w=GfxModeWidth(g) : h=GfxModeHeight(g) : d=GfxModeDepth(g)
full=ButtonState(radiobutton1)
EndIf

; close GUI and created graphics display
FreeGadget win
If full=0 Then full=2 ; windowed
If startflag=True
AppTitle title$
SetGfxDriver GFXDriver
Graphics w,h,d,full
SetBuffer BackBuffer()
EndIf
Return startflag
End Function


Hotshot2005(Posted 2014) [#3]
try oranise the code and dont forget put [code] with your code [/ code(when together) ]

hope that help!