Skip to content

Instantly share code, notes, and snippets.

@diaphore
Last active July 10, 2020 07:41
Show Gist options
  • Select an option

  • Save diaphore/30ecc94ede1814c7dbdcb0d35d119212 to your computer and use it in GitHub Desktop.

Select an option

Save diaphore/30ecc94ede1814c7dbdcb0d35d119212 to your computer and use it in GitHub Desktop.
Unify native entry points and dynamic imports by faking `__imp_*` symbols
#include "glimp.h"
#if defined _WIN32
#include <Windows.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
#define COMMAND(name) __declspec(dllexport) PROC __imp_##name;
#include "glimp.inl"
#pragma clang diagnostic pop
void
glimp_initialize(void)
{
#define COMMAND(name) __imp_##name = wglGetProcAddress(#name);
#include "glimp.inl"
}
#endif // defined _WIN32
#pragma once
#if defined _WIN32
#define GLAPI __declspec(dllimport)
// Prevent the inclusion of <Windows.h>
#if !defined APIENTRY
#define WINAPI __stdcall
#define APIENTRY WINAPI
#endif
#endif // defined _WIN32
#define GL_GLEXT_PROTOTYPES
#include <GL/glcorearb.h>
void glimp_initialize(void);
COMMAND(glCreateBuffers)
COMMAND(glDebugMessageCallback)
COMMAND(glDebugMessageControl)
#undef COMMAND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment