mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-14 03:39:57 +01:00
Setup Multisampling for all rendering and frame buffers. Store in
settings.
This commit is contained in:
@@ -57,9 +57,6 @@ void Frame::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
|
|
||||||
if ( visible_ ) {
|
if ( visible_ ) {
|
||||||
|
|
||||||
// enable antialiasing
|
|
||||||
glEnable(GL_MULTISAMPLE_ARB);
|
|
||||||
|
|
||||||
// shadow
|
// shadow
|
||||||
if(shadow_)
|
if(shadow_)
|
||||||
shadow_->draw( modelview * transform_, projection);
|
shadow_->draw( modelview * transform_, projection);
|
||||||
@@ -83,8 +80,6 @@ void Frame::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
border_->draw( ctm, projection );
|
border_->draw( ctm, projection );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// enable antialiasing
|
|
||||||
glDisable(GL_MULTISAMPLE_ARB);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +124,6 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( visible_ ) {
|
if ( visible_ ) {
|
||||||
// enable antialiasing
|
|
||||||
glEnable(GL_MULTISAMPLE_ARB);
|
|
||||||
|
|
||||||
// set color
|
// set color
|
||||||
handle_->shader()->color = color;
|
handle_->shader()->color = color;
|
||||||
@@ -185,8 +178,6 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
||||||
handle_->draw( ctm, projection );
|
handle_->draw( ctm, projection );
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_MULTISAMPLE_ARB);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,9 +231,6 @@ void Icon::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
|
|
||||||
if ( visible_ ) {
|
if ( visible_ ) {
|
||||||
|
|
||||||
// enable antialiasing
|
|
||||||
glEnable(GL_MULTISAMPLE_ARB);
|
|
||||||
|
|
||||||
if(icon_) {
|
if(icon_) {
|
||||||
// set color
|
// set color
|
||||||
icon_->shader()->color = color;
|
icon_->shader()->color = color;
|
||||||
@@ -254,9 +242,6 @@ void Icon::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
|
|
||||||
icon_->draw( ctm, projection);
|
icon_->draw( ctm, projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable antialiasing
|
|
||||||
glDisable(GL_MULTISAMPLE_ARB);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
#include "ImageShader.h"
|
#include "ImageShader.h"
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
|
#include "Settings.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -20,58 +21,65 @@ glm::vec3 FrameBuffer::getResolutionFromParameters(int ar, int h)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::FrameBuffer(glm::vec3 resolution, bool useAlpha, bool useDepthBuffer): textureid_(0), framebufferid_(0), usealpha_(useAlpha), usedepth_(useDepthBuffer)
|
FrameBuffer::FrameBuffer(glm::vec3 resolution, bool useAlpha, bool multiSampling): textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0), use_alpha_(useAlpha), use_multi_sampling_(multiSampling)
|
||||||
{
|
{
|
||||||
attrib_.viewport = glm::ivec2(resolution);
|
attrib_.viewport = glm::ivec2(resolution);
|
||||||
attrib_.clear_color = glm::vec4(0.f, 0.f, 0.f, usealpha_ ? 0.f : 1.f);
|
attrib_.clear_color = glm::vec4(0.f, 0.f, 0.f, use_alpha_ ? 0.f : 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::FrameBuffer(uint width, uint height, bool useAlpha, bool useDepthBuffer): textureid_(0), framebufferid_(0), usealpha_(useAlpha), usedepth_(useDepthBuffer)
|
FrameBuffer::FrameBuffer(uint width, uint height, bool useAlpha, bool multiSampling): textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0), use_alpha_(useAlpha), use_multi_sampling_(multiSampling)
|
||||||
{
|
{
|
||||||
attrib_.viewport = glm::ivec2(width, height);
|
attrib_.viewport = glm::ivec2(width, height);
|
||||||
attrib_.clear_color = glm::vec4(0.f, 0.f, 0.f, usealpha_ ? 0.f : 1.f);
|
attrib_.clear_color = glm::vec4(0.f, 0.f, 0.f, use_alpha_ ? 0.f : 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::init()
|
void FrameBuffer::init()
|
||||||
{
|
{
|
||||||
// create a renderbuffer object to store depth info
|
|
||||||
GLuint rboId;
|
|
||||||
if (usedepth_){
|
|
||||||
glGenRenderbuffers(1, &rboId);
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, rboId);
|
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, attrib_.viewport.x, attrib_.viewport.y);
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a framebuffer object
|
|
||||||
glGenFramebuffers(1, &framebufferid_);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, framebufferid_);
|
|
||||||
|
|
||||||
// generate texture
|
// generate texture
|
||||||
glGenTextures(1, &textureid_);
|
glGenTextures(1, &textureid_);
|
||||||
glBindTexture(GL_TEXTURE_2D, textureid_);
|
glBindTexture(GL_TEXTURE_2D, textureid_);
|
||||||
if (usealpha_)
|
glTexImage2D(GL_TEXTURE_2D, 0, use_alpha_ ? GL_RGBA : GL_RGB, attrib_.viewport.x, attrib_.viewport.y,
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, attrib_.viewport.x, attrib_.viewport.y,
|
|
||||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
else
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, attrib_.viewport.x, attrib_.viewport.y,
|
|
||||||
0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
// attach the texture to FBO color attachment point
|
// create a framebuffer object
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
glGenFramebuffers(1, &framebufferid_);
|
||||||
GL_TEXTURE_2D, textureid_, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, framebufferid_);
|
||||||
|
|
||||||
// attach the renderbuffer to depth attachment point
|
// take settings into account: no multisampling for level 0
|
||||||
if (usedepth_){
|
use_multi_sampling_ &= Settings::application.multisampling_level > 0;
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
|
||||||
GL_RENDERBUFFER, rboId);
|
if (use_multi_sampling_){
|
||||||
|
|
||||||
|
// create a multisample texture
|
||||||
|
glGenTextures(1, &intermediate_textureid_);
|
||||||
|
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, intermediate_textureid_);
|
||||||
|
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, Settings::application.multisampling_level,
|
||||||
|
use_alpha_ ? GL_RGBA : GL_RGB, attrib_.viewport.x, attrib_.viewport.y, GL_TRUE);
|
||||||
|
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
|
||||||
|
|
||||||
|
// attach the multisampled texture to FBO (currently binded)
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, intermediate_textureid_, 0);
|
||||||
|
|
||||||
|
// create an intermediate FBO
|
||||||
|
glGenFramebuffers(1, &intermediate_framebufferid_);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, intermediate_framebufferid_);
|
||||||
|
|
||||||
|
// attach the 2D texture to intermediate FBO
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureid_, 0);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// direct attach the 2D texture to FBO
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureid_, 0);
|
||||||
|
}
|
||||||
|
|
||||||
checkFramebufferStatus();
|
checkFramebufferStatus();
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::~FrameBuffer()
|
FrameBuffer::~FrameBuffer()
|
||||||
@@ -119,9 +127,18 @@ void FrameBuffer::begin()
|
|||||||
|
|
||||||
void FrameBuffer::end()
|
void FrameBuffer::end()
|
||||||
{
|
{
|
||||||
Rendering::manager().popAttrib();
|
// if multisampling frame buffer
|
||||||
|
if (use_multi_sampling_) {
|
||||||
|
// blit the multisample FBO into unisample FBO to generate 2D texture
|
||||||
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferid_);
|
||||||
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, intermediate_framebufferid_);
|
||||||
|
glBlitFramebuffer(0, 0, attrib_.viewport.x, attrib_.viewport.y,
|
||||||
|
0, 0, attrib_.viewport.x, attrib_.viewport.y, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
}
|
||||||
|
|
||||||
FrameBuffer::release();
|
FrameBuffer::release();
|
||||||
|
|
||||||
|
Rendering::manager().popAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::release()
|
void FrameBuffer::release()
|
||||||
@@ -131,11 +148,11 @@ void FrameBuffer::release()
|
|||||||
|
|
||||||
bool FrameBuffer::blit(FrameBuffer *other)
|
bool FrameBuffer::blit(FrameBuffer *other)
|
||||||
{
|
{
|
||||||
if (!framebufferid_ || !other || !other->id())
|
if (!framebufferid_ || !other || !other->framebufferid_)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, other->framebufferid_);
|
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferid_);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferid_);
|
||||||
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, other->framebufferid_);
|
||||||
// blit to the frame buffer object
|
// blit to the frame buffer object
|
||||||
glBlitFramebuffer(0, 0, attrib_.viewport.x, attrib_.viewport.y,
|
glBlitFramebuffer(0, 0, attrib_.viewport.x, attrib_.viewport.y,
|
||||||
0, 0, other->width(), other->height(),
|
0, 0, other->width(), other->height(),
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ public:
|
|||||||
static float resolution_height[4];
|
static float resolution_height[4];
|
||||||
static glm::vec3 getResolutionFromParameters(int ar, int h);
|
static glm::vec3 getResolutionFromParameters(int ar, int h);
|
||||||
|
|
||||||
FrameBuffer(glm::vec3 resolution, bool useAlpha = false, bool useDepthBuffer = false);
|
FrameBuffer(glm::vec3 resolution, bool useAlpha = false, bool multiSampling = false);
|
||||||
FrameBuffer(uint width, uint height, bool useAlpha = false, bool useDepthBuffer = false);
|
FrameBuffer(uint width, uint height, bool useAlpha = false, bool multiSampling = false);
|
||||||
~FrameBuffer();
|
~FrameBuffer();
|
||||||
|
|
||||||
// bind the FrameBuffer as current to draw into
|
// bind the FrameBuffer as current to draw into
|
||||||
@@ -43,16 +43,16 @@ public:
|
|||||||
// texture index for draw
|
// texture index for draw
|
||||||
uint texture() const;
|
uint texture() const;
|
||||||
|
|
||||||
inline uint id() const { return framebufferid_; }
|
// inline uint id() const { return framebufferid_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void checkFramebufferStatus();
|
void checkFramebufferStatus();
|
||||||
|
|
||||||
RenderingAttrib attrib_;
|
RenderingAttrib attrib_;
|
||||||
uint textureid_;
|
uint textureid_, intermediate_textureid_;
|
||||||
uint framebufferid_;
|
uint framebufferid_, intermediate_framebufferid_;
|
||||||
bool usealpha_, usedepth_;
|
bool use_alpha_, use_multi_sampling_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -255,14 +255,9 @@ void LineStrip::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
|
|
||||||
glLineWidth(linewidth_);
|
glLineWidth(linewidth_);
|
||||||
|
|
||||||
// enable antialiasing
|
|
||||||
glEnable(GL_MULTISAMPLE_ARB);
|
|
||||||
|
|
||||||
Primitive::draw(modelview, projection);
|
Primitive::draw(modelview, projection);
|
||||||
|
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glDisable(GL_MULTISAMPLE_ARB);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineStrip::accept(Visitor& v)
|
void LineStrip::accept(Visitor& v)
|
||||||
|
|||||||
@@ -95,6 +95,32 @@ static void WindowMoveCallback( GLFWwindow *w, int x, int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void WindowKeyCallback( GLFWwindow *w, int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE)
|
||||||
|
{
|
||||||
|
// Log::Info("Esc");
|
||||||
|
// escape fullscreen
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WindowMouseCallback( GLFWwindow *w, int button, int action, int mods)
|
||||||
|
{
|
||||||
|
static double seconds = 0.f;
|
||||||
|
|
||||||
|
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS)
|
||||||
|
{
|
||||||
|
// detect double clic
|
||||||
|
if ( glfwGetTime() - seconds < 0.2f ) {
|
||||||
|
Log::Info("double clic");
|
||||||
|
// toggle fullscreen
|
||||||
|
|
||||||
|
}
|
||||||
|
// for next clic detection
|
||||||
|
seconds = glfwGetTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rendering::Rendering()
|
Rendering::Rendering()
|
||||||
{
|
{
|
||||||
@@ -121,7 +147,7 @@ bool Rendering::init()
|
|||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
|
||||||
#endif
|
#endif
|
||||||
// GL Multisampling #3
|
// GL Multisampling #3
|
||||||
glfwWindowHint(GLFW_SAMPLES, 3);
|
glfwWindowHint(GLFW_SAMPLES, Settings::application.multisampling_level);
|
||||||
|
|
||||||
// Create window with graphics context
|
// Create window with graphics context
|
||||||
Settings::WindowConfig winset = Settings::application.windows[0];
|
Settings::WindowConfig winset = Settings::application.windows[0];
|
||||||
@@ -160,11 +186,11 @@ bool Rendering::init()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// show window
|
// // show window
|
||||||
glfwShowWindow(main_window_);
|
// glfwShowWindow(main_window_);
|
||||||
// restore fullscreen
|
// // restore fullscreen
|
||||||
if (winset.fullscreen)
|
// if (winset.fullscreen)
|
||||||
toggleFullscreen();
|
// toggleFullscreen();
|
||||||
|
|
||||||
// Rendering area (here same as window)
|
// Rendering area (here same as window)
|
||||||
glfwGetFramebufferSize(main_window_, &(main_window_attributes_.viewport.x), &(main_window_attributes_.viewport.y));
|
glfwGetFramebufferSize(main_window_, &(main_window_attributes_.viewport.x), &(main_window_attributes_.viewport.y));
|
||||||
@@ -179,7 +205,10 @@ bool Rendering::init()
|
|||||||
gst_init (NULL, NULL);
|
gst_init (NULL, NULL);
|
||||||
|
|
||||||
// Antialiasing
|
// Antialiasing
|
||||||
|
if (Settings::application.multisampling_level > 0) {
|
||||||
|
glEnable(GL_MULTISAMPLE_ARB);
|
||||||
glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);
|
glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);
|
||||||
|
}
|
||||||
// This hint can improve the speed of texturing when perspective-correct texture coordinate interpolation isn't needed
|
// This hint can improve the speed of texturing when perspective-correct texture coordinate interpolation isn't needed
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||||
// This hint can improve the speed of shading when dFdx dFdy aren't needed in GLSL
|
// This hint can improve the speed of shading when dFdx dFdy aren't needed in GLSL
|
||||||
@@ -230,6 +259,12 @@ bool Rendering::init()
|
|||||||
// output window
|
// output window
|
||||||
output.init(main_window_, 1);
|
output.init(main_window_, 1);
|
||||||
|
|
||||||
|
// show window
|
||||||
|
glfwShowWindow(main_window_);
|
||||||
|
// restore fullscreen
|
||||||
|
if (winset.fullscreen)
|
||||||
|
toggleFullscreen();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,9 +565,9 @@ bool RenderingWindow::init(GLFWwindow *share, int id)
|
|||||||
glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
|
glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
|
||||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_SAMPLES, 0);
|
// glfwWindowHint(GLFW_SAMPLES, 0);
|
||||||
glfwWindowHint(GLFW_DEPTH_BITS, 0);
|
// glfwWindowHint(GLFW_DEPTH_BITS, 0);
|
||||||
glfwWindowHint(GLFW_ALPHA_BITS, 0);
|
// glfwWindowHint(GLFW_ALPHA_BITS, 0);
|
||||||
|
|
||||||
window_ = glfwCreateWindow(winset.w, winset.h, winset.name.c_str(), NULL, master_);
|
window_ = glfwCreateWindow(winset.w, winset.h, winset.name.c_str(), NULL, master_);
|
||||||
if (window_ == NULL){
|
if (window_ == NULL){
|
||||||
@@ -544,6 +579,8 @@ bool RenderingWindow::init(GLFWwindow *share, int id)
|
|||||||
// callbacks
|
// callbacks
|
||||||
glfwSetFramebufferSizeCallback( window_, WindowResizeCallback );
|
glfwSetFramebufferSizeCallback( window_, WindowResizeCallback );
|
||||||
glfwSetWindowPosCallback( window_, WindowMoveCallback );
|
glfwSetWindowPosCallback( window_, WindowMoveCallback );
|
||||||
|
glfwSetKeyCallback( window_, WindowKeyCallback);
|
||||||
|
glfwSetMouseButtonCallback( window_, WindowMouseCallback);
|
||||||
|
|
||||||
// take context ownership
|
// take context ownership
|
||||||
glfwMakeContextCurrent(window_);
|
glfwMakeContextCurrent(window_);
|
||||||
@@ -586,12 +623,10 @@ void RenderingWindow::draw(FrameBuffer *fb)
|
|||||||
// take context ownership
|
// take context ownership
|
||||||
glfwMakeContextCurrent(window_);
|
glfwMakeContextCurrent(window_);
|
||||||
|
|
||||||
// render some stuff
|
// update viewport (could be done with callback)
|
||||||
glfwGetFramebufferSize(window_, &(window_attributes_.viewport.x), &(window_attributes_.viewport.y));
|
glfwGetFramebufferSize(window_, &(window_attributes_.viewport.x), &(window_attributes_.viewport.y));
|
||||||
glViewport(0, 0, window_attributes_.viewport.x, window_attributes_.viewport.y);
|
|
||||||
|
|
||||||
glClearColor(window_attributes_.clear_color.r, window_attributes_.clear_color.g,
|
Rendering::manager().pushAttrib(window_attributes_);
|
||||||
window_attributes_.clear_color.b, window_attributes_.clear_color.a);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
static glm::mat4 projection = glm::ortho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
|
static glm::mat4 projection = glm::ortho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
|
||||||
@@ -610,6 +645,10 @@ void RenderingWindow::draw(FrameBuffer *fb)
|
|||||||
surface->draw(glm::scale(glm::identity<glm::mat4>(), scale), projection);
|
surface->draw(glm::scale(glm::identity<glm::mat4>(), scale), projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
Rendering::manager().popAttrib();
|
||||||
|
|
||||||
|
|
||||||
// swap buffer
|
// swap buffer
|
||||||
glfwSwapBuffers(window_);
|
glfwSwapBuffers(window_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ void Settings::Save()
|
|||||||
applicationNode->SetAttribute("toolbox", application.toolbox);
|
applicationNode->SetAttribute("toolbox", application.toolbox);
|
||||||
applicationNode->SetAttribute("framebuffer_ar", application.framebuffer_ar);
|
applicationNode->SetAttribute("framebuffer_ar", application.framebuffer_ar);
|
||||||
applicationNode->SetAttribute("framebuffer_h", application.framebuffer_h);
|
applicationNode->SetAttribute("framebuffer_h", application.framebuffer_h);
|
||||||
|
applicationNode->SetAttribute("multisampling_level", application.multisampling_level);
|
||||||
pRoot->InsertEndChild(applicationNode);
|
pRoot->InsertEndChild(applicationNode);
|
||||||
|
|
||||||
// bloc views
|
// bloc views
|
||||||
@@ -166,6 +167,7 @@ void Settings::Load()
|
|||||||
pElement->QueryIntAttribute("stats_corner", &application.stats_corner);
|
pElement->QueryIntAttribute("stats_corner", &application.stats_corner);
|
||||||
pElement->QueryIntAttribute("framebuffer_ar", &application.framebuffer_ar);
|
pElement->QueryIntAttribute("framebuffer_ar", &application.framebuffer_ar);
|
||||||
pElement->QueryIntAttribute("framebuffer_h", &application.framebuffer_h);
|
pElement->QueryIntAttribute("framebuffer_h", &application.framebuffer_h);
|
||||||
|
pElement->QueryIntAttribute("multisampling_level", &application.multisampling_level);
|
||||||
|
|
||||||
// bloc windows
|
// bloc windows
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ struct Application
|
|||||||
std::map<int, ViewConfig> views;
|
std::map<int, ViewConfig> views;
|
||||||
int framebuffer_ar;
|
int framebuffer_ar;
|
||||||
int framebuffer_h;
|
int framebuffer_h;
|
||||||
|
int multisampling_level;
|
||||||
|
|
||||||
// multiple windows handling
|
// multiple windows handling
|
||||||
// TODO: manage other windows
|
|
||||||
std::vector<WindowConfig> windows;
|
std::vector<WindowConfig> windows;
|
||||||
|
|
||||||
// recent files histories
|
// recent files histories
|
||||||
@@ -98,6 +98,7 @@ struct Application
|
|||||||
current_view = 1;
|
current_view = 1;
|
||||||
framebuffer_ar = 3;
|
framebuffer_ar = 3;
|
||||||
framebuffer_h = 1;
|
framebuffer_h = 1;
|
||||||
|
multisampling_level = 2; // todo GUI selection
|
||||||
std::vector<int> second (4,100);
|
std::vector<int> second (4,100);
|
||||||
windows = std::vector<WindowConfig>(3);
|
windows = std::vector<WindowConfig>(3);
|
||||||
windows[0].name = APP_NAME APP_TITLE;
|
windows[0].name = APP_NAME APP_TITLE;
|
||||||
|
|||||||
3
View.cpp
3
View.cpp
@@ -205,7 +205,8 @@ void RenderView::setResolution(glm::vec3 resolution)
|
|||||||
if (frame_buffer_)
|
if (frame_buffer_)
|
||||||
delete frame_buffer_;
|
delete frame_buffer_;
|
||||||
|
|
||||||
frame_buffer_ = new FrameBuffer(resolution);
|
// output frame is an RBG Multisamples FrameBuffer
|
||||||
|
frame_buffer_ = new FrameBuffer(resolution, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderView::draw()
|
void RenderView::draw()
|
||||||
|
|||||||
@@ -34,14 +34,12 @@
|
|||||||
#define IMGUI_TITLE_DELETE ICON_FA_BROOM " Delete?"
|
#define IMGUI_TITLE_DELETE ICON_FA_BROOM " Delete?"
|
||||||
#define IMGUI_RIGHT_ALIGN -3.5f * ImGui::GetTextLineHeightWithSpacing()
|
#define IMGUI_RIGHT_ALIGN -3.5f * ImGui::GetTextLineHeightWithSpacing()
|
||||||
#define IMGUI_NOTIFICATION_DURATION 1.5f
|
#define IMGUI_NOTIFICATION_DURATION 1.5f
|
||||||
|
|
||||||
#ifdef APPLE
|
#ifdef APPLE
|
||||||
#define CTRL_MOD "Cmd+"
|
#define CTRL_MOD "Cmd+"
|
||||||
#else
|
#else
|
||||||
#define CTRL_MOD "Ctrl+"
|
#define CTRL_MOD "Ctrl+"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define COLOR_BGROUND 0.2f, 0.2f, 0.2f
|
#define COLOR_BGROUND 0.2f, 0.2f, 0.2f
|
||||||
#define COLOR_NAVIGATOR 0.1f, 0.1f, 0.1f
|
#define COLOR_NAVIGATOR 0.1f, 0.1f, 0.1f
|
||||||
#define COLOR_DEFAULT_SOURCE 1.f, 1.f, 1.f
|
#define COLOR_DEFAULT_SOURCE 1.f, 1.f, 1.f
|
||||||
|
|||||||
Reference in New Issue
Block a user