Jeremy
Jeremy

Reputation: 13

Declaring important oglplus objects throws the exception oglplus::MissingFunction

I want to create C++ programs using OpenGL with the C++ OpenGL wrapper library oglplus, but I can't get programs using oglplus to run because when I declare certain oglplus objects the oglplus::MissingFunction exception is always thrown.

My OS is archlinux.

My programs compile but don't run. For example:

#include <cassert>
#include <iostream>

#include <GL/glew.h>
#include <GL/glut.h>

#include <oglplus/all.hpp>

int main()
{
    oglplus::VertexShader vs;   
    return 0;
}

This program compiles, but when I run it, the exception oglplus::MissingFunction is thrown.

Since my programs compile, I believe this means I have the necessary packages installed and have the correct libraries linked. I just don't understand why the exception is being thrown. The description of the exception says that the occurrence of it being thrown means that some pointers used to call OpenGL functions are uninitialized.

So far I've observed oglplus::MissingFunction being thrown when I declare objects of types:

Any suggestions as to how to solve this problem?

Upvotes: 1

Views: 67

Answers (1)

kloffy
kloffy

Reputation: 2928

Before you can use any OpenGL resources, you need to create an OpenGL context. This example shows how to set up a context using GLUT:

https://github.com/matus-chochlik/oglplus/blob/develop/example/standalone/001_hello_glut_glew.cpp

Essentially, you need this part:

#include <iostream>

#include <GL/glew.h>
#include <GL/glut.h>

#include <oglplus/all.hpp>

int main(int argc, char* argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);

    GLint width = 800;
    GLint height = 150;

    glutInitWindowSize(width, height);
    glutInitWindowPosition(100,100);
    glutCreateWindow("OGLplus+GLUT+GLEW");

    if(glewInit() == GLEW_OK) try
    {
        // Your code goes here.

        return 0;
    }
    catch(oglplus::Error& err)
    {
        std::cerr << "OGLPlus error." << std::endl;
    }

    return 1;
}

Upvotes: 2

Related Questions