[DEV] update new EGAMI

This commit is contained in:
Edouard DUPIN 2021-05-03 16:58:34 +02:00
parent a4127835a4
commit c19cafa55e
5 changed files with 36 additions and 35 deletions

View File

@ -431,11 +431,11 @@ public class OpenGL {
}
public static void drawElements(final RenderMode mode, final int vertexCount) {
GL11.glDrawElements(CONVERT_RENDER_MODE.get(mode), vertexCount, GL11.GL_UNSIGNED_INT, 0);
}
public static void drawTriangleRed(final Vector3f aaa, final Vector3f bbb, final Vector3f ccc) {
GL11.glFinish();
if (programId >= 0) {
updateAllFlags();
GL11.glDrawElements(CONVERT_RENDER_MODE.get(mode), vertexCount, GL11.GL_UNSIGNED_INT, 0);
checkGlError("glDrawElements");
}
}
/**

View File

@ -373,7 +373,7 @@ public abstract class GaleContext {
OpenGL.setViewPort(new Vector2f(0, 0), this.application.getSize());
final Color bgColor = new Color(0.8f, 0.5f, 0.8f, 1.0f);
OpenGL.clearColor(bgColor);
Log.info("==> appl clear ==> not created ...");
//Log.info("==> appl clear ==> not created ...");
}
unLockContext();
hasDisplayDone = true;

View File

@ -35,7 +35,7 @@ public abstract class Resource {
}
protected Resource(final Uri uri) {
this.name = uri.getValue();
this.name = uri.toString();
getManager().localAdd(this);
}

View File

@ -2,7 +2,7 @@ package org.atriasoft.gale.resource;
import java.nio.ByteBuffer;
import org.atriasoft.egami.Image;
import org.atriasoft.egami.ImageByteRGBA;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.gale.backend3d.OpenGL;
@ -48,26 +48,26 @@ public class ResourceTexture extends Resource {
}
resource = new ResourceTexture(uriTexture, textureUnit);
final ImageRawData decodedData = ImageLoader.decodePngFile(uriTexture);
Image img = new Image(decodedData.getWidth(), decodedData.getHeight());
ImageByteRGBA img = new ImageByteRGBA(decodedData.getWidth(), decodedData.getHeight());
ByteBuffer mlklmklm = decodedData.getBuffer();
byte[] elemData = new byte[mlklmklm.remaining()];
mlklmklm.get(elemData);
if (decodedData.isHasAlpha()) {
for (int yyy = 0; yyy < decodedData.getHeight(); yyy++) {
for (int xxx = 0; xxx < decodedData.getWidth(); xxx++) {
img.setR(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 4 + 0]);
img.setG(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 4 + 1]);
img.setB(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 4 + 2]);
img.setA(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 4 + 3]);
img.setRByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 4 + 0]);
img.setGByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 4 + 1]);
img.setBByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 4 + 2]);
img.setAByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 4 + 3]);
}
}
} else {
for (int yyy = 0; yyy < decodedData.getHeight(); yyy++) {
for (int xxx = 0; xxx < decodedData.getWidth(); xxx++) {
img.setA(xxx, yyy, 0xFF);
img.setR(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 3 + 0]);
img.setG(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 3 + 1]);
img.setB(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 3 + 2]);
img.setAFloat(xxx, yyy, 0xFF);
img.setRByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 3 + 0]);
img.setGByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 3 + 1]);
img.setBByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 3 + 2]);
}
}
}
@ -101,7 +101,7 @@ public class ResourceTexture extends Resource {
// Image properties:
// pointer on the image data.
//private ByteBuffer data = null;
protected Image data = new Image(32, 32);
protected ImageByteRGBA data = new ImageByteRGBA(32, 32);
// size of the image data.
private Vector2i size = new Vector2i(-1, -1);
//!< Color space of the image.
@ -171,7 +171,7 @@ public class ResourceTexture extends Resource {
this.texId = -1;
}
public void setTexture(final Image data, final Vector2i size, final TextureColorMode dataColorSpace, final int textureUnit) {
public void setTexture(final ImageByteRGBA data, final Vector2i size, final TextureColorMode dataColorSpace, final int textureUnit) {
this.data = data;
this.size = size;
this.textureUnit = textureUnit;

View File

@ -80,7 +80,7 @@ public class ResourceVirtualArrayObject extends Resource {
return buffer;
}
private final boolean dynamic = false;
private boolean dynamic = false;
private int vaoID = -1;
private boolean exist = false; //!< This data is availlable in the Graphic card
@ -101,6 +101,7 @@ public class ResourceVirtualArrayObject extends Resource {
protected ResourceVirtualArrayObject() {
super();
this.resourceLevel = 3;
this.dynamic = true;
Log.debug("OGL: load VBO count (dynamic)");
}
@ -170,7 +171,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
private void createVAO() {
Log.error("create VAO...");
Log.verbose("create VAO...");
this.vaoID = GL30.glGenVertexArrays();
GL30.glBindVertexArray(this.vaoID);
}
@ -199,23 +200,23 @@ public class ResourceVirtualArrayObject extends Resource {
public void loadAgainToVAO() {
createVAO();
if (this.indices != null) {
Log.error("Set indices");
Log.verbose("Set indices");
bindIndicesBuffer(this.indices);
}
if (this.positions != null) {
Log.error("Set positions");
Log.verbose("Set positions");
storeDataInAttributeList(0, 3, this.positions);
}
if (this.textureCoordinates != null) {
Log.error("Set textureCoordinates");
Log.verbose("Set textureCoordinates");
storeDataInAttributeList(1, 2, this.textureCoordinates);
}
if (this.normals != null) {
Log.error("Set normals");
Log.verbose("Set normals");
storeDataInAttributeList(2, 3, this.normals);
}
if (this.colors != null) {
Log.error("Set colors");
Log.verbose("Set colors");
storeDataInAttributeList(3, 4, this.colors);
}
unbindVAO();
@ -224,23 +225,23 @@ public class ResourceVirtualArrayObject extends Resource {
public void loadToVAO() {
GL30.glBindVertexArray(this.vaoID);
if (this.indices != null) {
Log.error("Set indices");
Log.verbose("Set indices");
bindIndicesBuffer(this.indices);
}
if (this.positions != null) {
Log.error("Set positions");
Log.verbose("Set positions");
storeDataInAttributeList(0, 3, this.positions);
}
if (this.textureCoordinates != null) {
Log.error("Set textureCoordinates");
Log.verbose("Set textureCoordinates");
storeDataInAttributeList(1, 2, this.textureCoordinates);
}
if (this.normals != null) {
Log.error("Set normals");
Log.verbose("Set normals");
storeDataInAttributeList(2, 3, this.normals);
}
if (this.colors != null) {
Log.error("Set colors");
Log.verbose("Set colors");
storeDataInAttributeList(3, 4, this.colors);
}
unbindVAO();
@ -379,7 +380,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
private void unbindVAO() {
Log.error("Unbind VAO ...");
Log.verbose("Unbind VAO ...");
GL30.glBindVertexArray(0);
}
@ -388,7 +389,7 @@ public class ResourceVirtualArrayObject extends Resource {
*/
@Override
public boolean updateContext() {
Log.error(" Start: [" + getId() + "] '" + getName() + "' (size=" + this.vertexCount + ") ********************************");
Log.verbose(" Start: [" + getId() + "] '" + getName() + "' (size=" + this.vertexCount + ") ********************************");
if (!this.exist) {
Log.error(" ==> ALLOCATE new handle");
// Allocate and assign a Vertex Array Object to our handle
@ -396,13 +397,13 @@ public class ResourceVirtualArrayObject extends Resource {
} else {
// Update VAO (only for dynamic:
if (!this.dynamic) {
Log.error(" Request update a VAO with a static buffer !!!");
Log.error(" Request update a VAO with a static buffer !!!" + this.name);
}
loadAgainToVAO();
}
this.exist = true;
Log.error(" Stop: [" + getId() + "] '" + getName() + "'");
Log.verbose(" Stop: [" + getId() + "] '" + getName() + "'");
return true;
}