MiniB3d for FreeBasic

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

Re: MiniB3d for FreeBasic

Postby D.J.Peters » Oct 19, 2017 6:28

Why do you use on PC OpenGL >=3.0 FrameBuffer and not the OpenGL 2.0 DepthTexture instead ?
you need it only if GLES2 are defined

I ask only for info I self don't need it since fbgxf create a 3.0 render context ?

Joshy
angros47
Posts: 1421
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Postby angros47 » Oct 19, 2017 18:09

Are you referring to something in the postfx module, or in the texture module?
I am not sure I understand which >=3.0 feature are you talking about
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

Re: MiniB3d for FreeBasic

Postby D.J.Peters » Oct 19, 2017 19:06

So far I know for example glGenFramebuffers() is OpenGL ES2.0/3.0 and OpenGL >= 3.0 but not OpenGL 2.0 ?

Joshy

edit: OK I saw you don't check the version of running OpenGL you used gLee instead.

Your lib use ARB_framebuffer_object or EXT_framebuffer_object if OpenmGL<3.0
angros47
Posts: 1421
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Postby angros47 » Oct 19, 2017 20:00

I ported the code from MiniB3D, that used glee. Then, when I added the rendering to texture, I found, of several tutorials, the suggestion to use framebuffers as the most modern and efficient solution, and since such an implementation worked (it even works if compiled with Emscripten), I didn't look for other solutions. How would you have implemented it, using OpenGL2 features?
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

Re: MiniB3d for FreeBasic

Postby D.J.Peters » Oct 19, 2017 23:23

I hope I don't waste your time i'm currently a little bit confuse :-)

if glGetString(GL_VERSION) reports "3.0" or higher that means glGenFramebuffers are implented as a standard
AND ONLY if the OpenGL context are created with an OpenGL profile 3.0 or higher you can use:

dim as GLInt FBO
glGenFramebuffers(1,@FBO)

If for example the OpenGL version is 1.4 or 2.0 but "GL_EXT_framebuffer_object" are reported as an extenmsion you can use:

dim as GLInt FBO
glGenFramebuffersEXT(1,@FBO)

Can you point me in the right direction why your code works with an none OpenGL 3.0 profile created by FBGFX ?

Do you ever tested OpenB3D with an older gfx card or with an older OpenGL driver ?

glGenFramebuffers needs OpenGL 3.0 or OpenGL ES2.0
OpenGL 3.0 : https://www.khronos.org/registry/OpenGL ... fers.xhtml
OpenGL ES 2.0 : https://www.khronos.org/registry/OpenGL ... uffers.xml

As an fallback the extension "GL_EXT_framebuffer_object"
glGenFramebuffersEXT: https://www.khronos.org/registry/OpenGL ... object.txt

Thank you

Joshy
angros47
Posts: 1421
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Postby angros47 » Oct 19, 2017 23:50

I tested openGL on a laptop built in 2005, that doesn't even support shaders, and has OpenGL 1.4 (I believe). It worked (except the shader part, of course). I don't remember if I had tested rendering on a texture, too, but I think I did. Also, I don't know other methods to render directly on a texture, so when you mentioned rendering on a texture without a framebuffer I wondered what you were talking about.

If your card doesn't support framebuffers at all, in theory it is possible to render on backbuffer, and copy that on the texture: original Blitz3D did that, and even the original MiniB3D, using the command "BackBufferToTex", that is still implemented in OpenB3D, in case you want to try.

FBGFX, in this case is not required to provide support to modern profile, since the profile is used in C++, not in FreeBasic (FreeBasic only creates the window and the context... a bit like the library GLUT); and in C++ the profile and the extensions are provided by GLee (or GLext on Linux)
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

Re: MiniB3d for FreeBasic

Postby D.J.Peters » Oct 20, 2017 7:14

Looks like you need only for OpenGL 3.2 and higer versions an render context init with an profile.

So glGenFrameBuffers is for example in GLee:

#define glGenFramebuffers glGenFramebuffersEXT

or

#define glGenFramebuffers glGenFramebuffersARB

(*) that makes more sence for me now :-)

For the future ScreenControl GL_SET_PROFILE,XYZ would be an good option.

* I was confused because #define is compile time and not runtime where your code can detect the active OpenGL environment.
So in real it's more complicated glGenFramebuffersEXT or ARB are pointers are set as runtime.
...

Joshy
Last edited by D.J.Peters on Oct 20, 2017 11:50, edited 1 time in total.
angros47
Posts: 1421
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Postby angros47 » Oct 20, 2017 8:54

D.J.Peters wrote:Looks like you need only for OpenGL 3.1 and higer versions an render context init with an profile.


