Clean up
This commit is contained in:
1 parent
16d250a51d
commit
519d780b3c
9 files changed
+25
-126
No files matched your search
@@ -9,10 +9,9 @@ namespace ZL {
|
||||
GLuint fbo = 0;
|
||||
GLuint textureID = 0;
|
||||
int width, height;
|
||||
bool useMipmaps; // ���� ������������� ���-�����
|
||||
bool useMipmaps;
|
||||
|
||||
public:
|
||||
// ��������� �������� � ����������� �� ��������� false
|
||||
FrameBuffer(int w, int h, bool useMipmaps = false);
|
||||
~FrameBuffer();
|
||||
|
||||
@@ -22,7 +21,6 @@ namespace ZL {
|
||||
void Bind();
|
||||
void Unbind();
|
||||
|
||||
// ����� ��� �������������� ��������� ���-����� ����� �������
|
||||
void GenerateMipmaps();
|
||||
|
||||
GLuint getTextureID() const { return textureID; }
|
||||
|
||||
@@ -14,8 +14,6 @@ namespace ZL {
|
||||
GLuint shaderProgram;
|
||||
|
||||
std::unordered_map<std::string, GLuint> uniformList;
|
||||
|
||||
//std::unordered_map<std::string, std::pair<bool, size_t>> UniformList;
|
||||
std::map<std::string, GLuint> attribList;
|
||||
|
||||
|
||||
|
||||
@@ -298,34 +298,6 @@ bool TextRenderer::loadGlyphs(const std::string& ttfPath, int pixelSize, const s
|
||||
rowHeight = max(rowHeight, gb.height);
|
||||
}
|
||||
|
||||
// // Проходим по стандартным ASCII символам
|
||||
// for (unsigned char c = 32; c < 128; ++c) {
|
||||
//
|
||||
// FT_Load_Char(face, c, FT_LOAD_RENDER);
|
||||
|
||||
// TextureDataStruct glyphData;
|
||||
// glyphData.width = face->glyph->bitmap.width;
|
||||
// glyphData.height = face->glyph->bitmap.rows;
|
||||
// glyphData.format = TextureDataStruct::R8;
|
||||
// glyphData.mipmap = TextureDataStruct::NONE;
|
||||
|
||||
// // Копируем буфер FreeType в вектор данных
|
||||
// size_t dataSize = glyphData.width * glyphData.height;
|
||||
// glyphData.data.assign(face->glyph->bitmap.buffer, face->glyph->bitmap.buffer + dataSize);
|
||||
|
||||
// // Теперь создание текстуры — это одна строка!
|
||||
// auto tex = std::make_shared<Texture>(glyphData);
|
||||
|
||||
//GlyphInfo g;
|
||||
// g.texture = tex;
|
||||
// g.size = Eigen::Vector2f((float)face->glyph->bitmap.width, (float)face->glyph->bitmap.rows);
|
||||
// g.bearing = Eigen::Vector2f((float)face->glyph->bitmap_left, (float)face->glyph->bitmap_top);
|
||||
// // Advance во FreeType измеряется в 1/64 пикселя
|
||||
// g.advance = (unsigned int)face->glyph->advance.x;
|
||||
|
||||
// glyphs.emplace((char)c, g);
|
||||
// }
|
||||
|
||||
// Создаём Texture из atlasData (R8)
|
||||
TextureDataStruct atlasTex;
|
||||
atlasTex.width = atlasWidth;
|
||||
@@ -466,12 +438,9 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca
|
||||
// Примечание: для текста лучше использовать GL_DYNAMIC_DRAW,
|
||||
// но RefreshVBO сейчас жестко зашит на GL_STATIC_DRAW.
|
||||
// Для UI это обычно не критично, если строк не тысячи.
|
||||
// textMesh.AssignFrom(textData);
|
||||
|
||||
// 4. Рендеринг
|
||||
r->shaderManager.PushShader(shaderName);
|
||||
//r->PushMatrix();
|
||||
//r->LoadIdentity();
|
||||
|
||||
// Матрица проекции — используем виртуальные проекционные размеры,
|
||||
// чтобы координаты текста были независимы от физического разрешения экрана.
|
||||
@@ -498,24 +467,7 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
//for (size_t i = 0; i < text.length(); ++i) {
|
||||
// auto it = glyphs.find(text[i]);
|
||||
// if (it == glyphs.end()) continue;
|
||||
|
||||
// glBindTexture(GL_TEXTURE_2D, it->second.texture->getTexID());
|
||||
|
||||
// // Отрисовываем по 6 вершин за раз
|
||||
// // Нам нужно вручную биндить VBO, так как DrawVertexRenderStruct рисует всё сразу
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, textMesh.positionVBO->getBuffer());
|
||||
// r->VertexAttribPointer3fv("vPosition", 0, (const char*)(i * 6 * sizeof(Vector3f)));
|
||||
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, textMesh.texCoordVBO->getBuffer());
|
||||
// r->VertexAttribPointer2fv("vTexCoord", 0, (const char*)(i * 6 * sizeof(Vector2f)));
|
||||
|
||||
// glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
//}
|
||||
r->DrawVertexRenderStruct(cached.mesh);
|
||||
//r->PopMatrix();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
namespace ZL {
|
||||
|
||||
struct GlyphInfo {
|
||||
// std::shared_ptr<Texture> texture; // Texture for glyph
|
||||
Eigen::Vector2f uv; // u,v координата левого верхнего угла в атласе (0..1)
|
||||
Eigen::Vector2f uvSize; // ширина/высота в UV (0..1)
|
||||
|
||||
@@ -42,10 +41,6 @@ private:
|
||||
|
||||
std::unordered_map<uint32_t, GlyphInfo> glyphs;
|
||||
|
||||
// OpenGL objects for a dynamic quad
|
||||
//unsigned int vao = 0;
|
||||
//unsigned int vbo = 0;
|
||||
|
||||
// единый атлас для всех глифов
|
||||
std::shared_ptr<Texture> atlasTexture;
|
||||
size_t atlasWidth = 0;
|
||||
|
||||
Reference in new issue
Block a user