OpenB3DMax

Started by _PJ_, July 21, 2020, 11:53:02

Previous topic - Next topic

_PJ_

Form what I can see, the 3D Graphics command voids return value, so there is no TGraphics (or TGLGraphics?) object exposed.
In order to switch graphics objects such as:
[vode]
Global GPU_CURRENT:TGraphics
'....
      GPU_CURRENT=Graphics(W,H,D) 
'....
If (GPU_CURRENT<>Null)
CloseGraphics(GPU_CURRENT)
GCCollect
End If
        GPU_CURRENT = Graphics(NewW, NewH, NewD)


I have trawled through Docs, but cannot find a way to access to the current TGraphics3D object nor the actual Object type (TGLGraphics? TGraphics3D? etc...) or if there are suitable appropriate alternative "Close" funcitons etc. for the OpenGL B3D Max modules...

Can anyone help with this?

markcwm

There's no TGraphics3D object there's gfx_obj:TGraphics, stored in TGlobal3D.gfx_obj.

_PJ_

Hi Mark, thanks for the quick reply.

I was able to find TGlobal3D.gfx_obj where it was declared in the exposed Graphics3D function ("B3DGlGraphics.Mod")


   If usecanvas=False Then TGlobal3D.gfx_obj=Graphics( width,height,depth,rate,flags ) ' gfx object

_PJ_

#3
Now my follow up question is:

When MaxGUI is used, how to render 3D to a canvas?

---
I have set the useCanvas parameter to TRUE

I created a UI Canvas object

and then make a RenderWorld() call
---

IF, between calling Graphics3D and the RenderWorld() I use the following:

'testc:TCamera = CreateCamera()
teste:TEntity = CreateSphere()
testl:TLight = CreateLight()
AmbientLight(128,128,128)

Everything compiles and runs without issue. HOWEVER As soon as I uncomment the CreateCamera() line - the whole build dies completely crashing BlitzMax with a notification "ERROR_ ACCESS VIOLATION"

_

What requirements do I need to be in place before creating camera, and, just so I am clear on this, in IMPORTing the necessary modules to render 3D content in  a MaxGUI canvas, Should I have any additional frameworks/imports?

Currently I am only calling
Import MaxGUI.Drivers
Import BRL.Standardio
( For the MaxUI stuff )

Import OpenB3DMax.B3DGLGraphics
( For the 3D stuff )


_PJ_

In the event of no response, I wonder if perhaps there is a way to copy the backbuffer render and send draw this to the canvas as a PixMap instead?

What are other peoples' solutions to how to render 3D camera view to a MaxGUI Canvas?

markcwm

Sorry, I haven't had much free time. I think you can find the solution to this in the examples at openb3dmax.docs. See minib3d/maxgui.bmx.

Krischan

A very simple MaxGUI+OpenB3D test code:

Code (Blitzmax) Select
SuperStrict

Framework Openb3dmax.B3dglgraphics
Import maxgui.Drivers

' Screen
Local SCREEN_WIDTH:Int = 1024
Local SCREEN_HEIGHT:Int = 600
Local SCREEN_DEPTH:Int = 0
Local SCREEN_MODE:Int = 2
Local SCREEN_HERTZ:Int = 60

' MaxGUI
Local MAXGUI_WINDOW:TGadget = CreateWindow("OpenB3D MaxGUI Test", DesktopWidth() / 2 - SCREEN_WIDTH / 2, DesktopHeight() / 2 - SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT, Null, WINDOW_TITLEBAR)
Local MAXGUI_CANVAS:TGadget = CreateCanvas(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, MAXGUI_WINDOW, 0)
SetGadgetLayout(MAXGUI_CANVAS, 1, 1, 1, 1)
ActivateGadget(MAXGUI_CANVAS)
SetGraphics CanvasGraphics(MAXGUI_CANVAS)
Graphics3D(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, SCREEN_MODE, SCREEN_HERTZ, -1, True)

' 3D
Local PIVOT:TPivot = CreatePivot()
Local CUBE:TMesh = CreateCube(PIVOT)
AmbientLight 64, 64, 64
PositionEntity PIVOT, 0, 0, 5
CreateCamera()
CreateLight(1)

MoveMouse SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2
EnablePolledInput()

' Main Loop
While Not KeyDown(KEY_ESCAPE)

TurnEntity CUBE, MouseYSpeed(), 0, 0
TurnEntity PIVOT, 0, MouseXSpeed(), 0

' render
RenderWorld

' 2D output
BeginMax2D()

DrawText "MaxGUI Test", 0, 0

EndMax2D()

Flip True

Wend

End
Kind regards
Krischan

Windows 10 Pro | i7 9700K@ 3.6GHz | RTX 2080 8GB]
Metaverse | Blitzbasic Archive | My Github projects