refactor ui framework to use openglstate
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-03-21 19:51:42 -04:00
parent 37a4cd7dd6
commit 20c0bff89d
21 changed files with 98 additions and 60 deletions

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Tue Mar 19 19:54:15 EDT 2024
buildNumber=77
#Thu Mar 21 19:13:46 EDT 2024
buildNumber=78

View File

@ -0,0 +1,8 @@
@page structuresandbuildings Structures and Buildings
For this, I think we're going to try for 0.25 meter cube voxels in a separate mesh from the terrain. This will allow for LOD at long distance with good scaling.
0.25 meter cubed voxels are going to be 256kb/chunk uncompressed. That's 250mb/1000 chunks
Problems to be solved:
LOD alongside terrain marching cubes

View File

@ -182,6 +182,8 @@ Fix Frustum Culling for skybox
Fix Character creation preview not working
Fix bad data with human mesh textures not mapping
Clean up main method/class
Include Remotery library
@ -253,6 +255,7 @@ Generate Tree Entities
- Ability to specify central stem
- Cubic function for limb dispersion over length
- Generate branch starters from trunk that are not full length
- Have leaves point out of branches at specific angles
Foliage Manager upgrades
- Wind system (environment ubi that defines wind that is lookup'd by individual blades)

View File

@ -557,10 +557,6 @@ public class RenderingEngine {
glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer);
}
public void setViewportSize(int width, int height){
glViewport(0, 0, width, height);
}
public void setTitleBarDimensions(){
IntBuffer tLeft = BufferUtils.createIntBuffer(1);
IntBuffer tTop = BufferUtils.createIntBuffer(1);

View File

@ -38,7 +38,7 @@ public class DebugRendering {
if(currentElement instanceof DrawableElement){
DrawableElement drawable = (DrawableElement) currentElement;
if(drawable.getVisible()){
drawable.draw(RenderingEngine.GL_DEFAULT_FRAMEBUFFER, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
drawable.draw(Globals.renderingEngine.getRenderPipelineState(),Globals.renderingEngine.getOpenGLState(),RenderingEngine.GL_DEFAULT_FRAMEBUFFER, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
}
}
}

View File

@ -67,7 +67,7 @@ public class UIPipeline implements RenderPipeline {
if(currentElement instanceof DrawableElement){
DrawableElement drawable = (DrawableElement) currentElement;
if(drawable.getVisible()){
drawable.draw(RenderingEngine.GL_DEFAULT_FRAMEBUFFER, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
drawable.draw(renderPipelineState, openGLState, RenderingEngine.GL_DEFAULT_FRAMEBUFFER, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
}
}
}

View File

@ -1,5 +1,8 @@
package electrosphere.renderer.ui;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
/**
*
* @author amaterasu
@ -10,7 +13,7 @@ public interface DrawableElement extends Element {
public void setVisible(boolean draw);
public abstract void draw(int parentFramebufferPointer, int parentWidth, int parentHeight);
public abstract void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight);
}

View File

@ -14,6 +14,8 @@ import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.debug.DebugRendering;
import electrosphere.renderer.framebuffer.Framebuffer;
import electrosphere.renderer.framebuffer.FramebufferUtils;
@ -57,10 +59,10 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
}
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
widgetBuffer.bind();
Globals.renderingEngine.setViewportSize(width, height);
openGLState.glViewport(width, height);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -68,13 +70,13 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
for(Element child : childList){
if(child instanceof DrawableElement){
DrawableElement drawableChild = (DrawableElement) child;
drawableChild.draw(widgetBuffer.getFramebufferPointer(),width,height);
drawableChild.draw(renderPipelineState,openGLState,widgetBuffer.getFramebufferPointer(),width,height);
}
}
//this call binds the screen as the "texture" we're rendering to
//have to call before actually rendering
glBindFramebuffer(GL_FRAMEBUFFER, parentFramebufferPointer);
Globals.renderingEngine.setViewportSize(parentWidth, parentHeight);
openGLState.glViewport(parentWidth, parentHeight);
Model planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
if(planeModel != null){

View File

@ -22,6 +22,8 @@ import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.RenderingEngine;
import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.debug.DebugRendering;
@ -74,7 +76,7 @@ public class ActorPanel implements DrawableElement, DraggableElement {
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
elementBuffer.bind();
// Globals.renderingEngine.setViewportSize(width, height);
@ -82,10 +84,10 @@ public class ActorPanel implements DrawableElement, DraggableElement {
RenderingEngine.setFOV(FOV);
RenderingEngine.setAspectRatio(aspectRatio);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
openGLState.glDepthTest(true);
openGLState.glDepthFunc(GL_LESS);
glDepthMask(true);
glViewport(0, 0, width, height);
openGLState.glViewport(width, height);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -105,13 +107,13 @@ public class ActorPanel implements DrawableElement, DraggableElement {
//
// Set rendering engine state
//
Globals.renderingEngine.getRenderPipelineState().setUseMeshShader(true);
Globals.renderingEngine.getRenderPipelineState().setBufferStandardUniforms(true);
Globals.renderingEngine.getRenderPipelineState().setBufferNonStandardUniforms(true);
Globals.renderingEngine.getRenderPipelineState().setUseMaterial(true);
Globals.renderingEngine.getRenderPipelineState().setUseShadowMap(true);
Globals.renderingEngine.getRenderPipelineState().setUseBones(true);
Globals.renderingEngine.getRenderPipelineState().setUseLight(true);
renderPipelineState.setUseMeshShader(true);
renderPipelineState.setBufferStandardUniforms(true);
renderPipelineState.setBufferNonStandardUniforms(true);
renderPipelineState.setUseMaterial(true);
renderPipelineState.setUseShadowMap(true);
renderPipelineState.setUseBones(true);
renderPipelineState.setUseLight(true);
@ -120,19 +122,19 @@ public class ActorPanel implements DrawableElement, DraggableElement {
actor.applyModelMatrix(modelMatrix);
actor.draw(Globals.renderingEngine.getRenderPipelineState(),Globals.renderingEngine.getOpenGLState());
actor.draw(renderPipelineState,openGLState);
RenderingEngine.setFOV(Globals.verticalFOV);
RenderingEngine.setAspectRatio(Globals.aspectRatio);
glDisable(GL_DEPTH_TEST);
openGLState.glDepthTest(false);
//this call binds the screen as the "texture" we're rendering to
//have to call before actually rendering
glBindFramebuffer(GL_FRAMEBUFFER, parentFramebufferPointer);
//set viewport
Globals.renderingEngine.setViewportSize(parentWidth, parentHeight);
openGLState.glViewport(parentWidth, parentHeight);
float ndcX = (float)positionX/parentWidth;
float ndcY = (float)positionY/parentHeight;
@ -142,8 +144,8 @@ public class ActorPanel implements DrawableElement, DraggableElement {
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
Globals.renderingEngine.getOpenGLState().setActiveShader(
Globals.renderingEngine.getRenderPipelineState(),
openGLState.setActiveShader(
renderPipelineState,
Globals.assetManager.fetchShader("Shaders/ui/windowContent/windowContent.vs", null, "Shaders/ui/windowContent/windowContent.fs")
);
@ -154,13 +156,13 @@ public class ActorPanel implements DrawableElement, DraggableElement {
//
// Set rendering engine state
//
Globals.renderingEngine.getRenderPipelineState().setUseMeshShader(false);
Globals.renderingEngine.getRenderPipelineState().setBufferStandardUniforms(false);
Globals.renderingEngine.getRenderPipelineState().setBufferNonStandardUniforms(true);
Globals.renderingEngine.getRenderPipelineState().setUseMaterial(true);
Globals.renderingEngine.getRenderPipelineState().setUseShadowMap(false);
Globals.renderingEngine.getRenderPipelineState().setUseBones(false);
Globals.renderingEngine.getRenderPipelineState().setUseLight(false);
renderPipelineState.setUseMeshShader(false);
renderPipelineState.setBufferStandardUniforms(false);
renderPipelineState.setBufferNonStandardUniforms(true);
renderPipelineState.setUseMaterial(true);
renderPipelineState.setUseShadowMap(false);
renderPipelineState.setUseBones(false);
renderPipelineState.setUseLight(false);
@ -173,7 +175,7 @@ public class ActorPanel implements DrawableElement, DraggableElement {
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
planeModel.getMeshes().get(0).setMaterial(customMat);
planeModel.draw(Globals.renderingEngine.getRenderPipelineState(),Globals.renderingEngine.getOpenGLState());
planeModel.draw(renderPipelineState,Globals.renderingEngine.getOpenGLState());
} else {
LoggerInterface.loggerRenderer.ERROR("Actor Panel unable to find plane model!!", new Exception());
}

View File

@ -6,6 +6,8 @@ import java.util.List;
import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.debug.DebugRendering;
import electrosphere.renderer.ui.ClickableElement;
import electrosphere.renderer.ui.ContainerElement;
@ -204,11 +206,11 @@ public class Button implements DrawableElement, FocusableElement, ContainerEleme
}
}
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
for(Element child : childList){
if(child instanceof DrawableElement){
DrawableElement drawableChild = (DrawableElement) child;
drawableChild.draw(parentFramebufferPointer,parentWidth,parentHeight);
drawableChild.draw(renderPipelineState,openGLState,parentFramebufferPointer,parentWidth,parentHeight);
}
}

View File

@ -6,6 +6,8 @@ import java.util.List;
import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.debug.DebugRendering;
import electrosphere.renderer.ui.ClickableElement;
import electrosphere.renderer.ui.ContainerElement;
@ -334,11 +336,11 @@ public class Div implements ClickableElement,ContainerElement,DraggableElement,F
}
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
for(Element child : childList){
if(child instanceof DrawableElement){
DrawableElement drawableChild = (DrawableElement) child;
drawableChild.draw(parentFramebufferPointer,parentWidth,parentHeight);
drawableChild.draw(renderPipelineState,openGLState,parentFramebufferPointer,parentWidth,parentHeight);
}
}

View File

@ -7,6 +7,8 @@ import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.debug.DebugRendering;
import electrosphere.renderer.model.Material;
import electrosphere.renderer.model.Model;
@ -66,7 +68,7 @@ public class ImagePanel implements DrawableElement, DraggableElement {
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
if(!hasLoadedTexture){
texture = Globals.assetManager.fetchTexture(this.texturePath);
if(texture != null){

View File

@ -6,6 +6,8 @@ import java.util.List;
import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.debug.DebugRendering;
import electrosphere.renderer.ui.DrawableElement;
import electrosphere.renderer.ui.Element;
@ -85,9 +87,9 @@ public class Label implements DrawableElement {
}
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
for(DrawableElement child : childrenElements){
child.draw(parentFramebufferPointer, parentWidth, parentHeight);
child.draw(renderPipelineState,openGLState,parentFramebufferPointer, parentWidth, parentHeight);
}
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS && DebugRendering.RENDER_DEBUG_OUTLINE_LABEL){

View File

@ -8,6 +8,8 @@ import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.framebuffer.Framebuffer;
import electrosphere.renderer.framebuffer.FramebufferUtils;
import electrosphere.renderer.model.Material;
@ -187,7 +189,7 @@ public class ScrollableContainer implements DrawableElement, ContainerElement {
}
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
//figure out if currently focused element is a child or subchild of this container
if(containsFocusedElement(this)){
//if it is, if it is offscreen, calculate offset to put it onscreen
@ -243,13 +245,13 @@ public class ScrollableContainer implements DrawableElement, ContainerElement {
for(Element child : childList){
if(child instanceof DrawableElement){
DrawableElement drawableChild = (DrawableElement) child;
drawableChild.draw(widgetBuffer.getFramebufferPointer(),width,height);
drawableChild.draw(renderPipelineState,openGLState,widgetBuffer.getFramebufferPointer(),width,height);
}
}
//this call binds the screen as the "texture" we're rendering to
//have to call before actually rendering
glBindFramebuffer(GL_FRAMEBUFFER, parentFramebufferPointer);
Globals.renderingEngine.setViewportSize(parentWidth, parentHeight);
openGLState.glViewport(parentWidth, parentHeight);
Model planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
if(planeModel != null){

View File

@ -4,6 +4,8 @@ import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.debug.DebugRendering;
import electrosphere.renderer.model.Model;
import electrosphere.renderer.ui.ClickableElement;
@ -70,10 +72,10 @@ public class Slider implements ClickableElement, DraggableElement, FocusableElem
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
Globals.renderingEngine.bindFramebuffer(parentFramebufferPointer);
Globals.renderingEngine.setViewportSize(parentWidth, parentHeight);
openGLState.glViewport(parentWidth, parentHeight);
int marginX = Math.max(width - idealMargin * 2, 0);
if(marginX < idealMargin){

View File

@ -6,6 +6,8 @@ import java.util.List;
import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.ui.DrawableElement;
import electrosphere.renderer.ui.Element;
import electrosphere.renderer.ui.FocusableElement;
@ -118,9 +120,9 @@ public class StringCarousel implements DrawableElement, MenuEventElement, Focusa
}
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
for(DrawableElement child : childrenElements){
child.draw(parentFramebufferPointer, parentWidth, parentHeight);
child.draw(renderPipelineState, openGLState, parentFramebufferPointer, parentWidth, parentHeight);
}
}

View File

@ -2,6 +2,8 @@ package electrosphere.renderer.ui.elements;
import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.model.Model;
import electrosphere.renderer.ui.DrawableElement;
import electrosphere.renderer.ui.events.Event;
@ -52,7 +54,7 @@ public class TextBox implements DrawableElement {
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight){
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight){
throw new UnsupportedOperationException("Transparent Text box draw function not implemented yet oop");
// float ndcX = (float)positionX/Globals.WINDOW_WIDTH;
// float ndcY = (float)positionY/Globals.WINDOW_HEIGHT;

View File

@ -2,6 +2,8 @@ package electrosphere.renderer.ui.elements;
import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.framebuffer.Framebuffer;
import electrosphere.renderer.framebuffer.FramebufferUtils;
import electrosphere.renderer.model.Material;
@ -103,9 +105,9 @@ public class TextInput implements DrawableElement, FocusableElement, KeyEventEle
}
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
for(DrawableElement child : childrenElements){
child.draw(parentFramebufferPointer, parentWidth, parentHeight);
child.draw(renderPipelineState, openGLState, parentFramebufferPointer, parentWidth, parentHeight);
}
}

View File

@ -2,6 +2,8 @@ package electrosphere.renderer.ui.font.bitmapchar;
import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.model.Material;
import electrosphere.renderer.model.Model;
import electrosphere.renderer.ui.DrawableElement;
@ -49,9 +51,9 @@ public class BitmapCharacter implements DrawableElement {
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight){
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight){
Globals.renderingEngine.bindFramebuffer(parentFramebufferPointer);
Globals.renderingEngine.setViewportSize(parentWidth, parentHeight);
openGLState.glViewport(parentWidth, parentHeight);
float ndcX = (float)positionX/parentWidth;
float ndcY = (float)positionY/parentHeight;// + (float)Globals.WINDOW_TITLE_BAR_HEIGHT/parentHeight;
float ndcWidth = (float)width/parentWidth;

View File

@ -3,6 +3,8 @@ package electrosphere.renderer.ui.form;
import java.util.LinkedList;
import java.util.List;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.ui.ContainerElement;
import electrosphere.renderer.ui.DrawableElement;
import electrosphere.renderer.ui.Element;
@ -12,11 +14,11 @@ public class FormElement implements DrawableElement, ContainerElement {
List<Element> childList = new LinkedList<Element>();
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
for(Element child : childList){
if(child instanceof DrawableElement){
DrawableElement drawableChild = (DrawableElement) child;
drawableChild.draw(parentFramebufferPointer,parentWidth,parentHeight);
drawableChild.draw(renderPipelineState,openGLState,parentFramebufferPointer,parentWidth,parentHeight);
}
}
}

View File

@ -13,6 +13,8 @@ import java.util.List;
import org.joml.Vector3f;
import electrosphere.engine.Globals;
import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.RenderPipelineState;
import electrosphere.renderer.debug.DebugRendering;
import electrosphere.renderer.framebuffer.Framebuffer;
import electrosphere.renderer.framebuffer.FramebufferUtils;
@ -54,14 +56,14 @@ public class LayoutSchemeListScrollable implements DrawableElement,LayoutScheme
static float aaaa = 0;
@Override
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentWidth, int parentHeight) {
widgetBuffer.bind();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
for(Element child : childList){
if(child instanceof DrawableElement){
DrawableElement drawableChild = (DrawableElement) child;
drawableChild.draw(widgetBuffer.getFramebufferPointer(),width,height);
drawableChild.draw(renderPipelineState,openGLState,widgetBuffer.getFramebufferPointer(),width,height);
}
}
//this call binds the screen as the "texture" we're rendering to