这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
36a3238
buildsystem: inotify package search name lowercased
TheJJ Apr 19, 2015
16aea56
buildsystem: implemented vulkan cmake module
TheJJ Apr 19, 2015
7880ff0
buildsystem: integrated vulkan and opengl detection
TheJJ Apr 19, 2015
f36e375
renderer: modular render window and context creation
TheJJ Apr 20, 2015
4b745d2
renderer: legacy opengl square rendering
TheJJ Jun 25, 2015
5ed8d71
renderer: initial generic texture implementation
TheJJ Jun 29, 2015
46049a8
renderer: rendering quad with opengl 3.3
TheJJ Jun 29, 2015
d1aafcf
renderer: texture and shader creation abstractions
TheJJ Aug 10, 2015
cb9ff46
util: modernized whole file reading
TheJJ Aug 11, 2015
912580a
renderer: use the full framebuffer for the test quad
TheJJ Aug 11, 2015
d94e1b3
renderer: implemented loading shaders from file
TheJJ Aug 11, 2015
006f9fd
watch: created new file watching subsystem
TheJJ Aug 12, 2015
f3b1edb
assetmanager: use new file watching subsystem
TheJJ Aug 12, 2015
e30b151
renderer: initially integrated into the engine
TheJJ Aug 12, 2015
bc19ac9
renderer: renamed pipeline Program to RawProgram
TheJJ Aug 13, 2015
d340348
renderer: moved program api contents to separate files
TheJJ Aug 13, 2015
b783458
renderer: initial pipeline variable abstraction
TheJJ Aug 25, 2015
89210b0
error: always collect backtrace information
TheJJ Sep 15, 2015
4a63a69
renderer: demo id selection via cython
TheJJ Sep 15, 2015
22162c0
renderer: first successful texture draw
TheJJ Sep 15, 2015
3c4e93a
renderer: basic uniform variable abstraction
TheJJ Sep 16, 2015
e0afef1
renderer: implemented vertex attribute packing and uploading
TheJJ Sep 18, 2015
7a24057
datastructure: implemented constexpr key-value map
TheJJ Sep 19, 2015
2cce2cc
renderer: drawing texture with pipeline abstraction
TheJJ Sep 20, 2015
b6c0089
util: implemented quaternion
TheJJ Sep 23, 2015
8446bd5
renderer: made error checking context-dependent
TheJJ Oct 2, 2015
88e7393
renderer: only upload gpu buffer when changed.
TheJJ Oct 21, 2015
459d735
renderer: towards render tasks by storing uniform state
TheJJ Nov 5, 2015
2ec7544
renderer: opengl version checking
Vtec234 Nov 8, 2016
b380899
misc: add YouCompleteMe metadata to .gitignore and add self to authors
Vtec234 Nov 8, 2016
880fdb8
engine: adjust new upstream changes to renderer branch changes
Vtec234 Nov 8, 2016
47c89b0
build: fix build on GCC 5.3.0 Gentoo Linux
Vtec234 Nov 8, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ Makefile
callgrind.out.*
perf.data*
.gdb_history
.ycm_extra_conf.py
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,24 @@ if(NOT DEFINED WANT_INOTIFY)
set(WANT_INOTIFY if_available)
endif()

if(NOT DEFINED WANT_OPENGL)
set(WANT_OPENGL if_available)
endif()

if(NOT DEFINED WANT_VULKAN)
set(WANT_VULKAN if_available)
endif()

if(NOT DEFINED WANT_GPERFTOOLS_PROFILER)
set(WANT_GPERFTOOLS_PROFILER if_available)
endif()

if(NOT DEFINED WANT_GPERFTOOLS_TCMALLOC)
set(WANT_GPERFTOOLS_TCMALLOC false)
endif()
# -- options

# set cmake paths
set(BUILDSYSTEM_DIR "${CMAKE_SOURCE_DIR}/buildsystem")
set(CMAKE_MODULE_PATH "${BUILDSYSTEM_DIR}" "${BUILDSYSTEM_DIR}/modules/")

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Technology | Component
**Python3** | Scripting, media conversion, in-game console, code generation
**Cython** | Glue code
**CMake** | Build system
**OpenGL2.1** | Rendering, shaders
**OpenGL3.3** | Rendering, shaders
**SDL2** | Cross-platform Audio/Input/Window handling
**Opus** | Audio codec
**Humans** | Mixing together all of the above
Expand Down
4 changes: 2 additions & 2 deletions buildsystem/modules/FindInotify.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2014-2014 the openage authors. See copying.md for legal info.
# Copyright 2014-2015 the openage authors. See copying.md for legal info.

