Implement mechanism to push & pop rendering attributes

This commit is contained in:
brunoherbelin
2020-04-05 11:44:01 +02:00
parent 370e680e91
commit 1e70d8f4e2
11 changed files with 139 additions and 100 deletions

View File

@@ -221,6 +221,7 @@ set(VMIX_SRCS
Primitives.cpp Primitives.cpp
SessionVisitor.cpp SessionVisitor.cpp
Settings.cpp Settings.cpp
Screenshot.cpp
Resource.cpp Resource.cpp
FileDialog.cpp FileDialog.cpp
MediaPlayer.cpp MediaPlayer.cpp

View File

@@ -5,14 +5,18 @@
#include <glad/glad.h> #include <glad/glad.h>
FrameBuffer::FrameBuffer(uint width, uint height, bool useDepthBuffer) : width_(width), height_(height) FrameBuffer::FrameBuffer(uint width, uint height, bool useDepthBuffer)
{ {
attrib_.viewport.x = width;
attrib_.viewport.y = height;
attrib_.clear_color = glm::vec3(0.f);
// create a renderbuffer object to store depth info // create a renderbuffer object to store depth info
GLuint rboId; GLuint rboId;
if (useDepthBuffer){ if (useDepthBuffer){
glGenRenderbuffers(1, &rboId); glGenRenderbuffers(1, &rboId);
glBindRenderbuffer(GL_RENDERBUFFER, rboId); glBindRenderbuffer(GL_RENDERBUFFER, rboId);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width_, height_); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0);
} }
@@ -23,7 +27,7 @@ FrameBuffer::FrameBuffer(uint width, uint height, bool useDepthBuffer) : width_(
// generate texture // generate texture
glGenTextures(1, &textureid_); glGenTextures(1, &textureid_);
glBindTexture(GL_TEXTURE_2D, textureid_); glBindTexture(GL_TEXTURE_2D, textureid_);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width_, height_, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
@@ -38,6 +42,8 @@ FrameBuffer::FrameBuffer(uint width, uint height, bool useDepthBuffer) : width_(
GL_RENDERBUFFER, rboId); GL_RENDERBUFFER, rboId);
} }
checkFramebufferStatus(); checkFramebufferStatus();
FrameBuffer::release();
} }
@@ -48,21 +54,30 @@ FrameBuffer::~FrameBuffer()
float FrameBuffer::aspectRatio() const float FrameBuffer::aspectRatio() const
{ {
return static_cast<float>(width_) / static_cast<float>(height_); return static_cast<float>(width()) / static_cast<float>(height());
} }
void FrameBuffer::bind() void FrameBuffer::bind()
{ {
glBindFramebuffer(GL_FRAMEBUFFER, framebufferid_); glBindFramebuffer(GL_FRAMEBUFFER, framebufferid_);
}
// handle window resize void FrameBuffer::begin()
glViewport(0, 0, width_, height_); {
bind();
Rendering::manager().PushAttrib(attrib_);
// GL Colors+
glClearColor(0.f, 0.f, 0.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
void FrameBuffer::end()
{
Rendering::manager().PopAttrib();
FrameBuffer::release();
}
void FrameBuffer::release() void FrameBuffer::release()
{ {
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -71,13 +86,13 @@ void FrameBuffer::release()
bool FrameBuffer::blit(FrameBuffer *other) bool FrameBuffer::blit(FrameBuffer *other)
{ {
if (width_ != other->width() || height_ != other->height()) if (attrib_.viewport.x != other->width() || attrib_.viewport.y != other->height())
return false; return false;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, other->framebufferid_); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, other->framebufferid_);
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferid_); glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferid_);
// blit to the frame buffer object // blit to the frame buffer object
glBlitFramebuffer(0, height_, width_, 0, 0, 0, glBlitFramebuffer(0, attrib_.viewport.y, attrib_.viewport.x, 0, 0, 0,
other->width(), other->height(), other->width(), other->height(),
GL_COLOR_BUFFER_BIT, GL_NEAREST); GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);

View File

@@ -2,7 +2,7 @@
#define FRAMEBUFFER_H #define FRAMEBUFFER_H
#include "Scene.h" #include "Scene.h"
#include "RenderingManager.h"
class FrameBuffer { class FrameBuffer {
@@ -12,20 +12,23 @@ public:
// bind the FrameBuffer as current to draw into // bind the FrameBuffer as current to draw into
void bind(); void bind();
// releases the framebuffer object void begin();
void end();
// release any framebuffer object
static void release(); static void release();
// blit copy to another, returns true on success // blit copy to another, returns true on success
bool blit(FrameBuffer *other); bool blit(FrameBuffer *other);
inline uint width() const { return width_; } inline uint width() const { return attrib_.viewport.x; }
inline uint height() const { return height_; } inline uint height() const { return attrib_.viewport.y; }
inline uint texture() const { return textureid_; } inline uint texture() const { return textureid_; }
float aspectRatio() const; float aspectRatio() const;
private: private:
void checkFramebufferStatus(); void checkFramebufferStatus();
uint width_; RenderingAttrib attrib_;
uint height_;
uint textureid_; uint textureid_;
uint framebufferid_; uint framebufferid_;
}; };

View File

@@ -215,7 +215,6 @@ void LineCircle::init()
} }
shader_ = new Shader(); shader_ = new Shader();
visible_ = true; visible_ = true;
initialized_ = true; initialized_ = true;
} }

