Rudimentary resolution changer, window icon

This commit is contained in:
2016-11-28 19:11:38 +11:00
parent aeeef1a60f
commit eb4b0e1714
6 changed files with 196 additions and 81 deletions
+35 -4
View File
@@ -97,6 +97,14 @@ INTERNAL void scrollCallback(GLFWwindow *window, double xOffset, double yOffset)
{
}
INTERNAL void setGlfwWindowHints()
{
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
}
i32 main(void)
{
/*
@@ -105,10 +113,7 @@ i32 main(void)
**************************
*/
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
setGlfwWindowHints();
i32 windowWidth = 1600;
i32 windowHeight = 900;
@@ -181,6 +186,19 @@ i32 main(void)
glfwSetWindowUserPointer(window, CAST(void *)(gameState));
{
i32 width, height;
char *iconPath = "data/textures/Asteroids/icon.png";
u8 *pixels = asset_imageLoad(&width, &height, NULL, iconPath, FALSE);
if (pixels)
{
GLFWimage image = {width, height, pixels};
glfwSetWindowIcon(window, 1, &image);
asset_imageFree(pixels);
}
}
/*
*******************
* GAME LOOP
@@ -252,6 +270,19 @@ i32 main(void)
}
startTime = endTime;
StartMenuState *menuState =
ASTEROID_GET_STATE_DATA(gameState, StartMenuState);
if (menuState)
{
if (menuState->newResolutionRequest)
{
windowSize = menuState->newResolution;
glfwSetWindowSize(window, (i32)windowSize.w, (i32)windowSize.h);
menuState->newResolutionRequest = FALSE;
}
}
}
glfwTerminate();