Imagegadget3D New Issues... Frustrated!

Advanced game related topics
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Imagegadget3D New Issues... Frustrated!

Post by Rook Zimbabwe »

I am having troubles making a already loaded image work with Imagegadget 3D() the text from the online manual is slightly confusing... do I need to make it a texture???
Creates an Image gadget in the current GadgetList. If #PB_Any is used as '#Gadget3D' parameter, the new gadget number will be returned as 'Result'. The TextureID represents an image and can be obtained with TextureID() from the Texture library. If the TextureID is 0, then no image will be displayed. The gadget dimensions autofit to the image size.
I had alreadyloaded the images to the program with the

Code: Select all

#J= "Data\"

DataSection
  Image1:
  IncludeBinary #J + "BACK0.jpg"
  Image2:
  IncludeBinary #J + "2.jpg"
; etc
EndDataSection
but either I get a grey box in the 3D GUI or I get a program error...

Anyone got a working example of the DUI 3D Imagegadget working? :mrgreen:
Last edited by Rook Zimbabwe on Wed Feb 09, 2011 8:50 pm, edited 1 time in total.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Imagegadget3D issues

Post by Comtois »

Rook Zimbabwe wrote:I am having troubles making a already loaded image work with Imagegadget 3D() the text from the online manual is slightly confusing... do I need to make it a texture???
Yes.
Anyone got a working example of the DUI 3D Imagegadget working?
added 3 lines in the Gadget3D.pb example.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Gadget 3D
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;
  
#CameraSpeed = 10

#MainWindow = 0
#CloseButton = 0
#Image3D = 1 ; <<< NEW

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()

  Add3DArchive("Data/", #PB_3DArchive_FileSystem)
  Add3DArchive("GUI/", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/skybox.zip", #PB_3DArchive_Zip)

    
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()

    SkyBox("desert07.jpg")
    
    CreateCamera(0, 0, 0, 100, 100)  ; Front camera
    CameraLocate(0,0,100,100)
    
    LoadTexture(0, "Geebee2.bmp") ; <<< NEW
    
    OpenWindow3D(#MainWindow, 100, 100, 300, 300, "Hello in 3D !")
		
			ButtonGadget3D(#CloseButton, 10, 260, 120, 25, "Close")
			ImageGadget3D(#Image3D, 10, 60, 200, 200, TextureID(0)) ; <<< NEW
			
  	ShowGUI(128, 1) ; Display the GUI, semi-transparent and display the mouse cursor
    		
    Repeat
      Screen3DEvents()
      
      If ExamineKeyboard()
        Input$ = KeyboardInkey()
      EndIf
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)*#CameraSpeed
        MouseY = -(MouseDeltaY()/10)*#CameraSpeed
        
        InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left), Input$)
      EndIf
      
      ; Handle the GUI 3D events, it's similar to regular GUI events
      ;
      Repeat
      	Event = WindowEvent3D()
      	
      	Select Event
      		Case #PB_Event3D_Gadget
      		  If EventGadget3D() = #CloseButton
      		    CloseWindow3D(#MainWindow)
      		  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/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Imagegadget3D issues

Post by Rook Zimbabwe »

Thank you Comtois... that is great! :mrgreen:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Imagegadget3D issues

Post by Rook Zimbabwe »

Small issue now... have 2 textures and want to change form 1 to the other when spacebar is pressed... according to the CHM this is supposed to work... it isn't.

what did I do wrong?

Code: Select all


; ------------------------------------------------------------
;
;   PureBasic - Gadget 3D
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;
  
#CameraSpeed = 10

#MainWindow = 0
#CloseButton = 0
#Image3D = 1 ; <<< NEW

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()

  Add3DArchive("Data/", #PB_3DArchive_FileSystem)
  Add3DArchive("GUI/", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/skybox.zip", #PB_3DArchive_Zip)

    
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()

    SkyBox("14.jpg")
    
    CreateCamera(0, 0, 0, 100, 100)  ; Front camera
    CameraLocate(0,0,100,100)
    
    LoadTexture(0, "26.bmp") 
    LoadTexture(1,"25.bmp") ; ******** NEW
    
    OpenWindow3D(#MainWindow, 100, 100, 300, 300, "Hello in 3D !")
      
         ButtonGadget3D(#CloseButton, 10, 260, 120, 25, "Close")
         ImageGadget3D(#Image3D, 10, 60, 200, 200, TextureID(0)) ; <<< NEW
         
     ShowGUI(128, 1) ; Display the GUI, semi-transparent and display the mouse cursor
          
    Repeat
      Screen3DEvents()
      
      If ExamineKeyboard()
        Input$ = KeyboardInkey()
      EndIf
      
      If KeyboardReleased(#PB_Key_Space)
        SetGadgetState3D(#Image3D, TextureID(1)) ; *************  This does NOT work!!!
      EndIf
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)*#CameraSpeed
        MouseY = -(MouseDeltaY()/10)*#CameraSpeed
        
        InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left), Input$)
      EndIf
      
      ; Handle the GUI 3D events, it's similar to regular GUI events
      ;
      Repeat
         Event = WindowEvent3D()
         
         Select Event
            Case #PB_Event3D_Gadget
              If EventGadget3D() = #CloseButton
                CloseWindow3D(#MainWindow)
              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
:mrgreen:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Nituvious
Addict
Addict
Posts: 1030
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Imagegadget3D New Issues... Frustrated!

Post by Nituvious »

You're right, according to the help file it's supposed to work exactly like this. I couldn't get it to work no matter what I tried. Debugging says that the change was successful. Could there possibly be some sort of redraw for the Gadget3D library?
▓▓▓▓▓▒▒▒▒▒░░░░░
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Imagegadget3D New Issues... Frustrated!

Post by PMV »

User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Imagegadget3D New Issues... Frustrated!

Post by Rook Zimbabwe »

yep I found that later in the day after my post...

my solution? Draw a new gadget with the same #ID in the same location with the new texture...

Lame code idea but it works! :mrgreen:

considering that this is not really a gadget anyway but a billboard... seems to be OK and since OGRE is OOPish should not cause a memory issue.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Imagegadget3D New Issues... Frustrated!

Post by PMV »

Rook Zimbabwe wrote:and since OGRE is OOPish should not cause a memory issue.
:lol:

oop and memory issues are two separate things
Post Reply