miniB3D extended 0.41

BlitzMax Modules Forums/MiniB3D/miniB3D extended 0.41

@LT, have you copied all files into : 'YourBMaxPath/mod/klepto.mod/' ? If think you're trying to run it from sidesign.minib3d or something like this.

@arctic fox:

Strict

Import klepto.minib3d

SetGraphicsDriver(GLMax2DDriver()) 'Very important on windows


Global GAME_WIDTH=640
Global GAME_HEIGHT=480

' create a centered window with client size GAME_WIDTH,GAME_HEIGHT

Local wx=(ClientWidth(Desktop())-GAME_WIDTH)/2
Local wy=(ClientHeight(Desktop())-GAME_HEIGHT)/2

Local window:TGadget=CreateWindow("My Canvas",wx,wy,GAME_WIDTH,GAME_HEIGHT,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_RESIZABLE)

' create a canvas for our game

Local canvas:TGadget=CreateCanvas(0,0,640,480,window)

' create an update timer
CanvasGraphics3D(Canvas)

Local cam:TCamera=CreateCamera()
PositionEntity cam,0,0,-10

Local light:TLight=CreateLight(1)

Local cube:TMesh=CreateCube()
Local sphere:TMesh=CreateSphere()
Local cylinder:TMesh=CreateCylinder()
Local cone:TMesh=CreateCone() 

PositionEntity cube,-6,0,0
PositionEntity sphere,-2,0,0
PositionEntity cylinder,2,0,0
PositionEntity cone,6,0,0

ScaleEntity sphere,3,3,3

CreateTimer 60

While WaitEvent()
	Select EventID()
		Case EVENT_TIMERTICK
			RedrawGadget canvas

		Case EVENT_GADGETPAINT
			SetGraphics CanvasGraphics( canvas )
			
			TurnEntity cube,0,1,0
				
			RotateEntity(sphere,EntityPitch(sphere)+0.7,EntityYaw(sphere)+0.7,EntityRoll(sphere)+0.7)
				
			UpdateWorld
			RenderWorld							
				
			DrawText "FPS: "+String(TGlobal.Getfps()),0,0
			
			Flip
			
				
		Case EVENT_MOUSEMOVE
		
		Case EVENT_WINDOWSIZE
			SetGadgetShape(Canvas , 0 , 0 , ClientWidth(window) , ClientHeight(window))
			UpdateCanvas3D(Canvas)
			CameraViewport(Cam , 0 , 0 , ClientWidth(window) , ClientHeight(window) ) 
			
		Case EVENT_WINDOWCLOSE
			FreeGadget canvas
			End

		Case EVENT_APPTERMINATE
			End
	End Select
Wend


The most important thing is that you have to set the GraphicsDriver to OpenGL (on win). The second thing is that you have to set the new Viewports for you cams extra after the updatcanvas3D command, thats because I don't know where the user wants to have their cams or what is their main cam.

I hope this helps.