mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 10:49:59 +01:00
Work in progress - towards display initials on sources
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include <glad/glad.h>
|
||||||
|
|
||||||
Frame::Frame(CornerType corner, BorderType border, ShadowType shadow) : Node(),
|
Frame::Frame(CornerType corner, BorderType border, ShadowType shadow) : Node(),
|
||||||
right_(nullptr), left_(nullptr), top_(nullptr), shadow_(nullptr), square_(nullptr)
|
right_(nullptr), left_(nullptr), top_(nullptr), shadow_(nullptr), square_(nullptr)
|
||||||
@@ -557,54 +559,76 @@ void Disk::accept(Visitor& v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//SelectionBox::SelectionBox()
|
|
||||||
//{
|
|
||||||
//// color = glm::vec4( 1.f, 1.f, 1.f, 1.f);
|
|
||||||
// color = glm::vec4( 1.f, 0.f, 0.f, 1.f);
|
|
||||||
// square_ = new LineSquare( 3 );
|
|
||||||
|
|
||||||
//}
|
//FrameBuffer *textToFrameBuffer(const std::string &text, font_style type, uint h)
|
||||||
|
|
||||||
//void SelectionBox::draw (glm::mat4 modelview, glm::mat4 projection)
|
|
||||||
//{
|
//{
|
||||||
// if ( !initialized() ) {
|
// FrameBuffer *fb = nullptr;
|
||||||
// square_->init();
|
|
||||||
// init();
|
// uint w = 0;
|
||||||
|
// for (auto i = 0; i < text.size(); ++i) {
|
||||||
|
// const ImFontGlyph* glyph = fontmap[type]->FindGlyph( text[i] );
|
||||||
|
// w += h * (uint) ceil( (glyph->X1 - glyph->X0) / (glyph->Y1 - glyph->Y0) );
|
||||||
// }
|
// }
|
||||||
|
// if (w > 0) {
|
||||||
|
|
||||||
// if (visible_) {
|
// // create and fill a FrameBuffer with the ImGui Font texture (once)
|
||||||
|
// static uint framebufferFont_ = 0;
|
||||||
// // use a visitor bounding box to calculate extend of all selected nodes
|
// static uint textureFont_ = 0;
|
||||||
// BoundingBoxVisitor vbox;
|
// static int widthFont_ =0;
|
||||||
|
// static int heightFont_ =0;
|
||||||
// // visit every child of the selection
|
// if (framebufferFont_ == 0) {
|
||||||
// for (NodeSet::iterator node = children_.begin();
|
// glGenTextures(1, &textureFont_);
|
||||||
// node != children_.end(); node++) {
|
// glBindTexture(GL_TEXTURE_2D, textureFont_);
|
||||||
// // reset the transform before
|
// unsigned char *pixels;
|
||||||
// vbox.setModelview(glm::identity<glm::mat4>());
|
// int bpp = 0;
|
||||||
// (*node)->accept(vbox);
|
// ImGuiIO& io = ImGui::GetIO();
|
||||||
|
// io.Fonts->GetTexDataAsRGBA32(&pixels, &widthFont_, &heightFont_, &bpp);
|
||||||
|
// glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA, widthFont_, heightFont_);
|
||||||
|
// glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, widthFont_, heightFont_, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
// glGenFramebuffers(1, &framebufferFont_);
|
||||||
|
// glBindFramebuffer(GL_FRAMEBUFFER, framebufferFont_);
|
||||||
|
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureFont_, 0);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // get the bounding box
|
// // create an empty FrameBuffer for the target glyphs
|
||||||
// bbox_ = vbox.bbox();
|
// fb = new FrameBuffer(w, h, true);
|
||||||
|
|
||||||
//// Log::Info(" -------- visitor box (%f, %f)-(%f, %f)", bbox_.min().x, bbox_.min().y, bbox_.max().x, bbox_.max().y);
|
//// uint textureGlyphs_ = 0;
|
||||||
|
//// glGenTextures(1, &textureGlyphs_);
|
||||||
|
//// glBindTexture(GL_TEXTURE_2D, textureGlyphs_);
|
||||||
|
//// glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA, w, h);
|
||||||
|
//// glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
//// uint framebufferGlyphs_ = 0;
|
||||||
|
//// glGenFramebuffers(1, &framebufferGlyphs_);
|
||||||
|
//// glBindFramebuffer(GL_FRAMEBUFFER, framebufferGlyphs_);
|
||||||
|
//// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureGlyphs_, 0);
|
||||||
|
|
||||||
// // set color
|
//// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferGlyphs_);
|
||||||
// square_->shader()->color = color;
|
|
||||||
|
|
||||||
// // compute transformation from bounding box
|
|
||||||
//// glm::mat4 ctm = modelview * GlmToolkit::transform(glm::vec3(0.f), glm::vec3(0.f), glm::vec3(1.f));
|
|
||||||
// glm::mat4 ctm = modelview * GlmToolkit::transform(bbox_.center(), glm::vec3(0.f), bbox_.scale());
|
|
||||||
|
|
||||||
// // draw bbox
|
// // blit glyphs from framebufferFont_ to framebuffer target
|
||||||
//// square_->draw( modelview, projection);
|
// glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferFont_);
|
||||||
// square_->draw( ctm, projection);
|
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb->opengl_id() );
|
||||||
|
|
||||||
|
// GLint write_x = 0;
|
||||||
|
// for (auto i = 0; i < text.size(); ++i) {
|
||||||
|
// const ImFontGlyph* glyph = fontmap[type]->FindGlyph( text[i] );
|
||||||
|
// w = h * (uint) ceil( (glyph->X1 - glyph->X0) / (glyph->Y1 - glyph->Y0) );
|
||||||
|
|
||||||
|
// GLint read_x0 = (GLint) ( glyph->U0 * (float) widthFont_ );
|
||||||
|
// GLint read_y0 = (GLint) ( glyph->V0 * (float) heightFont_ );
|
||||||
|
// GLint read_x1 = (GLint) ( glyph->U1 * (float) widthFont_ );
|
||||||
|
// GLint read_y1 = (GLint) ( glyph->V1 * (float) heightFont_ );
|
||||||
|
// glBlitFramebuffer(read_x0, read_y0, read_x1, read_y1,
|
||||||
|
// write_x, 0, w, h, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||||
|
|
||||||
|
// write_x += w;
|
||||||
|
// }
|
||||||
|
|
||||||
// // DEBUG
|
|
||||||
//// visible_=false;
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// return fb;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -94,18 +94,19 @@ protected:
|
|||||||
static Mesh *disk_;
|
static Mesh *disk_;
|
||||||
};
|
};
|
||||||
|
|
||||||
//class SelectionBox : public Group
|
//class TextSurface : public Node
|
||||||
//{
|
//{
|
||||||
//public:
|
//public:
|
||||||
// SelectionBox();
|
// TextSurface();
|
||||||
|
|
||||||
// void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
// void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
||||||
|
|
||||||
|
// void setText(const std::string &t);
|
||||||
// glm::vec4 color;
|
// glm::vec4 color;
|
||||||
|
|
||||||
//protected:
|
//protected:
|
||||||
// LineSquare *square_;
|
|
||||||
// GlmToolkit::AxisAlignedBoundingBox bbox_;
|
// std::string text_;
|
||||||
|
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user