c++ - SFML & OpenGL(glew) Why does my program fail when drawing to new window? -


i have problem regarding sfml windows, contexts , opengl drawing follows:

when create new window draw (because need fullscreen or changed delicate context settings @ runtime) use sf::window::create(args...) create new window, old 1 vanishes. understanding not affect opengl calls, because "active" states of contexts windows hold set automatically (so new window active).

so why opengl fail draw new window or stops working ?

i use wrappers sfmlcontents(sfmlhandler) , hide opengl calls in class(graphics). here's code: constructor of mainapp:

mainapp::mainapp() {     imediahandle::contextsettings settings;     settings.depth = 24;     settings.stencil = 8;     settings.antialiasing = 0;     settings.openglmajor = 3;     settings.openglminor = 3;     sfmlhandle.createwindow("test", 800, 600, settings);     graphics.init();     //i want able following line     sfmlhandle.createwindow("test", 200, 400, settings); } 

this code works fine old window gets destroyed , new 1 comes up. when start rendering in apploop later programm crashes @ call of glbindvertexarray(0);

if leave out additional line rendering works of course.

what have apply old drawing mechanism new window ? can initialize graphics again have ? not point of setting context active or inactive ?:

sfmlhandle.createwindow("test", 800, 600, settings); graphics.init();  sfmlhandle.createwindow("test", 200, 400, settings); // unnecessary ?  graphics.init(); 

this code works, too, no crashes later.

i thank clearing 1 !

when create new window, new opengl context made. sfml made context shares resources old (or other) context. means textures, buffers , shaders still valid.

there are, however, opengl objects cannot shared between opengl contexts. vertex array objects among , afaik framebuffer objects too. have recreate these before start drawing in new context.

see this page.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -