feat(render): 实现独立的 OpenGL 上下文管理器
- 将 GL 上下文管理从 ModelRenderPanel 抽离到独立的 GLContextManager 类- 实现离屏渲染上下文的创建、初始化和资源管理 - 支持动态调整渲染缓冲区大小和缩放功能 - 提供线程安全的任务队列机制用于在 GL 线程执行操作 - 实现像素数据读取和转换为 BufferedImage 的完整流程- 添加摄像机拖拽状态和缩放控制的支持 -重构 ModelRenderPanel以使用新的 GLContextManager- 更新所有 GL 相关操作的调用方式指向新的上下文管理器 - 修改 dispose 流程以正确释放所有 OpenGL 资源 - 优化渲染循环和平滑缩放逻辑实现
This commit is contained in:
@@ -96,7 +96,7 @@ public class ModelLayerPanelTest {
|
||||
// 添加选中部件更新按钮
|
||||
JButton updateSelectionBtn = new JButton("更新选中部件");
|
||||
updateSelectionBtn.addActionListener(e -> {
|
||||
renderPanel.executeInGLContext(() -> {
|
||||
renderPanel.getGlContextManager().executeInGLContext(() -> {
|
||||
List<ModelPart> selectedPart = renderPanel.getSelectedParts();
|
||||
transformPanel.setSelectedParts(selectedPart);
|
||||
});
|
||||
@@ -134,7 +134,7 @@ public class ModelLayerPanelTest {
|
||||
public void windowClosed(java.awt.event.WindowEvent e) {
|
||||
// 进程退出(确保彻底关闭)
|
||||
try {
|
||||
renderPanel.dispose();
|
||||
renderPanel.getGlContextManager().dispose();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
model.saveToFile("C:\\Users\\Administrator\\Desktop\\testing.model");
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TestModelGLPanel {
|
||||
|
||||
// 在 GL 上下文中创建 mesh / part / physics 等资源
|
||||
ModelRenderPanel finalGlPanel = glPanel;
|
||||
glPanel.executeInGLContext(() -> {
|
||||
glPanel.getGlContextManager().executeInGLContext(() -> {
|
||||
setupModelInGL(testModel);
|
||||
return null;
|
||||
});
|
||||
@@ -53,7 +53,7 @@ public class TestModelGLPanel {
|
||||
if (!animate) return;
|
||||
float dt = 1.0f / fps;
|
||||
// 在 GL 上下文中更新模型状态(旋转、参数、物理更新等)
|
||||
finalGlPanel.executeInGLContext(() -> {
|
||||
finalGlPanel.getGlContextManager().executeInGLContext(() -> {
|
||||
updateAnimation(testModel, dt);
|
||||
return null;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user