Showing the changes to libraries/render-utils/src/TextRenderer3D.cpp (1 of 2 files). Show all
Unified · Split
| @@ -106,29 +106,6 @@ struct QuadBuilder { · 105 unmodified lines | |||
| 106 | 106 | ||
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | QDebug operator<<(QDebug debug, glm::vec2& value) { | ||
| 110 | debug << value.x << value.y; | ||
| 111 | return debug; | ||
| 112 | } | ||
| 113 | |||
| 114 | QDebug operator<<(QDebug debug, glm::vec3& value) { | ||
| 115 | debug << value.x << value.y << value.z; | ||
| 116 | return debug; | ||
| 117 | } | ||
| 118 | |||
| 119 | QDebug operator<<(QDebug debug, TextureVertex& value) { | ||
| 120 | debug << "Pos:" << value.pos << ", Tex:" << value.tex; | ||
| 121 | return debug; | ||
| 122 | } | ||
| 123 | |||
| 124 | QDebug operator<<(QDebug debug, QuadBuilder& value) { | ||
| 125 | debug << '\n' << value.vertices[0] | ||
| 126 | << '\n' << value.vertices[1] | ||
| 127 | << '\n' << value.vertices[2] | ||
| 128 | << '\n' << value.vertices[3]; | ||
| 129 | return debug; | ||
| 130 | } | ||
| 131 | |||
| 132 | class Font3D { | 109 | class Font3D { |
| 133 | public: | 110 | public: |
| 134 | Font3D(); | 111 | Font3D(); |
| @@ -339,11 +316,7 @@ void Font3D::read(QIODevice& in) { · 204 unmodified lines | |||
| 339 | _glyphs[g.c] = g; | 316 | _glyphs[g.c] = g; |
| 340 | }; | 317 | }; |
| 341 | 318 | ||
| 342 | qDebug() << _family << "size" << image.size(); | ||
| 343 | qDebug() << _family << "format" << image.format(); | ||
| 344 | image = image.convertToFormat(QImage::Format_RGBA8888); | 319 | image = image.convertToFormat(QImage::Format_RGBA8888); |
| 345 | qDebug() << _family << "size" << image.size(); | ||
| 346 | qDebug() << _family << "format" << image.format(); | ||
| 347 | 320 | ||
| 348 | gpu::Element formatGPU = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB); | 321 | gpu::Element formatGPU = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB); |
| 349 | gpu::Element formatMip = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB); | 322 | gpu::Element formatMip = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB); |
| @@ -352,7 +325,7 @@ void Font3D::read(QIODevice& in) { · 2 unmodified lines | |||
| 352 | formatMip = gpu::Element(gpu::VEC4, gpu::UINT8, gpu::BGRA); | 325 | formatMip = gpu::Element(gpu::VEC4, gpu::UINT8, gpu::BGRA); |
| 353 | } | 326 | } |
| 354 | _texture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, image.width(), image.height(), | 327 | _texture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, image.width(), image.height(), |
| 355 | gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR))); | 328 | gpu::Sampler(gpu::Sampler::FILTER_MIN_POINT_MAG_LINEAR))); |
| 356 | _texture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits()); | 329 | _texture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits()); |
| 357 | _texture->autoGenerateMips(-1); | 330 | _texture->autoGenerateMips(-1); |
| 358 | } | 331 | } |
| @@ -373,25 +346,6 @@ void Font3D::setupGPU() { · 14 unmodified lines | |||
| 373 | _outlineLoc = program->getUniforms().findLocation("Outline"); | 346 | _outlineLoc = program->getUniforms().findLocation("Outline"); |
| 374 | _colorLoc = program->getUniforms().findLocation("Color"); | 347 | _colorLoc = program->getUniforms().findLocation("Color"); |
| 375 | 348 | ||
| 376 | |||
| 377 | auto f = [&] (QString str, const gpu::Shader::SlotSet& set) { | ||
| 378 | if (set.size() == 0) { | ||
| 379 | return; | ||
| 380 | } | ||
| 381 | qDebug() << str << set.size(); | ||
| 382 | for (auto slot : set) { | ||
| 383 | qDebug() << " " << QString::fromStdString(slot._name) << slot._location; | ||
| 384 | } | ||
| 385 | }; | ||
| 386 | f("getUniforms:", program->getUniforms()); | ||
| 387 | f("getBuffers:", program->getBuffers()); | ||
| 388 | f("getTextures:", program->getTextures()); | ||
| 389 | f("getSamplers:", program->getSamplers()); | ||
| 390 | f("getInputs:", program->getInputs()); | ||
| 391 | f("getOutputs:", program->getOutputs()); | ||
| 392 | |||
| 393 | qDebug() << "Texture:" << _texture.get(); | ||
| 394 | |||
| 395 | gpu::StatePointer state = gpu::StatePointer(new gpu::State()); | 349 | gpu::StatePointer state = gpu::StatePointer(new gpu::State()); |
| 396 | state->setCullMode(gpu::State::CULL_BACK); | 350 | state->setCullMode(gpu::State::CULL_BACK); |
| 397 | state->setDepthTest(true, true, gpu::LESS_EQUAL); | 351 | state->setDepthTest(true, true, gpu::LESS_EQUAL); |
| @@ -404,8 +358,7 @@ void Font3D::setupGPU() { · 6 unmodified lines | |||
| 404 | static const int OFFSET = offsetof(TextureVertex, tex); | 358 | static const int OFFSET = offsetof(TextureVertex, tex); |
| 405 | assert(OFFSET == sizeof(glm::vec2)); | 359 | assert(OFFSET == sizeof(glm::vec2)); |
| 406 | assert(sizeof(glm::vec2) == 2 * sizeof(float)); | 360 | assert(sizeof(glm::vec2) == 2 * sizeof(float)); |
| 407 | assert(sizeof(glm::vec3) == 3 * sizeof(float)); | 361 | assert(sizeof(TextureVertex) == 2 * sizeof(glm::vec2)); |
| 408 | assert(sizeof(TextureVertex) == sizeof(glm::vec2) + sizeof(glm::vec2)); | ||
| 409 | assert(sizeof(QuadBuilder) == 4 * sizeof(TextureVertex)); | 362 | assert(sizeof(QuadBuilder) == 4 * sizeof(TextureVertex)); |
| 410 | 363 | ||
| 411 | // Setup rendering structures | 364 | // Setup rendering structures |
| @@ -440,7 +393,7 @@ void Font3D::drawString(gpu::Batch& batch, float x, float y, const QString& str, · 28 unmodified lines | |||
| 440 | } | 393 | } |
| 441 | if (isNewLine || forceNewLine) { | 394 | if (isNewLine || forceNewLine) { |
| 442 | // Character return, move the advance to a new line | 395 | // Character return, move the advance to a new line |
| 443 | advance = glm::vec2(0.0f, advance.y - _rowHeight); | 396 | advance = glm::vec2(x, advance.y - _rowHeight); |
| 444 | 397 | ||
| 445 | if (isNewLine) { | 398 | if (isNewLine) { |
| 446 | // No need to draw anything, go directly to next token | 399 | // No need to draw anything, go directly to next token |