Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoherbelin committed Apr 6, 2024
2 parents cba7f5b + ff48107 commit a33dbac
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ set(VMIX_RSC_FILES
./rsc/mesh/h_line.ply
./rsc/mesh/h_mark.ply
./rsc/shaders/filters/default.glsl
./rsc/shaders/filters/blend.glsl
./rsc/shaders/filters/bloom.glsl
./rsc/shaders/filters/bokeh.glsl
./rsc/shaders/filters/talk.glsl
Expand Down
12 changes: 12 additions & 0 deletions rsc/shaders/filters/blend.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Blending of source texture (channel 0) with output window loopback (channel 1)
// by Bruno Herbelin for vimix
uniform float Blend;

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy / iResolution.xy;
fragColor = mix( texture(iChannel0, uv), texture(iChannel1, uv), Blend);
}



11 changes: 7 additions & 4 deletions src/ImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "Primitives.h"
#include "BaseToolkit.h"

#include "Mixer.h"

#include "ImageFilter.h"

std::string fragmentHeader = "#version 330 core\n"
Expand Down Expand Up @@ -61,6 +63,7 @@ std::string fragmentFooter = "void main() {\n"

std::list< FilteringProgram > FilteringProgram::presets = {
FilteringProgram(),
FilteringProgram("Blend", "shaders/filters/blend.glsl", "", { }),
FilteringProgram("Bilateral","shaders/filters/focus.glsl", "", { }),
FilteringProgram("Pixelate", "shaders/filters/pixelate.glsl", "", { }),
FilteringProgram("Earlybird","shaders/filters/earlybird.glsl", "", { }),
Expand All @@ -80,8 +83,8 @@ std::string FilteringProgram::getFilterCodeInputs()
"float iTimeDelta; // render time (in seconds)\n"
"int iFrame; // shader playback frame\n"
"vec3 iChannelResolution[2]; // input channels resolution (in pixels)\n"
"sampler2D iChannel0; // input channel 0 (texture).\n"
"sampler2D iChannel1; // input channel 1 (texture).\n"
"sampler2D iChannel0; // input channel 0 (source).\n"
"sampler2D iChannel1; // input channel 1 (display loopback).\n"
"vec4 iDate; // (year, month, day, time in seconds)\n"
"vec4 iMouse; // simulate mouse input with sliders:";
return filterHeaderHelp;
Expand Down Expand Up @@ -378,7 +381,6 @@ void ImageFilter::draw (FrameBuffer *input)
input_ = input;
// create first-pass surface and shader, taking as texture the input framebuffer
surfaces_.first->setTextureIndex( input_->texture() );
shaders_.first->mask_texture = input_->texture();
// (re)create framebuffer for result of first-pass
if (buffers_.first != nullptr)
delete buffers_.first;
Expand All @@ -388,7 +390,6 @@ void ImageFilter::draw (FrameBuffer *input)
input_->blit( buffers_.first );
// create second-pass surface and shader, taking as texture the first-pass framebuffer
surfaces_.second->setTextureIndex( buffers_.first->texture() );
shaders_.second->mask_texture = input_->texture();
// (re)create framebuffer for result of second-pass
if (buffers_.second != nullptr)
delete buffers_.second;
Expand All @@ -401,13 +402,15 @@ void ImageFilter::draw (FrameBuffer *input)
{
// FIRST PASS
// render input surface into frame buffer
shaders_.first->mask_texture = Mixer::manager().session()->frame()->texture();
buffers_.first->begin();
surfaces_.first->draw(glm::identity<glm::mat4>(), buffers_.first->projection());
buffers_.first->end();

// SECOND PASS
if ( program_.isTwoPass() ) {
// render filtered surface from first pass into frame buffer
shaders_.second->mask_texture = Mixer::manager().session()->frame()->texture();
buffers_.second->begin();
surfaces_.second->draw(glm::identity<glm::mat4>(), buffers_.second->projection());
buffers_.second->end();
Expand Down
16 changes: 8 additions & 8 deletions src/MediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,20 @@ typedef enum {
} GstPlayFlags;


GstBusSyncReply mediaplayer_signal_handler(GstBus *, GstMessage *msg, gpointer ptr)
GstBusSyncReply MediaPlayer::signal_handler(GstBus *, GstMessage *msg, gpointer ptr)
{
// only handle error messages
if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR && ptr != nullptr) {
GError *error;
gchar *debugs;
gst_message_parse_error(msg, &error, &debugs);
// register failure in source
reinterpret_cast<MediaPlayer *>(ptr)->failed_ = true;

Log::Warning("MediaPlayer %s Error %s",
// inform user
GError *error;
gst_message_parse_error(msg, &error, NULL);
Log::Warning("MediaPlayer %s : %s - %s",
std::to_string(reinterpret_cast<MediaPlayer*>(ptr)->id()).c_str(),
error->message);

g_error_free(error);
free(debugs);
}

// drop all messages to avoid filling up the stack
Expand Down Expand Up @@ -504,7 +504,7 @@ void MediaPlayer::execute_open()
#else
// set message handler for the pipeline's bus
gst_bus_set_sync_handler(gst_element_get_bus(pipeline_),
mediaplayer_signal_handler, this, NULL);
MediaPlayer::signal_handler, this, NULL);
#endif

// all good
Expand Down
1 change: 1 addition & 0 deletions src/MediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ class MediaPlayer {
static void callback_end_of_stream (GstAppSink *, gpointer);
static GstFlowReturn callback_new_preroll (GstAppSink *, gpointer );
static GstFlowReturn callback_new_sample (GstAppSink *, gpointer);
static GstBusSyncReply signal_handler(GstBus *, GstMessage *, gpointer);

// global list of registered media player
static void pipeline_terminate(GstElement *p);
Expand Down
19 changes: 3 additions & 16 deletions src/RenderingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,10 @@ void Rendering::MonitorConnect(GLFWmonitor* monitor, int event)

// Disconnection of a monitor messes up with fullscreen windows
if (event == GLFW_DISCONNECTED) {
// loop over all windows
// exit fullscreen all windows
for (auto w = Rendering::manager().windows_.begin();
w != Rendering::manager().windows_.end(); ++w) {
std::string wm = Settings::application.windows[w->second->index()].monitor;
// for all windows that are fullscreen;
if (w->second->isFullscreen()) {
// those which were on the disconnected monitor must exit fullscreen
if ( wm == glfwGetMonitorName(monitor) ) {
w->second->exitFullscreen();
}
// those which were on another monitor must be re-adjusted
else {
Settings::application.windows[w->second->index()].fullscreen = false;
w->second->setFullscreen( wm );
}
}
}
w != Rendering::manager().windows_.end(); ++w)
w->second->setFullscreen_(nullptr);
}

// inform Displays View that monitors changed
Expand Down

0 comments on commit a33dbac

Please sign in to comment.