Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
integeruser committed Nov 3, 2016
2 parents 391404e + b661cde commit 038123d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 40 deletions.
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
39 changes: 28 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>integeruser.jgltut</groupId>
<artifactId>jgltut</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>

<name>jgltut</name>
<description>Learning Modern 3D Graphics Programming with LWJGL 3 and JOML</description>
<url>https://github.com/integeruser/jgltut</url>

<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>

<properties>
<lwjgl.version>3.1.1-SNAPSHOT</lwjgl.version>
<joml.version>1.9.1-SNAPSHOT</joml.version>
<lwjgl.version>3.1.0</lwjgl.version>
<joml.version>1.9.0</joml.version>
</properties>

<profiles>
<profile>
<id>windows</id>
Expand Down Expand Up @@ -43,6 +57,7 @@
</properties>
</profile>
</profiles>

<build>
<sourceDirectory>src</sourceDirectory>
<resources>
Expand All @@ -65,6 +80,7 @@
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>oss.sonatype.org</id>
Expand All @@ -74,6 +90,7 @@
</snapshots>
</repository>
</repositories>

<dependencies>
<!-- LWJGL modules -->
<dependency>
Expand All @@ -97,14 +114,7 @@
<version>${lwjgl.version}</version>
</dependency>

<!-- JOML -->
<dependency>
<groupId>org.joml</groupId>
<artifactId>joml</artifactId>
<version>${joml.version}</version>
</dependency>

<!-- LWJGL 3 natives -->
<!-- LWJGL natives -->
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
Expand All @@ -123,5 +133,12 @@
<version>${lwjgl.version}</version>
<classifier>natives-${platform}</classifier>
</dependency>

<!-- JOML -->
<dependency>
<groupId>org.joml</groupId>
<artifactId>joml</artifactId>
<version>${joml.version}</version>
</dependency>
</dependencies>
</project>
27 changes: 14 additions & 13 deletions src/integeruser/jglsdk/glimg/StbLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
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;


/**
* Visit https://github.com/integeruser/jgltut for info and updates.
* 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;
Expand Down Expand Up @@ -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]);
}
}

0 comments on commit 038123d

Please sign in to comment.