image-based frames for backing elements
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
a005e067fe
commit
ff44e78078
BIN
assets/Textures/ui/panel-001.png
Normal file
BIN
assets/Textures/ui/panel-001.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 160 B |
BIN
assets/Textures/ui/panel-005.png
Normal file
BIN
assets/Textures/ui/panel-005.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 180 B |
@ -1,3 +1,3 @@
|
||||
#maven.buildNumber.plugin properties file
|
||||
#Fri Mar 28 19:50:10 EDT 2025
|
||||
buildNumber=612
|
||||
#Tue Apr 01 15:25:00 EDT 2025
|
||||
buildNumber=616
|
||||
|
||||
@ -91,6 +91,12 @@ public class MenuWorldSelect {
|
||||
public static Element createWorldCreationMenu(){
|
||||
FormElement rVal = new FormElement();
|
||||
|
||||
//set nav callback
|
||||
WindowUtils.setMainMenuBackoutCallback((NavigationEvent event) -> {
|
||||
WindowUtils.replaceMainMenuContents(MenuWorldSelect.createWorldSelectMenu());
|
||||
return false;
|
||||
});
|
||||
|
||||
//text entry (world name)
|
||||
Div worldNameInputContainer = Div.createRow();
|
||||
worldNameInputContainer.setMarginBottom(20);
|
||||
|
||||
@ -621,10 +621,11 @@ public class Globals {
|
||||
"Textures/w1.png",
|
||||
"Textures/ow1.png",
|
||||
"Textures/ui/WindowBorder.png",
|
||||
"Textures/ui/uiFrame1.png",
|
||||
"Textures/ui/uiFrame2.png",
|
||||
"Textures/ui/uiOutline1.png",
|
||||
AssetDataStrings.UI_ENGINE_LOGO_1,
|
||||
AssetDataStrings.UI_FRAME_TEXTURE_DEFAULT_1,
|
||||
AssetDataStrings.UI_FRAME_TEXTURE_DEFAULT_2,
|
||||
AssetDataStrings.UI_FRAME_TEXTURE_DEFAULT_3,
|
||||
"Textures/ui/circle.png",
|
||||
"Textures/ui/square.png",
|
||||
"Textures/color/transparent_green.png",
|
||||
|
||||
@ -44,6 +44,7 @@ public class AssetDataStrings {
|
||||
public static final String UI_ENGINE_LOGO_1 = "Textures/engine/stormenginelogo1.png";
|
||||
public static final String UI_FRAME_TEXTURE_DEFAULT_1 = "Textures/ui/uiFrame1.png";
|
||||
public static final String UI_FRAME_TEXTURE_DEFAULT_2 = "Textures/ui/uiFrame2.png";
|
||||
public static final String UI_FRAME_TEXTURE_DEFAULT_3 = "Textures/ui/panel-001.png";
|
||||
|
||||
/**
|
||||
* UI generic audio
|
||||
|
||||
@ -38,7 +38,7 @@ public class ShaderUtils {
|
||||
//matrix4f
|
||||
if(value instanceof Matrix4f){
|
||||
Matrix4f currentUniform = (Matrix4f)value;
|
||||
GL40.glUniformMatrix4fv(uniformLocation, false, currentUniform.get(new float[16]));
|
||||
GL40.glUniformMatrix4fv(uniformLocation, false, currentUniform.get(BufferUtils.createFloatBuffer(16)));
|
||||
Globals.renderingEngine.checkError();
|
||||
uniformMap.put(uniformLocation,new Matrix4f(currentUniform)); //create new matrix4f to break pointer-matching with equals on cache check
|
||||
|
||||
@ -46,7 +46,7 @@ public class ShaderUtils {
|
||||
//matrix4d
|
||||
} else if(value instanceof Matrix4d){
|
||||
Matrix4d currentUniform = (Matrix4d)value;
|
||||
GL40.glUniformMatrix4fv(uniformLocation, false, currentUniform.get(new float[16]));
|
||||
GL40.glUniformMatrix4fv(uniformLocation, false, currentUniform.get(BufferUtils.createFloatBuffer(16)));
|
||||
Globals.renderingEngine.checkError();
|
||||
uniformMap.put(uniformLocation,new Matrix4d(currentUniform)); //create new matrix4f to break pointer-matching with equals on cache check
|
||||
|
||||
|
||||
@ -4,13 +4,10 @@ import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
import electrosphere.renderer.framebuffer.Framebuffer;
|
||||
import electrosphere.renderer.model.Material;
|
||||
import electrosphere.renderer.model.Model;
|
||||
import electrosphere.renderer.texture.Texture;
|
||||
import electrosphere.renderer.ui.elementtypes.ClickableElement;
|
||||
import electrosphere.renderer.ui.elementtypes.DrawableElement;
|
||||
import electrosphere.renderer.ui.elementtypes.Element;
|
||||
@ -21,6 +18,7 @@ import electrosphere.renderer.ui.events.Event;
|
||||
import electrosphere.renderer.ui.events.FocusEvent;
|
||||
import electrosphere.renderer.ui.events.HoverEvent;
|
||||
import electrosphere.renderer.ui.events.MouseEvent;
|
||||
import electrosphere.renderer.ui.frame.UIFrameUtils;
|
||||
|
||||
/**
|
||||
* A button element
|
||||
@ -29,11 +27,19 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
||||
|
||||
static Vector3f COLOR_DEFAULT = new Vector3f(1.0f);
|
||||
|
||||
static float COLOR_FRAME_FOCUSED_DEFAULT = 0.1f;
|
||||
static float COLOR_FRAME_UNFOCUSED_DEFAULT = 0.01f;
|
||||
|
||||
/**
|
||||
* The color of the backing element
|
||||
*/
|
||||
Vector3f color = new Vector3f(COLOR_DEFAULT);
|
||||
|
||||
/**
|
||||
* The color of the frame
|
||||
*/
|
||||
Vector3f frameColor = new Vector3f(COLOR_FRAME_FOCUSED_DEFAULT);
|
||||
|
||||
Vector3f boxPosition = new Vector3f();
|
||||
Vector3f boxDimensions = new Vector3f();
|
||||
Vector3f texPosition = new Vector3f(0,0,0);
|
||||
@ -221,38 +227,29 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
||||
float ndcY = (float)this.absoluteToFramebuffer(getAbsoluteY(),framebufferPosY)/framebuffer.getHeight();
|
||||
boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||
boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||
|
||||
Model planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
|
||||
Texture windowFrame = null;
|
||||
if(this.isFocused()){
|
||||
windowFrame = Globals.assetManager.fetchTexture("Textures/ui/uiFrame2.png");
|
||||
} else {
|
||||
windowFrame = Globals.assetManager.fetchTexture("Textures/ui/uiFrame1.png");
|
||||
}
|
||||
|
||||
//this call binds the screen as the "texture" we're rendering to
|
||||
//have to call before actually rendering
|
||||
framebuffer.bind(openGLState);
|
||||
openGLState.glViewport(framebuffer.getWidth(), framebuffer.getHeight());
|
||||
|
||||
//error if assets are null
|
||||
if(planeModel == null || windowFrame == null){
|
||||
LoggerInterface.loggerRenderer.ERROR("Window unable to find plane model or window frame!!", new Exception());
|
||||
}
|
||||
|
||||
//render background of window
|
||||
if(planeModel != null && windowFrame != null){
|
||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||
planeModel.drawUI();
|
||||
if(this.isFocused()){
|
||||
frameColor.set(COLOR_FRAME_FOCUSED_DEFAULT);
|
||||
UIFrameUtils.drawFrame(
|
||||
AssetDataStrings.UI_FRAME_TEXTURE_DEFAULT_3, frameColor, 48, 12,
|
||||
this.getAbsoluteX(), this.getAbsoluteY(), this.getWidth(), this.getHeight(),
|
||||
framebuffer, framebufferPosX, framebufferPosY
|
||||
);
|
||||
} else {
|
||||
frameColor.set(COLOR_FRAME_UNFOCUSED_DEFAULT);
|
||||
UIFrameUtils.drawFrame(
|
||||
AssetDataStrings.UI_FRAME_TEXTURE_DEFAULT_3, frameColor, 48, 12,
|
||||
this.getAbsoluteX(), this.getAbsoluteY(), this.getWidth(), this.getHeight(),
|
||||
framebuffer, framebufferPosX, framebufferPosY
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//Draw children elements
|
||||
for(Element child : childList){
|
||||
|
||||
@ -3,13 +3,10 @@ package electrosphere.renderer.ui.elements;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
import electrosphere.renderer.framebuffer.Framebuffer;
|
||||
import electrosphere.renderer.model.Material;
|
||||
import electrosphere.renderer.model.Model;
|
||||
import electrosphere.renderer.texture.Texture;
|
||||
import electrosphere.renderer.ui.elementtypes.ClickableElement;
|
||||
import electrosphere.renderer.ui.elementtypes.DrawableElement;
|
||||
import electrosphere.renderer.ui.elementtypes.Element;
|
||||
@ -22,6 +19,7 @@ import electrosphere.renderer.ui.events.FocusEvent;
|
||||
import electrosphere.renderer.ui.events.KeyboardEvent;
|
||||
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||
import electrosphere.renderer.ui.font.Font;
|
||||
import electrosphere.renderer.ui.frame.UIFrameUtils;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.util.yoga.Yoga;
|
||||
@ -144,35 +142,25 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
|
||||
float ndcY = (float)this.absoluteToFramebuffer(getAbsoluteY(),framebufferPosY)/framebuffer.getHeight();
|
||||
boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||
boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||
|
||||
Model planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
|
||||
Texture windowFrame = null;
|
||||
if(this.isFocused()){
|
||||
windowFrame = Globals.assetManager.fetchTexture("Textures/ui/uiFrame2.png");
|
||||
} else {
|
||||
windowFrame = Globals.assetManager.fetchTexture("Textures/ui/uiFrame1.png");
|
||||
}
|
||||
|
||||
//this call binds the screen as the "texture" we're rendering to
|
||||
//have to call before actually rendering
|
||||
framebuffer.bind(openGLState);
|
||||
openGLState.glViewport(framebuffer.getWidth(), framebuffer.getHeight());
|
||||
|
||||
//error if assets are null
|
||||
if(planeModel == null || windowFrame == null){
|
||||
LoggerInterface.loggerRenderer.ERROR("Window unable to find plane model or window frame!!", new Exception());
|
||||
}
|
||||
|
||||
//render background of window
|
||||
if(planeModel != null && windowFrame != null){
|
||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", backgroundColor);
|
||||
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||
planeModel.drawUI();
|
||||
if(this.isFocused()){
|
||||
UIFrameUtils.drawFrame(
|
||||
AssetDataStrings.UI_FRAME_TEXTURE_DEFAULT_3, backgroundColor, 48, 12,
|
||||
this.getAbsoluteX(), this.getAbsoluteY(), this.getWidth(), this.getHeight(),
|
||||
framebuffer, framebufferPosX, framebufferPosY
|
||||
);
|
||||
} else {
|
||||
UIFrameUtils.drawFrame(
|
||||
AssetDataStrings.UI_FRAME_TEXTURE_DEFAULT_3, backgroundColor, 48, 12,
|
||||
this.getAbsoluteX(), this.getAbsoluteY(), this.getWidth(), this.getHeight(),
|
||||
framebuffer, framebufferPosX, framebufferPosY
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -158,6 +158,8 @@ public class ToggleInput extends StandardDrawableElement implements ClickableEle
|
||||
planeModel.getMeshes().get(0).setMaterial(barMat);
|
||||
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.getMeshes().get(0).getMeshName(), "color", barColor);
|
||||
planeModel.drawUI();
|
||||
|
||||
@ -171,6 +173,8 @@ public class ToggleInput extends StandardDrawableElement implements ClickableEle
|
||||
planeModel.getMeshes().get(0).setMaterial(circleMat);
|
||||
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.getMeshes().get(0).getMeshName(), "color", circleColor);
|
||||
planeModel.drawUI();
|
||||
} else {
|
||||
|
||||
300
src/main/java/electrosphere/renderer/ui/frame/UIFrameUtils.java
Normal file
300
src/main/java/electrosphere/renderer/ui/frame/UIFrameUtils.java
Normal file
@ -0,0 +1,300 @@
|
||||
package electrosphere.renderer.ui.frame;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.renderer.framebuffer.Framebuffer;
|
||||
import electrosphere.renderer.model.Material;
|
||||
import electrosphere.renderer.model.Model;
|
||||
import electrosphere.renderer.texture.Texture;
|
||||
|
||||
/**
|
||||
* Utilities to draw frames behind elements
|
||||
*/
|
||||
public class UIFrameUtils {
|
||||
|
||||
/**
|
||||
* The material used for drawing the texture for the frame
|
||||
*/
|
||||
private static final Material customMat = new Material();
|
||||
|
||||
/**
|
||||
* Stores the position of the box to draw
|
||||
*/
|
||||
private static final Vector3f boxPosition = new Vector3f();
|
||||
|
||||
/**
|
||||
* Stores the dimensions of the box to draw
|
||||
*/
|
||||
private static final Vector3f boxDimensions = new Vector3f();
|
||||
|
||||
/**
|
||||
* Stores the position of the texture to draw on the box
|
||||
*/
|
||||
private static final Vector3f texPosition = new Vector3f();
|
||||
|
||||
/**
|
||||
* Stores the dimensions of the texture to draw on the box
|
||||
*/
|
||||
private static final Vector3f texScale = new Vector3f();
|
||||
|
||||
/**
|
||||
* Draws a frame
|
||||
* @param frame The texture of the frame to draw
|
||||
* @param color The color to draw
|
||||
* @param frameCornerDim The dimensions of a corner of the frame texture
|
||||
* @param posX The absolute x position to draw the frame
|
||||
* @param posY The absolute y position to draw the frame
|
||||
* @param width The width of the frame
|
||||
* @param height The height of the frame
|
||||
* @param framebuffer The framebuffer to draw to
|
||||
* @param framebufferPosX The x position of the framebuffer
|
||||
* @param framebufferPosY The y position of the framebuffer
|
||||
*/
|
||||
public static void drawFrame(
|
||||
String frame, Vector3f color, int frameTexDim, int frameCornerDim,
|
||||
int posX, int posY, int width, int height,
|
||||
Framebuffer framebuffer, int framebufferPosX, int framebufferPosY
|
||||
){
|
||||
Model planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
|
||||
Texture windowFrame = Globals.assetManager.fetchTexture(frame);
|
||||
//render background of window
|
||||
if(planeModel != null && windowFrame != null){
|
||||
//set materials + uniforms
|
||||
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||
|
||||
|
||||
//top left corner
|
||||
boxPosition.set(
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posX,framebufferPosX)/framebuffer.getWidth(),
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posY,framebufferPosY)/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
boxDimensions.set(
|
||||
(float)frameCornerDim/framebuffer.getWidth(),
|
||||
(float)frameCornerDim/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
texPosition.set(
|
||||
0,
|
||||
((frameTexDim - frameCornerDim) / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
texScale.set(
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
UIFrameUtils.drawBox(planeModel);
|
||||
|
||||
//top center side
|
||||
boxPosition.set(
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posX + frameCornerDim,framebufferPosX)/framebuffer.getWidth(),
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posY,framebufferPosY)/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
boxDimensions.set(
|
||||
(float)(width - (frameCornerDim * 2))/framebuffer.getWidth(),
|
||||
(float)frameCornerDim/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
texPosition.set(
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
((frameTexDim - frameCornerDim) / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
texScale.set(
|
||||
((frameTexDim - (frameCornerDim * 2)) / (float)frameTexDim),
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
UIFrameUtils.drawBox(planeModel);
|
||||
|
||||
//top right corner
|
||||
boxPosition.set(
|
||||
(float)UIFrameUtils.absoluteToFramebuffer((posX + width) - frameCornerDim,framebufferPosX)/framebuffer.getWidth(),
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posY,framebufferPosY)/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
boxDimensions.set(
|
||||
(float)frameCornerDim/framebuffer.getWidth(),
|
||||
(float)frameCornerDim/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
texPosition.set(
|
||||
((frameTexDim - frameCornerDim) / (float)frameTexDim),
|
||||
((frameTexDim - frameCornerDim) / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
texScale.set(
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
UIFrameUtils.drawBox(planeModel);
|
||||
|
||||
//center left side
|
||||
boxPosition.set(
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posX,framebufferPosX)/framebuffer.getWidth(),
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posY + frameCornerDim,framebufferPosY)/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
boxDimensions.set(
|
||||
(float)frameCornerDim/framebuffer.getWidth(),
|
||||
(float)(height - (frameCornerDim * 2))/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
texPosition.set(
|
||||
0,
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
texScale.set(
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
((frameTexDim - (frameCornerDim * 2)) / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
UIFrameUtils.drawBox(planeModel);
|
||||
|
||||
//center point
|
||||
boxPosition.set(
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posX + frameCornerDim,framebufferPosX)/framebuffer.getWidth(),
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posY + frameCornerDim,framebufferPosY)/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
boxDimensions.set(
|
||||
(float)(width - (frameCornerDim * 2))/framebuffer.getWidth(),
|
||||
(float)(height - (frameCornerDim * 2))/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
texPosition.set(
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
texScale.set(
|
||||
((frameTexDim - (frameCornerDim * 2)) / (float)frameTexDim),
|
||||
((frameTexDim - (frameCornerDim * 2)) / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
UIFrameUtils.drawBox(planeModel);
|
||||
|
||||
//center right side
|
||||
boxPosition.set(
|
||||
(float)UIFrameUtils.absoluteToFramebuffer((posX + width) - frameCornerDim,framebufferPosX)/framebuffer.getWidth(),
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posY + frameCornerDim,framebufferPosY)/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
boxDimensions.set(
|
||||
(float)frameCornerDim/framebuffer.getWidth(),
|
||||
(float)(height - (frameCornerDim * 2))/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
texPosition.set(
|
||||
((frameTexDim - frameCornerDim) / (float)frameTexDim),
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
texScale.set(
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
((frameTexDim - (frameCornerDim * 2)) / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
UIFrameUtils.drawBox(planeModel);
|
||||
|
||||
//bottom left corner
|
||||
boxPosition.set(
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posX,framebufferPosX)/framebuffer.getWidth(),
|
||||
(float)UIFrameUtils.absoluteToFramebuffer((posY + height) - frameCornerDim,framebufferPosY)/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
boxDimensions.set(
|
||||
(float)frameCornerDim/framebuffer.getWidth(),
|
||||
(float)frameCornerDim/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
texPosition.set(
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
texScale.set(
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
UIFrameUtils.drawBox(planeModel);
|
||||
|
||||
//bottom center side
|
||||
boxPosition.set(
|
||||
(float)UIFrameUtils.absoluteToFramebuffer(posX + frameCornerDim,framebufferPosX)/framebuffer.getWidth(),
|
||||
(float)UIFrameUtils.absoluteToFramebuffer((posY + height) - frameCornerDim,framebufferPosY)/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
boxDimensions.set(
|
||||
(float)(width - (frameCornerDim * 2))/framebuffer.getWidth(),
|
||||
(float)frameCornerDim/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
texPosition.set(
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0,
|
||||
0
|
||||
);
|
||||
texScale.set(
|
||||
((frameTexDim - (frameCornerDim * 2)) / (float)frameTexDim),
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
UIFrameUtils.drawBox(planeModel);
|
||||
|
||||
//bottom right corner
|
||||
boxPosition.set(
|
||||
(float)UIFrameUtils.absoluteToFramebuffer((posX + width) - frameCornerDim,framebufferPosX)/framebuffer.getWidth(),
|
||||
(float)UIFrameUtils.absoluteToFramebuffer((posY + height) - frameCornerDim,framebufferPosY)/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
boxDimensions.set(
|
||||
(float)frameCornerDim/framebuffer.getWidth(),
|
||||
(float)frameCornerDim/framebuffer.getHeight(),
|
||||
0
|
||||
);
|
||||
texPosition.set(
|
||||
((frameTexDim - frameCornerDim) / (float)frameTexDim),
|
||||
0,
|
||||
0
|
||||
);
|
||||
texScale.set(
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
(frameCornerDim / (float)frameTexDim),
|
||||
0
|
||||
);
|
||||
UIFrameUtils.drawBox(planeModel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a box for the frame
|
||||
* @param planeModel The model to use
|
||||
*/
|
||||
private static void drawBox(Model planeModel){
|
||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||
planeModel.drawUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an absolute (to the screen) position to a position within a framebuffer
|
||||
* @param absolutePos The absolute position
|
||||
* @param framebufferPos The position of the framebuffer on the screen
|
||||
* @return The position within the framebuffer
|
||||
*/
|
||||
public static int absoluteToFramebuffer(int absolutePos, int framebufferPos){
|
||||
return absolutePos - framebufferPos;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user