Проблемы с копированием растрового изображения в текстуру OpenGL

я пытаюсь сгенерировать все растровые изображения для символов из' ' в'~' и добавьте их в одну длинную текстуру. Я намерен расположить их в текстуре с фиксированной шириной, но сейчас я просто хотел убедиться, что концепция будет работать.

Но у меня проблемы. Вместо того, чтобы получить ожидаемую текстуру, я просто получаю следующее для шрифта 16px:

Мне кажется, что яЯ копирую это неправильно, но независимо от того, что я делаю, у меня всегда получается один и тот же вывод.

Наконец, код:

Font.h

#ifndef _FONT_H_
#define _FONT_H_

#include 
#include 
#include 
#include 
#include 

#include 
#include FT_FREETYPE_H

#include "vector2.h"
#include "math_helper.h"

class Font {
public:
  Font(const std::string font_path, int size);
  ~Font();

  int get_texture() const { return texture_; }

private:
  unsigned int width_, height_, texture_;

  static FT_Library LIBRARY;
  static const char START_CHAR = ' ';
  static const char END_CHAR   = '~';

  static void initialize_library();
};

#endif

Font.cpp

#include "font.h"

FT_Library Font::LIBRARY = NULL;        

Font::Font(const std::string font_path, int size)
  : width_(64), height_(2), texture_(0) {
  initialize_library();

  FT_Face face = NULL;
  int error = FT_New_Face(Font::LIBRARY, font_path.c_str(), 0, &face);

  if(error == FT_Err_Unknown_File_Format) {
    std::cout < "Error: Unknown file format for font \"" < font_path < "\"" < std::endl;
  } else if(error) {
    std::cout < "Error: Could not open font \"" < font_path < "\"" < std::endl;
  }

  error = FT_Set_Pixel_Sizes(face, 0, size);
  if(error) {
    std::cout < "Error: Could not set pixel size for font \"" < font_path < "\"" < std::endl;
  }

  int num_chars = (END_CHAR - START_CHAR);
  width_ = to_nearest_pow2(num_chars * size);
  height_ = to_nearest_pow2(size);
  std::vector

Ответы на вопрос(2)

Ваш ответ на вопрос