BlitzMax+MaxGUI+Blitz3D.SDK

BlitzMax Forums/BlitzMax Programming/BlitzMax+MaxGUI+Blitz3D.SDK

Leafus(Posted 2009) [#1]
Having all three working together.


Shagwana(Posted 2009) [#2]
is that a question or statement?


Leafus(Posted 2009) [#3]
[REQUEST] Hi, pretty new to this. I've got all three and have managed to get a Blitz3D 3D environment rendering to a 'main' GUI windows child canvas.

How to do this is given in the 3D helpfiles' examples section.

...BUT...

Although I have managed to read scancodes via the events queue, no mouse operations are reported, neither can KeyDown, MouseDown etc. be used as they return nothing.

is anyone experiencing same difficulties or are able to help me with this please?


SebHoll(Posted 2009) [#4]
Add EnablePolledInput() to the top of your code to get the standard Max2D key/mouse commands to work as expected.


skidracer(Posted 2009) [#5]
Not quite Seb, enablepolledinput may fix keyboard but for mouse handling a blitz3dsdk event handler is required:

' panel3d.bmx

' demonstrates running a Blitz3D runtime inside a MaxGUI application

Import maxgui.drivers

Import blitz3d.blitz3dsdk

Strict

enablepolledinput

Local b3dapp:TBlitz3DApplet

b3dapp=New TBlitz3DApplet.Create("Blitz3DSDK (C)2007 Blitz Research Ltd.")

While True
	WaitEvent
	b3dapp.OnEvent(CurrentEvent)
Wend

End

Const MENU_NEW=101
Const MENU_OPEN=102
Const MENU_SAVE=103
Const MENU_CLOSE=104
Const MENU_EXIT=105

Const MENU_CUT=106
Const MENU_COPY=107
Const MENU_PASTE=108

Const MENU_ABOUT=109

Type TBlitz3DApplet

	Field camera,light
	Field cube,cube2
	Field lost=True
		
	Function BBEventHandler(hwnd,msg,wp,lp) "win32"
		bbSystemEmitOSEvent hwnd,msg,wp,lp,Null
		Return -1
	End Function
	
	Method InitWorld(hwnd,maxwidth,maxheight)
		bbSetBlitz3DHWND(hwnd)
		bbSetBlitz3DEventCallback Int Byte Ptr BBEventHandler
		bbBeginBlitz3D 
		bbGraphics3D maxwidth,maxheight,0,2
		Local brush=bbCreateBrush(255,100,50)
		cube=bbCreateCube()
		bbPaintEntity cube,brush
		bbFitMesh cube,-20,-20,-2,40,40,4	
		cube2=bbCreateCube()
		bbPaintEntity cube2,brush
		bbFitMesh cube2,-2,-20,-20,4,40,40
		light=bbCreateLight()
		camera=bbCreateCamera()
		bbCameraClsColor camera,255,100,80
		bbPositionEntity camera,0,0,-64
		lost=False
	End Method

	Method DrawWorld(w,h)
		If lost Return
		bbCameraViewport camera,0,0,w,h		
		bbTurnEntity cube,0,1,0
		bbTurnEntity cube2,0,1,0
		bbRenderWorld
		bbFlip 
	End Method

	Field	window:TGadget
	Field	canvas:TGadget
	Field	timer:TTimer
	Field	image:TImage

	Field filemenu:TGadget
	Field editmenu:TGadget
	Field helpmenu:TGadget

	Method Create:TBlitz3DApplet(name$)
		Local	w,h,hwnd
		
		image=LoadImage("fltkwindow.png")
		window=CreateWindow(name,20,20,512,512)

		filemenu=CreateMenu("&File",0,WindowMenu(window))
		CreateMenu"&New",MENU_NEW,filemenu,KEY_N,MODIFIER_COMMAND
		CreateMenu"&Open",MENU_OPEN,filemenu,KEY_O,MODIFIER_COMMAND
		CreateMenu"&Close",MENU_CLOSE,filemenu,KEY_W,MODIFIER_COMMAND
		CreateMenu"",0,filemenu
		CreateMenu"&Save",MENU_SAVE,filemenu,KEY_S,MODIFIER_COMMAND
		CreateMenu"",0,filemenu
		CreateMenu"E&xit",MENU_EXIT,filemenu,KEY_F4,MODIFIER_COMMAND
		
		editmenu=CreateMenu("&Edit",0,WindowMenu(window))
		CreateMenu "Cu&t",MENU_CUT,editmenu,KEY_X,MODIFIER_COMMAND
		CreateMenu "&Copy",MENU_COPY,editmenu,KEY_C,MODIFIER_COMMAND
		CreateMenu "&Paste",MENU_PASTE,editmenu,KEY_V,MODIFIER_COMMAND
		
		helpmenu=CreateMenu("&Help",0,WindowMenu(window))
		CreateMenu "&About",MENU_ABOUT,helpmenu
		
		UpdateWindowMenu window
	
		w=ClientWidth(window)
		h=ClientHeight(window)
		canvas=CreatePanel(0,0,w,h,window,PANEL_ACTIVE)
		canvas.SetLayout 1,1,1,1

		w=ClientWidth(Desktop())
		h=ClientHeight(Desktop())
		hwnd=QueryGadget(canvas,QUERY_HWND)
		InitWorld(hwnd,w,h)
		
		timer=CreateTimer(30)
		Return Self		
	End Method
	
	Field rendertime=MilliSecs()
	
	Method OnEvent:Object(Event:TEvent)
		If event.id<>EVENT_TIMERTICK
			DebugLog CurrentEvent.ToString()
		EndIf
		
		Select event.id
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_TIMERTICK
			If (MilliSecs()-rendertime<10) Return
			DrawWorld ClientWidth(canvas),ClientHeight(canvas)
			rendertime=MilliSecs()
		Case EVENT_MENUACTION
			Select EventData()
				Case MENU_EXIT
					End
				Case MENU_ABOUT
					Notify "Incrediabler~n(C)2005 Incredible Software"
			End Select
		End Select
	End Method

	
End Type




Leafus(Posted 2013) [#6]
sorry for not thanking you guys A LOT sooner! Must have seemed rude, much appreciated, thanks.


Leafus(Posted 2013) [#7]
I gave up you see but have decided to give it another go.

Just did a search for EnablePolledInput and found Zeke said that the key polling is KeyDown and KeyHit, his example works. I gave up as despite Mouse working with given demo the BlitzMax GetChar() wouldn't, nor would BBGetKey(), these were the commands I wished to get working as I wanted to make a modeller app and wanted ASCII codes to simplify naming shapes etc.

This is still the 1st app I intend to write but will have to adapt the naming system to use scancodes instead, or maybe an onscreen keyboard.

I'll make anything I achieve freely available on here for others to cannibalise as they please when/if I have anything worth posting.

Hope this helps :o)


skidracer(Posted 2013) [#8]
Could you be more specific / post example source.

If you use a MaxGUI TextGadget with Blitz3DSDK is it borked?

After 3 years are you using same computer?

Where do you want to be in 30 years?


Captain Wicker (crazy hillbilly)(Posted 2013) [#9]
After 3 years are you using same computer?

that's nothing compared to my second hand Dell laptop from over 8 years ago. Max resolution = 1024x768. CPU = 1.4GHz. Works like new (having replaced several broken components).


Russell(Posted 2013) [#10]
My friend's mother does freelance record keeping for various doctor's offices from home. She still uses a Commodore 64 with an Okidata printer! Works for her (and she's used this same setup for over 25 years), so it doesn't matter how old your computer is as long as it still does what you want/need it to do.

Russell