Compare commits

...

3 Commits

Author SHA1 Message Date
Edouard DUPIN
a9ae5adc5c [FEAT] decrease a log level 2025-05-26 07:58:41 +02:00
Edouard DUPIN
fb8d53359e [FIX] arbo 2025-05-24 00:24:25 +02:00
Edouard DUPIN
3dd42d77ca [FIX] ??? 2025-05-18 19:10:04 +02:00
45 changed files with 98 additions and 144 deletions

43
pom.xml
View File

@ -1,17 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.atriasoft</groupId>
<artifactId>gale</artifactId>
<version>0.1.0</version>
<properties>
<maven.compiler.version>3.13.0</maven.compiler.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.dependency.version>3.1.1</maven.dependency.version>
<lwjgl.version>3.3.3</lwjgl.version>
<lwjgl3-awt.version>0.1.8</lwjgl3-awt.version>
<lwjgl.natives>natives-linux</lwjgl.natives>
<lwjgl.natives>natives-linux</lwjgl.natives>
</properties>
<licenses>
<license>
<name>Mozilla Public License 2.0</name>
<url>https://opensource.org/licenses/MPL-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>dev1</id>
<name>Edouard DUPIN</name>
<email>edouard.dupin@proton.me</email>
<roles>
<role>Lead Developer</role>
</roles>
</developer>
</developers>
<repositories>
<repository>
@ -251,7 +265,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.0-M2</version>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
@ -263,22 +277,21 @@
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<sourceDirectory>src/main</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src/resources</directory>
</resource>
</resources>
<testSourceDirectory>test/src</testSourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<version>3.14.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<!--<encoding>${project.build.sourceEncoding}</encoding>-->
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<!-- Create the source bundle -->
@ -299,7 +312,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.2.5</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
@ -318,7 +331,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
@ -332,7 +345,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
<configuration>
<show>public</show>
</configuration>

View File