View File

@@ -62,10 +62,8 @@ static void WindowRefreshCallback( GLFWwindow* window )
Rendering::Rendering() Rendering::Rendering()
{ {
window = nullptr; main_window_ = nullptr;
render_width = 0; request_screenshot_ = false;
render_height = 0;
request_screenshot = false;
} }
bool Rendering::Init() bool Rendering::Init()
@@ -90,8 +88,8 @@ bool Rendering::Init()
// Create window with graphics context // Create window with graphics context
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
window = glfwCreateWindow(winset.w, winset.h, winset.name.c_str(), NULL, NULL); main_window_ = glfwCreateWindow(winset.w, winset.h, winset.name.c_str(), NULL, NULL);
if (window == NULL){ if (main_window_ == NULL){
Log::Error("Failed to Create GLFW Window."); Log::Error("Failed to Create GLFW Window.");
return false; return false;
} }
@@ -102,14 +100,14 @@ bool Rendering::Init()
if (fp != nullptr) { if (fp != nullptr) {
GLFWimage icon; GLFWimage icon;
icon.pixels = stbi_load_from_memory( (const stbi_uc*)fp, fpsize, &icon.width, &icon.height, nullptr, 4 ); icon.pixels = stbi_load_from_memory( (const stbi_uc*)fp, fpsize, &icon.width, &icon.height, nullptr, 4 );
glfwSetWindowIcon( window, 1, &icon ); glfwSetWindowIcon( main_window_, 1, &icon );
free( icon.pixels ); free( icon.pixels );
} }
glfwSetWindowPos(window, winset.x, winset.y); glfwSetWindowPos(main_window_, winset.x, winset.y);
glfwMakeContextCurrent(window); glfwMakeContextCurrent(main_window_);
glfwSwapInterval(1); // Enable vsync3 glfwSwapInterval(1); // Enable vsync3
glfwSetWindowRefreshCallback( window, WindowRefreshCallback ); glfwSetWindowRefreshCallback( main_window_, WindowRefreshCallback );
// Initialize OpenGL loader // Initialize OpenGL loader
bool err = gladLoadGLLoader((GLADloadproc) glfwGetProcAddress) == 0; bool err = gladLoadGLLoader((GLADloadproc) glfwGetProcAddress) == 0;
@@ -119,14 +117,15 @@ bool Rendering::Init()
} }
// show window // show window
glfwShowWindow(window); glfwShowWindow(main_window_);
// restore fullscreen // restore fullscreen
if (winset.fullscreen) if (winset.fullscreen)
ToggleFullscreen(); ToggleFullscreen();
// Rendering area (not necessarily same as window) // Rendering area (here same as window)
glfwGetFramebufferSize(window, &render_width, &render_height); glfwGetFramebufferSize(main_window_, &(main_window_attributes_.viewport.x), &(main_window_attributes_.viewport.y));
glViewport(0, 0, render_width, render_height); glViewport(0, 0, main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
main_window_attributes_.clear_color = glm::vec3(COLOR_BGROUND);
// Gstreamer link to context // Gstreamer link to context
g_setenv ("GST_GL_API", "opengl3", FALSE); g_setenv ("GST_GL_API", "opengl3", FALSE);
@@ -153,10 +152,10 @@ bool Rendering::Init()
global_display = (GstGLDisplay*) gst_gl_display_x11_new_with_display( glfwGetX11Display() ); global_display = (GstGLDisplay*) gst_gl_display_x11_new_with_display( glfwGetX11Display() );
global_gl_context = gst_gl_context_new_wrapped (global_display, global_gl_context = gst_gl_context_new_wrapped (global_display,
(guintptr) glfwGetGLXContext(window), (guintptr) glfwGetGLXContext(main_window_),
GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL); GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL);
global_window_handle = (guintptr) glfwGetX11Window(window); global_window_handle = (guintptr) glfwGetX11Window(main_window_);
#endif #endif
@@ -173,25 +172,25 @@ bool Rendering::Init()
// gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE(vdpaumpegdec), GST_RANK_PRIMARY); // gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE(vdpaumpegdec), GST_RANK_PRIMARY);
// file drop callback // file drop callback
glfwSetDropCallback(window, Rendering::FileDropped); glfwSetDropCallback(main_window_, Rendering::FileDropped);
return true; return true;
} }
bool Rendering::isActive() bool Rendering::isActive()
{ {
return !glfwWindowShouldClose(window); return !glfwWindowShouldClose(main_window_);
} }
void Rendering::PushFrontDrawCallback(RenderingCallback function) void Rendering::PushFrontDrawCallback(RenderingCallback function)
{ {
drawCallbacks.push_front(function); draw_callbacks_.push_front(function);
} }
void Rendering::PushBackDrawCallback(RenderingCallback function) void Rendering::PushBackDrawCallback(RenderingCallback function)
{ {
drawCallbacks.push_back(function); draw_callbacks_.push_back(function);
} }
void Rendering::Draw() void Rendering::Draw()
@@ -201,7 +200,7 @@ void Rendering::Draw()
UserInterface::manager().NewFrame(); UserInterface::manager().NewFrame();
std::list<Rendering::RenderingCallback>::iterator iter; std::list<Rendering::RenderingCallback>::iterator iter;
for (iter=drawCallbacks.begin(); iter != drawCallbacks.end(); iter++) for (iter=draw_callbacks_.begin(); iter != draw_callbacks_.end(); iter++)
{ {
(*iter)(); (*iter)();
} }
@@ -224,19 +223,20 @@ bool Rendering::Begin()
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
glfwPollEvents(); glfwPollEvents();
glfwMakeContextCurrent(window); glfwMakeContextCurrent(main_window_);
if( glfwGetWindowAttrib( window, GLFW_ICONIFIED ) ) if( glfwGetWindowAttrib( main_window_, GLFW_ICONIFIED ) )
{ {
std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) ); std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
return false; return false;
} }
// handle window resize // handle window resize
glfwGetFramebufferSize(window, &render_width, &render_height); glfwGetFramebufferSize(main_window_, &(main_window_attributes_.viewport.x), &(main_window_attributes_.viewport.y));
glViewport(0, 0, render_width, render_height); glViewport(0, 0, main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
// GL Colors // GL Colors
glClearColor(0.2f, 0.2f, 0.2f, 1.f); glClearColor(main_window_attributes_.clear_color.r, main_window_attributes_.clear_color.g,
main_window_attributes_.clear_color.b, 1.f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
return true; return true;
@@ -244,16 +244,16 @@ bool Rendering::Begin()
void Rendering::End() void Rendering::End()
{ {
glfwMakeContextCurrent(window); glfwMakeContextCurrent(main_window_);
// perform screenshot if requested // perform screenshot if requested
if (request_screenshot) { if (request_screenshot_) {
window_screenshot.CreateFromCaptureGL(0, 0, render_width, render_height); screenshot_.CreateFromCaptureGL(0, 0, main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
request_screenshot = false; request_screenshot_ = false;
} }
// swap GL buffers // swap GL buffers
glfwSwapBuffers(window); glfwSwapBuffers(main_window_);
} }
@@ -262,23 +262,51 @@ void Rendering::Terminate()
// settings // settings
if ( !Settings::application.windows.front().fullscreen) { if ( !Settings::application.windows.front().fullscreen) {
int x, y; int x, y;
glfwGetWindowPos(window, &x, &y); glfwGetWindowPos(main_window_, &x, &y);
Settings::application.windows.front().x = x; Settings::application.windows.front().x = x;
Settings::application.windows.front().y = y; Settings::application.windows.front().y = y;
glfwGetWindowSize(window,&x, &y); glfwGetWindowSize(main_window_,&x, &y);
Settings::application.windows.front().w = x; Settings::application.windows.front().w = x;
Settings::application.windows.front().h = y; Settings::application.windows.front().h = y;
} }
// close window // close window
glfwDestroyWindow(window); glfwDestroyWindow(main_window_);
glfwTerminate(); glfwTerminate();
} }
void Rendering::Close() void Rendering::Close()
{ {
glfwSetWindowShouldClose(window, true); glfwSetWindowShouldClose(main_window_, true);
}
void Rendering::PushAttrib(RenderingAttrib ra)
{
// push it to top of pile
draw_attributes_.push_front(ra);
// apply Changes to OpenGL
glViewport(0, 0, ra.viewport.x, ra.viewport.y);
glClearColor(ra.clear_color.r, ra.clear_color.g, ra.clear_color.b, 1.f);
}
void Rendering::PopAttrib()
{
// pops the top of the pile
if (draw_attributes_.size() > 0)
draw_attributes_.pop_front();
// set attribute element to default
RenderingAttrib ra = main_window_attributes_;
// if there is an element at top, use it
if (draw_attributes_.size() > 0)
ra = draw_attributes_.front();
// apply Changes to OpenGL
glViewport(0, 0, ra.viewport.x, ra.viewport.y);
glClearColor(ra.clear_color.r, ra.clear_color.g, ra.clear_color.b, 1.f);
} }
@@ -290,12 +318,15 @@ glm::mat4 Rendering::Projection()
return projection * scale; return projection * scale;
} }
float Rendering::Width() { return main_window_attributes_.viewport.x; }
float Rendering::Height() { return main_window_attributes_.viewport.y; }
void Rendering::ToggleFullscreen() void Rendering::ToggleFullscreen()
{ {
// if in fullscreen mode // if in fullscreen mode
if (glfwGetWindowMonitor(window) != nullptr) { if (glfwGetWindowMonitor(main_window_) != nullptr) {
// set to window mode // set to window mode
glfwSetWindowMonitor( window, nullptr, Settings::application.windows.front().x, glfwSetWindowMonitor( main_window_, nullptr, Settings::application.windows.front().x,
Settings::application.windows.front().y, Settings::application.windows.front().y,
Settings::application.windows.front().w, Settings::application.windows.front().w,
Settings::application.windows.front().h, 0 ); Settings::application.windows.front().h, 0 );
@@ -305,10 +336,10 @@ void Rendering::ToggleFullscreen()
else { else {
// remember window geometry // remember window geometry
int x, y; int x, y;
glfwGetWindowPos(window, &x, &y); glfwGetWindowPos(main_window_, &x, &y);
Settings::application.windows.front().x = x; Settings::application.windows.front().x = x;
Settings::application.windows.front().y = y; Settings::application.windows.front().y = y;
glfwGetWindowSize(window,&x, &y); glfwGetWindowSize(main_window_,&x, &y);
Settings::application.windows.front().w = x; Settings::application.windows.front().w = x;
Settings::application.windows.front().h = y; Settings::application.windows.front().h = y;
@@ -317,7 +348,7 @@ void Rendering::ToggleFullscreen()
const GLFWvidmode * mode = glfwGetVideoMode(monitor); const GLFWvidmode * mode = glfwGetVideoMode(monitor);
// set to fullscreen mode // set to fullscreen mode
glfwSetWindowMonitor( window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); glfwSetWindowMonitor( main_window_, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
Settings::application.windows.front().fullscreen = true; Settings::application.windows.front().fullscreen = true;
} }
@@ -325,7 +356,7 @@ void Rendering::ToggleFullscreen()
float Rendering::AspectRatio() float Rendering::AspectRatio()
{ {
return static_cast<float>(render_width) / static_cast<float>(render_height); return static_cast<float>(main_window_attributes_.viewport.x) / static_cast<float>(main_window_attributes_.viewport.y);
} }
void Rendering::FileDropped(GLFWwindow* window, int path_count, const char* paths[]) void Rendering::FileDropped(GLFWwindow* window, int path_count, const char* paths[])
@@ -339,13 +370,13 @@ void Rendering::FileDropped(GLFWwindow* window, int path_count, const char* path
Screenshot *Rendering::CurrentScreenshot() Screenshot *Rendering::CurrentScreenshot()
{ {
return &window_screenshot; return &screenshot_;
} }
void Rendering::RequestScreenshot() void Rendering::RequestScreenshot()
{ {
window_screenshot.Clear(); screenshot_.Clear();
request_screenshot = true; request_screenshot_ = true;
} }

View File

@@ -12,7 +12,7 @@
struct RenderingAttrib struct RenderingAttrib
{ {
RenderingAttrib() {} RenderingAttrib() {}
glm::ivec4 viewport; glm::ivec2 viewport;
glm::vec3 clear_color; glm::vec3 clear_color;
}; };
@@ -22,11 +22,8 @@ class Rendering
friend class UserInterface; friend class UserInterface;
// GLFW integration in OS window management // GLFW integration in OS window management
class GLFWwindow* window; class GLFWwindow* main_window_;
Screenshot window_screenshot;
std::string glsl_version; std::string glsl_version;
int render_width, render_height;
bool request_screenshot;
// Private Constructor // Private Constructor
Rendering(); Rendering();
@@ -59,7 +56,7 @@ public:
void PushBackDrawCallback(RenderingCallback function); void PushBackDrawCallback(RenderingCallback function);
// push and pop rendering attributes // push and pop rendering attributes
void PushAttrib(glm::ivec4 viewport, glm::vec3 color); void PushAttrib(RenderingAttrib ra);
void PopAttrib(); void PopAttrib();
// request screenshot // request screenshot
@@ -70,9 +67,9 @@ public:
// request fullscreen // request fullscreen
void ToggleFullscreen(); void ToggleFullscreen();
// get width of rendering area // get width of rendering area
float Width() { return render_width; } float Width();
// get height of rendering area // get height of rendering area
float Height() { return render_height; } float Height();
// get aspect ratio of rendering area // get aspect ratio of rendering area
float AspectRatio(); float AspectRatio();
@@ -90,13 +87,17 @@ private:
void End(); void End();
// list of rendering attributes // list of rendering attributes
std::list<RenderingAttrib> drawAttributes; std::list<RenderingAttrib> draw_attributes_;
RenderingAttrib main_window_attributes_;
// list of functions to call at each Draw // list of functions to call at each Draw
std::list<RenderingCallback> drawCallbacks; std::list<RenderingCallback> draw_callbacks_;
// file drop callback // file drop callback
static void FileDropped(GLFWwindow* window, int path_count, const char* paths[]); static void FileDropped(GLFWwindow* main_window_, int path_count, const char* paths[]);
Screenshot screenshot_;
bool request_screenshot_;
}; };

View File

@@ -203,11 +203,3 @@ void Shader::reset()
} }
void Shader::setModelview(float x, float y, float angle, float scale, float aspect_ratio)
{
glm::mat4 View = glm::translate(glm::identity<glm::mat4>(), glm::vec3(x, y, 0.f));
View = glm::rotate(View, angle, glm::vec3(0.0f, 0.0f, 1.0f));
glm::mat4 Model = glm::scale(glm::identity<glm::mat4>(), glm::vec3(scale * aspect_ratio, scale, scale));
modelview = View * Model;
}

View File

@@ -59,11 +59,10 @@ public:
} BlendMode; } BlendMode;
BlendMode blending; BlendMode blending;
void setModelview(float x, float y, float angle, float scale, float aspect_ratio);
protected: protected:
ShadingProgram *program_; ShadingProgram *program_;
}; };
#endif /* __SHADER_H_ */ #endif /* __SHADER_H_ */

