Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple nanogui::screen #473

Closed
ashwinbhat opened this issue Dec 2, 2022 · 2 comments
Closed

Multiple nanogui::screen #473

ashwinbhat opened this issue Dec 2, 2022 · 2 comments

Comments

@ashwinbhat
Copy link

Hi,
Are multiple screen supported in nanogui? Does this share the underlying OpenGL Context?

@wjakob
Copy link
Owner

wjakob commented Dec 2, 2022

Nobody has ever tried it AFAIK.

@ashwinbhat
Copy link
Author

I think I might have a workaround, but it needs making OpenGL calls.

// Create a nanogui screen with OpenGL 4.5
parent = new nanogui::Screen(nanogui::Vector2i(300, 500), 
                                                   "Screen1", 
                                                   true,   
                                                   false,  
                                                   8,      
                                                   8,      
                                                   24,     
                                                   8,      
                                                   4,      
                                                   4,      
                                                   5);     

// Create a new window using a shared context 
// see https://www.glfw.org/docs/3.3/group__window.html#ga3555a418df92ad53f917597fe2f64aeb
GLFWwindow* window = glfwCreateWindow(300, 400, "Screen2", nullptr, parent->glfwWindow());
if (window) {
   // Create a new screen using this window
   // Note: need to call glfwMakeContextCurrent(window) to ensure when we switch between screens
   screen2 = new nanogui::Screen();
   screen2->initialize(window, false);    
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants