Inconsistant Openwindow()

Just starting out? Need help? Post your questions and find answers here.
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Inconsistant Openwindow()

Post by ppnl »

I'm not sure if this is a coding problem, editor problem or a bug.

I was experimenting with openwindow and openwindowedscreen trying to understand the system. I was getting some inconsistent results that I didn't understand so I went back to some previous code to look at what I had done before. It ran different than it had before.

I had opened a 1500 by 1500 window and then opened a 1500 by 1500 screen on it like this:

Code: Select all

 InitSprite()
InitKeyboard()
#FLAGS = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#WINDOW_MAIN, 0, 0, ScrW, ScrH, "Windowed Screen", #FLAGS)
OpenWindowedScreen(WindowID(#WINDOW_MAIN), 0, 0, ScrW, ScrH, 0, 0, 0)
The problem is it opened the window at the wrong resolution and it had not done this before. My desktop resolution is 3840 by 2160 and the opened window would not even fit on my desktop.

I copy and pasted the entire program into a new editor tab an ran it from there. It worked perfectly. What is this and how can it happen? The full code is:

Code: Select all

#WINDOW_MAIN = 1
#IMAGE_MAIN = 1
Global ScrW.l = 1500
Global ScrH.l = 1500
Global ScrD.l = 32
Global Quit.b = #False
Global Dim life.i(1, 100, 100)
Global flag.i = 0

Procedure.i invrt(x.i)
  If x > 0
    ProcedureReturn 0
  Else
    ProcedureReturn 1
  EndIf   
EndProcedure     
    
    
    
    



For x = 0 To 99
  For y = 0 To 99
    life(flag, x, y) = Random(1,0)
  Next y
Next x




InitSprite()
InitKeyboard()
#FLAGS = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#WINDOW_MAIN, 0, 0, ScrW, ScrH, "Windowed Screen", #FLAGS)
OpenWindowedScreen(WindowID(#WINDOW_MAIN), 0, 0, ScrW, ScrH, 0, 0, 0)



If CreateImage(#IMAGE_MAIN, 15, 15)
  If StartDrawing(ImageOutput(#IMAGE_MAIN))
    Box(0, 0, 15, 15, RGB(0, 0, 0))
    StopDrawing()
  EndIf
EndIf

SetFrameRate(5)
Repeat
  Event.l = WindowEvent()
  ClearScreen(RGB(225, 225, 225))
  StartDrawing(ScreenOutput())
  
  For x = 0 To 99
    For y = 0 To 99
      If life(flag, x, y) = 1
        DrawImage(ImageID(#IMAGE_MAIN), 15*x, 15*y)
      EndIf
    Next y 
  Next x
  StopDrawing()
  FlipBuffers()
  ExamineKeyboard()
  If KeyboardReleased(#PB_Key_Escape)
    Quit = #True
  EndIf
  For x.i = 0 To 99
    For y.i = 0 To 99
      total.i = life(flag, ((x+99)%100), (y+99)%100) + life(flag, x, (y+99)%100) + life(flag, (x + 1)%100, (y+99)%100) + life(flag, (x+99)%100, y) + life(flag, (x+1)%100, y) + life(flag, (x+99)%100, (y+1)%100) + life(flag, x, (y+1)%100) + life(flag, (x+1)%100, (y+1)%100)
      If total = 3
        life(invrt(flag), x, y) = 1
      ElseIf total = 2
        life(invrt(flag), x, y) = life(flag, x, y)
      Else
        life(invrt(flag), x, y) = 0
      EndIf
    Next y
  Next x
  flag = invrt(flag)
  
  
  
      
  
Until Event = #PB_Event_CloseWindow Or Quit = #True
I'm not sure how that will help since I cannot recreate the problem even with copy and pasted code.
User avatar
Caronte3D
Addict
Addict
Posts: 1363
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Inconsistant Openwindow()

Post by Caronte3D »

Maybe you have different compiler options (DPI?), since if you open a new tab editor, the compiler options would be the default ones.
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Re: Inconsistant Openwindow()

Post by ppnl »

Thanks,

I don't know anything about the compiler options but I did open the compiler option drop down. I don't see any thing different. But the program is working correctly now. Does just opening compiler options refresh possibly corrupted settings?

What compiler options could even do this?
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Re: Inconsistant Openwindow()

Post by ppnl »

It just keeps happening. Now the original works fine but I have a copy on my windows clipboard that if I post it to another tab will run with the incorrect resolution. I don't get it. Is the editor bugged?
BarryG
Addict
Addict
Posts: 4196
Joined: Thu Apr 18, 2019 8:17 am

Re: Inconsistant Openwindow()

Post by BarryG »

Is it possible to make a screen recording showing the problem, and posting it to Imgur.com or somewhere?
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Re: Inconsistant Openwindow()

Post by ppnl »

BarryG wrote: Sun Mar 13, 2022 8:24 am Is it possible to make a screen recording showing the problem, and posting it to Imgur.com or somewhere?
I will try to figure out how to do that tomorrow maybe. For now it just gets stranger and stranger but I can reproduce the problem reliably. I have four files open in the IDE. One is a program that I did not write but should be pretty clean and the other three are different experiments with opening screens and windows. I start purebasic fresh and run/kill each program one after the other. The fourth program that I run/kill always runs with the wrong resolution. Once it runs in the wrong resolution it continues to run in the wrong resolution until I restart purebasic.

It does not matter what order I run/kill the programs in. It is the fourth one that I run that is wrong.
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Re: Inconsistant Openwindow()

Post by ppnl »

Ok, screen recording here:

https://www.youtube.com/watch?v=cuo0ToUYCKU

On the first run through I run/kill each tab and on the fourth tab it has the wrong size. On the second run through I do it in a different order and it has the wrong size when I run the first tab. On the last run through I run the first tab four times and it is still correct. I run the second tad twice and it is still correct. I run the third tab once and it is correct. But I run the fourth tab and is is wrong.
tored
User
User
Posts: 88
Joined: Wed Feb 16, 2022 12:47 pm
Location: Sweden

Re: Inconsistant Openwindow()

Post by tored »

ppnl wrote: Sun Mar 13, 2022 8:19 am It just keeps happening. Now the original works fine but I have a copy on my windows clipboard that if I post it to another tab will run with the incorrect resolution. I don't get it. Is the editor bugged?
I had some weird behavior with the editor recently where depending on which tab was focused I got different compiler options. I was writing an application that used threads and the thread safe compiler option was sometimes checked and later unchecked.
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Re: Inconsistant Openwindow()

Post by ppnl »

tored wrote: Sun Mar 13, 2022 9:45 pm
ppnl wrote: Sun Mar 13, 2022 8:19 am It just keeps happening. Now the original works fine but I have a copy on my windows clipboard that if I post it to another tab will run with the incorrect resolution. I don't get it. Is the editor bugged?
I had some weird behavior with the editor recently where depending on which tab was focused I got different compiler options. I was writing an application that used threads and the thread safe compiler option was sometimes checked and later unchecked.
As far as I can tell the compiler options are the same in all of the tabs. And I could get a bad program into the clipboard and past it to another tab and still be bad.

I have had problems with white space characters and corrupted characters causing compiler issues. But the need to run four programs to get the problem suggests that that is not the problem. I thought it might be a compiler bug that generated code that left windows in a strange state. Maybe but I don't know how. I thought it might be a bug in the debugger but I turned it off and no difference.

Or maybe it is a problem with the specific hardware on my computer. I have a 2080 super card and a 65 inch tv as a monitor. I'm running the monitor at 3840x2160. That is higher than the 1920x1080 that windows recommends but has never caused a problem before. If the window was at 1920x1080 and upscaled to the 3840x2160 then that might look like what I'm getting. But why would it and why after running precisely four different tabs and how does it remember which was the fourth tab?

Can anyone try to reproduce the problem? Just past the code I pasted above in four different tabs and then run them one after the other.
BarryG
Addict
Addict
Posts: 4196
Joined: Thu Apr 18, 2019 8:17 am

Re: Inconsistant Openwindow()

Post by BarryG »

ppnl wrote: Mon Mar 14, 2022 6:13 amCan anyone try to reproduce the problem? Just past the code I pasted above in four different tabs and then run them one after the other.
Tried that for you and all 4 windows were the same size, so I can't reproduce it here, sorry.

Using PureBasic 6.00 beta 5 (64-bit) on Windows 10 Pro (64-bit). Desktop size is 1920x1080.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Inconsistant Openwindow()

Post by Paul »

ppnl wrote: Mon Mar 14, 2022 6:13 am Can anyone try to reproduce the problem? Just past the code I pasted above in four different tabs and then run them one after the other.
I have a 2070 Super running at 3840x2160 and when I paste your code into 4 tabs, I can confirm the strange behavior you are seeing.
The first tab displays the window properly and the other 3 display the window huge. When I delete the the first tab then whatever tab I select next displays the window properly and the other tabs display the window huge.

Very strange!!
Image Image
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Re: Inconsistant Openwindow()

Post by ppnl »

Paul wrote: Mon Mar 14, 2022 2:41 pm
ppnl wrote: Mon Mar 14, 2022 6:13 am Can anyone try to reproduce the problem? Just past the code I pasted above in four different tabs and then run them one after the other.
I have a 2070 Super running at 3840x2160 and when I paste your code into 4 tabs, I can confirm the strange behavior you are seeing.
The first tab displays the window properly and the other 3 display the window huge. When I delete the the first tab then whatever tab I select next displays the window properly and the other tabs display the window huge.

Very strange!!
Well I'm glad it's not just me. I guess. Possible causes are 20 series geforce graphics cards and/or 3840x2160 resolution. Would be nice to see if it reproduces on other series of graphics cards.

I just cannot think how the IDE could be getting corrupted to cause this. It makes debugging an adventure if I cannot trust that the IDE is not screwing up.

In any case it is pretty clear that it is not a coding issue.
User avatar
idle
Always Here
Always Here
Posts: 5966
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Inconsistant Openwindow()

Post by idle »

I can't reproduce the problem, it just opens a 1500x1500 window each time. PB 6.0 B4 x64 Win 11 at native 3440x1440

a few possibilities to consider.
What happens if you compile without the debugger?
Does it also do it from the command line?
and what happens if you turn off code history?
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Re: Inconsistant Openwindow()

Post by ppnl »

idle wrote: Wed Mar 16, 2022 11:12 pm I can't reproduce the problem, it just opens a 1500x1500 window each time. PB 6.0 B4 x64 Win 11 at native 3440x1440

a few possibilities to consider.
What happens if you compile without the debugger?
Does it also do it from the command line?
and what happens if you turn off code history?
I tried it with the debugger unchecked in the debugger drop down list. No good. I tried it with the debugger unchecked in the compiler options. No joy. I tried restarting the compiler. No help. I turned off code history. No difference.

Yikes! I compiled the executable and ran it and they all run at the wrong resolution. This is a much more serious problem. I could work around the IDE messing up. But this? I can't use this.

What graphics card are you using?
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Re: Inconsistant Openwindow()

Post by ppnl »

Three other things to note:

1) I'm using purebasic 5.72. I clicked the check for updates button and nothing happened.

2) Windows recommends I set my desktop to 1920x1080. I have my resolution set to 3840x2160. This has never been a problem for me. The window that opens too large looks about like what it would look like if I opened a 1500x1500 window on a 1920x1080 desktop.

3) I have been opening a windowed screen but the problem also happens when I open an ordinary window.
Post Reply