[DEV] updates

This commit is contained in:
Edouard DUPIN 2021-03-25 18:55:52 +01:00
parent da0e6810f6
commit 84fc01f773
27 changed files with 2155 additions and 2043 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false"> <fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="ewol" local="false"> <fileset name="all" enabled="true" check-config-name="Ewol" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/> <file-match-pattern match-pattern="." include-pattern="true"/>
</fileset> </fileset>
</fileset-config> </fileset-config>

View File

@ -5,6 +5,7 @@
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" path="resources"/>
<classpathentry including="**/*.java" kind="src" output="out/eclipse/classes-test" path="test/src"> <classpathentry including="**/*.java" kind="src" output="out/eclipse/classes-test" path="test/src">
<attributes> <attributes>
<attribute name="test" value="true"/> <attribute name="test" value="true"/>

16
gale.iml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="etk" exported="" />
<orderEntry type="library" exported="" name="lwjgl-stb-natives-linux" level="project" />
<orderEntry type="library" exported="" name="pngdecoder" level="project" />
<orderEntry type="library" exported="" name="lwjgl3-awt-0.1.7" level="project" />
<orderEntry type="library" scope="TEST" name="org.junit.jupiter:junit-jupiter-api:5.7.1" level="project" />
</component>
</module>

View File

@ -0,0 +1,16 @@
#version 400 core
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
in vec4 io_color;
// output:
out vec4 out_Color;
void main(void) {
out_Color = io_color;
}

View File

@ -0,0 +1,21 @@
#version 400 core
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
// Input :
in vec3 in_position;
uniform vec4 in_colors;
uniform mat4 in_matrixTransformation;
uniform mat4 in_matrixProjection;
uniform mat4 in_matrixView;
// output :
out vec4 io_color;
void main(void) {
gl_Position = in_matrixProjection * in_matrixView * in_matrixTransformation * vec4(in_position, 1.0);
io_color = vec4(in_colors.xyz, 0.3);
}

View File

