How to disable the GUI on a second camera

Everything related to 3D programming
gavindi
User
User
Posts: 41
Joined: Mon Jan 21, 2013 12:57 am

How to disable the GUI on a second camera

Post by gavindi »

Hi all,

I'm using a 3D GUI in my little project that I only want to be displayed on Camera 0. My second camera (1) shouldn't display the GUI at all as it's used as a top-down map view of the playfield.
Currently, I have:

Code: Select all

ShowGUI(32, #False,0,#True)
ShowGUI(255, #False,1,#False)
My understanding is that the third parameter that state camera 1 will be disabled by #False in the fourth parameter, but it isn't working for me.

My work-around is to use:

Code: Select all

ShowGUI(32, #False,0,#True)
ShowGUI(0, #False,1,#False)
which uses the first parameter to set full transparency of the GUI.
I would rather disable the GUI completely on the second camera as I expect that this would save me a few rendering cycles.

Any ideas anyone? Please?

Cheers,
G.
Using Ubuntu 14.04 x64, Intel4700HD Graphics, 16GB RAM
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: How to disable the GUI on a second camera

Post by Comtois »

It works fine here.

Just added a camera in Window3D.pb example :

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Window 3D
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

#MainWindow = 0
#CloseButton = 0

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  
  Add3DArchive("Data/GUI", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Packs/desert.zip", #PB_3DArchive_Zip)
  
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    SkyBox("desert07.jpg")
    
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0,0,100,100, #PB_Absolute)
    CreateCamera(1, 0, 50, 50, 50) 
    MoveCamera(1,0,100,100, #PB_Absolute)    
    
    OpenWindow3D(#MainWindow, 100, 100, 300, 100, "Hello in 3D !")
    
    ButtonGadget3D(#CloseButton, 150, 40, 120, 25, "Quit")
    
    ShowGUI(128, 1, 1, #False) ; Display the GUI, semi-transparent and display the mouse cursor
    
    Repeat
      Screen3DEvents()
      
      If ExamineKeyboard() And ExamineMouse()
        Input$ = KeyboardInkey()
        
        InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left), Input$, 0)
      EndIf
      
      ; Handle the GUI 3D events, it's similar to regular GUI events
      ;
      Repeat
        Event = WindowEvent3D()
        
        Select Event
          Case #PB_Event3D_CloseWindow
            If EventWindow3D() = #MainWindow
              CloseWindow3D(#MainWindow)
            EndIf
            
          Case #PB_Event3D_Gadget
            If EventGadget3D() = #CloseButton
              Quit = 1
            EndIf
            
        EndSelect
      Until Event = 0
      
      RenderWorld()
      
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
Please correct my english
http://purebasic.developpez.com/
gavindi
User
User
Posts: 41
Joined: Mon Jan 21, 2013 12:57 am

Re: How to disable the GUI on a second camera

Post by gavindi »

Hey,

That's really odd. Your example works as expected and it's a very simple thing to code. SO simple, I must be overlooking something but for the life of me, I can't see why it isn't working in my code. I tried mangling your example to break it and I can't so what the hell am I overlooking?!

Here's my two procedures, the first is camera set-up and second for the GUI:

Code: Select all

Procedure PositionGameCamera()
; Create & Position Camera
; ------------------------------------------------------------
	CreateCamera(0,0,0,100,100)
	MoveCamera(0,5,5,20,#PB_Absolute)

	CameraLookAt(0,5,0,5)
	CameraBackColor(0,$c08000)
	
	CreateCamera(1,45,83,10,15)
	MoveCamera(1,5,14,5,#PB_Absolute)
	RotateCamera(1,-90,0,0)

	CreateLight(0,$ffffff,5,5,11)
EndProcedure
and

Code: Select all

Procedure InitInGameGUI(*ptr.MediaStruct, Array Hero.Player(1))
	OpenWindow3D(0, 10, 10, 200, 100, "Player 1",#PB_Window3D_Borderless)
	ProgressBarGadget3D(0,10,35,180,20,0,7)
	TextGadget3D(4,10,5,70,30,"Health")
	
	OpenWindow3D(1, *ptr\ScreenWidth-210, 10, 200, 100, "Player 2",#PB_Window3D_Borderless)
	ProgressBarGadget3D(1,10,35,180,20,0,7)
	TextGadget3D(5,10,5,70,30,"Health")
	
	OpenWindow3D(2, 10, *ptr\ScreenHeight-110, 200, 100, "Player 3",#PB_Window3D_Borderless)
	ProgressBarGadget3D(2,10,35,180,20,0,7)
	TextGadget3D(6,10,5,70,30,"Health")
	
	OpenWindow3D(3, *ptr\ScreenWidth-210, *ptr\ScreenHeight-110, 200, 100, "Player 4",#PB_Window3D_Borderless)
	ProgressBarGadget3D(3,10,35,180,20,0,7)
	TextGadget3D(7,10,5,70,30,"Health")
	
	ButtonGadget3D(20, 90, 70, 100, 25, "Quit")
	
	;ShowGUI(192, #False,0,#True)
													; Need to find out how to properly disable the GUI
													; on Camera 1. Currently using the transparency value
													; to effectively hide the GUI from this camera
	ShowGUI(192, #False,1,#False)
EndProcedure
Using Ubuntu 14.04 x64, Intel4700HD Graphics, 16GB RAM
gavindi
User
User
Posts: 41
Joined: Mon Jan 21, 2013 12:57 am

Re: How to disable the GUI on a second camera

Post by gavindi »

Hi Again,

I thought I'd show how I also mangled your example since it's also having a strange side-affect now. I'm trying to tell it to show the mouse pointer on camera 0 only and now there is no mouse at all on either camera:

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Window 3D
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

#MainWindow = 0
#CloseButton = 0

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  
  Add3DArchive("Data/GUI", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Packs/desert.zip", #PB_3DArchive_Zip)
  
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    SkyBox("desert07.jpg")
    
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0,0,20,100, #PB_Absolute)
    CameraLookAt(0,0,0,0)
    CreateCamera(1, 0, 50, 50, 50) 
    MoveCamera(1,0,100,20, #PB_Absolute)    
    
    OpenWindow3D(#MainWindow, 100, 100, 300, 100, "Hello in 3D !",#PB_Window3D_Borderless)
    ProgressBarGadget3D(0,10,35,180,20,0,7)
    TextGadget3D(4,10,5,70,30,"Health")
    
    ButtonGadget3D(10, 150, 60, 120, 25, "Quit")
    
    OpenWindow3D(#MainWindow+1, 200, 200, 300, 100, "Hello in 3D !",#PB_Window3D_Borderless)
    ProgressBarGadget3D(1,10,35,180,20,0,7)
    TextGadget3D(5,10,5,70,30,"Health")
    
    OpenWindow3D(#MainWindow+2, 300, 300, 300, 100, "Hello in 3D !",#PB_Window3D_Borderless)
    ProgressBarGadget3D(2,10,35,180,20,0,7)
    TextGadget3D(6,10,5,70,30,"Health")
    
    OpenWindow3D(#MainWindow+3, 400, 400, 300, 100, "Hello in 3D !",#PB_Window3D_Borderless)
    ProgressBarGadget3D(3,10,35,180,20,0,7)
    TextGadget3D(7,10,5,70,30,"Health")
    
    ShowGUI(128, #True, 0, #True)
    ShowGUI(128, #False, 1, #False) ; Display the GUI, semi-transparent and display the mouse cursor
    
    Repeat
      Screen3DEvents()
      
      If ExamineKeyboard() And ExamineMouse()
        Input$ = KeyboardInkey()
        
        InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left), Input$, 0)
      EndIf
      
      ; Handle the GUI 3D events, it's similar to regular GUI events
      ;
      Repeat
        Event = WindowEvent3D()
        
        Select Event
          Case #PB_Event3D_CloseWindow
            If EventWindow3D() = #MainWindow
              CloseWindow3D(#MainWindow)
            EndIf
            
          Case #PB_Event3D_Gadget
            If EventGadget3D() = #CloseButton
              Quit = 1
            EndIf
            
        EndSelect
      Until Event = 0
      
      RenderWorld()
      
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
Using Ubuntu 14.04 x64, Intel4700HD Graphics, 16GB RAM
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: How to disable the GUI on a second camera

Post by Comtois »

You have one mouse cursor For a screen, set the parameter 'ShowMouseCursor' With the same value

Code: Select all

    ShowGUI(128, #True, 0, #True)
    ShowGUI(128, #True, 1, #False)
Please correct my english
http://purebasic.developpez.com/
Post Reply