diff --git a/src/graphics/components/BoxComponent.cpp b/src/graphics/components/BoxComponent.cpp index 72d764e18ec5e03d7315f68d00ed44ab90b829eb..5373131450d16e28ae9c4b5e0606ca2ad35c180f 100644 --- a/src/graphics/components/BoxComponent.cpp +++ b/src/graphics/components/BoxComponent.cpp @@ -151,6 +151,26 @@ void BoxComponent::render() { // can actuall delete vertices here } +void BoxComponent::changeColor(const unsigned int hexColor) { + // really a texture swap + + // set texture color + data[0][0][0] = (hexColor >> 24) & 0xFF; + data[0][0][1] = (hexColor >> 16) & 0xFF; + data[0][0][2] = (hexColor >> 8) & 0xFF; + data[0][0][3] = (hexColor >> 0) & 0xFF; + + glBindVertexArray(vertexArrayObject); + + // now replace existing texture + glBindTexture(GL_TEXTURE_2D, texture); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + glGenerateMipmap(GL_TEXTURE_2D); + + glBindVertexArray(0); // unbind to prevent anything from accidentally changing it +} + // this seems to work 17-08-10 // for box // anime girl, we'll get aspect ratio breakage @@ -158,7 +178,7 @@ void BoxComponent::resize(const int passedWindowWidth, const int passedWindowHei //std::cout << "BoxComponent::resize" << std::endl; windowWidth = passedWindowWidth; windowHeight = passedWindowHeight; - + //std::cout << "BoxComponent::resize - boundToPage " << boundToPage << std::endl; // figure out new vertices float vx = x; @@ -185,77 +205,3 @@ void BoxComponent::resize(const int passedWindowWidth, const int passedWindowHei verticesDirty = true; } - -void BoxComponent::changeColor(const unsigned int hexColor) { - // really a texture swap - - // set texture color - data[0][0][0] = (hexColor >> 24) & 0xFF; - data[0][0][1] = (hexColor >> 16) & 0xFF; - data[0][0][2] = (hexColor >> 8) & 0xFF; - data[0][0][3] = (hexColor >> 0) & 0xFF; - - glBindVertexArray(vertexArrayObject); - - // now replace existing texture - glBindTexture(GL_TEXTURE_2D, texture); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); - glGenerateMipmap(GL_TEXTURE_2D); - - glBindVertexArray(0); // unbind to prevent anything from accidentally changing it -} - -/* -void BoxComponent::resize(const int passedWindowWidth, const int passedWindowHeight) { - - std::cout << "BoxComponent::resize" << std::endl; - windowWidth = passedWindowWidth; - windowHeight = passedWindowHeight; - - if (boundToPage) { - std::cout << "BoxComponent::resize - boundToPage doing nothing" << std::endl; - } else { - - // figure out our percentages - // 0 / WW = 0 - // 768 / 1024 = 75% - float xPer = initialX / (float)initialWindowWidth; - float yPer = initialY / (float)initialWindowHeight; - // adjust width - float wPer = initialWidth / (float)initialWindowWidth; - //float hPer = initialHeight / (float)initialWindowHeight; - - float vx = xPer * windowWidth; - float vy = yPer * windowHeight; - - // nah I don't think we want things to stretch - //float vWidth = wPer * windowWidth; - //float vHeight = hPer * windowHeight; - - // ugh these just need to be relaid out - //float vWidth = width; - float vWidth = wPer * windowWidth; - float vHeight = height; - - //std::cout << "initial: " << initialX << "x" << initialY << " size: " << initialWidth << "x" << initialHeight << " window size: " << initialWindowWidth << "x" << initialWindowHeight << std::endl; - - //std::cout << "scaled to: " << (int)vx << "x" << (int)vy << " size: " << (int)vWidth << "x" << (int)vHeight << " window size: " << windowWidth << "x" << windowHeight << std::endl; - - - pointToViewport(vx, vy); - distanceToViewport(vWidth, vHeight); - - vertices[(0 * 5) + 0] = vx; - vertices[(0 * 5) + 1] = vy + vHeight; - vertices[(1 * 5) + 0] = vx + vWidth; - vertices[(1 * 5) + 1] = vy + vHeight; - vertices[(2 * 5) + 0] = vx + vWidth; - vertices[(2 * 5) + 1] = vy; - vertices[(3 * 5) + 0] = vx; - vertices[(3 * 5) + 1] = vy; - - verticesDirty = true; - } -} -*/