Browse Source

* The OpenGL2 renderer now actually scales non-power-of-2 textures instead of throwing out a useless warning
* Nifty GUI now supports the rescaling of textures by storing the resolution beforehand

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7281 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

sha..rd 14 years ago
parent
commit
ed7789b7a6

+ 5 - 4
engine/src/lwjgl-ogl/com/jme3/renderer/lwjgl/LwjglRenderer.java

@@ -83,6 +83,7 @@ import java.util.logging.Logger;
 //import org.lwjgl.opengl.ARBHalfFloatVertex;
 //import org.lwjgl.opengl.ARBVertexArrayObject;
 //import jme3tools.converters.MipMapGenerator;
+import jme3tools.converters.MipMapGenerator;
 import org.lwjgl.opengl.ARBDrawBuffers;
 //import org.lwjgl.opengl.ARBDrawInstanced;
 import org.lwjgl.opengl.ARBDrawInstanced;
@@ -1620,16 +1621,16 @@ public class LwjglRenderer implements Renderer {
             }
         }
 
-        // Check sizes if graphics card doesn't support NPOT
+        // Yes, some OpenGL2 cards (GeForce 5) still dont support NPOT.
         if (!GLContext.getCapabilities().GL_ARB_texture_non_power_of_two){
             if (img.getWidth() != 0 && img.getHeight() != 0){
                 if (!FastMath.isPowerOfTwo(img.getWidth())
                     || !FastMath.isPowerOfTwo(img.getHeight())
                     || img.getWidth() != img.getHeight()){
-                    logger.log(Level.WARNING, "Encountered NPOT texture {0}, "
-                                            + "it might not display correctly.", img);
+//                    logger.log(Level.WARNING, "Encountered NPOT texture {0}, "
+//                                            + "it might not display correctly.", img);
 
-                    //MipMapGenerator.resizeToPowerOf2(img);
+                    MipMapGenerator.resizeToPowerOf2(img);
                 }
             }
         }

+ 2 - 2
engine/src/niftygui/com/jme3/niftygui/RenderDeviceJme.java

@@ -224,8 +224,8 @@ public class RenderDeviceJme implements RenderDevice {
         niftyMat.setBoolean("UseTex", true);
         setColor(color);
 
-        float imageWidth  = texture.getImage().getWidth();
-        float imageHeight = texture.getImage().getHeight();
+        float imageWidth  = jmeImage.getWidth();
+        float imageHeight = jmeImage.getHeight();
         FloatBuffer texCoords = (FloatBuffer) quadModTC.getData();
 
         float startX = srcX / imageWidth;

+ 2 - 2
engine/src/niftygui/com/jme3/niftygui/RenderImageJme.java

@@ -74,11 +74,11 @@ public class RenderImageJme implements RenderImage {
     }
 
     public int getWidth() {
-        return image.getWidth();
+        return width;
     }
 
     public int getHeight() {
-        return image.getHeight();
+        return height;
     }
 
     public void dispose() {

+ 1 - 1
engine/src/tools/jme3tools/converters/MipMapGenerator.java

@@ -52,7 +52,7 @@ public class MipMapGenerator {
         BufferedImage targetImage = new BufferedImage(targetWidth, targetHeight, sourceImage.getType());
 
         Graphics2D g = targetImage.createGraphics();
-        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
         g.drawImage(sourceImage, 0, 0, targetWidth, targetHeight, 0, 0, sourceWidth, sourceHeight, null);
         g.dispose();