[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"?>
<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"/>
</fileset>
</fileset-config>

View File

@ -5,6 +5,7 @@
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="resources"/>
<classpathentry including="**/*.java" kind="src" output="out/eclipse/classes-test" path="test/src">
<attributes>
<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 {
exports org.atriasoft.gale;
exports org.atriasoft.gale.backend3d;
exports org.atriasoft.gale.context;
//exports org.atriasoft.gale.context.JOGL;
// exports org.atriasoft.gale.context.JOGL;
exports org.atriasoft.gale.context.LWJG_AWT;
exports org.atriasoft.gale.key;
exports org.atriasoft.gale.resource;
requires transitive org.atriasoft.etk;
//requires transitive vecmath;
// requires transitive vecmath;
requires transitive org.lwjgl;
requires transitive org.lwjgl.natives;
requires transitive org.lwjgl.glfw;
requires transitive org.lwjgl.glfw.natives;
requires transitive org.lwjgl.assimp;
requires transitive org.lwjgl.assimp.natives;
// requires transitive org.lwjgl.openal;
// requires transitive org.lwjgl.openal.natives;
// requires transitive org.lwjgl.openal;
// requires transitive org.lwjgl.openal.natives;
requires transitive org.lwjgl.stb;
requires transitive org.lwjgl.stb.natives;
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.natives;
//requires org.lwjgl.openvr;
//requires transitive jogamp.fat;
// requires org.lwjgl.openvr;
// requires transitive jogamp.fat;
requires transitive java.desktop;
requires transitive pngdecoder;
requires transitive lwjgl3.awt;

View File

@ -15,278 +15,296 @@ public class Application {
public boolean canDraw = false;
private boolean needRedraw = true;
private String title = "gale";
private Uri iconName = new Uri("");
private Cursor cursor = Cursor.arrow;
private Uri iconName = null;
private final Cursor cursor = Cursor.arrow;
private Orientation orientation = Orientation.screenAuto;
Vector2f windowsSize = new Vector2f(800,600);
Vector2f windowsSize = new Vector2f(800, 600);
public Application() {
Log.verbose("Constructor Gale Application");
}
/**
* @brief The application is created.
* @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))
* 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
*/
public void exit(int value) {
public void exit(final int value) {
Log.verbose("Exit Requested " + value);
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() {
return windowsSize.x/windowsSize.y;
return this.windowsSize.x() / this.windowsSize.y();
}
/**
* @brief Event generated when user change the position of the window.
* @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.
* Get the cursor type.
* @return the current cursor.
*/
public Cursor getCursor() {
return this.cursor;
}
/**
* @brief set the screen orientation (if possible : only on iOs/Android)
* @param orientation New orientation.
* Get the current filename of the application.
* @return Filename of the icon.
*/
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
Gale.getContext().forceOrientation(this.orientation);
public Uri getIcon() {
return this.iconName;
}
/**
* @brief get the screen orientation (if possible : only on iOs/Android)
* get the screen orientation (if possible : only on iOs/Android)
* @return Current orientation.
*/
public Orientation getOrientation() {
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.
*/
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;
*/
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;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
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
*/
public class Dimension {
private final static Vector2f ratio = new Vector2f(9999999, 888888);
private final static Vector2f invRatio = new Vector2f(1, 1);
private final static Dimension windowsSize = new Dimension(new Vector2f(9999999, 888888), Distance.PIXEL);
@SuppressWarnings("preview")
public record Dimension(
Vector2f size,
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 final static float FOOT_TO_MILLIMETER = 1.0f / 304.8f;
public final static float METER_TO_MILLIMETER = 1.0f / 1000.0f;
public final static float CENTIMETER_TO_MILLIMETER = 1.0f / 10.0f;
public final static float KILOMETER_TO_MILLIMETER = 1.0f / 1000000.0f;
public final static float MILLIMETER_TO_INCH = 25.4f;
public final static float MILLIMETER_TO_FOOT = 304.8f;
public final static float MILLIMETER_TO_METER = 1000.0f;
public final static float MILLIMETER_TO_CENTIMETER = 10.0f;
public final static float MILLIMETER_TO_KILOMETER = 1000000.0f;
public static final float INCH_TO_MILLIMETER = 1.0f / 25.4f;
public static final float FOOT_TO_MILLIMETER = 1.0f / 304.8f;
public static final float METER_TO_MILLIMETER = 1.0f / 1000.0f;
public static final float CENTIMETER_TO_MILLIMETER = 1.0f / 10.0f;
public static final float KILOMETER_TO_MILLIMETER = 1.0f / 1000000.0f;
public static final float MILLIMETER_TO_INCH = 25.4f;
public static final float MILLIMETER_TO_FOOT = 304.8f;
public static final float MILLIMETER_TO_METER = 1000.0f;
public static final float MILLIMETER_TO_CENTIMETER = 10.0f;
public static final float MILLIMETER_TO_KILOMETER = 1000000.0f;
/**
* @brief basic init
* basic init
*/
static {
final Dimension conversion = new Dimension(new Vector2f(72, 72), Distance.INCH);
ratio.set(conversion.getMillimeter());
invRatio.setValue(1.0f / ratio.x, 1.0f / ratio.y);
windowsSize.set(new Vector2f(200, 200), Distance.PIXEL);
ratio = conversion.getMillimeter();
invRatio = new Vector2f(1.0f / ratio.x(), 1.0f / ratio.y());
windowsSize = new Dimension(new Vector2f(200, 200), Distance.PIXEL);
}
/**
* @brief get the Windows diagonal size in the request unit
* @param[in] type Unit type requested.
* get the Windows diagonal size in the request unit
* @param type Unit type requested.
* @return the requested size
*/
public static float getWindowsDiag(final Distance _type) {
final Vector2f size = getWindowsSize(_type);
public static float getWindowsDiag(final Distance type) {
final Vector2f size = getWindowsSize(type);
return size.length();
}
/**
* @brief get the Windows size in the request unit
* @param[in] type Unit type requested.
* get the Windows size in the request unit
* @param type Unit type requested.
* @return the requested size
*/
public static Vector2f getWindowsSize(final Distance _type) {
return windowsSize.get(_type);
public static Vector2f getWindowsSize(final Distance type) {
return windowsSize.get(type);
}
/**
* @brief set the Milimeter ratio for calculation
* @param[in] Ratio Milimeter ration for the screen calculation interpolation
* @param[in] type Unit type requested.
* set the Milimeter ratio for calculation
* @param ratio Milimeter ration for the screen calculation interpolation
* @param type Unit type requested.
* @note: same as @ref setPixelPerInch (internal manage convertion)
*/
public static void setPixelRatio(final Vector2f _ratio, final Distance _type) {
Log.info("Set a new screen ratio for the screen : ratio=" + _ratio + " type=" + _type);
final Dimension conversion = new Dimension(_ratio, _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);
final Dimension conversion = new Dimension(ratio, type);
Log.info(" == > " + conversion);
ratio.set(conversion.getMillimeter());
invRatio.setValue(1.0f / ratio.x, 1.0f / ratio.y);
Log.info("Set a new screen ratio for the screen : ratioMm=" + ratio);
Dimension.ratio = conversion.getMillimeter();
invRatio = new Vector2f(1.0f / Dimension.ratio.x(), 1.0f / Dimension.ratio.y());
Log.info("Set a new screen ratio for the screen : ratioMm=" + Dimension.ratio);
}
/**
* @brief set the current Windows size
* @param[in] size size of the current windows in pixel.
* set the current Windows size
* @param size size of the current windows in pixel.
*/
public static void setPixelWindowsSize(final Vector2f _size) {
windowsSize.set(_size);
public static void setPixelWindowsSize(final Vector2f size) {
windowsSize = new Dimension(size);
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() {
this(Vector2f.ZERO, Distance.PIXEL);
}
/**
* @brief Constructor
* @param[in] _config dimension configuration.
* Constructor
* @param size Requested dimension
*/
public Dimension(final String _config) {
set(_config);
public Dimension(final Vector2f size) {
this(size, Distance.PIXEL);
}
public Dimension(final Vector2f size, final Distance type) {
this.size = size;
this.type = type;
}
/**
* @brief Constructor
* @param[in] _size Requested dimension
* @param[in] _type Unit of the Dimension
* get the current dimension in requested type
* @param type Type of unit requested.
* @return dimension requested.
*/
public Dimension(final Vector2f _size) {
set(_size, Distance.PIXEL);
}
public Dimension(final Vector2f _size, final Distance _type) {
set(_size, _type);
}
/*****************************************************
* isEqual
*****************************************************/
@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;
public Vector2f get(final Distance type) {
return switch (type) {
case POURCENT -> getPourcent();
case PIXEL -> getPixel();
case METER -> getMeter();
case CENTIMETER -> getCentimeter();
case MILLIMETER -> getMillimeter();
case KILOMETER -> getKilometer();
case INCH -> getInch();
case FOOT -> getFoot();
};
}
/**
* @brief get the current dimention in requested type
* @param[in] _type Type of unit requested.
* @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
* get the current dimension in Centimeter
* @return dimension in Centimeter
*/
public Vector2f getCentimeter() {
return getMillimeter().multiplyNew(MILLIMETER_TO_CENTIMETER);
return getMillimeter().multiply(MILLIMETER_TO_CENTIMETER);
}
/**
* @brief get the current dimention in Foot
* @return dimention in Foot
* get the current dimension in Foot
* @return dimension in Foot
*/
public Vector2f getFoot() {
return getMillimeter().multiplyNew(MILLIMETER_TO_FOOT);
return getMillimeter().multiply(MILLIMETER_TO_FOOT);
}
/**
* @brief get the current dimention in Inch
* @return dimention in Inch
* get the current dimension in Inch
* @return dimension in Inch
*/
public Vector2f getInch() {
return getMillimeter().multiplyNew(MILLIMETER_TO_INCH);
return getMillimeter().multiply(MILLIMETER_TO_INCH);
}
/**
* @brief get the current dimention in Kilometer
* @return dimention in Kilometer
* get the current dimension in Kilometer
* @return dimension in Kilometer
*/
public Vector2f getKilometer() {
return getMillimeter().multiplyNew(MILLIMETER_TO_KILOMETER);
return getMillimeter().multiply(MILLIMETER_TO_KILOMETER);
}
/**
* @brief get the current dimention in Meter
* @return dimention in Meter
* get the current dimension in Meter
* @return dimension in Meter
*/
public Vector2f getMeter() {
return getMillimeter().multiplyNew(MILLIMETER_TO_METER);
return getMillimeter().multiply(MILLIMETER_TO_METER);
}
/**
* @brief get the current dimention in Millimeter
* @return dimention in Millimeter
* get the current dimension in Millimeter
* @return dimension in Millimeter
*/
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
* @return dimention in Pixel
* get the current dimension in pixel
* @return dimension in Pixel
*/
public Vector2f getPixel() {
if (this.type != Distance.POURCENT) {
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
* @return dimention in Pourcent
* get the current dimension in Pourcent
* @return dimension in Pourcent
*/
public Vector2f getPourcent() {
if (this.type != Distance.POURCENT) {
final Vector2f windDim = windowsSize.getPixel();
//GALE_DEBUG(" windows dimention : " /*+ windowsSize*/ + " == > " + windDim + "px"); // ==> infinite loop ...
//printf(" windows dimention : %f,%f", windDim.x(),windDim.y());
//GALE_DEBUG(" windows dimension : " /*+ windowsSize*/ + " == > " + windDim + "px"); // ==> infinite loop ...
//printf(" windows dimension : %f,%f", windDim.x(),windDim.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
*/
public Distance getType() {
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
* @param[in] _config dimension configuration.
* set the current dimension in requested type
* @param config dimension configuration.
*/
private void set(String _config) {
this.size.setValue(0, 0);
this.type = Distance.PIXEL;
public static Dimension valueOf(String config) {
final Vector2f size = Vector2f.ZERO;
Distance type = Distance.PIXEL;
if (_config.endsWith("%") == true) {
if (config.endsWith("%")) {
type = Distance.POURCENT;
_config = _config.substring(0, _config.length() - 1);
} else if (_config.endsWith("px") == true) {
config = config.substring(0, config.length() - 1);
} else if (config.endsWith("px")) {
type = Distance.PIXEL;
_config = _config.substring(0, _config.length() - 2);
} else if (_config.endsWith("ft") == true) {
config = config.substring(0, config.length() - 2);
} else if (config.endsWith("ft")) {
type = Distance.FOOT;
_config = _config.substring(0, _config.length() - 2);
} else if (_config.endsWith("in") == true) {
config = config.substring(0, config.length() - 2);
} else if (config.endsWith("in")) {
type = Distance.INCH;
_config = _config.substring(0, _config.length() - 2);
} else if (_config.endsWith("km") == true) {
config = config.substring(0, config.length() - 2);
} else if (config.endsWith("km")) {
type = Distance.KILOMETER;
_config = _config.substring(0, _config.length() - 2);
} else if (_config.endsWith("mm") == true) {
config = config.substring(0, config.length() - 2);
} else if (config.endsWith("mm")) {
type = Distance.MILLIMETER;
_config = _config.substring(0, _config.length() - 2);
} else if (_config.endsWith("cm") == true) {
config = config.substring(0, config.length() - 2);
} else if (config.endsWith("cm")) {
type = Distance.CENTIMETER;
_config = _config.substring(0, _config.length() - 2);
} else if (_config.endsWith("m") == true) {
config = config.substring(0, config.length() - 2);
} else if (config.endsWith("m")) {
type = Distance.METER;
_config = _config.substring(0, _config.length() - 1);
config = config.substring(0, config.length() - 1);
} else {
Log.critical("Can not parse dimention : '" + _config + "'");
return;
Log.critical("Can not parse dimension : '" + config + "'");
return null;
}
final Vector2f tmp = Vector2f.valueOf(_config);
set(tmp, type);
Log.verbose(" config dimention : \"" + _config + "\" == > " + this);
}
public void set(final Vector2f _size) {
this.size = _size;
this.type = Distance.PIXEL;
final Vector2f tmp = Vector2f.valueOf(config);
final Dimension ret = new Dimension(tmp, type);
Log.verbose(" config dimension : '" + config + "' == > " + ret.toString());
return ret;
}
/**
* @brief set the current dimention in requested type
* @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 :
* string cast :
*/
@Override
public String toString() {
String str = get(getType()).toString();
switch (getType()) {
case POURCENT:
str += "%";
break;
case PIXEL:
str += "px";
break;
case METER:
str += "m";
break;
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;
case POURCENT -> str += "%";
case PIXEL -> str += "px";
case METER -> str += "m";
case CENTIMETER -> str += "cm";
case MILLIMETER -> str += "mm";
case KILOMETER -> str += "km";
case INCH -> str += "in";
case FOOT -> str += "ft";
default -> str += "";
}
return str;
}

View File

@ -1,5 +1,6 @@
package org.atriasoft.gale;
import org.atriasoft.etk.Uri;
import org.atriasoft.gale.context.Context;
//import org.atriasoft.gale.context.JOGL.ContextJOGL;
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;
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:
* 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
@ -20,7 +37,8 @@ public class Gale {
* @param _argv Standard argv
* @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);
Context context = null;
String request = "";
@ -34,17 +52,6 @@ public class Gale {
}
return context.run();
}
/**
* @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();
}
private Gale() {}
}

File diff suppressed because it is too large Load Diff

View File

@ -3,14 +3,14 @@ package org.atriasoft.gale.context;
public class 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 _data The string that might be send to the clipboard
*/
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,
* 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
@ -19,7 +19,7 @@ public class ClipBoard {
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.
* @param _clipboardID selected clipboard ID
* @param _data new buffer data
@ -27,7 +27,7 @@ public class ClipBoard {
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.
* @note if we call this fuction withoutcallin @ref gale::context::clipBoard::Request, we only get the previous clipboard
* @param _clipboardID selected clipboard ID

View File

@ -28,7 +28,7 @@ public abstract class Context {
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.
*/
public static Context getContext() {
@ -78,13 +78,13 @@ public abstract class Context {
// this.displayFps=true;
// } else if ( this.commandLine.get(iii) == "-h"
// || 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-fps");
// Log.print(" Display the current fps of the display");
// Log.print(" -h/--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) << "'");
// // remove parameter ...
// } else {
@ -101,14 +101,14 @@ public abstract class Context {
Log.info("GALE v:" + Gale.getVersion());
forceOrientation(Orientation.screenAuto);
postAction((_context) -> {
final Application appl = _context.getApplication();
postAction((context) -> {
final Application appl = context.getApplication();
if (appl == null) {
return;
}
appl.onCreate(_context);
appl.onStart(_context);
appl.onResume(_context);
appl.onCreate(context);
appl.onStart(context);
appl.onResume(context);
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
* @param _clipboardID ID of the clipboard (STD/SELECTION) only apear here
* Inform the Gui that we want to have a copy of the clipboard
* @param clipboardID ID of the clipboard (STD/SELECTION) only apear here
*/
public void clipBoardGet(final ClipboardList clipboardID) {
// 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
* @param _clipboardID ID of the clipboard (STD/SELECTION) only apear here
* Inform the Gui that we are the new owner of the clipboard
* @param clipboardID ID of the clipboard (STD/SELECTION) only apear here
*/
public void clipBoardSet(final ClipboardList clipboardID) {
// nothing to do, data is already copyed in the GALE clipborad center
}
/**
* @brief force the screen orientation (availlable on portable elements ...
* @param _orientation Selected orientation.
* force the screen orientation (availlable on portable elements ...
* @param orientation Selected orientation.
*/
public void forceOrientation(final Orientation orientation) {}
/**
* @brief Redraw all the windows
* Redraw all the windows
*/
public void forceRedrawAll() {
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.
*/
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 ...
*/
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)
* @param _status "true" if all the event will be get, false if we want only ours.
* 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.
*/
public void grabKeyboardEvents(final boolean status) {}
/**
* @brief 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 _forcedPosition the position where the mouse might be reset at every events ...
* 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 forcedPosition the position where the mouse might be reset at every events ...
*/
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() {
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() {
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() {
Log.info("keyboardShow: NOT implemented ...");
@ -242,13 +242,13 @@ public abstract class Context {
}
/**
* @brief Open an URL on an eternal brother.
* @param _url URL to open.
* Open an URL on an eternal brother.
* @param url URL to open.
*/
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() {
// 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)
* @param Id of the clipboard
* Call by the OS when a clipboard arrive to US (previously requested by a widget)
* @param clipboardID of the clipboard
*/
public void operatingSystemClipBoardArrive(final ClipboardList clipboardID) {
postAction((context) -> {
@ -297,7 +297,7 @@ public abstract class Context {
OpenGL.threadHasContext();
OpenGL.resetFlagState();
// process the events
if (this.displayFps == true) {
if (this.displayFps) {
this.fpsSystemEvent.tic();
}
boolean needRedraw = false;
@ -333,52 +333,52 @@ public abstract class Context {
{
// Lock openGl context:
OpenGL.lock();
if (this.displayFps == true) {
if (this.displayFps) {
this.fpsSystemContext.tic();
}
if (needRedraw = true || displayEveryTime == true) {
if (needRedraw || displayEveryTime) {
//Log.debug(" ==> real Draw");
lockContext();
this.resourceManager.updateContext();
unLockContext();
if (this.displayFps == true) {
if (this.displayFps) {
this.fpsSystemContext.incrementCounter();
}
}
if (this.displayFps == true) {
if (this.displayFps) {
this.fpsSystemContext.toc();
this.fpsSystem.tic();
}
if (this.application != null) {
if (needRedraw == true || displayEveryTime == true) {
if (needRedraw || displayEveryTime) {
this.fpsSystem.incrementCounter();
// set the current interface :
lockContext();
if (this.application.canDraw == true) {
if (this.application.canDraw) {
this.application.onDraw(this);
}
unLockContext();
hasDisplayDone = true;
}
}
if (this.displayFps == true) {
if (this.displayFps) {
this.fpsSystem.toc();
this.fpsFlush.tic();
}
if (hasDisplayDone == true) {
//Log.info("lklklklklk " << _displayEveryTime);
if (this.displayFps == true) {
if (hasDisplayDone) {
//Log.info("lklklklklk " << displayEveryTime);
if (this.displayFps) {
this.fpsFlush.incrementCounter();
}
OpenGL.flush();
}
if (this.displayFps == true) {
if (this.displayFps) {
this.fpsFlush.toc();
}
// release open GL Context
OpenGL.unLock();
}
if (this.displayFps == true) {
if (this.displayFps) {
this.fpsSystemEvent.draw();
this.fpsSystemContext.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() {
// 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() {
postAction((context) -> {
/*
Application> appl = _context.getApplication();
Application> appl = context.getApplication();
if (appl == null) {
return;
}
appl.onKeyboard(_special,
_type,
_char,
_state);
appl.onKeyboard(special,
type,
char,
state);
*/
Log.todo("HIDE ... ");
});
};
/**
* @brief The OS inform that the current windows has change his position.
* @param _pos New position of the Windows.
* The OS inform that the current windows has change his position.
* @param pos New position of the Windows.
*/
public void operatingSystemMove(final Vector2f _pos) {
if (this.windowsPos.isEqual(_pos)) {
public void operatingSystemMove(final Vector2f pos) {
if (this.windowsPos.isEqual(pos)) {
return;
}
postAction((context) -> {
Log.debug("Receive MSG : THREAD_MOVE : " + context.windowsPos + " ==> " + _pos);
context.windowsPos = _pos;
Log.debug("Receive MSG : THREADMOVE : " + context.windowsPos + " ==> " + pos);
context.windowsPos = pos;
final Application appl = context.getApplication();
if (appl == null) {
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() {
this.resourceManager.contextHasBeenDestroyed();
};
/**
* @brief The OS inform that the current windows has change his size.
* @param _size new size of the windows.
* The OS inform that the current windows has change his size.
* @param size new size of the windows.
*/
public void operatingSystemResize(final Vector2f _size) {
if (this.windowsSize == _size) {
public void operatingSystemResize(final Vector2f size) {
if (this.windowsSize == size) {
return;
}
// TODO Better in the thread ... ==> but generate some init error ...
//gale::Dimension::setPixelWindowsSize(_size);
//gale::Dimension::setPixelWindowsSize(size);
postAction((context) -> {
Log.debug("Receive MSG : THREAD_RESIZE : " + context.windowsSize + " ==> " + _size);
context.windowsSize = _size;
//gale::Dimension::setPixelWindowsSize(_context.windowsSize);
Log.debug("Receive MSG : THREADRESIZE : " + context.windowsSize + " ==> " + size);
context.windowsSize = size;
//gale::Dimension::setPixelWindowsSize(context.windowsSize);
final Application tmpAppl = context.getApplication();
if (tmpAppl != null) {
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() {
// 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) {
KeyStatus tmpState = state;
if (isARepeateKey == true) {
if (isARepeateKey) {
if (tmpState == KeyStatus.down) {
tmpState = KeyStatus.downRepeate;
tmpState = KeyStatus.downRepeat;
} else {
tmpState = KeyStatus.upRepeate;
tmpState = KeyStatus.upRepeat;
}
}
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() {
postAction((context) -> {
/*
Application> appl = _context.getApplication();
Application> appl = context.getApplication();
if (appl == null) {
return;
}
appl.onKeyboard(_special,
_type,
_char,
_state);
appl.onKeyboard(special,
type,
char,
state);
*/
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() {
// 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() {
// 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() {
int nbEvent = 0;
@ -648,63 +648,63 @@ public abstract class Context {
// }
public void requestUpdateSize() {
postAction((context) -> {
//Log.debug("Receive MSG : THREAD_RESIZE");
//Log.debug("Receive MSG : THREADRESIZE");
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() {
// 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
* @note INTERNAL API
*/
public abstract int run();
/**
* @brief set the cursor display type.
* @param NewCursor selected new cursor.
* set the cursor display type.
* @param newCursor selected new cursor.
*/
public void setCursor(final Cursor newCursor) {}
/**
* @brief The application request a change of his current size force the fullscreen mode.
* @param _status status of the fullscreen mode.
* The application request a change of his current size force the fullscreen mode.
* @param status status of the fullscreen mode.
*/
public void setFullScreen(final boolean status) {
this.fullscreen = status;
}
/**
* @brief set the Icon of the program
* @param _inputFile new filename icon of the current program.
* set the Icon of the program
* @param inputFile new filename icon of the current program.
*/
public void setIcon(final Uri inputFile) {};
/**
* @brief The Application request that the current windows will change his position.
* @param _pos New position of the Windows requested.
* The Application request that the current windows will change his position.
* @param pos New position of the Windows requested.
*/
public void setPos(final Vector2f pos) {
Log.info("setPos: NOT implemented ...");
};
/**
* @brief The application request a change of his current size.
* @param _size new Requested size of the windows.
* The application request a change of his current size.
* @param size new Requested size of the windows.
*/
public void setSize(final Vector2f size) {
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
*/
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)
* @param _status "true" to enable decoration / false otherwise
* Enable or Disable the decoration on the Windows (availlable only on Desktop)
* @param status "true" to enable decoration / false otherwise
*/
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() {
Log.info("show: NOT implemented ...");
};
/**
* @brief StartProcessing (2nd thread).
* StartProcessing (2nd thread).
* @note to call when all the Context is started
*/
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() {
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 valueInsert = false;
/**
* @brief Main ructor
* Main ructor
*/
public KeySpecial() {
}
/**
* @brief get the current CapLock Status
* get the current CapLock Status
* @return The CapLock value
*/
public boolean getCapsLock() {
return valueCapLock;
}
/**
* @brief set the current CapLock Status
* set the current CapLock Status
* @param value The new CapLock value
*/
public void setCapsLock(boolean value) {
valueCapLock = value;
}
/**
* @brief Get the current Shift key status
* Get the current Shift key status
* @return The Shift value
*/
public boolean getShift() {
return valueShiftLeft || valueShiftRight;
}
/**
* @brief Get the current Shift left key status
* Get the current Shift left key status
* @return The Shift value
*/
public boolean getShiftLeft() {
return valueShiftLeft;
}
/**
* @brief Get the current Shift right key status
* Get the current Shift right key status
* @return The Shift value
*/
public boolean getShiftRight() {
return valueShiftRight;
}
/**
* @brief Set the current Shift left key status
* Set the current Shift left key status
* @param value The new Shift value
*/
public void setShiftLeft(boolean value) {
valueShiftLeft = value;
}
/**
* @brief Set the current Shift right key status
* Set the current Shift right key status
* @param value The new Shift value
*/
public void setShiftRight(boolean value) {
valueShiftRight = value;
}
/**
* @brief Get the Current Control key status
* Get the Current Control key status
* @return The Control value
*/
public boolean getCtrl() {
return valueCtrlLeft || valueCtrlRight;
}
/**
* @brief Get the Current Control left key status
* Get the Current Control left key status
* @return The Control value
*/
public boolean getCtrlLeft() {
return valueCtrlLeft;
}
/**
* @brief Get the Current Control right key status
* Get the Current Control right key status
* @return The Control value
*/
public boolean getCtrlRight() {
return valueCtrlRight;
}
/**
* @brief Set the Current Control left key status
* Set the Current Control left key status
* @param value The new Control value
*/
public void setCtrlLeft(boolean value){
valueCtrlLeft = value;
}
/**
* @brief Set the Current Control right key status
* Set the Current Control right key status
* @param value The new Control value
*/
public void setCtrlRight(boolean 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 ...)
*/
public boolean getMeta() {
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 ...)
*/
public boolean getMetaLeft() {
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 ...)
*/
public boolean getMetaRight() {
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 ...)
*/
public void setMetaLeft(boolean 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 ...)
*/
public void setMetaRight(boolean value) {
valueMetaRight = value;
}
/**
* @brief Get the current Alt key status
* Get the current Alt key status
* @return The Alt value
*/
public boolean getAlt() {
return valueAltLeft || valueAltRight;
}
/**
* @brief Get the current Alt left key status
* Get the current Alt left key status
* @return The Alt value
*/
public boolean getAltLeft() {
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
*/
public boolean getAltRight() {
return valueAltRight;
}
/**
* @brief Set the current Alt left key status
* Set the current Alt left key status
* @param value The new Alt value
*/
public void setAltLeft(boolean 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
*/
public void setAltRight(boolean 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)
*/
public boolean getAltGr() {
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)
*/
public void setAltGr(boolean value) {
setAltRight(value);
}
/**
* @brief Get the current Ver-num key status
* Get the current Ver-num key status
* @return The Numerical Lock value
*/
public boolean getNumLock() {
return valueNumLock;
}
/**
* @brief Set the current Ver-num key status
* Set the current Ver-num key status
* @param value The new Numerical Lock value
*/
public void setNumLock(boolean value) {
valueNumLock = value;
}
/**
* @brief Get the current Intert key status
* Get the current Intert key status
* @return The Insert value
*/
public boolean getInsert() {
return valueInsert;
}
/**
* @brief Set the current Intert key status
* Set the current Intert key status
* @param value The new Insert value
*/
public void setInsert(boolean 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 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.
* @return true The key is pressed.
* @return false The key is released.

View File

@ -1,37 +1,32 @@
package org.atriasoft.gale.key;
public enum KeyStatus {
unknow,
down, // availlable on Keyboard too
downRepeate, // availlable on Keyboard too: the down event us in repeate cycle
unknown,
down, // available on Keyboard too
downRepeat, // available on Keyboard too: the down event us in repeate cycle
move,
pressSingle,
pressDouble,
pressTriple,
pressQuad,
pressQuinte,
up, // availlable on Keyboard too
upRepeate, // availlable on Keyboard too: the up event us in repeate cycle
pressQuint,
up, // available on Keyboard too
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...)
enter,
leave,
abort, // Appeare 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)
abort, // Appear when an event is tranfert betwwen widgets (the widget which receive this has lost the events)
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) {
switch (i) {
case 1:
return pressSingle;
case 2:
return pressDouble;
case 3:
return pressTriple;
case 4:
return pressQuad;
case 5:
return pressQuinte;
}
return unknow;
return switch (i) {
case 1 -> pressSingle;
case 2 -> pressDouble;
case 3 -> pressTriple;
case 4 -> pressQuad;
case 5 -> pressQuint;
default -> unknown;
};
}
}

View File

@ -10,7 +10,7 @@ public abstract class Resource {
private static int idGenerated = 10;
/**
* @brief Get the current resource Manager
* Get the current resource Manager
*/
protected static ResourceManager getManager() {
return Context.getContext().getResourcesManager();
@ -22,7 +22,7 @@ public abstract class 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() {
this.uid = idGenerated++;
@ -50,7 +50,7 @@ public abstract class Resource {
}
/**
* @brief get the resource name
* get the resource name
* @return The requested name
*/
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]
*/
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() {
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() {
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
*/
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.
*/
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.
* @return true The context is updated
* @return false The context is not updated

View File

@ -30,7 +30,7 @@ public class ResourceColored3DObject extends Resource {
super();
// get the shader resource :
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) {
this.oGLMatrixTransformation = this.program.getUniform("in_matrixTransformation");
this.oGLMatrixProjection = this.program.getUniform("in_matrixProjection");
@ -49,9 +49,9 @@ public class ResourceColored3DObject extends Resource {
private float[] convertInFloat(final List<Vector3f> data) {
final float[] out = new float[data.size() * 3];
for (int iii = 0; iii < data.size(); iii++) {
out[iii * 3] = data.get(iii).x;
out[iii * 3 + 1] = data.get(iii).y;
out[iii * 3 + 2] = data.get(iii).z;
out[iii * 3] = data.get(iii).x();
out[iii * 3 + 1] = data.get(iii).y();
out[iii * 3 + 2] = data.get(iii).z();
}
return out;
}
@ -64,9 +64,9 @@ public class ResourceColored3DObject extends Resource {
Log.error("No shader ...");
return;
}
if (true == depthtest) {
if (depthtest) {
OpenGL.enable(OpenGL.Flag.flag_depthTest);
if (false == updateDepthBuffer) {
if (!updateDepthBuffer) {
OpenGL.setDeathMask(false);
}
}
@ -74,7 +74,7 @@ public class ResourceColored3DObject extends Resource {
this.program.use();
final Matrix4f projectionMatrix = OpenGL.getMatrix();
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.oGLMatrixProjection, projectionMatrix);
this.program.uniformMatrix(this.oGLMatrixTransformation, transformationMatrix);
@ -83,20 +83,20 @@ public class ResourceColored3DObject extends Resource {
// position :
final FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices));
this.program.sendAttribute(this.oGLPosition, 3, buffer, 3);
if (color.a < 1.0f) {
if (color.a() < 1.0f) {
OpenGL.enable(OpenGL.Flag.flag_blend);
}
// Request the draw of the elements:
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size());
if (color.a < 1.0f) {
if (color.a() < 1.0f) {
OpenGL.disable(OpenGL.Flag.flag_blend);
}
this.program.unUse();
// Request the draw od the elements:
//glDrawArrays(oGLLINES, 0, vertices.size());
//this.oGLprogram.UnUse();
if (true == depthtest) {
if (false == updateDepthBuffer) {
if (depthtest) {
if (!updateDepthBuffer) {
OpenGL.setDeathMask(true);
}
OpenGL.disable(OpenGL.Flag.flag_depthTest);
@ -111,9 +111,9 @@ public class ResourceColored3DObject extends Resource {
Log.error("No shader ...");
return;
}
if (true == depthtest) {
if (depthtest) {
OpenGL.enable(OpenGL.Flag.flag_depthTest);
if (false == updateDepthBuffer) {
if (!updateDepthBuffer) {
OpenGL.setDeathMask(false);
}
}
@ -131,17 +131,17 @@ public class ResourceColored3DObject extends Resource {
// color :
//Log.info("color= " + color + " " + this.oGLPosition);
this.program.uniformColor(this.oGLColor, color);
if (color.a < 1.0f) {
if (color.a() < 1.0f) {
OpenGL.enable(OpenGL.Flag.flag_blend);
}
// Request the draw of the elements:
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size());
if (color.a < 1.0f) {
if (color.a() < 1.0f) {
OpenGL.disable(OpenGL.Flag.flag_blend);
}
this.program.unUse();
if (true == depthtest) {
if (false == updateDepthBuffer) {
if (depthtest) {
if (!updateDepthBuffer) {
OpenGL.setDeathMask(true);
}
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) {
final List<Vector3f> vertices = new ArrayList<>();
vertices.add(new Vector3f(min.x, min.y, min.z));
vertices.add(new Vector3f(max.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, max.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(min.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, min.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, max.y, min.z));
vertices.add(new Vector3f(max.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, max.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(min.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, min.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, min.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(), max.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(), min.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, max.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(min.x, min.y, max.z));
vertices.add(new Vector3f(min.x, max.y, max.z));
vertices.add(new Vector3f(min.x(), min.y(), max.z()));
vertices.add(new Vector3f(min.x(), max.y(), max.z()));
drawLine(vertices, color, transformationMatrix, updateDepthBuffer, depthtest);
}
@ -402,9 +402,9 @@ public class ResourceColored3DObject extends Resource {
Log.error("No shader ...");
return;
}
if (true == depthtest) {
if (depthtest) {
OpenGL.enable(OpenGL.Flag.flag_depthTest);
if (false == updateDepthBuffer) {
if (!updateDepthBuffer) {
OpenGL.setDeathMask(false);
}
}
@ -421,17 +421,17 @@ public class ResourceColored3DObject extends Resource {
this.program.sendAttribute(this.oGLPosition, 3, buffer, 3);
// color :
this.program.uniformColor(this.oGLColor, color);
if (color.a < 1.0f) {
if (color.a() < 1.0f) {
OpenGL.enable(OpenGL.Flag.flag_blend);
}
// Request the draw od the elements:
OpenGL.drawArrays(OpenGL.RenderMode.line, 0, vertices.size());
if (color.a < 1.0f) {
if (color.a() < 1.0f) {
OpenGL.disable(OpenGL.Flag.flag_blend);
}
this.program.unUse();
if (true == depthtest) {
if (false == updateDepthBuffer) {
if (depthtest) {
if (!updateDepthBuffer) {
OpenGL.setDeathMask(true);
}
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) {
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 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) };
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()) };
tmpVertices.clear();
for (int iii = 0; iii < 36; iii += 3) {
// 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) {
final List<Vector3f> tmpVertices = new ArrayList<>();
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 + 1)).addNew(offset));
tmpVertices.add(vertex.get(indice.get(iii * 3 + 2)).addNew(offset));
tmpVertices.add(vertex.get(indice.get(iii * 3 + 0)).add(offset));
tmpVertices.add(vertex.get(indice.get(iii * 3 + 1)).add(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(" 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;
/**
* @brief initialize the internal variable
* initialize the internal variable
*/
public ResourceManager() {
}
/**
* @brief special end of application
* special end of application
*/
public void applicationExiting() {
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() {
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() {
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
*/
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...
*/
//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() {
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
*/
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() {
if (this.exiting == true) {
if (this.exiting) {
Log.error("Request update after application EXIT ...");
return;
}
// TODO Check the number of call this ... Log.info("update open-gl context ... ");
if (this.contextHasBeenRemoved == true) {
if (this.contextHasBeenRemoved) {
// need to update all ...
this.contextHasBeenRemoved = false;
this.resourceListToUpdate.clear();
@ -173,7 +173,7 @@ public class ResourceManager {
for (final Resource it : this.resourceList) {
if (jjj == it.getResourceLevel()) {
//Log.debug("Update context named : " + lresourceList[iii].getName());
if (it.updateContext() == false) {
if (!it.updateContext()) {
// Lock error ==> postponned
this.resourceListToUpdate.add(it);
}
@ -193,7 +193,7 @@ public class ResourceManager {
Log.verbose(" updateContext level (U) : " + jjj + "/" + (MAX_RESOURCE_LEVEL - 1));
for (final Resource it : resourceListToUpdate) {
if (jjj == it.getResourceLevel()) {
if (it.updateContext() == false) {
if (!it.updateContext()) {
// Lock error ==> postponned
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;
Resource resource2;
final String name = uriShader.getValue();
if (name.isEmpty() == false && name != "---") {
if (!name.isEmpty() && !name.equals("---")) {
resource2 = getManager().localKeep(name);
} else {
Log.error("Can not create a shader without a filaname");
@ -26,23 +26,18 @@ public class ResourceShader extends Resource {
return null;
}
resource = new ResourceShader(uriShader);
if (resource == null) {
Log.error("allocation error of a resource : " + name);
return null;
}
getManager().localAdd(resource);
return resource;
}
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 final ShaderType type; //!< Type of the current shader(vertex/fragment)
private final Uri uri;
/**
* @brief Contructor of an opengl Shader
* @param filename Standard file name format. see @ref etk::FSNode
* Constructor of an opengl Shader
* @param uri Standard file name format. see @ref etk::FSNode
*/
protected ResourceShader(final Uri uri) {
super(uri);
@ -64,7 +59,7 @@ public class ResourceShader extends Resource {
}
/**
* @brief Destructor, remove the current Shader
* Destructor, remove the current Shader
*/
@Override
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.
*/
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.
*/
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.
* @note this is really usefull when we tested the new themes or shader developpements.
* Reloaded the shader from the file. used when a request of resources reload is done.
* @note this is really useful when we tested the new themes or shader developments.
*/
@Override
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 ...
if (OpenGL.hasContext() == true) {
if (OpenGL.hasContext()) {
Log.debug("OGL : load SHADER '" + this.name + "' ==> call update context (direct)");
removeContext();
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
public void removeContext() {
if (true == this.exist) {
if (this.exist) {
OpenGL.shaderRemove(this.shader);
this.shader = -1;
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
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
public boolean updateContext() {
if (this.exist == true) {
// Do nothing == > too dangerous ...
} else {
this.shader = OpenGL.shaderLoad(this.uri.get(), this.type);
if (!this.exist) {
this.shader = OpenGL.shaderLoad(this.uri, this.type);
// create the Shader
if (this.shader < 0) {
return true;

View File

@ -32,7 +32,7 @@ public class ResourceTexture extends Resource {
ResourceTexture resource;
Resource resource2;
final String name = uriTexture.getValue();
if (name.isEmpty() == false && name != "---") {
if (!name.isEmpty() && !name.equals("---")) {
resource2 = getManager().localKeep(name);
} else {
Log.error("Can not create a shader without a filaname");
@ -48,14 +48,14 @@ public class ResourceTexture extends Resource {
}
resource = new ResourceTexture(uriTexture, textureUnit);
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);
resource.flush();
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
* @return result value
*/
@ -105,7 +105,7 @@ public class ResourceTexture extends Resource {
}
public void bindForRendering(final int idTexture) {
if (this.loaded == false) {
if (!this.loaded) {
return;
}
GL13.glActiveTexture(textureIdBinding[idTexture]);
@ -142,7 +142,7 @@ public class ResourceTexture extends Resource {
@Override
public synchronized void removeContext() {
if (this.loaded == true) {
if (this.loaded) {
// Request remove texture ...
Log.info("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
// TODO Check if we are in the correct thread
@ -161,14 +161,13 @@ public class ResourceTexture extends Resource {
this.data = data;
this.size = size;
this.textureUnit = textureUnit;
this.endPointSize.x = size.x;
this.endPointSize.y = size.y;
this.endPointSize = new Vector2f(size.x(), size.y());
this.dataColorSpace = dataColorSpace;
flush();
}
public void unBindForRendering() {
if (this.loaded == false) {
if (!this.loaded) {
return;
}
if (this.dataColorSpace == TextureColorMode.rgb) {
@ -180,7 +179,7 @@ public class ResourceTexture extends Resource {
// Gale internal API:
@Override
public boolean updateContext() {
if (this.loaded == true) {
if (this.loaded) {
return true;
}
// Request a new texture at openGl :
@ -192,9 +191,9 @@ public class ResourceTexture extends Resource {
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
Log.info("TEXTURE: add [" + getId() + "]=" + this.size + " OGlId=" + this.texId);
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 {
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
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);

View File

@ -76,10 +76,6 @@ public class ResourceVirtualArrayObject extends Resource {
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) {
super();
this.resourceLevel = 3;
@ -93,7 +89,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
public void bindForRendering() {
if (this.exist == false) {
if (!this.exist) {
return;
}
GL30.glBindVertexArray(this.vaoID);
@ -113,7 +109,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
private void bindIndicesBuffer(final int[] indices) {
final int vboId = OpenGL.glGenBuffers();
final int vboId = OpenGL.genBuffers();
this.vbo.add(vboId);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboId);
final IntBuffer buffer = storeDataInIntBuffer(indices);
@ -121,7 +117,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
/**
* @brief Destructor of this VBO.
* Destructor of this VBO.
*/
@Override
public void cleanUp() {
@ -129,7 +125,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
/**
* @brief clear buffers
* clear buffers
*/
public void clear() {
//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() {
// 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.
*/
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.
*/
@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
public void removeContext() {
if (this.exist == true) {
if (this.exist) {
// OpenGL.deleteBuffers(this.vbo);
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
public void removeContextToLate() {
this.exist = false;
// for (int iii=0; iii<this.vbo.length; iii++) {
// this.vbo[iii] = 0;
@ -233,7 +227,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
public void unBindForRendering() {
if (this.exist == false) {
if (!this.exist) {
return;
}
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
public boolean updateContext() {
//Log.verbose(" Start: [" + getId() + "] '" + getName() + "' (size=" + this.indices.length + ") ********************************");
if (this.exist == false) {
if (!this.exist) {
Log.debug(" ==> ALLOCATE new handle");
// Allocate and assign a Vertex Array Object to our handle
loadToVAO();

View File

@ -5,6 +5,8 @@
*/
package org.atriasoft.gale.resource;
import java.util.Arrays;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f;
@ -13,7 +15,7 @@ import org.atriasoft.gale.backend3d.OpenGL.Usage;
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 {
@ -26,14 +28,14 @@ public class ResourceVirtualBufferObject extends Resource {
private final Object[] buffer; //!< data that is availlable in the VBO system ...
/**
* @brief Constructor of this VBO.
* @param[in] accesMode Acces mode : ???
* Constructor of this VBO.
* @param accesMode Acces mode : ???
*/
protected ResourceVirtualBufferObject(final int _number) {
protected ResourceVirtualBufferObject(final int number) {
super();
this.vbo = new int[_number]; // 0
this.buffer = new Object[_number];
Log.debug("OGL : load VBO count=\"" + _number + "\"");
this.vbo = new int[number]; // 0
this.buffer = new Object[number];
Log.debug("OGL : load VBO count=\"" + number + "\"");
this.resourceLevel = 3;
}
@ -63,18 +65,16 @@ public class ResourceVirtualBufferObject extends Resource {
}
/**
* @brief clear buffers
* clear buffers
*/
public void clear() {
Log.verbose(" Clear: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.length + ")");
// DO not clear the this.vbo indexed in the graphic cards ...
for (int iii = 0; iii < this.buffer.length; iii++) {
this.buffer[iii] = null;
}
Arrays.fill(this.buffer, null);
}
/**
* @brief Send the data to the graphic card.
* Send the data to the graphic card.
*/
public synchronized void flush() {
// 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.
*/
public int getGL_ID(final int _id) {
return this.vbo[_id];
public int getOpenGlId(final int 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.
*/
@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
public synchronized void removeContext() {
if (this.exist == true) {
if (this.exist) {
OpenGL.deleteBuffers(this.vbo);
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
public synchronized void removeContextToLate() {
this.exist = false;
for (int iii = 0; iii < this.vbo.length; iii++) {
this.vbo[iii] = 0;
}
Arrays.fill(this.vbo, 0);
}
/**
* @brief get the data from the graphic card.
* get the data from the graphic card.
*/
public void retreiveData() {
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
public synchronized boolean updateContext() {
@ -182,7 +180,7 @@ public class ResourceVirtualBufferObject extends Resource {
return false;
}
*/
if (this.exist == false) {
if (!this.exist) {
Log.debug(" ==> ALLOCATE new handle");
// Allocate and assign a Vertex Array Object to our handle
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.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:
this.verticesVBO.setName("[VBO] of basic SAMPLE");
// 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)
OpenGL.setViewPort(new Vector2f(0,0), size);
// Clear all the stacked matrix ...
OpenGL.setBasicMatrix(Matrix4f.identity());
OpenGL.setBasicMatrix(Matrix4f.IDENTITY);
// clear background
Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f);
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.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:
this.verticesVBO.setName("[VBO] of basic SAMPLE");
// 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)
OpenGL.setViewPort(new Vector2f(0,0), size);
// Clear all the stacked matrix ...
OpenGL.setBasicMatrix(Matrix4f.identity());
OpenGL.setBasicMatrix(Matrix4f.IDENTITY);
// clear background
Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f);
OpenGL.enable(OpenGL.Flag.flag_depthTest);
@ -143,12 +139,12 @@ public class Sample2Application extends Application {
// set Matrix : translation/positionMatrix
Matrix4f projectionMatrix = tmpProjection; //OpenGL.getMatrix();
Matrix4f transforamtionMatrix = Matrix4f.identity();
transforamtionMatrix.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-1)));
transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(1,0,0),this.angleX));
transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,1,0),this.angleY));
transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,0,1),this.angleZ));
Matrix4f viewMatrix = OpenGL.getCameraMatrix().multiplyNew(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-2)));
Matrix4f transforamtionMatrix = Matrix4f.IDENTITY;
transforamtionMatrix = transforamtionMatrix.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-1)));
transforamtionMatrix = transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(1,0,0),this.angleX));
transforamtionMatrix = transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,1,0),this.angleY));
transforamtionMatrix = transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,0,1),this.angleZ));
Matrix4f viewMatrix = OpenGL.getCameraMatrix().multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-2)));
//Matrix4f tmpMatrix = projMatrix * camMatrix;
this.verticesVBO.bindForRendering();
this.oGLprogram.uniformMatrix(this.oGLMatrixView, viewMatrix);

View File

@ -1,6 +1,5 @@
package org.atriasoft.gale.tools;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
@ -11,39 +10,39 @@ import de.matthiasmann.twl.utils.PNGDecoder;
import de.matthiasmann.twl.utils.PNGDecoder.Format;
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() {}
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 org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
//import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
@TestMethodOrder(OrderAnnotation.class)