OpenB3D and OpenGL commands

BlitzMax Forums/MiniB3D Module/OpenB3D and OpenGL commands

RustyKristi(Posted 2016) [#1]
Just curious as I have seen some good opengl examples that I want to try out..


Yan(Posted 2016) [#2]
Just curious as I have seen some good opengl examples that I want to try out..

Good for you?


markcw(Posted 2016) [#3]
The point of Openb3d, Minib3d, etc is so users don't have to learn OpenGL, at least not much, sometimes you need to but then you find it's more complex as there is a rendering pipeline to understand as well, so you can't just throw in some OGL commands to your main loop you've to hack around in the cpp.

I would point to the Nehe tutorials as a great OGL basics course and Kfprimm has updated the old Bmx tutorials here, I haven't tried these yet so don't know if they run.

Then there's Grover's OGL deferred render which apparently is very good but again I haven't looked at it yet, there's plenty of downloads in that thread though.


RustyKristi(Posted 2016) [#4]
ok thanks. so I can't use openb3d commands inside this part?


  Case EVENT_GADGETPAINT
                        SetGraphics CanvasGraphics( c )
                                Local wid = c.ClientWidth()
                                Local hgt = c.ClientHeight()
                                Local asp# = Float(wid)/Float(hgt)
                                
                                glViewport 0,0,wid,hgt
                                glMatrixMode GL_PROJECTION
                                glLoadIdentity
                                gluPerspective 45, asp, 1, 100
                                gltranslatef 0,0,-50+tim
                                tim=20*Cos(MilliSecs()/10.0)
                                
                                glMatrixMode GL_MODELVIEW
                                glLoadIdentity
                                
                                Local global_ambient#[]=[0.6#, 0.5#,  0.3#, 1.0#]
                                Local light0pos#[]=     [0.0#, 5.0#, 10.0#, 1.0#]
                                Local light0ambient#[]= [0.5#, 0.5#,  0.5#, 1.0#]
                                Local light0diffuse#[]= [0.3#, 0.3#,  0.3#, 1.0#]
                                Local light0specular#[]=[0.8#, 0.8#,  0.8#, 1.0#]
                        
                                Local lmodel_ambient#[]=[ 0.2#,0.2#,0.2#,1.0#]
                                glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient)
                        
                                glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient)
                                glLightfv(GL_LIGHT0, GL_POSITION, light0pos)
                                glLightfv(GL_LIGHT0, GL_AMBIENT, light0ambient)
                                glLightfv(GL_LIGHT0, GL_DIFFUSE, light0diffuse)
                                glLightfv(GL_LIGHT0, GL_SPECULAR, light0specular)
                                glEnable(GL_LIGHTING)
                                glEnable(GL_LIGHT0)
                                glShadeModel(GL_SMOOTH)
                                glMateriali(GL_FRONT, GL_SHININESS, 128)
        
                                                                
                                glClearColor 0,0,0.5,1
                                glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

                                glEnable(GL_DEPTH_TEST)
                                
                                glRotatef ax,1,0,0
                                glRotatef ay,0,1,0
                                ax:+1
                                ay:+5
                                DrawSizeCube(7)
                                
                                Flip
                                
        EndSelect


this is from the glcube example


angros47(Posted 2016) [#5]
You can, but by default the command RenderWorld clears the screen, unless you use CameraClsMode.

Some OpenGL commands that can be fun to use with OpenB3D are the ones related to accumulation buffer. You can use them to blur images, simulating motion blur or depth of field.


RustyKristi(Posted 2016) [#6]
Thanks guys. I'm just curious if this can be done.


Kryzon(Posted 2016) [#7]
MiniB3D and OpenB3D can be thought of as a convenience: they set up OpenGL states and use the complicated code for you. They help a lot by doing that.
Then you only have to worry about meshes, materials, cameras etc. (the abstraction, I think it's called).

That code you posted is the "complicated code" that they are already using internally. So maybe you just want to use the BRL.GLGraphics module, which gives you access to OpenGL and you can try some raw OpenGL coding with those NeHe tutorials etc.
This same BRL.GLGraphics module is used by the Mini\Open modules to access OpenGL.

You can still use raw OpenGL calls with these 3D modules, just make sure it's at a point in the program that won't disrupt what they are doing.
When I used MiniB3D and needed some customisation I added it directly to the MiniB3D source code (for example, by adding more FX flags and blending modes), and then I rebuilt the module. I think there's less chance of doing something wrong like this than writing outside of it.


RustyKristi(Posted 2016) [#8]
Thank you for these Kryzon. I think I now got a better understanding reading through all your thoughts. I am still new on how modules work on Blitzmax but I agree with the integration there.