Skip to content

Commit 2793152

Browse files
committed
Use matching GLES hints for core test windows
1 parent 4a13c85 commit 2793152

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

test/init.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import * as three from 'three';
33
import type { TGlfw, TInitOpts } from '../ts/types.ts';
44

55
const 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+
1924
const bootstrapHeadlessGlfw = async (): Promise<TGlfw | null> => {
2025
if (!shouldUseHeadlessGlfw) {
2126
return null;
@@ -108,14 +113,18 @@ export const {
108113
export { doc, window, document, glfw };
109114

110115
const 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

Comments
 (0)