plop
This commit is contained in:
parent
a9ae5adc5c
commit
d05675d9b8
7
pom.xml
7
pom.xml
@ -268,10 +268,11 @@
|
|||||||
<version>5.11.0</version>
|
<version>5.11.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- generic logger of SLF4J to console (in color) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>slf4j-simple</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<version>2.1.0-alpha1</version>
|
<version>1.5.18</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -17,17 +17,17 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class ResourceTexture2 extends Resource {
|
public class ResourceTexture2 extends Resource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(ResourceTexture2.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(ResourceTexture2.class);
|
||||||
|
|
||||||
public enum TextureColorMode {
|
public enum TextureColorMode {
|
||||||
rgb, // !< red/green/blue data
|
rgb, // !< red/green/blue data
|
||||||
rgba // !< red/green/blue/alpha data
|
rgba // !< red/green/blue/alpha data
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceTexture2 create() {
|
public static ResourceTexture2 create() {
|
||||||
LOGGER.trace("KEEP: Resource Texture Dynamic: ");
|
LOGGER.trace("KEEP: Resource Texture Dynamic: ");
|
||||||
return new ResourceTexture2();
|
return new ResourceTexture2();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceTexture2 create(final Uri uri) {
|
public static ResourceTexture2 create(final Uri uri) {
|
||||||
LOGGER.trace("KEEP: Resource Texture: " + uri);
|
LOGGER.trace("KEEP: Resource Texture: " + uri);
|
||||||
final Resource object2 = Resource.getManager().localKeep(uri);
|
final Resource object2 = Resource.getManager().localKeep(uri);
|
||||||
@ -42,7 +42,7 @@ public class ResourceTexture2 extends Resource {
|
|||||||
LOGGER.trace("CREATE: new Texture: " + uri);
|
LOGGER.trace("CREATE: new Texture: " + uri);
|
||||||
return new ResourceTexture2(uri);
|
return new ResourceTexture2(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceTexture2 createNamed(final String uri) {
|
public static ResourceTexture2 createNamed(final String uri) {
|
||||||
LOGGER.trace("KEEP: Resource Texture Named: " + uri);
|
LOGGER.trace("KEEP: Resource Texture Named: " + uri);
|
||||||
final Resource object2 = Resource.getManager().localKeep(uri);
|
final Resource object2 = Resource.getManager().localKeep(uri);
|
||||||
@ -57,7 +57,7 @@ public class ResourceTexture2 extends Resource {
|
|||||||
LOGGER.debug("CREATE: new Texture Named: " + uri);
|
LOGGER.debug("CREATE: new Texture Named: " + uri);
|
||||||
return new ResourceTexture2(uri);
|
return new ResourceTexture2(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* public static ResourceTexture2 createFromPng(final Uri uriTexture) { return
|
* public static ResourceTexture2 createFromPng(final Uri uriTexture) { return
|
||||||
* createFromPng(uriTexture, 1); }
|
* createFromPng(uriTexture, 1); }
|
||||||
@ -80,7 +80,7 @@ public class ResourceTexture2 extends Resource {
|
|||||||
* (decodedData.isHasAlpha() == true ? TextureColorMode.rgba :
|
* (decodedData.isHasAlpha() == true ? TextureColorMode.rgba :
|
||||||
* TextureColorMode.rgb), textureUnit); resource.flush(); return resource; }
|
* TextureColorMode.rgb), textureUnit); resource.flush(); return resource; }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// openGl Context properties :
|
// openGl Context properties :
|
||||||
protected ImageByte data = new ImageByteRGBA(32, 32);
|
protected ImageByte data = new ImageByteRGBA(32, 32);
|
||||||
// !< Color space of the image.
|
// !< Color space of the image.
|
||||||
@ -96,18 +96,18 @@ public class ResourceTexture2 extends Resource {
|
|||||||
// ! some image are not square == > we need to sqared it to prevent some openGl
|
// ! some image are not square == > we need to sqared it to prevent some openGl
|
||||||
// api error the the displayable size is not all the time 0.0 . 1.0
|
// api error the the displayable size is not all the time 0.0 . 1.0
|
||||||
protected Vector2i realImageSize = new Vector2i(1, 1);
|
protected Vector2i realImageSize = new Vector2i(1, 1);
|
||||||
|
|
||||||
// repeat mode of the image (repeat the image if out of range [0..1])
|
// repeat mode of the image (repeat the image if out of range [0..1])
|
||||||
protected boolean repeat = false;
|
protected boolean repeat = false;
|
||||||
|
|
||||||
protected int texId = -1; // !< openGl textureID.
|
protected int texId = -1; // !< openGl textureID.
|
||||||
|
|
||||||
public ResourceTexture2() {}
|
public ResourceTexture2() {}
|
||||||
|
|
||||||
public ResourceTexture2(final String filename) {
|
public ResourceTexture2(final String filename) {
|
||||||
super(filename);
|
super(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* public void bindForRendering(final int idTexture) { if (this.loaded == false)
|
* public void bindForRendering(final int idTexture) { if (this.loaded == false)
|
||||||
* { return; } GL13.glActiveTexture(textureIdBinding[idTexture]);
|
* { return; } GL13.glActiveTexture(textureIdBinding[idTexture]);
|
||||||
@ -115,11 +115,11 @@ public class ResourceTexture2 extends Resource {
|
|||||||
* == TextureColorMode.rgb) { OpenGL.enable(OpenGL.Flag.flagcullFace);
|
* == TextureColorMode.rgb) { OpenGL.enable(OpenGL.Flag.flagcullFace);
|
||||||
* OpenGL.enable(OpenGL.Flag.flagback); } }
|
* OpenGL.enable(OpenGL.Flag.flagback); } }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public ResourceTexture2(final Uri filename) {
|
public ResourceTexture2(final Uri filename) {
|
||||||
super(filename);
|
super(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindForRendering(final int idTexture) {
|
public void bindForRendering(final int idTexture) {
|
||||||
if (!this.loaded) {
|
if (!this.loaded) {
|
||||||
return;
|
return;
|
||||||
@ -131,36 +131,36 @@ public class ResourceTexture2 extends Resource {
|
|||||||
OpenGL.enable(OpenGL.Flag.flag_back);
|
OpenGL.enable(OpenGL.Flag.flag_back);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
removeContext();
|
removeContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush the data to send it at the openGl system
|
// Flush the data to send it at the openGl system
|
||||||
public synchronized void flush() {
|
public synchronized void flush() {
|
||||||
// request to the manager to be call at the next update ...
|
// request to the manager to be call at the next update ...
|
||||||
LOGGER.trace("Request UPDATE of Element");
|
LOGGER.trace("Request UPDATE of Element");
|
||||||
Resource.getManager().update(this);
|
Resource.getManager().update(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the reference on this image to draw something on it ...
|
// Get the reference on this image to draw something on it ...
|
||||||
public ImageByte get() {
|
public ImageByte get() {
|
||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2i getOpenGlSize() {
|
public Vector2i getOpenGlSize() {
|
||||||
return this.data.getSize();
|
return this.data.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRendererId() {
|
public int getRendererId() {
|
||||||
return this.texId;
|
return this.texId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2i getUsableSize() {
|
public Vector2i getUsableSize() {
|
||||||
return this.realImageSize;
|
return this.realImageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void removeContext() {
|
public synchronized void removeContext() {
|
||||||
if (this.loaded) {
|
if (this.loaded) {
|
||||||
@ -171,21 +171,21 @@ public class ResourceTexture2 extends Resource {
|
|||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void removeContextToLate() {
|
public synchronized void removeContextToLate() {
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.texId = -1;
|
this.texId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the image in the texture system
|
* Set the image in the texture system
|
||||||
* @note It will resize in square2 if needed by the system.
|
* @note It will resize in square2 if needed by the system.
|
||||||
* @param image Image to set.
|
* @param image Image to set.
|
||||||
*/
|
*/
|
||||||
public synchronized void set(final ImageByte image) {
|
public synchronized void set(final ImageByte image) {
|
||||||
LOGGER.debug("Set a new image in a texture:");
|
System.out.println("Set a new image in a texture:");
|
||||||
LOGGER.debug(" size=" + image.getSize());
|
System.out.println(" size=" + image.getSize());
|
||||||
this.data = image;
|
this.data = image;
|
||||||
this.realImageSize = this.data.getSize();
|
this.realImageSize = this.data.getSize();
|
||||||
// Disable compatibility size for embended ...
|
// Disable compatibility size for embended ...
|
||||||
@ -196,7 +196,7 @@ public class ResourceTexture2 extends Resource {
|
|||||||
// }
|
// }
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Filter mode to apply at the image when display with a scale
|
* Set the Filter mode to apply at the image when display with a scale
|
||||||
* (not 1:1 ratio)
|
* (not 1:1 ratio)
|
||||||
@ -205,13 +205,13 @@ public class ResourceTexture2 extends Resource {
|
|||||||
public void setFilterMode(final TextureFilter filter) {
|
public void setFilterMode(final TextureFilter filter) {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// You must set the size here, because it will be set in multiple of pow(2)
|
// You must set the size here, because it will be set in multiple of pow(2)
|
||||||
public synchronized void setImageSize(Vector2i newSize) {
|
public synchronized void setImageSize(Vector2i newSize) {
|
||||||
newSize = new Vector2i(Tools.nextP2(newSize.x()), Tools.nextP2(newSize.y()));
|
newSize = new Vector2i(Tools.nextP2(newSize.x()), Tools.nextP2(newSize.y()));
|
||||||
this.data.resize(newSize.x(), newSize.y());
|
this.data.resize(newSize.x(), newSize.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the repeate mode of the images if UV range is out of [0..1]
|
* Set the repeate mode of the images if UV range is out of [0..1]
|
||||||
* @param value Value of the new repeate mode
|
* @param value Value of the new repeate mode
|
||||||
@ -219,7 +219,7 @@ public class ResourceTexture2 extends Resource {
|
|||||||
public void setRepeat(final boolean value) {
|
public void setRepeat(final boolean value) {
|
||||||
this.repeat = value;
|
this.repeat = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unBindForRendering() {
|
public void unBindForRendering() {
|
||||||
if (!this.loaded) {
|
if (!this.loaded) {
|
||||||
return;
|
return;
|
||||||
@ -229,7 +229,7 @@ public class ResourceTexture2 extends Resource {
|
|||||||
OpenGL.disable(OpenGL.Flag.flag_back);
|
OpenGL.disable(OpenGL.Flag.flag_back);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean updateContext() {
|
public synchronized boolean updateContext() {
|
||||||
LOGGER.trace("updateContext [START]");
|
LOGGER.trace("updateContext [START]");
|
||||||
@ -263,7 +263,7 @@ public class ResourceTexture2 extends Resource {
|
|||||||
// in all case we set the texture properties :
|
// in all case we set the texture properties :
|
||||||
// TODO check error ???
|
// TODO check error ???
|
||||||
OpenGL.bindTexture2D(this.texId);
|
OpenGL.bindTexture2D(this.texId);
|
||||||
|
|
||||||
if (!this.loaded) {
|
if (!this.loaded) {
|
||||||
if (!this.repeat) {
|
if (!this.repeat) {
|
||||||
OpenGL.setTexture2DWrapClampToEdge();
|
OpenGL.setTexture2DWrapClampToEdge();
|
||||||
@ -287,7 +287,7 @@ public class ResourceTexture2 extends Resource {
|
|||||||
typeObject, // format
|
typeObject, // format
|
||||||
sizeObject, // type
|
sizeObject, // type
|
||||||
this.data.getRaw());
|
this.data.getRaw());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
OpenGL.glTexSubImage2D(0, // Level
|
OpenGL.glTexSubImage2D(0, // Level
|
||||||
0, // x offset
|
0, // x offset
|
||||||
@ -302,5 +302,5 @@ public class ResourceTexture2 extends Resource {
|
|||||||
// LOGGER.error(" updateContext [STOP] ==> " + (toc - toc1));
|
// LOGGER.error(" updateContext [STOP] ==> " + (toc - toc1));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user