From c67de8aca04d988179191ccb52461af00125920e Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Tue, 13 Aug 2019 11:41:53 -0400
Subject: [PATCH] RGB skybox

---
 CameraPane.java |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/CameraPane.java b/CameraPane.java
index df28651..778fb13 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -110,7 +110,9 @@
     //private Mat4f spotlightTransform = new Mat4f();
     //private Mat4f spotlightInverseTransform = new Mat4f();
     static GLContext glcontext = null;
-    /*static*/ com.sun.opengl.util.texture.Texture cubemap;
+    /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
+    /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
+    /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
     boolean reverseUP = false;
     static boolean frozen = false;
     boolean enablebackspace = false; // patch for back buffer refresh
@@ -188,15 +190,16 @@
     
     private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
 
-    public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
+    public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
     {
         try
         {
-            cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
+            return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
         } catch (IOException e)
         {
             System.out.println("NAME = " + name);
             e.printStackTrace(); // throw new RuntimeException(e);
+            return null;
         }
     }
     
@@ -9233,6 +9236,8 @@
 
     void LoadEnvy(int which)
     {
+        assert(false);
+        
         String name;
         String ext;
 
@@ -11077,18 +11082,32 @@
 //
 //        newenvy = -1;
         
-        if (object.skyboxname != null)
+        if (object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
         {
-            if (!object.skyboxname.equals(this.loadedskyboxname))
+            if (cubemaprgb == null)
             {
-                LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
-                loadedskyboxname = object.skyboxname;
+                cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
             }
+            
+            cubemap = cubemaprgb;
         }
         else
         {
-            cubemap = null;
-            loadedskyboxname = null;
+            if (object.skyboxname != null)
+            {
+                if (!object.skyboxname.equals(this.loadedskyboxname))
+                {
+                    cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
+                    loadedskyboxname = object.skyboxname;
+                }
+            }
+            else
+            {
+                cubemapcustom = null;
+                loadedskyboxname = null;
+            }
+            
+            cubemap = cubemapcustom;
         }
         
         ratio = ((double) getWidth()) / getHeight();

--
Gitblit v1.6.2