-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
content: add example to show main thread crash
- Loading branch information
Showing
4 changed files
with
44 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package app | ||
|
||
import ( | ||
"testing" | ||
"x/mainthread" | ||
"x/thread" | ||
|
||
"github.com/go-gl/gl/v3.3-core/gl" | ||
) | ||
|
||
// This test will crash! | ||
func TestApp(t *testing.T) { | ||
mainthread.Init(func() { | ||
w, _ := NewWindow() | ||
defer Terminate() | ||
|
||
renderThread := thread.New() | ||
renderThread.Call(func() { | ||
// Initialize gl from a different thread | ||
gl.Init() | ||
// gl.MakeContextCurrent() | ||
gl.GoStr(gl.GetString(gl.VERSION)) | ||
}) | ||
mainthread.Call(func() { | ||
// Initialize gl from the main thread can | ||
// prevent crash from the GetVersion crash. | ||
// gl.Init() | ||
gl.GoStr(gl.GetString(gl.VERSION)) | ||
}) | ||
w.Stop() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters