ofxFenster
ofxFenster copied to clipboard
glfwCreateWindow on windows
There is an issue in setupOpenGL. When calling glfwCreateWindow on runtime there is an unhandled exception by an access violation location.
¿Any ideas?
OS: windows 7 64b Openframeworks 0.8.0 Visual Studio 12
I just changen shared to NULL windowP = glfwCreateWindow(w, h, "", NULL, NULL); and it works for now. I apears that shared is set to shared = ofxFensterManager::get()->getMainWindow()->windowP; And causes some kind of trouble to the flfwCreateWindow I'll try to use like this and understand what is happening here. Cheers
glfwCreateContext() call seems to be causing problems. wich is already compliled, so I think I´ll wait for any suggestions.
@xumo's change works fine for the example code but breaks more complicated use cases. I made a simple example of trying to create windows on a key press instead of during the setup method and now get a segmentation fault with the following call
glfwMakeContextCurrent(windowP);
which is the first line in the ofxFenster class's draw function - display(bool notifyDraw)
I also have this problem, there are solutions?
OS: windows 7 32bit Openframeworks 0.8.0 Visual Studio 2012
If anyone still has this problem with shared context in ofxFenster addon, here is my solution. I did modify some code in ofxFenster::setupOpenGL(int w, int h, int screenMode) like this (basically added/changed 4 lines of code):
GLFWwindow* shared = NULL;
if(ofxFensterManager::get()->getMainWindow().get() != NULL){
shared = ofxFensterManager::get()->getMainWindow()->windowP;
}
if(requestedMode==OF_GAME_MODE){
int count;
GLFWmonitor** monitors = glfwGetMonitors(&count);
if(count>0){
windowP = glfwCreateWindow(w, h, "", monitors[0], shared);
}else{
ofLogError("ofxFenster") << "couldn't find any monitors";
return;
}
}else{
// ADD following line:
// get shared context from glfwGetCurrentContext()
/*->*/ GLFWwindow* sharedContext = glfwGetCurrentContext(); // shared crash fix
/*->*/ windowP = glfwCreateWindow(w, h, "", NULL, sharedContext);
if(!windowP){
ofLogError("ofxFenster") << "couldn't create GLFW window";
}
#ifdef TARGET_LINUX
// here was some long code (i just didn't copied it in this post)
}
if(!windowP) {
ofLogError("ofxFenster") << "couldn't create window";
return;
}
// ADD this lines (for creating context for the first time)
// if shared still null we make new shared context from current windowP
/*->*/ if (!shared) // shared crash fix
/*->*/ glfwMakeContextCurrent(windowP);
Fix works for me and I hope it would help someone else too.
Best, b