[Patch] Rendering of FreeBasic graphic on OpenGL

General discussion for topics related to the FreeBASIC project or its community.
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by angros47 »

This is compiled for Windows 32 bit: https://ufile.io/xump3 (I compiled it under Wine)
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by Imortis »

That confirmed my suspicions. I compiled it correctly, it just will not show on the machine I am currently using. Other OpenGL apps work fine. I will test from another machine as soon as I can.
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by angros47 »

What happens if you remove the line:

Code: Select all

	__fb_gl.Enable(GL_TEXTURE_2D);
from function fb_hGL_SetupProjection in gfx_opengl.c ?
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by angros47 »

The code you showed me is the unpatched file, provided with original FreeBasic. In the patch I made, the subroutine is completely different. Have you download the file I included on Sourceforge and extracted the modified files from it?

The link is: https://sourceforge.net/p/fbc/patches/3 ... ib2.tar.gz
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by Imortis »

No difference.
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by angros47 »

I tried clicking on it now, and looking at the file inside. The routine should be:

Code: Select all

void fb_hGL_SetupProjection(void)
{
	const GLfloat vert[]={-1,-1,-1,1,1,1,1,-1};

	__fb_gl.PushAttrib(GL_ALL_ATTRIB_BITS);
	__fb_gl.Viewport(0, 0, __fb_gfx->w * __fb_gl_params.scale, __fb_gfx->h * __fb_gl_params.scale);
	__fb_gl.MatrixMode(GL_PROJECTION);
	__fb_gl.PushMatrix();
	__fb_gl.LoadIdentity();

	__fb_gl.Ortho(-1, 1, -1, 1, -1, 1);
	__fb_gl.MatrixMode(GL_MODELVIEW);
	__fb_gl.LoadIdentity();
	__fb_gl.ShadeModel(GL_FLAT);
	__fb_gl.Disable(GL_DEPTH_TEST);
	__fb_gl.DepthMask(GL_FALSE);
	__fb_gl.Enable( GL_VERTEX_ARRAY );
	__fb_gl.Enable( GL_TEXTURE_COORD_ARRAY );

	__fb_gl.VertexPointer(2, GL_FLOAT, 0, vert);
	__fb_gl.TexCoordPointer(2, GL_FLOAT, 0, texcoords);

	//__fb_gl.ActiveTexture(GL_TEXTURE0);
	__fb_gl.BindTexture(GL_TEXTURE_2D, ScreenTex);
	switch(__fb_gfx->depth){
	case 32:
	case 24:
		__fb_gl.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, __fb_gfx->w, __fb_gfx->h, GL_BGRA, GL_UNSIGNED_BYTE, (unsigned char *)__fb_gfx->framebuffer);
		break;
	case 16:
	case 15:
		__fb_gl.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, __fb_gfx->w, __fb_gfx->h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, (unsigned char *)__fb_gfx->framebuffer);
		break;
	case 8:
	case 4:
	case 2:
	case 1:
		__fb_gl.PixelTransferi(GL_MAP_COLOR, GL_TRUE );
		__fb_gl.PixelMap(GL_PIXEL_MAP_I_TO_R,256, map_r);
		__fb_gl.PixelMap(GL_PIXEL_MAP_I_TO_G,256, map_g);
		__fb_gl.PixelMap(GL_PIXEL_MAP_I_TO_B,256, map_b);

		__fb_gl.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, __fb_gfx->w, __fb_gfx->h, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, (unsigned char *)__fb_gfx->framebuffer);

	}

	__fb_gl.Enable(GL_TEXTURE_2D);
	__fb_gl.DrawArrays(GL_TRIANGLE_FAN,0,4);

	__fb_gl.PopMatrix();
	__fb_gl.PopAttrib();


}
Can you see it? Otherwise, something went wrong in your download
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by Imortis »

Sorry. I had the source code in a couple different places on my drive. I was looking at the unmodified code. If you look you will see I deleted that post because I was in error. I removed the line of code you suggested and still had the same results. No rendering at all.
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by angros47 »

Screen is white, or black? Also, try adding the line

Code: Select all

printf ("test");
to see if the subroutine is executed
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by angros47 »

Also, this is a file I compiled on my system: does it work? https://ufile.io/ij4hl (warning, executable file)
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by Imortis »

Black screen, and yes it gets executed.
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by Imortis »

angros47 wrote:Also, this is a file I compiled on my system: does it work? https://ufile.io/ij4hl (warning, executable file)
It also does not work.
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by angros47 »

If you try to draw a triangle in OpenGL, does it show on the screen? And does it show if you use screencontrol 150,1?
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by Imortis »

The OpenGL examples bundled with FB work, but your code when using the screencontrol command does not. If I remove it, the code works in normal FBGFX.
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by angros47 »

If you take one of the normal example, and add the screencontrol 150,1 command before the screen command, what happens?
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: [Patch] Rendering of FreeBasic graphic on OpenGL

Post by Imortis »

angros47 wrote:If you take one of the normal example, and add the screencontrol 150,1 command before the screen command, what happens?
Black screen.
Post Reply