wjakob / nanogui

Minimalistic GUI library for OpenGL
Other
4.66k stars 608 forks source link

Opengl calls in application cause GL_INVALID_OPERATION #50

Closed dupred16 closed 8 years ago

dupred16 commented 8 years ago

Pretty simple to test, I was having trouble integrating nanogui in my application, any OpenGL calls I make in my app cause an invalid operation. I worked in it a while on my end, but got nowhere. So, I simply went down into example1.cpp and added

  virtual void drawContents() {
        using namespace nanogui;

        /* Draw the window contents using OpenGL */
        mShader.bind();

        Matrix4f mvp;
        mvp.setIdentity();
        mvp.topLeftCorner<3,3>() = Matrix3f(Eigen::AngleAxisf((float) glfwGetTime(),  Vector3f::UnitZ())) * 0.25f;

        mvp.row(0) *= (float) mSize.y() / (float) mSize.x();

        mShader.setUniform("modelViewProj", mvp);

        /* Draw 2 triangles starting at index 0 */
        mShader.drawIndexed(GL_TRIANGLES, 0, 2);

      GLenum glErr = glGetError();  // Clear any errors.
        glRenderMode(GL_RENDER); // Set state.
        glErr = glGetError();   // Get error

        if (glErr) {
            std::cout << "OpenGL Error: " << glErr << std::endl;
        }
    }

So, if you run you will get a bunch of 1282 errors, GL_INVALID_OPERATION.

wjakob commented 8 years ago

Simple answer: you're using functionality that has been deprecated and is not available in an OpenGL 3.3 core profile. You'll have to fork the project and modify the default profile if you want to use a backwards-compatible context.