@@ -3,10 +3,10 @@ import * as three from 'three';
33import type { TGlfw , TInitOpts } from '../ts/types.ts' ;
44
55const shouldUseHeadlessGlfw = platform === 'darwin' ;
6+ const shouldUseGlesTestWindowHints = platform === 'darwin' || platform === 'linux' ;
67
7- const applyHeadlessWindowHints = ( currentGlfw : TGlfw ) : void => {
8+ const applyGlesWindowHints = ( currentGlfw : TGlfw ) : void => {
89 currentGlfw . windowHint ( currentGlfw . VISIBLE , currentGlfw . FALSE ) ;
9- currentGlfw . windowHint ( currentGlfw . CONTEXT_CREATION_API , currentGlfw . EGL_CONTEXT_API ) ;
1010 currentGlfw . windowHint ( currentGlfw . OPENGL_PROFILE , currentGlfw . OPENGL_ANY_PROFILE ) ;
1111 currentGlfw . windowHint ( currentGlfw . CONTEXT_VERSION_MAJOR , 3 ) ;
1212 currentGlfw . windowHint ( currentGlfw . CONTEXT_VERSION_MINOR , 2 ) ;
@@ -16,6 +16,11 @@ const applyHeadlessWindowHints = (currentGlfw: TGlfw): void => {
1616 currentGlfw . windowHint ( currentGlfw . SAMPLES , 0 ) ;
1717} ;
1818
19+ const applyHeadlessWindowHints = ( currentGlfw : TGlfw ) : void => {
20+ currentGlfw . windowHint ( currentGlfw . CONTEXT_CREATION_API , currentGlfw . EGL_CONTEXT_API ) ;
21+ applyGlesWindowHints ( currentGlfw ) ;
22+ } ;
23+
1924const bootstrapHeadlessGlfw = async ( ) : Promise < TGlfw | null > => {
2025 if ( ! shouldUseHeadlessGlfw ) {
2126 return null ;
@@ -108,14 +113,18 @@ export const {
108113export { doc , window , document , glfw } ;
109114
110115const getTestDocumentOpts = ( opts : TInitOpts = { } ) : TInitOpts => {
111- if ( ! shouldUseHeadlessGlfw ) {
116+ if ( ! shouldUseGlesTestWindowHints ) {
112117 return opts ;
113118 }
114119
115120 return {
116121 ...opts ,
117122 onBeforeWindow ( windowCurrent , currentGlfw ) {
118- applyHeadlessWindowHints ( currentGlfw as TGlfw ) ;
123+ if ( shouldUseHeadlessGlfw ) {
124+ applyHeadlessWindowHints ( currentGlfw as TGlfw ) ;
125+ } else {
126+ applyGlesWindowHints ( currentGlfw as TGlfw ) ;
127+ }
119128 opts . onBeforeWindow ?.( windowCurrent , currentGlfw ) ;
120129 } ,
121130 } ;
0 commit comments