@ -1,37 +1,39 @@
/** Basic module interface. /**
* Basic module interface.
* *
* @author Edouard DUPIN */ * @author Edouard DUPIN
*/
open module org.atriasoft.gale { open module org.atriasoft.gale {
exports org.atriasoft.gale; exports org.atriasoft.gale;
exports org.atriasoft.gale.backend3d; exports org.atriasoft.gale.backend3d;
exports org.atriasoft.gale.context; exports org.atriasoft.gale.context;
//exports org.atriasoft.gale.context.JOGL; // exports org.atriasoft.gale.context.JOGL;
exports org.atriasoft.gale.context.LWJG_AWT; exports org.atriasoft.gale.context.LWJG_AWT;
exports org.atriasoft.gale.key; exports org.atriasoft.gale.key;
exports org.atriasoft.gale.resource; exports org.atriasoft.gale.resource;
requires transitive org.atriasoft.etk; requires transitive org.atriasoft.etk;
//requires transitive vecmath; // requires transitive vecmath;
requires transitive org.lwjgl; requires transitive org.lwjgl;
requires transitive org.lwjgl.natives; requires transitive org.lwjgl.natives;
requires transitive org.lwjgl.glfw; requires transitive org.lwjgl.glfw;
requires transitive org.lwjgl.glfw.natives; requires transitive org.lwjgl.glfw.natives;
requires transitive org.lwjgl.assimp; requires transitive org.lwjgl.assimp;
requires transitive org.lwjgl.assimp.natives; requires transitive org.lwjgl.assimp.natives;
// requires transitive org.lwjgl.openal; // requires transitive org.lwjgl.openal;
// requires transitive org.lwjgl.openal.natives; // requires transitive org.lwjgl.openal.natives;
requires transitive org.lwjgl.stb; requires transitive org.lwjgl.stb;
requires transitive org.lwjgl.stb.natives; requires transitive org.lwjgl.stb.natives;
requires transitive org.lwjgl.jawt; requires transitive org.lwjgl.jawt;
//requires transitive org.lwjgl.opengl.awt; // requires transitive org.lwjgl.opengl.awt;
requires transitive org.lwjgl.opengl; requires transitive org.lwjgl.opengl;
requires transitive org.lwjgl.opengl.natives; requires transitive org.lwjgl.opengl.natives;
//requires org.lwjgl.openvr; // requires org.lwjgl.openvr;
//requires transitive jogamp.fat; // requires transitive jogamp.fat;
requires transitive java.desktop; requires transitive java.desktop;
requires transitive pngdecoder; requires transitive pngdecoder;
requires transitive lwjgl3.awt; requires transitive lwjgl3.awt;

View File

@ -15,278 +15,296 @@ public class Application {
public boolean canDraw = false; public boolean canDraw = false;
private boolean needRedraw = true; private boolean needRedraw = true;
private String title = "gale"; private String title = "gale";
private Uri iconName = new Uri(""); private Uri iconName = null;
private Cursor cursor = Cursor.arrow; private final Cursor cursor = Cursor.arrow;
private Orientation orientation = Orientation.screenAuto; private Orientation orientation = Orientation.screenAuto;
Vector2f windowsSize = new Vector2f(800,600); Vector2f windowsSize = new Vector2f(800, 600);
public Application() { public Application() {
Log.verbose("Constructor Gale Application"); Log.verbose("Constructor Gale Application");
} }
/** /**
* @brief The application is created. * Exit the application (not availlable on IOs, ==> the user will not understand the comportement. He will think the application has crashed (Apple philosophie))
* @param context Current gale context.
*/
public void onCreate(Context context) {
Log.verbose("Create Gale Application");
}
/**
* @brief The application is started.
* @param context Current gale context.
*/
public void onStart(Context context){
Log.verbose("Start Gale Application");
}
/**
* @brief The application is resumed (now visible).
* @param context Current gale context.
*/
public void onResume(Context context){
Log.verbose("Start Gale Application");
}
/**
* @brief call application to precalculate drawing.
* @param context Current gale context.
*/
public void onRegenerateDisplay(Context context) {
//Log.verbose("Regenerate Gale Application");
markDrawingIsNeeded();
}
/**
* @brief Real draw of the application
* @param context Current gale context.
*/
public void onDraw(Context context) {
Log.verbose("draw Gale Application");
}
/**
* @brief The application is Hide / not visible.
* @param context Current gale context.
*/
public void onPause(Context context) {
Log.verbose("Pause Gale Application");
}
/**
* @brief The application is stopped.
* @param context Current gale context.
*/
public void onStop(Context context) {
Log.verbose("Stop Gale Application");
}
/**
* @brief The application is removed (call destructor just adter it.).
* @param context Current gale context.
*/
public void onDestroy(Context context) {
Log.verbose("Destroy Gale Application");
}
/**
* @brief The user request application removing.
* @param context Current gale context.
*/
public void onKillDemand(Context context) {
Log.info("Gale request auto destroy ==> no applification specification");
System.exit(0);
}
/**
* @brief Exit the application (not availlable on IOs, ==> the user will not understand the comportement. He will think the application has crashed (Apple philosophie))
* @param value value to return on the program * @param value value to return on the program
*/ */
public void exit(int value) { public void exit(final int value) {
Log.verbose("Exit Requested " + value); Log.verbose("Exit Requested " + value);
Gale.getContext().stop(); Gale.getContext().stop();
} }
public void markDrawingIsNeeded() {
this.needRedraw = true;
}
public boolean isDrawingNeeded() {
boolean tmp = this.needRedraw;
this.needRedraw = false;
return tmp;
}
/**
* @brief Get touch/mouse/... event.
* @param type Type of pointer event
* @param pointerID Pointer id of the touch event.
* @param pos Position of the event (can be <0 if out of window).
* @param state Key state (up/down/move)
*/
public void onPointer(KeySpecial special,
KeyType type,
int pointerID,
Vector2f pos,
KeyStatus state) {
}
/**
* @brief Get keyborad value input.
* @param special Current special key status (ctrl/alt/shift ...).
* @param type Type of the event.
* @param value Unicode value of the char pushed (viable only if type==gale::key::keyboard::character).
* @param state State of the key (up/down/upRepeate/downRepeate)
*/
public void onKeyboard(KeySpecial special,
KeyKeyboard type,
Character value,
KeyStatus state) {
}
/**
* @brief Show the virtal keyboard (if possible : only on iOs/Android)
*/
public void keyboardShow() {
Context context = Gale.getContext();
if (context == null) {
return;
}
context.keyboardShow();
}
/**
* @brief Hide the virtal keyboard (if possible : only on iOs/Android)
*/
public void keyboardHide() {
Context context = Gale.getContext();
if (context == null) {
return;
}
context.keyboardHide();
}
/**
* @brief Event generated when user change the size of the window.
* @param size New size of the window.
*/
public void onResize(Vector2f size) {
if (size == null) {
Log.error("Try to set a null size ...");
return;
}
windowsSize = size;
}
/**
* @brief Set the size of the window (if possible: Android and Ios does not support it)
* @param size New size of the window.
* @return
*/
public void setSize(Vector2f size) {
windowsSize = size;
Context context = Gale.getContext();
if (context == null) {
return;
}
context.setSize(size);
}
/**
* @brief Get the size of the window.
* @return Current size of the window.
*/
public Vector2f getSize() {
return windowsSize;
}
public float getAspectRatio() { public float getAspectRatio() {
return windowsSize.x/windowsSize.y; return this.windowsSize.x() / this.windowsSize.y();
} }
/** /**
* @brief Event generated when user change the position of the window. * Get the cursor type.
* @param size New position of the window.
*/
public void onMovePosition(Vector2f size) {
}
/**
* @brief Set the position of the window (if possible: Android and Ios does not support it)
* @param size New position of the window.
*/
public void setPosition(Vector2f size) {
}
/**
* @brief Get the position of the window.
* @return Current position of the window.
*/
public Vector2f getPosition() {
return new Vector2f(0,0);
}
/**
* @brief Set the title of the application
* @param title New title to set at the application (if possible: Android and Ios does not support it)
*/
public void setTitle(String title) {
this.title = title;
Context context = Gale.getContext();
if (context == null) {
return;
}
context.setTitle(this.title);
}
/**
* @brief Get the current title of the application
* @return Current title
*/
public String getTitle() {
return this.title;
}
/**
* @brief set the Icon of the application.
* @param iconFile File name icon (.bmp/.png).
*/
public void setIcon(Uri iconFile) {
this.iconName = iconFile;
Gale.getContext().setIcon(this.iconName);
}
/**
* @brief Get the current filename of the application.
* @return Filename of the icon.
*/
public Uri getIcon() {
return this.iconName;
}
/**
* @brief Set the cursor type.
* @param newCursor Selected cursor.
*/
public void setCursor(Cursor newCursor) {
Gale.getContext().setCursor(this.cursor);
}
/**
* @brief Get the cursor type.
* @return the current cursor. * @return the current cursor.
*/ */
public Cursor getCursor() { public Cursor getCursor() {
return this.cursor; return this.cursor;
} }
/** /**
* @brief set the screen orientation (if possible : only on iOs/Android) * Get the current filename of the application.
* @param orientation New orientation. * @return Filename of the icon.
*/ */
public void setOrientation(Orientation orientation) { public Uri getIcon() {
this.orientation = orientation; return this.iconName;
Gale.getContext().forceOrientation(this.orientation);
} }
/** /**
* @brief get the screen orientation (if possible : only on iOs/Android) * get the screen orientation (if possible : only on iOs/Android)
* @return Current orientation. * @return Current orientation.
*/ */
public Orientation getOrientation() { public Orientation getOrientation() {
return this.orientation; return this.orientation;
} }
/** /**
* @brief A clipboard data is back (apear after a request of a new clipboard). * Get the position of the window.
* @return Current position of the window.
*/
public Vector2f getPosition() {
return new Vector2f(0, 0);
}
/**
* Get the size of the window.
* @return Current size of the window.
*/
public Vector2f getSize() {
return this.windowsSize;
}
/**
* Get the current title of the application
* @return Current title
*/
public String getTitle() {
return this.title;
}
public boolean isDrawingNeeded() {
final boolean tmp = this.needRedraw;
this.needRedraw = false;
return tmp;
}
/**
* Hide the virtal keyboard (if possible : only on iOs/Android)
*/
public void keyboardHide() {
final Context context = Gale.getContext();
if (context == null) {
return;
}
context.keyboardHide();
}
/**
* Show the virtal keyboard (if possible : only on iOs/Android)
*/
public void keyboardShow() {
final Context context = Gale.getContext();
if (context == null) {
return;
}
context.keyboardShow();
}
public void markDrawingIsNeeded() {
this.needRedraw = true;
}
/**
* A clipboard data is back (apear after a request of a new clipboard).
* @param clipboardId Id of the clipboard. * @param clipboardId Id of the clipboard.
*/ */
public void onClipboardEvent(ClipboardList clipboardId) { public void onClipboardEvent(final ClipboardList clipboardId) {
} }
/** /**
* @brief Call every time a draw is called (not entirely periodic, but faster at we can ... * The application is created.
* @param context Current gale context.
*/
public void onCreate(final Context context) {
Log.verbose("Create Gale Application");
}
/**
* The application is removed (call destructor just adter it.).
* @param context Current gale context.
*/
public void onDestroy(final Context context) {
Log.verbose("Destroy Gale Application");
}
/**
* Real draw of the application
* @param context Current gale context.
*/
public void onDraw(final Context context) {
Log.verbose("draw Gale Application");
}
/**
* Get keyborad value input.
* @param special Current special key status (ctrl/alt/shift ...).
* @param type Type of the event.
* @param value Unicode value of the char pushed (viable only if type==gale::key::keyboard::character).
* @param state State of the key (up/down/upRepeate/downRepeate)
*/
public void onKeyboard(final KeySpecial special, final KeyKeyboard type, final Character value, final KeyStatus state) {
}
/**
* The user request application removing.
* @param context Current gale context.
*/
public void onKillDemand(final Context context) {
Log.info("Gale request auto destroy ==> no applification specification");
System.exit(0);
}
/**
* Event generated when user change the position of the window.
* @param size New position of the window.
*/
public void onMovePosition(final Vector2f size) {
}
/**
* The application is Hide / not visible.
* @param context Current gale context.
*/
public void onPause(final Context context) {
Log.verbose("Pause Gale Application");
}
/**
* Call every time a draw is called (not entirely periodic, but faster at we can ...
* @param time Current time of the call; * @param time Current time of the call;
*/ */
public void onPeriod(long time) {}; public void onPeriod(final long time) {}
/**
* Get touch/mouse/... event.
* @param type Type of pointer event
* @param pointerID Pointer id of the touch event.
* @param pos Position of the event (can be <0 if out of window).
* @param state Key state (up/down/move)
*/
public void onPointer(final KeySpecial special, final KeyType type, final int pointerID, final Vector2f pos, final KeyStatus state) {
}
/**
* call application to precalculate drawing.
* @param context Current gale context.
*/
public void onRegenerateDisplay(final Context context) {
//Log.verbose("Regenerate Gale Application");
markDrawingIsNeeded();
}
/**
* Event generated when user change the size of the window.
* @param size New size of the window.
*/
public void onResize(final Vector2f size) {
if (size == null) {
Log.error("Try to set a null size ...");
return;
}
this.windowsSize = size;
}
/**
* The application is resumed (now visible).
* @param context Current gale context.
*/
public void onResume(final Context context) {
Log.verbose("Start Gale Application");
}
/**
* The application is started.
* @param context Current gale context.
*/
public void onStart(final Context context) {
Log.verbose("Start Gale Application");
}
/**
* The application is stopped.
* @param context Current gale context.
*/
public void onStop(final Context context) {
Log.verbose("Stop Gale Application");
}
/**
* Set the cursor type.
* @param newCursor Selected cursor.
*/
public void setCursor(final Cursor newCursor) {
Gale.getContext().setCursor(this.cursor);
}
/**
* set the Icon of the application.
* @param iconFile File name icon (.bmp/.png).
*/
public void setIcon(final Uri iconFile) {
this.iconName = iconFile;
Gale.getContext().setIcon(this.iconName);
}
/**
* set the screen orientation (if possible : only on iOs/Android)
* @param orientation New orientation.
*/
public void setOrientation(final Orientation orientation) {
this.orientation = orientation;
Gale.getContext().forceOrientation(this.orientation);
}
/**
* Set the position of the window (if possible: Android and Ios does not support it)
* @param size New position of the window.
*/
public void setPosition(final Vector2f size) {
}
/**
* Set the size of the window (if possible: Android and Ios does not support it)
* @param size New size of the window.
* @return
*/
public void setSize(final Vector2f size) {
this.windowsSize = size;
final Context context = Gale.getContext();
if (context == null) {
return;
}
context.setSize(size);
}
/**
* Set the title of the application
* @param title New title to set at the application (if possible: Android and Ios does not support it)
*/
public void setTitle(final String title) {
this.title = title;
final Context context = Gale.getContext();
if (context == null) {
return;
}
context.setTitle(this.title);
};
} }

View File

@ -6,340 +6,275 @@
package org.atriasoft.gale; package org.atriasoft.gale;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.gale.internal.Log; import org.atriasoft.gale.internal.Log;
/** /**
* @brief in the dimention class we store the data as the more usefull unit (pixel) * in the dimension class we store the data as the more usefull unit (pixel)
* but one case need to be dynamic the %, then when requested in % the register the % value * but one case need to be dynamic the %, then when requested in % the register the % value
*/ */
public class Dimension { @SuppressWarnings("preview")
private final static Vector2f ratio = new Vector2f(9999999, 888888); public record Dimension(
private final static Vector2f invRatio = new Vector2f(1, 1); Vector2f size,
private final static Dimension windowsSize = new Dimension(new Vector2f(9999999, 888888), Distance.PIXEL); Distance type) {
public static final Dimension ZERO = new Dimension(Vector2f.ZERO, Distance.PIXEL);
private static Vector2f ratio = new Vector2f(9999999, 888888);
private static Vector2f invRatio = new Vector2f(1, 1);
private static Dimension windowsSize = new Dimension(Vector2f.MAX_VALUE, Distance.PIXEL);
public final static float INCH_TO_MILLIMETER = 1.0f / 25.4f; public static final float INCH_TO_MILLIMETER = 1.0f / 25.4f;
public final static float FOOT_TO_MILLIMETER = 1.0f / 304.8f; public static final float FOOT_TO_MILLIMETER = 1.0f / 304.8f;
public final static float METER_TO_MILLIMETER = 1.0f / 1000.0f; public static final float METER_TO_MILLIMETER = 1.0f / 1000.0f;
public final static float CENTIMETER_TO_MILLIMETER = 1.0f / 10.0f; public static final float CENTIMETER_TO_MILLIMETER = 1.0f / 10.0f;
public final static float KILOMETER_TO_MILLIMETER = 1.0f / 1000000.0f; public static final float KILOMETER_TO_MILLIMETER = 1.0f / 1000000.0f;
public final static float MILLIMETER_TO_INCH = 25.4f; public static final float MILLIMETER_TO_INCH = 25.4f;
public final static float MILLIMETER_TO_FOOT = 304.8f; public static final float MILLIMETER_TO_FOOT = 304.8f;
public final static float MILLIMETER_TO_METER = 1000.0f; public static final float MILLIMETER_TO_METER = 1000.0f;
public final static float MILLIMETER_TO_CENTIMETER = 10.0f; public static final float MILLIMETER_TO_CENTIMETER = 10.0f;
public final static float MILLIMETER_TO_KILOMETER = 1000000.0f; public static final float MILLIMETER_TO_KILOMETER = 1000000.0f;
/** /**
* @brief basic init * basic init
*/ */
static { static {
final Dimension conversion = new Dimension(new Vector2f(72, 72), Distance.INCH); final Dimension conversion = new Dimension(new Vector2f(72, 72), Distance.INCH);
ratio.set(conversion.getMillimeter()); ratio = conversion.getMillimeter();
invRatio.setValue(1.0f / ratio.x, 1.0f / ratio.y); invRatio = new Vector2f(1.0f / ratio.x(), 1.0f / ratio.y());
windowsSize.set(new Vector2f(200, 200), Distance.PIXEL); windowsSize = new Dimension(new Vector2f(200, 200), Distance.PIXEL);
} }
/** /**
* @brief get the Windows diagonal size in the request unit * get the Windows diagonal size in the request unit
* @param[in] type Unit type requested. * @param type Unit type requested.
* @return the requested size * @return the requested size
*/ */
public static float getWindowsDiag(final Distance _type) { public static float getWindowsDiag(final Distance type) {
final Vector2f size = getWindowsSize(_type); final Vector2f size = getWindowsSize(type);
return size.length(); return size.length();
} }
/** /**
* @brief get the Windows size in the request unit * get the Windows size in the request unit
* @param[in] type Unit type requested. * @param type Unit type requested.
* @return the requested size * @return the requested size
*/ */
public static Vector2f getWindowsSize(final Distance _type) { public static Vector2f getWindowsSize(final Distance type) {
return windowsSize.get(_type); return windowsSize.get(type);
} }
/** /**
* @brief set the Milimeter ratio for calculation * set the Milimeter ratio for calculation
* @param[in] Ratio Milimeter ration for the screen calculation interpolation * @param ratio Milimeter ration for the screen calculation interpolation
* @param[in] type Unit type requested. * @param type Unit type requested.
* @note: same as @ref setPixelPerInch (internal manage convertion) * @note: same as @ref setPixelPerInch (internal manage convertion)
*/ */
public static void setPixelRatio(final Vector2f _ratio, final Distance _type) { public static void setPixelRatio(final Vector2f ratio, final Distance type) {
Log.info("Set a new screen ratio for the screen : ratio=" + _ratio + " type=" + _type); Log.info("Set a new screen ratio for the screen : ratio=" + ratio + " type=" + type);
final Dimension conversion = new Dimension(_ratio, _type); final Dimension conversion = new Dimension(ratio, type);
Log.info(" == > " + conversion); Log.info(" == > " + conversion);
ratio.set(conversion.getMillimeter()); Dimension.ratio = conversion.getMillimeter();
invRatio.setValue(1.0f / ratio.x, 1.0f / ratio.y); invRatio = new Vector2f(1.0f / Dimension.ratio.x(), 1.0f / Dimension.ratio.y());
Log.info("Set a new screen ratio for the screen : ratioMm=" + ratio); Log.info("Set a new screen ratio for the screen : ratioMm=" + Dimension.ratio);
} }
/** /**
* @brief set the current Windows size * set the current Windows size
* @param[in] size size of the current windows in pixel. * @param size size of the current windows in pixel.
*/ */
public static void setPixelWindowsSize(final Vector2f _size) { public static void setPixelWindowsSize(final Vector2f size) {
windowsSize.set(_size); windowsSize = new Dimension(size);
Log.verbose("Set a new Windows property size " + windowsSize + "px"); Log.verbose("Set a new Windows property size " + windowsSize + "px");
} }
private Vector2f size = new Vector2f(0, 0);
private Distance type = Distance.PIXEL;
/** /**
* @brief Constructor (default :0,0 mode pixel) * Constructor (default :0,0 mode pixel)
*/ */
public Dimension() { public Dimension() {
this(Vector2f.ZERO, Distance.PIXEL);
} }
/** /**
* @brief Constructor * Constructor
* @param[in] _config dimension configuration. * @param size Requested dimension
*/ */
public Dimension(final String _config) { public Dimension(final Vector2f size) {
set(_config); this(size, Distance.PIXEL);
}
public Dimension(final Vector2f size, final Distance type) {
this.size = size;
this.type = type;
} }
/** /**
* @brief Constructor * get the current dimension in requested type
* @param[in] _size Requested dimension * @param type Type of unit requested.
* @param[in] _type Unit of the Dimension * @return dimension requested.
*/ */
public Dimension(final Vector2f _size) { public Vector2f get(final Distance type) {
set(_size, Distance.PIXEL); return switch (type) {
} case POURCENT -> getPourcent();
case PIXEL -> getPixel();
public Dimension(final Vector2f _size, final Distance _type) { case METER -> getMeter();
set(_size, _type); case CENTIMETER -> getCentimeter();
} case MILLIMETER -> getMillimeter();
case KILOMETER -> getKilometer();
/***************************************************** case INCH -> getInch();
* isEqual case FOOT -> getFoot();
*****************************************************/ };
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
if (!(obj instanceof Dimension)) {
return false;
}
final Dimension other = (Dimension) obj;
return this.size.equals(other.size) && this.type == other.type;
} }
/** /**
* @brief get the current dimention in requested type * get the current dimension in Centimeter
* @param[in] _type Type of unit requested. * @return dimension in Centimeter
* @return dimention requested.
*/
public Vector2f get(final Distance _type) {
switch (_type) {
case POURCENT:
return getPourcent();
case PIXEL:
return getPixel();
case METER:
return getMeter();
case CENTIMETER:
return getCentimeter();
case MILLIMETER:
return getMillimeter();
case KILOMETER:
return getKilometer();
case INCH:
return getInch();
case FOOT:
return getFoot();
}
return new Vector2f(0, 0);
}
/**
* @brief get the current dimention in Centimeter
* @return dimention in Centimeter
*/ */
public Vector2f getCentimeter() { public Vector2f getCentimeter() {
return getMillimeter().multiplyNew(MILLIMETER_TO_CENTIMETER); return getMillimeter().multiply(MILLIMETER_TO_CENTIMETER);
} }
/** /**
* @brief get the current dimention in Foot * get the current dimension in Foot
* @return dimention in Foot * @return dimension in Foot
*/ */
public Vector2f getFoot() { public Vector2f getFoot() {
return getMillimeter().multiplyNew(MILLIMETER_TO_FOOT); return getMillimeter().multiply(MILLIMETER_TO_FOOT);
} }
/** /**
* @brief get the current dimention in Inch * get the current dimension in Inch
* @return dimention in Inch * @return dimension in Inch
*/ */
public Vector2f getInch() { public Vector2f getInch() {
return getMillimeter().multiplyNew(MILLIMETER_TO_INCH); return getMillimeter().multiply(MILLIMETER_TO_INCH);
} }
/** /**
* @brief get the current dimention in Kilometer * get the current dimension in Kilometer
* @return dimention in Kilometer * @return dimension in Kilometer
*/ */
public Vector2f getKilometer() { public Vector2f getKilometer() {
return getMillimeter().multiplyNew(MILLIMETER_TO_KILOMETER); return getMillimeter().multiply(MILLIMETER_TO_KILOMETER);
} }
/** /**
* @brief get the current dimention in Meter * get the current dimension in Meter
* @return dimention in Meter * @return dimension in Meter
*/ */
public Vector2f getMeter() { public Vector2f getMeter() {
return getMillimeter().multiplyNew(MILLIMETER_TO_METER); return getMillimeter().multiply(MILLIMETER_TO_METER);
} }
/** /**
* @brief get the current dimention in Millimeter * get the current dimension in Millimeter
* @return dimention in Millimeter * @return dimension in Millimeter
*/ */
public Vector2f getMillimeter() { public Vector2f getMillimeter() {
return new Vector2f(getPixel().x * invRatio.x, getPixel().y * invRatio.y); return new Vector2f(getPixel().x() * invRatio.x(), getPixel().y() * invRatio.y());
} }
/** /**
* @brief get the current dimention in pixel * get the current dimension in pixel
* @return dimention in Pixel * @return dimension in Pixel
*/ */
public Vector2f getPixel() { public Vector2f getPixel() {
if (this.type != Distance.POURCENT) { if (this.type != Distance.POURCENT) {
return this.size; return this.size;
} else {
final Vector2f windDim = windowsSize.getPixel();
final Vector2f res = new Vector2f(windDim.x * this.size.x, windDim.y * this.size.y);
//GALE_DEBUG("Get % : " + m_data + " / " + windDim + " == > " + res);
return res;
} }
final Vector2f windDim = windowsSize.getPixel();
final Vector2f res = new Vector2f(windDim.x() * this.size.x(), windDim.y() * this.size.y());
//GALE_DEBUG("Get % : " + m_data + " / " + windDim + " == > " + res);
return res;
}
public Vector2i getPixeli() {
if (this.type != Distance.POURCENT) {
return new Vector2i((int) this.size.x(), (int) this.size.y());
}
final Vector2f windDim = windowsSize.getPixel();
final Vector2i res = new Vector2i((int) (windDim.x() * this.size.x()), (int) (windDim.y() * this.size.y()));
//GALE_DEBUG("Get % : " + m_data + " / " + windDim + " == > " + res);
return res;
} }
/** /**
* @brief get the current dimention in Pourcent * get the current dimension in Pourcent
* @return dimention in Pourcent * @return dimension in Pourcent
*/ */
public Vector2f getPourcent() { public Vector2f getPourcent() {
if (this.type != Distance.POURCENT) { if (this.type != Distance.POURCENT) {
final Vector2f windDim = windowsSize.getPixel(); final Vector2f windDim = windowsSize.getPixel();
//GALE_DEBUG(" windows dimention : " /*+ windowsSize*/ + " == > " + windDim + "px"); // ==> infinite loop ... //GALE_DEBUG(" windows dimension : " /*+ windowsSize*/ + " == > " + windDim + "px"); // ==> infinite loop ...
//printf(" windows dimention : %f,%f", windDim.x(),windDim.y()); //printf(" windows dimension : %f,%f", windDim.x(),windDim.y());
//printf(" data : %f,%f", m_data.x(),m_data.y()); //printf(" data : %f,%f", m_data.x(),m_data.y());
return new Vector2f((this.size.x / windDim.x) * 100.0f, (this.size.y / windDim.y) * 100.0f); return new Vector2f((this.size.x() / windDim.x()) * 100.0f, (this.size.y() / windDim.y()) * 100.0f);
} }
return new Vector2f(this.size.x * 100.0f, this.size.y * 100.0f); return new Vector2f(this.size.x() * 100.0f, this.size.y() * 100.0f);
}; };
/** /**
* @breif get the dimension type * get the dimension type
* @return the type * @return the type
*/ */
public Distance getType() { public Distance getType() {
return this.type; return this.type;
} }
/*****************************************************
* assigment
*****************************************************/
public Dimension set(final Dimension _obj) {
if (this != _obj) {
this.size = _obj.size;
this.type = _obj.type;
}
return this;
}
/** /**
* @brief set the current dimention in requested type * set the current dimension in requested type
* @param[in] _config dimension configuration. * @param config dimension configuration.
*/ */
private void set(String _config) { public static Dimension valueOf(String config) {
this.size.setValue(0, 0); final Vector2f size = Vector2f.ZERO;
this.type = Distance.PIXEL;
Distance type = Distance.PIXEL; Distance type = Distance.PIXEL;
if (_config.endsWith("%") == true) { if (config.endsWith("%")) {
type = Distance.POURCENT; type = Distance.POURCENT;
_config = _config.substring(0, _config.length() - 1); config = config.substring(0, config.length() - 1);
} else if (_config.endsWith("px") == true) { } else if (config.endsWith("px")) {
type = Distance.PIXEL; type = Distance.PIXEL;
_config = _config.substring(0, _config.length() - 2); config = config.substring(0, config.length() - 2);
} else if (_config.endsWith("ft") == true) { } else if (config.endsWith("ft")) {
type = Distance.FOOT; type = Distance.FOOT;
_config = _config.substring(0, _config.length() - 2); config = config.substring(0, config.length() - 2);
} else if (_config.endsWith("in") == true) { } else if (config.endsWith("in")) {
type = Distance.INCH; type = Distance.INCH;
_config = _config.substring(0, _config.length() - 2); config = config.substring(0, config.length() - 2);
} else if (_config.endsWith("km") == true) { } else if (config.endsWith("km")) {
type = Distance.KILOMETER; type = Distance.KILOMETER;
_config = _config.substring(0, _config.length() - 2); config = config.substring(0, config.length() - 2);
} else if (_config.endsWith("mm") == true) { } else if (config.endsWith("mm")) {
type = Distance.MILLIMETER; type = Distance.MILLIMETER;
_config = _config.substring(0, _config.length() - 2); config = config.substring(0, config.length() - 2);
} else if (_config.endsWith("cm") == true) { } else if (config.endsWith("cm")) {
type = Distance.CENTIMETER; type = Distance.CENTIMETER;
_config = _config.substring(0, _config.length() - 2); config = config.substring(0, config.length() - 2);
} else if (_config.endsWith("m") == true) { } else if (config.endsWith("m")) {
type = Distance.METER; type = Distance.METER;
_config = _config.substring(0, _config.length() - 1); config = config.substring(0, config.length() - 1);
} else { } else {
Log.critical("Can not parse dimention : '" + _config + "'"); Log.critical("Can not parse dimension : '" + config + "'");
return; return null;
} }
final Vector2f tmp = Vector2f.valueOf(_config); final Vector2f tmp = Vector2f.valueOf(config);
set(tmp, type); final Dimension ret = new Dimension(tmp, type);
Log.verbose(" config dimention : \"" + _config + "\" == > " + this); Log.verbose(" config dimension : '" + config + "' == > " + ret.toString());
} return ret;
public void set(final Vector2f _size) {
this.size = _size;
this.type = Distance.PIXEL;
} }
/** /**
* @brief set the current dimention in requested type * string cast :
* @param[in] _size Dimention to set
* @param[in] _type Type of unit requested.
*/
public void set(final Vector2f _size, final Distance _type) {
this.size = _size;
this.type = _type;
}
/**
* @brief string cast :
*/ */
@Override @Override
public String toString() { public String toString() {
String str = get(getType()).toString(); String str = get(getType()).toString();
switch (getType()) { switch (getType()) {
case POURCENT: case POURCENT -> str += "%";
str += "%"; case PIXEL -> str += "px";
break; case METER -> str += "m";
case PIXEL: case CENTIMETER -> str += "cm";
str += "px"; case MILLIMETER -> str += "mm";
break; case KILOMETER -> str += "km";
case METER: case INCH -> str += "in";
str += "m"; case FOOT -> str += "ft";
break; default -> str += "";
case CENTIMETER:
str += "cm";
break;
case MILLIMETER:
str += "mm";
break;
case KILOMETER:
str += "km";
break;
case INCH:
str += "in";
break;
case FOOT:
str += "ft";
break;
} }
return str; return str;
} }

View File

@ -1,5 +1,6 @@
package org.atriasoft.gale; package org.atriasoft.gale;
import org.atriasoft.etk.Uri;
import org.atriasoft.gale.context.Context; import org.atriasoft.gale.context.Context;
//import org.atriasoft.gale.context.JOGL.ContextJOGL; //import org.atriasoft.gale.context.JOGL.ContextJOGL;
import org.atriasoft.gale.context.LWJG_AWT.ContextLWJGLAWT; import org.atriasoft.gale.context.LWJG_AWT.ContextLWJGLAWT;
@ -7,9 +8,25 @@ import org.atriasoft.gale.context.LWJG_AWT.ContextLWJGLAWT;
import org.atriasoft.gale.internal.Log; import org.atriasoft.gale.internal.Log;
public class Gale { public class Gale {
private Gale() {} public static Context getContext() {
// TODO Auto-generated method stub
return Context.getContext();
}
/** /**
* @brief This is the only one things the User might done in his main(); * get GALE version
* @return The string that describe gale version
*/
public static String getVersion() {
return "J-0.5";
}
public static void init() {
Uri.addLibrary("gale", Gale.class, "/resources/gale/");
}
/**
* This is the only one things the User might done in his main();
* @note To answare you before you ask the question, this is really simple: * @note To answare you before you ask the question, this is really simple:
* Due to the fect that the current system is multiple-platform, you "main" * Due to the fect that the current system is multiple-platform, you "main"
* Does not exist in the android platform, then gale call other start * Does not exist in the android platform, then gale call other start
@ -20,7 +37,8 @@ public class Gale {
* @param _argv Standard argv * @param _argv Standard argv
* @return normal error int for the application error management * @return normal error int for the application error management
*/ */
public static int run(Application application, String[] arg) { public static int run(final Application application, final String[] arg) {
init();
//etk::init(_argc, _argv); //etk::init(_argc, _argv);
Context context = null; Context context = null;
String request = ""; String request = "";
@ -34,17 +52,6 @@ public class Gale {
} }
return context.run(); return context.run();
} }
/** private Gale() {}
* @brief get GALE version
* @return The string that describe gale version
*/
public static String getVersion() {
return "J-0.5";
}
public static Context getContext() {
// TODO Auto-generated method stub
return Context.getContext();
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,14 +3,14 @@ package org.atriasoft.gale.context;
public class ClipBoard { public class ClipBoard {
private ClipBoard() {} private ClipBoard() {}
/** /**
* @brief set the string data on a specific clipboard. The Gui system is notify that the clipboard "SELECTION" and "COPY" are change * set the string data on a specific clipboard. The Gui system is notify that the clipboard "SELECTION" and "COPY" are change
* @param _clipboardID Select the specific ID of the clipboard * @param _clipboardID Select the specific ID of the clipboard
* @param _data The string that might be send to the clipboard * @param _data The string that might be send to the clipboard
*/ */
public static void set(ClipboardList clipboardID, String data) { public static void set(ClipboardList clipboardID, String data) {
} }
/** /**
* @brief Call system to request the current clipboard. * Call system to request the current clipboard.
* @note Due to some system that manage the clipboard request asynchronous (like X11) and gale managing the system with only one thread, * @note Due to some system that manage the clipboard request asynchronous (like X11) and gale managing the system with only one thread,
* we need the call the system to send us the buffer, this is really ambigous, but the widget (who has focus) receive the * we need the call the system to send us the buffer, this is really ambigous, but the widget (who has focus) receive the
* notification of the arrival of this buffer id * notification of the arrival of this buffer id
@ -19,7 +19,7 @@ public class ClipBoard {
public static void request(ClipboardList clipboardID) { public static void request(ClipboardList clipboardID) {
} }
/** /**
* @brief set the gale internal buffer (no notification at the GUI). This fuction might be use by the * set the gale internal buffer (no notification at the GUI). This fuction might be use by the
* Gui abstraction to set the buffer we receive. The end user must not use it. * Gui abstraction to set the buffer we receive. The end user must not use it.
* @param _clipboardID selected clipboard ID * @param _clipboardID selected clipboard ID
* @param _data new buffer data * @param _data new buffer data
@ -27,7 +27,7 @@ public class ClipBoard {
public static void setSystem(ClipboardList clipboardID, String data) { public static void setSystem(ClipboardList clipboardID, String data) {
} }
/** /**
* @brief get the gale internal buffer of the curent clipboard. The end user can use it when he receive the event in * get the gale internal buffer of the curent clipboard. The end user can use it when he receive the event in
* the widget : @ref onEventClipboard == > we can nothe this function is the only one which permit it. * the widget : @ref onEventClipboard == > we can nothe this function is the only one which permit it.
* @note if we call this fuction withoutcallin @ref gale::context::clipBoard::Request, we only get the previous clipboard * @note if we call this fuction withoutcallin @ref gale::context::clipBoard::Request, we only get the previous clipboard
* @param _clipboardID selected clipboard ID * @param _clipboardID selected clipboard ID

View File

@ -28,7 +28,7 @@ public abstract class Context {
private static int countMemeCheck = 0; private static int countMemeCheck = 0;
/** /**
* @brief From everyware in the program, we can get the context inteface. * From everyware in the program, we can get the context inteface.
* @return current reference on the instance. * @return current reference on the instance.
*/ */
public static Context getContext() { public static Context getContext() {
@ -78,13 +78,13 @@ public abstract class Context {
// this.displayFps=true; // this.displayFps=true;
// } else if ( this.commandLine.get(iii) == "-h" // } else if ( this.commandLine.get(iii) == "-h"
// || this.commandLine.get(iii) == "--help" // || this.commandLine.get(iii) == "--help"
// || start_with(this.commandLine.get(iii), "--gale")) { // || startwith(this.commandLine.get(iii), "--gale")) {
// Log.print("gale - help : "); // Log.print("gale - help : ");
// Log.print(" --gale-fps"); // Log.print(" --gale-fps");
// Log.print(" Display the current fps of the display"); // Log.print(" Display the current fps of the display");
// Log.print(" -h/--help"); // Log.print(" -h/--help");
// Log.print(" Display this help"); // Log.print(" Display this help");
// if (start_with(this.commandLine.get(iii), "--gale")) { // if (startwith(this.commandLine.get(iii), "--gale")) {
// Log.error("gale unknow element in parameter: '" << this.commandLine.get(iii) << "'"); // Log.error("gale unknow element in parameter: '" << this.commandLine.get(iii) << "'");
// // remove parameter ... // // remove parameter ...
// } else { // } else {
@ -101,14 +101,14 @@ public abstract class Context {
Log.info("GALE v:" + Gale.getVersion()); Log.info("GALE v:" + Gale.getVersion());
forceOrientation(Orientation.screenAuto); forceOrientation(Orientation.screenAuto);
postAction((_context) -> { postAction((context) -> {
final Application appl = _context.getApplication(); final Application appl = context.getApplication();
if (appl == null) { if (appl == null) {
return; return;
} }
appl.onCreate(_context); appl.onCreate(context);
appl.onStart(_context); appl.onStart(context);
appl.onResume(_context); appl.onResume(context);
appl.canDraw = true; appl.canDraw = true;
}); });
@ -118,8 +118,8 @@ public abstract class Context {
} }
/** /**
* @brief Inform the Gui that we want to have a copy of the clipboard * Inform the Gui that we want to have a copy of the clipboard
* @param _clipboardID ID of the clipboard (STD/SELECTION) only apear here * @param clipboardID ID of the clipboard (STD/SELECTION) only apear here
*/ */
public void clipBoardGet(final ClipboardList clipboardID) { public void clipBoardGet(final ClipboardList clipboardID) {
// just transmit an event , we have the data in the system // just transmit an event , we have the data in the system
@ -127,21 +127,21 @@ public abstract class Context {
} }
/** /**
* @brief Inform the Gui that we are the new owner of the clipboard * Inform the Gui that we are the new owner of the clipboard
* @param _clipboardID ID of the clipboard (STD/SELECTION) only apear here * @param clipboardID ID of the clipboard (STD/SELECTION) only apear here
*/ */
public void clipBoardSet(final ClipboardList clipboardID) { public void clipBoardSet(final ClipboardList clipboardID) {
// nothing to do, data is already copyed in the GALE clipborad center // nothing to do, data is already copyed in the GALE clipborad center
} }
/** /**
* @brief force the screen orientation (availlable on portable elements ... * force the screen orientation (availlable on portable elements ...
* @param _orientation Selected orientation. * @param orientation Selected orientation.
*/ */
public void forceOrientation(final Orientation orientation) {} public void forceOrientation(final Orientation orientation) {}
/** /**
* @brief Redraw all the windows * Redraw all the windows
*/ */
public void forceRedrawAll() { public void forceRedrawAll() {
if (this.application == null) { if (this.application == null) {
@ -180,7 +180,7 @@ public abstract class Context {
} }
/** /**
* @brief The Application request the current position of the windows. * The Application request the current position of the windows.
* @return Turrent position of the Windows. * @return Turrent position of the Windows.
*/ */
public Vector2f getPos() { public Vector2f getPos() {
@ -192,7 +192,7 @@ public abstract class Context {
} }
/** /**
* @brief get the current windows size * get the current windows size
* @return the current size ... * @return the current size ...
*/ */
public Vector2f getSize() { public Vector2f getSize() {
@ -200,20 +200,20 @@ public abstract class Context {
} }
/** /**
* @brief get all Keyboard event from the X system (like many time use of META) * get all Keyboard event from the X system (like many time use of META)
* @param _status "true" if all the event will be get, false if we want only ours. * @param status "true" if all the event will be get, false if we want only ours.
*/ */
public void grabKeyboardEvents(final boolean status) {} public void grabKeyboardEvents(final boolean status) {}
/** /**
* @brief get all Mouse/Touch events from the X system * get all Mouse/Touch events from the X system
* @param _status "true" if all the event will be get, false if we want only ours. * @param status "true" if all the event will be get, false if we want only ours.
* @param _forcedPosition the position where the mouse might be reset at every events ... * @param forcedPosition the position where the mouse might be reset at every events ...
*/ */
public void grabPointerEvents(final boolean status, final Vector2f forcedPosition) {} public void grabPointerEvents(final boolean status, final Vector2f forcedPosition) {}
/** /**
* @brief The Application request that the Windows will be Hidden. * The Application request that the Windows will be Hidden.
*/ */
public void hide() { public void hide() {
Log.info("hide: NOT implemented ..."); Log.info("hide: NOT implemented ...");
@ -224,14 +224,14 @@ public abstract class Context {
} }
/** /**
* @brief Hide the virtal keyboard (for touch system only) * Hide the virtal keyboard (for touch system only)
*/ */
public void keyboardHide() { public void keyboardHide() {
Log.info("keyboardHide: NOT implemented ..."); Log.info("keyboardHide: NOT implemented ...");
} }
/** /**
* @brief display the virtal keyboard (for touch system only) * display the virtal keyboard (for touch system only)
*/ */
public void keyboardShow() { public void keyboardShow() {
Log.info("keyboardShow: NOT implemented ..."); Log.info("keyboardShow: NOT implemented ...");
@ -242,13 +242,13 @@ public abstract class Context {
} }
/** /**
* @brief Open an URL on an eternal brother. * Open an URL on an eternal brother.
* @param _url URL to open. * @param url URL to open.
*/ */
public void openURL(final String url) {} public void openURL(final String url) {}
/** /**
* @brief The current context is set in background (framerate is slowing down (max fps)/5 # 4fps) * The current context is set in background (framerate is slowing down (max fps)/5 # 4fps)
*/ */
public void operatingSystemBackground() { public void operatingSystemBackground() {
// set the current interface : // set the current interface :
@ -262,8 +262,8 @@ public abstract class Context {
} }
/** /**
* @brief Call by the OS when a clipboard arrive to US (previously requested by a widget) * Call by the OS when a clipboard arrive to US (previously requested by a widget)
* @param Id of the clipboard * @param clipboardID of the clipboard
*/ */
public void operatingSystemClipBoardArrive(final ClipboardList clipboardID) { public void operatingSystemClipBoardArrive(final ClipboardList clipboardID) {
postAction((context) -> { postAction((context) -> {
@ -297,7 +297,7 @@ public abstract class Context {
OpenGL.threadHasContext(); OpenGL.threadHasContext();
OpenGL.resetFlagState(); OpenGL.resetFlagState();
// process the events // process the events
if (this.displayFps == true) { if (this.displayFps) {
this.fpsSystemEvent.tic(); this.fpsSystemEvent.tic();
} }
boolean needRedraw = false; boolean needRedraw = false;
@ -333,52 +333,52 @@ public abstract class Context {
{ {
// Lock openGl context: // Lock openGl context:
OpenGL.lock(); OpenGL.lock();
if (this.displayFps == true) { if (this.displayFps) {
this.fpsSystemContext.tic(); this.fpsSystemContext.tic();
} }
if (needRedraw = true || displayEveryTime == true) { if (needRedraw || displayEveryTime) {
//Log.debug(" ==> real Draw"); //Log.debug(" ==> real Draw");
lockContext(); lockContext();
this.resourceManager.updateContext(); this.resourceManager.updateContext();
unLockContext(); unLockContext();
if (this.displayFps == true) { if (this.displayFps) {
this.fpsSystemContext.incrementCounter(); this.fpsSystemContext.incrementCounter();
} }
} }
if (this.displayFps == true) { if (this.displayFps) {
this.fpsSystemContext.toc(); this.fpsSystemContext.toc();
this.fpsSystem.tic(); this.fpsSystem.tic();
} }
if (this.application != null) { if (this.application != null) {
if (needRedraw == true || displayEveryTime == true) { if (needRedraw || displayEveryTime) {
this.fpsSystem.incrementCounter(); this.fpsSystem.incrementCounter();
// set the current interface : // set the current interface :
lockContext(); lockContext();
if (this.application.canDraw == true) { if (this.application.canDraw) {
this.application.onDraw(this); this.application.onDraw(this);
} }
unLockContext(); unLockContext();
hasDisplayDone = true; hasDisplayDone = true;
} }
} }
if (this.displayFps == true) { if (this.displayFps) {
this.fpsSystem.toc(); this.fpsSystem.toc();
this.fpsFlush.tic(); this.fpsFlush.tic();
} }
if (hasDisplayDone == true) { if (hasDisplayDone) {
//Log.info("lklklklklk " << _displayEveryTime); //Log.info("lklklklklk " << displayEveryTime);
if (this.displayFps == true) { if (this.displayFps) {
this.fpsFlush.incrementCounter(); this.fpsFlush.incrementCounter();
} }
OpenGL.flush(); OpenGL.flush();
} }
if (this.displayFps == true) { if (this.displayFps) {
this.fpsFlush.toc(); this.fpsFlush.toc();
} }
// release open GL Context // release open GL Context
OpenGL.unLock(); OpenGL.unLock();
} }
if (this.displayFps == true) { if (this.displayFps) {
this.fpsSystemEvent.draw(); this.fpsSystemEvent.draw();
this.fpsSystemContext.draw(); this.fpsSystemContext.draw();
this.fpsSystem.draw(); this.fpsSystem.draw();
@ -403,7 +403,7 @@ public abstract class Context {
}; };
/** /**
* @brief The current context is set in foreground (framerate is maximum speed) * The current context is set in foreground (framerate is maximum speed)
*/ */
public void operatingSystemForeground() { public void operatingSystemForeground() {
// set the current interface : // set the current interface :
@ -418,35 +418,35 @@ public abstract class Context {
} }
/** /**
* @brief The OS inform that the Windows is now Hidden. * The OS inform that the Windows is now Hidden.
*/ */
public void operatingSystemHide() { public void operatingSystemHide() {
postAction((context) -> { postAction((context) -> {
/* /*
Application> appl = _context.getApplication(); Application> appl = context.getApplication();
if (appl == null) { if (appl == null) {
return; return;
} }
appl.onKeyboard(_special, appl.onKeyboard(special,
_type, type,
_char, char,
_state); state);
*/ */
Log.todo("HIDE ... "); Log.todo("HIDE ... ");
}); });
}; };
/** /**
* @brief The OS inform that the current windows has change his position. * The OS inform that the current windows has change his position.
* @param _pos New position of the Windows. * @param pos New position of the Windows.
*/ */
public void operatingSystemMove(final Vector2f _pos) { public void operatingSystemMove(final Vector2f pos) {
if (this.windowsPos.isEqual(_pos)) { if (this.windowsPos.isEqual(pos)) {
return; return;
} }
postAction((context) -> { postAction((context) -> {
Log.debug("Receive MSG : THREAD_MOVE : " + context.windowsPos + " ==> " + _pos); Log.debug("Receive MSG : THREADMOVE : " + context.windowsPos + " ==> " + pos);
context.windowsPos = _pos; context.windowsPos = pos;
final Application appl = context.getApplication(); final Application appl = context.getApplication();
if (appl == null) { if (appl == null) {
return; return;
@ -456,26 +456,26 @@ public abstract class Context {
} }
/** /**
* @brief The OS inform that the openGL ext has been destroy == > use to automaticly reload the texture and other thinks ... * The OS inform that the openGL ext has been destroy == > use to automaticly reload the texture and other thinks ...
*/ */
public void operatingSystemOpenGlContextDestroy() { public void operatingSystemOpenGlContextDestroy() {
this.resourceManager.contextHasBeenDestroyed(); this.resourceManager.contextHasBeenDestroyed();
}; };
/** /**
* @brief The OS inform that the current windows has change his size. * The OS inform that the current windows has change his size.
* @param _size new size of the windows. * @param size new size of the windows.
*/ */
public void operatingSystemResize(final Vector2f _size) { public void operatingSystemResize(final Vector2f size) {
if (this.windowsSize == _size) { if (this.windowsSize == size) {
return; return;
} }
// TODO Better in the thread ... ==> but generate some init error ... // TODO Better in the thread ... ==> but generate some init error ...
//gale::Dimension::setPixelWindowsSize(_size); //gale::Dimension::setPixelWindowsSize(size);
postAction((context) -> { postAction((context) -> {
Log.debug("Receive MSG : THREAD_RESIZE : " + context.windowsSize + " ==> " + _size); Log.debug("Receive MSG : THREADRESIZE : " + context.windowsSize + " ==> " + size);
context.windowsSize = _size; context.windowsSize = size;
//gale::Dimension::setPixelWindowsSize(_context.windowsSize); //gale::Dimension::setPixelWindowsSize(context.windowsSize);
final Application tmpAppl = context.getApplication(); final Application tmpAppl = context.getApplication();
if (tmpAppl != null) { if (tmpAppl != null) {
tmpAppl.onResize(context.windowsSize); tmpAppl.onResize(context.windowsSize);
@ -486,7 +486,7 @@ public abstract class Context {
}; };
/** /**
* @brief The current context is resumed * The current context is resumed
*/ */
public void operatingSystemResume() { public void operatingSystemResume() {
// set the current interface : // set the current interface :
@ -517,11 +517,11 @@ public abstract class Context {
public void operatingSystemsetKeyboard(final KeySpecial special, final KeyKeyboard type, final KeyStatus state, final boolean isARepeateKey, final Character charValue) { public void operatingSystemsetKeyboard(final KeySpecial special, final KeyKeyboard type, final KeyStatus state, final boolean isARepeateKey, final Character charValue) {
KeyStatus tmpState = state; KeyStatus tmpState = state;
if (isARepeateKey == true) { if (isARepeateKey) {
if (tmpState == KeyStatus.down) { if (tmpState == KeyStatus.down) {
tmpState = KeyStatus.downRepeate; tmpState = KeyStatus.downRepeat;
} else { } else {
tmpState = KeyStatus.upRepeate; tmpState = KeyStatus.upRepeat;
} }
} }
operatingSystemsetKeyboard2(special, type, state, charValue); operatingSystemsetKeyboard2(special, type, state, charValue);
@ -538,26 +538,26 @@ public abstract class Context {
} }
/** /**
* @brief The OS inform that the Windows is now visible. * The OS inform that the Windows is now visible.
*/ */
public void operatingSystemShow() { public void operatingSystemShow() {
postAction((context) -> { postAction((context) -> {
/* /*
Application> appl = _context.getApplication(); Application> appl = context.getApplication();
if (appl == null) { if (appl == null) {
return; return;
} }
appl.onKeyboard(_special, appl.onKeyboard(special,
_type, type,
_char, char,
_state); state);
*/ */
Log.todo("SHOW ... "); Log.todo("SHOW ... ");
}); });
}; };
/** /**
* @brief The OS Inform that the Window has been killed * The OS Inform that the Window has been killed
*/ */
public void operatingSystemStop() { public void operatingSystemStop() {
// set the current interface : // set the current interface :
@ -573,7 +573,7 @@ public abstract class Context {
} }
/** /**
* @brief The current context is suspended * The current context is suspended
*/ */
public void operatingSystemSuspend() { public void operatingSystemSuspend() {
// set the current interface : // set the current interface :
@ -595,7 +595,7 @@ public abstract class Context {
} }
/** /**
* @brief Processing all the event arrived ... (commoly called in draw function) * Processing all the event arrived ... (commoly called in draw function)
*/ */
public void processEvents() { public void processEvents() {
int nbEvent = 0; int nbEvent = 0;
@ -648,63 +648,63 @@ public abstract class Context {
// } // }
public void requestUpdateSize() { public void requestUpdateSize() {
postAction((context) -> { postAction((context) -> {
//Log.debug("Receive MSG : THREAD_RESIZE"); //Log.debug("Receive MSG : THREADRESIZE");
context.forceRedrawAll(); context.forceRedrawAll();
}); });
} }
/** /**
* @brief reset event management for the IO like Input ou Mouse or keyborad * reset event management for the IO like Input ou Mouse or keyborad
*/ */
public void resetIOEvent() { public void resetIOEvent() {
// TODO this.input.newLayerSet(); // TODO this.input.newLayerSet();
} }
/** /**
* @brief Internal API to run the processing of the event loop ... * Internal API to run the processing of the event loop ...
* @return The Exit value of the program * @return The Exit value of the program
* @note INTERNAL API * @note INTERNAL API
*/ */
public abstract int run(); public abstract int run();
/** /**
* @brief set the cursor display type. * set the cursor display type.
* @param NewCursor selected new cursor. * @param newCursor selected new cursor.
*/ */
public void setCursor(final Cursor newCursor) {} public void setCursor(final Cursor newCursor) {}
/** /**
* @brief The application request a change of his current size force the fullscreen mode. * The application request a change of his current size force the fullscreen mode.
* @param _status status of the fullscreen mode. * @param status status of the fullscreen mode.
*/ */
public void setFullScreen(final boolean status) { public void setFullScreen(final boolean status) {
this.fullscreen = status; this.fullscreen = status;
} }
/** /**
* @brief set the Icon of the program * set the Icon of the program
* @param _inputFile new filename icon of the current program. * @param inputFile new filename icon of the current program.
*/ */
public void setIcon(final Uri inputFile) {}; public void setIcon(final Uri inputFile) {};
/** /**
* @brief The Application request that the current windows will change his position. * The Application request that the current windows will change his position.
* @param _pos New position of the Windows requested. * @param pos New position of the Windows requested.
*/ */
public void setPos(final Vector2f pos) { public void setPos(final Vector2f pos) {
Log.info("setPos: NOT implemented ..."); Log.info("setPos: NOT implemented ...");
}; };
/** /**
* @brief The application request a change of his current size. * The application request a change of his current size.
* @param _size new Requested size of the windows. * @param size new Requested size of the windows.
*/ */
public void setSize(final Vector2f size) { public void setSize(final Vector2f size) {
Log.info("setSize: NOT implemented ..."); Log.info("setSize: NOT implemented ...");
} }
/** /**
* @brief set the new title of the windows * set the new title of the windows
* @param title New desired title * @param title New desired title
*/ */
public void setTitle(final String title) { public void setTitle(final String title) {
@ -712,20 +712,20 @@ public abstract class Context {
}; };
/** /**
* @brief Enable or Disable the decoration on the Windows (availlable only on Desktop) * Enable or Disable the decoration on the Windows (availlable only on Desktop)
* @param _status "true" to enable decoration / false otherwise * @param status "true" to enable decoration / false otherwise
*/ */
public void setWindowsDecoration(final boolean status) {}; public void setWindowsDecoration(final boolean status) {};
/** /**
* @brief The Application request that the Windows will be visible. * The Application request that the Windows will be visible.
*/ */
public void show() { public void show() {
Log.info("show: NOT implemented ..."); Log.info("show: NOT implemented ...");
}; };
/** /**
* @brief StartProcessing (2nd thread). * StartProcessing (2nd thread).
* @note to call when all the Context is started * @note to call when all the Context is started
*/ */
public void start2ndThreadProcessing() { public void start2ndThreadProcessing() {
@ -743,7 +743,7 @@ public abstract class Context {
}; };
/** /**
* @brief The application request that the Window will be killed * The application request that the Window will be killed
*/ */
public void stop() { public void stop() {
Log.warning("stop: NOT implemented for this platform..."); Log.warning("stop: NOT implemented for this platform...");

File diff suppressed because it is too large Load Diff

View File

@ -13,209 +13,209 @@ public class KeySpecial {
private boolean valueNumLock = false; private boolean valueNumLock = false;
private boolean valueInsert = false; private boolean valueInsert = false;
/** /**
* @brief Main ructor * Main ructor
*/ */
public KeySpecial() { public KeySpecial() {
} }
/** /**
* @brief get the current CapLock Status * get the current CapLock Status
* @return The CapLock value * @return The CapLock value
*/ */
public boolean getCapsLock() { public boolean getCapsLock() {
return valueCapLock; return valueCapLock;
} }
/** /**
* @brief set the current CapLock Status * set the current CapLock Status
* @param value The new CapLock value * @param value The new CapLock value
*/ */
public void setCapsLock(boolean value) { public void setCapsLock(boolean value) {
valueCapLock = value; valueCapLock = value;
} }
/** /**
* @brief Get the current Shift key status * Get the current Shift key status
* @return The Shift value * @return The Shift value
*/ */
public boolean getShift() { public boolean getShift() {
return valueShiftLeft || valueShiftRight; return valueShiftLeft || valueShiftRight;
} }
/** /**
* @brief Get the current Shift left key status * Get the current Shift left key status
* @return The Shift value * @return The Shift value
*/ */
public boolean getShiftLeft() { public boolean getShiftLeft() {
return valueShiftLeft; return valueShiftLeft;
} }
/** /**
* @brief Get the current Shift right key status * Get the current Shift right key status
* @return The Shift value * @return The Shift value
*/ */
public boolean getShiftRight() { public boolean getShiftRight() {
return valueShiftRight; return valueShiftRight;
} }
/** /**
* @brief Set the current Shift left key status * Set the current Shift left key status
* @param value The new Shift value * @param value The new Shift value
*/ */
public void setShiftLeft(boolean value) { public void setShiftLeft(boolean value) {
valueShiftLeft = value; valueShiftLeft = value;
} }
/** /**
* @brief Set the current Shift right key status * Set the current Shift right key status
* @param value The new Shift value * @param value The new Shift value
*/ */
public void setShiftRight(boolean value) { public void setShiftRight(boolean value) {
valueShiftRight = value; valueShiftRight = value;
} }
/** /**
* @brief Get the Current Control key status * Get the Current Control key status
* @return The Control value * @return The Control value
*/ */
public boolean getCtrl() { public boolean getCtrl() {
return valueCtrlLeft || valueCtrlRight; return valueCtrlLeft || valueCtrlRight;
} }
/** /**
* @brief Get the Current Control left key status * Get the Current Control left key status
* @return The Control value * @return The Control value
*/ */
public boolean getCtrlLeft() { public boolean getCtrlLeft() {
return valueCtrlLeft; return valueCtrlLeft;
} }
/** /**
* @brief Get the Current Control right key status * Get the Current Control right key status
* @return The Control value * @return The Control value
*/ */
public boolean getCtrlRight() { public boolean getCtrlRight() {
return valueCtrlRight; return valueCtrlRight;
} }
/** /**
* @brief Set the Current Control left key status * Set the Current Control left key status
* @param value The new Control value * @param value The new Control value
*/ */
public void setCtrlLeft(boolean value){ public void setCtrlLeft(boolean value){
valueCtrlLeft = value; valueCtrlLeft = value;
} }
/** /**
* @brief Set the Current Control right key status * Set the Current Control right key status
* @param value The new Control value * @param value The new Control value
*/ */
public void setCtrlRight(boolean value) { public void setCtrlRight(boolean value) {
valueCtrlRight = value; valueCtrlRight = value;
} }
/** /**
* @brief Get the current Meta key status (also named windows or apple key) * Get the current Meta key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...) * @return The Meta value (name Windows key, apple key, command key ...)
*/ */
public boolean getMeta() { public boolean getMeta() {
return valueMetaLeft || valueMetaRight; return valueMetaLeft || valueMetaRight;
} }
/** /**
* @brief Get the current Meta left key status (also named windows or apple key) * Get the current Meta left key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...) * @return The Meta value (name Windows key, apple key, command key ...)
*/ */
public boolean getMetaLeft() { public boolean getMetaLeft() {
return valueMetaLeft; return valueMetaLeft;
} }
/** /**
* @brief Get the current Meta right key status (also named windows or apple key) * Get the current Meta right key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...) * @return The Meta value (name Windows key, apple key, command key ...)
*/ */
public boolean getMetaRight() { public boolean getMetaRight() {
return valueMetaRight; return valueMetaRight;
} }
/** /**
* @brief Set the current Meta left key status (also named windows or apple key) * Set the current Meta left key status (also named windows or apple key)
* @param value The new Meta value (name Windows key, apple key, command key ...) * @param value The new Meta value (name Windows key, apple key, command key ...)
*/ */
public void setMetaLeft(boolean value) { public void setMetaLeft(boolean value) {
valueMetaLeft = value; valueMetaLeft = value;
} }
/** /**
* @brief Set the current Meta right key status (also named windows or apple key) * Set the current Meta right key status (also named windows or apple key)
* @param value The new Meta value (name Windows key, apple key, command key ...) * @param value The new Meta value (name Windows key, apple key, command key ...)
*/ */
public void setMetaRight(boolean value) { public void setMetaRight(boolean value) {
valueMetaRight = value; valueMetaRight = value;
} }
/** /**
* @brief Get the current Alt key status * Get the current Alt key status
* @return The Alt value * @return The Alt value
*/ */
public boolean getAlt() { public boolean getAlt() {
return valueAltLeft || valueAltRight; return valueAltLeft || valueAltRight;
} }
/** /**
* @brief Get the current Alt left key status * Get the current Alt left key status
* @return The Alt value * @return The Alt value
*/ */
public boolean getAltLeft() { public boolean getAltLeft() {
return valueAltLeft; return valueAltLeft;
} }
/** /**
* @brief Get the current Alt right key status (alt-gr) * Get the current Alt right key status (alt-gr)
* @return The Alt value * @return The Alt value
*/ */
public boolean getAltRight() { public boolean getAltRight() {
return valueAltRight; return valueAltRight;
} }
/** /**
* @brief Set the current Alt left key status * Set the current Alt left key status
* @param value The new Alt value * @param value The new Alt value
*/ */
public void setAltLeft(boolean value) { public void setAltLeft(boolean value) {
valueAltLeft = value; valueAltLeft = value;
} }
/** /**
* @brief Set the current Alt right key status (alt-gr) * Set the current Alt right key status (alt-gr)
* @param value The new Alt value * @param value The new Alt value
*/ */
public void setAltRight(boolean value) { public void setAltRight(boolean value) {
valueAltRight = value; valueAltRight = value;
} }
/** /**
* @brief Get the current Alt-Gr key status * Get the current Alt-Gr key status
* @return The Alt-gr value (does not exist on MacOs) * @return The Alt-gr value (does not exist on MacOs)
*/ */
public boolean getAltGr() { public boolean getAltGr() {
return getAltRight(); return getAltRight();
} }
/** /**
* @brief Set the current Alt-Gr key status * Set the current Alt-Gr key status
* @param value The new Alt-gr value (does not exist on MacOs) * @param value The new Alt-gr value (does not exist on MacOs)
*/ */
public void setAltGr(boolean value) { public void setAltGr(boolean value) {
setAltRight(value); setAltRight(value);
} }
/** /**
* @brief Get the current Ver-num key status * Get the current Ver-num key status
* @return The Numerical Lock value * @return The Numerical Lock value
*/ */
public boolean getNumLock() { public boolean getNumLock() {
return valueNumLock; return valueNumLock;
} }
/** /**
* @brief Set the current Ver-num key status * Set the current Ver-num key status
* @param value The new Numerical Lock value * @param value The new Numerical Lock value
*/ */
public void setNumLock(boolean value) { public void setNumLock(boolean value) {
valueNumLock = value; valueNumLock = value;
} }
/** /**
* @brief Get the current Intert key status * Get the current Intert key status
* @return The Insert value * @return The Insert value
*/ */
public boolean getInsert() { public boolean getInsert() {
return valueInsert; return valueInsert;
} }
/** /**
* @brief Set the current Intert key status * Set the current Intert key status
* @param value The new Insert value * @param value The new Insert value
*/ */
public void setInsert(boolean value) { public void setInsert(boolean value) {
valueInsert = value; valueInsert = value;
} }
/** /**
* @brief Update the internal value with the input moving key. * Update the internal value with the input moving key.
* @param move Moving key. * @param move Moving key.
* @param isDown The key is pressed or not. * @param isDown The key is pressed or not.
*/ */
@ -259,7 +259,7 @@ public class KeySpecial {
} }
} }
/** /**
* @brief Get the value with the input moving key. * Get the value with the input moving key.
* @param move Moving key. * @param move Moving key.
* @return true The key is pressed. * @return true The key is pressed.
* @return false The key is released. * @return false The key is released.

View File

@ -1,37 +1,32 @@
package org.atriasoft.gale.key; package org.atriasoft.gale.key;
public enum KeyStatus { public enum KeyStatus {
unknow, unknown,
down, // availlable on Keyboard too down, // available on Keyboard too
downRepeate, // availlable on Keyboard too: the down event us in repeate cycle downRepeat, // available on Keyboard too: the down event us in repeate cycle
move, move,
pressSingle, pressSingle,
pressDouble, pressDouble,
pressTriple, pressTriple,
pressQuad, pressQuad,
pressQuinte, pressQuint,
up, // availlable on Keyboard too up, // available on Keyboard too
upRepeate, // availlable on Keyboard too: the up event us in repeate cycle upRepeat, // available on Keyboard too: the up event us in repeate cycle
upAfter, // mouse input & finger input this appear after the single event (depending on some case...) upAfter, // mouse input & finger input this appear after the single event (depending on some case...)
enter, enter,
leave, leave,
abort, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has lost the events) abort, // Appear when an event is tranfert betwwen widgets (the widget which receive this has lost the events)
transfert // Appeare when an event is tranfert betwwen widgets (the widget which receive this has receive the transfert of the event) transfer // Appear when an event is tranfert betwwen widgets (the widget which receive this has receive the transfert of the event)
; ;
public static KeyStatus pressCount(final int i) { public static KeyStatus pressCount(final int i) {
switch (i) { return switch (i) {
case 1: case 1 -> pressSingle;
return pressSingle; case 2 -> pressDouble;
case 2: case 3 -> pressTriple;
return pressDouble; case 4 -> pressQuad;
case 3: case 5 -> pressQuint;
return pressTriple; default -> unknown;
case 4: };
return pressQuad;
case 5:
return pressQuinte;
}
return unknow;
} }
} }

View File

@ -10,7 +10,7 @@ public abstract class Resource {
private static int idGenerated = 10; private static int idGenerated = 10;
/** /**
* @brief Get the current resource Manager * Get the current resource Manager
*/ */
protected static ResourceManager getManager() { protected static ResourceManager getManager() {
return Context.getContext().getResourcesManager(); return Context.getContext().getResourcesManager();
@ -22,7 +22,7 @@ public abstract class Resource {
protected String name = NO_NAME_RESOURCE; //!< name of the resource ... protected String name = NO_NAME_RESOURCE; //!< name of the resource ...
/** /**
* @brief generic protected contructor (use factory to create this class) * generic protected contructor (use factory to create this class)
*/ */
protected Resource() { protected Resource() {
this.uid = idGenerated++; this.uid = idGenerated++;
@ -50,7 +50,7 @@ public abstract class Resource {
} }
/** /**
* @brief get the resource name * get the resource name
* @return The requested name * @return The requested name
*/ */
public String getName() { public String getName() {
@ -58,7 +58,7 @@ public abstract class Resource {
} }
/** /**
* @brief Get the current resource level; * Get the current resource level;
* @return value in [0..5] * @return value in [0..5]
*/ */
public int getResourceLevel() { public int getResourceLevel() {
@ -77,21 +77,21 @@ public abstract class Resource {
} }
/** /**
* @brief User request the reload of all resources (usefull when the file depend on DATA:GUI:xxx ... * User request the reload of all resources (usefull when the file depend on DATA:GUI:xxx ...
*/ */
public void reload() { public void reload() {
Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)"); Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
}; };
/** /**
* @brief The current OpenGl context is removing ==> remove yout own system data * The current OpenGl context is removing ==> remove yout own system data
*/ */
public void removeContext() { public void removeContext() {
Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)"); Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
} }
/** /**
* @brief The notification of the Context removing is too late, we have no more acces on the OpenGl context (thank you Android). * The notification of the Context removing is too late, we have no more acces on the OpenGl context (thank you Android).
* Just update your internal state * Just update your internal state
*/ */
public void removeContextToLate() { public void removeContextToLate() {
@ -99,7 +99,7 @@ public abstract class Resource {
} }
/** /**
* @brief get the resource name * get the resource name
* @param name The name to set. * @param name The name to set.
*/ */
public void setName(final String name) { public void setName(final String name) {
@ -107,7 +107,7 @@ public abstract class Resource {
} }
/** /**
* @brief Call when need to send data on the harware (openGL) * Call when need to send data on the harware (openGL)
* @note This is done asynchronously with the create of the Resource. * @note This is done asynchronously with the create of the Resource.
* @return true The context is updated * @return true The context is updated
* @return false The context is not updated * @return false The context is not updated

View File

@ -30,7 +30,7 @@ public class ResourceColored3DObject extends Resource {
super(); super();
// get the shader resource : // get the shader resource :
this.oGLPosition = 0; this.oGLPosition = 0;
this.program = ResourceProgram.create(new Uri("DATA_EGE", "simple3D.vert"), new Uri("DATA_EGE", "simple3D.frag")); this.program = ResourceProgram.create(new Uri("DATA", "simple3D.vert", "gale"), new Uri("DATA", "simple3D.frag", "gale"));
if (this.program != null) { if (this.program != null) {
this.oGLMatrixTransformation = this.program.getUniform("in_matrixTransformation"); this.oGLMatrixTransformation = this.program.getUniform("in_matrixTransformation");
this.oGLMatrixProjection = this.program.getUniform("in_matrixProjection"); this.oGLMatrixProjection = this.program.getUniform("in_matrixProjection");
@ -49,9 +49,9 @@ public class ResourceColored3DObject extends Resource {
private float[] convertInFloat(final List<Vector3f> data) { private float[] convertInFloat(final List<Vector3f> data) {
final float[] out = new float[data.size() * 3]; final float[] out = new float[data.size() * 3];
for (int iii = 0; iii < data.size(); iii++) { for (int iii = 0; iii < data.size(); iii++) {
out[iii * 3] = data.get(iii).x; out[iii * 3] = data.get(iii).x();
out[iii * 3 + 1] = data.get(iii).y; out[iii * 3 + 1] = data.get(iii).y();
out[iii * 3 + 2] = data.get(iii).z; out[iii * 3 + 2] = data.get(iii).z();
} }
return out; return out;
} }
@ -64,9 +64,9 @@ public class ResourceColored3DObject extends Resource {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
if (true == depthtest) { if (depthtest) {
OpenGL.enable(OpenGL.Flag.flag_depthTest); OpenGL.enable(OpenGL.Flag.flag_depthTest);
if (false == updateDepthBuffer) { if (!updateDepthBuffer) {
OpenGL.setDeathMask(false); OpenGL.setDeathMask(false);
} }
} }
@ -74,7 +74,7 @@ public class ResourceColored3DObject extends Resource {
this.program.use(); this.program.use();
final Matrix4f projectionMatrix = OpenGL.getMatrix(); final Matrix4f projectionMatrix = OpenGL.getMatrix();
final Matrix4f viewMatrix = OpenGL.getCameraMatrix(); final Matrix4f viewMatrix = OpenGL.getCameraMatrix();
final Matrix4f transformationMatrix = Matrix4f.identity(); final Matrix4f transformationMatrix = Matrix4f.IDENTITY;
this.program.uniformMatrix(this.oGLMatrixView, viewMatrix); this.program.uniformMatrix(this.oGLMatrixView, viewMatrix);
this.program.uniformMatrix(this.oGLMatrixProjection, projectionMatrix); this.program.uniformMatrix(this.oGLMatrixProjection, projectionMatrix);
this.program.uniformMatrix(this.oGLMatrixTransformation, transformationMatrix); this.program.uniformMatrix(this.oGLMatrixTransformation, transformationMatrix);
@ -83,20 +83,20 @@ public class ResourceColored3DObject extends Resource {
// position : // position :
final FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices)); final FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices));
this.program.sendAttribute(this.oGLPosition, 3, buffer, 3); this.program.sendAttribute(this.oGLPosition, 3, buffer, 3);
if (color.a < 1.0f) { if (color.a() < 1.0f) {
OpenGL.enable(OpenGL.Flag.flag_blend); OpenGL.enable(OpenGL.Flag.flag_blend);
} }
// Request the draw of the elements: // Request the draw of the elements:
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size()); OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size());
if (color.a < 1.0f) { if (color.a() < 1.0f) {
OpenGL.disable(OpenGL.Flag.flag_blend); OpenGL.disable(OpenGL.Flag.flag_blend);
} }
this.program.unUse(); this.program.unUse();
// Request the draw od the elements: // Request the draw od the elements:
//glDrawArrays(oGLLINES, 0, vertices.size()); //glDrawArrays(oGLLINES, 0, vertices.size());
//this.oGLprogram.UnUse(); //this.oGLprogram.UnUse();
if (true == depthtest) { if (depthtest) {
if (false == updateDepthBuffer) { if (!updateDepthBuffer) {
OpenGL.setDeathMask(true); OpenGL.setDeathMask(true);
} }
OpenGL.disable(OpenGL.Flag.flag_depthTest); OpenGL.disable(OpenGL.Flag.flag_depthTest);
@ -111,9 +111,9 @@ public class ResourceColored3DObject extends Resource {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
if (true == depthtest) { if (depthtest) {
OpenGL.enable(OpenGL.Flag.flag_depthTest); OpenGL.enable(OpenGL.Flag.flag_depthTest);
if (false == updateDepthBuffer) { if (!updateDepthBuffer) {
OpenGL.setDeathMask(false); OpenGL.setDeathMask(false);
} }
} }
@ -131,17 +131,17 @@ public class ResourceColored3DObject extends Resource {
// color : // color :
//Log.info("color= " + color + " " + this.oGLPosition); //Log.info("color= " + color + " " + this.oGLPosition);
this.program.uniformColor(this.oGLColor, color); this.program.uniformColor(this.oGLColor, color);
if (color.a < 1.0f) { if (color.a() < 1.0f) {
OpenGL.enable(OpenGL.Flag.flag_blend); OpenGL.enable(OpenGL.Flag.flag_blend);
} }
// Request the draw of the elements: // Request the draw of the elements:
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size()); OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size());
if (color.a < 1.0f) { if (color.a() < 1.0f) {
OpenGL.disable(OpenGL.Flag.flag_blend); OpenGL.disable(OpenGL.Flag.flag_blend);
} }
this.program.unUse(); this.program.unUse();
if (true == depthtest) { if (depthtest) {
if (false == updateDepthBuffer) { if (!updateDepthBuffer) {
OpenGL.setDeathMask(true); OpenGL.setDeathMask(true);
} }
OpenGL.disable(OpenGL.Flag.flag_depthTest); OpenGL.disable(OpenGL.Flag.flag_depthTest);
@ -286,41 +286,41 @@ public class ResourceColored3DObject extends Resource {
public void drawCubeLine(final Vector3f min, final Vector3f max, final Color color, final Matrix4f transformationMatrix, final boolean updateDepthBuffer, final boolean depthtest) { public void drawCubeLine(final Vector3f min, final Vector3f max, final Color color, final Matrix4f transformationMatrix, final boolean updateDepthBuffer, final boolean depthtest) {
final List<Vector3f> vertices = new ArrayList<>(); final List<Vector3f> vertices = new ArrayList<>();
vertices.add(new Vector3f(min.x, min.y, min.z)); vertices.add(new Vector3f(min.x(), min.y(), min.z()));
vertices.add(new Vector3f(max.x, min.y, min.z)); vertices.add(new Vector3f(max.x(), min.y(), min.z()));
vertices.add(new Vector3f(max.x, min.y, min.z)); vertices.add(new Vector3f(max.x(), min.y(), min.z()));
vertices.add(new Vector3f(max.x, min.y, max.z)); vertices.add(new Vector3f(max.x(), min.y(), max.z()));
vertices.add(new Vector3f(max.x, min.y, max.z)); vertices.add(new Vector3f(max.x(), min.y(), max.z()));
vertices.add(new Vector3f(min.x, min.y, max.z)); vertices.add(new Vector3f(min.x(), min.y(), max.z()));
vertices.add(new Vector3f(min.x, min.y, max.z)); vertices.add(new Vector3f(min.x(), min.y(), max.z()));
vertices.add(new Vector3f(min.x, min.y, min.z)); vertices.add(new Vector3f(min.x(), min.y(), min.z()));
vertices.add(new Vector3f(min.x, max.y, min.z)); vertices.add(new Vector3f(min.x(), max.y(), min.z()));
vertices.add(new Vector3f(max.x, max.y, min.z)); vertices.add(new Vector3f(max.x(), max.y(), min.z()));
vertices.add(new Vector3f(max.x, max.y, min.z)); vertices.add(new Vector3f(max.x(), max.y(), min.z()));
vertices.add(new Vector3f(max.x, max.y, max.z)); vertices.add(new Vector3f(max.x(), max.y(), max.z()));
vertices.add(new Vector3f(max.x, max.y, max.z)); vertices.add(new Vector3f(max.x(), max.y(), max.z()));
vertices.add(new Vector3f(min.x, max.y, max.z)); vertices.add(new Vector3f(min.x(), max.y(), max.z()));
vertices.add(new Vector3f(min.x, max.y, max.z)); vertices.add(new Vector3f(min.x(), max.y(), max.z()));
vertices.add(new Vector3f(min.x, max.y, min.z)); vertices.add(new Vector3f(min.x(), max.y(), min.z()));
vertices.add(new Vector3f(min.x, min.y, min.z)); vertices.add(new Vector3f(min.x(), min.y(), min.z()));
vertices.add(new Vector3f(min.x, max.y, min.z)); vertices.add(new Vector3f(min.x(), max.y(), min.z()));
vertices.add(new Vector3f(max.x, min.y, min.z)); vertices.add(new Vector3f(max.x(), min.y(), min.z()));
vertices.add(new Vector3f(max.x, max.y, min.z)); vertices.add(new Vector3f(max.x(), max.y(), min.z()));
vertices.add(new Vector3f(max.x, min.y, max.z)); vertices.add(new Vector3f(max.x(), min.y(), max.z()));
vertices.add(new Vector3f(max.x, max.y, max.z)); vertices.add(new Vector3f(max.x(), max.y(), max.z()));
vertices.add(new Vector3f(min.x, min.y, max.z)); vertices.add(new Vector3f(min.x(), min.y(), max.z()));
vertices.add(new Vector3f(min.x, max.y, max.z)); vertices.add(new Vector3f(min.x(), max.y(), max.z()));
drawLine(vertices, color, transformationMatrix, updateDepthBuffer, depthtest); drawLine(vertices, color, transformationMatrix, updateDepthBuffer, depthtest);
} }
@ -402,9 +402,9 @@ public class ResourceColored3DObject extends Resource {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
if (true == depthtest) { if (depthtest) {
OpenGL.enable(OpenGL.Flag.flag_depthTest); OpenGL.enable(OpenGL.Flag.flag_depthTest);
if (false == updateDepthBuffer) { if (!updateDepthBuffer) {
OpenGL.setDeathMask(false); OpenGL.setDeathMask(false);
} }
} }
@ -421,17 +421,17 @@ public class ResourceColored3DObject extends Resource {
this.program.sendAttribute(this.oGLPosition, 3, buffer, 3); this.program.sendAttribute(this.oGLPosition, 3, buffer, 3);
// color : // color :
this.program.uniformColor(this.oGLColor, color); this.program.uniformColor(this.oGLColor, color);
if (color.a < 1.0f) { if (color.a() < 1.0f) {
OpenGL.enable(OpenGL.Flag.flag_blend); OpenGL.enable(OpenGL.Flag.flag_blend);
} }
// Request the draw od the elements: // Request the draw od the elements:
OpenGL.drawArrays(OpenGL.RenderMode.line, 0, vertices.size()); OpenGL.drawArrays(OpenGL.RenderMode.line, 0, vertices.size());
if (color.a < 1.0f) { if (color.a() < 1.0f) {
OpenGL.disable(OpenGL.Flag.flag_blend); OpenGL.disable(OpenGL.Flag.flag_blend);
} }
this.program.unUse(); this.program.unUse();
if (true == depthtest) { if (depthtest) {
if (false == updateDepthBuffer) { if (!updateDepthBuffer) {
OpenGL.setDeathMask(true); OpenGL.setDeathMask(true);
} }
OpenGL.disable(OpenGL.Flag.flag_depthTest); OpenGL.disable(OpenGL.Flag.flag_depthTest);
@ -477,8 +477,9 @@ public class ResourceColored3DObject extends Resource {
public void drawSquare(final Vector3f size, final Matrix4f transformationMatrix, final Color tmpColor) { public void drawSquare(final Vector3f size, final Matrix4f transformationMatrix, final Color tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>(); final List<Vector3f> tmpVertices = new ArrayList<>();
final int[] indices = { 0, 1, 2, 3, 2, 1, 4, 0, 6, 6, 0, 2, 5, 1, 4, 4, 1, 0, 7, 3, 1, 7, 1, 5, 5, 4, 7, 7, 4, 6, 7, 2, 3, 7, 6, 2 }; final int[] indices = { 0, 1, 2, 3, 2, 1, 4, 0, 6, 6, 0, 2, 5, 1, 4, 4, 1, 0, 7, 3, 1, 7, 1, 5, 5, 4, 7, 7, 4, 6, 7, 2, 3, 7, 6, 2 };
final Vector3f[] vertices = { new Vector3f(size.x, size.y, size.z), new Vector3f(-size.x, size.y, size.z), new Vector3f(size.x, -size.y, size.z), new Vector3f(-size.x, -size.y, size.z), final Vector3f[] vertices = { new Vector3f(size.x(), size.y(), size.z()), new Vector3f(-size.x(), size.y(), size.z()), new Vector3f(size.x(), -size.y(), size.z()),
new Vector3f(size.x, size.y, -size.z), new Vector3f(-size.x, size.y, -size.z), new Vector3f(size.x, -size.y, -size.z), new Vector3f(-size.x, -size.y, -size.z) }; new Vector3f(-size.x(), -size.y(), size.z()), new Vector3f(size.x(), size.y(), -size.z()), new Vector3f(-size.x(), size.y(), -size.z()), new Vector3f(size.x(), -size.y(), -size.z()),
new Vector3f(-size.x(), -size.y(), -size.z()) };
tmpVertices.clear(); tmpVertices.clear();
for (int iii = 0; iii < 36; iii += 3) { for (int iii = 0; iii < 36; iii += 3) {
// normal calculation : // normal calculation :
@ -498,9 +499,9 @@ public class ResourceColored3DObject extends Resource {
public void drawTriangles(final List<Vector3f> vertex, final List<Integer> indice, final Matrix4f transformationMatrix, final Color tmpColor, final Vector3f offset) { public void drawTriangles(final List<Vector3f> vertex, final List<Integer> indice, final Matrix4f transformationMatrix, final Color tmpColor, final Vector3f offset) {
final List<Vector3f> tmpVertices = new ArrayList<>(); final List<Vector3f> tmpVertices = new ArrayList<>();
for (int iii = 0; iii < indice.size() / 3; ++iii) { for (int iii = 0; iii < indice.size() / 3; ++iii) {
tmpVertices.add(vertex.get(indice.get(iii * 3 + 0)).addNew(offset)); tmpVertices.add(vertex.get(indice.get(iii * 3 + 0)).add(offset));
tmpVertices.add(vertex.get(indice.get(iii * 3 + 1)).addNew(offset)); tmpVertices.add(vertex.get(indice.get(iii * 3 + 1)).add(offset));
tmpVertices.add(vertex.get(indice.get(iii * 3 + 2)).addNew(offset)); tmpVertices.add(vertex.get(indice.get(iii * 3 + 2)).add(offset));
//Log.info(" indices " << indice[iii*3 + 0] << " " << indice[iii*3 + 1] << " " << indice[iii*3 + 2]); //Log.info(" indices " << indice[iii*3 + 0] << " " << indice[iii*3 + 1] << " " << indice[iii*3 + 2]);
//Log.info(" triangle " << vertex[indice[iii*3 + 0]] << " " << vertex[indice[iii*3 + 1]] << " " << vertex[indice[iii*3 + 2]]); //Log.info(" triangle " << vertex[indice[iii*3 + 0]] << " " << vertex[indice[iii*3 + 1]] << " " << vertex[indice[iii*3 + 2]]);
} }

View File

@ -14,14 +14,14 @@ public class ResourceManager {
private boolean exiting = false; private boolean exiting = false;
/** /**
* @brief initialize the internal variable * initialize the internal variable
*/ */
public ResourceManager() { public ResourceManager() {
} }
/** /**
* @brief special end of application * special end of application
*/ */
public void applicationExiting() { public void applicationExiting() {
contextHasBeenDestroyed(); contextHasBeenDestroyed();
@ -41,7 +41,7 @@ public class ResourceManager {
} }
/** /**
* @brief This is to inform the resources manager that we have no more openGl context ... * This is to inform the resources manager that we have no more openGl context ...
*/ */
public void contextHasBeenDestroyed() { public void contextHasBeenDestroyed() {
for (final Resource it : this.resourceList) { for (final Resource it : this.resourceList) {
@ -54,7 +54,7 @@ public class ResourceManager {
} }
/** /**
* @brief display in the log all the resources loaded ... * display in the log all the resources loaded ...
*/ */
public void display() { public void display() {
Log.info("Resources loaded : "); Log.info("Resources loaded : ");
@ -97,7 +97,7 @@ public class ResourceManager {
} }
/** /**
* @brief Reload all resources from files, and send there in openGL card if needed. * Reload all resources from files, and send there in openGL card if needed.
* @note If file is reference at THEMEXXX:///filename if the Theme change the file will reload the newOne * @note If file is reference at THEMEXXX:///filename if the Theme change the file will reload the newOne
*/ */
public void reLoadResources() { public void reLoadResources() {
@ -120,12 +120,12 @@ public class ResourceManager {
} }
/** /**
* @brief Uninitiamize the resource manager, free all resources previously requested * Uninitiamize the resource manager, free all resources previously requested
* @note when not free == > generate warning, because the segfault can appear after... * @note when not free == > generate warning, because the segfault can appear after...
*/ */
//public ~Manager(); //public ~Manager();
/** /**
* @brief remove all resources (un-init) out of the destructor (due to the system implementation) * remove all resources (un-init) out of the destructor (due to the system implementation)
*/ */
public void unInit() { public void unInit() {
display(); display();
@ -138,7 +138,7 @@ public class ResourceManager {
} }
/** /**
* @brief Call by the system to send all the needed data on the graphic card chen they change ... * Call by the system to send all the needed data on the graphic card chen they change ...
* @param object The resources that might be updated * @param object The resources that might be updated
*/ */
public void update(final Resource object) { public void update(final Resource object) {
@ -154,15 +154,15 @@ public class ResourceManager {
} }
/** /**
* @brief Call by the system chen the openGL Context has been unexpectially removed == > This reload all the texture, VBO and other .... * Call by the system chen the openGL Context has been unexpectially removed == > This reload all the texture, VBO and other ....
*/ */
public void updateContext() { public void updateContext() {
if (this.exiting == true) { if (this.exiting) {
Log.error("Request update after application EXIT ..."); Log.error("Request update after application EXIT ...");
return; return;
} }
// TODO Check the number of call this ... Log.info("update open-gl context ... "); // TODO Check the number of call this ... Log.info("update open-gl context ... ");
if (this.contextHasBeenRemoved == true) { if (this.contextHasBeenRemoved) {
// need to update all ... // need to update all ...
this.contextHasBeenRemoved = false; this.contextHasBeenRemoved = false;
this.resourceListToUpdate.clear(); this.resourceListToUpdate.clear();
@ -173,7 +173,7 @@ public class ResourceManager {
for (final Resource it : this.resourceList) { for (final Resource it : this.resourceList) {
if (jjj == it.getResourceLevel()) { if (jjj == it.getResourceLevel()) {
//Log.debug("Update context named : " + lresourceList[iii].getName()); //Log.debug("Update context named : " + lresourceList[iii].getName());
if (it.updateContext() == false) { if (!it.updateContext()) {
// Lock error ==> postponned // Lock error ==> postponned
this.resourceListToUpdate.add(it); this.resourceListToUpdate.add(it);
} }
@ -193,7 +193,7 @@ public class ResourceManager {
Log.verbose(" updateContext level (U) : " + jjj + "/" + (MAX_RESOURCE_LEVEL - 1)); Log.verbose(" updateContext level (U) : " + jjj + "/" + (MAX_RESOURCE_LEVEL - 1));
for (final Resource it : resourceListToUpdate) { for (final Resource it : resourceListToUpdate) {
if (jjj == it.getResourceLevel()) { if (jjj == it.getResourceLevel()) {
if (it.updateContext() == false) { if (!it.updateContext()) {
// Lock error ==> postponned // Lock error ==> postponned
this.resourceListToUpdate.add(it); this.resourceListToUpdate.add(it);
} }

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@ public class ResourceShader extends Resource {
ResourceShader resource; ResourceShader resource;
Resource resource2; Resource resource2;
final String name = uriShader.getValue(); final String name = uriShader.getValue();
if (name.isEmpty() == false && name != "---") { if (!name.isEmpty() && !name.equals("---")) {
resource2 = getManager().localKeep(name); resource2 = getManager().localKeep(name);
} else { } else {
Log.error("Can not create a shader without a filaname"); Log.error("Can not create a shader without a filaname");
@ -26,23 +26,18 @@ public class ResourceShader extends Resource {
return null; return null;
} }
resource = new ResourceShader(uriShader); resource = new ResourceShader(uriShader);
if (resource == null) {
Log.error("allocation error of a resource : " + name);
return null;
}
getManager().localAdd(resource); getManager().localAdd(resource);
return resource; return resource;
} }
private boolean exist = false; //!< The shader file existed and has been loaded private boolean exist = false; //!< The shader file existed and has been loaded
private final String fileData = ""; //!< A copy of the data loaded from the file (usefull only when opengl context is removed)
private int shader = -1; //!< opengl id of this element private int shader = -1; //!< opengl id of this element
private final ShaderType type; //!< Type of the current shader(vertex/fragment) private final ShaderType type; //!< Type of the current shader(vertex/fragment)
private final Uri uri; private final Uri uri;
/** /**
* @brief Contructor of an opengl Shader * Constructor of an opengl Shader
* @param filename Standard file name format. see @ref etk::FSNode * @param uri Standard file name format. see @ref etk::FSNode
*/ */
protected ResourceShader(final Uri uri) { protected ResourceShader(final Uri uri) {
super(uri); super(uri);
@ -64,7 +59,7 @@ public class ResourceShader extends Resource {
} }
/** /**
* @brief Destructor, remove the current Shader * Destructor, remove the current Shader
*/ */
@Override @Override
public void cleanUp() { public void cleanUp() {
@ -73,7 +68,7 @@ public class ResourceShader extends Resource {
}; };
/** /**
* @brief get the opengl reference id of this shader. * get the opengl reference id of this shader.
* @return The opengl id. * @return The opengl id.
*/ */
public int getGLID() { public int getGLID() {
@ -81,7 +76,7 @@ public class ResourceShader extends Resource {
}; };
/** /**
* @brief get the opengl type of this shader. * get the opengl type of this shader.
* @return The type of this loaded shader. * @return The type of this loaded shader.
*/ */
public ShaderType getShaderType() { public ShaderType getShaderType() {
@ -89,14 +84,16 @@ public class ResourceShader extends Resource {
} }
/** /**
* @brief Relode the shader from the file. used when a request of resouces reload is done. * Reloaded the shader from the file. used when a request of resources reload is done.
* @note this is really usefull when we tested the new themes or shader developpements. * @note this is really useful when we tested the new themes or shader developments.
*/ */
@Override @Override
public void reload() { public void reload() {
Log.verbose("load shader:\n-----------------------------------------------------------------\n" + this.fileData + "\n-----------------------------------------------------------------"); //!< A copy of the data loaded from the file (useful only when opengl context is removed)
String fileData = "";
Log.verbose("load shader:\n-----------------------------------------------------------------\n" + fileData + "\n-----------------------------------------------------------------");
// now change the OGL context ... // now change the OGL context ...
if (OpenGL.hasContext() == true) { if (OpenGL.hasContext()) {
Log.debug("OGL : load SHADER '" + this.name + "' ==> call update context (direct)"); Log.debug("OGL : load SHADER '" + this.name + "' ==> call update context (direct)");
removeContext(); removeContext();
updateContext(); updateContext();
@ -110,11 +107,11 @@ public class ResourceShader extends Resource {
} }
/** /**
* @brief remove the data from the opengl context. * remove the data from the opengl context.
*/ */
@Override @Override
public void removeContext() { public void removeContext() {
if (true == this.exist) { if (this.exist) {
OpenGL.shaderRemove(this.shader); OpenGL.shaderRemove(this.shader);
this.shader = -1; this.shader = -1;
this.exist = false; this.exist = false;
@ -122,7 +119,7 @@ public class ResourceShader extends Resource {
} }
/** /**
* @brief Special android spec! It inform us that all context is removed and after notify us... * Special android spec! It inform us that all context is removed and after notify us...
*/ */
@Override @Override
public void removeContextToLate() { public void removeContextToLate() {
@ -131,14 +128,12 @@ public class ResourceShader extends Resource {
} }
/** /**
* @brief This load/reload the data in the opengl context, needed when removed previously. * This load/reload the data in the opengl context, needed when removed previously.
*/ */
@Override @Override
public boolean updateContext() { public boolean updateContext() {
if (this.exist == true) { if (!this.exist) {
// Do nothing == > too dangerous ... this.shader = OpenGL.shaderLoad(this.uri, this.type);
} else {
this.shader = OpenGL.shaderLoad(this.uri.get(), this.type);
// create the Shader // create the Shader
if (this.shader < 0) { if (this.shader < 0) {
return true; return true;

View File

@ -32,7 +32,7 @@ public class ResourceTexture extends Resource {
ResourceTexture resource; ResourceTexture resource;
Resource resource2; Resource resource2;
final String name = uriTexture.getValue(); final String name = uriTexture.getValue();
if (name.isEmpty() == false && name != "---") { if (!name.isEmpty() && !name.equals("---")) {
resource2 = getManager().localKeep(name); resource2 = getManager().localKeep(name);
} else { } else {
Log.error("Can not create a shader without a filaname"); Log.error("Can not create a shader without a filaname");
@ -48,14 +48,14 @@ public class ResourceTexture extends Resource {
} }
resource = new ResourceTexture(uriTexture, textureUnit); resource = new ResourceTexture(uriTexture, textureUnit);
final ImageRawData decodedData = ImageLoader.decodePngFile(uriTexture); final ImageRawData decodedData = ImageLoader.decodePngFile(uriTexture);
resource.setTexture(decodedData.getBuffer(), new Vector2i(decodedData.getWidth(), decodedData.getHeight()), (decodedData.isHasAlpha() == true ? TextureColorMode.rgba : TextureColorMode.rgb), resource.setTexture(decodedData.getBuffer(), new Vector2i(decodedData.getWidth(), decodedData.getHeight()), (decodedData.isHasAlpha() ? TextureColorMode.rgba : TextureColorMode.rgb),
textureUnit); textureUnit);
resource.flush(); resource.flush();
return resource; return resource;
} }
/** /**
* @brief get the next power 2 if the input * get the next power 2 if the input
* @param value Value that we want the next power of 2 * @param value Value that we want the next power of 2
* @return result value * @return result value
*/ */
@ -105,7 +105,7 @@ public class ResourceTexture extends Resource {
} }
public void bindForRendering(final int idTexture) { public void bindForRendering(final int idTexture) {
if (this.loaded == false) { if (!this.loaded) {
return; return;
} }
GL13.glActiveTexture(textureIdBinding[idTexture]); GL13.glActiveTexture(textureIdBinding[idTexture]);
@ -142,7 +142,7 @@ public class ResourceTexture extends Resource {
@Override @Override
public synchronized void removeContext() { public synchronized void removeContext() {
if (this.loaded == true) { if (this.loaded) {
// Request remove texture ... // Request remove texture ...
Log.info("TEXTURE: Rm [" + getId() + "] texId=" + this.texId); Log.info("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
// TODO Check if we are in the correct thread // TODO Check if we are in the correct thread
@ -161,14 +161,13 @@ public class ResourceTexture extends Resource {
this.data = data; this.data = data;
this.size = size; this.size = size;
this.textureUnit = textureUnit; this.textureUnit = textureUnit;
this.endPointSize.x = size.x; this.endPointSize = new Vector2f(size.x(), size.y());
this.endPointSize.y = size.y;
this.dataColorSpace = dataColorSpace; this.dataColorSpace = dataColorSpace;
flush(); flush();
} }
public void unBindForRendering() { public void unBindForRendering() {
if (this.loaded == false) { if (!this.loaded) {
return; return;
} }
if (this.dataColorSpace == TextureColorMode.rgb) { if (this.dataColorSpace == TextureColorMode.rgb) {
@ -180,7 +179,7 @@ public class ResourceTexture extends Resource {
// Gale internal API: // Gale internal API:
@Override @Override
public boolean updateContext() { public boolean updateContext() {
if (this.loaded == true) { if (this.loaded) {
return true; return true;
} }
// Request a new texture at openGl : // Request a new texture at openGl :
@ -192,9 +191,9 @@ public class ResourceTexture extends Resource {
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
Log.info("TEXTURE: add [" + getId() + "]=" + this.size + " OGlId=" + this.texId); Log.info("TEXTURE: add [" + getId() + "]=" + this.size + " OGlId=" + this.texId);
if (this.dataColorSpace == TextureColorMode.rgb) { if (this.dataColorSpace == TextureColorMode.rgb) {
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.size.x, this.size.y, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, this.data); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.size.x(), this.size.y(), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, this.data);
} else { } else {
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.size.x, this.size.y, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, this.data); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.size.x(), this.size.y(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, this.data);
} }
// generate multi-texture mapping // generate multi-texture mapping
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);

View File

@ -76,10 +76,6 @@ public class ResourceVirtualArrayObject extends Resource {
int vertexCount = -1; int vertexCount = -1;
/**
* @brief ructor of this VBO.
* @param accesMode Acces mode : ???
*/
protected ResourceVirtualArrayObject(final float[] positions, final float[] colors, final float[] textureCoordinates, final float[] normals, final int[] indices, final int vertexCount) { protected ResourceVirtualArrayObject(final float[] positions, final float[] colors, final float[] textureCoordinates, final float[] normals, final int[] indices, final int vertexCount) {
super(); super();
this.resourceLevel = 3; this.resourceLevel = 3;
@ -93,7 +89,7 @@ public class ResourceVirtualArrayObject extends Resource {
} }
public void bindForRendering() { public void bindForRendering() {
if (this.exist == false) { if (!this.exist) {
return; return;
} }
GL30.glBindVertexArray(this.vaoID); GL30.glBindVertexArray(this.vaoID);
@ -113,7 +109,7 @@ public class ResourceVirtualArrayObject extends Resource {
} }
private void bindIndicesBuffer(final int[] indices) { private void bindIndicesBuffer(final int[] indices) {
final int vboId = OpenGL.glGenBuffers(); final int vboId = OpenGL.genBuffers();
this.vbo.add(vboId); this.vbo.add(vboId);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboId); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboId);
final IntBuffer buffer = storeDataInIntBuffer(indices); final IntBuffer buffer = storeDataInIntBuffer(indices);
@ -121,7 +117,7 @@ public class ResourceVirtualArrayObject extends Resource {
} }
/** /**
* @brief Destructor of this VBO. * Destructor of this VBO.
*/ */
@Override @Override
public void cleanUp() { public void cleanUp() {
@ -129,7 +125,7 @@ public class ResourceVirtualArrayObject extends Resource {
} }
/** /**
* @brief clear buffers * clear buffers
*/ */
public void clear() { public void clear() {
//Log.verbose(" Clear: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.get(0).length + ")"); //Log.verbose(" Clear: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.get(0).length + ")");
@ -143,7 +139,7 @@ public class ResourceVirtualArrayObject extends Resource {
} }
/** /**
* @brief Send the data to the graphic card. * Send the data to the graphic card.
*/ */
public void flush() { public void flush() {
// request to the manager to be call at the next update ... // request to the manager to be call at the next update ...
@ -152,7 +148,7 @@ public class ResourceVirtualArrayObject extends Resource {
} }
/** /**
* @brief get the real openGL ID. * get the real openGL ID.
* @return the Ogl id reference of this VBO. * @return the Ogl id reference of this VBO.
*/ */
public int getGLID() { public int getGLID() {
@ -185,7 +181,7 @@ public class ResourceVirtualArrayObject extends Resource {
} }
/** /**
* @brief Relode the shader from the file. used when a request of resouces reload is done. * 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. * @note this is really usefull when we tested the new themes or shader developpements.
*/ */
@Override @Override
@ -195,23 +191,21 @@ public class ResourceVirtualArrayObject extends Resource {
} }
/** /**
* @brief remove the data from the opengl context. * remove the data from the opengl context.
*/ */
@Override @Override
public void removeContext() { public void removeContext() {
if (this.exist) {
if (this.exist == true) {
// OpenGL.deleteBuffers(this.vbo); // OpenGL.deleteBuffers(this.vbo);
this.exist = false; this.exist = false;
} }
} }
/** /**
* @brief Special android spec! It inform us that all context is removed and after notify us... * Special android spec! It inform us that all context is removed and after notify us...
*/ */
@Override @Override
public void removeContextToLate() { public void removeContextToLate() {
this.exist = false; this.exist = false;
// for (int iii=0; iii<this.vbo.length; iii++) { // for (int iii=0; iii<this.vbo.length; iii++) {
// this.vbo[iii] = 0; // this.vbo[iii] = 0;
@ -233,7 +227,7 @@ public class ResourceVirtualArrayObject extends Resource {
} }
public void unBindForRendering() { public void unBindForRendering() {
if (this.exist == false) { if (!this.exist) {
return; return;
} }
if (this.positions != null) { if (this.positions != null) {
@ -256,12 +250,12 @@ public class ResourceVirtualArrayObject extends Resource {
} }
/** /**
* @brief This load/reload the data in the opengl context, needed when removed previously. * This load/reload the data in the opengl context, needed when removed previously.
*/ */
@Override @Override
public boolean updateContext() { public boolean updateContext() {
//Log.verbose(" Start: [" + getId() + "] '" + getName() + "' (size=" + this.indices.length + ") ********************************"); //Log.verbose(" Start: [" + getId() + "] '" + getName() + "' (size=" + this.indices.length + ") ********************************");
if (this.exist == false) { if (!this.exist) {
Log.debug(" ==> ALLOCATE new handle"); Log.debug(" ==> ALLOCATE new handle");
// Allocate and assign a Vertex Array Object to our handle // Allocate and assign a Vertex Array Object to our handle
loadToVAO(); loadToVAO();

View File

@ -5,6 +5,8 @@
*/ */
package org.atriasoft.gale.resource; package org.atriasoft.gale.resource;
import java.util.Arrays;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
@ -13,7 +15,7 @@ import org.atriasoft.gale.backend3d.OpenGL.Usage;
import org.atriasoft.gale.internal.Log; import org.atriasoft.gale.internal.Log;
/** /**
* @brief ResourceVirtualBufferObject is a specific resources for opengl, this load the data directly in the graphic card ad keep these inside * ResourceVirtualBufferObject is a specific resources for opengl, this load the data directly in the graphic card ad keep these inside
*/ */
public class ResourceVirtualBufferObject extends Resource { public class ResourceVirtualBufferObject extends Resource {
@ -26,14 +28,14 @@ public class ResourceVirtualBufferObject extends Resource {
private final Object[] buffer; //!< data that is availlable in the VBO system ... private final Object[] buffer; //!< data that is availlable in the VBO system ...
/** /**
* @brief Constructor of this VBO. * Constructor of this VBO.
* @param[in] accesMode Acces mode : ??? * @param accesMode Acces mode : ???
*/ */
protected ResourceVirtualBufferObject(final int _number) { protected ResourceVirtualBufferObject(final int number) {
super(); super();
this.vbo = new int[_number]; // 0 this.vbo = new int[number]; // 0
this.buffer = new Object[_number]; this.buffer = new Object[number];
Log.debug("OGL : load VBO count=\"" + _number + "\""); Log.debug("OGL : load VBO count=\"" + number + "\"");
this.resourceLevel = 3; this.resourceLevel = 3;
} }
@ -63,18 +65,16 @@ public class ResourceVirtualBufferObject extends Resource {
} }
/** /**
* @brief clear buffers * clear buffers
*/ */
public void clear() { public void clear() {
Log.verbose(" Clear: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.length + ")"); Log.verbose(" Clear: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.length + ")");
// DO not clear the this.vbo indexed in the graphic cards ... // DO not clear the this.vbo indexed in the graphic cards ...
for (int iii = 0; iii < this.buffer.length; iii++) { Arrays.fill(this.buffer, null);
this.buffer[iii] = null;
}
} }
/** /**
* @brief Send the data to the graphic card. * Send the data to the graphic card.
*/ */
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 ...
@ -103,15 +103,15 @@ public class ResourceVirtualBufferObject extends Resource {
} }
/** /**
* @brief get the real openGL ID. * get the real openGL ID.
* @return the Ogl id reference of this VBO. * @return the Ogl id reference of this VBO.
*/ */
public int getGL_ID(final int _id) { public int getOpenGlId(final int id) {
return this.vbo[_id]; return this.vbo[id];
} }
/** /**
* @brief Relode the shader from the file. used when a request of resouces reload is done. * 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. * @note this is really usefull when we tested the new themes or shader developpements.
*/ */
@Override @Override
@ -121,29 +121,27 @@ public class ResourceVirtualBufferObject extends Resource {
} }
/** /**
* @brief remove the data from the opengl context. * remove the data from the opengl context.
*/ */
@Override @Override
public synchronized void removeContext() { public synchronized void removeContext() {
if (this.exist == true) { if (this.exist) {
OpenGL.deleteBuffers(this.vbo); OpenGL.deleteBuffers(this.vbo);
this.exist = false; this.exist = false;
} }
} }
/** /**
* @brief Special android spec! It inform us that all context is removed and after notify us... * Special android spec! It inform us that all context is removed and after notify us...
*/ */
@Override @Override
public synchronized void removeContextToLate() { public synchronized void removeContextToLate() {
this.exist = false; this.exist = false;
for (int iii = 0; iii < this.vbo.length; iii++) { Arrays.fill(this.vbo, 0);
this.vbo[iii] = 0;
}
} }
/** /**
* @brief get the data from the graphic card. * get the data from the graphic card.
*/ */
public void retreiveData() { public void retreiveData() {
Log.error("TODO ... "); Log.error("TODO ... ");
@ -170,7 +168,7 @@ public class ResourceVirtualBufferObject extends Resource {
} }
/** /**
* @brief This load/reload the data in the opengl context, needed when removed previously. * This load/reload the data in the opengl context, needed when removed previously.
*/ */
@Override @Override
public synchronized boolean updateContext() { public synchronized boolean updateContext() {
@ -182,7 +180,7 @@ public class ResourceVirtualBufferObject extends Resource {
return false; return false;
} }
*/ */
if (this.exist == false) { if (!this.exist) {
Log.debug(" ==> ALLOCATE new handle"); Log.debug(" ==> ALLOCATE new handle");
// Allocate and assign a Vertex Array Object to our handle // Allocate and assign a Vertex Array Object to our handle
OpenGL.genBuffers(this.vbo); OpenGL.genBuffers(this.vbo);

View File

@ -51,10 +51,6 @@ public class Sample1Application extends Application {
}; };
// this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=float "i"=integer // this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=float "i"=integer
this.verticesVBO = ResourceVirtualArrayObject.create(vertices, colors, indices); this.verticesVBO = ResourceVirtualArrayObject.create(vertices, colors, indices);
if (this.verticesVBO == null) {
Log.error("can not instanciate VBO ...");
return;
}
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
this.verticesVBO.setName("[VBO] of basic SAMPLE"); this.verticesVBO.setName("[VBO] of basic SAMPLE");
// update all the VBO elements ... // update all the VBO elements ...
@ -69,7 +65,7 @@ public class Sample1Application extends Application {
// set the basic openGL view port: (position drawed in the windows) // set the basic openGL view port: (position drawed in the windows)
OpenGL.setViewPort(new Vector2f(0,0), size); OpenGL.setViewPort(new Vector2f(0,0), size);
// Clear all the stacked matrix ... // Clear all the stacked matrix ...
OpenGL.setBasicMatrix(Matrix4f.identity()); OpenGL.setBasicMatrix(Matrix4f.IDENTITY);
// clear background // clear background
Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f); Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f);
OpenGL.clearColor(bgColor); OpenGL.clearColor(bgColor);

View File

@ -92,10 +92,6 @@ public class Sample2Application extends Application {
}; };
// this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=float "i"=integer // this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=float "i"=integer
this.verticesVBO = ResourceVirtualArrayObject.create(vertices, textureCoords, null, indices); this.verticesVBO = ResourceVirtualArrayObject.create(vertices, textureCoords, null, indices);
if (this.verticesVBO == null) {
Log.error("can not instanciate VBO ...");
return;
}
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
this.verticesVBO.setName("[VBO] of basic SAMPLE"); this.verticesVBO.setName("[VBO] of basic SAMPLE");
// update all the VBO elements ... // update all the VBO elements ...
@ -119,7 +115,7 @@ public class Sample2Application extends Application {
// set the basic openGL view port: (position drawed in the windows) // set the basic openGL view port: (position drawed in the windows)
OpenGL.setViewPort(new Vector2f(0,0), size); OpenGL.setViewPort(new Vector2f(0,0), size);
// Clear all the stacked matrix ... // Clear all the stacked matrix ...
OpenGL.setBasicMatrix(Matrix4f.identity()); OpenGL.setBasicMatrix(Matrix4f.IDENTITY);
// clear background // clear background
Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f); Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f);
OpenGL.enable(OpenGL.Flag.flag_depthTest); OpenGL.enable(OpenGL.Flag.flag_depthTest);
@ -143,12 +139,12 @@ public class Sample2Application extends Application {
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
Matrix4f projectionMatrix = tmpProjection; //OpenGL.getMatrix(); Matrix4f projectionMatrix = tmpProjection; //OpenGL.getMatrix();
Matrix4f transforamtionMatrix = Matrix4f.identity(); Matrix4f transforamtionMatrix = Matrix4f.IDENTITY;
transforamtionMatrix.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-1))); transforamtionMatrix = transforamtionMatrix.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-1)));
transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(1,0,0),this.angleX)); transforamtionMatrix = transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(1,0,0),this.angleX));
transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,1,0),this.angleY)); transforamtionMatrix = transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,1,0),this.angleY));
transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,0,1),this.angleZ)); transforamtionMatrix = transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,0,1),this.angleZ));
Matrix4f viewMatrix = OpenGL.getCameraMatrix().multiplyNew(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-2))); Matrix4f viewMatrix = OpenGL.getCameraMatrix().multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-2)));
//Matrix4f tmpMatrix = projMatrix * camMatrix; //Matrix4f tmpMatrix = projMatrix * camMatrix;
this.verticesVBO.bindForRendering(); this.verticesVBO.bindForRendering();
this.oGLprogram.uniformMatrix(this.oGLMatrixView, viewMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixView, viewMatrix);

View File

@ -1,6 +1,5 @@
package org.atriasoft.gale.tools; package org.atriasoft.gale.tools;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -11,39 +10,39 @@ import de.matthiasmann.twl.utils.PNGDecoder;
import de.matthiasmann.twl.utils.PNGDecoder.Format; import de.matthiasmann.twl.utils.PNGDecoder.Format;
public class ImageLoader { public class ImageLoader {
public static ImageRawData decodePngFile(final Uri filename) {
ByteBuffer buf = null;
int tWidth = 0;
int tHeight = 0;
boolean hasAlpha = false;
try {
// Open the PNG file as an InputStream
final InputStream in = Uri.getStream(filename);
// Link the PNG decoder to this stream
final PNGDecoder decoder = new PNGDecoder(in);
// Get the width and height of the texture
tWidth = decoder.getWidth();
tHeight = decoder.getHeight();
hasAlpha = decoder.hasAlpha();
// Decode the PNG file in a ByteBuffer
if (hasAlpha) {
buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
//decoder.decodeFlipped(buf, decoder.getWidth() * 4, Format.RGBA);
decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
} else {
buf = ByteBuffer.allocateDirect(3 * decoder.getWidth() * decoder.getHeight());
//decoder.decodeFlipped(buf, decoder.getWidth() * 4, Format.RGBA);
decoder.decode(buf, decoder.getWidth() * 3, Format.RGB);
}
buf.flip();
in.close();
} catch (final IOException e) {
e.printStackTrace();
System.err.println("try to load texture " + filename + ", didn't work");
System.exit(-1);
}
return new ImageRawData(buf, tWidth, tHeight, hasAlpha);
}
private ImageLoader() {} private ImageLoader() {}
public static ImageRawData decodePngFile(Uri filename) {
ByteBuffer buf = null;
int tWidth = 0;
int tHeight = 0;
boolean hasAlpha = false;
try {
// Open the PNG file as an InputStream
InputStream in = new FileInputStream(filename.get());
// Link the PNG decoder to this stream
PNGDecoder decoder = new PNGDecoder(in);
// Get the width and height of the texture
tWidth = decoder.getWidth();
tHeight = decoder.getHeight();
hasAlpha = decoder.hasAlpha();
// Decode the PNG file in a ByteBuffer
if (hasAlpha == true) {
buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
//decoder.decodeFlipped(buf, decoder.getWidth() * 4, Format.RGBA);
decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
} else {
buf = ByteBuffer.allocateDirect(3 * decoder.getWidth() * decoder.getHeight());
//decoder.decodeFlipped(buf, decoder.getWidth() * 4, Format.RGBA);
decoder.decode(buf, decoder.getWidth() * 3, Format.RGB);
}
buf.flip();
in.close();
} catch (IOException e) {
e.printStackTrace();
System.err.println("try to load texture " + filename + ", didn't work");
System.exit(-1);
}
return new ImageRawData(buf, tWidth, tHeight, hasAlpha);
}
} }

View File

@ -13,10 +13,9 @@ import java.util.List;
import io.scenarium.logger.Logger; import io.scenarium.logger.Logger;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
//import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.TestMethodOrder;
@TestMethodOrder(OrderAnnotation.class) @TestMethodOrder(OrderAnnotation.class)