forked from fahim2020/OpenGLFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wobakj
committed
Oct 12, 2016
0 parents
commit 10b31f4
Showing
831 changed files
with
359,191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build | ||
install | ||
*.o | ||
*.sublime-workspace | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
cmake_minimum_required (VERSION 2.8) | ||
# allows access to environment variables with the name | ||
project (OpenGL_Framework) | ||
|
||
#set the build type if its not set | ||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE ) | ||
endif() | ||
|
||
#if user didnt set install dir, override it and write it to the cache -> Type and description necessary, | ||
#overwrite variable, not just write it to cache | ||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install" CACHE STRING "Install path prefix, prepended onto install directories." FORCE) | ||
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
|
||
#before adding libraries, define the output paths | ||
# MSVC & Xcode automatically create the build-type folders | ||
if(MSVC OR CMAKE_GENERATOR STREQUAL Xcode) | ||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}) | ||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}) | ||
else() | ||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE}) | ||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE}) | ||
endif() | ||
|
||
# include glm, as system header to suppress warnings | ||
include_directories(SYSTEM external/glm-0.9.6.3) | ||
|
||
# include stb_image, as system header to suppress warnings | ||
include_directories(SYSTEM external/stb_image-2.0.6) | ||
|
||
# add tinyobjloader | ||
include_directories(external/tinyobjloader-aa07206) | ||
# just one file so it can be directly compiled into main exe | ||
file(GLOB TINYOBJLOADER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/external/tinyobjloader-aa07206/*.cc) | ||
|
||
# configure glfw building | ||
option(GLFW_BUILD_DOCS OFF) | ||
option(GLFW_BUILD_EXAMPLES OFF) | ||
option(GLFW_BUILD_TESTS OFF) | ||
option(GLFW_INSTALL OFF) | ||
|
||
# glfw | ||
# set(BUILD_SHARED_LIBS ${DYNAMIC_LINKING} CACHE BOOL "Build shared libraries" FORCE) | ||
|
||
# add glfw build system | ||
add_subdirectory(external/glfw-3.1.1) | ||
# include glfw headers | ||
include_directories(external/glfw-3.1.1/include) | ||
|
||
# add glbindings | ||
add_subdirectory(external/glbinding-2.1.1) | ||
include_directories(external/glbinding-2.1.1/source/glbinding/include) | ||
|
||
# create framework helper library | ||
file(GLOB FRAMEWORK_SOURCES framework/source/*.cpp) | ||
add_library(framework STATIC ${FRAMEWORK_SOURCES} ${TINYOBJLOADER_SOURCES}) | ||
target_include_directories(framework PUBLIC framework/include) | ||
target_link_libraries(framework glbinding glfw ${GLFW_LIBRARIES}) | ||
|
||
# output executables | ||
include_directories(application/include) | ||
|
||
add_executable(solar_system application/source/application_solar.cpp) | ||
target_link_libraries(solar_system framework) | ||
|
||
# add setting whether examples are build | ||
option(BUILD_EXAMPLES OFF) | ||
|
||
if(BUILD_EXAMPLES) | ||
add_executable(1_fixed application/source/application_fixed.cpp) | ||
target_link_libraries(1_fixed framework) | ||
|
||
add_executable(2_vbo application/source/application_vbo.cpp) | ||
target_link_libraries(2_vbo framework) | ||
|
||
add_executable(3_indexed application/source/application_indexed.cpp) | ||
target_link_libraries(3_indexed framework) | ||
|
||
add_executable(4_shader application/source/application_shader.cpp) | ||
target_link_libraries(4_shader framework) | ||
|
||
add_executable(5_uniform application/source/application_uniform.cpp) | ||
target_link_libraries(5_uniform framework) | ||
|
||
add_executable(6_vao application/source/application_vao.cpp) | ||
target_link_libraries(6_vao framework) | ||
endif() | ||
|
||
# set build type dependent flags | ||
if(UNIX) | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O2") | ||
elseif(MSVC) | ||
set(CMAKE_CXX_FLAGS_RELEASE "/MD /O2") | ||
set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi") | ||
endif() | ||
|
||
# activate C++ 11 | ||
if(NOT MSVC) | ||
add_definitions(-std=c++11) | ||
# show warnings but suppress those caused by glm | ||
add_definitions(-Wall -Wconversion) | ||
# force linking with c++11 lib | ||
if(APPLE) | ||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x") | ||
add_definitions(-stdlib=libc++) | ||
endif() | ||
else() | ||
# build in parallel, show warnings and suppress one caused by glbinding | ||
add_definitions(/MP /W3 /wd4251) | ||
endif() | ||
|
||
# remove external configuration vars from cmake gui | ||
mark_as_advanced(OPTION_SELF_CONTAINED) | ||
mark_as_advanced(GLFW_BUILD_DOCS GLFW_BUILD_TESTS GLFW_INSTALL GLFW_BUILD_EXAMPLES | ||
GLFW_DOCUMENT_INTERNALS GLFW_USE_EGL GLFW_USE_MIR GLFW_USE_WAYLAND GLFW_LIBRARIES | ||
LIB_SUFFIX BUILD_SHARED_LIBS) | ||
|
||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
# installation rules, copy over binaries to bin | ||
# install(TARGETS OpenGLFramework DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## OpenGLFramework | ||
is a small cross-platform framework for learning OpenGL programming | ||
|
||
[Installation](https://github.com/wobakj/OpenGLFramework/wiki/Installation) | ||
|
||
[Troubleshooting](https://github.com/wobakj/OpenGLFramework/wiki/Troubleshooting) | ||
|
||
### Features | ||
* launcher encapsulating window and context management | ||
* example applications for usage of basic OpenGL objects | ||
* png & tga texture loading | ||
* obj model loading | ||
* GLSL shader loading and error checking | ||
* runtime OpenLG error checking | ||
* live shader reloading by pressing _R_ | ||
|
||
### Examples | ||
toggle compilation with cmake option _BUILD_EXAMPLES_ | ||
* **Immediate Mode** - application_fixed.cpp | ||
* **Vertex Buffer Object** - application_vbo.cpp | ||
* **Index Buffer Object** - application_indexed.cpp | ||
* **Shader Program** - application_shader.cpp | ||
* **Shader Uniforms** - application_uniforms.cpp | ||
* **Vertex Array Object** - application_vao.cpp | ||
|
||
### Tested Platforms | ||
* **Linux** - makefile | ||
* **Windows** - MSVC 2013 | ||
* **MacOS** - CLion, XCode, makefile | ||
|
||
### Libraries | ||
* [**GLFW**](http://www.glfw.org/) for window and context creation | ||
* [**glbinding**](https://github.com/cginternals/glbinding) for OpenGL function binding | ||
* [**GLM**](glm.g-truc.net/) for mathematics | ||
* [**tinyobjloader**](http://syoyo.github.io/tinyobjloader/) for model loading | ||
* [**stb_image**](https://github.com/nothings/stb) for image loading | ||
|
||
### License | ||
this framework is licensed undet the GPL v3 | ||
* **GLFW** is licensed under the zlib/libpng license | ||
* **glbinding** is licensed under the MIT license | ||
* **glm** is licensed under the Happy Bunny License (Modified MIT) | ||
* **tinyobjloader** is licensed under 2 clause BSD | ||
* **stb_image** is public domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef APPLICATION_FIXED_HPP | ||
#define APPLICATION_FIXED_HPP | ||
|
||
#include "application.hpp" | ||
|
||
// gpu representation of model | ||
class ApplicationFixed : public Application { | ||
public: | ||
// allocate and initialize objects | ||
ApplicationFixed(std::string const& resource_path); | ||
|
||
// update projection matrix | ||
void updateProjection(); | ||
// draw all objects | ||
void render() const; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef APPLICATION_INDEXED_HPP | ||
#define APPLICATION_INDEXED_HPP | ||
|
||
#include "application.hpp" | ||
|
||
// gpu representation of model | ||
class ApplicationIndexed : public Application { | ||
public: | ||
// allocate and initialize objects | ||
ApplicationIndexed(std::string const& resource_path); | ||
~ApplicationIndexed(); | ||
|
||
// update projection matrix | ||
void updateProjection(); | ||
// draw all objects | ||
void render() const; | ||
|
||
private: | ||
void initializeGeometry(); | ||
// vertex buffer object | ||
GLuint m_vertex_bo; | ||
// index buffer object | ||
GLuint m_index_bo; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef APPLICATION_SHADER_HPP | ||
#define APPLICATION_SHADER_HPP | ||
|
||
#include "application.hpp" | ||
|
||
// gpu representation of model | ||
class ApplicationShader : public Application { | ||
public: | ||
// allocate and initialize objects | ||
ApplicationShader(std::string const& resource_path); | ||
~ApplicationShader(); | ||
|
||
// update projection matrix | ||
void updateProjection(); | ||
// draw all objects | ||
void render() const; | ||
|
||
protected: | ||
void initializeShaderPrograms(); | ||
|
||
GLuint m_program; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef APPLICATION_SOLAR_HPP | ||
#define APPLICATION_SOLAR_HPP | ||
|
||
#include "application.hpp" | ||
#include "model.hpp" | ||
#include "structs.hpp" | ||
|
||
// gpu representation of model | ||
class ApplicationSolar : public Application { | ||
public: | ||
// allocate and initialize objects | ||
ApplicationSolar(std::string const& resource_path); | ||
// free allocated objects | ||
~ApplicationSolar(); | ||
|
||
// update uniform locations and values | ||
void uploadUniforms(); | ||
// update projection matrix | ||
void updateProjection(); | ||
// react to key input | ||
void keyCallback(int key, int scancode, int action, int mods); | ||
// draw all objects | ||
void render() const; | ||
|
||
protected: | ||
void initializeShaderPrograms(); | ||
void initializeGeometry(); | ||
void updateView(); | ||
|
||
// cpu representation of model | ||
model_object planet_object; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef APPLICATION_UNIFORM_HPP | ||
#define APPLICATION_UNIFORM_HPP | ||
|
||
#include "application.hpp" | ||
|
||
#include <glm/gtc/type_precision.hpp> | ||
|
||
// gpu representation of model | ||
class ApplicationUniform : public Application { | ||
public: | ||
// allocate and initialize objects | ||
ApplicationUniform(std::string const& resource_path); | ||
|
||
// update uniform locations and values | ||
void uploadUniforms(); | ||
// update projection matrix | ||
void updateProjection(); | ||
// draw all objects | ||
void render() const; | ||
|
||
protected: | ||
void initializeShaderPrograms(); | ||
// uniform locations | ||
GLint m_ul_model_view; | ||
GLint m_ul_projection; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef APPLICATION_VAO_HPP | ||
#define APPLICATION_VAO_HPP | ||
|
||
#include "application.hpp" | ||
|
||
// gpu representation of model | ||
class ApplicationVao : public Application { | ||
public: | ||
// allocate and initialize objects | ||
ApplicationVao(std::string const& resource_path); | ||
~ApplicationVao(); | ||
|
||
// update uniform locations and values | ||
void uploadUniforms(); | ||
// update projection matrix | ||
void updateProjection(); | ||
// draw all objects | ||
void render() const; | ||
|
||
protected: | ||
void initializeShaderPrograms(); | ||
void initializeGeometry(); | ||
|
||
// vertex array object | ||
GLuint m_vertex_ao; | ||
// vertex buffer object | ||
GLuint m_vertex_bo; | ||
// index buffer object | ||
GLuint m_index_bo; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef APPLICATION_VBO_HPP | ||
#define APPLICATION_VBO_HPP | ||
|
||
#include "application.hpp" | ||
|
||
// gpu representation of model | ||
class ApplicationVbo : public Application { | ||
public: | ||
// allocate and initialize objects | ||
ApplicationVbo(std::string const& resource_path); | ||
~ApplicationVbo(); | ||
|
||
// update projection matrix | ||
void updateProjection(); | ||
// draw all objects | ||
void render() const; | ||
|
||
private: | ||
void initializeGeometry(); | ||
// vertex buffer object | ||
GLuint m_vertex_bo; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.