Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • gamedev/fggl
  • onuralpsezer/fggl
2 results
Show changes
Commits on Source (101)
Showing
with 174 additions and 87 deletions
*,ogg filter=lfs diff=lfs merge=lfs -text
*.mtl filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.obj filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
......@@ -5,6 +5,9 @@ imgui.ini
.flatpak-builder/
compile_commands.json
# Engine data
demo/data/*.bin
# dotfiles (IDE)
.idea/
.cache/
......
......@@ -26,8 +26,8 @@ variables:
.f34-ogl:
image: git.fossgalaxy.com:8042/gamedev/containers/fedora:36-opengl
before_script:
- dnf install -y pkgconfig\(dri\) pkgconfig\(glu\) pkgconfig\(x11\) pkgconfig\(xcursor\) pkgconfig\(xi\) pkgconfig\(xinerama\) pkgconfig\(xrandr\) doxygen
- dnf install -y glm-devel glfw-devel openal-soft-devel spdlog-devel freetype-devel yaml-cpp-devel assimp-devel bullet-devel gtest-devel gmock-devel
- dnf install -y pkgconfig\(dri\) pkgconfig\(glu\) pkgconfig\(x11\) pkgconfig\(xcursor\) pkgconfig\(xi\) pkgconfig\(xinerama\) pkgconfig\(xrandr\) pkgconfig\(lua\) doxygen
- dnf install -y glm-devel glfw-devel openal-soft-devel spdlog-devel freetype-devel yaml-cpp-devel assimp-devel gtest-devel gmock-devel
##
# Build Targets check it builds on popular Linux Distributions
......@@ -36,7 +36,7 @@ build:fedora:
extends: .f34-ogl
stage: build
script:
- cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
- cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DFGGL_EXT_BULLET=OFF
- cmake --build build
artifacts:
paths:
......@@ -47,9 +47,9 @@ build:ubuntu:
stage: build
before_script:
- apt update && apt install -y build-essential cmake
- apt install -y libglm-dev libglfw3-dev libopenal-dev libspdlog-dev libfreetype-dev libyaml-cpp-dev libassimp-dev libbullet-dev libbullet-extras-dev libgtest-dev libgmock-dev
- apt install -y libglm-dev libglfw3-dev libopenal-dev libspdlog-dev libfreetype-dev libyaml-cpp-dev libassimp-dev libbullet-extras-dev libgtest-dev libgmock-dev liblua5.2-dev
script:
- cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
- cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DFGGL_EXT_BULLET=OFF -DFGGL_EXT_LUA=OFF
- cmake --build build
......
......@@ -8,6 +8,9 @@ option(FGGL_EXAMPLES "Should we build examples or just the library" ON)
option(FGGL_TESTS "Should we enable the testing suite?" ON)
option(FGGL_DOCS "Should we build documentation?" ON)
option(FGGL_EXT_BULLET "Should we build the bullet module?" OFF)
option(FGGL_EXT_LUA "Should we build the lua module?" ON)
##
# Windows
# When on windows, integrate vcpkg
......@@ -31,8 +34,9 @@ project(fggl
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# vendor dependencies
add_subdirectory( vendor/entt )
add_subdirectory( vendor/imgui )
add_subdirectory(vendor/glad)
add_subdirectory( vendor/glad )
# engine headers
file(GLOB_RECURSE public_headers
......@@ -44,9 +48,6 @@ add_subdirectory( fggl )
target_compile_options( fggl PRIVATE -Wall -Wpedantic -Wextra -Wodr -fno-strict-aliasing -fno-strict-overflow )
set_property(TARGET fggl PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
# vendor dependencies
add_subdirectory( integrations/entt )
# Unit Tests
if (FGGL_TESTS)
include(CTest)
......@@ -63,11 +64,25 @@ if (FGGL_DOCS)
endif()
endif()
##
# Optional/Extra modules
##
# 3rd party integrations
if ( FGGL_EXT_BULLET )
add_subdirectory( integrations/bullet )
endif()
if ( FGGL_EXT_LUA )
add_subdirectory( integrations/lua )
endif()
# Tools
# add_subdirectory( tools/pack )
# Demo project
if (FGGL_EXAMPLES)
add_subdirectory(demo)
target_compile_options( demo PRIVATE -Wall -Wextra -Wodr -Wdouble-promotion -fno-strict-aliasing -fno-strict-overflow )
set_property(TARGET demo PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
add_subdirectory(demo EXCLUDE_FROM_ALL)
endif()
##
......@@ -127,6 +142,3 @@ export(EXPORT "${PROJECT_NAME}Targets"
NAMESPACE ${namespace}::
)
# 3rd party integrations
add_subdirectory( integrations/bullet )
......@@ -3,6 +3,7 @@
include(CMakeFindDependencyMacro)
find_dependency(glm)
find_dependency(fmt)
find_dependency(Lua)
find_dependency(spdlog)
find_dependency(Freetype)
find_dependency(OpenAL CONFIG)
......
......@@ -12,6 +12,10 @@ On Ubuntu:
sudo apt install build-essential cmake
sudo apt install -y libglm-dev libglfw3-dev libopenal-dev libspdlog-dev libfreetype-dev libyaml-cpp-dev libassimp-dev libbullet-dev
```
On Fedora:
```bash
sudo dnf install -y glm-devel glfw-devel openal-soft-devel spdlog-devel freetype-devel yaml-cpp-devel assimp-devel bullet-devel gcc gcc-c++ cmake gtest-devel doxygen lua lua-devel gmock gmock-devel
```
### Building
It's designed to be a fairly standard cmake project, so the standard cmake steps should work:
......
......@@ -8,8 +8,15 @@ add_executable(demo
demo/rollball.cpp
demo/topdown.cpp
demo/grid.cpp
demo/robot/programmer.cpp
demo/models/viewer.cpp
demo/hexboard/board.cpp
demo/hexboard/camera.cpp
)
# set build flags
target_compile_options( demo PRIVATE -Wall -Wextra -Wodr -Wdouble-promotion -fno-strict-aliasing -fno-strict-overflow )
set_property(TARGET demo PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
target_include_directories(demo
PRIVATE
......@@ -18,15 +25,22 @@ target_include_directories(demo
target_link_libraries( demo fggl )
#target_link_libraries(demo fggl fgglbt)
if ( FGGL_EXT_LUA )
target_link_libraries( demo fggl-lua )
endif()
find_package(spdlog)
target_link_libraries(demo spdlog::spdlog)
#target_include_directories(FgglDemo PUBLIC ${PROJECT_BINARY_DIR})
# rssources
#find_package(Lua)
#target_link_libraries(demo ${LUA_LIBRARIES})
# resources
file(GLOB_RECURSE data data/*)
file(COPY ${data} DESTINATION data )
include(GNUInstallDirs)
install(
TARGETS demo
RUNTIME
......
packs/
demo/data/backpack/ao.jpg

132 B

source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
demo/data/backpack/diffuse.jpg

132 B

image diff could not be displayed: it is too large. Options to address this: view the blob.
demo/data/backpack/roughness.jpg

132 B

Model by Berk Gedik, from: https://sketchfab.com/3d-models/survival-guitar-backpack-low-poly-799f8c4511f84fab8c3f12887f7e6b36
Modified material assignment (Joey de Vries) for easier load in OpenGL model loading chapter, and renamed albedo to diffuse and metallic to specular to match non-PBR lighting setup.
\ No newline at end of file
demo/data/backpack/specular.jpg

132 B

---
- define: label
attrs:
value: """
- define: button
children:
- template: label
- define: textinput
children:
- template: label
- define: checkbox
attrs:
state: False
- define: radio
attrs:
state: False
- define: frame
......@@ -12,7 +12,7 @@ uniform mat4 model;
void main()
{
gl_Position = view * model * vec4(aPos, 1.0);
gl_Position = view * model * vec4(aPos, 1.0);
mat3 normalMatrix = mat3(transpose(inverse(view * model)));
vs_out.normal = normalize(vec3(vec4(normalMatrix * aNormal, 0.0)));
}
---
# This currently isn't functional, it's an experiment in how this
# might be defined in a user-friendly(ish) way.
prefabs:
wallX:
transform:
staticMesh:
pipeline: phong
shape: # TODO
rigidBody:
type: static
shape:
type: box
extents: [0.5, 2.5, 20.5]
wallZ:
transform:
staticMesh:
pipeline: phong
rigidBody:
type: static
shape:
type: box
extents: [39.0, 2.5, 0.5]
floor:
transform:
staticMesh:
pipeline: phong
shape: # TODO
rigidBody:
type: static
shape: box
extents: [20, 0.5, 20.0]
player:
transform:
rigidBody:
mass: 1
shape:
type: sphere
extents: [0.5, 0.5, 0.5]
dynamics:
staticMesh:
pipeline: phong
shape: # TODO
collectable:
transform:
staticMesh:
shader: phong
shape: # TODO
callbacks:
scene:
entities:
- prefab: wallX
transform:
origin: [20, 0, 0]
- prefab: wallX
transform:
origin: [-20, 0, 0]
- prefab: wallZ
transform: [0, 0, -20]
- prefab: wallZ
transform: [0, 0, 20]
- prefab: floor
transform: [0, -2.5, 0]
- prefab: player
\ No newline at end of file
/**
* OpenGL RedBook Shader.
* Examples 7.8, 7.9 and 7.10.
*
* Reflections are happening in camera space
*/
#version 330 core
in vec4 Position;
in vec3 Normal;
in vec4 Colour;
in Vertex {
vec3 Position;
vec3 Normal;
vec3 Colour;
vec2 TexPos;
};
out vec4 FragColour;
const float constant = 1.0;
const float linear = 0.022;
const float quadratic = 0.0019;
float specPower = 0.5;
const float shininess = 8;
uniform sampler2D diffuseTexture;
uniform sampler2D specularTexture;
uniform mat4 MVMatrix;
uniform vec3 viewerPos_ws;
struct DirectionalLight {
vec3 direction;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
struct Material {
vec3 emission;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
uniform DirectionalLight light;
uniform Material material;
const int hasPos = 0;
vec4 calcDirLight(DirectionalLight light, vec3 Normal, vec3 viewDir, vec4 specPx, vec4 diffPx) {
vec3 lightDir = normalize( ( vec4(light.direction, 1) * MVMatrix).xyz - Position.xyz );
vec4 ambient = 0.1 * vec4( light.ambient, 1);
vec3 reflectDir = reflect( -lightDir, Normal );
float spec = pow( max( dot(viewDir, reflectDir), 0.0), shininess);
vec4 specular = 1.0 * vec4( light.specular, 1) * specPower * (spec * specPx);
float diff = max( dot(Normal, lightDir), 0.0 );
vec4 diffuse = vec4(light.diffuse,1) * (diff * diffPx);
if ( hasPos == 1 ) {
vec3 lightPos = ( vec4(light.direction, 1) * MVMatrix).xyz;
float distance = length( lightPos - Position.xyz );
float att = 1.0 / (constant +
(linear * distance) +
(quadratic * (distance * distance)));
ambient *= att;
diffuse *= att;
specular *= att;
}
return (ambient + diffuse + specular);
}
void main() {
vec3 normalScale = 0.5 + (Normal / 2);
FragColour = vec4(normalScale, 1);
vec3 viewDir = normalize(-Position);
vec4 diffPx = vec4(material.diffuse, 1);
vec4 specPx = vec4(material.specular, 1);
if ( hasPos != 1) {
diffPx *= texture(diffuseTexture, TexPos);
specPx *= texture(specularTexture, TexPos);
}
FragColour = vec4(Colour, 1);
FragColour *= calcDirLight(light, Normal, viewDir, specPx, diffPx);
}
\ No newline at end of file