# This module defines
#
Expand All @@ -8,6 +8,6 @@
find_path(INOTIFY_INCLUDE_DIR sys/inotify.h HINTS /usr/include/${CMAKE_LIBRARY_ARCHITECTURE})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(INOTIFY DEFAULT_MSG INOTIFY_INCLUDE_DIR)
find_package_handle_standard_args(inotify DEFAULT_MSG INOTIFY_INCLUDE_DIR)

mark_as_advanced(INOTIFY_INCLUDE_DIR)
50 changes: 50 additions & 0 deletions buildsystem/modules/FindVulkan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2015-2015 the openage authors. See copying.md for legal info.
#
# (To distribute this file outside of openage, extend the above
# copyright line with an appropriate GPLv3 or later reference,
# as you probably don't have a our copying.md)


#=================================================================
# Locate Vulkan graphics library
#
# usage:
# find_package(Vulkan)
#
# This module sets the following variables:
# VULKAN_FOUND True, if the system has Vulkan.
# VULKAN_INCLUDE_DIR Path to the Vulkan include directory.
# VULKAN_LIBRARIES Paths to the Vulkan libraries.
#=================================================================

set(_Vulkan_REQUIRED_VARS "VULKAN_vk_LIBRARY" "VULKAN_INCLUDE_DIR")

find_path(VULKAN_INCLUDE_DIR
VK/vk.h
/opt/graphics/Vulkan/include
)

find_library(VULKAN_vk_LIBRARY
NAMES VK Vulkan
PATHS
/opt/graphics/Vulkan/lib
)

if(VULKAN_vk_LIBRARY)
set(VULKAN_LIBRARIES ${VULKAN_vk_LIBRARY})
endif()


include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Vulkan
REQUIRED_VARS ${_Vulkan_REQUIRED_VARS}
FAIL_MESSAGE "Vulkan NOT found."
)

unset(_Vulkan_REQUIRED_VARS)

mark_as_advanced(
VULKAN_INCLUDE_DIR
VULKAN_vk_LIBRARY
)
2 changes: 2 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def features(args, parser):
options = {
"backtrace": "if_available",
"inotify": "if_available",
"opengl": "if_available",
"vulkan": "if_available",
"gperftools-tcmalloc": False,
"gperftools-profiler": "if_available",
}
Expand Down
1 change: 1 addition & 0 deletions copying.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ _the openage authors_ are:
| Johannes Walcher | tomatower | johannes.walcher@stusta.de |
| Akritas Akritidis | MaanooAk | akritasak@gmail.com |
| Edgard Mota | edgardmota | edgardmota@gmail.com |
| Wojciech Nawrocki | Vtec234 | wjnawrocki@protonmail.com |

If you're a first-time commiter, add yourself to the above list. This is not
just for legal reasons, but also to keep an overview of all those nicknames.
Expand Down
34 changes: 31 additions & 3 deletions libopenage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ add_subdirectory("gui")
add_subdirectory("error")
add_subdirectory("gamestate")
add_subdirectory("input")
add_subdirectory("log")
add_subdirectory("job")
add_subdirectory("log")
add_subdirectory("pathfinding")
add_subdirectory("pyinterface")
add_subdirectory("renderer")
Expand All @@ -51,7 +51,7 @@ add_subdirectory("terrain")
add_subdirectory("testing")
add_subdirectory("unit")
add_subdirectory("util")

add_subdirectory("watch")

# run codegen, add files to executable
codegen_run()
Expand Down Expand Up @@ -79,7 +79,6 @@ if(NOT WIN32)
endif()

find_package(Freetype REQUIRED)
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2Image REQUIRED)
find_package(Opusfile REQUIRED)
Expand Down Expand Up @@ -134,6 +133,35 @@ else()
have_config_option(inotify INOTIFY false)
endif()

# opengl support
if(WANT_OPENGL)
find_package(OpenGL)
endif()

# vulkan support
if(WANT_VULKAN)
find_package(Vulkan)
endif()

if(WANT_OPENGL AND OPENGL_FOUND)
have_config_option(opengl OPENGL true)
include_directories(${OPENGL_INCLUDE_DIR})
else()
have_config_option(opengl OPENGL false)
endif()

if(WANT_VULKAN AND VULKAN_FOUND)
have_config_option(vulkan VULKAN true)
include_directories(${VULKAN_INCLUDE_DIR})
else()
have_config_option(vulkan VULKAN false)
endif()

