Skip to content
Snippets Groups Projects
Commit 7f5f4345 authored by Odilitime's avatar Odilitime
Browse files

minor note, moved macro

parent 6963de42
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,6 @@
#include <iostream>
#include <ctime>
#define posMac(p) (p * (3 + 4 + 2)) // 3 positions + 4 color channels + 2 S&T (texture mapping)
extern TextRasterizerCache *rasterizerCache;
TextComponent::TextComponent(const std::string &rawText, const int rawX, const int rawY, const unsigned int size, const bool bolded, const unsigned int hexColor, const int passedWindowWidth, const int passedWindowHeight) {
......@@ -88,6 +86,8 @@ TextComponent::~TextComponent() {
}
}
#define posMac(p) (p * (3 + 4 + 2)) // 3 positions + 4 color channels + 2 S&T (texture mapping)
inline void setVerticesColor(std::unique_ptr<float[]> &vertices, int p, unsigned int color) {
vertices[static_cast<size_t>(posMac(p) + 2)] = 0.0f;
vertices[static_cast<size_t>(posMac(p) + 3)] = (static_cast<float>((color >> 24) & 0xFF)) / 255;
......@@ -154,7 +154,7 @@ void TextComponent::rasterize(const int rawX, const int rawY) {
//std::cout << "glyph x from: " << (int)glyph.x0 << " to " << (int)glyph.x1 << std::endl;
float vx1 = startX + (response->x1 - response->x0);
float vy1 = response->y1 + rawY;
//std::cout << "textcomponent at " << (int)vx0 << "," << (int)vy0 << " to " << (int)vx1 << "," << (int)vy1 << std::endl;
//std::cout << "TextComponent::rasterize - placing at " << (int)vx0 << "," << (int)vy0 << " to " << (int)vx1 << "," << (int)vy1 << std::endl;
// convert our local x,y,w,h into actual ogl coords
......@@ -165,7 +165,7 @@ void TextComponent::rasterize(const int rawX, const int rawY) {
pointToViewport(vx0, vy0);
pointToViewport(vx1, vy1);
//std::cout << "textcomponent at GL" << (int)vx0 << "," << (int)vy0 << " to GL" << (int)vx1 << "," << (int)vy1 << std::endl;
//std::cout << "TextComponent::rasterize - placing at GL" << vx0 << "," << vy0 << " to GL" << vx1 << "," << vy1 << std::endl;
std::unique_ptr<float[]> vertices = std::make_unique<float[]>(36);
vertices[posMac(0) + 0] = vx0;
......@@ -242,7 +242,10 @@ void TextComponent::resize(const int passedWindowWidth, const int passedWindowHe
availableWidth = passedAvailableWidth;
//std::cout << "TextComponent::resize" << std::endl;
//std::cout << "TextComponent::resize - rasterizing at " << (int)x << "x" << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
// update the vertices and any wrapping
rasterize(x, y);
//std::cout << "TextComponent::resize - rasterized at " << (int)x << "x" << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
// make sure we have glyphs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment