closing then reopening screen with mouse?

Linux specific forum
GBeebe
Enthusiast
Enthusiast
Posts: 263
Joined: Sat Oct 09, 2004 6:52 pm
Location: Franklin, PA - USA
Contact:

closing then reopening screen with mouse?

Post by GBeebe »

I'm having a problem closing a screen and then recreating it while still having mouse support. I was getting this error when recreating the screen:
The debugged executable quit unexpectedly
but then I added ReleaseMouse(1) before closing the screen and all was fine except now only the first screen responded to the mouse (MouseX() MouseY() and MouseButton(1) always return zero). The keyboard continues to work. If I add ReleaseMouse(0) after the screen has been recreated, I get the same error again.

I'm using opengl subsystem, PB4.3, Latest Ubuntu.
GBeebe
Enthusiast
Enthusiast
Posts: 263
Joined: Sat Oct 09, 2004 6:52 pm
Location: Franklin, PA - USA
Contact:

Post by GBeebe »

This problem only occurs with the opengl subsystem

Code: Select all


Global Quit = 0

#SCREENWIDTH = 640
#SCREENHEIGHT = 480

InitSprite()
InitKeyboard()
InitMouse()
InitSprite3D()

Global screen

FullScreen = 0
If FullScreen 
    screen = OpenScreen(#SCREENWIDTH, #SCREENHEIGHT, 32, "Game")
Else
     win = OpenWindow(#PB_Any,0,0, #SCREENWIDTH, #SCREENHEIGHT, "Game",#PB_Window_ScreenCentered | #PB_Window_SizeGadget)
    screen = OpenWindowedScreen(WindowID(win),0,0,#SCREENWIDTH,#SCREENHEIGHT,0,0,0)
EndIf   
If screen

cursor = LoadSprite(#PB_Any, "cursor.bmp")
cursor_texture = LoadSprite(#PB_Any, "cursor.bmp", #PB_Sprite_Texture)
cursor = CreateSprite3d(#PB_Any, cursor_texture)

Repeat
    ExamineMouse()
    ExamineKeyboard()
 
    ClearScreen(0)
                  
                If  KeyboardPushed(#PB_Key_Escape)
                    Quit = 1    ;exits the loop
                EndIf
                
                If KeyboardReleased(#PB_Key_A)
                    
                    ReleaseMouse(1) ;release access of the mouse
                    CloseScreen()   ;close the screen
                    If IsWindow(win) : CloseWindow(win) : EndIf ; Close the containing window (if not fullscreen) - I figure I might have to do this.
                    
                    Delay(1000)
                    
                    If FullScreen 
                        screen = OpenScreen(#SCREENWIDTH, #SCREENHEIGHT, 32, "Game")
                    Else
                        win = OpenWindow(#PB_Any,0,0, #SCREENWIDTH, #SCREENHEIGHT, "Game",#PB_Window_ScreenCentered | #PB_Window_SizeGadget)
                        screen = OpenWindowedScreen(WindowID(win),0,0,#SCREENWIDTH,#SCREENHEIGHT,0,0,0)
                    EndIf   
                    If screen
                        ;reload graphics
                        cursor = LoadSprite(#PB_Any, "cursor.bmp")
                        cursor_texture = LoadSprite(#PB_Any, "cursor.bmp", #PB_Sprite_Texture)
                        cursor = CreateSprite3d(#PB_Any, cursor_texture)                        
                        ;try to capture mouse again
                        ReleaseMouse(0)
                    Else
                        End
                    EndIf
                    
                EndIf
                
                
        Start3D()
            DisplaySprite3D(cursor, MouseX(), MouseY())
        Stop3D()   
    
        ;DisplaySprite(cursor, MouseX(), MouseY())
    
    FlipBuffers()
    Delay(10)
Until Quit = 1



CloseScreen()
EndIf   
This code gives me that error. Comment out ReleaseMouse(0) around line 57 and there's no error, but The mouse doesn't work.
Post Reply