if(NOT (OPENGL_FOUND OR VULKAN_FOUND))
message(FATAL_ERROR "One of OpenGL or Vulkan is required!")
endif()


get_config_option_string()

configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
Expand Down
67 changes: 13 additions & 54 deletions libopenage/assetmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

#include "assetmanager.h"

#if WITH_INOTIFY
#ifdef WITH_INOTIFY
#include <sys/inotify.h>
#include <unistd.h>
#include <limits.h> /* for NAME_MAX */
#endif

#include "util/compiler.h"
#include "util/file.h"
#include "error/error.h"
#include "log/log.h"

#include "texture.h"
#include "util/compiler.h"
#include "util/file.h"
#include "watch/watch.h"


namespace openage {

Expand All @@ -23,13 +22,7 @@ AssetManager::AssetManager(qtsdl::GuiItemLink *gui_link)
missing_tex{nullptr},
gui_link{gui_link} {

#if WITH_INOTIFY
// initialize the inotify instance
this->inotify_fd = inotify_init1(IN_NONBLOCK);
if (this->inotify_fd < 0) {
throw Error{MSG(err) << "Failed to initialize inotify!"};
}
#endif
this->watch_manager = watch::WatchManager::create();
}

util::Dir *AssetManager::get_data_dir() {
Expand Down Expand Up @@ -70,14 +63,12 @@ std::shared_ptr<Texture> AssetManager::load_texture(const std::string &name, boo
// create the texture!
tex = std::make_shared<Texture>(filename, use_metafile);

#if WITH_INOTIFY
// create inotify update trigger for the requested file
int wd = inotify_add_watch(this->inotify_fd, filename.c_str(), IN_CLOSE_WRITE);
if (wd < 0) {
throw Error{MSG(warn) << "Failed to add inotify watch for " << filename};
}
this->watch_fds[wd] = tex;
#endif
this->watch_manager->watch_file(
filename,
[=](watch::event_type, std::string) {
tex->reload();
}
);
}

// insert the texture into the map and return the texture.
Expand All @@ -100,39 +91,7 @@ Texture *AssetManager::get_texture(const std::string &name, bool use_metafile) {
}

void AssetManager::check_updates() {
#if WITH_INOTIFY
// buffer for at least 4 inotify events
char buf[4 * (sizeof(struct inotify_event) + NAME_MAX + 1)];
ssize_t len;

while (true) {
// fetch all events, the kernel won't write "half" structs.
len = read(this->inotify_fd, buf, sizeof(buf));

if (len == -1 and errno == EAGAIN) {
// no events, nothing to do.
break;
}
else if (len == -1) {
throw Error{MSG(err) << "Failed to read inotify events!"};
}

// process fetched events,
// the kernel guarantees complete events in the buffer.
char *ptr = buf;
while (ptr < buf + len) {
struct inotify_event *event = (struct inotify_event *)ptr;

if (event->mask & IN_CLOSE_WRITE) {
// TODO: this should invoke callback functions
this->watch_fds[event->wd]->reload();
}

// move the buffer ptr to the next event.
ptr += sizeof(struct inotify_event) + event->len;
}
}
#endif
this->watch_manager->check_changes();
}

std::shared_ptr<Texture> AssetManager::get_missing_tex() {
Expand Down
10 changes: 8 additions & 2 deletions libopenage/assetmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

#pragma once

#include "config.h"

#include <unordered_map>
#include <string>
#include <memory>

#include "util/dir.h"
#include "watch/watch.h"
#include "config.h"


namespace qtsdl {
class GuiItemLink;
Expand Down Expand Up @@ -53,6 +54,11 @@ class AssetManager final {
void check_updates();

protected:
/**
* File change monitoring and automatic reloading.
*/
std::unique_ptr<watch::WatchManager> watch_manager;

/**
* Create an internal texture handle.
*/
Expand Down
1 change: 1 addition & 0 deletions libopenage/audio/dynamic_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "../engine.h"
#include "../log/log.h"
#include "../job/job_manager.h"

namespace openage {
namespace audio {
Expand Down
2 changes: 2 additions & 0 deletions libopenage/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#define WITH_BACKTRACE ${WITH_BACKTRACE}
#define WITH_INOTIFY ${WITH_INOTIFY}
#define WITH_OPENGL ${WITH_OPENGL}
#define WITH_VULKAN ${WITH_VULKAN}
#define WITH_GPERFTOOLS_PROFILER ${WITH_GPERFTOOLS_PROFILER}
#define WITH_GPERFTOOLS_TCMALLOC ${WITH_GPERFTOOLS_TCMALLOC}

Expand Down
Loading