|
| 1 | +/* |
| 2 | + * Copyright (c) 2024 jMonkeyEngine |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions are |
| 7 | + * met: |
| 8 | + * |
| 9 | + * * Redistributions of source code must retain the above copyright |
| 10 | + * notice, this list of conditions and the following disclaimer. |
| 11 | + * |
| 12 | + * * Redistributions in binary form must reproduce the above copyright |
| 13 | + * notice, this list of conditions and the following disclaimer in the |
| 14 | + * documentation and/or other materials provided with the distribution. |
| 15 | + * |
| 16 | + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors |
| 17 | + * may be used to endorse or promote products derived from this software |
| 18 | + * without specific prior written permission. |
| 19 | + * |
| 20 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 22 | + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 23 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 24 | + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 25 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 26 | + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 27 | + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 28 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 29 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 30 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | + */ |
| 32 | +package com.jme3.texture; |
| 33 | + |
| 34 | +import com.jme3.texture.image.ColorSpace; |
| 35 | +import com.jme3.util.BufferUtils; |
| 36 | +import java.nio.ByteBuffer; |
| 37 | +import java.util.ArrayList; |
| 38 | +import org.junit.Test; |
| 39 | + |
| 40 | +/** |
| 41 | + * Verify that setMultiSamples(1) can be applied to any Image. This was issue |
| 42 | + * #2250 at GitHub. |
| 43 | + * |
| 44 | + * @author Stephen Gold |
| 45 | + */ |
| 46 | +public class TestIssue2250 { |
| 47 | + |
| 48 | + /** |
| 49 | + * Test setMultiSamples() on an Image with a data buffer. |
| 50 | + */ |
| 51 | + @Test |
| 52 | + public void testIssue2250WithData() { |
| 53 | + int width = 8; |
| 54 | + int height = 8; |
| 55 | + int numBytes = 4 * width * height; |
| 56 | + ByteBuffer data = BufferUtils.createByteBuffer(numBytes); |
| 57 | + Image image1 = new Image( |
| 58 | + Image.Format.RGBA8, width, height, data, ColorSpace.Linear); |
| 59 | + |
| 60 | + image1.setMultiSamples(1); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Test setMultiSamples() on an Image with mip maps. |
| 65 | + */ |
| 66 | + @Test |
| 67 | + public void testIssue2250WithMips() { |
| 68 | + int width = 8; |
| 69 | + int height = 8; |
| 70 | + int depth = 1; |
| 71 | + int[] mipMapSizes = {256, 64, 16, 4}; |
| 72 | + |
| 73 | + ArrayList<ByteBuffer> data = new ArrayList<>(); |
| 74 | + Image image2 = new Image(Image.Format.RGBA8, width, height, depth, data, |
| 75 | + mipMapSizes, ColorSpace.Linear); |
| 76 | + |
| 77 | + image2.setMultiSamples(1); |
| 78 | + } |
| 79 | +} |
0 commit comments