dimanche 12 juin 2016

'GLEWContext does not name a type' error on ubuntu


I am trying to port a glew_mx project from windows to ubuntu but I always get errors because of GLEWContext being undefined.

error: ‘GLEWContext’ does not name a type

I know that I dont really need GLEWContext on linux but nevertheless I have to define

GLEWContext* glewGetContext();

in order to compile my project. So I created a global GLEWContext and simply return it in glewGetContext.
My window.h code looks like this:

#pragma once
#define GLEW_MX
#define GLEW_STATIC
#include "GL/glew.h"
#include "GLFW/glfw3.h"
#define GLM_SWIZZLE
#include "glm/glm.hpp"
#include "glm/ext.hpp"

#ifdef _WIN32
#define CONTEXT_PREFIX  window
#else
#define CONTEXT_PREFIX 
#endif

namespace window
{
    class Window
    {
    public:   
        Window() {}
        ~Window() {}

        //...

#ifdef _WIN32
        static void makeContextCurrent(Window* window_handle);
#endif
        static Window* createWindow(int win_width, int win_height, const std::string& title, GLFWmonitor* monitor, Window* share);

        GLFWwindow* window;
#ifdef _WIN32
        GLEWContext* glew_context;
#endif
        //...

    private:
        //...
    };

    GLEWContext* glewGetContext();
#ifdef _WIN32
    //...
#else
    GLEWContext* glew_context;
#endif
}

And the code in window.cpp looks like this:

#ifdef _WIN32
GLEWContext* window::glewGetContext()
{
    //...
}
#else
GLEWContext* window::glewGetContext()
{
    return glew_context;
}
#endif

The error occurs while compiling the last two lines in window.h Many thanks for your help


Aucun commentaire:

Enregistrer un commentaire