mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-18 13:22:11 +02:00
Remove debug/tweak sampler
This commit is contained in:
parent
12d75481e5
commit
ca529e4bb8
2 changed files with 8 additions and 54 deletions
|
@ -32,8 +32,6 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
glm::vec4 textColor = glm::vec4(toGlm(getTextColorX()), 1.0f);
|
||||
glm::vec4 backgroundColor = glm::vec4(toGlm(getBackgroundColorX()), 1.0f);
|
||||
glm::vec3 dimensions = getDimensions();
|
||||
float leftMargin = 0.1f, topMargin = 0.1f;
|
||||
glm::vec2 bounds = glm::vec2(dimensions.x - 2 * leftMargin, dimensions.y - 2 * topMargin);
|
||||
|
||||
Transform transformToTopLeft = getTransformToCenter();
|
||||
transformToTopLeft.postTranslate(glm::vec3(-0.5f, 0.5f, 0.0f)); // Go to the top left
|
||||
|
@ -50,9 +48,12 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
DependencyManager::get<DeferredLightingEffect>()->renderQuad(batch, minCorner, maxCorner, backgroundColor);
|
||||
|
||||
float scale = _lineHeight / _textRenderer->getRowHeight();
|
||||
transformToTopLeft.setScale(scale);
|
||||
transformToTopLeft.setScale(scale); // Scale to have the correct line height
|
||||
batch.setModelTransform(transformToTopLeft);
|
||||
_textRenderer->draw(batch, leftMargin, topMargin, _text, textColor, bounds / scale);
|
||||
|
||||
float leftMargin = 0.5f * _lineHeight, topMargin = 0.5f * _lineHeight;
|
||||
glm::vec2 bounds = glm::vec2(dimensions.x - 2.0f * leftMargin, dimensions.y - 2.0f * topMargin);
|
||||
_textRenderer->draw(batch, leftMargin / scale, -topMargin / scale, _text, textColor, bounds / scale);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -106,29 +106,6 @@ struct QuadBuilder {
|
|||
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug debug, glm::vec2& value) {
|
||||
debug << value.x << value.y;
|
||||
return debug;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, glm::vec3& value) {
|
||||
debug << value.x << value.y << value.z;
|
||||
return debug;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, TextureVertex& value) {
|
||||
debug << "Pos:" << value.pos << ", Tex:" << value.tex;
|
||||
return debug;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, QuadBuilder& value) {
|
||||
debug << '\n' << value.vertices[0]
|
||||
<< '\n' << value.vertices[1]
|
||||
<< '\n' << value.vertices[2]
|
||||
<< '\n' << value.vertices[3];
|
||||
return debug;
|
||||
}
|
||||
|
||||
class Font3D {
|
||||
public:
|
||||
Font3D();
|
||||
|
@ -339,11 +316,7 @@ void Font3D::read(QIODevice& in) {
|
|||
_glyphs[g.c] = g;
|
||||
};
|
||||
|
||||
qDebug() << _family << "size" << image.size();
|
||||
qDebug() << _family << "format" << image.format();
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888);
|
||||
qDebug() << _family << "size" << image.size();
|
||||
qDebug() << _family << "format" << image.format();
|
||||
|
||||
gpu::Element formatGPU = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB);
|
||||
gpu::Element formatMip = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB);
|
||||
|
@ -352,7 +325,7 @@ void Font3D::read(QIODevice& in) {
|
|||
formatMip = gpu::Element(gpu::VEC4, gpu::UINT8, gpu::BGRA);
|
||||
}
|
||||
_texture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, image.width(), image.height(),
|
||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
|
||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_POINT_MAG_LINEAR)));
|
||||
_texture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits());
|
||||
_texture->autoGenerateMips(-1);
|
||||
}
|
||||
|
@ -373,25 +346,6 @@ void Font3D::setupGPU() {
|
|||
_outlineLoc = program->getUniforms().findLocation("Outline");
|
||||
_colorLoc = program->getUniforms().findLocation("Color");
|
||||
|
||||
|
||||
auto f = [&] (QString str, const gpu::Shader::SlotSet& set) {
|
||||
if (set.size() == 0) {
|
||||
return;
|
||||
}
|
||||
qDebug() << str << set.size();
|
||||
for (auto slot : set) {
|
||||
qDebug() << " " << QString::fromStdString(slot._name) << slot._location;
|
||||
}
|
||||
};
|
||||
f("getUniforms:", program->getUniforms());
|
||||
f("getBuffers:", program->getBuffers());
|
||||
f("getTextures:", program->getTextures());
|
||||
f("getSamplers:", program->getSamplers());
|
||||
f("getInputs:", program->getInputs());
|
||||
f("getOutputs:", program->getOutputs());
|
||||
|
||||
qDebug() << "Texture:" << _texture.get();
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
state->setCullMode(gpu::State::CULL_BACK);
|
||||
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||
|
@ -404,8 +358,7 @@ void Font3D::setupGPU() {
|
|||
static const int OFFSET = offsetof(TextureVertex, tex);
|
||||
assert(OFFSET == sizeof(glm::vec2));
|
||||
assert(sizeof(glm::vec2) == 2 * sizeof(float));
|
||||
assert(sizeof(glm::vec3) == 3 * sizeof(float));
|
||||
assert(sizeof(TextureVertex) == sizeof(glm::vec2) + sizeof(glm::vec2));
|
||||
assert(sizeof(TextureVertex) == 2 * sizeof(glm::vec2));
|
||||
assert(sizeof(QuadBuilder) == 4 * sizeof(TextureVertex));
|
||||
|
||||
// Setup rendering structures
|
||||
|
@ -440,7 +393,7 @@ void Font3D::drawString(gpu::Batch& batch, float x, float y, const QString& str,
|
|||
}
|
||||
if (isNewLine || forceNewLine) {
|
||||
// Character return, move the advance to a new line
|
||||
advance = glm::vec2(0.0f, advance.y - _rowHeight);
|
||||
advance = glm::vec2(x, advance.y - _rowHeight);
|
||||
|
||||
if (isNewLine) {
|
||||
// No need to draw anything, go directly to next token
|
||||
|
|
Loading…
Reference in a new issue