In addition, the surface taken by the frame (borders and title) is baddly taken into account when the FreeBASIC graphics instructions are drawn in OpenGL mode.
(the plotting appears to have been stretched to the outer limits of the window instead of remaining within the inner limits of the window)
[Patch] Rendering of FreeBasic graphic on OpenGL
Re: [Patch] Rendering of FreeBasic graphic on OpenGL
Last edited by fxm on Mar 12, 2019 10:06, edited 2 times in total.
Re: [Patch] Rendering of FreeBasic graphic on OpenGL
@fxm
There is no real limitation in my code about the zoom factor. The maximum possible zoom depends on screen resolution, and (I guess) on the OpenGL implementation, so there is no way to document it
@dodicat
the flip command renders the FreeBasic screen on a square over the OpenGL mode, covering everything else. So, if you want to keep the image you have drawn using OpenGL commands (the cube, in your case) you must make the FreeBasic picture transparent, by setting the alpha value of background color to zero, with COLOR ,RGBA(0,0,0,0) (pay attention to the comma before RGBA) and clearing the screen
There is no real limitation in my code about the zoom factor. The maximum possible zoom depends on screen resolution, and (I guess) on the OpenGL implementation, so there is no way to document it
@dodicat
the flip command renders the FreeBasic screen on a square over the OpenGL mode, covering everything else. So, if you want to keep the image you have drawn using OpenGL commands (the cube, in your case) you must make the FreeBasic picture transparent, by setting the alpha value of background color to zero, with COLOR ,RGBA(0,0,0,0) (pay attention to the comma before RGBA) and clearing the screen
Re: [Patch] Rendering of FreeBasic graphic on OpenGL
No luck yet angros47.
I have tried
COLOR ,RGBA(0,0,0,0)
cls
all over the place, including just after screenres where it would normally go.
(Also trying an alpha value in my draw string (as an experiment) makes no difference to the text colour).
...
If I create my own texture to an image in a background quad it works fine in a normal opengl screen.
...
Obviously I am missing something.
Sorry to be a pain.
I have tried
COLOR ,RGBA(0,0,0,0)
cls
all over the place, including just after screenres where it would normally go.
(Also trying an alpha value in my draw string (as an experiment) makes no difference to the text colour).
...
If I create my own texture to an image in a background quad it works fine in a normal opengl screen.
...
Obviously I am missing something.
Sorry to be a pain.
Re: [Patch] Rendering of FreeBasic graphic on OpenGL
Hi dodicat, I tried your code. It seems to render the cube only on the first frame. Later frames only show the red background rendered by 'glClear(GL_COLOR_BUFFER_BIT)'. This suggests to me that the render state somehow changed after the first frame before subsequent frames where rendered. Adding a call to your 'glsetup' function atop the render loop seems to confirm this.
(p.s. The GL_ONE,GL_ONE blending function is a nice touch, it makes the ball and cube blend together)
After further investigation I saw that the code posted by angros47 seems to push the projection matrix stack, but it pops the model-view matrix stack.
viewtopic.php?f=17&t=25902&start=15#p236050
I have found it is also possible to get your code working by guarding the flip call with:
This is probably a bug in the new feature!
(p.s. The GL_ONE,GL_ONE blending function is a nice touch, it makes the ball and cube blend together)
After further investigation I saw that the code posted by angros47 seems to push the projection matrix stack, but it pops the model-view matrix stack.
viewtopic.php?f=17&t=25902&start=15#p236050
I have found it is also possible to get your code working by guarding the flip call with:
Code: Select all
glMatrixMode GL_MODELVIEW
glPushMatrix
Flip
glMatrixMode GL_PROJECTION
glPopMatrix
glMatrixMode GL_MODELVIEW
Re: [Patch] Rendering of FreeBasic graphic on OpenGL
Thanks gothon.
It is now identical to texturing without using angros47's library, including the transparency as the ball crosses over the cube (which is not really wanted)
It is now identical to texturing without using angros47's library, including the transparency as the ball crosses over the cube (which is not really wanted)
Re: [Patch] Rendering of FreeBasic graphic on OpenGL
replace
Add
the circle will not be transparent
Code: Select all
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA)
Code: Select all
do
...
Color(,RGBA(0,0,0,0))
...
loop
Re: [Patch] Rendering of FreeBasic graphic on OpenGL
@gothon, thanks for your pull request. Fixed in fbc 1.07.0.gothon wrote:...After further investigation I saw that the code posted by angros47 seems to push the projection matrix stack, but it pops the model-view matrix stack.
...
This is probably a bug in the new feature!
Re: [Patch] Rendering of FreeBasic graphic on OpenGL
Does not work in VBO when you connect the light in the Shader
Code: Select all
#version 140
uniform sampler2D textures;
in vec2 ex_texcoord;
in vec4 vFinalColor;
out vec4 out_colour;
void main(void)
{
out_colour = texture(textures, ex_texcoord);//*vFinalColor; //<<<<<<<<<<<<<<< here
}
Code: Select all
#version 140
uniform mat4 projection;
uniform mat4 modelview;
in vec3 position;
in vec3 normal;
in vec2 texcoord;
out vec2 ex_texcoord;
out vec4 vFinalColor;
const vec3 vLightDirection = vec3(-1.0, -1.0, -1.0);
void main()
{
mat3 nv = mat3(modelview);
vec3 N = normalize( nv * normal);
vec3 L = normalize(vLightDirection);
float lambertComponent = max(dot(N, -L), 0.2);
vec3 diffuseLight = vec3(lambertComponent,lambertComponent,lambertComponent);
vFinalColor = vec4(diffuseLight, 1.0);
gl_Position = projection * modelview *vec4(position, 1.0);
ex_texcoord = texcoord;
}