Browse Source

remove window global, don't updateText on cstr

master
Odilitime 5 years ago
parent
commit
7e2f064ccb
  1. 17
      src/graphics/components/InputComponent.cpp
  2. 3
      src/graphics/components/InputComponent.h

17
src/graphics/components/InputComponent.cpp

@ -39,7 +39,9 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r @@ -39,7 +39,9 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
this->cursorBox->y = this->windowHeight + y - 13;
}
this->cursorBox->resize(this->windowWidth, this->windowHeight);
this->updateText();
// can't updateText because no win set yet
// don't seem to need it either
//this->updateText();
onFocus=[this]() {
this->focused = true;
@ -156,7 +158,7 @@ void InputComponent::render() { @@ -156,7 +158,7 @@ void InputComponent::render() {
// can actuall delete vertices here
if (userInputText) {
// make sure we're using win's transformMatrix
Shader *fontShader = window->shaderLoader.getShader(VertexShader("FontShader.vert"),
Shader *fontShader = this->win->shaderLoader.getShader(VertexShader("FontShader.vert"),
FragmentShader("FontShader.frag"));
fontShader->bind();
if (!boundToPage) {
@ -166,7 +168,7 @@ void InputComponent::render() { @@ -166,7 +168,7 @@ void InputComponent::render() {
std::cout << "InputComponent::render - glGetUniformLocation not ok: " << glErr << std::endl;
}
// it's about the document transformMatrix
glUniformMatrix4fv(transformLocation, 1, GL_FALSE, window->transformMatrix);
glUniformMatrix4fv(transformLocation, 1, GL_FALSE, this->win->transformMatrix);
glErr=glGetError();
if(glErr != GL_NO_ERROR) {
std::cout << "InputComponent::render - glUniformMatrix4fv not ok: " << glErr << std::endl;
@ -174,7 +176,7 @@ void InputComponent::render() { @@ -174,7 +176,7 @@ void InputComponent::render() {
}
//std::cout << "rendering some text" << std::endl;
userInputText->render();
Shader *textureShader = window->shaderLoader.getShader(VertexShader("TextureShader.vert"),
Shader *textureShader = this->win->shaderLoader.getShader(VertexShader("TextureShader.vert"),
FragmentShader("TextureShader.frag"));
textureShader->bind();
}
@ -304,6 +306,9 @@ void InputComponent::updateText() { @@ -304,6 +306,9 @@ void InputComponent::updateText() {
delete userInputText;
}
userInputText=new TextComponent(value, 0, 0, 12, false, 0x000000FF, windowWidth, windowHeight);
if (!userInputText->win && this->win) {
userInputText->win = this->win;
}
//std::cout << "placing userInputText at " << static_cast<int>(x) << "," << static_cast<int>(y) << std::endl;
userInputText->x = x;
if (y < 0) {
@ -345,5 +350,7 @@ void InputComponent::updateText() { @@ -345,5 +350,7 @@ void InputComponent::updateText() {
//std::cout << "InputComponent::updateText - our width: " << static_cast<int>(width) << " windowWidth: " << windowWidth << std::endl;
userInputText->resize(windowWidth, windowHeight, width); // need to make sure there's a texture
window->renderDirty = true;
if (this->win) {
this->win->renderDirty = true;
} // else it was called from cstr, and window isn't set up yet but no worrites, render will be dirty
}

3
src/graphics/components/InputComponent.h

@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
#include <string>
#include "BoxComponent.h"
#include "TextComponent.h"
#include "../opengl/Window.h"
#include "../../scheduler.h"
class Window;
@ -31,8 +30,6 @@ public: @@ -31,8 +30,6 @@ public:
bool focused = false;
bool showCursor = true;
std::shared_ptr<timer_handle> cursorTimer = nullptr;
// handle to signal that a redraw is needed, and access to shader programs
Window *win;
// store for cursor
int estWidth;
};

Loading…
Cancel
Save