diff --git a/CHANGELOG.md b/CHANGELOG.md index e4d6c52..81e2f4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] + + +## [2.1.0] - 2016-11-03 ### Added - Links to original source files (6740859d4a97a5b5cfae5c3b44eb0edf20d1809d) -- `CHANGELOG.md` (303a987d2f63a5abb5c272b1cbabf712fafcb9f8) +- `CHANGELOG.md` +- Maven `pom.xml` and common `.gitignore` (thanks to @httpdigest) ### Changed -- Switched to MIT license (57f20622f1be542544714066bac816fc98459b34) -- Tested on LWJGL 3.1.0 build 40 and JOML 1.9.0 +- Switched to MIT license +- Replaced usages of ImageIO with STBImage (c3723ffb238476cc7702527ce4fc26904f723a5c) ### Fixed - Updated link to LM3DGP in `README.md` (e67ddda9f06dbb3bc9c62cec44b83490e40f63cb) @@ -42,5 +46,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `MatrixStack.java` and almost all the math classes, replaced by their JOML counterparts -[Unreleased]: https://github.com/integeruser/jgltut/compare/v2.0.0...HEAD +[Unreleased]: https://github.com/integeruser/jgltut/compare/v2.1.0...HEAD +[2.1.0]: https://github.com/integeruser/jgltut/compare/v2.0.0...v2.1.0 [2.0.0]: https://github.com/integeruser/jgltut/compare/v1.0.2...v2.0.0 diff --git a/README.md b/README.md index 337c6c1..6b585f3 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,6 @@ jgltut/ jglsdk/ |-- glimg/ -|-- glm/ |-- glutil/ ``` Each tutorial loads the files it needs from the global `integeruser.jgltut.data` folder or from its own `data` folder. The `integeruser.jgltut.framework` package contains utility code needed by multiple tutorials. @@ -64,18 +63,17 @@ At first, the code may appear difficult to read, but after a bit of reading you ## Credits The LWJGL license can be found [here](http://lwjgl.org/license.php). +The JOML license can be found [here](https://github.com/JOML-CI/JOML/blob/master/LICENSE). Licenses of the projects `gltut` and `glsdk` can be found [here](https://bitbucket.org/alfonse/gltut/raw/3ee6f3dd04a7/License.txt) and [here](https://bitbucket.org/alfonse/unofficial-opengl-sdk/raw/1893b6e851b9/License.txt). Extract from the `gltut` license: -``` -The following files are copywritten and distributed under the Creative Commons Attribution 3.0 Unported (CC BY 3.0) license, as described in the "./CC BY 3.0 legalcode.txt" file. Attribution for these works is presented here: - -Attributed to Etory, of OpenGameArt.org: -* data/seamless_rock1_small.dds - -Attributed to p0ss, of OpenGameArt.org: -* data/concrete649_small.dds -* data/dsc_1621_small.dds -* data/rough645_small.dds -``` +> The following files are copywritten and distributed under the Creative Commons Attribution 3.0 Unported (CC BY 3.0) license, as described in the "./CC BY 3.0 legalcode.txt" file. Attribution for these works is presented here: +> +> Attributed to Etory, of OpenGameArt.org: +> * data/seamless_rock1_small.dds +> +> Attributed to p0ss, of OpenGameArt.org: +> * data/concrete649_small.dds +> * data/dsc_1621_small.dds +> * data/rough645_small.dds diff --git a/pom.xml b/pom.xml index 75c68c7..ef6d291 100644 --- a/pom.xml +++ b/pom.xml @@ -1,13 +1,27 @@ 4.0.0 + integeruser.jgltut jgltut - 1.0.0-SNAPSHOT + 2.1.0-SNAPSHOT + + jgltut + Learning Modern 3D Graphics Programming with LWJGL 3 and JOML + https://github.com/integeruser/jgltut + + + + MIT License + http://www.opensource.org/licenses/mit-license.php + + + - 3.1.1-SNAPSHOT - 1.9.1-SNAPSHOT + 3.1.0 + 1.9.0 + windows @@ -43,6 +57,7 @@ + src @@ -65,6 +80,7 @@ + oss.sonatype.org @@ -74,6 +90,7 @@ + @@ -97,14 +114,7 @@ ${lwjgl.version} - - - org.joml - joml - ${joml.version} - - - + org.lwjgl lwjgl @@ -123,5 +133,12 @@ ${lwjgl.version} natives-${platform} + + + + org.joml + joml + ${joml.version} + diff --git a/src/integeruser/jglsdk/glimg/StbLoader.java b/src/integeruser/jglsdk/glimg/StbLoader.java index edac294..84b7a71 100644 --- a/src/integeruser/jglsdk/glimg/StbLoader.java +++ b/src/integeruser/jglsdk/glimg/StbLoader.java @@ -3,10 +3,12 @@ import integeruser.jglsdk.glimg.ImageFormat.*; import integeruser.jglsdk.glimg.ImageSet.Dimensions; -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; import java.io.IOException; -import java.io.InputStream; +import java.net.URISyntaxException; +import java.nio.ByteBuffer; +import java.nio.file.Paths; + +import static org.lwjgl.stb.STBImage.stbi_load; /** @@ -14,7 +16,7 @@ * Original: https://bitbucket.org/alfonse/unofficial-opengl-sdk/src/default/glimg/source/StbLoader.cpp */ public class StbLoader { - private static ImageSet buildImageSetFromIntegerData(BufferedImage bufferedImage, int width, int height, int numComponents) { + private static ImageSet buildImageSetFromIntegerData(ByteBuffer image, int width, int height, int numComponents) { Dimensions imageDimensions = new Dimensions(); imageDimensions.numDimensions = 2; imageDimensions.depth = 0; @@ -47,21 +49,20 @@ private static ImageSet buildImageSetFromIntegerData(BufferedImage bufferedImage uncheckedImageFormat.lineAlignment = 1; byte[] imageData = new byte[width * height * numComponents]; - bufferedImage.getRaster().getDataElements(0, 0, width, height, imageData); + image.get(imageData); ImageCreator imgCreator = new ImageCreator(new ImageFormat(uncheckedImageFormat), imageDimensions, 1, 1, 1); imgCreator.setImageData(imageData, true, 0, 0, 0); return imgCreator.createImage(); } - public static ImageSet loadFromFile(String imagePath) throws IOException { - InputStream imageInputStream = ClassLoader.class.getResourceAsStream(imagePath); - BufferedImage bufferedImage = ImageIO.read(imageInputStream); - - int width = bufferedImage.getWidth(); - int height = bufferedImage.getHeight(); - int numComponents = bufferedImage.getColorModel().getNumComponents(); + public static ImageSet loadFromFile(String imagePath) throws IOException, URISyntaxException { + String path = Paths.get(ClassLoader.class.getResource(imagePath).toURI()).toString(); + int[] x = new int[1]; + int[] y = new int[1]; + int[] comp = new int[1]; + ByteBuffer image = stbi_load(path, x, y, comp, 0); - return buildImageSetFromIntegerData(bufferedImage, width, height, numComponents); + return buildImageSetFromIntegerData(image, x[0], y[0], comp[0]); } }