Cleanup and comments
This commit is contained in:
parent
0182ab6eb3
commit
db2f079266
1 changed files with 140 additions and 153 deletions
|
@ -30,8 +30,9 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
||||||
(void)scancode;
|
(void)scancode;
|
||||||
(void)mods;
|
(void)mods;
|
||||||
|
|
||||||
if (action == GLFW_PRESS)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
case GLFW_PRESS:
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case GLFW_KEY_ESCAPE:
|
case GLFW_KEY_ESCAPE:
|
||||||
|
@ -115,9 +116,10 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
||||||
gbUseJoystick = FALSE;
|
gbUseJoystick = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (action == GLFW_RELEASE)
|
break;
|
||||||
{
|
|
||||||
|
case GLFW_RELEASE:
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case GLFW_KEY_ESCAPE:
|
case GLFW_KEY_ESCAPE:
|
||||||
|
@ -197,6 +199,8 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
||||||
gKey &= ~KEY_PLUS;
|
gKey &= ~KEY_PLUS;
|
||||||
break;
|
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)
|
static void DragAndDropCallback(GLFWwindow *window, int count, const char **paths)
|
||||||
{
|
{
|
||||||
(void)window;
|
(void)window;
|
||||||
|
(void)count;
|
||||||
|
|
||||||
LoadProfile(paths[0]);
|
LoadProfile(paths[0]);
|
||||||
}
|
}
|
||||||
|
@ -247,6 +252,7 @@ void PlatformBackend_PostWindowCreation(void)
|
||||||
|
|
||||||
BOOL PlatformBackend_GetBasePath(char *string_buffer)
|
BOOL PlatformBackend_GetBasePath(char *string_buffer)
|
||||||
{
|
{
|
||||||
|
// GLFW3 doesn't seem to have a mechanism for this
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +263,7 @@ void PlatformBackend_HideMouse(void)
|
||||||
|
|
||||||
void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
|
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);
|
unsigned char *rgba_pixels = (unsigned char*)malloc(width * height * 4);
|
||||||
|
|
||||||
const unsigned char *rgb_pointer = rgb_pixels;
|
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)
|
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);
|
unsigned char *rgba_pixels = (unsigned char*)malloc(width * height * 4);
|
||||||
|
|
||||||
const unsigned char *rgb_pointer = rgb_pixels;
|
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)
|
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++;
|
||||||
*rgba_pointer++ = *rgb_pointer++;
|
*rgba_pointer++ = *rgb_pointer++;
|
||||||
|
@ -338,34 +346,12 @@ BOOL PlatformBackend_SystemTask(void)
|
||||||
while (!bActive)
|
while (!bActive)
|
||||||
glfwWaitEvents();
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_ShowMessageBox(const char *title, const char *message)
|
void PlatformBackend_ShowMessageBox(const char *title, const char *message)
|
||||||
{
|
{
|
||||||
|
// GLFW3 doesn't have a message box
|
||||||
printf("ShowMessageBox - '%s' - '%s'\n", title, message);
|
printf("ShowMessageBox - '%s' - '%s'\n", title, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,5 +362,6 @@ unsigned long PlatformBackend_GetTicks(void)
|
||||||
|
|
||||||
void PlatformBackend_Delay(unsigned int ticks)
|
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));
|
std::this_thread::sleep_for(std::chrono::milliseconds(ticks));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue