mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 22:39:09 -05:00
Some more work on the LuaConsole
This commit is contained in:
@@ -62,8 +62,7 @@ private:
|
||||
properties::BoolProperty _remoteScripting;
|
||||
|
||||
properties::FloatProperty _width;
|
||||
properties::FloatProperty _heightRetracted;
|
||||
properties::FloatProperty _heightExtended;
|
||||
//properties::FloatProperty _height;
|
||||
|
||||
size_t _inputPosition;
|
||||
std::vector<std::string> _commandsHistory;
|
||||
@@ -76,6 +75,7 @@ private:
|
||||
std::string initialValue;
|
||||
} _autoCompleteInfo;
|
||||
|
||||
float _currentHeight;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
|
||||
GLuint _vao;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#version __CONTEXT__
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main() {
|
||||
FragColor = vec4(0.65, 0.65, 0.85, 0.9);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#version __CONTEXT__
|
||||
|
||||
in vec2 in_position;
|
||||
|
||||
uniform float height;
|
||||
uniform float width;
|
||||
uniform ivec2 res;
|
||||
|
||||
uniform mat4 ortho;
|
||||
|
||||
void main() {
|
||||
const float x = in_position.x * res.x * width + (res.x / 2.0 - width * res.x / 2.0);
|
||||
const float y = float(res.y) - in_position.y * height * res.y;
|
||||
|
||||
gl_Position = ortho * vec4(x, y, 0.0, 1.0);
|
||||
}
|
||||
@@ -66,18 +66,17 @@ LuaConsole::LuaConsole()
|
||||
, _isVisible("isVisible", "Is Visible", false)
|
||||
, _remoteScripting("remoteScripting", "Remote scripting", false)
|
||||
, _width("width", "Width", 0.75f, 0.f, 1.f)
|
||||
, _heightRetracted("heightRetracted", "Height when retracted", 0.04f, 0.f, 1.f)
|
||||
, _heightExtended("heightExtended", "Height when extended", 0.5f, 0.f, 1.f)
|
||||
//, _height("height", "Height", 0.04f, 0.f, 1.f)
|
||||
, _inputPosition(0)
|
||||
, _activeCommand(0)
|
||||
, _autoCompleteInfo({NoAutoComplete, false, ""})
|
||||
, _currentHeight(0.f)
|
||||
{
|
||||
addProperty(_isVisible);
|
||||
addProperty(_remoteScripting);
|
||||
|
||||
//addProperty(_height);
|
||||
addProperty(_width);
|
||||
addProperty(_heightRetracted);
|
||||
addProperty(_heightExtended);
|
||||
}
|
||||
|
||||
void LuaConsole::initialize() {
|
||||
@@ -463,7 +462,10 @@ void LuaConsole::charCallback(unsigned int codepoint, KeyModifier modifier) {
|
||||
}
|
||||
|
||||
void LuaConsole::render() {
|
||||
static const float FontSize = 13.0f;
|
||||
|
||||
if (!_isVisible) {
|
||||
_currentHeight = 0.f;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -471,6 +473,12 @@ void LuaConsole::render() {
|
||||
_program->rebuildFromFile();
|
||||
}
|
||||
|
||||
glm::ivec2 res = OsEng.windowWrapper().currentWindowResolution();
|
||||
const float frametime = static_cast<float>(OsEng.windowWrapper().deltaTime());
|
||||
static const float Delta = 0.15f;
|
||||
_currentHeight = std::min(_currentHeight + Delta * frametime, FontSize * 2.5f / res.y);
|
||||
|
||||
|
||||
// Render background
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_BLEND);
|
||||
@@ -479,7 +487,6 @@ void LuaConsole::render() {
|
||||
|
||||
_program->activate();
|
||||
|
||||
glm::ivec2 res = OsEng.windowWrapper().currentWindowResolution();
|
||||
const glm::mat4 projection = glm::ortho(
|
||||
0.f,
|
||||
static_cast<float>(res.x),
|
||||
@@ -489,7 +496,7 @@ void LuaConsole::render() {
|
||||
|
||||
_program->setUniform("res", res);
|
||||
_program->setUniform("width", _width);
|
||||
_program->setUniform("height", _heightExtended);
|
||||
_program->setUniform("height", _currentHeight);
|
||||
_program->setUniform("ortho", projection);
|
||||
|
||||
glBindVertexArray(_vao);
|
||||
@@ -501,7 +508,6 @@ void LuaConsole::render() {
|
||||
|
||||
|
||||
// Render text
|
||||
const float FontSize = 10.0f;
|
||||
const int ySize = OsEng.renderEngine().fontResolution().y;
|
||||
|
||||
const glm::vec4 red(1, 0, 0, 1);
|
||||
@@ -515,7 +521,7 @@ void LuaConsole::render() {
|
||||
|
||||
glm::vec2 inputLocation = glm::vec2(
|
||||
res.x / 2.f - _width * res.x / 2.f + FontSize / 2.f,
|
||||
res.y - _heightExtended * res.y + FontSize / 2.f
|
||||
res.y - _currentHeight * res.y + FontSize / 2.f
|
||||
);
|
||||
|
||||
RenderFont(
|
||||
|
||||
Reference in New Issue
Block a user