project: Improve Linux support (#27 and #13)

While Linux was not an original goal of the project, it should still be supported out of the box. Therefore a number of changes are contained in this changeset:

- All C++ .h files were renamed to .hpp.
- All C includes (<....h>) were replaced with C++ includes (<c...>) and missing includes were added.
- std::memset and std::memcpy was replaced with memset and memcpy.
- All anonymous structs were removed where necessary.
- `extern "C"` was removed where it wasn't needed.
- #pragma warning was placed behind an #ifdef _MSC_VER
- The macros for `min`, `max` and `clamp` were removed as they were not used.
- `-fpedantic` was added to the GCC flags for bitmask support.
- `gs::rendertarget_op` is now declared before use.
- std::exception(const char*) was replaced with std::runtime_error(const char*).
- Added aligned_alloc and aligned_free macros for GCC and MSVC support.
- Replaced use of `sprintf_s` with `snprintf`.
- Placed additional guards around windows only code.

Additonally some changes were made that do not affect Linux:
- `NOMINMAX` and `NOINOUT` were removed.

Fixes: #27
Fixes: #13
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-01-14 11:23:21 +01:00
parent 3b1551b8ef
commit e0e2d9fe80
52 changed files with 380 additions and 296 deletions

View File

@ -128,9 +128,21 @@ if(MSVC)
endif() endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary # Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic") # GCC: -fpermissive is required as GCC does not allow the same template to be in different namespaces.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wpedantic -fpermissive")
endif() endif()
# C++ Standard and Extensions
IF (CMAKE_VERSION VERSION_LESS "3.8")
SET(CMAKE_CXX_STANDARD 14)
ELSEIF (CMAKE_VERSION VERSION_LESS "3.11")
SET(CMAKE_CXX_STANDARD 17)
ELSE() # CMake 3.11 or higher:
SET(CMAKE_CXX_STANDARD 20)
ENDIF()
## Disable nonstandard extensions
SET(CMAKE_CXX_EXTENSIONS OFF)
################################################################################ ################################################################################
# Options # Options
################################################################################ ################################################################################
@ -239,57 +251,57 @@ SET(PROJECT_PRIVATE
${PROJECT_DATA_SHADERS_FILTER} ${PROJECT_DATA_SHADERS_FILTER}
"${PROJECT_BINARY_DIR}/source/module.cpp" "${PROJECT_BINARY_DIR}/source/module.cpp"
"${PROJECT_BINARY_DIR}/source/version.hpp" "${PROJECT_BINARY_DIR}/source/version.hpp"
"${PROJECT_SOURCE_DIR}/source/plugin.h" "${PROJECT_SOURCE_DIR}/source/plugin.hpp"
"${PROJECT_SOURCE_DIR}/source/plugin.cpp" "${PROJECT_SOURCE_DIR}/source/plugin.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-displacement.h" "${PROJECT_SOURCE_DIR}/source/filter-displacement.hpp"
"${PROJECT_SOURCE_DIR}/source/filter-displacement.cpp" "${PROJECT_SOURCE_DIR}/source/filter-displacement.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-blur.h" "${PROJECT_SOURCE_DIR}/source/filter-blur.hpp"
"${PROJECT_SOURCE_DIR}/source/filter-blur.cpp" "${PROJECT_SOURCE_DIR}/source/filter-blur.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-shadow-sdf.hpp" "${PROJECT_SOURCE_DIR}/source/filter-shadow-sdf.hpp"
"${PROJECT_SOURCE_DIR}/source/filter-shadow-sdf.cpp" "${PROJECT_SOURCE_DIR}/source/filter-shadow-sdf.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-shape.h" "${PROJECT_SOURCE_DIR}/source/filter-shape.hpp"
"${PROJECT_SOURCE_DIR}/source/filter-shape.cpp" "${PROJECT_SOURCE_DIR}/source/filter-shape.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-transform.h" "${PROJECT_SOURCE_DIR}/source/filter-transform.hpp"
"${PROJECT_SOURCE_DIR}/source/filter-transform.cpp" "${PROJECT_SOURCE_DIR}/source/filter-transform.cpp"
"${PROJECT_SOURCE_DIR}/source/filter-custom-shader.h" "${PROJECT_SOURCE_DIR}/source/filter-custom-shader.hpp"
"${PROJECT_SOURCE_DIR}/source/filter-custom-shader.cpp" "${PROJECT_SOURCE_DIR}/source/filter-custom-shader.cpp"
"${PROJECT_SOURCE_DIR}/source/source-mirror.h" "${PROJECT_SOURCE_DIR}/source/source-mirror.hpp"
"${PROJECT_SOURCE_DIR}/source/source-mirror.cpp" "${PROJECT_SOURCE_DIR}/source/source-mirror.cpp"
"${PROJECT_SOURCE_DIR}/source/gfx-effect-source.h" "${PROJECT_SOURCE_DIR}/source/gfx-effect-source.hpp"
"${PROJECT_SOURCE_DIR}/source/gfx-effect-source.cpp" "${PROJECT_SOURCE_DIR}/source/gfx-effect-source.cpp"
"${PROJECT_SOURCE_DIR}/source/gfx-source-texture.h" "${PROJECT_SOURCE_DIR}/source/gfx-source-texture.hpp"
"${PROJECT_SOURCE_DIR}/source/gfx-source-texture.cpp" "${PROJECT_SOURCE_DIR}/source/gfx-source-texture.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-helper.h" "${PROJECT_SOURCE_DIR}/source/gs-helper.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-helper.cpp" "${PROJECT_SOURCE_DIR}/source/gs-helper.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-effect.h" "${PROJECT_SOURCE_DIR}/source/gs-effect.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-effect.cpp" "${PROJECT_SOURCE_DIR}/source/gs-effect.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-indexbuffer.h" "${PROJECT_SOURCE_DIR}/source/gs-indexbuffer.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-indexbuffer.cpp" "${PROJECT_SOURCE_DIR}/source/gs-indexbuffer.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-limits.h" "${PROJECT_SOURCE_DIR}/source/gs-limits.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-mipmapper.h" "${PROJECT_SOURCE_DIR}/source/gs-mipmapper.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-mipmapper.cpp" "${PROJECT_SOURCE_DIR}/source/gs-mipmapper.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-rendertarget.h" "${PROJECT_SOURCE_DIR}/source/gs-rendertarget.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-rendertarget.cpp" "${PROJECT_SOURCE_DIR}/source/gs-rendertarget.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-sampler.h" "${PROJECT_SOURCE_DIR}/source/gs-sampler.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-sampler.cpp" "${PROJECT_SOURCE_DIR}/source/gs-sampler.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-texture.h" "${PROJECT_SOURCE_DIR}/source/gs-texture.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-texture.cpp" "${PROJECT_SOURCE_DIR}/source/gs-texture.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-vertex.h" "${PROJECT_SOURCE_DIR}/source/gs-vertex.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-vertex.cpp" "${PROJECT_SOURCE_DIR}/source/gs-vertex.cpp"
"${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.h" "${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.hpp"
"${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.cpp" "${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.cpp"
"${PROJECT_SOURCE_DIR}/source/obs-audio-capture.h" "${PROJECT_SOURCE_DIR}/source/obs-audio-capture.hpp"
"${PROJECT_SOURCE_DIR}/source/obs-audio-capture.cpp" "${PROJECT_SOURCE_DIR}/source/obs-audio-capture.cpp"
"${PROJECT_SOURCE_DIR}/source/obs-tools.hpp" "${PROJECT_SOURCE_DIR}/source/obs-tools.hpp"
"${PROJECT_SOURCE_DIR}/source/obs-tools.cpp" "${PROJECT_SOURCE_DIR}/source/obs-tools.cpp"
"${PROJECT_SOURCE_DIR}/source/strings.h" "${PROJECT_SOURCE_DIR}/source/strings.hpp"
"${PROJECT_SOURCE_DIR}/source/utility.h" "${PROJECT_SOURCE_DIR}/source/utility.hpp"
"${PROJECT_SOURCE_DIR}/source/utility.cpp" "${PROJECT_SOURCE_DIR}/source/utility.cpp"
"${PROJECT_SOURCE_DIR}/source/util-event.hpp" "${PROJECT_SOURCE_DIR}/source/util-event.hpp"
"${PROJECT_SOURCE_DIR}/source/util-event.cpp" "${PROJECT_SOURCE_DIR}/source/util-event.cpp"
"${PROJECT_SOURCE_DIR}/source/util-math.h" "${PROJECT_SOURCE_DIR}/source/util-math.hpp"
"${PROJECT_SOURCE_DIR}/source/util-math.cpp" "${PROJECT_SOURCE_DIR}/source/util-math.cpp"
"${PROJECT_SOURCE_DIR}/source/util-memory.h" "${PROJECT_SOURCE_DIR}/source/util-memory.hpp"
"${PROJECT_SOURCE_DIR}/source/util-memory.cpp" "${PROJECT_SOURCE_DIR}/source/util-memory.cpp"
"${PROJECT_SOURCE_DIR}/source/obs-source.hpp" "${PROJECT_SOURCE_DIR}/source/obs-source.hpp"
"${PROJECT_SOURCE_DIR}/source/obs-source.cpp" "${PROJECT_SOURCE_DIR}/source/obs-source.cpp"

View File

@ -17,22 +17,26 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "filter-blur.h" #include "filter-blur.hpp"
#include <cmath> #include <cmath>
#include <inttypes.h> #include <cinttypes>
#include <map> #include <map>
#include "strings.h" #include "strings.hpp"
#include "util-math.h" #include "util-math.hpp"
#include <cfloat>
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include "callback/signal.h" #endif
#include "graphics/graphics.h" #include <callback/signal.h>
#include "graphics/matrix4.h" #include <graphics/graphics.h>
#include "util/platform.h" #include <graphics/matrix4.h>
#include <util/platform.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
// Translation Strings // Translation Strings
#define SOURCE_NAME "Filter.Blur" #define SOURCE_NAME "Filter.Blur"
@ -569,7 +573,7 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect)
if (obs_source_process_filter_begin(this->m_source, GS_RGBA, OBS_NO_DIRECT_RENDERING)) { if (obs_source_process_filter_begin(this->m_source, GS_RGBA, OBS_NO_DIRECT_RENDERING)) {
obs_source_process_filter_end(this->m_source, defaultEffect, baseW, baseH); obs_source_process_filter_end(this->m_source, defaultEffect, baseW, baseH);
} else { } else {
throw std::exception("Failed to render source"); throw std::runtime_error("Failed to render source");
} }
} catch (std::exception ex) { } catch (std::exception ex) {
if (this->can_log()) { if (this->can_log()) {

View File

@ -26,19 +26,22 @@
#include <list> #include <list>
#include <map> #include <map>
#include <memory> #include <memory>
#include "gfx-source-texture.h" #include "gfx-source-texture.hpp"
#include "gs-effect.h" #include "gs-effect.hpp"
#include "gs-helper.h" #include "gs-helper.hpp"
#include "gs-texture.h" #include "gs-texture.hpp"
#include "gs-rendertarget.h" #include "gs-rendertarget.hpp"
#include "plugin.h" #include "plugin.hpp"
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include "callback/signal.h" #endif
#include <callback/signal.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
namespace filter { namespace filter {
namespace blur { namespace blur {

View File

@ -17,20 +17,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "filter-custom-shader.h" #include "filter-custom-shader.hpp"
#include <fstream> #include <fstream>
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include "strings.h" #include "strings.hpp"
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include "graphics/graphics.h" #endif
#include "graphics/matrix4.h" #include <graphics/graphics.h>
#include "util/platform.h" #include <graphics/matrix4.h>
#include <util/platform.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
#define S "Filter.CustomShader" #define S "Filter.CustomShader"

View File

@ -18,13 +18,13 @@
*/ */
#pragma once #pragma once
#include <inttypes.h> #include <cinttypes>
#include <list> #include <list>
#include <vector> #include <vector>
#include "gfx-effect-source.h" #include "gfx-effect-source.hpp"
#include "gs-effect.h" #include "gs-effect.hpp"
#include "gs-rendertarget.h" #include "gs-rendertarget.hpp"
#include "plugin.h" #include "plugin.hpp"
namespace filter { namespace filter {
class CustomShader { class CustomShader {

View File

@ -17,8 +17,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "filter-displacement.h" #include "filter-displacement.hpp"
#include "strings.h" #include <sys/stat.h>
#include "strings.hpp"
// Initializer & Finalizer // Initializer & Finalizer
static filter::Displacement* filterDisplacementInstance; static filter::Displacement* filterDisplacementInstance;

View File

@ -18,17 +18,19 @@
*/ */
#pragma once #pragma once
#include "plugin.h" #include "plugin.hpp"
#include <string>
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#endif
#include <obs-source.h> #include <obs-source.h>
#include <util/platform.h> #include <util/platform.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
#include <string>
#define S_FILTER_DISPLACEMENT "Filter.Displacement" #define S_FILTER_DISPLACEMENT "Filter.Displacement"
#define S_FILTER_DISPLACEMENT_FILE "Filter.Displacement.File" #define S_FILTER_DISPLACEMENT_FILE "Filter.Displacement.File"

View File

@ -18,7 +18,7 @@
*/ */
#include "filter-shadow-sdf.hpp" #include "filter-shadow-sdf.hpp"
#include "strings.h" #include "strings.hpp"
// Translation Strings // Translation Strings
#define SOURCE_NAME "Filter.ShadowSDF" #define SOURCE_NAME "Filter.ShadowSDF"
@ -221,25 +221,25 @@ void filter::shadow_sdf::shadow_sdf_instance::video_render(gs_effect_t*)
if (obs_source_process_filter_begin(this->m_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { if (obs_source_process_filter_begin(this->m_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) {
obs_source_process_filter_end(this->m_self, default_effect, baseW, baseH); obs_source_process_filter_end(this->m_self, default_effect, baseW, baseH);
} else { } else {
throw std::exception("failed to process source"); throw std::runtime_error("failed to process source");
} }
} }
m_input->get_texture(this->m_source_texture); m_input->get_texture(this->m_source_texture);
if (!this->m_source_texture) { if (!this->m_source_texture) {
throw std::exception("failed to draw source"); throw std::runtime_error("failed to draw source");
} }
// Generate SDF Buffers // Generate SDF Buffers
{ {
this->m_sdf_read->get_texture(this->m_sdf_texture); this->m_sdf_read->get_texture(this->m_sdf_texture);
if (!this->m_sdf_texture) { if (!this->m_sdf_texture) {
throw std::exception("SDF Backbuffer empty"); throw std::runtime_error("SDF Backbuffer empty");
} }
std::shared_ptr<gs::effect> sdf_effect = std::shared_ptr<gs::effect> sdf_effect =
filter::shadow_sdf::shadow_sdf_factory::get()->get_sdf_generator_effect(); filter::shadow_sdf::shadow_sdf_factory::get()->get_sdf_generator_effect();
if (!sdf_effect) { if (!sdf_effect) {
throw std::exception("SDF Effect no loaded"); throw std::runtime_error("SDF Effect no loaded");
} }
{ {
@ -266,7 +266,7 @@ void filter::shadow_sdf::shadow_sdf_instance::video_render(gs_effect_t*)
this->m_sdf_write.swap(this->m_sdf_read); this->m_sdf_write.swap(this->m_sdf_read);
this->m_sdf_read->get_texture(this->m_sdf_texture); this->m_sdf_read->get_texture(this->m_sdf_texture);
if (!this->m_sdf_texture) { if (!this->m_sdf_texture) {
throw std::exception("SDF Backbuffer empty"); throw std::runtime_error("SDF Backbuffer empty");
} }
} }
} }
@ -275,7 +275,7 @@ void filter::shadow_sdf::shadow_sdf_instance::video_render(gs_effect_t*)
std::shared_ptr<gs::effect> shadow_effect = std::shared_ptr<gs::effect> shadow_effect =
filter::shadow_sdf::shadow_sdf_factory::get()->get_sdf_shadow_effect(); filter::shadow_sdf::shadow_sdf_factory::get()->get_sdf_shadow_effect();
if (!shadow_effect) { if (!shadow_effect) {
throw std::exception("Shadow Effect no loaded"); throw std::runtime_error("Shadow Effect no loaded");
} }
gs_set_cull_mode(GS_NEITHER); gs_set_cull_mode(GS_NEITHER);

View File

@ -22,16 +22,22 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include "gs-effect.h" #include "gs-effect.hpp"
#include "gs-rendertarget.h" #include "gs-rendertarget.hpp"
#include "gs-sampler.h" #include "gs-sampler.hpp"
#include "gs-texture.h" #include "gs-texture.hpp"
#include "gs-vertexbuffer.h" #include "gs-vertexbuffer.hpp"
#include "plugin.h" #include "plugin.hpp"
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4201)
#endif
#include <obs.h> #include <obs.h>
} #ifdef _MSC_VER
#pragma warning(pop)
#endif
namespace filter { namespace filter {
namespace shadow_sdf { namespace shadow_sdf {

View File

@ -17,21 +17,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "filter-shape.h" #include "filter-shape.hpp"
#include <map> #include <map>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include "strings.h" #include "strings.hpp"
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include "graphics/graphics.h" #endif
#include "graphics/matrix4.h" #include <graphics/graphics.h>
#include "util/platform.h" #include <graphics/matrix4.h>
#include <util/platform.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
// Initializer & Finalizer // Initializer & Finalizer
static filter::Shape* filterShapeInstance; static filter::Shape* filterShapeInstance;

View File

@ -18,8 +18,8 @@
*/ */
#pragma once #pragma once
#include "gs-vertexbuffer.h" #include "gs-vertexbuffer.hpp"
#include "plugin.h" #include "plugin.hpp"
#define P_SHAPE "Shape" #define P_SHAPE "Shape"
#define P_SHAPE_LOOP "Shape.Loop" #define P_SHAPE_LOOP "Shape.Loop"

View File

@ -17,18 +17,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "filter-transform.h" #include "filter-transform.hpp"
#include "strings.h" #include "strings.hpp"
#include "util-math.h" #include "util-math.hpp"
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include "graphics/graphics.h" #endif
#include "graphics/matrix4.h" #include <graphics/graphics.h>
#include "util/platform.h" #include <graphics/matrix4.h>
#include <util/platform.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
// Initializer & Finalizer // Initializer & Finalizer
static filter::Transform* filterTransformInstance; static filter::Transform* filterTransformInstance;

View File

@ -20,11 +20,11 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "gs-mipmapper.h" #include "gs-mipmapper.hpp"
#include "gs-rendertarget.h" #include "gs-rendertarget.hpp"
#include "gs-texture.h" #include "gs-texture.hpp"
#include "gs-vertexbuffer.h" #include "gs-vertexbuffer.hpp"
#include "plugin.h" #include "plugin.hpp"
namespace filter { namespace filter {
class Transform { class Transform {
@ -78,12 +78,10 @@ namespace filter {
// 3D Information // 3D Information
uint32_t rotation_order; uint32_t rotation_order;
struct { std::unique_ptr<util::vec3a> position;
std::unique_ptr<util::vec3a> position; std::unique_ptr<util::vec3a> rotation;
std::unique_ptr<util::vec3a> rotation; std::unique_ptr<util::vec3a> scale;
std::unique_ptr<util::vec3a> scale; std::unique_ptr<util::vec3a> shear;
std::unique_ptr<util::vec3a> shear;
};
public: public:
Instance(obs_data_t*, obs_source_t*); Instance(obs_data_t*, obs_source_t*);

View File

@ -15,10 +15,23 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-effect-source.h" #include "gfx-effect-source.hpp"
#include <fstream> #include <fstream>
#include <sys/stat.h>
#include "strings.hpp"
#include <cfloat>
#include <climits>
#include <cstdint>
// OBS
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4201)
#endif
#include <util/platform.h> #include <util/platform.h>
#include "strings.h" #ifdef _MSC_VER
#pragma warning(pop)
#endif
bool gfx::effect_source::property_type_modified(void*, obs_properties_t* props, obs_property_t*, obs_data_t* sett) bool gfx::effect_source::property_type_modified(void*, obs_properties_t* props, obs_property_t*, obs_data_t* sett)
{ {

View File

@ -21,16 +21,18 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "gfx-source-texture.h" #include "gfx-source-texture.hpp"
#include "gs-effect.h" #include "gs-effect.hpp"
#include "gs-mipmapper.h" #include "gs-mipmapper.hpp"
#include "gs-rendertarget.h" #include "gs-rendertarget.hpp"
#include "gs-texture.h" #include "gs-texture.hpp"
#include "gs-vertexbuffer.h" #include "gs-vertexbuffer.hpp"
extern "C" { // OBS
#pragma warning(push)
#pragma warning(disable : 4201)
#include <obs.h> #include <obs.h>
} #pragma warning(pop)
// Data Defines // Data Defines
#define D_TYPE "CustomShader.Type" #define D_TYPE "CustomShader.Type"

View File

@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-source-texture.h" #include "gfx-source-texture.hpp"
gfx::source_texture::~source_texture() gfx::source_texture::~source_texture()
{ {

View File

@ -18,13 +18,15 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <string> #include <string>
#include "gs-rendertarget.h" #include "gs-rendertarget.hpp"
#include "gs-texture.h" #include "gs-texture.hpp"
#include "obs-source.hpp" #include "obs-source.hpp"
extern "C" { // OBS
#pragma warning(push)
#pragma warning(disable : 4201)
#include <obs.h> #include <obs.h>
} #pragma warning(pop)
namespace gfx { namespace gfx {
class source_texture { class source_texture {

View File

@ -17,15 +17,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "gs-effect.h" #include "gs-effect.hpp"
#include <stdexcept> #include <stdexcept>
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#endif
#include <obs.h> #include <obs.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
gs::effect::effect() : m_effect(nullptr) {} gs::effect::effect() : m_effect(nullptr) {}

View File

@ -18,14 +18,13 @@
*/ */
#pragma once #pragma once
#include <inttypes.h> #include <cinttypes>
#include <list> #include <list>
#include <memory> #include <memory>
#include <string> #include <string>
#include "gs-sampler.h" #include "gs-sampler.hpp"
#include "gs-texture.h" #include "gs-texture.hpp"
extern "C" {
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include <graphics/graphics.h> #include <graphics/graphics.h>
@ -34,7 +33,6 @@ extern "C" {
#include <graphics/vec3.h> #include <graphics/vec3.h>
#include <graphics/vec4.h> #include <graphics/vec4.h>
#pragma warning(pop) #pragma warning(pop)
}
namespace gs { namespace gs {
class effect_parameter { class effect_parameter {

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "gs-helper.h" #include "gs-helper.hpp"
gs_effect_param* gs_effect_get_param(gs_effect_t* effect, const char* name) gs_effect_param* gs_effect_get_param(gs_effect_t* effect, const char* name)
{ {

View File

@ -19,13 +19,13 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include "plugin.h" #include "plugin.hpp"
extern "C" {
// OBS
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include "graphics/graphics.h" #include <graphics/graphics.h>
#pragma warning(pop) #pragma warning(pop)
}
gs_effect_param* gs_effect_get_param(gs_effect_t* effect, const char* name); gs_effect_param* gs_effect_get_param(gs_effect_t* effect, const char* name);
bool gs_set_param_int(gs_effect_t* effect, const char* name, int value); bool gs_set_param_int(gs_effect_t* effect, const char* name, int value);

View File

@ -17,14 +17,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "gs-indexbuffer.h" #include "gs-indexbuffer.hpp"
#include "gs-limits.h" #include "gs-limits.hpp"
extern "C" {
// OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#endif
#include <obs.h> #include <obs.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
gs::index_buffer::index_buffer(uint32_t maximumVertices) gs::index_buffer::index_buffer(uint32_t maximumVertices)
{ {

View File

@ -18,14 +18,13 @@
*/ */
#pragma once #pragma once
#include <inttypes.h> #include <cinttypes>
#include <vector> #include <vector>
extern "C" {
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include <graphics/graphics.h> #include <graphics/graphics.h>
#pragma warning(pop) #pragma warning(pop)
}
namespace gs { namespace gs {
class index_buffer : public std::vector<uint32_t> { class index_buffer : public std::vector<uint32_t> {

View File

@ -18,7 +18,7 @@
*/ */
#pragma once #pragma once
#include <inttypes.h> #include <cinttypes>
namespace gs { namespace gs {
static const uint32_t MAXIMUM_VERTICES = 0xFFFFFFu; static const uint32_t MAXIMUM_VERTICES = 0xFFFFFFu;

View File

@ -17,20 +17,26 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "gs-mipmapper.h" #include "gs-mipmapper.hpp"
#include "plugin.h" #include "plugin.hpp"
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#endif
#include <graphics/graphics.h> #include <graphics/graphics.h>
#include <obs-module.h> #include <obs-module.h>
#include <obs.h> #include <obs.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#if defined(WIN32) || defined(WIN64)
#include <windows.h>
#endif #endif
#if defined(WIN32) || defined(WIN64)
extern "C" {
#include <windows.h>
} }
#endif
// Here be dragons! // Here be dragons!
// This is to add support for mipmap generation which is by default not possible with libobs. // This is to add support for mipmap generation which is by default not possible with libobs.
@ -146,7 +152,9 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
// Render // Render
graphics_t* ctx = gs_get_context(); graphics_t* ctx = gs_get_context();
#if defined(WIN32) || defined(WIN64)
gs_d3d11_device* dev = reinterpret_cast<gs_d3d11_device*>(ctx->device); gs_d3d11_device* dev = reinterpret_cast<gs_d3d11_device*>(ctx->device);
#endif
int device_type = gs_get_device_type(); int device_type = gs_get_device_type();
void* sobj = gs_texture_get_obj(source->get_object()); void* sobj = gs_texture_get_obj(source->get_object());
void* tobj = gs_texture_get_obj(target->get_object()); void* tobj = gs_texture_get_obj(target->get_object());

View File

@ -18,17 +18,16 @@
*/ */
#pragma once #pragma once
#include "gs-effect.h" #include "gs-effect.hpp"
#include "gs-rendertarget.h" #include "gs-rendertarget.hpp"
#include "gs-texture.h" #include "gs-texture.hpp"
#include "gs-vertexbuffer.h" #include "gs-vertexbuffer.hpp"
extern "C" { // OBS
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include <graphics/graphics.h> #include <graphics/graphics.h>
#pragma warning(pop) #pragma warning(pop)
}
namespace gs { namespace gs {
class mipmapper { class mipmapper {

View File

@ -17,16 +17,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "gs-rendertarget.h" #include "gs-rendertarget.hpp"
#include <stdexcept> #include <stdexcept>
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#endif
#include <graphics/graphics.h> #include <graphics/graphics.h>
#include <obs.h> #include <obs.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
gs::rendertarget::~rendertarget() gs::rendertarget::~rendertarget()
{ {

View File

@ -20,16 +20,17 @@
#pragma once #pragma once
#include <cinttypes> #include <cinttypes>
#include <memory> #include <memory>
#include "gs-texture.h" #include "gs-texture.hpp"
extern "C" { // OBS
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include <graphics/graphics.h> #include <graphics/graphics.h>
#pragma warning(pop) #pragma warning(pop)
}
namespace gs { namespace gs {
class rendertarget_op;
class rendertarget { class rendertarget {
friend class rendertarget_op; friend class rendertarget_op;

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "gs-sampler.h" #include "gs-sampler.hpp"
gs::sampler::sampler() gs::sampler::sampler()
{ {

View File

@ -18,13 +18,13 @@
*/ */
#pragma once #pragma once
#include <inttypes.h> #include <cinttypes>
extern "C" {
// OBS
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include <graphics/graphics.h> #include <graphics/graphics.h>
#pragma warning(pop) #pragma warning(pop)
}
namespace gs { namespace gs {
class sampler { class sampler {

View File

@ -17,19 +17,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "gs-texture.h" #include "gs-texture.hpp"
#include <fstream> #include <fstream>
#include <stdexcept> #include <stdexcept>
#include <sys/stat.h> #include <sys/stat.h>
#include "util-math.h" #include "util-math.hpp"
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#endif
#include <obs.h> #include <obs.h>
#include <util/platform.h> #include <util/platform.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels, gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels,
const uint8_t** mip_data, gs::texture::flags texture_flags) const uint8_t** mip_data, gs::texture::flags texture_flags)

View File

@ -20,14 +20,13 @@
#pragma once #pragma once
#include <cinttypes> #include <cinttypes>
#include <string> #include <string>
#include "utility.h" #include "utility.hpp"
extern "C" { // OBS
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include <graphics/graphics.h> #include <graphics/graphics.h>
#pragma warning(pop) #pragma warning(pop)
}
namespace gs { namespace gs {
class texture { class texture {

View File

@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "gs-vertex.h" #include "gs-vertex.hpp"
#include "util-memory.h" #include "util-memory.hpp"
gs::vertex::vertex() gs::vertex::vertex()
: hasStore(true), store(nullptr), position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr) : hasStore(true), store(nullptr), position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr)

View File

@ -20,13 +20,13 @@
#pragma once #pragma once
#include <cinttypes> #include <cinttypes>
#include <xmmintrin.h> #include <xmmintrin.h>
#include "gs-limits.h" #include "gs-limits.hpp"
extern "C" {
// OBS
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include <graphics/vec3.h> #include <graphics/vec3.h>
#pragma warning(pop) #pragma warning(pop)
}
namespace gs { namespace gs {
struct vertex { struct vertex {

View File

@ -17,15 +17,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "gs-vertexbuffer.h" #include "gs-vertexbuffer.hpp"
#include <stdexcept> #include <stdexcept>
#include "util-memory.h" #include "util-memory.hpp"
extern "C" {
// OBS
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#endif
#include <obs.h> #include <obs.h>
#ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
} #endif
gs::vertex_buffer::~vertex_buffer() gs::vertex_buffer::~vertex_buffer()
{ {
@ -56,7 +60,7 @@ gs::vertex_buffer::~vertex_buffer()
m_layerdata = nullptr; m_layerdata = nullptr;
} }
if (m_vertexbufferdata) { if (m_vertexbufferdata) {
std::memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); memset(m_vertexbufferdata, 0, sizeof(gs_vb_data));
if (!m_vertexbuffer) { if (!m_vertexbuffer) {
gs_vbdata_destroy(m_vertexbufferdata); gs_vbdata_destroy(m_vertexbufferdata);
m_vertexbufferdata = nullptr; m_vertexbufferdata = nullptr;
@ -94,12 +98,12 @@ gs::vertex_buffer::vertex_buffer(uint32_t vertices, uint8_t uvlayers)
m_vertexbufferdata->colors = m_colors = (uint32_t*)util::malloc_aligned(16, sizeof(uint32_t) * m_capacity); m_vertexbufferdata->colors = m_colors = (uint32_t*)util::malloc_aligned(16, sizeof(uint32_t) * m_capacity);
// cppcheck-suppress memsetClassFloat // cppcheck-suppress memsetClassFloat
std::memset(m_positions, 0, sizeof(vec3) * m_capacity); memset(m_positions, 0, sizeof(vec3) * m_capacity);
// cppcheck-suppress memsetClassFloat // cppcheck-suppress memsetClassFloat
std::memset(m_normals, 0, sizeof(vec3) * m_capacity); memset(m_normals, 0, sizeof(vec3) * m_capacity);
// cppcheck-suppress memsetClassFloat // cppcheck-suppress memsetClassFloat
std::memset(m_tangents, 0, sizeof(vec3) * m_capacity); memset(m_tangents, 0, sizeof(vec3) * m_capacity);
std::memset(m_colors, 0, sizeof(uint32_t) * m_capacity); memset(m_colors, 0, sizeof(uint32_t) * m_capacity);
m_vertexbufferdata->num_tex = m_layers; m_vertexbufferdata->num_tex = m_layers;
if (m_layers > 0) { if (m_layers > 0) {
@ -108,7 +112,7 @@ gs::vertex_buffer::vertex_buffer(uint32_t vertices, uint8_t uvlayers)
for (size_t n = 0; n < m_layers; n++) { for (size_t n = 0; n < m_layers; n++) {
m_layerdata[n].array = m_uvs[n] = (vec4*)util::malloc_aligned(16, sizeof(vec4) * m_capacity); m_layerdata[n].array = m_uvs[n] = (vec4*)util::malloc_aligned(16, sizeof(vec4) * m_capacity);
m_layerdata[n].width = 4; m_layerdata[n].width = 4;
std::memset(m_uvs[n], 0, sizeof(vec4) * m_capacity); memset(m_uvs[n], 0, sizeof(vec4) * m_capacity);
} }
} else { } else {
m_vertexbufferdata->tvarray = nullptr; m_vertexbufferdata->tvarray = nullptr;
@ -117,7 +121,7 @@ gs::vertex_buffer::vertex_buffer(uint32_t vertices, uint8_t uvlayers)
// Allocate GPU // Allocate GPU
obs_enter_graphics(); obs_enter_graphics();
m_vertexbuffer = gs_vertexbuffer_create(m_vertexbufferdata, GS_DYNAMIC); m_vertexbuffer = gs_vertexbuffer_create(m_vertexbufferdata, GS_DYNAMIC);
std::memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); memset(m_vertexbufferdata, 0, sizeof(gs_vb_data));
m_vertexbufferdata->num = m_capacity; m_vertexbufferdata->num = m_capacity;
m_vertexbufferdata->num_tex = m_layers; m_vertexbufferdata->num_tex = m_layers;
obs_leave_graphics(); obs_leave_graphics();
@ -138,24 +142,24 @@ gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb)
this->set_uv_layers((uint32_t)vbd->num_tex); this->set_uv_layers((uint32_t)vbd->num_tex);
if (vbd->points != nullptr) if (vbd->points != nullptr)
std::memcpy(m_positions, vbd->points, vbd->num * sizeof(vec3)); memcpy(m_positions, vbd->points, vbd->num * sizeof(vec3));
if (vbd->normals != nullptr) if (vbd->normals != nullptr)
std::memcpy(m_normals, vbd->normals, vbd->num * sizeof(vec3)); memcpy(m_normals, vbd->normals, vbd->num * sizeof(vec3));
if (vbd->tangents != nullptr) if (vbd->tangents != nullptr)
std::memcpy(m_tangents, vbd->tangents, vbd->num * sizeof(vec3)); memcpy(m_tangents, vbd->tangents, vbd->num * sizeof(vec3));
if (vbd->colors != nullptr) if (vbd->colors != nullptr)
std::memcpy(m_colors, vbd->colors, vbd->num * sizeof(uint32_t)); memcpy(m_colors, vbd->colors, vbd->num * sizeof(uint32_t));
if (vbd->tvarray != nullptr) { if (vbd->tvarray != nullptr) {
for (size_t n = 0; n < vbd->num_tex; n++) { for (size_t n = 0; n < vbd->num_tex; n++) {
if (vbd->tvarray[n].array != nullptr && vbd->tvarray[n].width <= 4 && vbd->tvarray[n].width > 0) { if (vbd->tvarray[n].array != nullptr && vbd->tvarray[n].width <= 4 && vbd->tvarray[n].width > 0) {
if (vbd->tvarray[n].width == 4) { if (vbd->tvarray[n].width == 4) {
std::memcpy(m_uvs[n], vbd->tvarray[n].array, vbd->num * sizeof(vec4)); memcpy(m_uvs[n], vbd->tvarray[n].array, vbd->num * sizeof(vec4));
} else { } else {
for (size_t idx = 0; idx < m_capacity; idx++) { for (size_t idx = 0; idx < m_capacity; idx++) {
float* mem = reinterpret_cast<float*>(vbd->tvarray[n].array) + (idx * vbd->tvarray[n].width); float* mem = reinterpret_cast<float*>(vbd->tvarray[n].array) + (idx * vbd->tvarray[n].width);
// cppcheck-suppress memsetClassFloat // cppcheck-suppress memsetClassFloat
std::memset(&m_uvs[n][idx], 0, sizeof(vec4)); memset(&m_uvs[n][idx], 0, sizeof(vec4));
std::memcpy(&m_uvs[n][idx], mem, vbd->tvarray[n].width); memcpy(&m_uvs[n][idx], mem, vbd->tvarray[n].width);
} }
} }
} }
@ -168,12 +172,12 @@ gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb)
gs::vertex_buffer::vertex_buffer(vertex_buffer const& other) : vertex_buffer(other.m_capacity) gs::vertex_buffer::vertex_buffer(vertex_buffer const& other) : vertex_buffer(other.m_capacity)
{ {
// Copy Constructor // Copy Constructor
std::memcpy(m_positions, other.m_positions, m_capacity * sizeof(vec3)); memcpy(m_positions, other.m_positions, m_capacity * sizeof(vec3));
std::memcpy(m_normals, other.m_normals, m_capacity * sizeof(vec3)); memcpy(m_normals, other.m_normals, m_capacity * sizeof(vec3));
std::memcpy(m_tangents, other.m_tangents, m_capacity * sizeof(vec3)); memcpy(m_tangents, other.m_tangents, m_capacity * sizeof(vec3));
std::memcpy(m_colors, other.m_colors, m_capacity * sizeof(vec3)); memcpy(m_colors, other.m_colors, m_capacity * sizeof(vec3));
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) { for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
std::memcpy(m_uvs[n], other.m_uvs[n], m_capacity * sizeof(vec3)); memcpy(m_uvs[n], other.m_uvs[n], m_capacity * sizeof(vec3));
} }
} }
@ -225,7 +229,7 @@ void gs::vertex_buffer::operator=(vertex_buffer const&& other)
m_layerdata = nullptr; m_layerdata = nullptr;
} }
if (m_vertexbufferdata) { if (m_vertexbufferdata) {
std::memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); memset(m_vertexbufferdata, 0, sizeof(gs_vb_data));
if (!m_vertexbuffer) { if (!m_vertexbuffer) {
gs_vbdata_destroy(m_vertexbufferdata); gs_vbdata_destroy(m_vertexbufferdata);
m_vertexbufferdata = nullptr; m_vertexbufferdata = nullptr;
@ -338,7 +342,7 @@ gs_vertbuffer_t* gs::vertex_buffer::update(bool refreshGPU)
// Update VertexBuffer data. // Update VertexBuffer data.
obs_enter_graphics(); obs_enter_graphics();
m_vertexbufferdata = gs_vertexbuffer_get_data(m_vertexbuffer); m_vertexbufferdata = gs_vertexbuffer_get_data(m_vertexbuffer);
std::memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); memset(m_vertexbufferdata, 0, sizeof(gs_vb_data));
m_vertexbufferdata->num = m_capacity; m_vertexbufferdata->num = m_capacity;
m_vertexbufferdata->points = m_positions; m_vertexbufferdata->points = m_positions;
m_vertexbufferdata->normals = m_normals; m_vertexbufferdata->normals = m_normals;
@ -356,7 +360,7 @@ gs_vertbuffer_t* gs::vertex_buffer::update(bool refreshGPU)
obs_leave_graphics(); obs_leave_graphics();
// WORKAROUND: OBS Studio 20.x and below incorrectly deletes data that it doesn't own. // WORKAROUND: OBS Studio 20.x and below incorrectly deletes data that it doesn't own.
std::memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); memset(m_vertexbufferdata, 0, sizeof(gs_vb_data));
m_vertexbufferdata->num = m_capacity; m_vertexbufferdata->num = m_capacity;
m_vertexbufferdata->num_tex = m_layers; m_vertexbufferdata->num_tex = m_layers;
for (uint32_t n = 0; n < m_layers; n++) { for (uint32_t n = 0; n < m_layers; n++) {

View File

@ -19,17 +19,16 @@
#pragma once #pragma once
#include <cinttypes> #include <cinttypes>
#include "gs-limits.h" #include "gs-limits.hpp"
#include "gs-vertex.h" #include "gs-vertex.hpp"
#include "util-math.h" #include "util-math.hpp"
#include "util-memory.h" #include "util-memory.hpp"
extern "C" { // OBS
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include <graphics/graphics.h> #include <graphics/graphics.h>
#pragma warning(pop) #pragma warning(pop)
}
namespace gs { namespace gs {
class vertex_buffer { class vertex_buffer {

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "obs-audio-capture.h" #include "obs-audio-capture.hpp"
void obs::audio_capture::audio_capture_cb(void* data, obs_source_t*, const struct audio_data* audio, bool muted) void obs::audio_capture::audio_capture_cb(void* data, obs_source_t*, const struct audio_data* audio, bool muted)
{ {

View File

@ -19,7 +19,12 @@
#pragma once #pragma once
#include <functional> #include <functional>
// OBS
#pragma warning(push)
#pragma warning(disable : 4201)
#include <obs.h> #include <obs.h>
#pragma warning(pop)
namespace obs { namespace obs {
typedef std::function<void(void* data, struct audio_data const* audio, bool muted)> audio_capture_callback_t; typedef std::function<void(void* data, struct audio_data const* audio, bool muted)> audio_capture_callback_t;

View File

@ -25,9 +25,11 @@
#include <string> #include <string>
#include "util-event.hpp" #include "util-event.hpp"
extern "C" { // OBS
#include "obs.h" #pragma warning(push)
} #pragma warning(disable : 4201)
#include <obs.h>
#pragma warning(pop)
namespace obs { namespace obs {
class source { class source {

View File

@ -24,9 +24,11 @@
#include <cinttypes> #include <cinttypes>
#include <string> #include <string>
extern "C" { // OBS
#include "obs.h" #pragma warning(push)
} #pragma warning(disable : 4201)
#include <obs.h>
#pragma warning(pop)
namespace obs { namespace obs {
namespace tools { namespace tools {

View File

@ -17,11 +17,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "plugin.h" #include "plugin.hpp"
#include "filter-blur.h" #include "filter-blur.hpp"
#include "filter-displacement.h" #include "filter-displacement.hpp"
#include "filter-shape.h" #include "filter-shape.hpp"
#include "filter-transform.h" #include "filter-transform.hpp"
filter::Displacement* filterDisplacement; filter::Displacement* filterDisplacement;
filter::Shape* filterShape; filter::Shape* filterShape;
@ -50,10 +50,10 @@ MODULE_EXPORT void obs_module_unload(void)
} }
#ifdef _WIN32 #ifdef _WIN32
#define NOMINMAX // Windows Only
#define NOINOUT extern "C" {
#include <windows.h> #include <windows.h>
}
BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID) BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID)
{ {

View File

@ -19,16 +19,14 @@
#pragma once #pragma once
#include <functional> #include <functional>
#include <inttypes.h> #include <cinttypes>
#include <list> #include <list>
extern "C" {
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) #pragma warning(disable : 4201)
#include "obs-module.h" #include "obs-module.h"
#include "util/platform.h" #include "util/platform.h"
#pragma warning(pop) #pragma warning(pop)
}
// Plugin // Plugin
#define PLUGIN_NAME "Stream Effects" #define PLUGIN_NAME "Stream Effects"
@ -44,16 +42,6 @@ extern "C" {
#define vstr(s) dstr(s) #define vstr(s) dstr(s)
#define dstr(s) #s #define dstr(s) #s
#define clamp(val, low, high) (val > high ? high : (val < low ? low : val))
#ifdef max
#undef max
#endif
#define max(val, high) (val > high ? val : high)
#ifdef min
#undef min
#endif
#define min(val, low) (val < low ? val : low)
#ifndef __FUNCTION_NAME__ #ifndef __FUNCTION_NAME__
#if defined(_WIN32) || defined(_WIN64) //WINDOWS #if defined(_WIN32) || defined(_WIN64) //WINDOWS
#define __FUNCTION_NAME__ __FUNCTION__ #define __FUNCTION_NAME__ __FUNCTION__

View File

@ -17,19 +17,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "source-mirror.h" #include "source-mirror.hpp"
#include <bitset> #include <bitset>
#include <cstring> #include <cstring>
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "obs-tools.hpp" #include "obs-tools.hpp"
#include "strings.h" #include "strings.hpp"
extern "C" { // OBS
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4201)
#endif
#include <media-io/audio-io.h> #include <media-io/audio-io.h>
#include <obs-config.h> #include <obs-config.h>
} #ifdef _MSC_VER
#pragma warning(pop)
#endif
#define S_SOURCE_MIRROR "Source.Mirror" #define S_SOURCE_MIRROR "Source.Mirror"
#define P_SOURCE "Source.Mirror.Source" #define P_SOURCE "Source.Mirror.Source"
@ -109,7 +115,7 @@ bool Source::MirrorAddon::modified_properties(obs_properties_t* pr, obs_property
obs_source_t* target = obs_get_source_by_name(obs_data_get_string(data, P_SOURCE)); obs_source_t* target = obs_get_source_by_name(obs_data_get_string(data, P_SOURCE));
if (target) { if (target) {
std::vector<char> buf(256); std::vector<char> buf(256);
sprintf_s(buf.data(), buf.size(), "%ldx%ld\0", obs_source_get_width(target), obs_source_get_height(target)); snprintf(buf.data(), buf.size(), "%ldx%ld\0", obs_source_get_width(target), obs_source_get_height(target));
obs_data_set_string(data, P_SOURCE_SIZE, buf.data()); obs_data_set_string(data, P_SOURCE_SIZE, buf.data());
} else { } else {
obs_data_set_string(data, P_SOURCE_SIZE, "0x0"); obs_data_set_string(data, P_SOURCE_SIZE, "0x0");

View File

@ -23,16 +23,18 @@
#include <mutex> #include <mutex>
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "gfx-source-texture.h" #include "gfx-source-texture.hpp"
#include "gs-rendertarget.h" #include "gs-rendertarget.hpp"
#include "gs-sampler.h" #include "gs-sampler.hpp"
#include "obs-audio-capture.h" #include "obs-audio-capture.hpp"
#include "obs-source.hpp" #include "obs-source.hpp"
#include "plugin.h" #include "plugin.hpp"
extern "C" { // OBS
#pragma warning(push)
#pragma warning(disable : 4201)
#include <obs-source.h> #include <obs-source.h>
} #pragma warning(pop)
namespace Source { namespace Source {
class MirrorAddon { class MirrorAddon {

View File

@ -18,7 +18,7 @@
*/ */
#pragma once #pragma once
#include "plugin.h" #include "plugin.hpp"
#define P_TRANSLATE(x) obs_module_text(x) #define P_TRANSLATE(x) obs_module_text(x)
#define P_DESC(x) x ".Description" #define P_DESC(x) x ".Description"

View File

@ -62,4 +62,4 @@ namespace util {
listeners.clear(); listeners.clear();
} }
}; };
}; // namespace util } // namespace util

View File

@ -17,50 +17,49 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "util-math.h" #include "util-math.hpp"
#include <cctype> #include <cctype>
#include <malloc.h> #include <cstdlib>
#include <stdlib.h> #include "util-memory.hpp"
#include "util-memory.h"
void* util::vec3a::operator new(size_t count) void* util::vec3a::operator new(size_t count)
{ {
return _aligned_malloc(count, 16); return aligned_alloc(count, 16);
} }
void* util::vec3a::operator new[](size_t count) void* util::vec3a::operator new[](size_t count)
{ {
return _aligned_malloc(count, 16); return aligned_alloc(count, 16);
} }
void util::vec3a::operator delete(void* p) void util::vec3a::operator delete(void* p)
{ {
_aligned_free(p); aligned_free(p);
} }
void util::vec3a::operator delete[](void* p) void util::vec3a::operator delete[](void* p)
{ {
_aligned_free(p); aligned_free(p);
} }
void* util::vec4a::operator new(size_t count) void* util::vec4a::operator new(size_t count)
{ {
return _aligned_malloc(count, 16); return aligned_alloc(count, 16);
} }
void* util::vec4a::operator new[](size_t count) void* util::vec4a::operator new[](size_t count)
{ {
return _aligned_malloc(count, 16); return aligned_alloc(count, 16);
} }
void util::vec4a::operator delete(void* p) void util::vec4a::operator delete(void* p)
{ {
_aligned_free(p); aligned_free(p);
} }
void util::vec4a::operator delete[](void* p) void util::vec4a::operator delete[](void* p)
{ {
_aligned_free(p); aligned_free(p);
} }
std::pair<int64_t, int64_t> util::SizeFromString(std::string text, bool allowSquare) std::pair<int64_t, int64_t> util::SizeFromString(std::string text, bool allowSquare)

View File

@ -18,15 +18,18 @@
*/ */
#pragma once #pragma once
#include <inttypes.h> #include <cinttypes>
#include <cmath> #include <cmath>
#include <string> #include <string>
#include <utility> #include <utility>
// OBS // OBS
#pragma warning(push)
#pragma warning(disable : 4201)
#include <graphics/vec2.h> #include <graphics/vec2.h>
#include <graphics/vec3.h> #include <graphics/vec3.h>
#include <graphics/vec4.h> #include <graphics/vec4.h>
#pragma warning(pop)
// Constants // Constants
#define PI 3.1415926535897932384626433832795 #define PI 3.1415926535897932384626433832795
@ -60,18 +63,24 @@ inline size_t GetNearestPowerOfTwoBelow(size_t v)
} }
namespace util { namespace util {
__declspec(align(16)) struct vec3a : public vec3 { #ifdef _MSC_VER
static void* vec3a::operator new(size_t count); __declspec(align(16))
static void* vec3a::operator new[](size_t count); #endif
static void vec3a::operator delete(void* p); struct vec3a : public vec3 {
static void vec3a::operator delete[](void* p); static void* operator new(size_t count);
static void* operator new[](size_t count);
static void operator delete(void* p);
static void operator delete[](void* p);
}; };
__declspec(align(16)) struct vec4a : public vec4 { #ifdef _MSC_VER
static void* vec4a::operator new(size_t count); __declspec(align(16))
static void* vec4a::operator new[](size_t count); #endif
static void vec4a::operator delete(void* p); struct vec4a : public vec4 {
static void vec4a::operator delete[](void* p); static void* operator new(size_t count);
static void* operator new[](size_t count);
static void operator delete(void* p);
static void operator delete[](void* p);
}; };
std::pair<int64_t, int64_t> SizeFromString(std::string text, bool allowSquare = true); std::pair<int64_t, int64_t> SizeFromString(std::string text, bool allowSquare = true);
@ -108,15 +117,15 @@ namespace util {
inline bool is_power_of_two(x v) \ inline bool is_power_of_two(x v) \
{ \ { \
return is_power_of_two_loop(v); \ return is_power_of_two_loop(v); \
}; }
is_power_of_two_as_loop(int8_t); is_power_of_two_as_loop(int8_t)
is_power_of_two_as_loop(uint8_t); is_power_of_two_as_loop(uint8_t)
is_power_of_two_as_loop(int16_t); is_power_of_two_as_loop(int16_t)
is_power_of_two_as_loop(uint16_t); is_power_of_two_as_loop(uint16_t)
is_power_of_two_as_loop(int32_t); is_power_of_two_as_loop(int32_t)
is_power_of_two_as_loop(uint32_t); is_power_of_two_as_loop(uint32_t)
is_power_of_two_as_loop(int64_t); is_power_of_two_as_loop(int64_t)
is_power_of_two_as_loop(uint64_t); is_power_of_two_as_loop(uint64_t)
#undef is_power_of_two_as_loop #undef is_power_of_two_as_loop
#pragma pop_macro("is_power_of_two_as_loop") #pragma pop_macro("is_power_of_two_as_loop")

View File

@ -17,18 +17,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "util-memory.h" #include "util-memory.hpp"
#include <cstdlib> #include <cstdlib>
#define USE_STD_ALLOC_FREE #define USE_STD_ALLOC_FREE
void* util::malloc_aligned(size_t align, size_t size) void* util::malloc_aligned(size_t align, size_t size)
{ {
#ifdef USE_STD_ALLOC_FREE #ifdef USE_STD_ALLOC_FREE
#if defined(_MSC_VER) return aligned_alloc(align, size);
return _aligned_malloc(size, align);
#else
return aligned_malloc(align, size);
#endif
#else #else
// Ensure that we have space for the pointer and the data. // Ensure that we have space for the pointer and the data.
size_t asize = aligned_offset(align, size + (sizeof(void*) * 2)); size_t asize = aligned_offset(align, size + (sizeof(void*) * 2));
@ -50,11 +47,7 @@ void* util::malloc_aligned(size_t align, size_t size)
void util::free_aligned(void* mem) void util::free_aligned(void* mem)
{ {
#ifdef USE_STD_ALLOC_FREE #ifdef USE_STD_ALLOC_FREE
#if defined(_MSC_VER) aligned_free(mem);
_aligned_free(mem);
#else
free(mem);
#endif
#else #else
void* ptr = reinterpret_cast<void*>(*reinterpret_cast<intptr_t*>(static_cast<char*>(mem) - sizeof(void*))); void* ptr = reinterpret_cast<void*>(*reinterpret_cast<intptr_t*>(static_cast<char*>(mem) - sizeof(void*)));
free(ptr); free(ptr);

View File

@ -18,8 +18,14 @@
*/ */
#pragma once #pragma once
#include <malloc.h> #include <cstdlib>
#include <stdlib.h>
#ifdef _MSC_VER
#define aligned_alloc _aligned_malloc
#define aligned_free _aligned_free
#else
#define aligned_free free
#endif
namespace util { namespace util {
inline size_t aligned_offset(size_t align, size_t pos) inline size_t aligned_offset(size_t align, size_t pos)

View File

@ -17,4 +17,4 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "utility.h" #include "utility.hpp"