[refactor]renamed the renderers to gl renderers

liteCraft
hYdos 2020-03-06 07:40:24 +10:00
parent 4dc752d7ef
commit b04274b2e8
17 changed files with 60 additions and 64 deletions

View File

@ -19,7 +19,7 @@ import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.common.obj.ModelLoader;
import com.github.hydos.ginger.engine.opengl.api.*;
import com.github.hydos.ginger.engine.opengl.postprocessing.PostProcessing;
import com.github.hydos.ginger.engine.opengl.render.MasterRenderer;
import com.github.hydos.ginger.engine.opengl.render.GLRenderManager;
import com.github.hydos.ginger.engine.opengl.render.models.GLTexturedModel;
import com.github.hydos.ginger.engine.opengl.utils.*;
@ -150,7 +150,7 @@ public class Litecraft extends Game
this.camera = new FirstPersonCamera(player);
this.data = new GameData(this.player, this.camera, 20);
this.data.handleGuis = false;
((GingerGL)engine).setup(new MasterRenderer(this.camera), INSTANCE);
((GingerGL)engine).setup(new GLRenderManager(this.camera), INSTANCE);
((GingerGL)engine).setGlobalFont(font);
this.data.entities.add(this.player);
break;

View File

@ -7,13 +7,13 @@ import com.github.hydos.ginger.engine.common.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.common.font.GUIText;
import com.github.hydos.ginger.engine.common.screen.Screen;
import com.github.hydos.ginger.engine.opengl.postprocessing.FrameBufferObject;
import com.github.hydos.ginger.engine.opengl.render.MasterRenderer;
import com.github.hydos.ginger.engine.opengl.render.GLRenderManager;
/** Used if a game wants to access engine variables safely */
public class GingerRegister
{
private static GingerRegister INSTANCE;
public MasterRenderer masterRenderer;
public GLRenderManager masterRenderer;
public static GingerRegister getInstance()
{ return INSTANCE; }

View File

@ -5,19 +5,19 @@ import java.util.*;
import com.github.hydos.ginger.engine.common.info.RenderAPI;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.opengl.api.GingerGL;
import com.github.hydos.ginger.engine.opengl.render.renderers.FontRenderer;
import com.github.hydos.ginger.engine.opengl.render.renderers.GLFontRenderer;
import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class TextMaster
{
private static Map<FontType, List<GUIText>> texts = new HashMap<FontType, List<GUIText>>();
private static FontRenderer renderer;
private static GLFontRenderer renderer;
public static void cleanUp()
{ renderer.cleanUp(); }
public static void init()
{ renderer = new FontRenderer(); }
{ renderer = new GLFontRenderer(); }
public static void loadText(GUIText text)
{

View File

@ -12,7 +12,7 @@ import com.github.hydos.ginger.engine.common.screen.Screen;
import com.github.hydos.ginger.engine.common.tools.MousePicker;
import com.github.hydos.ginger.engine.common.util.Timer;
import com.github.hydos.ginger.engine.opengl.postprocessing.*;
import com.github.hydos.ginger.engine.opengl.render.MasterRenderer;
import com.github.hydos.ginger.engine.opengl.render.GLRenderManager;
import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class GingerGL extends GingerEngine
@ -70,7 +70,7 @@ public class GingerGL extends GingerEngine
public void setGlobalFont(FontType font)
{ this.globalFont = font; }
public void setup(MasterRenderer masterRenderer, Game game)
public void setup(GLRenderManager masterRenderer, Game game)
{
INSTANCE = this;
registry = new GingerRegister();

View File

@ -17,7 +17,7 @@ import com.github.hydos.ginger.engine.opengl.render.renderers.*;
import com.github.hydos.ginger.engine.opengl.render.shaders.*;
import com.github.hydos.ginger.engine.opengl.shadow.ShadowMapMasterRenderer;
public class MasterRenderer
public class GLRenderManager
{
public static final float FOV = 80f;
public static final float NEAR_PLANE = 0.1f;
@ -34,25 +34,25 @@ public class MasterRenderer
public BlockRenderer blockRenderer;
private StaticShader entityShader;
public ObjectRenderer entityRenderer;
public GLObjectRenderer entityRenderer;
private GuiShader guiShader;
private GuiRenderer guiRenderer;
private GLGuiRenderer guiRenderer;
// private SkyboxRenderer skyboxRenderer;
private NormalMappingRenderer normalRenderer;
private GLNormalMappingRenderer normalRenderer;
private Matrix4f projectionMatrix;
private ShadowMapMasterRenderer shadowMapRenderer;
private Map<GLTexturedModel, List<RenderObject>> entities = new HashMap<GLTexturedModel, List<RenderObject>>();
private Map<GLTexturedModel, List<RenderObject>> normalMapEntities = new HashMap<GLTexturedModel, List<RenderObject>>();
public MasterRenderer(Camera camera)
public GLRenderManager(Camera camera)
{
createProjectionMatrix();
entityShader = new StaticShader();
blockRenderer = new BlockRenderer(entityShader, projectionMatrix);
entityRenderer = new ObjectRenderer(entityShader, projectionMatrix);
entityRenderer = new GLObjectRenderer(entityShader, projectionMatrix);
guiShader = new GuiShader();
guiRenderer = new GuiRenderer(guiShader);
normalRenderer = new NormalMappingRenderer(projectionMatrix);
guiRenderer = new GLGuiRenderer(guiShader);
normalRenderer = new GLNormalMappingRenderer(projectionMatrix);
shadowMapRenderer = new ShadowMapMasterRenderer(camera);
}

View File

@ -8,11 +8,11 @@ import com.github.hydos.ginger.engine.common.font.*;
import com.github.hydos.ginger.engine.opengl.render.Renderer;
import com.github.hydos.ginger.engine.opengl.render.shaders.FontShader;
public class FontRenderer extends Renderer
public class GLFontRenderer extends Renderer
{
private FontShader shader;
public FontRenderer()
public GLFontRenderer()
{ shader = new FontShader(); }
public void cleanUp()

View File

@ -12,12 +12,12 @@ import com.github.hydos.ginger.engine.opengl.render.models.RawModel;
import com.github.hydos.ginger.engine.opengl.render.shaders.GuiShader;
import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class GuiRenderer extends Renderer
public class GLGuiRenderer extends Renderer
{
private final RawModel quad;
private GuiShader shader;
public GuiRenderer(GuiShader shader)
public GLGuiRenderer(GuiShader shader)
{
this.shader = shader;
float[] positions =

View File

@ -14,11 +14,11 @@ import com.github.hydos.ginger.engine.opengl.render.models.*;
import com.github.hydos.ginger.engine.opengl.render.shaders.NormalMappingShader;
import com.github.hydos.ginger.engine.opengl.render.texture.ModelTexture;
public class NormalMappingRenderer extends Renderer
public class GLNormalMappingRenderer extends Renderer
{
private NormalMappingShader shader;
public NormalMappingRenderer(Matrix4f projectionMatrix)
public GLNormalMappingRenderer(Matrix4f projectionMatrix)
{
this.shader = new NormalMappingShader();
shader.start();
@ -58,7 +58,7 @@ public class NormalMappingRenderer extends Renderer
GL20.glEnableVertexAttribArray(3);
ModelTexture texture = model.getTexture();
if (texture.isTransparent())
{ MasterRenderer.disableCulling(); }
{ GLRenderManager.disableCulling(); }
shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureID());
@ -87,7 +87,7 @@ public class NormalMappingRenderer extends Renderer
private void unbindTexturedModel()
{
MasterRenderer.enableCulling();
GLRenderManager.enableCulling();
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL20.glDisableVertexAttribArray(2);

View File

@ -15,11 +15,11 @@ import com.github.hydos.ginger.engine.opengl.render.models.*;
import com.github.hydos.ginger.engine.opengl.render.shaders.StaticShader;
import com.github.hydos.ginger.engine.opengl.render.texture.ModelTexture;
public class ObjectRenderer extends Renderer
public class GLObjectRenderer extends Renderer
{
private StaticShader shader;
public ObjectRenderer(StaticShader shader, Matrix4f projectionMatrix)
public GLObjectRenderer(StaticShader shader, Matrix4f projectionMatrix)
{
this.shader = shader;
shader.start();
@ -46,11 +46,11 @@ public class ObjectRenderer extends Renderer
ModelTexture texture = model.getTexture();
if (texture.isTransparent())
{
MasterRenderer.disableCulling();
GLRenderManager.disableCulling();
}
else
{
MasterRenderer.enableCulling();
GLRenderManager.enableCulling();
}
shader.loadFakeLightingVariable(texture.isUseFakeLighting());
shader.loadShine(texture.getShineDamper(), texture.getReflectivity());

View File

@ -9,7 +9,7 @@ import com.github.hydos.ginger.engine.opengl.render.models.RawModel;
import com.github.hydos.ginger.engine.opengl.render.shaders.SkyboxShader;
import com.github.hydos.ginger.engine.opengl.utils.GLLoader;
public class SkyboxRenderer extends Renderer
public class GLSkyboxRenderer extends Renderer
{
//TODO: use these vertices for cubes
private static final float SIZE = 50f;
@ -60,7 +60,7 @@ public class SkyboxRenderer extends Renderer
private int texture;
private SkyboxShader shader;
public SkyboxRenderer(Matrix4f projectionMatrix)
public GLSkyboxRenderer(Matrix4f projectionMatrix)
{
cube = GLLoader.loadToVAO(VERTICES, 3);
texture = GLLoader.loadCubeMap(TEXTURE_FILES);

View File

@ -6,7 +6,7 @@ import org.joml.*;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.opengl.render.MasterRenderer;
import com.github.hydos.ginger.engine.opengl.render.GLRenderManager;
/** Represents the 3D cuboidal area of the world in which objects will cast
* shadows (basically represents the orthographic projection area for the shadow
@ -120,9 +120,9 @@ public class ShadowBox
* but means that distant objects wouldn't cast shadows. */
private void calculateWidthsAndHeights()
{
farWidth = (float) (SHADOW_DISTANCE * Math.tan(Math.toRadians(MasterRenderer.FOV)));
nearWidth = (float) (MasterRenderer.NEAR_PLANE
* Math.tan(Math.toRadians(MasterRenderer.FOV)));
farWidth = (float) (SHADOW_DISTANCE * Math.tan(Math.toRadians(GLRenderManager.FOV)));
nearWidth = (float) (GLRenderManager.NEAR_PLANE
* Math.tan(Math.toRadians(GLRenderManager.FOV)));
farHeight = farWidth / getAspectRatio();
nearHeight = nearWidth / getAspectRatio();
}
@ -171,7 +171,7 @@ public class ShadowBox
Vector3f toFar = new Vector3f(forwardVector);
toFar.mul(SHADOW_DISTANCE);
Vector3f toNear = new Vector3f(forwardVector);
toNear.mul(MasterRenderer.NEAR_PLANE);
toNear.mul(GLRenderManager.NEAR_PLANE);
Vector3f centerNear = toNear.add(cam.getPosition());
Vector3f centerFar = toFar.add(cam.getPosition());
Vector4f[] points = calculateFrustumVertices(rotation, forwardVector, centerNear,

View File

@ -7,7 +7,7 @@ import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.common.math.Maths;
import com.github.hydos.ginger.engine.opengl.render.MasterRenderer;
import com.github.hydos.ginger.engine.opengl.render.GLRenderManager;
import com.github.hydos.ginger.engine.opengl.render.models.*;
public class ShadowMapEntityRenderer
@ -69,7 +69,7 @@ public class ShadowMapEntityRenderer
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureID());
if (model.getTexture().isTransparent())
{ MasterRenderer.disableCulling(); }
{ GLRenderManager.disableCulling(); }
for (RenderObject entity : entities.get(model))
{
prepareInstance(entity);
@ -77,7 +77,7 @@ public class ShadowMapEntityRenderer
GL11.GL_UNSIGNED_INT, 0);
}
if (model.getTexture().isTransparent())
{ MasterRenderer.enableCulling(); }
{ GLRenderManager.enableCulling(); }
}
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);

View File

@ -3,7 +3,7 @@ package com.github.hydos.ginger.engine.opengl.utils;
import com.github.hydos.ginger.engine.common.font.TextMaster;
import com.github.hydos.ginger.engine.common.obj.ModelLoader;
import com.github.hydos.ginger.engine.common.obj.normals.NormalMappedObjLoader;
import com.github.hydos.ginger.engine.opengl.render.MasterRenderer;
import com.github.hydos.ginger.engine.opengl.render.GLRenderManager;
import com.github.hydos.ginger.engine.opengl.render.models.*;
import com.github.hydos.ginger.engine.opengl.render.texture.ModelTexture;
@ -25,7 +25,7 @@ public class GLUtils
public static void init()
{ TextMaster.init(); }
public static void preRenderScene(MasterRenderer renderer)
public static void preRenderScene(GLRenderManager renderer)
{}
public static void update()

View File

@ -1,43 +1,30 @@
package com.github.hydos.ginger.engine.vulkan.misc;
import org.joml.Vector2f;
import org.joml.Vector2fc;
import org.joml.Vector3f;
import org.joml.Vector3fc;
import org.lwjgl.PointerBuffer;
import org.lwjgl.assimp.*;
import java.io.File;
import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import static java.util.Objects.requireNonNull;
import static org.lwjgl.assimp.Assimp.*;
import java.io.File;
import java.nio.IntBuffer;
import java.util.*;
import org.joml.*;
import org.lwjgl.PointerBuffer;
import org.lwjgl.assimp.*;
public class VKModelLoader {
public static VKMesh loadModel(File file, int flags) {
try(AIScene scene = aiImportFile(file.getAbsolutePath(), flags)) {
Logger logger = Logger.getLogger(VKModelLoader.class.getSimpleName());
logger.info("Loading model " + file.getPath() + "...");
if(scene == null || scene.mRootNode() == null) {
throw new RuntimeException("Could not load model: " + aiGetErrorString());
}
VKMesh model = new VKMesh();
long startTime = System.nanoTime();
processNode(scene.mRootNode(), scene, model);
logger.info("Model loaded in " + ((System.nanoTime() - startTime) / 1e6) + "ms");
return model;
}
}

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.vulkan.pipelines;
package com.github.hydos.ginger.engine.vulkan.render.pipelines;
import static org.lwjgl.system.MemoryStack.stackPush;
import static org.lwjgl.vulkan.VK10.*;

View File

@ -0,0 +1,9 @@
package com.github.hydos.ginger.engine.vulkan.render.renderers;
/**
* used to manage all the renderers and shaders to go with them
* @author hydos
*
*/
public class VKRenderManager
{
}

View File

@ -15,7 +15,7 @@ import org.lwjgl.vulkan.*;
import com.github.hydos.ginger.VulkanExample.VulkanDemoGinger2;
import com.github.hydos.ginger.VulkanExample.VulkanDemoGinger2.*;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.vulkan.pipelines.VKPipelineManager;
import com.github.hydos.ginger.engine.vulkan.render.pipelines.VKPipelineManager;
public class VKSwapchainManager
{