Skip to content

Commit

Permalink
graphics: attempt to fix build error on win32
Browse files Browse the repository at this point in the history
gl_api.c++(719): error C2672: 'aw::gl::get_proc': no matching overloaded function found

I suspect this error is due to __stdcall changing the pointer type. To
fix this, I changed get_proc to accept any function pointer.
  • Loading branch information
Hedede committed Apr 6, 2024
1 parent f016374 commit 85c2fd9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 9 additions & 11 deletions graphics/include/aw/graphics/gl/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,27 @@ using GLcharARB = char;
using GLhalfARB = GLushort;
using GLhalf = GLushort;
using GLfixed = GLint;
using GLintptr = ptrdiff_t;
using GLsizeiptr = ptrdiff_t;
using GLintptrARB = ptrdiff_t;
using GLsizeiptrARB = ptrdiff_t;
using GLintptr = aw::ptrdiff_t;
using GLsizeiptr = aw::ptrdiff_t;
using GLintptrARB = aw::ptrdiff_t;
using GLsizeiptrARB = aw::ptrdiff_t;
using GLint64 = aw::i64;
using GLuint64 = aw::u64;
using GLint64EXT = aw::i64;
using GLuint64EXT = aw::u64;
using GLsync = struct __GLsync*;

#if (AW_PLATFORM == AW_PLATFORM_WIN32)
#define APIENTRY __stdcall
#define AWGL_API __stdcall
#else
#define APIENTRY
#define AWGL_API
#endif

#define AWGL_API APIENTRY

struct _cl_context;
struct _cl_event;
using GLDEBUGPROC = void (APIENTRY *)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
using GLDEBUGPROCARB = void (APIENTRY *)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
using GLDEBUGPROCAMD = void (APIENTRY *)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
using GLDEBUGPROC = void (AWGL_API *)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
using GLDEBUGPROCARB = void (AWGL_API *)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
using GLDEBUGPROCAMD = void (AWGL_API *)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);

using GLhalfNV = unsigned short;
using GLvdpauSurfaceNV = GLintptr;
Expand Down
8 changes: 5 additions & 3 deletions graphics/include/aw/graphics/gl/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define aw_gl_loader_h
#include <aw/types/unknown.h>
#include <aw/config.h>
#include <type_traits>
namespace aw {
namespace gl {

Expand Down Expand Up @@ -42,8 +43,9 @@ unknown_fn* get_proc_address(const char* name);
#endif//AW_SUPPORT_PLATFORM_X11

namespace gl {
template <typename R, typename...Args>
void get_proc(R(*& func)(Args...), char const* name)
template <typename Function>
requires std::is_function_v<Function>
void get_proc(Function*& func, char const* name)
{
#if AW_SUPPORT_PLATFORM_APPLE
using apple::get_proc_address;
Expand All @@ -52,7 +54,7 @@ void get_proc(R(*& func)(Args...), char const* name)
#elif AW_SUPPORT_PLATFORM_X11
using glx::get_proc_address;
#endif
func = reinterpret_cast<R(*)(Args...)>( get_proc_address(name) );
func = reinterpret_cast<Function*>( get_proc_address(name) );
};
} // namespace gl
} // namespace aw
Expand Down

0 comments on commit 85c2fd9

Please sign in to comment.