work to diagnose ui misalign
This commit is contained in:
parent
12aeb0a317
commit
c641512886
@ -6,10 +6,10 @@ uniform vec3 mDimension;
|
||||
|
||||
void main(){
|
||||
//0,0
|
||||
vec2 finalPos = vec2(
|
||||
((aPos.x + 1)/2 * mDimension.x + mPosition.x) * 2 - 1,
|
||||
((((aPos.y + 1)/2) * mDimension.y + mPosition.y) * 2 - 1)
|
||||
// aPos.y * mDimension.y + (mPosition.y) + (1 - mDimension.y)
|
||||
);
|
||||
vec2 finalPos = vec2(
|
||||
((((aPos.x + 1)/2) * mDimension.x + mPosition.x) * 2 - 1),
|
||||
((((aPos.y + 1)/2) * mDimension.y + mPosition.y) * 2 - 1)
|
||||
// aPos.y * mDimension.y + (mPosition.y) + (1 - mDimension.y)
|
||||
);
|
||||
gl_Position = vec4(finalPos.x, finalPos.y, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@ -423,9 +423,36 @@ public class MenuGenerators {
|
||||
}});
|
||||
|
||||
//slider test
|
||||
Slider slider = new Slider(500, 500, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
Slider slider = new Slider(0, 0, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
rVal.addChild(slider);
|
||||
|
||||
// slider = new Slider(0, 100, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
// slider = new Slider(0, 200, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
// slider = new Slider(0, 300, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
// slider = new Slider(0, 400, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
// slider = new Slider(0, 500, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
// slider = new Slider(0, 600, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
// slider = new Slider(0, 700, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
// slider = new Slider(0, 800, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
// slider = new Slider(0, 900, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@ import static org.lwjgl.glfw.GLFW.glfwSetInputMode;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSwapBuffers;
|
||||
import static org.lwjgl.glfw.GLFW.glfwTerminate;
|
||||
import static org.lwjgl.glfw.GLFW.glfwWindowHint;
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor;
|
||||
import org.lwjgl.glfw.GLFWWindowSizeCallbackI;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@ -215,7 +216,9 @@ public class RenderingEngine {
|
||||
// glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent
|
||||
// glfwWindowHint(GLFW_OPACITY, 23);
|
||||
//Creates the window reference object
|
||||
Globals.window = glfwCreateWindow(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, "ORPG", NULL, NULL);
|
||||
// Globals.window = glfwCreateWindow(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, "ORPG", NULL, NULL);
|
||||
//below line is for fullscreen
|
||||
Globals.window = glfwCreateWindow(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, "ORPG", glfwGetPrimaryMonitor(), NULL);
|
||||
//Errors for failure to create window (IE: No GUI mode on linux ?)
|
||||
if (Globals.window == NULL) {
|
||||
LoggerInterface.loggerEngine.ERROR("Failed to make window.", new Exception("Renderer Creation Failure"));
|
||||
|
||||
@ -51,7 +51,7 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
||||
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
|
||||
|
||||
widgetBuffer.bind();
|
||||
// Globals.renderingEngine.setViewportSize(width, height);
|
||||
Globals.renderingEngine.setViewportSize(width, height);
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
@ -108,17 +108,17 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextureCoord(int x, int y){
|
||||
float ndcX = (float)x/Globals.WINDOW_WIDTH;
|
||||
float ndcY = (float)y/Globals.WINDOW_HEIGHT;
|
||||
texPosition = new Vector3f(ndcX,ndcY,0);
|
||||
}
|
||||
// public void setTextureCoord(int x, int y){
|
||||
// float ndcX = (float)x/Globals.WINDOW_WIDTH;
|
||||
// float ndcY = (float)y/Globals.WINDOW_HEIGHT;
|
||||
// texPosition = new Vector3f(ndcX,ndcY,0);
|
||||
// }
|
||||
|
||||
public void setTextureScale(int x, int y){
|
||||
float ndcWidth = (float)x/Globals.WINDOW_WIDTH;
|
||||
float ndcHeight = (float)y/Globals.WINDOW_HEIGHT;
|
||||
texScale = new Vector3f(ndcWidth,ndcHeight,0);
|
||||
}
|
||||
// public void setTextureScale(int x, int y){
|
||||
// float ndcWidth = (float)x/Globals.WINDOW_WIDTH;
|
||||
// float ndcHeight = (float)y/Globals.WINDOW_HEIGHT;
|
||||
// texScale = new Vector3f(ndcWidth,ndcHeight,0);
|
||||
// }
|
||||
|
||||
public int width = 1;
|
||||
public int height = 1;
|
||||
|
||||
@ -97,14 +97,11 @@ public class Slider implements ClickableElement, DraggableElement, FocusableElem
|
||||
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||
|
||||
|
||||
Model planeModel = Globals.assetManager.fetchModel(Globals.solidPlaneModelID);
|
||||
if(planeModel != null){
|
||||
//bounding box/margin
|
||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||
planeModel.pushUniformToMesh("plane", "tPosition", new Vector3f(0,0,0));
|
||||
planeModel.pushUniformToMesh("plane", "tDimension", new Vector3f(1,1,0));
|
||||
planeModel.pushUniformToMesh(planeModel.meshes.get(0).nodeID, "color", colorBackground);
|
||||
planeModel.drawUI();
|
||||
|
||||
@ -117,8 +114,6 @@ public class Slider implements ClickableElement, DraggableElement, FocusableElem
|
||||
boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||
planeModel.pushUniformToMesh("plane", "tPosition", new Vector3f(0,0,0));
|
||||
planeModel.pushUniformToMesh("plane", "tDimension", new Vector3f(1,1,0));
|
||||
planeModel.pushUniformToMesh(planeModel.meshes.get(0).nodeID, "color", colorForeground);
|
||||
planeModel.drawUI();
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user