I have a wrapper for glfw & opengl (intended to support x11, win32, wayland etc directly later), but whenever I try to make use of the depth buffer bit (the position is extracted via pawvfxWhatBits to map to the api’s bits) my window hangs, this is what I’ve got (just think of the functions as 1 to 1 equivalent of the same functions in glfw & opengl, I’ll add some comments after the initial post to make clearer what calls are happening under the hood):
pawd test_wrappers()
{
pawu numint = 0, gfxBits = 0;
pawWFX Wfx = libWfx.api;
pawVFX Vfx = libVfx.api;
pawVFR App = NULL;
pawd aid = -1;
pawlsu numstr = INIT_pawlsu;
pawd numlen = 0;
if ( !Wfx || !Vfx || !winText )
{
if ( !Wfx ) pawPrints( "Need window api hook!\n" );
if ( !Vfx ) pawPrints("Need graphics api hook!\n");
if ( !winText ) pawPrints("Need initial window title!\n");
return -1;
}
// glfwWindowHint
pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_CTXAPI, PAWWFX_E_CTXAPI_NATIVE );
pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_GFXAPI, PAWWFX_E_GFXAPI_OPENGL );
pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_GFXAPI_PROFILE, PAWWFX_E_GFXAPI_PROFILE_CORE );
pawwfxDeclBooleanHint( Wfx, PAWWFX_H_BOOLEAN_GFXAPI_FW_SAFE, true );
pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_CTXVER_MAJOR, 4 );
pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_CTXVER_MINOR, 3 );
pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_SAMPLES, 4 );
#if 0
pawwfxDeclBooleanHint( Wfx, PAWWFX_H_BOOLEAN_IGNORE_ERRORS, false );
#endif
pawwinDeclIntegerHint( Wfx, PAWWIN_H_INTEGER_DEPTH_BITS, 32 );
// glfwCreateWindow
wid = PawwinCreate( Wfx, NULL, NULL, winBoxW, winBoxH, winText );
// Garbage collector related, mutices are built into these objects for optional thread safety
Win = PawSeekUD( wid );
if ( !Win )
{
pawPrints("Failed to create window!\n");
return -1;
}
// glfwMakeContextCurrent
pawwinBindContext( Win );
// glewInit + glewExperimental
if ( pawvfxInitApi( Vfx, true ) != 0 )
{
pawPrints("Failed to initiliase GFX API!\n");
return -1;
}
// glDebugMessageCallback, glEnable(GL_DEBUG_OUTPUT) if ( insync ) glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS)
pawvfxInitDbg( Vfx, true, debugVfxCB, NULL );
// if ( test ) glEnable( GL_DEPTH_TEST ) else glDisable( GL_DEPTH_TEST )
pawvfxTestDepth( Vfx, true );
// glDepthMask( mask ? GL_TRUE : GL_FALSE )
pawvfxMaskDepth( Vfx, true );
pawPrints("Launching Graphics Tests...\n");
/*
pawd whatGfxBits( pawd opts )
{
pawd give = 0;
if ( opts & PAWVFX_O_COLOR_BUFFER )
give |= GL_COLOR_BUFFER_BIT;
if ( opts & PAWVFX_O_DEPTH_BUFFER )
give |= GL_DEPTH_BUFFER_BIT;
if ( opts & PAWVFX_O_ACCUM_BUFFER )
give |= GL_ACCUM_BUFFER_BIT;
if ( opts & PAWVFX_O_STENCIL_BUFF )
give |= GL_STENCIL_BUFFER_BIT;
return give;
}
*/
#if 1
gfxBits = pawvfxWhatBits
( Vfx, PAWVFX_O_COLOR_BUFFER | PAWVFX_O_DEPTH_BUFFER );
#else
gfxBits = pawvfxWhatBits( Vfx, PAWVFX_O_COLOR_BUFFER );
#endif
aid = PawvfxMakeGfxApp( Vfx );
App = PawSeekUD( aid );
pawwinShow( Win, true );
// glViewport
pawvfxMoveCtx( Vfx, 0, 0, winBoxW, winBoxW );
if ( App )
{
// glfwShouldWindowClose
while ( pawwinKeep( Win ) )
{
pawPrintf
(
L"%80lc\n=%|78ls=\n%80lc\n",
L'=', L"Draw Loop", L'='
);
// glUseProgram
pawvfxBindGfxApp( Vfx, NULL );
// glfwPollEvents
pawwfxPollAll( Wfx );
if ( pawwfxReadKey( Win, PAWKEY_ANSI_ESC ) )
{
pawwinShut( Win, true );
continue;
}
// glClearColor
pawvfxBaseColor( Vfx, 0, 0, 0, 0 );
// glClear
pawgfxZeroBits( Vfx, gfxBits );
// glClearDepth
pawvfxBaseDepth( Vfx, 0.0 );
numlen = pawu2s( &numstr, numint, PAW_BASE10 );
pawtcsResizen( winText, numstr.str, numlen );
numint = (numint + 1) * numlen;
pawwinDeclText( Win, winText );
/* glfwSwapBuffers
This is where it hangs but only if the depth buffer bit is used */
pawwinSwapBuffers( Win );
}
}
pawDropID(aid);
PawDropID(wid);
Win = NULL;
wid = -1;
return 0;
}