ofxFenster icon indicating copy to clipboard operation
ofxFenster copied to clipboard

glfwCreateWindow on windows

Open inundaciones opened this issue 11 years ago • 5 comments

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

inundaciones avatar Sep 03 '13 14:09 inundaciones

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

xumo avatar Sep 06 '13 19:09 xumo

glfwCreateContext() call seems to be causing problems. wich is already compliled, so I think I´ll wait for any suggestions.

inundaciones avatar Sep 07 '13 20:09 inundaciones

@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)

sheridanis avatar Sep 13 '13 11:09 sheridanis

I also have this problem, there are solutions?

OS: windows 7 32bit Openframeworks 0.8.0 Visual Studio 2012

yty avatar Dec 26 '13 03:12 yty

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

blazm avatar Apr 23 '14 22:04 blazm