refactor(render):重构渲染系统架构
- 将 BufferBuilder 移至 systems.buffer 包并增强功能- 添加 BuiltBuffer 和 RenderState 内部类支持状态管理- 新增 BufferUploader 类处理缓冲区上传和状态应用 - 引入 RenderSystem 统一封装 OpenGL 调用 - Mesh2D 和 ModelRender 更新使用新的渲染系统接口- ModelGLPanel 适配新包结构并使用 RenderSystem 初始化 - 移除旧版 LightSource 构造函数- 整体提升渲染代码的模块化和可维护性 重要更新 - 重写渲染器 - 移除辉光,采用旧版着色器渲染,任何有关辉光的将在下一个版本彻底删除
This commit is contained in:
@@ -6,6 +6,7 @@ import com.chuangzhou.vivid2D.render.model.ModelPart;
|
||||
import com.chuangzhou.vivid2D.render.model.util.LightSource;
|
||||
import com.chuangzhou.vivid2D.render.model.util.Mesh2D;
|
||||
import com.chuangzhou.vivid2D.render.model.util.Texture;
|
||||
import com.chuangzhou.vivid2D.render.systems.RenderSystem;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -136,15 +137,15 @@ public class ModelRenderLightingTest {
|
||||
body.addChild(rightLeg);
|
||||
|
||||
LightSource ambientLight = new LightSource(
|
||||
Color.GRAY,
|
||||
Color.lightGray,
|
||||
0.3f
|
||||
);
|
||||
ambientLight.setAmbient(true);
|
||||
model.addLight(ambientLight);
|
||||
|
||||
// 添加光源
|
||||
model.addLight(new LightSource(new Vector2f(-100, -100), Color.ORANGE, 100f));
|
||||
//model.addLight(new LightSource(new Vector2f(150, 150), new Color(1f, 1f, 1f), 200f));
|
||||
model.addLight(new LightSource(new Vector2f(-100, -100), Color.lightGray, 200f));
|
||||
model.addLight(new LightSource(new Vector2f(150, 150), new Color(1f, 1f, 1f), 200f));
|
||||
}
|
||||
|
||||
private Texture createSolidTexture(int w, int h, int rgba) {
|
||||
@@ -221,7 +222,7 @@ public class ModelRenderLightingTest {
|
||||
}
|
||||
|
||||
private void render() {
|
||||
ModelRender.setClearColor(0.18f,0.18f,0.25f,1.0f);
|
||||
RenderSystem.setClearColor(0.18f,0.18f,0.25f,1.0f);
|
||||
ModelRender.render(1f/60f, model);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.chuangzhou.vivid2D.render.model.ModelPart;
|
||||
import com.chuangzhou.vivid2D.render.model.util.Mesh2D;
|
||||
import com.chuangzhou.vivid2D.render.model.util.PhysicsSystem;
|
||||
import com.chuangzhou.vivid2D.render.model.util.Texture;
|
||||
import com.chuangzhou.vivid2D.render.systems.RenderSystem;
|
||||
import org.joml.Vector2f;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||
@@ -261,7 +262,7 @@ public class ModelRenderTest {
|
||||
}
|
||||
|
||||
private void render() {
|
||||
ModelRender.setClearColor(0.18f, 0.18f, 0.25f, 1.0f);
|
||||
RenderSystem.setClearColor(0.18f, 0.18f, 0.25f, 1.0f);
|
||||
ModelRender.render(1.0f / 60.0f, testModel);
|
||||
|
||||
// 每 5 秒输出一次统计
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.chuangzhou.vivid2D.render.model.Model2D;
|
||||
import com.chuangzhou.vivid2D.render.model.ModelPart;
|
||||
import com.chuangzhou.vivid2D.render.model.util.Mesh2D;
|
||||
import com.chuangzhou.vivid2D.render.model.util.Texture;
|
||||
import com.chuangzhou.vivid2D.render.systems.RenderSystem;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Vector2f;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -214,7 +215,7 @@ public class ModelRenderTest2 {
|
||||
}
|
||||
|
||||
private void render() {
|
||||
ModelRender.setClearColor(0.2f, 0.2f, 0.3f, 1.0f);
|
||||
RenderSystem.setClearColor(0.2f, 0.2f, 0.3f, 1.0f);
|
||||
ModelRender.render(1.0f / 60.0f, testModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.chuangzhou.vivid2D.render.model.ModelPart;
|
||||
import com.chuangzhou.vivid2D.render.model.util.Mesh2D;
|
||||
import com.chuangzhou.vivid2D.render.model.util.Texture;
|
||||
import com.chuangzhou.vivid2D.render.model.util.PhysicsSystem;
|
||||
import com.chuangzhou.vivid2D.render.systems.RenderSystem;
|
||||
import org.joml.Vector2f;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||
@@ -666,7 +667,7 @@ public class ModelTest2 {
|
||||
}
|
||||
|
||||
private void render(long last) {
|
||||
ModelRender.setClearColor(0.1f, 0.1f, 0.15f, 1.0f);
|
||||
RenderSystem.setClearColor(0.1f, 0.1f, 0.15f, 1.0f);
|
||||
ModelRender.render(last, physicsModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.chuangzhou.vivid2D.test;
|
||||
|
||||
import com.chuangzhou.vivid2D.render.ModelGLPanel;
|
||||
import com.chuangzhou.vivid2D.render.awt.ModelGLPanel;
|
||||
import com.chuangzhou.vivid2D.render.model.Model2D;
|
||||
import com.chuangzhou.vivid2D.render.model.ModelPart;
|
||||
import com.chuangzhou.vivid2D.render.model.util.Mesh2D;
|
||||
|
||||
Reference in New Issue
Block a user