View File

@@ -73,7 +73,7 @@ UserInterface::UserInterface()
bool UserInterface::Init() bool UserInterface::Init()
{ {
if (Rendering::manager().window == nullptr) if (Rendering::manager().main_window_ == nullptr)
return false; return false;
// Setup Dear ImGui context // Setup Dear ImGui context
@@ -84,7 +84,7 @@ bool UserInterface::Init()
io.MouseDrawCursor = true; io.MouseDrawCursor = true;
// Setup Platform/Renderer bindings // Setup Platform/Renderer bindings
ImGui_ImplGlfw_InitForOpenGL(Rendering::manager().window, true); ImGui_ImplGlfw_InitForOpenGL(Rendering::manager().main_window_, true);
ImGui_ImplOpenGL3_Init(Rendering::manager().glsl_version.c_str()); ImGui_ImplOpenGL3_Init(Rendering::manager().glsl_version.c_str());
// Setup Dear ImGui style // Setup Dear ImGui style

View File

@@ -19,6 +19,13 @@
#define SCENE_UNIT 10.0 #define SCENE_UNIT 10.0
#define CIRCLE_SQUARE_DIST(x,y) ( (x*x + y*y) / (SCENE_UNIT * SCENE_UNIT * SCENE_UNIT * SCENE_UNIT) ) #define CIRCLE_SQUARE_DIST(x,y) ( (x*x + y*y) / (SCENE_UNIT * SCENE_UNIT * SCENE_UNIT * SCENE_UNIT) )
#define IMGUI_TITLE_MAINWINDOW ICON_FA_CIRCLE_NOTCH " v-mix"
#define IMGUI_TITLE_MEDIAPLAYER ICON_FA_FILM " Media Player"
#define IMGUI_TITLE_SHADEREDITOR ICON_FA_CODE " Shader Editor"
#define COLOR_BGROUND 0.2, 0.2, 0.2
// from glmixer
#define TEXTURE_REQUIRED_MAXIMUM 2048 #define TEXTURE_REQUIRED_MAXIMUM 2048
#define CATALOG_TEXTURE_HEIGHT 96 #define CATALOG_TEXTURE_HEIGHT 96
#define SELECTBUFSIZE 512 #define SELECTBUFSIZE 512
@@ -42,7 +49,6 @@
#define COLOR_SOURCE_STATIC 230, 40, 40 #define COLOR_SOURCE_STATIC 230, 40, 40
#define COLOR_SELECTION 10, 210, 40 #define COLOR_SELECTION 10, 210, 40
#define COLOR_SELECTION_AREA 50, 210, 50 #define COLOR_SELECTION_AREA 50, 210, 50
#define COLOR_BGROUND 52, 52, 52
#define COLOR_CIRCLE 210, 30, 210 #define COLOR_CIRCLE 210, 30, 210
#define COLOR_CIRCLE_MOVE 230, 30, 230 #define COLOR_CIRCLE_MOVE 230, 30, 230
#define COLOR_DRAWINGS 180, 180, 180 #define COLOR_DRAWINGS 180, 180, 180
@@ -54,9 +60,6 @@
#define COLOR_FRAME_MOVE 230, 30, 230 #define COLOR_FRAME_MOVE 230, 30, 230
#define COLOR_CURSOR 10, 100, 255 #define COLOR_CURSOR 10, 100, 255
#define IMGUI_TITLE_MAINWINDOW ICON_FA_CIRCLE_NOTCH " v-mix"
#define IMGUI_TITLE_MEDIAPLAYER ICON_FA_FILM " Media Player"
#define IMGUI_TITLE_SHADEREDITOR ICON_FA_CODE " Shader Editor"
#endif // VMIX_DEFINES_H #endif // VMIX_DEFINES_H

View File

@@ -178,26 +178,21 @@ void drawScene()
last_time = current_time; last_time = current_time;
// recursive update from root of scene // recursive update from root of scene
glm::mat4 MV = glm::identity<glm::mat4>();
glm::mat4 P = glm::scale( glm::ortho(-5.f, 5.f, -5.f, 5.f), glm::vec3(1.f, output->aspectRatio(), 1.f));
// glm::mat4 View = glm::translate(glm::identity<glm::mat4>(), glm::vec3(0, 0, 0.f));
// View = glm::rotate(View, 0.f, glm::vec3(0.0f, 0.0f, 1.0f));
// glm::mat4 Model = glm::scale(glm::identity<glm::mat4>(), glm::vec3(1, 1, 1));
// mv = View * Model;
scene.root_.update( static_cast<float>( GST_TIME_AS_MSECONDS(dt)) * 0.001f ); scene.root_.update( static_cast<float>( GST_TIME_AS_MSECONDS(dt)) * 0.001f );
// draw in output frame buffer // draw in output frame buffer
output->bind(); glm::mat4 P = glm::scale( glm::ortho(-5.f, 5.f, -5.f, 5.f), glm::vec3(1.f, output->aspectRatio(), 1.f));
scene.root_.draw(MV, P); output->begin();
FrameBuffer::release(); scene.root_.draw(glm::identity<glm::mat4>(), P);
output->end();
// draw in main view
scene.root_.draw(glm::identity<glm::mat4>(), Rendering::manager().Projection());
// draw GUI tree scene // draw GUI tree scene
ImGui::Begin(IMGUI_TITLE_MAINWINDOW); ImGui::Begin(IMGUI_TITLE_MAINWINDOW);
static ImGuiVisitor v; static ImGuiVisitor v;
scene.accept(v); scene.accept(v);
ImGui::End(); ImGui::End();
} }