3
Watch
3
Star
1
Fork
0
Issue

Experimental code for this issue https://github.com/google/filament/issues/1921

roxlu
roxlu
pushedAt 2 years ago

roxlu/windows-opengl-context

Creating Shared OpenGL Contexts

I created this repository while looking into an issue with Filament. This repository contains 3 tests:

  • test-research.cpp: Contains a summary of how to create a OpenGL context on Windows and some background info.

  • test-shared-context.cpp: Contains code that creates a couple of OpenGL contexts using the recommended flow (e.g. using a temporary context).

  • test-shared-context-threading.cpp: Similar to test-shared-context.cpp but here, we simulate how Filament creates a shared context, most importantly that we create the context in a separate thread.

Building with Clang

  • Make sure that you have Clang installed into C:/Program Files/LLVM
  • Make sure that you have CMake 3.15+ installed
  • Make sure you have Ninja installed.
  • Open a x64 Native Tools Command Prompt for VS 2019
  • Go into the build directory
  • Run release.bat clang

Building with MSVC

  • Make sure that you have Clang installed into C:/Program Files/LLVM
  • Make sure that you have CMake 3.15+ installed
  • Make sure you have Ninja installed.
  • Open a x64 Native Tools Command Prompt for VS 2019
  • Go into the build directory
  • Run release.bat

Solution (?)

baldurk pointed me to something which seems to be the cause of the issue. I'm creating a new OpenGl context in a separate thread and try to use the OpenGl context from the main as a shared context. Though the OpenGl context from the main thread is still current. When I unset the current OpenGl context from the main thread things seem to work! See this, where I unset the current context.

IMPORTANT: when you create an OpenGl context and you want to share this context with a context that you create in another thread, make sure that the context is not current.

ucloud ads