From bcc7c14f418861ff05925a781c7d356aaecfad76 Mon Sep 17 00:00:00 2001
From: Odilitime <janesmith@airmail.cc>
Date: Fri, 25 Aug 2017 07:32:28 -0700
Subject: [PATCH] shuffle functions around

---
 src/graphics/components/BoxComponent.cpp | 96 ++++++------------------
 1 file changed, 21 insertions(+), 75 deletions(-)

diff --git a/src/graphics/components/BoxComponent.cpp b/src/graphics/components/BoxComponent.cpp
index 72d764e1..53731314 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;
-    }
-}
-*/
-- 
GitLab