Code style improvements

This commit is contained in:
Marcel Plch 2018-02-07 00:02:56 +01:00
parent 009ffeafdd
commit 28aef55a81

29
main.c
View file

@ -9,12 +9,11 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
GLFWwindow* window; GLFWwindow* window;
int main( void ) int main(void) {
{
// Initialise GLFW // Initialise GLFW
if( !glfwInit() ) if(!glfwInit()) {
{ fprintf(stderr, "Failed to initialize GLFW\n");
fprintf( stderr, "Failed to initialize GLFW\n" );
getchar(); getchar();
return -1; return -1;
} }
@ -26,13 +25,14 @@ int main( void )
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context // Open a window and create its OpenGL context
window = glfwCreateWindow( 1024, 768, "Tutorial 01", NULL, NULL); window = glfwCreateWindow(1024, 768, "OpenGL Clock", NULL, NULL);
if( window == NULL ){ if (window == NULL) {
fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" ); fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
getchar(); getchar();
glfwTerminate(); glfwTerminate();
return -1; return -1;
} }
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
// Initialize GLEW // Initialize GLEW
@ -49,9 +49,10 @@ int main( void )
// Dark grey background // Dark grey background
glClearColor(0.15f, 0.15f, 0.15f, 0.0f); glClearColor(0.15f, 0.15f, 0.15f, 0.0f);
do{ do {
// Clear the screen. It's not mentioned before Tutorial 02, but it can cause flickering, so it's there nonetheless. // Clear the screen. It's not mentioned before Tutorial 02,
glClear( GL_COLOR_BUFFER_BIT ); // but it can cause flickering, so it's there nonetheless.
glClear(GL_COLOR_BUFFER_BIT);
// Draw nothing, see you in tutorial 2 ! // Draw nothing, see you in tutorial 2 !
@ -60,9 +61,9 @@ int main( void )
glfwSwapBuffers(window); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} // Check if the ESC key was pressed or the window was closed // Check if the ESC key was pressed or the window was closed
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS && } while(glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0 ); glfwWindowShouldClose(window) == 0);
// Close OpenGL window and terminate GLFW // Close OpenGL window and terminate GLFW
glfwTerminate(); glfwTerminate();