Initial Commit
This commit is contained in:
commit
d69453233f
2 changed files with 99 additions and 0 deletions
27
CMakeLists.txt
Normal file
27
CMakeLists.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
# CMake entry point
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
project (OpenGL_Analog_Clock)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
set(ALL_LIBS
|
||||
${OPENGL_LIBRARY}
|
||||
glfw
|
||||
GLEW
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-DTW_STATIC
|
||||
-DTW_NO_LIB_PRAGMA
|
||||
-DTW_NO_DIRECT3D
|
||||
-DGLEW_STATIC
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
)
|
||||
|
||||
add_executable(clock
|
||||
main.c
|
||||
)
|
||||
|
||||
target_link_libraries(clock
|
||||
${ALL_LIBS}
|
||||
)
|
72
main.c
Normal file
72
main.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
// Include standard headers
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Include GLEW
|
||||
#include <GL/glew.h>
|
||||
|
||||
// Include GLFW
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* window;
|
||||
|
||||
int main( void )
|
||||
{
|
||||
// Initialise GLFW
|
||||
if( !glfwInit() )
|
||||
{
|
||||
fprintf( stderr, "Failed to initialize GLFW\n" );
|
||||
getchar();
|
||||
return -1;
|
||||
}
|
||||
|
||||
glfwWindowHint(GLFW_SAMPLES, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
// Open a window and create its OpenGL context
|
||||
window = glfwCreateWindow( 1024, 768, "Tutorial 01", NULL, 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" );
|
||||
getchar();
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
// Initialize GLEW
|
||||
if (glewInit() != GLEW_OK) {
|
||||
fprintf(stderr, "Failed to initialize GLEW\n");
|
||||
getchar();
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Ensure we can capture the escape key being pressed below
|
||||
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
|
||||
|
||||
// Dark grey background
|
||||
glClearColor(0.15f, 0.15f, 0.15f, 0.0f);
|
||||
|
||||
do{
|
||||
// Clear the screen. It's not mentioned before Tutorial 02, but it can cause flickering, so it's there nonetheless.
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Draw nothing, see you in tutorial 2 !
|
||||
|
||||
|
||||
// Swap buffers
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
|
||||
} // Check if the ESC key was pressed or the window was closed
|
||||
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
|
||||
glfwWindowShouldClose(window) == 0 );
|
||||
|
||||
// Close OpenGL window and terminate GLFW
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in a new issue