blob: b5c0ae006d8122f00e5557e3e4d529dae9177cdb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "fb/chfb.h"
#include <array>
#include <cmath>
#include <vector>
#include "math/vector.h"
#include "o3d/vertex.h"
#include "o3d/tri_vertex.h"
#include "o3d/vertex_data.h"
using namespace engine::fb;
CharacterFrameBuffer::CharacterFrameBuffer(unsigned int w, unsigned int h) {
resize(w, h);
}
void CharacterFrameBuffer::resize(unsigned int w, unsigned int h) {
this->w = w;
this->h = h;
chars_vector.resize(w * h);
clear();
}
unsigned int CharacterFrameBuffer::width() const {
return w;
}
unsigned int CharacterFrameBuffer::height() const {
return h;
}
const char* CharacterFrameBuffer::chars() const {
return chars_vector.data();
}
void CharacterFrameBuffer::clear() {
std::fill(chars_vector.begin(), chars_vector.end(), ' ');
}
void CharacterFrameBuffer::draw_point(int x, int y, engine::math::Vector3 loc, const engine::o3d::VertexData& vd) {
(void) vd;
chars_vector[x + y * w] = face_char(static_cast<int>(loc.x));
}
char CharacterFrameBuffer::face_char(int face_ind) const {
int n = 1 + face_ind / 2;
return (n < 10 ? '0' : 'A' - 10) + n;
}
|