@ -55,7 +55,14 @@ public class ResourceTexture extends Resource {
return null;
}
resource = new ResourceTexture(uriTexture, textureUnit);
final ImageRawData decodedData = ImageLoader.decodePngFile(uriTexture);
ImageRawData decodedData;
try {
decodedData = ImageLoader.decodePngFile(uriTexture);
} catch (final Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
final ImageByteRGBA img = new ImageByteRGBA(decodedData.getWidth(), decodedData.getHeight());
final ByteBuffer mlklmklm = decodedData.getBuffer();
final byte[] elemData = new byte[mlklmklm.remaining()];

View File

@ -243,7 +243,7 @@ public class ResourceTexture2 extends Resource {
if (this.loaded) {
if (this.lastTypeObject != typeObject || this.lastSizeObject != sizeObject
|| !this.lastSize.equals(this.data.getSize())) {
LOGGER.warn("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
LOGGER.trace("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
OpenGL.glDeleteTextures(this.texId);
this.loaded = false;
}

View File

@ -20,15 +20,13 @@ import org.lwjgl.opengl.GL30;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import models.RawModel;
public class ResourceVirtualArrayObject extends Resource {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceVirtualArrayObject.class);
public static final int INDICE_VBO_POSITIONS = 0;
public static final int INDICE_VBO_TEXTURE_COORDINATES = 1;
public static final int INDICE_VBO_NORMALS = 2;
public static final int INDICE_VBO_COLORS = 3;
public static int[] convertIntegers(final List<Integer> integers) {
final int[] ret = new int[integers.size()];
final Iterator<Integer> iterator = integers.iterator();
@ -37,7 +35,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
return ret;
}
public static ResourceVirtualArrayObject create(
final float[] positions,
final float[] colors,
@ -49,7 +47,7 @@ public class ResourceVirtualArrayObject extends Resource {
Resource.getManager().localAdd(resource);
return resource;
}
public static ResourceVirtualArrayObject create(
final float[] positions,
final float[] textureCoordinates,
@ -60,7 +58,7 @@ public class ResourceVirtualArrayObject extends Resource {
Resource.getManager().localAdd(resource);
return resource;
}
public static ResourceVirtualArrayObject create(
final float[] positions,
final float[] colors,
@ -70,58 +68,58 @@ public class ResourceVirtualArrayObject extends Resource {
Resource.getManager().localAdd(resource);
return resource;
}
public static ResourceVirtualArrayObject create(final float[] positions, final int dimentions) {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject(positions, null, null, null, null,
positions.length / dimentions);
Resource.getManager().localAdd(resource);
return resource;
}
public static ResourceVirtualArrayObject createDynamic() {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject();
Resource.getManager().localAdd(resource);
return resource;
}
public static FloatBuffer storeDataInFloatBuffer(final float[] data) {
final FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();
return buffer;
}
public static IntBuffer storeDataInIntBuffer(final int[] data) {
final IntBuffer buffer = BufferUtils.createIntBuffer(data.length);
buffer.put(data);
buffer.flip();
return buffer;
}
private boolean dynamic = false;
private int vaoID = -1;
private boolean exist = false; //!< This data is availlable in the Graphic card
private final List<Integer> vbo = new ArrayList<>();
Object positions = null;
Object colors = null;
Object textureCoordinates = null;
Object normals = null;
int[] indices = null;
int vertexCount = -1;
protected ResourceVirtualArrayObject() {
this.resourceLevel = 3;
this.dynamic = true;
LOGGER.debug("OGL: load VBO count (dynamic)");
}
protected ResourceVirtualArrayObject(final float[] positions, final float[] colors,
final float[] textureCoordinates, final float[] normals, final int[] indices, final int vertexCount) {
this.resourceLevel = 3;
@ -133,7 +131,7 @@ public class ResourceVirtualArrayObject extends Resource {
this.vertexCount = vertexCount;
LOGGER.debug("OGL: load VBO count");
}
public void bindForRendering() {
if (!this.exist) {
return;
@ -153,7 +151,7 @@ public class ResourceVirtualArrayObject extends Resource {
GL20.glEnableVertexAttribArray(ResourceVirtualArrayObject.INDICE_VBO_COLORS);
}
}
private void bindIndicesBuffer(final int[] indices) {
final int vboId = OpenGL.genBuffers();
this.vbo.add(vboId);
@ -165,7 +163,7 @@ public class ResourceVirtualArrayObject extends Resource {
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
}
}
/**
* Destructor of this VBO.
*/
@ -173,7 +171,7 @@ public class ResourceVirtualArrayObject extends Resource {
public void cleanUp() {
removeContext();
}
/**
* clear buffers
*/
@ -186,13 +184,13 @@ public class ResourceVirtualArrayObject extends Resource {
this.indices = null;
this.vertexCount = -1;
}
private void createVAO() {
LOGGER.trace("create VAO...");
this.vaoID = GL30.glGenVertexArrays();
GL30.glBindVertexArray(this.vaoID);
}
/**
* Send the data to the graphic card.
*/
@ -201,7 +199,7 @@ public class ResourceVirtualArrayObject extends Resource {
Resource.getManager().update(this);
LOGGER.trace("Request flush of VAO: [" + getId() + "] '" + getName() + "'");
}
/**
* get the real openGL ID.
* @return the Ogl id reference of this VBO.
@ -209,11 +207,11 @@ public class ResourceVirtualArrayObject extends Resource {
public int getGLID() {
return this.vaoID;
}
public int getVertexCount() {
return this.vertexCount;
}
public void loadAgainToVAO() {
GL30.glBindVertexArray(this.vaoID);
LOGGER.trace("push VAO: [" + getId() + "] '" + getName() + "'");
@ -240,7 +238,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
unbindVAO();
}
public void loadToVAO() {
createVAO();
LOGGER.trace("push VAO: [" + getId() + "] '" + getName() + "'");
@ -267,7 +265,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
unbindVAO();
}
/**
* Relode the shader from the file. used when a request of resouces reload is done.
* @note this is really usefull when we tested the new themes or shader developpements.
@ -277,7 +275,7 @@ public class ResourceVirtualArrayObject extends Resource {
removeContext();
updateContext();
}
/**
* remove the data from the opengl context.
*/
@ -288,7 +286,7 @@ public class ResourceVirtualArrayObject extends Resource {
this.exist = false;
}
}
/**
* Special android spec! It inform us that all context is removed and after notify us...
*/
@ -299,84 +297,84 @@ public class ResourceVirtualArrayObject extends Resource {
// this.vbo[iii] = 0;
// }
}
public void render(final RenderMode mode) {
LOGGER.trace("request rendering indices : " + this.vertexCount);
OpenGL.drawElements(mode, this.vertexCount);
}
public void render(final RenderMode mode, final int start, final int stop) {
OpenGL.drawArrays(mode, start, stop);
}
public void renderArrays(final RenderMode mode) {
LOGGER.trace("request rendering direct : " + this.vertexCount);
OpenGL.drawArrays(mode, 0, this.vertexCount);
}
public void setColors(final Color[] colors) {
this.colors = colors;
}
public void setColors(final float[] colors) {
this.colors = colors;
}
public void setColors(final List<Color> colors) {
setColors(colors.toArray(Color[]::new));
}
public void setIndices(final int[] indices) {
this.indices = indices;
}
public void setIndices(final List<Integer> indices) {
this.indices = ResourceVirtualArrayObject.convertIntegers(indices);
this.vertexCount = this.indices.length;
}
public void setNormals(final float[] normals) {
this.normals = normals;
}
public void setNormals(final List<Vector3f> normals) {
setNormals(normals.toArray(Vector3f[]::new));
}
public void setNormals(final Vector3f[] normals) {
this.normals = normals;
}
public void setPosition(final float[] positions) {
this.positions = positions;
}
public void setPosition(final List<Vector3f> outPosition) {
setPosition(outPosition.toArray(Vector3f[]::new));
}
public void setPosition(final Vector3f[] positions) {
this.positions = positions;
}
public void setTextureCoordinate(final float[] textureCoordinates) {
this.textureCoordinates = textureCoordinates;
}
public void setTextureCoordinate(final List<Vector2f> outTexturePosition) {
setTextureCoordinate(outTexturePosition.toArray(Vector2f[]::new));
}
public void setTextureCoordinate(final Vector2f[] textureCoordinates) {
this.textureCoordinates = textureCoordinates;
}
public void setVertexCount(final int vertexCount) {
this.vertexCount = vertexCount;
}
private void storeDataInAttributeList(final int attributeNumber, final int coordinateSize, final Object data) {
final int vboID = GL15.glGenBuffers();
this.vbo.add(vboID);
@ -402,7 +400,7 @@ public class ResourceVirtualArrayObject extends Resource {
GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
public void unBindForRendering() {
if (!this.exist) {
return;
@ -421,12 +419,12 @@ public class ResourceVirtualArrayObject extends Resource {
}
GL30.glBindVertexArray(0);
}
private void unbindVAO() {
LOGGER.trace("Unbind VAO ...");
GL30.glBindVertexArray(0);
}
/**
* This load/reload the data in the opengl context, needed when removed previously.
*/
@ -444,11 +442,11 @@ public class ResourceVirtualArrayObject extends Resource {
LOGGER.error(" Request update a VAO with a static buffer !!!" + this.name);
}
loadAgainToVAO();
}
this.exist = true;
LOGGER.trace(" Stop: [" + getId() + "] '" + getName() + "'");
return true;
}
}

View File

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -5,12 +5,11 @@ import java.io.InputStream;
import java.nio.ByteBuffer;
import org.atriasoft.etk.Uri;
import org.atriasoft.pngdecoder.PNGDecoder;
import org.atriasoft.pngdecoder.PNGDecoder.Format;
public class ImageLoader {
public static ImageRawData decodePngFile(final Uri filename) {
public static ImageRawData decodePngFile(final Uri filename) throws Exception {
ByteBuffer buf = null;
int tWidth = 0;
int tHeight = 0;
@ -18,6 +17,9 @@ public class ImageLoader {
try {
// Open the PNG file as an InputStream
final InputStream in = Uri.getStream(filename);
if (in == null) {
throw new Exception("fail to get th estream ...");
}
// Link the PNG decoder to this stream
final PNGDecoder decoder = new PNGDecoder(in);
// Get the width and height of the texture

View File

@ -1,36 +0,0 @@
/**
* Basic module interface.
*
* @author Edouard DUPIN
*/
open module org.atriasoft.gale {
exports org.atriasoft.gale;
exports org.atriasoft.gale.backend3d;
exports org.atriasoft.gale.context;
// exports org.atriasoft.gale.context.JOGL;
exports org.atriasoft.gale.context.LWJG_AWT;
exports org.atriasoft.gale.key;
exports org.atriasoft.gale.resource;
requires transitive org.atriasoft.etk;
requires transitive org.atriasoft.egami;
requires transitive org.lwjgl;
requires transitive org.lwjgl.natives;
requires transitive org.lwjgl.glfw;
requires transitive org.lwjgl.glfw.natives;
requires transitive org.lwjgl.assimp;
requires transitive org.lwjgl.assimp.natives;
requires transitive org.lwjgl.stb;
requires transitive org.lwjgl.stb.natives;
requires transitive org.lwjgl.jawt;
requires transitive org.lwjgl.opengl;
requires transitive org.lwjgl.opengl.natives;
requires transitive java.desktop;
requires transitive org.atriasoft.pngdecoder;
requires transitive lwjgl3.awt;
requires org.atriasoft.iogami;
requires org.slf4j;
}

View File

@ -1,30 +0,0 @@
package org.atriasoft.gale.test.sample1;
public class Log {
private Log() {}
private static final String LIBNAME = "Sample1";
public static void print(String data) {
System.out.println(data);
}
public static void critical(String data) {
System.out.println("[C] " + LIBNAME + " | " + data);
}
public static void error(String data) {
System.out.println("[E] " + LIBNAME + " | " + data);
}
public static void warning(String data) {
System.out.println("[W] " + LIBNAME + " | " + data);
}
public static void info(String data) {
System.out.println("[I] " + LIBNAME + " | " + data);
}
public static void debug(String data) {
System.out.println("[D] " + LIBNAME + " | " + data);
}
public static void verbose(String data) {
System.out.println("[V] " + LIBNAME + " | " + data);
}
public static void todo(String data) {
System.out.println("[TODO] " + LIBNAME + " | " + data);
}
}