QB64-Phoenix-Edition / QB64pe

The QB64 Phoenix Edition Repository
https://qb64phoenix.com
Other
131 stars 26 forks source link

VIEW and WINDOW do not work together. #545

Open oitofelix opened 1 month ago

oitofelix commented 1 month ago

Describe the bug Drawing statements don't work properly when both VIEW and WINDOW are active.

To Reproduce Run the folowing program.

SCREEN 7: _FULLSCREEN

WINDOW (-1, 1)-(1, -1)
WXMin = -.5: WYMin = -.5
WXMax = .5: WYMax = .5
VXMin = PMAP(WXMin, 0): VYMin = PMAP(WYMin, 1)
VXMax = PMAP(WXMax, 0): VYMax = PMAP(WYMax, 1)

PRINT "No WINDOW nor VIEW active."
PRINT "This work as expected."
VIEW SCREEN(VXMin, VYMin)-(VXMax, VYMax), , 4
VIEW
WINDOW
LINE (VXMin, VYMin)-(VXMax, VYMax)
SLEEP

CLS
PRINT "Only WINDOW active."
PRINT "This work as expected."
WINDOW (-1, 1)-(1, -1)
VIEW SCREEN(VXMin, VYMin)-(VXMax, VYMax), , 4
VIEW
LINE (WXMin, WYMin)-(WXMax, WYMax)
SLEEP

CLS 0
PRINT "Only VIEW active."
PRINT "This work as expected."
WINDOW
VIEW SCREEN(VXMin, VYMin)-(VXMax, VYMax), , 4
LINE (VXMin, VYMin)-(VXMax, VYMax)
SLEEP

CLS 0
PRINT "Both WINDOW and VIEW active."
PRINT "Bug!  This does not work as expected."
WINDOW (-1, 1)-(1, -1)
VIEW SCREEN(VXMin, VYMin)-(VXMax, VYMax), , 4
LINE (WXMin, WYMin)-(WXMax, WYMax)

Expected behavior The drawing behavior must be the same for equivalent drawing statements, regardless of WINDOW and VIEW effects.

Screenshots image image image image

Desktop (please complete the following information):

oitofelix commented 1 month ago

Just want to share that to work around this bug, I use PMAP to get the VIEWport coordinates from the WINDOW coordinates for the drawing at hand, then reset the WINDOW coordinates (as to let only VIEW active), then do the drawing using those physical coordinates obtained in the aforementioned step, and then restore the previous WINDOW coordinates.