mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Merge branch 'master' of https://github.com/JoeyDeVries/LearnOpenGL
This commit is contained in:
@@ -131,6 +131,8 @@ foreach(CHAPTER ${CHAPTERS})
|
|||||||
target_link_libraries(${DEMO} ${LIBS})
|
target_link_libraries(${DEMO} ${LIBS})
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set_target_properties(${DEMO} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}")
|
set_target_properties(${DEMO} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}")
|
||||||
|
elseif(UNIX)
|
||||||
|
set_target_properties(${DEMO} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin/${CHAPTER}")
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
# copy shader files to build directory
|
# copy shader files to build directory
|
||||||
file(GLOB SHADERS
|
file(GLOB SHADERS
|
||||||
@@ -143,7 +145,7 @@ foreach(CHAPTER ${CHAPTERS})
|
|||||||
# configure_file(${SHADER} "test")
|
# configure_file(${SHADER} "test")
|
||||||
add_custom_command(TARGET ${DEMO} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SHADER} $<TARGET_FILE_DIR:${DEMO}>)
|
add_custom_command(TARGET ${DEMO} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SHADER} $<TARGET_FILE_DIR:${DEMO}>)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
file(COPY ${SHADER} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
file(COPY ${SHADER} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin/${CHAPTER})
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
endforeach(SHADER)
|
endforeach(SHADER)
|
||||||
@@ -155,8 +157,3 @@ foreach(CHAPTER ${CHAPTERS})
|
|||||||
endforeach(CHAPTER)
|
endforeach(CHAPTER)
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/includes)
|
include_directories(${CMAKE_SOURCE_DIR}/includes)
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
endif(UNIX)
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ Note that you still have to manually copy the required .DLL files from the /dlls
|
|||||||
|
|
||||||
## Linux building
|
## Linux building
|
||||||
First make sure you have CMake, Git, and GCC by typing as root (sudo) `apt-get install g++ cmake git` and then get the required packages:
|
First make sure you have CMake, Git, and GCC by typing as root (sudo) `apt-get install g++ cmake git` and then get the required packages:
|
||||||
Using root (sudo) and type `apt-get install libsoil-dev libglm-dev libassimp-dev libglew-dev libglfw3-dev`
|
Using root (sudo) and type `apt-get install libsoil-dev libglm-dev libassimp-dev libglew-dev libglfw3-dev` . Next, run CMake (preferably CMake-gui). The source directory is LearnOpenGL and specify the build directory as LearnOpenGL/build. Creating the build directory within LearnOpenGL is important for linking to the resource files (it also will be ignored by Git). Hit configure and specify your compiler files (Unix Makefiles are recommended), resolve any missing directories or libraries, and then hit generate. Navigate to the build directory (`cd LearnOpenGL/build`) and type `make` in the terminal. This should generate the executables in the respective chapter folders. Note that using CodeBlocks or an IDE may have issues running the programs due to problems finding the shader and resource files, however it should still be able to generate the exectuables.
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
// Properties
|
// Properties
|
||||||
GLuint screenWidth = 800, screenHeight = 600;
|
GLuint screenWidth = 800, screenHeight = 600;
|
||||||
|
|
||||||
|
bool keys[1024];
|
||||||
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||||
|
|
||||||
// The MAIN function, from here we start our application and run our Game loop
|
// The MAIN function, from here we start our application and run our Game loop
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -27,6 +30,9 @@ int main()
|
|||||||
// Options
|
// Options
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
|
|
||||||
|
// Set the required callback functions
|
||||||
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
// Initialize GLEW to setup the OpenGL Function pointers
|
// Initialize GLEW to setup the OpenGL Function pointers
|
||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
glewInit();
|
glewInit();
|
||||||
@@ -81,3 +87,15 @@ int main()
|
|||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Is called whenever a key is pressed/released via GLFW
|
||||||
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
|
||||||
|
{
|
||||||
|
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||||
|
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||||
|
|
||||||
|
if(action == GLFW_PRESS)
|
||||||
|
keys[key] = true;
|
||||||
|
else if(action == GLFW_RELEASE)
|
||||||
|
keys[key] = false;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user