Use rendering helper in Luaconsole and Loading screen (working on #525)

This commit is contained in:
Alexander Bock
2018-09-03 00:35:42 -04:00
parent b3abcbdf4f
commit 40196262fb
10 changed files with 109 additions and 453 deletions
+7 -1
View File
@@ -27,7 +27,10 @@
#include <ghoul/opengl/uniformcache.h>
namespace ghoul::opengl { class ProgramObject; }
namespace ghoul::opengl {
class ProgramObject;
class Texture;
} // namespace ghoul::opengl
namespace openspace::rendering::helper {
@@ -52,6 +55,9 @@ void renderBox(ghoul::opengl::ProgramObject& program, GLint orthoLocation,
void renderBox(const glm::vec2& position, const glm::vec2& size, const glm::vec4& color,
Anchor anchor = Anchor::NW);
void renderBox(const glm::vec2& position, const glm::vec2& size, const glm::vec4& color,
const ghoul::opengl::Texture& texture, Anchor anchor = Anchor::NW);
struct Shaders {
struct {
std::unique_ptr<ghoul::opengl::ProgramObject> program;
+3 -18
View File
@@ -29,6 +29,7 @@
#include <ghoul/misc/boolean.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/opengl/uniformcache.h>
#include <atomic>
#include <memory>
#include <mutex>
#include <random>
@@ -97,11 +98,8 @@ private:
bool _showProgressbar;
Phase _phase;
int _iProgress = 0;
int _nItems = 0;
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
UniformCache(logoTexture, useTexture, color) _uniformCache;
std::atomic_int _iProgress = 0;
std::atomic_int _nItems = 0;
std::unique_ptr<ghoul::opengl::Texture> _logoTexture;
@@ -109,19 +107,6 @@ private:
std::shared_ptr<ghoul::fontrendering::Font> _messageFont;
std::shared_ptr<ghoul::fontrendering::Font> _itemFont;
struct {
GLuint vao = 0;
GLuint vbo = 0;
} _logo;
struct {
GLuint vaoFill = 0;
GLuint vboFill = 0;
GLuint vaoBox = 0;
GLuint vboBox = 0;
} _progressbar;
bool _hasCatastrophicErrorOccurred = false;
std::string _message;
std::mutex _messageMutex;
-8
View File
@@ -67,8 +67,6 @@ private:
properties::BoolProperty _remoteScripting;
properties::Vec4Property _backgroundColor;
properties::Vec4Property _highlightColor;
properties::Vec4Property _separatorColor;
properties::Vec4Property _entryTextColor;
properties::Vec4Property _historyTextColor;
properties::IntProperty _historyLength;
@@ -90,12 +88,6 @@ private:
std::shared_ptr<ghoul::fontrendering::Font> _font;
std::shared_ptr<ghoul::fontrendering::Font> _historyFont;
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
GLuint _vao = 0;
GLuint _vbo = 0;
UniformCache(res, color, height, ortho) _uniformCache;
};
} // namespace openspace
-41
View File
@@ -1,41 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
in vec2 st;
out vec4 FragColor;
uniform bool useTexture;
uniform sampler2D logoTexture;
uniform vec4 color;
void main() {
if (useTexture) {
FragColor = texture(logoTexture, st);
}
else {
FragColor = color;
}
}
-35
View File
@@ -1,35 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
in vec2 in_position;
in vec2 in_st;
out vec2 st;
void main() {
gl_Position = vec4(in_position, 0.0, 1.0);
st = in_st;
}
-33
View File
@@ -1,33 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
out vec4 FragColor;
uniform vec4 color;
void main() {
FragColor = color;
}
-38
View File
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
in vec2 in_position;
uniform float height;
uniform ivec2 res;
uniform mat4 ortho;
void main() {
float y = float(res.y) - in_position.y * height * res.y;
gl_Position = ortho * vec4(in_position.x * res.x, y, 0.0, 1.0);
}
+35 -5
View File
@@ -28,6 +28,8 @@
#include <openspace/engine/windowdelegate.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/assert.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureunit.h>
#include <fstream>
#include <string>
@@ -297,8 +299,8 @@ glm::mat4 ortho(const glm::vec2& position, const glm::vec2& size, Anchor anchor)
void renderBox(ghoul::opengl::ProgramObject& program, GLint orthoLocation,
GLint colorLocation, const glm::vec2& position, const glm::vec2& size,
const glm::vec4& color, Anchor anchor)
GLint colorLocation, const glm::vec2& position, const glm::vec2& size,
const glm::vec4& color, Anchor anchor)
{
program.setUniform(orthoLocation, ortho(position, size, anchor));
program.setUniform(colorLocation, color);
@@ -314,11 +316,39 @@ void renderBox(const glm::vec2& position, const glm::vec2& size, const glm::vec4
auto& shdr = shaders.xyuvrgba;
shdr.program->activate();
shdr.program->setUniform(shdr.cache.hasTexture, 0);
renderBox(*shdr.program, shdr.cache.ortho, shdr.cache.color, position, size, color,
anchor);
renderBox(
*shdr.program,
shdr.cache.ortho,
shdr.cache.color,
position, size,
color,
anchor
);
shdr.program->deactivate();
}
void renderBox(const glm::vec2& position, const glm::vec2& size, const glm::vec4& color,
const ghoul::opengl::Texture& texture, Anchor anchor)
{
auto& shdr = shaders.xyuvrgba;
shdr.program->activate();
shdr.program->setUniform(shdr.cache.hasTexture, 1);
ghoul::opengl::TextureUnit unit;
unit.activate();
texture.bind();
shdr.program->setUniform(shdr.cache.tex, unit);
renderBox(
*shdr.program,
shdr.cache.ortho,
shdr.cache.color,
position,
size,
color,
anchor
);
shdr.program->deactivate();
}
} // namespace openspace::rendering::helper
+59 -180
View File
@@ -26,12 +26,15 @@
#include <openspace/engine/globals.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/rendering/helper.h>
#include <ghoul/fmt.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/font/font.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
#include <ghoul/io/texture/texturereader.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/stringconversion.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureunit.h>
@@ -104,18 +107,6 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName
, _showProgressbar(showProgressbar)
, _randomEngine(_randomDevice())
{
_program = ghoul::opengl::ProgramObject::Build(
"Loading Screen",
absPath("${SHADERS}/loadingscreen.vert"),
absPath("${SHADERS}/loadingscreen.frag")
);
ghoul::opengl::updateUniformLocations(
*_program,
_uniformCache,
{ "logoTexture", "useTexture", "color" }
);
_loadingFont = global::fontManager.font(
"Loading",
LoadingFontSize,
@@ -147,47 +138,6 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName
absPath("${DATA}/openspace-logo.png")
);
_logoTexture->uploadTexture();
glGenVertexArrays(1, &_logo.vao);
glBindVertexArray(_logo.vao);
glGenBuffers(1, &_logo.vbo);
glBindBuffer(GL_ARRAY_BUFFER, _logo.vbo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), nullptr);
glEnableVertexAttribArray(1);
glVertexAttribPointer(
1,
2,
GL_FLOAT,
GL_FALSE,
4 * sizeof(GLfloat),
reinterpret_cast<void*>(2 * sizeof(GLfloat))
);
glBindVertexArray(0);
}
if (_showProgressbar) {
// Progress bar stuff
glGenVertexArrays(1, &_progressbar.vaoFill);
glBindVertexArray(_progressbar.vaoFill);
glGenBuffers(1, & _progressbar.vboFill);
glBindBuffer(GL_ARRAY_BUFFER, _progressbar.vboFill);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr);
glGenVertexArrays(1, &_progressbar.vaoBox);
glBindVertexArray(_progressbar.vaoBox);
glGenBuffers(1, & _progressbar.vboBox);
glBindBuffer(GL_ARRAY_BUFFER, _progressbar.vboBox);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr);
glBindVertexArray(0);
}
}
@@ -197,15 +147,6 @@ LoadingScreen::~LoadingScreen() {
_loadingFont = nullptr;
_messageFont = nullptr;
_itemFont = nullptr;
glDeleteVertexArrays(1, &_logo.vao);
glDeleteBuffers(1, &_logo.vbo);
glDeleteVertexArrays(1, &_progressbar.vaoFill);
glDeleteBuffers(1, &_progressbar.vboFill);
glDeleteVertexArrays(1, &_progressbar.vaoBox);
glDeleteBuffers(1, &_progressbar.vboBox);
}
void LoadingScreen::render() {
@@ -228,22 +169,6 @@ void LoadingScreen::render() {
LogoSize.y * textureAspectRatio * screenAspectRatio
};
const glm::vec2 logoLl = { LogoCenter.x - size.x, LogoCenter.y - size.y };
const glm::vec2 logoUr = { LogoCenter.x + size.x, LogoCenter.y + size.y };
const GLfloat data[] = {
logoLl.x, logoLl.y, 0.f, 0.f,
logoUr.x, logoUr.y, 1.f, 1.f,
logoLl.x, logoUr.y, 0.f, 1.f,
logoLl.x, logoLl.y, 0.f, 0.f,
logoUr.x, logoLl.y, 1.f, 0.f,
logoUr.x, logoUr.y, 1.f, 1.f
};
glBindVertexArray(_logo.vao);
glBindBuffer(GL_ARRAY_BUFFER, _logo.vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
//
// Clear background
//
@@ -258,16 +183,13 @@ void LoadingScreen::render() {
//
// Render logo
//
_program->activate();
ghoul::opengl::TextureUnit unit;
unit.activate();
_logoTexture->bind();
_program->setUniform(_uniformCache.logoTexture, unit);
_program->setUniform(_uniformCache.useTexture, true);
glDrawArrays(GL_TRIANGLES, 0, 6);
rendering::helper::renderBox(
glm::vec2(1.f) - ((LogoCenter + glm::vec2(1.f)) / 2.f),
size,
glm::vec4(1.f),
*_logoTexture,
rendering::helper::Anchor::Center
);
//
// Render progress bar
@@ -277,110 +199,54 @@ void LoadingScreen::render() {
ProgressbarSize.y * screenAspectRatio
};
const glm::vec2 progressbarLl = {
ProgressbarCenter.x - progressbarSize.x,
ProgressbarCenter.y - progressbarSize.y
};
const glm::vec2 progressbarUr = {
ProgressbarCenter.x + progressbarSize.x ,
ProgressbarCenter.y + progressbarSize.y
};
if (_showProgressbar) {
glBindVertexArray(_progressbar.vaoFill);
// Depending on the progress, we only want to draw the progress bar to a mixture
// of the lowerleft and upper right extent
const float progress = _nItems != 0 ?
static_cast<float>(_iProgress) / static_cast<float>(_nItems) :
0.f;
glm::vec2 ur = progressbarUr;
ur.x = glm::mix(progressbarLl.x, progressbarUr.x, progress);
const GLfloat dataFill[] = {
progressbarLl.x, progressbarLl.y,
ur.x, ur.y,
progressbarLl.x, ur.y,
progressbarLl.x, progressbarLl.y,
ur.x, progressbarLl.y,
ur.x, ur.y,
};
glBindBuffer(GL_ARRAY_BUFFER, _progressbar.vboFill);
glBufferData(GL_ARRAY_BUFFER, sizeof(dataFill), dataFill, GL_STATIC_DRAW);
_program->setUniform(_uniformCache.useTexture, false);
switch (_phase) {
case Phase::Construction:
_program->setUniform(_uniformCache.color, PhaseColorConstruction);
break;
case Phase::Synchronization:
_program->setUniform(_uniformCache.color, PhaseColorSynchronization);
break;
case Phase::Initialization:
_program->setUniform(_uniformCache.color, PhaseColorInitialization);
break;
}
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(_progressbar.vaoBox);
const float w = ProgressbarLineWidth / screenAspectRatio;
const float h = ProgressbarLineWidth;
const GLfloat dataBox[] = {
// In order to avoid the deprecated glLineWidth, we split the lines into
// separate triangles instead
rendering::helper::renderBox(
glm::vec2(1.f) - ((ProgressbarCenter + glm::vec2(1.f)) / 2.f),
progressbarSize + glm::vec2(2 * w, 2 * h),
ProgressbarOutlineColor,
rendering::helper::Anchor::Center
);
// Left side
progressbarLl.x - w , progressbarLl.y - h,
progressbarLl.x + w, progressbarUr.y + h,
progressbarLl.x - w, progressbarUr.y + h,
rendering::helper::renderBox(
glm::vec2(1.f) - ((ProgressbarCenter + glm::vec2(1.f)) / 2.f),
progressbarSize,
glm::vec4(0.f, 0.f, 0.f, 1.f),
rendering::helper::Anchor::Center
);
progressbarLl.x - w , progressbarLl.y - h,
progressbarLl.x + w , progressbarLl.y - h,
progressbarLl.x + w, progressbarUr.y + h,
glm::vec4 color;
switch (_phase) {
case Phase::Construction:
color = PhaseColorConstruction;
break;
case Phase::Synchronization:
color = PhaseColorSynchronization;
break;
case Phase::Initialization:
color = PhaseColorInitialization;
break;
}
// Top side
progressbarLl.x - w, progressbarUr.y - h,
progressbarUr.x + w, progressbarUr.y + h,
progressbarLl.x - w, progressbarUr.y + h,
glm::vec2 p = glm::vec2(1.f) - ((ProgressbarCenter + glm::vec2(1.f)) / 2.f);
rendering::helper::renderBox(
p - progressbarSize / 2.f,
progressbarSize * glm::vec2(progress, 1.f),
color,
rendering::helper::Anchor::NW
);
progressbarLl.x - w, progressbarUr.y - h,
progressbarUr.x + w, progressbarUr.y - h,
progressbarUr.x + w, progressbarUr.y + h,
// Right side
progressbarUr.x - w, progressbarLl.y - h,
progressbarUr.x + w, progressbarUr.y + h,
progressbarUr.x - w, progressbarUr.y - h,
progressbarUr.x - w, progressbarLl.y - h,
progressbarUr.x + w, progressbarLl.y - h,
progressbarUr.x + w, progressbarUr.y + h,
// Bottom side
progressbarLl.x - w, progressbarLl.y - h,
progressbarUr.x + w, progressbarLl.y + h,
progressbarLl.x - w, progressbarLl.y + h,
progressbarLl.x - w, progressbarLl.y - h,
progressbarUr.x + w, progressbarLl.y - h,
progressbarUr.x + w, progressbarLl.y + h,
};
glBindBuffer(GL_ARRAY_BUFFER, _progressbar.vboBox);
glBufferData(GL_ARRAY_BUFFER, sizeof(dataBox), dataBox, GL_STATIC_DRAW);
_program->setUniform(_uniformCache.useTexture, false);
_program->setUniform(_uniformCache.color, ProgressbarOutlineColor);
glDrawArrays(GL_TRIANGLES, 0, 24);
LINFOC("P", ghoul::to_string(p));
LINFOC("P2", ghoul::to_string(p - progressbarSize / 2.f));
LINFOC("S", ghoul::to_string(progressbarSize));
LINFOC("S2", ghoul::to_string(progressbarSize * glm::vec2(progress, 1.f)));
}
glBindVertexArray(0);
_program->deactivate();
//
// "Loading" text
//
@@ -431,13 +297,26 @@ void LoadingScreen::render() {
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
const glm::vec2 logoLl = { LogoCenter.x - size.x, LogoCenter.y - size.y };
const glm::vec2 logoUr = { LogoCenter.x + size.x, LogoCenter.y + size.y };
const glm::vec2 progressbarLl = {
ProgressbarCenter.x - progressbarSize.x,
ProgressbarCenter.y - progressbarSize.y
};
const glm::vec2 progressbarUr = {
ProgressbarCenter.x + progressbarSize.x ,
ProgressbarCenter.y + progressbarSize.y
};
for (Item& item : _items) {
if (!item.hasLocation) {
// Compute a new location
const FR::BoundingBoxInformation b = renderer.boundingBox(
*_itemFont,
(item.name + " 100%")
(item.name + " 100%\n99999999/99999999")
);
// The maximum count is in here since we can't control the amount of
+5 -94
View File
@@ -27,6 +27,7 @@
#include <openspace/engine/globals.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/network/parallelpeer.h>
#include <openspace/rendering/helper.h>
#include <openspace/scripting/scriptengine.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/filesystem/filesystem.h>
@@ -90,19 +91,6 @@ namespace {
"Sets the background color of the console."
};
constexpr openspace::properties::Property::PropertyInfo HighlightColorInfo = {
"HighlightColor",
"Highlight Color",
"Sets the color of the lines below the console."
};
constexpr openspace::properties::Property::PropertyInfo SeparatorColorInfo = {
"SeparatorColor",
"Separator Color",
"Sets the color of the separator between the history part and the entry part of "
"the console."
};
constexpr openspace::properties::Property::PropertyInfo EntryTextColorInfo = {
"EntryTextColor",
"Entry Text Color",
@@ -150,18 +138,6 @@ LuaConsole::LuaConsole()
glm::vec4(0.f),
glm::vec4(1.f)
)
, _highlightColor(
HighlightColorInfo,
glm::vec4(1.f, 1.f, 1.f, 0.f),
glm::vec4(0.f),
glm::vec4(1.f)
)
, _separatorColor(
SeparatorColorInfo,
glm::vec4(0.4f, 0.4f, 0.4f, 0.f),
glm::vec4(0.f),
glm::vec4(1.f)
)
, _entryTextColor(
EntryTextColorInfo,
glm::vec4(1.f, 1.f, 1.f, 1.f),
@@ -184,12 +160,6 @@ LuaConsole::LuaConsole()
_backgroundColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_backgroundColor);
_highlightColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_highlightColor);
_separatorColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_separatorColor);
_entryTextColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_entryTextColor);
@@ -240,35 +210,6 @@ void LuaConsole::initialize() {
_commands.emplace_back("");
_activeCommand = _commands.size() - 1;
_program = ghoul::opengl::ProgramObject::Build(
"Console",
absPath("${SHADERS}/luaconsole.vert"),
absPath("${SHADERS}/luaconsole.frag")
);
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
const GLfloat data[] = {
0.f, 0.f,
1.f, 1.f,
0.f, 1.f,
0.f, 0.f,
1.f, 0.f,
1.f, 1.f
};
glGenVertexArrays(1, &_vao);
glBindVertexArray(_vao);
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr);
glBindVertexArray(0);
_font = global::fontManager.font(
FontName,
EntryFontSize,
@@ -323,8 +264,6 @@ void LuaConsole::deinitialize() {
}
}
_program = nullptr;
global::parallelPeer.connectionEvent().unsubscribe("luaConsole");
}
@@ -699,12 +638,6 @@ void LuaConsole::render() {
return;
}
if (_program->isDirty()) {
_program->rebuildFromFile();
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
const glm::vec2 dpiScaling = global::windowDelegate.dpiScaling();
const glm::ivec2 res =
glm::vec2(global::windowDelegate.currentWindowResolution()) / dpiScaling;
@@ -716,34 +649,12 @@ void LuaConsole::render() {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
_program->activate();
_program->setUniform(_uniformCache.res, res);
_program->setUniform(_uniformCache.color, _backgroundColor);
_program->setUniform(_uniformCache.height, _currentHeight / res.y);
_program->setUniform(
_uniformCache.ortho,
glm::ortho(0.f, static_cast<float>(res.x), 0.f, static_cast<float>(res.y))
rendering::helper::renderBox(
glm::vec2(0.f, 0.f),
glm::vec2(1.f, _currentHeight / res.y),
_backgroundColor
);
// Draw the background color
glBindVertexArray(_vao);
glDrawArrays(GL_TRIANGLES, 0, 6);
// Draw the highlight lines above and below the background
_program->setUniform(_uniformCache.color, _highlightColor);
glDrawArrays(GL_LINES, 1, 4);
// Draw the separator between the current entry box and the history
_program->setUniform(_uniformCache.color, _separatorColor);
_program->setUniform(
_uniformCache.height,
_currentHeight / res.y - 2.5f * EntryFontSize / res.y
);
glDrawArrays(GL_LINES, 1, 2);
_program->deactivate();
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);