From f30962b944e4045a572ee0cf5e34d76b668a1fe8 Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 10 Apr 2017 10:00:34 +0800 Subject: [PATCH] Use lambda to workaround __stdcall issue --- src/graphics/irr_driver.cpp | 16 +++++++++++----- src/recorder/openglrecorder.h | 5 +++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index da9b13e9b..558087e69 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -624,11 +624,17 @@ void IrrDriver::initDevice() "RecorderConfig is invalid, use the default one."); } - ogrRegReadPixelsFunction((ogrFucReadPixels)glReadPixels); - ogrRegPBOFunctions((ogrFucGenBuffers)glGenBuffers, - (ogrFucBindBuffer)glBindBuffer, (ogrFucBufferData)glBufferData, - (ogrFucDeleteBuffers)glDeleteBuffers, (ogrFucMapBuffer)glMapBuffer, - (ogrFucUnmapBuffer)glUnmapBuffer); + ogrRegReadPixelsFunction([] + (int x, int y, int w, int h, unsigned int f, unsigned int t, void* d) + { glReadPixels(x, y, w, h, f, t, d); }); + + ogrRegPBOFunctions([](int n, unsigned int* b) { glGenBuffers(n, b); }, + [](unsigned int t, unsigned int b) { glBindBuffer(t, b); }, + [](unsigned int t, ptrdiff_t s, const void* d, unsigned int u) + { glBufferData(t, s, d, u); }, + [](int n, const unsigned int* b) { glDeleteBuffers(n, b); }, + [](unsigned int t, unsigned int a) { return glMapBuffer(t, a); }, + [](unsigned int t) { return glUnmapBuffer(t); }); ogrRegGeneralCallback(OGR_CBT_START_RECORDING, [] (void* user_data) { MessageQueue::add diff --git a/src/recorder/openglrecorder.h b/src/recorder/openglrecorder.h index 34c78d522..884d48574 100644 --- a/src/recorder/openglrecorder.h +++ b/src/recorder/openglrecorder.h @@ -167,10 +167,11 @@ typedef void(*ogrFucReadPixels)(int, int, int, int, unsigned int, unsigned int, void*); typedef void(*ogrFucGenBuffers)(int, unsigned int*); typedef void(*ogrFucBindBuffer)(unsigned int, unsigned int); -typedef void(*ogrFucBufferData)(unsigned int, ptrdiff_t, const void*, unsigned int); +typedef void(*ogrFucBufferData)(unsigned int, ptrdiff_t, const void*, + unsigned int); typedef void(*ogrFucDeleteBuffers)(int, const unsigned int*); typedef void*(*ogrFucMapBuffer)(unsigned int, unsigned int); -typedef void(*ogrFucUnmapBuffer)(unsigned int); +typedef unsigned char(*ogrFucUnmapBuffer)(unsigned int); #ifdef __cplusplus extern "C"