Cleanup and comments

This commit is contained in:
Clownacy 2020-04-01 21:52:18 +01:00
parent 0182ab6eb3
commit db2f079266

View file

@ -30,8 +30,9 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
(void)scancode;
(void)mods;
if (action == GLFW_PRESS)
switch (action)
{
case GLFW_PRESS:
switch (key)
{
case GLFW_KEY_ESCAPE:
@ -115,9 +116,10 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
gbUseJoystick = FALSE;
break;
}
}
else if (action == GLFW_RELEASE)
{
break;
case GLFW_RELEASE:
switch (key)
{
case GLFW_KEY_ESCAPE:
@ -197,6 +199,8 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
gKey &= ~KEY_PLUS;
break;
}
break;
}
}
@ -220,6 +224,7 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
static void DragAndDropCallback(GLFWwindow *window, int count, const char **paths)
{
(void)window;
(void)count;
LoadProfile(paths[0]);
}
@ -247,6 +252,7 @@ void PlatformBackend_PostWindowCreation(void)
BOOL PlatformBackend_GetBasePath(char *string_buffer)
{
// GLFW3 doesn't seem to have a mechanism for this
return FALSE;
}
@ -257,6 +263,7 @@ void PlatformBackend_HideMouse(void)
void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
{
// Convert to RGBA, since that's the only think GLFW3 accepts
unsigned char *rgba_pixels = (unsigned char*)malloc(width * height * 4);
const unsigned char *rgb_pointer = rgb_pixels;
@ -284,6 +291,7 @@ void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int
void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
{
// Convert to RGBA, since that's the only think GLFW3 accepts
unsigned char *rgba_pixels = (unsigned char*)malloc(width * height * 4);
const unsigned char *rgb_pointer = rgb_pixels;
@ -295,7 +303,7 @@ void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int wid
{
for (unsigned int x = 0; x < width; ++x)
{
if (rgb_pointer[0] == 0xFF && rgb_pointer[1] == 0 && rgb_pointer[2] == 0xFF)
if (rgb_pointer[0] == 0xFF && rgb_pointer[1] == 0 && rgb_pointer[2] == 0xFF) // Colour-key
{
*rgba_pointer++ = *rgb_pointer++;
*rgba_pointer++ = *rgb_pointer++;
@ -338,34 +346,12 @@ BOOL PlatformBackend_SystemTask(void)
while (!bActive)
glfwWaitEvents();
/*
while (SDL_PollEvent(NULL) || !bActive)
{
SDL_Event event;
if (!SDL_WaitEvent(&event))
return FALSE;
switch (event.type)
{
case SDL_DROPFILE:
LoadProfile(event.drop.file);
SDL_free(event.drop.file);
break;
case SDL_RENDER_TARGETS_RESET:
Backend_HandleRenderTargetLoss();
break;
}
}
*/
return TRUE;
}
void PlatformBackend_ShowMessageBox(const char *title, const char *message)
{
// GLFW3 doesn't have a message box
printf("ShowMessageBox - '%s' - '%s'\n", title, message);
}
@ -376,5 +362,6 @@ unsigned long PlatformBackend_GetTicks(void)
void PlatformBackend_Delay(unsigned int ticks)
{
// GLFW3 doesn't have a delay function, so here's some butt-ugly C++11
std::this_thread::sleep_for(std::chrono::milliseconds(ticks));
}