aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pugl/pugl_internal.h11
-rw-r--r--pugl/pugl_win.cpp22
-rw-r--r--pugl_test.c34
-rw-r--r--wscript2
4 files changed, 40 insertions, 29 deletions
diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h
index 46e9d9d..05381fa 100644
--- a/pugl/pugl_internal.h
+++ b/pugl/pugl_internal.h
@@ -48,6 +48,9 @@ puglDefaultHints(void)
PuglView*
puglInit(int* pargc, char** argv)
{
+ (void)pargc;
+ (void)argv;
+
PuglView* view = (PuglView*)calloc(1, sizeof(PuglView));
if (!view) {
return NULL;
@@ -210,7 +213,7 @@ puglSetEventFunc(PuglView* view, PuglEventFunc eventFunc)
}
/** Return the code point for buf, or the replacement character on error. */
-static uint32_t
+static inline uint32_t
puglDecodeUTF8(const uint8_t* buf)
{
#define FAIL_IF(cond) { if (cond) return 0xFFFD; }
@@ -223,12 +226,12 @@ puglDecodeUTF8(const uint8_t* buf)
return 0xFFFD;
} else if (buf[0] < 0xE0) {
FAIL_IF((buf[1] & 0xC0) != 0x80);
- return (buf[0] << 6) + buf[1] - 0x3080;
+ return (buf[0] << 6) + buf[1] - 0x3080u;
} else if (buf[0] < 0xF0) {
FAIL_IF((buf[1] & 0xC0) != 0x80);
FAIL_IF(buf[0] == 0xE0 && buf[1] < 0xA0);
FAIL_IF((buf[2] & 0xC0) != 0x80);
- return (buf[0] << 12) + (buf[1] << 6) + buf[2] - 0xE2080;
+ return (buf[0] << 12) + (buf[1] << 6) + buf[2] - 0xE2080u;
} else if (buf[0] < 0xF5) {
FAIL_IF((buf[1] & 0xC0) != 0x80);
FAIL_IF(buf[0] == 0xF0 && buf[1] < 0x90);
@@ -238,7 +241,7 @@ puglDecodeUTF8(const uint8_t* buf)
return ((buf[0] << 18) +
(buf[1] << 12) +
(buf[2] << 6) +
- buf[3] - 0x3C82080);
+ buf[3] - 0x3C82080u);
}
return 0xFFFD;
}
diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp
index 9bc9438..eade22a 100644
--- a/pugl/pugl_win.cpp
+++ b/pugl/pugl_win.cpp
@@ -102,7 +102,7 @@ puglCreateWindow(PuglView* view, const char* title)
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);
- impl->timerFrequency = frequency.QuadPart;
+ impl->timerFrequency = static_cast<double>(frequency.QuadPart);
if (!title) {
title = "Window";
@@ -125,7 +125,7 @@ puglCreateWindow(PuglView* view, const char* title)
return NULL;
}
- int winFlags = view->parent ? WS_CHILD : WS_POPUPWINDOW | WS_CAPTION;
+ unsigned winFlags = view->parent ? WS_CHILD : WS_POPUPWINDOW | WS_CAPTION;
if (view->hints.resizable) {
winFlags |= WS_SIZEBOX;
if (view->min_width || view->min_height) {
@@ -232,7 +232,7 @@ puglDestroy(PuglView* view)
}
static PuglKey
-keySymToSpecial(int sym)
+keySymToSpecial(WPARAM sym)
{
switch (sym) {
case VK_F1: return PUGL_KEY_F1;
@@ -293,14 +293,14 @@ initMouseEvent(PuglEvent* event,
ReleaseCapture();
}
- event->button.time = GetMessageTime();
+ event->button.time = static_cast<uint32_t>(GetMessageTime());
event->button.type = press ? PUGL_BUTTON_PRESS : PUGL_BUTTON_RELEASE;
event->button.x = GET_X_LPARAM(lParam);
event->button.y = GET_Y_LPARAM(lParam);
event->button.x_root = pt.x;
event->button.y_root = pt.y;
event->button.state = getModifiers();
- event->button.button = button;
+ event->button.button = static_cast<uint32_t>(button);
}
static void
@@ -309,7 +309,7 @@ initScrollEvent(PuglEvent* event, PuglView* view, LPARAM lParam, WPARAM)
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
ScreenToClient(view->impl->hwnd, &pt);
- event->scroll.time = GetMessageTime();
+ event->scroll.time = static_cast<uint32_t>(GetMessageTime());
event->scroll.type = PUGL_SCROLL;
event->scroll.x = pt.x;
event->scroll.y = pt.y;
@@ -321,7 +321,7 @@ initScrollEvent(PuglEvent* event, PuglView* view, LPARAM lParam, WPARAM)
}
static uint32_t
-utf16_to_code_point(const wchar_t* input, size_t input_size)
+utf16_to_code_point(const wchar_t* input, const int input_size)
{
uint32_t code_unit = *input;
// Equiv. range check between 0xD800 to 0xDBFF inclusive
@@ -354,13 +354,13 @@ initKeyEvent(PuglEvent* event, PuglView* view, bool press, LPARAM lParam)
ScreenToClient(view->impl->hwnd, &rpos);
event->key.type = press ? PUGL_KEY_PRESS : PUGL_KEY_RELEASE;
- event->key.time = GetMessageTime();
+ event->key.time = static_cast<uint32_t>(GetMessageTime());
event->key.state = getModifiers();
event->key.x_root = rpos.x;
event->key.y_root = rpos.y;
event->key.x = cpos.x;
event->key.y = cpos.y;
- event->key.keycode = (lParam & 0xFF0000) >> 16;
+ event->key.keycode = static_cast<uint32_t>((lParam & 0xFF0000) >> 16);
event->key.character = 0;
event->key.special = static_cast<PuglKey>(0);
event->key.filter = 0;
@@ -413,7 +413,7 @@ translateMessageParamsToEvent(LPARAM, WPARAM wParam, PuglEvent* event)
// So, since Google refuses to give me a better solution, and if no one
// else has a better solution, I will make a hack...
wchar_t buf[5] = { 0, 0, 0, 0, 0 };
- WPARAM c = MapVirtualKey(wParam, MAPVK_VK_TO_CHAR);
+ WPARAM c = MapVirtualKey(static_cast<unsigned>(wParam), MAPVK_VK_TO_CHAR);
buf[0] = c & 0xffff;
// TODO: This does not take caps lock into account
// TODO: Dead keys should affect key releases as well
@@ -497,7 +497,7 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
ClientToScreen(view->impl->hwnd, &pt);
event.motion.type = PUGL_MOTION_NOTIFY;
- event.motion.time = GetMessageTime();
+ event.motion.time = static_cast<uint32_t>(GetMessageTime());
event.motion.x = GET_X_LPARAM(lParam);
event.motion.y = GET_Y_LPARAM(lParam);
event.motion.x_root = pt.x;
diff --git a/pugl_test.c b/pugl_test.c
index 6d5c5c3..a42521a 100644
--- a/pugl_test.c
+++ b/pugl_test.c
@@ -28,12 +28,12 @@
#include <stdio.h>
#include <string.h>
-static int quit = 0;
-static float xAngle = 0.0f;
-static float yAngle = 0.0f;
-static float dist = 10.0f;
-static float lastMouseX = 0.0;
-static float lastMouseY = 0.0;
+static int quit = 0;
+static float xAngle = 0.0f;
+static float yAngle = 0.0f;
+static float dist = 10.0f;
+static double lastMouseX = 0.0;
+static double lastMouseY = 0.0;
static const float cubeVertices[] = {
-1.0f, -1.0f, -1.0f,
@@ -104,6 +104,8 @@ perspective(float* m, float fov, float aspect, float zNear, float zFar)
static void
onReshape(PuglView* view, int width, int height)
{
+ (void)view;
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, width, height);
@@ -116,6 +118,8 @@ onReshape(PuglView* view, int width, int height)
static void
onDisplay(PuglView* view)
{
+ (void)view;
+
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, dist * -1);
@@ -137,6 +141,8 @@ onDisplay(PuglView* view)
static void
printModifiers(PuglView* view, uint32_t mods)
{
+ (void)view;
+
fprintf(stderr, "Modifiers:%s%s%s%s\n",
(mods & PUGL_MOD_SHIFT) ? " Shift" : "",
(mods & PUGL_MOD_CTRL) ? " Ctrl" : "",
@@ -175,8 +181,8 @@ onEvent(PuglView* view, const PuglEvent* event)
event->key.utf8, event->key.filter ? " (filtered)" : "");
break;
case PUGL_MOTION_NOTIFY:
- xAngle = fmodf(xAngle + (event->motion.x - lastMouseX), 360.0f);
- yAngle = fmodf(yAngle + (event->motion.y - lastMouseY), 360.0f);
+ xAngle = fmodf(xAngle + (float)(event->motion.x - lastMouseX), 360.0f);
+ yAngle = fmodf(yAngle + (float)(event->motion.y - lastMouseY), 360.0f);
lastMouseX = event->motion.x;
lastMouseY = event->motion.y;
puglPostRedisplay(view);
@@ -194,7 +200,7 @@ onEvent(PuglView* view, const PuglEvent* event)
fprintf(stderr, "Scroll %f %f %f %f ",
event->scroll.x, event->scroll.y, event->scroll.dx, event->scroll.dy);
printModifiers(view, event->scroll.state);
- dist += event->scroll.dy;
+ dist += (float)event->scroll.dy;
if (dist < 10.0f) {
dist = 10.0f;
}
@@ -274,13 +280,13 @@ main(int argc, char** argv)
puglShowWindow(view);
- const double startTime = puglGetTime(view);
- double lastTime = startTime;
- double lastReportTime = startTime;
- unsigned frames = 0;
+ const float startTime = (float)puglGetTime(view);
+ float lastTime = startTime;
+ float lastReportTime = startTime;
+ unsigned frames = 0;
while (!quit) {
- const double thisTime = puglGetTime(view);
+ const float thisTime = (float)puglGetTime(view);
if (continuous) {
xAngle = fmodf(xAngle + (thisTime - lastTime) * 100.0f, 360.0f);
diff --git a/wscript b/wscript
index 6a8a7d1..31e59ac 100644
--- a/wscript
+++ b/wscript
@@ -42,6 +42,8 @@ def configure(conf):
if conf.env.TARGET_PLATFORM == 'win32':
conf.load('compiler_cxx', cache=True)
+ if conf.env.MSVC_COMPILER:
+ conf.env.append_unique('CXXFLAGS', ['/wd4191'])
elif conf.env.TARGET_PLATFORM == 'darwin':
conf.env.append_unique('CFLAGS', ['-Wno-deprecated-declarations'])