fix window framebuffer scrunching bug
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-14 13:17:13 -04:00
parent 43bb67ca57
commit c9691beaa9
3 changed files with 18 additions and 15 deletions

View File

@ -1767,6 +1767,7 @@ Update inventory utility logic
Fix styling for inventory panel ui element Fix styling for inventory panel ui element
Fix content serialization bug with attached items Fix content serialization bug with attached items
Fix playing audio without item defined in natural inventory panel Fix playing audio without item defined in natural inventory panel
Fix window framebuffer scrunching bug

View File

@ -296,7 +296,7 @@ public class ElementService extends SignalServiceImpl {
lock.unlock(); lock.unlock();
while(windowIterator.hasPrevious()){ while(windowIterator.hasPrevious()){
Element currentWindow = windowIterator.previous(); Element currentWindow = windowIterator.previous();
Stack<Element> elementStack = buildElementPositionalStack(new Stack<Element>(), currentWindow, x, y); Stack<Element> elementStack = this.buildElementPositionalStack(new Stack<Element>(), currentWindow, x, y);
Element currentElement = null; Element currentElement = null;
while(elementStack.size() > 0 && propagate == true){ while(elementStack.size() > 0 && propagate == true){
currentElement = elementStack.pop(); currentElement = elementStack.pop();
@ -409,14 +409,14 @@ public class ElementService extends SignalServiceImpl {
* @param offsetY the y offset accumulated * @param offsetY the y offset accumulated
* @return the stack, filled with all relevant elements * @return the stack, filled with all relevant elements
*/ */
Stack<Element> buildElementPositionalStack(Stack<Element> inputStack, Element current, int x, int y){ private Stack<Element> buildElementPositionalStack(Stack<Element> inputStack, Element current, int x, int y){
//if contains x,y, call function on el //if contains x,y, call function on el
if(elementContainsPoint(current,x,y)){ if(this.elementContainsPoint(current,x,y)){
inputStack.push(current); inputStack.push(current);
} }
if(current instanceof ContainerElement){ if(current instanceof ContainerElement){
for(Element el : ((ContainerElement)current).getChildren()){ for(Element el : ((ContainerElement)current).getChildren()){
buildElementPositionalStack(inputStack, el, x, y); this.buildElementPositionalStack(inputStack, el, x, y);
} }
} }
return inputStack; return inputStack;
@ -427,7 +427,7 @@ public class ElementService extends SignalServiceImpl {
ListIterator<Element> windowIterator = elementList.listIterator(elementList.size()); ListIterator<Element> windowIterator = elementList.listIterator(elementList.size());
while(windowIterator.hasPrevious()){ while(windowIterator.hasPrevious()){
Element currentWindow = windowIterator.previous(); Element currentWindow = windowIterator.previous();
Stack<Element> elementStack = buildElementPositionalStack(new Stack<Element>(), currentWindow, event.getCurrentX(), event.getCurrentY()); Stack<Element> elementStack = this.buildElementPositionalStack(new Stack<Element>(), currentWindow, event.getCurrentX(), event.getCurrentY());
Element currentElement = null; Element currentElement = null;
while(elementStack.size() > 0){ while(elementStack.size() > 0){
currentElement = elementStack.pop(); currentElement = elementStack.pop();
@ -486,7 +486,7 @@ public class ElementService extends SignalServiceImpl {
* @param event The event to fire * @param event The event to fire
*/ */
public void click(ClickEvent event){ public void click(ClickEvent event){
fireEvent(event,event.getCurrentX(),event.getCurrentY()); this.fireEvent(event,event.getCurrentX(),event.getCurrentY());
} }
/** /**
@ -502,7 +502,7 @@ public class ElementService extends SignalServiceImpl {
DragEvent event = new DragEvent(x, y, lastX, lastY, deltaX, deltaY, DragEventType.START, null); DragEvent event = new DragEvent(x, y, lastX, lastY, deltaX, deltaY, DragEventType.START, null);
currentDragElement = (DraggableElement)resolveFirstDraggable(event); currentDragElement = (DraggableElement)resolveFirstDraggable(event);
event.setTarget(currentDragElement); event.setTarget(currentDragElement);
fireEvent(event,x,y); this.fireEvent(event,x,y);
} }
/** /**

View File

@ -211,12 +211,6 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
) { ) {
int absoluteX = this.getAbsoluteX(); int absoluteX = this.getAbsoluteX();
int absoluteY = this.getAbsoluteY(); int absoluteY = this.getAbsoluteY();
float ndcWidth = (float)this.getWidth()/framebuffer.getWidth();
float ndcHeight = (float)this.getHeight()/framebuffer.getHeight();
float ndcX = (float)this.absoluteToFramebuffer(absoluteX,framebufferPosX)/framebuffer.getWidth();
float ndcY = (float)this.absoluteToFramebuffer(absoluteY,framebufferPosY)/framebuffer.getHeight();
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
widgetBuffer.bind(openGLState); widgetBuffer.bind(openGLState);
openGLState.glViewport(width, height); openGLState.glViewport(width, height);
@ -234,8 +228,10 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
drawableChild.draw(renderPipelineState,openGLState,widgetBuffer,absoluteX,absoluteY); drawableChild.draw(renderPipelineState,openGLState,widgetBuffer,absoluteX,absoluteY);
} }
} }
//this call binds the screen as the "texture" we're rendering to
//have to call before actually rendering
//
//Actually draw to screen
framebuffer.bind(openGLState); framebuffer.bind(openGLState);
openGLState.glViewport(framebuffer.getWidth(), framebuffer.getHeight()); openGLState.glViewport(framebuffer.getWidth(), framebuffer.getHeight());
@ -255,6 +251,12 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
} }
//render content of window //render content of window
float ndcWidth = (float)this.widgetBuffer.getWidth()/framebuffer.getWidth();
float ndcHeight = (float)this.widgetBuffer.getHeight()/framebuffer.getHeight();
float ndcX = (float)this.absoluteToFramebuffer(absoluteX,framebufferPosX)/framebuffer.getWidth();
float ndcY = (float)this.absoluteToFramebuffer(absoluteY,framebufferPosY)/framebuffer.getHeight();
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
if(planeModel != null){ if(planeModel != null){
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition); planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions); planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);