The official documentation states something similar: https://www.khronos.org/opengl/wiki/OpenGL_Context#OpenGL_3.2_and_Profiles

The 3.0 form of context creation did not have the concept of profiles. There was only one form of OpenGL: the core specification. In 3.2, OpenGL was effectively split into two profiles, core and compatibility. An implementation was only required to define core, so compatibility is not guaranteed to be available. However, on most implementations, the compatibility profile will be available.
BasicCoder2
Posts: 3308
Joined: Jan 01, 2009 7:03

Re: MiniB3d for FreeBasic

Postby BasicCoder2 » Oct 21, 2017 0:56

viewtopic.php?t=15409
When I go to,
http://sourceforge.net/projects/minib3d/
All I see is a download for OpenB3D,
I can't find any minib3d.bi in the download.
.
angros47
Posts: 1421
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Postby angros47 » Oct 21, 2017 6:59

The old name was MiniB3D (a port of a software for BlitzMax). With time, the library became so different that I changed its name. The file you need to use is OpenB3D.bi
BasicCoder2
Posts: 3308
Joined: Jan 01, 2009 7:03

Re: MiniB3d for FreeBasic

Postby BasicCoder2 » Oct 21, 2017 7:28

Thanks.
The example I wanted to run below needs "bird.b3d" but I can't find it?
Also perhaps LoadAnimMesh needs to deal with failure to return a value?

Code: Select all

#include "OpenB3D.bi"
#include "fbgfx.bi"
Using FB

Const xres = 1024
Const yres = 768
Screenres  xres, yres, 32,, GFX_OPENGL
Graphics3d xres, yres, 32, 1, 1

Var camera=createcamera(0)
CameraViewport(camera,0,0,xres,yres)
Var bird=LoadAnimMesh ("bird.b3d",0)
moveentity bird,0,0,15

animate bird,1,.1,0,0

AmbientLight(0, 255, 255)
Do
    EntityAlpha bird, Abs(Cos(Timer))
   
    If Multikey(SC_W) Then turnentity bird, -1,  0,  0, 0
    If Multikey(SC_S) Then turnentity bird,  1,  0,  0, 0
    If Multikey(SC_A) Then turnentity bird,  0, -1,  0, 0
    If Multikey(SC_D) Then turnentity bird,  0,  1,  0, 0
    If Multikey(SC_Q) Then turnentity bird,  0,  0, -1, 0
    If Multikey(SC_E) Then turnentity bird,  0,  0,  1, 0
   
    If Multikey(SC_RIGHT) Then TranslateEntity bird,  1,  0, 0, 0
    If Multikey(SC_LEFT)  Then TranslateEntity bird, -1,  0, 0, 0
    If Multikey(SC_DOWN)  Then TranslateEntity bird,  0, -1, 0, 0
    If Multikey(SC_UP)    Then TranslateEntity bird,  0,  1, 0, 0
   updateworld 1
   renderworld
   
   Flip
Loop Until Multikey(SC_ESCAPE)
angros47
Posts: 1421
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Postby angros47 » Oct 22, 2017 9:07

Here is the file: https://files.fm/u/rcs5bdka
BasicCoder2
Posts: 3308
Joined: Jan 01, 2009 7:03

Re: MiniB3d for FreeBasic

Postby BasicCoder2 » Oct 22, 2017 9:59

@angros47,

So is Flip required? I usually use screenlock/screenunlock.
I had to slow the key response down with the timer.
I also noticed that the translate made faster changes than the rotates.
So is there any tutorial for learning how to use the library?
The models are made how? By Blender?
Although I have been around a while and I see you began all this some time ago using these extensions to FreeBasic hadn't really interested before so I am completely new to this 3d programming.
.
angros47
Posts: 1421
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Postby angros47 » Oct 22, 2017 10:13

Flip is required. OpenGl works in a completely different way than normal graphic library, and OpenB3D is based on OpenGl.

Translation, mathematically, requires less calculation than rotation, so it is obviously faster. Most tutorials of Blitz3D can work on OpenB3D, too.

Several 3d softwares can export into .B3D format, blender can, too (it might need a specific plug in, that is just a script, for that)
D.J.Peters
Posts: 7455
Joined: May 28, 2005 3:28

Re: MiniB3d for FreeBasic

Postby D.J.Peters » Nov 27, 2017 21:18

there is an syntax error in shadow.cpp

Joshy

Code: Select all

float ShadowObject::light_x;
float ShadowObject::light_y, // << --- must be ";"
float ShadowObject::light_z;

Return to “Libraries”

Who is online

Users browsing this forum: Google [Bot] and 1 guest