0

I'm writing a Texture class to wrap details of OpenGL, and make it as a dll.
There are a lot of const define in OpenGL, like this.

/* TextureMinFilter */
/*      GL_NEAREST */
/*      GL_LINEAR */
#define GL_NEAREST_MIPMAP_NEAREST         0x2700
#define GL_LINEAR_MIPMAP_NEAREST          0x2701
#define GL_NEAREST_MIPMAP_LINEAR          0x2702
#define GL_LINEAR_MIPMAP_LINEAR           0x2703

I want to wrap them by enum class, like this.

    enum class Filter
    {
        Nearest = GL_NEAREST,
        Linear = GL_LINEAR,
        NearestMipmapNearest = GL_NEAREST_MIPMAP_NEAREST,
        LinearMipmapNearest = GL_LINEAR_MIPMAP_NEAREST,
        NearestMipmapLinear = GL_NEAREST_MIPMAP_LINEAR,
        LinearMipmapLinear = GL_LINEAR_MIPMAP_LINEAR
    };

There is a problem, if I put the enum class in header file, I need to include 3rd OpenGL header when I use my dll.
So I use enum class forward declaration in header and put the definition in cpp file.

// Texture.h
enum class Filter;

But in this case, Compiler can not found members of the enum class when I use enum class out of the cpp file.

Like this problem

How can I wrap them?

Squid
  • 1
  • 1
  • 1
    `extern const int FilterNearest;`? (possibly in "static" class). – Jarod42 Apr 27 '21 at 08:51
  • Working with third party code is always a mess, if possible at all, just use the library instead of fighting it, otherwise, you can extract parts of the library by copying it into your project or do some workaround like @Jarod42 suggested. – asynts Apr 27 '21 at 09:35

0 Answers0