Commit d1adbf84 authored by Philip Trettner's avatar Philip Trettner
Browse files

Ported GLFW adapter to GLFW 3

parent a2263871
Pipeline #1557 skipped
...@@ -43,3 +43,10 @@ target_compile_options(AntTweakBar PUBLIC ...@@ -43,3 +43,10 @@ target_compile_options(AntTweakBar PUBLIC
) )
target_include_directories(AntTweakBar PUBLIC include) target_include_directories(AntTweakBar PUBLIC include)
#target_link_libraries(AntTweakBar PRIVATE GL)
if (UNIX)
target_compile_definitions(AntTweakBar PUBLIC _UNIX)
target_link_libraries(AntTweakBar PRIVATE X11)
endif()
...@@ -303,22 +303,14 @@ TW_API int TW_CALL TwEventSDL(const void *sdlEvent, unsigned char sdlMajorV ...@@ -303,22 +303,14 @@ TW_API int TW_CALL TwEventSDL(const void *sdlEvent, unsigned char sdlMajorV
// For GLFW event callbacks // For GLFW event callbacks
// You should define GLFW_CDECL before including AntTweakBar.h if your version of GLFW uses cdecl calling convensions // You should define GLFW_CDECL before including AntTweakBar.h if your version of GLFW uses cdecl calling convensions
#ifdef GLFW_CDECL #ifdef GLFW_CDECL
TW_API int TW_CDECL_CALL TwEventMouseButtonGLFWcdecl(int glfwButton, int glfwAction); #error NOT SUPPORTED ANYMORE
TW_API int TW_CDECL_CALL TwEventKeyGLFWcdecl(int glfwKey, int glfwAction);
TW_API int TW_CDECL_CALL TwEventCharGLFWcdecl(int glfwChar, int glfwAction);
TW_API int TW_CDECL_CALL TwEventMousePosGLFWcdecl(int mouseX, int mouseY);
TW_API int TW_CDECL_CALL TwEventMouseWheelGLFWcdecl(int wheelPos);
# define TwEventMouseButtonGLFW TwEventMouseButtonGLFWcdecl
# define TwEventKeyGLFW TwEventKeyGLFWcdecl
# define TwEventCharGLFW TwEventCharGLFWcdecl
# define TwEventMousePosGLFW TwEventMousePosGLFWcdecl
# define TwEventMouseWheelGLFW TwEventMouseWheelGLFWcdecl
#else #else
TW_API int TW_CALL TwEventMouseButtonGLFW(int glfwButton, int glfwAction); struct GLFWwindow;
TW_API int TW_CALL TwEventKeyGLFW(int glfwKey, int glfwAction); TW_API int TW_CALL TwEventMouseButtonGLFW(struct GLFWwindow* window, int glfwButton, int glfwAction, int glfwModifier);
TW_API int TW_CALL TwEventCharGLFW(int glfwChar, int glfwAction); TW_API int TW_CALL TwEventKeyGLFW(struct GLFWwindow* window, int glfwKey, int glfwScanCode, int glfwAction, int glfwMods);
# define TwEventMousePosGLFW TwMouseMotion TW_API int TW_CALL TwEventCharGLFW(struct GLFWwindow* window, unsigned int glfwChar);
# define TwEventMouseWheelGLFW TwMouseWheel TW_API int TW_CALL TwEventMousePosGLFW(struct GLFWwindow* window, double x, double y);
TW_API int TW_CALL TwEventMouseWheelGLFW(struct GLFWwindow* window, double x, double y);
#endif #endif
// For GLUT event callbacks (Windows calling convention for GLUT callbacks is cdecl) // For GLUT event callbacks (Windows calling convention for GLUT callbacks is cdecl)
......
...@@ -18,8 +18,17 @@ ...@@ -18,8 +18,17 @@
#include <AntTweakBar.h> #include <AntTweakBar.h>
int TW_CALL TwEventMousePosGLFW(struct GLFWwindow* window, double x, double y)
{
return TwMouseMotion((int)x, (int)y);
}
int TW_CALL TwEventMouseWheelGLFW(struct GLFWwindow* window, double x, double y)
{
return TwMouseWheel((int)y);
}
int TW_CALL TwEventMouseButtonGLFW(int glfwButton, int glfwAction) int TW_CALL TwEventMouseButtonGLFW(struct GLFWwindow* window, int glfwButton, int glfwAction, int glfwModifier)
{ {
int handled = 0; int handled = 0;
TwMouseAction action = (glfwAction==GLFW_PRESS) ? TW_MOUSE_PRESSED : TW_MOUSE_RELEASED; TwMouseAction action = (glfwAction==GLFW_PRESS) ? TW_MOUSE_PRESSED : TW_MOUSE_RELEASED;
...@@ -38,7 +47,7 @@ int TW_CALL TwEventMouseButtonGLFW(int glfwButton, int glfwAction) ...@@ -38,7 +47,7 @@ int TW_CALL TwEventMouseButtonGLFW(int glfwButton, int glfwAction)
int g_KMod = 0; int g_KMod = 0;
int TW_CALL TwEventKeyGLFW(int glfwKey, int glfwAction) int TW_CALL TwEventKeyGLFW(struct GLFWwindow* window, int glfwKey, int glfwScanCode, int glfwAction, int glfwMods)
{ {
int handled = 0; int handled = 0;
...@@ -181,32 +190,13 @@ int TW_CALL TwEventKeyGLFW(int glfwKey, int glfwAction) ...@@ -181,32 +190,13 @@ int TW_CALL TwEventKeyGLFW(int glfwKey, int glfwAction)
} }
int TW_CALL TwEventCharGLFW(int glfwChar, int glfwAction) int TW_CALL TwEventCharGLFW(struct GLFWwindow* window, unsigned int glfwChar)
{ {
if( glfwAction==GLFW_PRESS && (glfwChar & 0xff00)==0 ) if( (glfwChar & 0xff00)==0 )
return TwKeyPressed(glfwChar, g_KMod); return TwKeyPressed(glfwChar, g_KMod);
return 0; return 0;
} }
// functions with __cdecl calling convension // functions with __cdecl calling convension
TW_API int TW_CDECL_CALL TwEventMouseButtonGLFWcdecl(int glfwButton, int glfwAction) // NOT SUPPORTED ANYMORE
{
return TwEventMouseButtonGLFW(glfwButton, glfwAction);
}
TW_API int TW_CDECL_CALL TwEventKeyGLFWcdecl(int glfwKey, int glfwAction)
{
return TwEventKeyGLFW(glfwKey, glfwAction);
}
TW_API int TW_CDECL_CALL TwEventCharGLFWcdecl(int glfwChar, int glfwAction)
{
return TwEventCharGLFW(glfwChar, glfwAction);
}
TW_API int TW_CDECL_CALL TwEventMousePosGLFWcdecl(int mouseX, int mouseY)
{
return TwMouseMotion(mouseX, mouseY);
}
TW_API int TW_CDECL_CALL TwEventMouseWheelGLFWcdecl(int wheelPos)
{
return TwMouseWheel(wheelPos);
}
...@@ -6450,7 +6450,8 @@ static XErrorHandler s_PrevErrorHandler = NULL; ...@@ -6450,7 +6450,8 @@ static XErrorHandler s_PrevErrorHandler = NULL;
static int InactiveErrorHandler(Display *display, XErrorEvent *err) static int InactiveErrorHandler(Display *display, XErrorEvent *err)
{ {
fprintf(stderr, "Ignoring Xlib error: error code %d request code %d\n", err->error_code, err->request_code); // THESE ERRORS JUST SPAM THE CONSOLE
// fprintf(stderr, "Ignoring Xlib error: error code %d request code %d\n", err->error_code, err->request_code);
// No exit! // No exit!
return 0 ; return 0 ;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment