Compare commits

..

No commits in common. "dev" and "main" have entirely different histories.
dev ... main

96 changed files with 2647 additions and 3081 deletions

106
.classpath Normal file
View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/__*" kind="src" path="src">
<attributes>
<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"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-14">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl3-awt-0.1.7.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/pngdecoder.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-assimp.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-assimp-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-glfw.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-glfw-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-jawt.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-opengl.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-stb.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-stb-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/lwjgl/lwjgl-opengl-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-egami">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-etk">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-io-gami">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="out/eclipse/classes"/>
</classpath>

2
.gitignore vendored
View File

@ -1,5 +1,3 @@
/__pycache__/
/bin/
/Operator/
/DrawerProperties/

24
.project Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>atriasoft-gale</name>
<comment></comment>
<projects>
<project>atriasoft-gale</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>

BIN
lib/jogamp-fat.jar Normal file

Binary file not shown.

29
lib/lwjgl/LICENSE Normal file
View File

@ -0,0 +1,29 @@
Copyright (c) 2012-present Lightweight Java Game Library
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name Lightweight Java Game Library nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,78 @@
Open Asset Import Library (assimp)
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************
AN EXCEPTION applies to all files in the ./test/models-nonbsd folder.
These are 3d models for testing purposes, from various free sources
on the internet. They are - unless otherwise stated - copyright of
their respective creators, which may impose additional requirements
on the use of their work. For any of these models, see
<model-name>.source.txt for more legal information. Contact us if you
are a copyright holder and believe that we credited you inproperly or
if you don't want your files to appear in the repository.
******************************************************************************
Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
http://code.google.com/p/poly2tri/
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Poly2Tri nor the names of its contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

1
lib/lwjgl/build.txt Normal file
View File

@ -0,0 +1 @@
LWJGL 3.2.3 SNAPSHOT build 13

View File

@ -0,0 +1,14 @@
Copyright (c) 2007-2015 Daniel Adler <dadler AT uni-goettingen DOT de>,
Tassilo Philipp <tphilipp AT potion-studios DOT com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -0,0 +1,21 @@
Copyright (c) 2002-2006 Marcus Geelnard
Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would
be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.

View File

@ -0,0 +1,22 @@
/*
** Copyright (c) 2013-2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl/lwjgl-assimp.jar Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl/lwjgl-egl.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl/lwjgl-glfw.jar Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl/lwjgl-jawt.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl/lwjgl-openal.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl/lwjgl-opengl.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl/lwjgl-sources.jar Normal file

Binary file not shown.

View File

@ -0,0 +1,27 @@
{
"build": "stable",
"mode": "zip",
"selectedAddons": [],
"platform": [
"linux"
],
"descriptions": false,
"compact": false,
"hardcoded": false,
"javadoc": false,
"includeJSON": true,
"source": true,
"osgi": false,
"language": "groovy",
"contents": [
"lwjgl",
"lwjgl-assimp",
"lwjgl-egl",
"lwjgl-glfw",
"lwjgl-jawt",
"lwjgl-openal",
"lwjgl-opengl",
"lwjgl-opengles",
"lwjgl-stb"
]
}

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl/lwjgl-stb.jar Normal file

Binary file not shown.

BIN
lib/lwjgl/lwjgl.jar Normal file

Binary file not shown.

View File

@ -0,0 +1,481 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl3-awt-0.1.7.jar Normal file

Binary file not shown.

BIN
lib/pngdecoder.jar Normal file

Binary file not shown.

View File

@ -1,100 +0,0 @@
#!/usr/bin/python
import realog.debug as debug
import lutin.tools as tools
import realog.debug as debug
import lutin.image as image
import os
import lutin.multiprocess as lutinMultiprocess
def get_type():
return "LIBRARY_DYNAMIC"
def get_desc():
return "Ewol Tool Kit"
def get_licence():
return "MPL-2"
def get_compagny_type():
return "org"
def get_compagny_name():
return "atria-soft"
#def get_maintainer():
# return "authors.txt"
#def get_version():
# return "version.txt"
def configure(target, my_module):
my_module.add_src_file([
'src/module-info.java',
'src/org/atriasoft/gale/TextureFilter.java',
'src/org/atriasoft/gale/internal/LOGGER.java',
'src/org/atriasoft/gale/DisplayManagerDraw.java',
'src/org/atriasoft/gale/test/sample1/Sample1.java',
'src/org/atriasoft/gale/test/sample1/Sample1Application.java',
'src/org/atriasoft/gale/test/sample1/LOGGER.java',
'src/org/atriasoft/gale/test/sample2/Sample2Application.java',
'src/org/atriasoft/gale/test/sample2/Main.java',
'src/org/atriasoft/gale/test/sample2/LOGGER.java',
'src/org/atriasoft/gale/context/ClipboardList.java',
'src/org/atriasoft/gale/context/Cursor.java',
'src/org/atriasoft/gale/context/LWJG_AWT/ContextLWJGLAWT.java',
'src/org/atriasoft/gale/context/GaleContext.java',
'src/org/atriasoft/gale/context/ClipBoard.java',
'src/org/atriasoft/gale/context/CommandLine.java',
'src/org/atriasoft/gale/context/GaleContextTest.java',
'src/org/atriasoft/gale/backend3d/OpenGL.java',
'src/org/atriasoft/gale/Orientation.java',
'src/org/atriasoft/gale/resource/ResourceTexture2.java',
'src/org/atriasoft/gale/resource/ResourceShader.java',
'src/org/atriasoft/gale/resource/ResourceTexture.java',
'src/org/atriasoft/gale/resource/ResourceManager.java',
'src/org/atriasoft/gale/resource/ResourceVirtualArrayObject.java',
'src/org/atriasoft/gale/resource/Resource.java',
'src/org/atriasoft/gale/resource/ResourceVirtualBufferObject.java',
'src/org/atriasoft/gale/resource/ResourceColored3DObject.java',
'src/org/atriasoft/gale/resource/ResourceTextureFile.java',
'src/org/atriasoft/gale/resource/ResourceProgram.java',
'src/org/atriasoft/gale/key/KeySpecial.java',
'src/org/atriasoft/gale/key/KeyStatus.java',
'src/org/atriasoft/gale/key/KeyType.java',
'src/org/atriasoft/gale/key/KeyKeyboard.java',
'src/org/atriasoft/gale/GaleApplication.java',
'src/org/atriasoft/gale/Fps.java',
'src/org/atriasoft/gale/Gale.java',
'src/org/atriasoft/gale/tools/ImageRawData.java',
'src/org/atriasoft/gale/tools/ImageLoader.java',
])
my_module.add_path('src/', type='java')
my_module.add_depend([
'org-atriasoft-iogami',
'org-atriasoft-pngdecoder',
])
my_module.add_path([
'lib/lwjgl/lwjgl.jar',
'lib/lwjgl3-awt-0.1.7.jar',
'lib/lwjgl/lwjgl-assimp.jar',
'lib/lwjgl/lwjgl-assimp-natives-linux.jar',
'lib/lwjgl/lwjgl-jawt.jar',
'lib/lwjgl/lwjgl-glfw-natives-linux.jar',
'lib/lwjgl/lwjgl-glfw.jar',
'lib/lwjgl/lwjgl-natives-linux.jar',
'lib/lwjgl/lwjgl-opengl.jar',
'lib/lwjgl/lwjgl-opengl-natives-linux.jar',
'lib/lwjgl/lwjgl-stb.jar',
'lib/lwjgl/lwjgl-stb-natives-linux.jar',
],
type='java',
export=True
);
my_module.add_flag('java', "RELEASE_15_PREVIEW");
return True

357
pom.xml
View File

@ -1,357 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.atriasoft</groupId>
<artifactId>gale</artifactId>
<version>0.1.0</version>
<properties>
<lwjgl.version>3.3.3</lwjgl.version>
<lwjgl3-awt.version>0.1.8</lwjgl3-awt.version>
<lwjgl.natives>natives-linux</lwjgl.natives>
</properties>
<licenses>
<license>
<name>Mozilla Public License 2.0</name>
<url>https://opensource.org/licenses/MPL-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>dev1</id>
<name>Edouard DUPIN</name>
<email>edouard.dupin@proton.me</email>
<roles>
<role>Lead Developer</role>
</roles>
</developer>
</developers>
<repositories>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
<snapshotRepository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</snapshotRepository>
</distributionManagement>
<!--
<profiles>
<profile>
<id>lwjgl-natives-linux-amd64</id>
<activation>
<os>
<family>unix</family>
<name>linux</name>
<arch>amd64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-linux</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-linux-aarch64</id>
<activation>
<os>
<family>unix</family>
<name>linux</name>
<arch>aarch64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-linux-arm64</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-linux-arm</id>
<activation>
<os>
<family>unix</family>
<name>linux</name>
<arch>arm</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-linux-arm32</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-linux-arm32</id>
<activation>
<os>
<family>unix</family>
<name>linux</name>
<arch>arm32</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-linux-arm32</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-macos-x86_64</id>
<activation>
<os>
<family>mac</family>
<arch>x86_64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-macos</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-macos-aarch64</id>
<activation>
<os>
<family>mac</family>
<arch>aarch64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-macos-arm64</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-windows-amd64</id>
<activation>
<os>
<family>windows</family>
<arch>amd64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-windows</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-windows-x86</id>
<activation>
<os>
<family>windows</family>
<arch>x86</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-windows-x86</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-windows-aarch64</id>
<activation>
<os>
<family>windows</family>
<arch>aarch64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-windows-arm64</lwjgl.natives>
</properties>
</profile>
</profiles>
-->
<!--
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-bom</artifactId>
<version>${lwjgl.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
-->
<dependencies>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>io-gami</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>png-decoder</artifactId>
<version>0.1.0</version>
</dependency>
<!-- generate with https://www.lwjgl.org/customize -->
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-assimp</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-jawt</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openal</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opengl</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-stb</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>${lwjgl.version}</version>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-assimp</artifactId>
<version>${lwjgl.version}</version>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
<version>${lwjgl.version}</version>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openal</artifactId>
<version>${lwjgl.version}</version>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opengl</artifactId>
<version>${lwjgl.version}</version>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-stb</artifactId>
<version>${lwjgl.version}</version>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjglx</groupId>
<artifactId>lwjgl3-awt</artifactId>
<version>${lwjgl3-awt.version}</version>
</dependency>
<!-- Test tools section-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<!-- generic logger of SLF4J to console (in color) -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.18</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main</sourceDirectory>
<resources>
<resource>
<directory>src/resources</directory>
</resource>
</resources>
<testSourceDirectory>src/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<!-- Create the source bundle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- junit results -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<!-- Java-doc generation for stand-alone site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
</configuration>
</plugin>
</plugins>
</build>
<!-- Generate Java-docs As Part Of Project Reports -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<show>public</show>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -1,88 +0,0 @@
package org.atriasoft.gale;
public class Fps {
private long startTime = 0;
private long nbCallTime = 0;
private long nbDisplayTime = 0;
private float min = (float) 99999999999999.0;
private float avg = 0;
private float max = 0;
private float minIdle = (float) 9999999999999.0;
private float avgIdle = 0;
private float maxIdle = 0;
private long ticTime = 0;
private boolean display = false;
private boolean drawingDone = false;
private String displayName = null;
private final boolean displayFPS;
public Fps(final String displayName, final boolean displayFPS) {
this.displayName = displayName;
this.displayFPS = displayFPS;
}
public void tic() {
long currentTime = System.nanoTime();
this.ticTime = currentTime;
this.nbCallTime++;
if (this.startTime == 0) {
this.startTime = currentTime;
}
if ( (currentTime - this.startTime) > 10000000000L) {
this.display = true;
}
}
public void toc() {
toc(false);
}
public void toc(final boolean displayTime) {
long currentTime = System.nanoTime();
long processTimeLocal = (currentTime - this.ticTime);
if (displayTime) {
System.out.println(this.displayName + ": processTime: " + processTimeLocal);
}
if (this.drawingDone) {
this.min = Math.min(this.min, processTimeLocal);
this.max = Math.max(this.max, processTimeLocal);
this.avg += processTimeLocal;
this.drawingDone = false;
} else {
this.minIdle = Math.min(this.minIdle, processTimeLocal);
this.maxIdle = Math.max(this.maxIdle, processTimeLocal);
this.avgIdle += processTimeLocal;
}
}
public void incrementCounter() {
this.nbDisplayTime++;
this.drawingDone = true;
}
public void draw() {
if (this.display) {
if (this.nbDisplayTime > 0) {
System.out.println(this.displayName + " : Active : "
+ this.min + " "
+ this.avg / this.nbDisplayTime + "ms "
+ this.max + " ");
}
if (this.nbCallTime-this.nbDisplayTime>0) {
System.out.println(this.displayName + " : idle : "
+ this.minIdle + " "
+ this.avgIdle / (this.nbCallTime-this.nbDisplayTime) + "ms "
+ this.maxIdle + " ");
}
if (this.displayFPS) {
System.out.println("FPS : " + this.nbDisplayTime + "/" + this.nbCallTime + "fps");
}
this.max = 0;
this.min = 99999999;
this.avg = 0;
this.maxIdle = 0;
this.minIdle = 99999999;
this.avgIdle = 0;
this.nbCallTime = 0;
this.nbDisplayTime = 0;
this.startTime = 0;
this.display = false;
}
}
}

View File

@ -1,5 +0,0 @@
package org.atriasoft.gale;
public enum TextureFilter {
LINEAR, NEAREST
}

View File

@ -1,35 +0,0 @@
package org.atriasoft.gale.context;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CommandLine {
static final Logger LOGGER = LoggerFactory.getLogger(CommandLine.class);
private final List<String> listArgs = new ArrayList<>();
public void parse(final String[] args) {
for (int iii = 1; iii < args.length; iii++) {
LOGGER.info("commandLine : '" + args[iii] + "'");
this.listArgs.add(args[iii]);
}
}
public int size() {
return this.listArgs.size();
}
public String get(final int id) {
return this.listArgs.get(id);
}
public void add(final String newElement) {
this.listArgs.add(newElement);
}
public void remove(final int id) {
this.listArgs.remove(id);
}
}

View File

@ -1,22 +0,0 @@
package org.atriasoft.gale.context;
import org.atriasoft.gale.GaleApplication;
class GaleApplicationTest extends GaleApplication {
}
public class GaleContextTest extends GaleContext {
public GaleContextTest() {
super(new GaleApplicationTest(), new String[0]);
setContext(this);
}
@Override
public int run() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,68 +0,0 @@
package org.atriasoft.gale.context;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MessageSystem {
static final Logger LOGGER = LoggerFactory.getLogger(MessageSystem.class);
private final Vector<ActionToDoInAsyncLoop> data = new Vector<>();
private final Map<String, ActionToDoInAsyncLoop> dataSingle = new HashMap<>();
public synchronized void addElement(final ActionToDoInAsyncLoop data2) {
this.data.addElement(data2);
notifyAll();
}
public synchronized void addElement(final String uniqueID, final ActionToDoInAsyncLoop data2) {
this.dataSingle.put(uniqueID, data2);
notifyAll();
}
protected synchronized ActionToDoInAsyncLoop getElementSingle() {
//LOGGER.warn("+++++++++++++++++++++++++++++++++ getElement()");
final Map.Entry<String, ActionToDoInAsyncLoop> entry = this.dataSingle.entrySet().iterator().next();
final String key = entry.getKey();
final ActionToDoInAsyncLoop message = entry.getValue();
this.dataSingle.remove(key);
//LOGGER.warn("+++++++++++++++++++++++++++++++++ getElement() ===> done " + message);
return message;
}
protected synchronized ActionToDoInAsyncLoop getElementVector() {
//LOGGER.warn("+++++++++++++++++++++++++++++++++ getElement()");
final ActionToDoInAsyncLoop message = this.data.firstElement();
this.data.removeElement(message);
//LOGGER.warn("+++++++++++++++++++++++++++++++++ getElement() ===> done " + message);
return message;
}
public synchronized ActionToDoInAsyncLoop getElementWait() {
if (this.data.isEmpty() && this.dataSingle.isEmpty()) {
try {
wait();
} catch (final InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
if (!this.data.isEmpty()) {
return getElementVector();
}
if (!this.dataSingle.isEmpty()) {
return getElementSingle();
}
return null;
}
public synchronized int getSize() {
LOGGER.trace("------------------------------------------------------------");
LOGGER.trace("-- nb message: {} + {}", this.data.size(), this.dataSingle.size());
LOGGER.trace("------------------------------------------------------------");
return this.data.size() + this.dataSingle.size();
}
}

View File

@ -1,53 +0,0 @@
package org.atriasoft.gale.context;
import java.time.Clock;
import org.atriasoft.etk.ThreadAbstract;
import org.atriasoft.gale.GaleApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PeriodicThread extends ThreadAbstract {
static final Logger LOGGER = LoggerFactory.getLogger(PeriodicThread.class);
private final GaleContext context;
public PeriodicThread(final GaleContext context) {
super("GaleAsync");
this.context = context;
}
@Override
protected void birth() {
// TODO Auto-generated method stub
}
@Override
protected void death() {
// TODO Auto-generated method stub
}
@Override
protected void runPeriodic() {
LOGGER.trace("----------------------------- [START] -----------------------------------");
try {
Thread.sleep(100);
} catch (final InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
// Keep global clock to process events
final Clock clock = Clock.systemUTC();
final long time = System.nanoTime();
///synchronized (this.context) {
this.context.processEventsAsync(clock, time);
// call all the application for periodic request (the application manage multiple instance )...
final GaleApplication appl = this.context.getApplication();
//LOGGER.trace("Call application : " + appl);
if (appl != null) {
appl.onPeriod(clock, time);
}
LOGGER.trace("----------------------------- [ END ] -----------------------------------");
}
}

View File

@ -1,305 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
package org.atriasoft.gale.resource;
import org.atriasoft.egami.ImageByte;
import org.atriasoft.egami.ImageByteRGBA;
import org.atriasoft.etk.Tools;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.gale.TextureFilter;
import org.atriasoft.gale.backend3d.OpenGL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ResourceTexture2 extends Resource {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceTexture2.class);
public enum TextureColorMode {
rgb, // !< red/green/blue data
rgba // !< red/green/blue/alpha data
}
public static ResourceTexture2 create() {
LOGGER.trace("KEEP: Resource Texture Dynamic: ");
return new ResourceTexture2();
}
public static ResourceTexture2 create(final Uri uri) {
LOGGER.trace("KEEP: Resource Texture: " + uri);
final Resource object2 = Resource.getManager().localKeep(uri);
if (object2 != null) {
if (object2 instanceof final ResourceTexture2 tmpp) {
return tmpp;
}
LOGGER.error("Request resource file : '" + uri + "' With the wrong type (dynamic cast error)");
System.exit(-1);
return null;
}
LOGGER.trace("CREATE: new Texture: " + uri);
return new ResourceTexture2(uri);
}
public static ResourceTexture2 createNamed(final String uri) {
LOGGER.trace("KEEP: Resource Texture Named: " + uri);
final Resource object2 = Resource.getManager().localKeep(uri);
if (object2 != null) {
if (object2 instanceof final ResourceTexture2 tmpp) {
return tmpp;
}
LOGGER.error("Request resource file : '" + uri + "' With the wrong type (dynamic cast error)");
System.exit(-1);
return null;
}
LOGGER.debug("CREATE: new Texture Named: " + uri);
return new ResourceTexture2(uri);
}
/*
* public static ResourceTexture2 createFromPng(final Uri uriTexture) { return
* createFromPng(uriTexture, 1); }
*
* public static ResourceTexture2 createFromPng(final Uri uriTexture, final int
* textureUnit) { ResourceTexture2 resource; Resource resource2; final String
* name = uriTexture.getValue(); if (name.isEmpty() == false && name != "---") {
* resource2 = getManager().localKeep(name); } else {
* LOGGER.error("Can not create a shader without a filaname"); return null; } if
* (resource2 != null) { if (resource2 instanceof ResourceTexture2) {
* resource2.keep(); return (ResourceTexture2) resource2; }
* LOGGER.critical("Request resource file : '" + name +
* "' With the wrong type (dynamic cast error)");
* System.exit(-1);
* return null; } resource = new
* ResourceTexture2(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), textureUnit); resource.flush(); return resource; }
*/
// openGl Context properties :
protected ImageByte data = new ImageByteRGBA(32, 32);
// !< Color space of the image.
private final TextureColorMode dataColorSpace = TextureColorMode.rgba;
// Filter apply at the image when rendering it
protected TextureFilter filter = TextureFilter.LINEAR;
// ! Last loaded size in the system openGL
protected Vector2i lastSize = new Vector2i(1, 1);
protected int lastSizeObject = 0;
protected int lastTypeObject = 0;
// internal state of the openGl system.
protected boolean loaded = false;
// ! some image are not square == > we need to sqared it to prevent some openGl
// api error the the displayable size is not all the time 0.0 . 1.0
protected Vector2i realImageSize = new Vector2i(1, 1);
// repeat mode of the image (repeat the image if out of range [0..1])
protected boolean repeat = false;
protected int texId = -1; // !< openGl textureID.
public ResourceTexture2() {}
public ResourceTexture2(final String filename) {
super(filename);
}
/*
* public void bindForRendering(final int idTexture) { if (this.loaded == false)
* { return; } GL13.glActiveTexture(textureIdBinding[idTexture]);
* GL11.glBindTexture(GL11.GLTEXTURE2D, this.texId); if (this.dataColorSpace
* == TextureColorMode.rgb) { OpenGL.enable(OpenGL.Flag.flagcullFace);
* OpenGL.enable(OpenGL.Flag.flagback); } }
*/
public ResourceTexture2(final Uri filename) {
super(filename);
}
public void bindForRendering(final int idTexture) {
if (!this.loaded) {
return;
}
OpenGL.activeTexture(idTexture);
OpenGL.bindTexture2D(this.texId);
if (this.dataColorSpace == TextureColorMode.rgb) {
OpenGL.enable(OpenGL.Flag.flag_cullFace);
OpenGL.enable(OpenGL.Flag.flag_back);
}
}
@Override
public void cleanUp() {
removeContext();
}
// Flush the data to send it at the openGl system
public synchronized void flush() {
// request to the manager to be call at the next update ...
LOGGER.trace("Request UPDATE of Element");
Resource.getManager().update(this);
}
// Get the reference on this image to draw something on it ...
public ImageByte get() {
return this.data;
}
public Vector2i getOpenGlSize() {
return this.data.getSize();
}
public int getRendererId() {
return this.texId;
}
public Vector2i getUsableSize() {
return this.realImageSize;
}
@Override
public synchronized void removeContext() {
if (this.loaded) {
// Request remove texture ...
LOGGER.info("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
// TODO Check if we are in the correct thread
OpenGL.glDeleteTextures(this.texId);
this.loaded = false;
}
}
@Override
public synchronized void removeContextToLate() {
this.loaded = false;
this.texId = -1;
}
/**
* Set the image in the texture system
* @note It will resize in square2 if needed by the system.
* @param image Image to set.
*/
public synchronized void set(final ImageByte image) {
LOGGER.info("Set a new image in a texture: size={}", image.getSize());
this.data = image;
this.realImageSize = this.data.getSize();
// Disable compatibility size for embended ...
// final Vector2i compatibilityHWSize = new Vector2i(Tools.nextP2(this.realImageSize.x()), Tools.nextP2(this.realImageSize.y()));
// if (!this.realImageSize.equals(compatibilityHWSize)) {
// LOGGER.warn("RESIZE Image for HArwareCompatibility:" + this.realImageSize + " => " + compatibilityHWSize);
// this.data.resize(compatibilityHWSize.x(), compatibilityHWSize.y());
// }
flush();
}
/**
* Set the Filter mode to apply at the image when display with a scale
* (not 1:1 ratio)
* @param filter Value of the new filter mode
*/
public void setFilterMode(final TextureFilter filter) {
this.filter = filter;
}
// You must set the size here, because it will be set in multiple of pow(2)
public synchronized void setImageSize(Vector2i newSize) {
newSize = new Vector2i(Tools.nextP2(newSize.x()), Tools.nextP2(newSize.y()));
this.data.resize(newSize.x(), newSize.y());
}
/**
* Set the repeat mode of the images if UV range is out of [0..1]
* @param value Value of the new repeat mode
*/
public void setRepeat(final boolean value) {
this.repeat = value;
}
public void unBindForRendering() {
if (!this.loaded) {
return;
}
if (this.dataColorSpace == TextureColorMode.rgb) {
OpenGL.disable(OpenGL.Flag.flag_cullFace);
OpenGL.disable(OpenGL.Flag.flag_back);
}
}
@Override
public synchronized boolean updateContext() {
LOGGER.trace("updateContext [START]");
//final Steady tic = Steady.now();
/*
* TODO : use unlockable synchronized ... if (lock.tryLock() == false) { //Lock
* error ==> try later ... return false; }
*/
final int typeObject = this.data.hasAlpha() ? OpenGL.GL_RGBA : OpenGL.GL_RGB;
final int sizeObject = OpenGL.GL_UNSIGNED_BYTE;
if (this.loaded) {
if (this.lastTypeObject != typeObject || this.lastSizeObject != sizeObject
|| !this.lastSize.equals(this.data.getSize())) {
LOGGER.trace("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
OpenGL.glDeleteTextures(this.texId);
this.loaded = false;
}
}
if (!this.loaded) {
// Request a new texture at openGl :
this.texId = OpenGL.glGenTextures();
this.lastSize = this.data.getSize();
this.lastTypeObject = typeObject;
this.lastSizeObject = sizeObject;
LOGGER.debug("TEXTURE: add [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize()
+ " OGlId=" + this.texId + " type=" + this.data.getClass().getCanonicalName());
} else {
LOGGER.debug("TEXTURE: update [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize()
+ " OGlId=" + this.texId + " type=" + this.data.getClass().getCanonicalName());
}
// in all case we set the texture properties :
// TODO check error ???
OpenGL.bindTexture2D(this.texId);
if (!this.loaded) {
if (!this.repeat) {
OpenGL.setTexture2DWrapClampToEdge();
} else {
OpenGL.setTexture2DWrapRepeat();
}
if (this.filter == TextureFilter.LINEAR) {
OpenGL.setTexture2DFilterLinear();
} else {
OpenGL.setTexture2DFilterNearest();
}
}
// glPixelStorei(GLUNPACKALIGNMENT,1);
//final Steady toc1 = Steady.now();
//LOGGER.trace(" BIND ==> " + toc1.less(tic));
// egami::store(this.data, String("~/texture") + etk::toString(getId()) + ".bmp");
if (!this.loaded) {
OpenGL.glTexImage2D(0, // Level
typeObject, // Format internal
this.data.getWidth(), this.data.getHeight(), 0, // Border
typeObject, // format
sizeObject, // type
this.data.getRaw());
} else {
OpenGL.glTexSubImage2D(0, // Level
0, // x offset
0, // y offset
this.data.getWidth(), this.data.getHeight(), typeObject, // format
sizeObject, // type
this.data.getRaw());
}
// now the data is loaded
this.loaded = true;
// final Steady toc = Steady.now();
// LOGGER.error(" updateContext [STOP] ==> " + (toc - toc1));
return true;
}
}

View File

@ -1,99 +0,0 @@
package org.atriasoft.gale.resource;
import org.atriasoft.egami.ImageByte;
import org.atriasoft.etk.Tools;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.iogami.IOgami;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO : Change tis file name ...
public class ResourceTextureFile extends ResourceTexture2 {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceTextureFile.class);
public static Vector2i sizeAuto = new Vector2i(-1, -1);
public static Vector2i sizeDefault = Vector2i.ZERO;
public static ResourceTextureFile create(final Uri filename) {
return ResourceTextureFile.create(filename, ResourceTextureFile.sizeAuto);
}
public static ResourceTextureFile create(final Uri filename, final Vector2i size) {
return ResourceTextureFile.create(filename, size, ResourceTextureFile.sizeAuto);
}
/**
* keep the resource pointer.
* @note Never free this pointer by your own...
* @param uri Name of the image file.
* @param size size of the image (usefull when loading .svg to
* automatic rescale)
* @param sizeRegister size register in named (When you preaload the images
* the size write here will be )
* @return pointer on the resource or null if an error occured.
*/
public static ResourceTextureFile create(final Uri uri, final Vector2i inSize, final Vector2i sizeRegister) {
LOGGER.trace("KEEP: TextureFile: '" + uri + "' size=" + inSize + " sizeRegister=" + sizeRegister);
Vector2i size = inSize;
if (uri == null) {
return new ResourceTextureFile();
}
if (size.x() == 0) {
size = size.withX(-1);
// LOGGER.error("Error Request the image size.x() =0 ???");
}
if (size.y() == 0) {
size = size.withY(-1);
// LOGGER.error("Error Request the image size.y() =0 ???");
}
if (!uri.getExtention().toLowerCase().contentEquals("svg")) {
size = ResourceTextureFile.sizeAuto;
}
if (size.x() > 0 && size.y() > 0) {
LOGGER.trace(" == > specific size : " + size);
size = new Vector2i(Tools.nextP2(size.x()), Tools.nextP2(size.y()));
if (!sizeRegister.equals(ResourceTextureFile.sizeAuto)) {
if (!sizeRegister.equals(ResourceTextureFile.sizeDefault)) {
// tmpFilename.getQuery().set("x", "" + size.x));
// tmpFilename.getQuery().set("y", "" + size.y));
}
}
}
LOGGER.trace("KEEP: TextureFile: '" + uri + "' new size=" + size);
final Resource object2 = Resource.getManager().localKeep(uri.toString());
if (object2 != null) {
if (object2 instanceof final ResourceTextureFile out) {
object2.keep();
return out;
}
LOGGER.error("Request resource file : '" + uri + "' With the wrong type (dynamic cast error)");
System.exit(-1);
return null;
}
LOGGER.debug("CREATE: TextureFile: '" + uri + "' size=" + size);
// need to crate a new one ...
final ResourceTextureFile object = new ResourceTextureFile(uri.toString(), uri, size);
Resource.getManager().localAdd(object);
return object;
}
protected ResourceTextureFile() {}
protected ResourceTextureFile(final String genName, final Uri uri, final Vector2i size) {
super(genName);
LOGGER.debug("create a new resource::Image : genName=" + genName + " uri=" + uri + " size=" + size);
final ImageByte tmp = IOgami.load(uri, size);
if (tmp == null) {
LOGGER.error("Can not load the file : " + uri);
return;
}
set(tmp);
}
public Vector2i getRealSize() {
return this.realImageSize;
}
}

35
src/module-info.java Normal file
View File

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

View File

@ -0,0 +1,88 @@
package org.atriasoft.gale;
public class Fps {
private long startTime = 0;
private long nbCallTime = 0;
private long nbDisplayTime = 0;
private float min = 99999999;
private float avg = 0;
private float max = 0;
private float minIdle = 99999999;
private float avgIdle = 0;
private float maxIdle = 0;
private long ticTime = 0;
private boolean display = false;
private boolean drawingDone = false;
private String displayName = null;
private boolean displayFPS;
public Fps(String displayName, boolean displayFPS) {
this.displayName = displayName;
this.displayFPS = displayFPS;
}
public void tic() {
long currentTime = System.currentTimeMillis();
ticTime = currentTime;
nbCallTime++;
if (startTime == 0) {
startTime = currentTime;
}
if ( (currentTime - startTime) > 10000) {
display = true;
}
}
public void toc() {
toc(false);
}
public void toc(boolean displayTime) {
long currentTime = System.currentTimeMillis();
long processTimeLocal = (currentTime - ticTime);
if (displayTime) {
System.out.println(displayName + ": processTime: " + processTimeLocal);
}
if (drawingDone) {
min = Math.min(min, processTimeLocal);
max = Math.max(max, processTimeLocal);
avg += processTimeLocal;
drawingDone = false;
} else {
minIdle = Math.min(minIdle, processTimeLocal);
maxIdle = Math.max(maxIdle, processTimeLocal);
avgIdle += processTimeLocal;
}
}
public void incrementCounter() {
nbDisplayTime++;
drawingDone = true;
}
public void draw() {
if (display) {
if (nbDisplayTime > 0) {
System.out.println(displayName + " : Active : "
+ min + " "
+ avg / nbDisplayTime + "ms "
+ max + " ");
}
if (nbCallTime-nbDisplayTime>0) {
System.out.println(displayName + " : idle : "
+ minIdle + " "
+ avgIdle / (nbCallTime-nbDisplayTime) + "ms "
+ maxIdle + " ");
}
if (displayFPS) {
System.out.println("FPS : " + nbDisplayTime + "/" + nbCallTime + "fps");
}
max = 0;
min = 99999999;
avg = 0;
maxIdle = 0;
minIdle = 99999999;
avgIdle = 0;
nbCallTime = 0;
nbDisplayTime = 0;
startTime = 0;
display = false;
}
}
}

View File

@ -4,12 +4,10 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.gale.context.GaleContext;
//import org.atriasoft.gale.context.JOGL.ContextJOGL;
import org.atriasoft.gale.context.LWJG_AWT.ContextLWJGLAWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import org.atriasoft.gale.context.LWJGL.ContextLWJGL;
import org.atriasoft.gale.internal.Log;
public class Gale {
static final Logger LOGGER = LoggerFactory.getLogger(Gale.class);
public static GaleContext getContext() {
// TODO Auto-generated method stub
return GaleContext.getContext();
@ -43,13 +41,13 @@ public class Gale {
init();
//etk::init(_argc, _argv);
GaleContext context = null;
final String request = "";
String request = "";
//context = ContextLWJGL.create(application, arg);
//context = ContextJOGL.create(application, arg);
context = ContextLWJGLAWT.create(application, arg);
if (context == null) {
LOGGER.error("Can not allocate the interface of the GUI ...");
Log.error("Can not allocate the interface of the GUI ...");
return -1;
}
return context.run();

View File

@ -1,21 +1,17 @@
package org.atriasoft.gale;
import java.time.Clock;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.gale.context.ClipboardList;
import org.atriasoft.gale.context.Cursor;
import org.atriasoft.gale.context.GaleContext;
import org.atriasoft.gale.context.Cursor;
import org.atriasoft.gale.internal.Log;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GaleApplication {
static final Logger LOGGER = LoggerFactory.getLogger(GaleApplication.class);
private boolean needRedraw = true;
private String title = "gale";
private Uri iconName = null;
@ -24,7 +20,7 @@ public class GaleApplication {
private Vector2f windowsSize = new Vector2f(800, 600);
public GaleApplication() {
LOGGER.trace("Constructor Gale Application");
Log.verbose("Constructor Gale Application");
}
/**
@ -32,7 +28,7 @@ public class GaleApplication {
* @param value value to return on the program
*/
public void exit(final int value) {
LOGGER.trace("Exit Requested " + value);
Log.verbose("Exit Requested " + value);
Gale.getContext().stop();
}
@ -133,7 +129,7 @@ public class GaleApplication {
* @param context Current gale context.
*/
public void onCreate(final GaleContext context) {
LOGGER.trace("Create Gale Application");
Log.verbose("Create Gale Application");
}
/**
@ -141,7 +137,7 @@ public class GaleApplication {
* @param context Current gale context.
*/
public void onDestroy(final GaleContext context) {
LOGGER.trace("Destroy Gale Application");
Log.verbose("Destroy Gale Application");
}
/**
@ -149,7 +145,7 @@ public class GaleApplication {
* @param context Current gale context.
*/
public void onDraw(final GaleContext context) {
LOGGER.trace("draw Gale Application");
Log.verbose("draw Gale Application");
}
/**
@ -159,11 +155,7 @@ public class GaleApplication {
* @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) {
public void onKeyboard(final KeySpecial special, final KeyKeyboard type, final Character value, final KeyStatus state) {
}
@ -172,7 +164,7 @@ public class GaleApplication {
* @param context Current gale context.
*/
public void onKillDemand(final GaleContext context) {
LOGGER.info("Gale request auto destroy ==> no applification specification");
Log.info("Gale request auto destroy ==> no applification specification");
System.exit(0);
}
@ -189,15 +181,14 @@ public class GaleApplication {
* @param context Current gale context.
*/
public void onPause(final GaleContext context) {
LOGGER.trace("Pause Gale Application");
Log.verbose("Pause Gale Application");
}
/**
* Call when contrext finish process event in the buffer and add a latency of 10ms between calls
* @param clock Current time of the call;
* @param time time of the program in nanoseconds (monotonic) ==> need restart application approximately every 292 years
* 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(final Clock clock, final long time) {}
public void onPeriod(final long time) {}
/**
* Get touch/mouse/... event.
@ -206,12 +197,7 @@ public class GaleApplication {
* @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) {
public void onPointer(final KeySpecial special, final KeyType type, final int pointerID, final Vector2f pos, final KeyStatus state) {
}
@ -220,7 +206,7 @@ public class GaleApplication {
* @param context Current gale context.
*/
public void onRegenerateDisplay(final GaleContext context) {
//LOGGER.trace("Regenerate Gale Application");
//Log.verbose("Regenerate Gale Application");
markDrawingIsNeeded();
}
@ -230,7 +216,7 @@ public class GaleApplication {
*/
public void onResize(final Vector2f size) {
if (size == null) {
LOGGER.error("Try to set a null size ...");
Log.error("Try to set a null size ...");
return;
}
this.windowsSize = size;
@ -242,7 +228,7 @@ public class GaleApplication {
* @param context Current gale context.
*/
public void onResume(final GaleContext context) {
LOGGER.trace("Start Gale Application");
Log.verbose("Start Gale Application");
}
/**
@ -250,7 +236,7 @@ public class GaleApplication {
* @param context Current gale context.
*/
public void onStart(final GaleContext context) {
LOGGER.trace("Start Gale Application");
Log.verbose("Start Gale Application");
}
/**
@ -258,7 +244,7 @@ public class GaleApplication {
* @param context Current gale context.
*/
public void onStop(final GaleContext context) {
LOGGER.trace("Stop Gale Application");
Log.verbose("Stop Gale Application");
}
/**
@ -269,10 +255,6 @@ public class GaleApplication {
Gale.getContext().setCursor(this.cursor);
}
void setForceRedraw() {
this.needRedraw = true;
}
/**
* set the Icon of the application.
* @param iconFile File name icon (.bmp/.png).
@ -306,21 +288,18 @@ public class GaleApplication {
*/
public void setSize(final Vector2f size) {
if (size.x() <= 0 || size.y() <= 0) {
LOGGER.error("Wrong windows size: " + size);
Log.error("Wrong windows size: " + size);
}
final Vector2f oldSize = this.windowsSize;
Vector2f oldSize = this.windowsSize;
this.windowsSize = size;
final GaleContext context = Gale.getContext();
if (context == null) {
return;
}
context.setSize(size);
/* ==> change API ==> need the GUI notify the Windows that the size has change ????
if (!) {
LOGGER.error("Can not set the size required by the user.");
if (!context.setSize(size)) {
Log.error("Can not set the size required by the user.");
this.windowsSize = oldSize;
}
*/
}
/**
@ -334,5 +313,5 @@ public class GaleApplication {
return;
}
context.setTitle(this.title);
}
};
}

View File

@ -0,0 +1,33 @@
package org.atriasoft.gale.context;
import java.util.ArrayList;
import java.util.List;
import org.atriasoft.gale.internal.Log;
public class CommandLine {
private List<String> listArgs = new ArrayList<String>();
public void parse(String[] args) {
for (int iii=1 ; iii<args.length; iii++) {
Log.info("commandLine : '" + args[iii] + "'" );
listArgs.add(args[iii]);
}
}
public int size() {
return listArgs.size();
}
public String get(int id) {
return listArgs.get(id);
}
public void add(String newElement) {
listArgs.add(newElement);
}
public void remove(int id) {
listArgs.remove(id);
}
}

View File

@ -1,6 +1,6 @@
package org.atriasoft.gale.context;
import java.time.Clock;
import java.util.Vector;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@ -8,33 +8,28 @@ import org.atriasoft.etk.Color;
import org.atriasoft.etk.ThreadAbstract;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.util.AutoUnLock;
import org.atriasoft.gale.Fps;
import org.atriasoft.gale.Gale;
import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.Orientation;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.internal.Log;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.atriasoft.gale.resource.ResourceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
interface ActionToDoInAsyncLoop {
void run(GaleContext context);
public void run(GaleContext context);
}
enum ApplicationState {
UNDEFINED, CREATE, RUNNING, DIED
}
};
public abstract class GaleContext {
static final Logger LOGGER = LoggerFactory.getLogger(GaleContext.class);
protected static final int MAX_MANAGE_INPUT = 15;
private static final String STATIC_ID_RESIZE = "010__RESIZE";
private static final String STATIC_ID_REDRAW_ALL = "0100__REDRAW_ALL";
private static GaleContext globalContext = null;
// return true if a flush is needed
private static int countMemeCheck = 0;
@ -42,17 +37,18 @@ public abstract class GaleContext {
/**
* From everyware in the program, we can get the context inteface.
* @return current reference on the instance.
* @note For test create a ``` new GaleContextTest()``` ... this permit to run some test...
*/
public static GaleContext getContext() {
return GaleContext.globalContext;
return globalContext;
}
public static void setContext(final GaleContext context) {
GaleContext.globalContext = context;
globalContext = context;
}
protected ThreadAbstract periodicThread;
Lock lock = new ReentrantLock();
protected ThreadAbstract periodicThread;;
protected GaleApplication application; //!< Application handle
protected ApplicationState applicationState = ApplicationState.UNDEFINED; // state of the application
private final CommandLine commandLine = new CommandLine(); //!< Start command line information;
@ -60,10 +56,7 @@ public abstract class GaleContext {
// simulation area:
private long previousDisplayTime; // this is to limit framerate ... in case...
private final boolean displayFps = true;
private final Lock msgSystemAsyncLock = new ReentrantLock();
private final MessageSystem msgSystemAsync = new MessageSystem();
private final MessageSystem msgSystemGui = new MessageSystem();
private final MessageSystem msgSystem = new MessageSystem();
private final Fps fpsSystemEvent = new Fps("SystemEvent", this.displayFps);
private final Fps fpsSystemContext = new Fps("SystemContext", this.displayFps);
private final Fps fpsSystem = new Fps("System", this.displayFps);
@ -71,21 +64,18 @@ public abstract class GaleContext {
protected Vector2f windowsSize = Vector2f.ZERO; //!< current size of the system
protected boolean fullscreen = false;
protected Vector2f windowsPos; //!< current size of the system
// note: in the current mode, the management is not able to synchronize it good..
private final boolean requestSynchronousProcessing = true; //!< this permit to process the event in the global GUI thread instead of the local processing thread.
public GaleContext(final GaleApplication application, final String[] args) {
// set a basic
this.application = application;
this.applicationState = ApplicationState.CREATE;
GaleContext.setContext(this);
setContext(this);
Thread.currentThread().setName("galeThread");
if (this.application == null) {
LOGGER.error("Can not start context with no Application ==> rtfm ...");
throw new RuntimeException("Can not start context with no Application ==> rtfm ...");
Log.critical("Can not start context with no Application ==> rtfm ...");
}
this.commandLine.parse(args);
LOGGER.info(" == > Gale system init (BEGIN)");
Log.info(" == > Gale system init (BEGIN)");
// create thread to manage real periodic event
this.periodicThread = new PeriodicThread(this);
@ -100,13 +90,13 @@ public abstract class GaleContext {
// } else if ( this.commandLine.get(iii) == "-h"
// || this.commandLine.get(iii) == "--help"
// || startwith(this.commandLine.get(iii), "--gale")) {
// LOGGER.print("gale - help : ");
// LOGGER.print(" --gale-fps");
// LOGGER.print(" Display the current fps of the display");
// LOGGER.print(" -h/--help");
// LOGGER.print(" Display this help");
// 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 (startwith(this.commandLine.get(iii), "--gale")) {
// LOGGER.error("gale unknow element in parameter: '" << this.commandLine.get(iii) << "'");
// Log.error("gale unknow element in parameter: '" << this.commandLine.get(iii) << "'");
// // remove parameter ...
// } else {
// // this is a global help system does not remove it
@ -120,9 +110,9 @@ public abstract class GaleContext {
// }
//cout.setOutputFile(true);
LOGGER.info("GALE v: {}", Gale.getVersion());
Log.info("GALE v:" + Gale.getVersion());
forceOrientation(Orientation.screenAuto);
postActionAsync(context -> {
postAction((context) -> {
final GaleApplication appl = context.getApplication();
if (appl == null) {
this.applicationState = ApplicationState.UNDEFINED;
@ -132,13 +122,11 @@ public abstract class GaleContext {
appl.onStart(context);
appl.onResume(context);
this.applicationState = ApplicationState.RUNNING;
// this is done at the end to perform a full ended rendering.
context.requestUpdateSize();
});
// force a recalculation
//requestUpdateSize();
LOGGER.info(" == > Gale system init (END)");
requestUpdateSize();
Log.info(" == > Gale system init (END)");
}
/**
@ -162,15 +150,7 @@ public abstract class GaleContext {
* force the screen orientation (availlable on portable elements ...
* @param orientation Selected orientation.
*/
public final void forceOrientation(final Orientation orientation) {
postActionToGui(context -> {
context.forceOrientationThreadGUI(orientation);
});
}
protected void forceOrientationThreadGUI(final Orientation orientation) {
LOGGER.info("TODO: forceOrientation: not implemented");
}
public void forceOrientation(final Orientation orientation) {}
/**
* Redraw all the windows
@ -187,20 +167,17 @@ public abstract class GaleContext {
// Called by Consumer
public ActionToDoInAsyncLoop getAction() {
return this.msgSystemAsync.getElementWait();
return this.msgSystem.getElementWait();
}
public GaleApplication getApplication() {
return this.application;
/*
* pb on this lock ...
this.msgSystemAsyncLock.lock();
this.lock.lock();
try {
return this.application;
} finally {
this.msgSystemAsyncLock.unlock();
this.lock.unlock();
}
*/
}
public CommandLine getCmd() {
@ -235,43 +212,20 @@ public abstract class GaleContext {
* 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 final void grabKeyboardEvents(final boolean status) {
postActionToGui(context -> {
context.grabKeyboardEventsThreadGUI(status);
});
}
protected void grabKeyboardEventsThreadGUI(final boolean status) {
LOGGER.info("grabKeyboardEvents: NOT implemented ...");
}
public void grabKeyboardEvents(final boolean status) {}
/**
* 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 final void grabPointerEvents(final boolean status, final Vector2f forcedPosition) {
postActionToGui(context -> {
context.grabPointerEventsThreadGUI(status, forcedPosition);
});
}
protected void grabPointerEventsThreadGUI(final boolean status, final Vector2f forcedPosition) {
LOGGER.info("grabPointerEvents: NOT implemented ...");
}
public void grabPointerEvents(final boolean status, final Vector2f forcedPosition) {}
/**
* The Application request that the Windows will be Hidden.
*/
public final void hide() {
postActionToGui(context -> {
context.hideThreadGUI();
});
}
protected void hideThreadGUI() {
LOGGER.info("hide: NOT implemented ...");
public void hide() {
Log.info("hide: NOT implemented ...");
}
public boolean isGrabPointerEvents() {
@ -279,57 +233,41 @@ public abstract class GaleContext {
}
/**
* Hide the virtual keyboard (for touch system only)
* Hide the virtal keyboard (for touch system only)
*/
public final void keyboardHide() {
postActionToGui(context -> {
context.keyboardHideThreadGUI();
});
}
protected void keyboardHideThreadGUI() {
LOGGER.info("keyboardHide: NOT implemented ...");
public void keyboardHide() {
Log.info("keyboardHide: NOT implemented ...");
}
/**
* display the virtual keyboard (for touch system only)
* display the virtal keyboard (for touch system only)
*/
public final void keyboardShow() {
postActionToGui(context -> {
context.keyboardShowThreadGUI();
});
public void keyboardShow() {
Log.info("keyboardShow: NOT implemented ...");
}
protected void keyboardShowThreadGUI() {
LOGGER.info("keyboardShow: NOT implemented ...");
protected void lockContext() {
}
/**
* Open an URL on an eternal brother.
* @param url URL to open.
*/
public final void openURL(final String url) {
postActionToGui(context -> {
context.openURLThreadGUI(url);
});
}
protected void openURLThreadGUI(final String url) {
LOGGER.info("openURL: NOT implemented ...");
}
public void openURL(final String url) {}
/**
* The current context is set in background (framerate is slowing down (max fps)/5 # 4fps)
*/
public void operatingSystemBackground() {
// set the current interface :
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
LOGGER.info("operatingSystemBackground...");
lockContext();
Log.info("operatingSystemBackground...");
// if (this.windowsCurrent != null) {
// this.windowsCurrent.onStateBackground();
// }
// release the current interface :
}
unLockContext();
}
/**
@ -337,7 +275,7 @@ public abstract class GaleContext {
* @param clipboardID of the clipboard
*/
public void operatingSystemClipBoardArrive(final ClipboardList clipboardID) {
postActionAsync(context -> {
postAction((context) -> {
final GaleApplication appl = context.getApplication();
if (appl != null) {
appl.onClipboardEvent(clipboardID);
@ -346,12 +284,13 @@ public abstract class GaleContext {
}
public boolean operatingSystemDraw(final boolean displayEveryTime) {
if (GaleContext.countMemeCheck++ >= 10 * 16) {
GaleContext.countMemeCheck = 0;
if (countMemeCheck++ >= 10 * 16) {
countMemeCheck = 0;
}
LOGGER.trace("Call draw");
final long currentTime = System.nanoTime();
//LOGGER.warn("Time = " << currentTime << " " << currentTime2);
Log.verbose("Call draw");
final long currentTime = System.currentTimeMillis();
//echrono::Time currentTime2 = echrono::Time::now();
//Log.warning("Time = " << currentTime << " " << currentTime2);
// TODO Review this ...
// this is to prevent the multiple display at the a high frequency ...
if (currentTime - this.previousDisplayTime < 8) {
@ -374,7 +313,7 @@ public abstract class GaleContext {
//! Event management section ...
{
// set the current interface:
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
lockContext();
/*
Lock the event processing
@ -388,7 +327,7 @@ public abstract class GaleContext {
if (this.application != null) {
if (this.applicationState == ApplicationState.RUNNING) {
// Redraw all needed elements
//LOGGER.debug("Regenerate Display");
//Log.debug("Regenerate Display");
this.application.onRegenerateDisplay(this);
needRedraw = this.application.isDrawingNeeded();
} else {
@ -399,7 +338,8 @@ public abstract class GaleContext {
this.fpsSystemEvent.incrementCounter();
this.fpsSystemEvent.toc();
}
}
// release the current interface :
unLockContext();
}
boolean hasDisplayDone = false;
//! drawing section:
@ -410,10 +350,10 @@ public abstract class GaleContext {
this.fpsSystemContext.tic();
}
if (needRedraw || displayEveryTime) {
//LOGGER.debug(" ==> real Draw");
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
//Log.debug(" ==> real Draw");
lockContext();
this.resourceManager.updateContext();
}
unLockContext();
if (this.displayFps) {
this.fpsSystemContext.incrementCounter();
}
@ -426,16 +366,16 @@ public abstract class GaleContext {
if (needRedraw || displayEveryTime) {
this.fpsSystem.incrementCounter();
// set the current interface :
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
lockContext();
if (this.applicationState == ApplicationState.RUNNING) {
this.application.onDraw(this);
} else {
OpenGL.setViewPort(new Vector2f(0, 0), this.application.getSize());
final Color bgColor = new Color(0.8f, 0.5f, 0.8f, 1.0f);
OpenGL.clearColor(bgColor);
//LOGGER.info("==> appl clear ==> not created ...");
}
//Log.info("==> appl clear ==> not created ...");
}
unLockContext();
hasDisplayDone = true;
}
}
@ -444,7 +384,7 @@ public abstract class GaleContext {
this.fpsFlush.tic();
}
if (hasDisplayDone) {
//LOGGER.info("lklklklklk " << displayEveryTime);
//Log.info("lklklklklk " << displayEveryTime);
if (this.displayFps) {
this.fpsFlush.incrementCounter();
}
@ -464,7 +404,7 @@ public abstract class GaleContext {
}
{
// set the current interface:
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
lockContext();
// release open GL Context
OpenGL.lock();
// while The Gui is drawing in OpenGl, we do some not realTime things
@ -473,31 +413,33 @@ public abstract class GaleContext {
OpenGL.unLock();
// TODO this.objectManager.cleanInternalRemoved();
this.resourceManager.cleanInternalRemoved();
}
// release the current interface:
unLockContext();
}
OpenGL.threadHasNoMoreContext();
return hasDisplayDone;
}
};
/**
* The current context is set in foreground (framerate is maximum speed)
*/
public void operatingSystemForeground() {
// set the current interface :
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
LOGGER.info("operatingSystemForeground...");
lockContext();
Log.info("operatingSystemForeground...");
// if (this.windowsCurrent != null) {
// this.windowsCurrent.onStateForeground();
// }
}
// release the current interface :
unLockContext();
}
/**
* The OS inform that the Windows is now Hidden.
*/
public void operatingSystemHide() {
postActionAsync(context -> {
postAction((context) -> {
/*
Application> appl = context.getApplication();
if (appl == null) {
@ -508,9 +450,9 @@ public abstract class GaleContext {
char,
state);
*/
LOGGER.info("TODO: HIDE ... ");
Log.todo("HIDE ... ");
});
}
};
/**
* The OS inform that the current windows has change his position.
@ -520,8 +462,8 @@ public abstract class GaleContext {
if (this.windowsPos.isEqual(pos)) {
return;
}
postActionAsync(context -> {
LOGGER.debug("Receive MSG : THREADMOVE : {} ==> {}", context.windowsPos, pos);
postAction((context) -> {
Log.debug("Receive MSG : THREADMOVE : " + context.windowsPos + " ==> " + pos);
context.windowsPos = pos;
final GaleApplication appl = context.getApplication();
if (appl == null) {
@ -536,21 +478,21 @@ public abstract class GaleContext {
*/
public void operatingSystemOpenGlContextDestroy() {
this.resourceManager.contextHasBeenDestroyed();
}
};
/**
* The OS inform that the current windows has change his size.
* @param size new size of the windows.
*/
public void operatingSystemResize(final Vector2f size) {
LOGGER.warn("Resize request={} previous={}", size, this.windowsSize);
Log.warning("Resize request: " + size + " old=" + this.windowsSize);
if (this.windowsSize.equals(size)) {
return;
}
// TODO Better in the thread ... ==> but generate some init error ...
//gale::Dimension::setPixelWindowsSize(size);
postActionAsync(GaleContext.STATIC_ID_RESIZE, context -> {
LOGGER.error("Receive MSG : THREAD_RESIZE : {} ==> {}", context.windowsSize, size);
postAction((context) -> {
Log.error("Receive MSG : THREAD_RESIZE : " + context.windowsSize + " ==> " + size);
context.windowsSize = size;
//gale::Dimension::setPixelWindowsSize(context.windowsSize);
final GaleApplication tmpAppl = context.getApplication();
@ -560,31 +502,26 @@ public abstract class GaleContext {
// call application inside ..
context.forceRedrawAll();
});
}
};
/**
* The current context is resumed
*/
public void operatingSystemResume() {
// set the current interface :
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
LOGGER.info("operatingSystemResume...");
lockContext();
Log.info("operatingSystemResume...");
this.previousDisplayTime = System.currentTimeMillis();
// TODO this.objectManager.timeCallResume(this.previousDisplayTime);
// if (this.windowsCurrent != null) {
// this.windowsCurrent.onStateResume();
// }
}
// release the current interface :
unLockContext();
}
public void operatingSystemSetInput(
final KeySpecial special,
final KeyType type,
final KeyStatus status,
final int pointerID,
final Vector2f pos) {
LOGGER.trace("Position motion: " + pos);
postActionAsync(context -> {
public void operatingSystemSetInput(final KeySpecial special, final KeyType type, final KeyStatus status, final int pointerID, final Vector2f pos) {
postAction((context) -> {
final GaleApplication appl = context.getApplication();
if (appl == null) {
return;
@ -593,20 +530,11 @@ public abstract class GaleContext {
});
}
public void operatingSystemsetKeyboard(
final KeySpecial special,
final KeyKeyboard type,
final KeyStatus state,
final boolean isARepeateKey) {
public void operatingSystemsetKeyboard(final KeySpecial special, final KeyKeyboard type, final KeyStatus state, final boolean isARepeateKey) {
operatingSystemsetKeyboard(special, type, state, isARepeateKey, (char) 0);
}
public void operatingSystemsetKeyboard(
final KeySpecial special,
final KeyKeyboard type,
final KeyStatus state,
final boolean isARepeateKey,
final Character charValue) {
public void operatingSystemsetKeyboard(final KeySpecial special, final KeyKeyboard type, final KeyStatus state, final boolean isARepeateKey, final Character charValue) {
KeyStatus tmpState = state;
if (isARepeateKey) {
if (tmpState == KeyStatus.down) {
@ -618,12 +546,8 @@ public abstract class GaleContext {
operatingSystemsetKeyboard2(special, type, state, charValue);
}
public void operatingSystemsetKeyboard2(
final KeySpecial special,
final KeyKeyboard type,
final KeyStatus state,
final Character charValue) {
postActionAsync(context -> {
public void operatingSystemsetKeyboard2(final KeySpecial special, final KeyKeyboard type, final KeyStatus state, final Character charValue) {
postAction((context) -> {
final GaleApplication appl = context.getApplication();
if (appl == null) {
return;
@ -636,7 +560,7 @@ public abstract class GaleContext {
* The OS inform that the Windows is now visible.
*/
public void operatingSystemShow() {
postActionAsync(context -> {
postAction((context) -> {
/*
Application> appl = context.getApplication();
if (appl == null) {
@ -647,23 +571,24 @@ public abstract class GaleContext {
char,
state);
*/
LOGGER.info("TODO: SHOW ... ");
Log.todo("SHOW ... ");
});
}
};
/**
* The OS Inform that the Window has been killed
*/
public void operatingSystemStop() {
// set the current interface :
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
LOGGER.info("operatingSystemStop...");
lockContext();
Log.info("operatingSystemStop...");
if (this.application == null) {
stop();
return;
}
this.application.onKillDemand(this);
}
// release the current interface :
unLockContext();
}
/**
@ -671,90 +596,49 @@ public abstract class GaleContext {
*/
public void operatingSystemSuspend() {
// set the current interface :
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
LOGGER.info("operatingSystemSuspend...");
lockContext();
Log.info("operatingSystemSuspend...");
this.previousDisplayTime = 0;
// if (this.windowsCurrent != null) {
// this.windowsCurrent.onStateSuspend();
// }
}
// release the current interface :
unLockContext();
}
protected void postActionAsync(final ActionToDoInAsyncLoop data) {
if (this.requestSynchronousProcessing) {
this.msgSystemGui.addElement(data);
} else {
this.msgSystemAsync.addElement(data);
}
//Later, when the necessary event happens, the thread that is running it calls notify() from a block synchronized on the same object.
}
protected void postActionAsync(final String uniqueID, final ActionToDoInAsyncLoop data) {
if (this.requestSynchronousProcessing) {
this.msgSystemGui.addElement(uniqueID, data);
} else {
this.msgSystemAsync.addElement(uniqueID, data);
}
//Later, when the necessary event happens, the thread that is running it calls notify() from a block synchronized on the same object.
}
protected void postActionToGui(final ActionToDoInAsyncLoop data) {
this.msgSystemGui.addElement(data);
private void postAction(final ActionToDoInAsyncLoop data) {
this.msgSystem.addElement(data);
//Later, when the necessary event happens, the thread that is running it calls notify() from a block synchronized on the same object.
}
/**
* Processing all the event arrived ... (commonly called in draw function)
* Processing all the event arrived ... (commoly called in draw function)
*/
public void processEventsAsync(final Clock clock, final long time) {
if (!this.msgSystemAsyncLock.tryLock()) {
public void processEvents() {
if (!this.lock.tryLock()) {
return;
}
try {
int nbEvent = 0;
while (this.msgSystemAsync.getSize() > 0) {
LOGGER.trace(" [" + nbEvent + "] event ...");
while (this.msgSystem.getSize() > 0) {
//Log.error(" [" + nbEvent + "] event ...");
nbEvent++;
final ActionToDoInAsyncLoop func = this.msgSystemAsync.getElementWait();
final ActionToDoInAsyncLoop func = this.msgSystem.getElementWait();
if (func == null) {
continue;
}
func.run(this);
}
} catch (final Exception e) {
LOGGER.error("Catch exception in main event Loop ...", e);
throw e;
} catch (Exception e) {
Log.critical("Catch exception in main event Loop ...", e);
} finally {
this.msgSystemAsyncLock.unlock();
}
}
/**
* Process event in the GUI thread ==> prevent dead lock on the global GUI interface
*/
protected void processEventsGui() {
if (!this.msgSystemAsyncLock.tryLock()) {
return;
}
try {
while (this.msgSystemGui.getSize() > 0) {
final ActionToDoInAsyncLoop func = this.msgSystemGui.getElementWait();
if (func == null) {
continue;
}
func.run(this);
}
} catch (final Exception e) {
LOGGER.error("Catch exception in main event Loop ...", e);
throw e;
} finally {
this.msgSystemAsyncLock.unlock();
this.lock.unlock();
}
}
// gale::Context::~Context() {
// LOGGER.info(" == > Gale system Un-Init (BEGIN)");
// Log.info(" == > Gale system Un-Init (BEGIN)");
// this.periodicThread.threadStart();
// getResourcesManager().applicationExiting();
// // TODO Clean the message list ...
@ -774,7 +658,7 @@ public abstract class GaleContext {
// //this.objectManager.cleanInternalRemoved();
// this.resourceManager.cleanInternalRemoved();
//
// LOGGER.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");
// Log.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");
// //this.objectManager.displayListObject();
// // Resource is an lower element as objects ...
// this.resourceManager.unInit();
@ -782,15 +666,15 @@ public abstract class GaleContext {
// //this.objectManager.unInit();
// // release the current interface :
// unLockContext();
// LOGGER.info(" == > Gale system Un-Init (END)");
// Log.info(" == > Gale system Un-Init (END)");
// if (this.simulationActive) {
// // in simulation case:
// this.simulationFile.close();
// }
// }
public void requestUpdateSize() {
postActionAsync(this.STATIC_ID_REDRAW_ALL, context -> {
//LOGGER.debug("Receive MSG : THREADRESIZE");
postAction((context) -> {
//Log.debug("Receive MSG : THREADRESIZE");
context.forceRedrawAll();
});
}
@ -813,117 +697,59 @@ public abstract class GaleContext {
* set the cursor display type.
* @param newCursor selected new cursor.
*/
public final void setCursor(final Cursor newCursor) {
postActionToGui(context -> {
context.setCursorThreadGUI(newCursor);
});
}
public void setCursorThreadGUI(final Cursor newCursor) {
LOGGER.info("setCursor: NOT implemented ...");
}
public void setCursor(final Cursor newCursor) {}
/**
* The application request a change of his current size force the fullscreen mode.
* @param status status of the fullscreen mode.
*/
public final void setFullScreen(final boolean status) {
postActionToGui(context -> {
public void setFullScreen(final boolean status) {
this.fullscreen = status;
context.setFullScreenThreadGUI(status);
});
}
protected void setFullScreenThreadGUI(final boolean status) {
LOGGER.info("setFullScreen: NOT implemented ...");
}
/**
* set the Icon of the program
* @param inputFile new filename icon of the current program.
*/
public final void setIcon(final Uri inputFile) {
postActionToGui(context -> {
context.setIconThreadGUI(inputFile);
});
}
public void setIconThreadGUI(final Uri inputFile) {
LOGGER.info("setIcon: NOT implemented ...");
}
public void setIcon(final Uri inputFile) {};
/**
* The Application request that the current windows will change his position.
* @param pos New position of the Windows requested.
*/
public final void setPos(final Vector2f pos) {
postActionToGui(context -> {
context.setPosThreadGUI(pos);
});
}
protected void setPosThreadGUI(final Vector2f pos) {
LOGGER.info("setPos: NOT implemented ...");
}
public void setPos(final Vector2f pos) {
Log.info("setPos: NOT implemented ...");
};
/**
* The application request a change of his current size.
* @param size new Requested size of the windows.
*/
public final void setSize(final Vector2f size) {
postActionToGui(context -> {
context.setSizeThreadGUI(size);
});
}
protected void setSizeThreadGUI(final Vector2f size) {
LOGGER.info("setSize: NOT implemented ...");
public boolean setSize(final Vector2f size) {
Log.info("setSize: NOT implemented ...");
return false;
}
/**
* set the new title of the windows
* @param title New desired title
*/
public final void setTitle(final String title) {
postActionToGui(context -> {
context.setTitleThreadGUI(title);
});
}
/**
* set the new title of the windows
* @param title New desired title
*/
protected void setTitleThreadGUI(final String title) {
LOGGER.info("setTitle: NOT implemented ...");
}
public void setTitle(final String title) {
Log.info("setTitle: NOT implemented ...");
};
/**
* Enable or Disable the decoration on the Windows (availlable only on Desktop)
* @param status "true" to enable decoration / false otherwise
*/
public final void setWindowsDecoration(final boolean status) {
postActionToGui(context -> {
context.setWindowsDecorationThreadGUI(status);
});
}
protected void setWindowsDecorationThreadGUI(final boolean status) {
LOGGER.info("setWindowsDecoration: NOT implemented ...");
}
public void setWindowsDecoration(final boolean status) {};
/**
* The Application request that the Windows will be visible.
*/
public void show() {
postActionToGui(context -> {
context.showThreadGUI();
});
}
public void showThreadGUI() {
LOGGER.info("show: NOT implemented ...");
}
Log.info("show: NOT implemented ...");
};
/**
* StartProcessing (2nd thread).
@ -931,7 +757,7 @@ public abstract class GaleContext {
*/
public void start2ndThreadProcessing() {
// set the current interface:
try (AutoUnLock autoUnlock = AutoUnLock.lock(this.msgSystemAsyncLock)) {
lockContext();
this.periodicThread.threadStart();
try {
Thread.sleep(1);
@ -939,14 +765,94 @@ public abstract class GaleContext {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
// release the current interface:
unLockContext();
};
/**
* The application request that the Window will be killed
*/
public void stop() {
LOGGER.warn("stop: NOT implemented for this platform...");
Log.warning("stop: NOT implemented for this platform...");
};
protected void unLockContext() {
}
}
class MessageSystem {
private final Vector<ActionToDoInAsyncLoop> data = new Vector<>();
public synchronized void addElement(final ActionToDoInAsyncLoop data2) {
this.data.addElement(data2);
notifyAll();
}
public synchronized ActionToDoInAsyncLoop getElement() {
//Log.warning("+++++++++++++++++++++++++++++++++ getElement()");
ActionToDoInAsyncLoop message = this.data.firstElement();
this.data.removeElement(message);
//Log.warning("+++++++++++++++++++++++++++++++++ getElement() ===> done " + message);
return message;
}
public synchronized ActionToDoInAsyncLoop getElementWait() {
if (this.data.isEmpty()) {
try {
wait();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
if (this.data.isEmpty()) {
return null;
}
return getElement();
}
public synchronized int getSize() {
return this.data.size();
}
};
class PeriodicThread extends ThreadAbstract {
private final GaleContext context;
public PeriodicThread(final GaleContext context) {
super("Galethread 2");
this.context = context;
}
@Override
protected void birth() {
// TODO Auto-generated method stub
}
@Override
protected void death() {
// TODO Auto-generated method stub
}
@Override
protected void runPeriodic() {
try {
Thread.sleep(10);
} catch (final InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
///synchronized (this.context) {
this.context.processEvents();
// call all the application for periodic request (the application manage multiple instance )...
final GaleApplication appl = this.context.getApplication();
if (appl != null) {
appl.onPeriod(System.currentTimeMillis());
}
//}
}
}

View File

@ -1,10 +1,12 @@
package org.atriasoft.gale.context.LWJG_AWT;
import static org.lwjgl.opengl.GL.createCapabilities;
import static org.lwjgl.opengl.GL11.glClearColor;
import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
@ -23,7 +25,8 @@ import java.util.List;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import io.scenarium.logger.Logger;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
@ -31,11 +34,11 @@ import org.atriasoft.gale.DisplayManagerDraw;
import org.atriasoft.gale.Fps;
import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.context.GaleContext;
import org.atriasoft.gale.internal.Log;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.awt.AWTGLCanvas;
//import org.lwjgl.Version;
@ -44,12 +47,8 @@ import org.lwjgl.opengl.awt.AWTGLCanvas;
//import org.lwjgl.opengl.GL;
//import org.lwjgl.system.MemoryStack;
import org.lwjgl.opengl.awt.GLData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ContextLWJGLAWT extends GaleContext
implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener {
static final Logger LOGGER = LoggerFactory.getLogger(ContextLWJGLAWT.class);
public class ContextLWJGLAWT extends GaleContext implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener {
private static final int WIDTH = 800;
private static final int HEIGHT = 600;
private static final int MAX_MANAGE_INPUT = 15;
@ -78,10 +77,10 @@ public class ContextLWJGLAWT extends GaleContext
}
public static float getFrameTimeSecconds() {
return ContextLWJGLAWT.delta;
return delta;
}
private final boolean[] inputIsPressed = new boolean[ContextLWJGLAWT.MAX_MANAGE_INPUT];
private final boolean[] inputIsPressed = new boolean[MAX_MANAGE_INPUT];
private Vector2f decoratedWindowsSize = Vector2f.ZERO;
private Vector2f cursorPos = Vector2f.ZERO;
@ -101,14 +100,12 @@ public class ContextLWJGLAWT extends GaleContext
private Robot robot = null;
private final List<Integer> pressedKey = new ArrayList<>();
private Boolean isInitialized = false;
public ContextLWJGLAWT(final GaleApplication application, final String[] args) {
super(application, args);
System.out.println("Hello JOGL !");
initWindows();
start2ndThreadProcessing();
this.isInitialized = true;
}
private int getUniqueIndex(final KeyEvent e) {
@ -126,7 +123,7 @@ public class ContextLWJGLAWT extends GaleContext
}
@Override
protected void grabPointerEventsThreadGUI(final boolean status, final Vector2f forcedPosition) {
public void grabPointerEvents(final boolean status, final Vector2f forcedPosition) {
if (status) {
try {
this.robot = new Robot();
@ -144,14 +141,13 @@ public class ContextLWJGLAWT extends GaleContext
private void hideCursor() {
final int[] pixels = new int[16 * 16];
final Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16));
final Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0),
"invisiblecursor");
final Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0), "invisiblecursor");
this.frame.setCursor(transparentCursor);
}
private void initWindows() {
this.frame = new JFrame("Gale base");
this.frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.frame.setLayout(new BorderLayout());
this.frame.setPreferredSize(new Dimension(800, 600));
this.glData = new GLData();
@ -160,45 +156,28 @@ public class ContextLWJGLAWT extends GaleContext
this.frame.add(this.canvas = new AWTGLCanvas(this.glData) {
@Override
public void initGL() {
System.out.println("OpenGL version: " + this.effective.majorVersion + "." + this.effective.minorVersion
+ " (Profile: " + this.effective.profile + ")");
GL.createCapabilities();
GL11.glClearColor(0.3f, 0.4f, 0.5f, 1);
System.out.println("OpenGL version: " + this.effective.majorVersion + "." + this.effective.minorVersion + " (Profile: " + this.effective.profile + ")");
createCapabilities();
glClearColor(0.3f, 0.4f, 0.5f, 1);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
@Override
public void paintGL() {
final long startRender = System.currentTimeMillis();
//LOGGER.warn("Draw ... ");
//Log.warning("Draw ... ");
final int w = getWidth();
final int h = getHeight();
if (ContextLWJGLAWT.this.decoratedWindowsSize.x() != w
|| ContextLWJGLAWT.this.decoratedWindowsSize.y() != h) {
if (ContextLWJGLAWT.this.decoratedWindowsSize.x() != w || ContextLWJGLAWT.this.decoratedWindowsSize.y() != h) {
ContextLWJGLAWT.this.decoratedWindowsSize = new Vector2f(w, h);
final Rectangle bounds = ContextLWJGLAWT.this.canvas.getBounds();
final Vector2f tmpWindowsSize = new Vector2f(bounds.width, bounds.height);
Vector2f tmpWindowsSize = new Vector2f(bounds.width, bounds.height);
operatingSystemResize(tmpWindowsSize);
}
operatingSystemDraw(true);
swapBuffers();
/*
if (Logger.isCriticalOccured()) {
ContextLWJGLAWT.this.frame.dispose();
}
*/
// Process event from the GUI (specific events...
processEventsGui();
/*
final long stopRender = System.currentTimeMillis();
try {
// limit at 60FPS ==> bad to do it here, but it work for now... add a minimum of 10ms to free lock...
Thread.sleep((int) FMath.max((3000.0f / 60.0f) - (stopRender - startRender), 10)); // This permit to limit the FPS (base 602FPS)
} catch (final InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
}
}, BorderLayout.CENTER);
this.frame.pack();
@ -211,7 +190,7 @@ public class ContextLWJGLAWT extends GaleContext
this.canvas.addMouseWheelListener(this);
this.frame.transferFocus();
ContextLWJGLAWT.lastFrameTime = ContextLWJGLAWT.getCurrentTime();
lastFrameTime = getCurrentTime();
}
@ -221,10 +200,10 @@ public class ContextLWJGLAWT extends GaleContext
}
public void keyEvent(final KeyEvent e, final boolean pressed, final boolean thisIsAReapeateKey) {
//LOGGER.info("event " + thisIsAReapeateKey + " " + e.getKeyCode() + " " + e);
//Log.info("event " + thisIsAReapeateKey + " " + e.getKeyCode() + " " + e);
boolean find = true;
KeyKeyboard keyInput = KeyKeyboard.UNKNOWN;
//LOGGER.error("keyboard input " + e.getWhen() + " " + e.getKeyCode() + " " + e.getKeyLocation());
//Log.error("keyboard input " + e.getWhen() + " " + e.getKeyCode() + " " + e.getKeyLocation());
switch (e.getKeyCode()) {
//case 328: // keypad
case KeyEvent.VK_UP:
@ -321,8 +300,7 @@ public class ContextLWJGLAWT extends GaleContext
keyInput = KeyKeyboard.SHIFT_LEFT;
this.guiKeyBoardMode.setShiftLeft(pressed);
break;
}
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
keyInput = KeyKeyboard.SHIFT_LEFT;
this.guiKeyBoardMode.setShiftRight(pressed);
break;
@ -332,8 +310,7 @@ public class ContextLWJGLAWT extends GaleContext
keyInput = KeyKeyboard.CTRL_LEFT;
this.guiKeyBoardMode.setCtrlLeft(pressed);
break;
}
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
keyInput = KeyKeyboard.CTRL_RIGHT;
this.guiKeyBoardMode.setCtrlRight(pressed);
break;
@ -343,8 +320,7 @@ public class ContextLWJGLAWT extends GaleContext
keyInput = KeyKeyboard.META_LEFT;
this.guiKeyBoardMode.setMetaLeft(pressed);
break;
}
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
keyInput = KeyKeyboard.META_RIGHT;
this.guiKeyBoardMode.setMetaRight(pressed);
break;
@ -368,45 +344,35 @@ public class ContextLWJGLAWT extends GaleContext
find = false;
if (this.guiKeyBoardMode.getNumLock()) {
if (thisIsAReapeateKey) {
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER,
(!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
}
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER,
(pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
} else {
if (thisIsAReapeateKey) {
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER,
(!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
}
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER,
(pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
}
break;
case KeyEvent.VK_TAB: // special case for TAB
find = false;
if (thisIsAReapeateKey) {
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER,
(!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
}
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER,
(pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
break;
default:
find = false;
if (thisIsAReapeateKey) {
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER,
(!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
}
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER,
(pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
}
if (find) {
if (thisIsAReapeateKey) {
operatingSystemsetKeyboard(this.guiKeyBoardMode, keyInput, (!pressed ? KeyStatus.down : KeyStatus.up),
thisIsAReapeateKey);
operatingSystemsetKeyboard(this.guiKeyBoardMode, keyInput, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey);
}
operatingSystemsetKeyboard(this.guiKeyBoardMode, keyInput, (pressed ? KeyStatus.down : KeyStatus.up),
thisIsAReapeateKey);
operatingSystemsetKeyboard(this.guiKeyBoardMode, keyInput, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey);
}
}
@ -433,65 +399,65 @@ public class ContextLWJGLAWT extends GaleContext
@Override
public void keyTyped(final KeyEvent e) {
// not needed with my model ...
//LOGGER.info(" typed " + e.getKeyChar() + " " + e);
//Log.info(" typed " + e.getKeyChar() + " " + e);
}
@Override
public void mouseClicked(final MouseEvent e) {
// System.out.println(e.getX());
// System.out.println(e.getY());
LOGGER.info("Mouse clicked:" + e.getX() + " " + e.getY());
Log.info("Mouse clicked:" + e.getX() + " " + e.getY());
}
@Override
public void mouseDragged(final MouseEvent e) {
//LOGGER.error("mouse drag ... " + e);
//Log.error("mouse drag ... " + e);
mouseMoved(e);
}
@Override
public void mouseEntered(final MouseEvent e) {
// TODO Auto-generated method stub
//LOGGER.info("Mouse entered:" + e.getX() + " " + e.getY());
this.cursorPos = new Vector2f(e.getX(), this.decoratedWindowsSize.y() - e.getY());
//Log.info("Mouse entered:" + e.getX() + " " + e.getY());
this.cursorPos = new Vector2f(e.getX(), e.getY());
operatingSystemSetInput(this.guiKeyBoardMode, KeyType.mouse, KeyStatus.enter, 0, this.cursorPos);
}
@Override
public void mouseExited(final MouseEvent e) {
// TODO Auto-generated method stub
//LOGGER.info("Mouse exited:" + e.getX() + " " + e.getY());
this.cursorPos = new Vector2f(e.getX(), this.decoratedWindowsSize.y() - e.getY());
//Log.info("Mouse exited:" + e.getX() + " " + e.getY());
this.cursorPos = new Vector2f(e.getX(), e.getY());
operatingSystemSetInput(this.guiKeyBoardMode, KeyType.mouse, KeyStatus.leave, 0, this.cursorPos);
//this.frame.mouseMove(e, 200, 200);
}
@Override
public void mouseMoved(final MouseEvent e) {
LOGGER.trace("Mouse moved:" + e.getX() + " " + e.getY() + " " + e);
//Log.info("Mouse moved:" + e.getX() + " " + e.getY() + " " + e);
if (this.robot != null) {
final Rectangle bounds = this.frame.getBounds();
//LOGGER.error(" " + bounds + " windows=" + windowsSize + " deco= " + decoratedWindowsSize);
//Log.error(" " + bounds + " windows=" + windowsSize + " deco= " + decoratedWindowsSize);
final float refPosX = bounds.x + bounds.width / 2.0f;
final float refPosY = bounds.y + bounds.height / 2.0f;
if (e.getXOnScreen() == (int) refPosX && e.getYOnScreen() == (int) refPosY) {
this.cursorPos = Vector2f.ZERO;
return;
}
//LOGGER.error(" " + bounds + " windows=" + windowsSize + " deco= " + decoratedWindowsSize);
this.cursorPos = new Vector2f(-(e.getXOnScreen() - refPosX), (e.getYOnScreen() - refPosY));
//this.cursorPos = new Vector2f(-(e.getXOnScreen() - refPosX), refPosY);
} else {
//Log.error(" " + bounds + " windows=" + windowsSize + " deco= " + decoratedWindowsSize);
this.cursorPos = new Vector2f(-(e.getXOnScreen() - refPosX), e.getYOnScreen() - refPosY);
this.robot.mouseMove((int) refPosX, (int) refPosY);
LOGGER.info("delta moved:" + this.cursorPos);
}
Log.info("delta moved:" + this.cursorPos);
} else {
// TODO use real size ... !!!!
this.cursorPos = new Vector2f(e.getX(), this.decoratedWindowsSize.y() + (this.cursorSize.y() - e.getY()));
this.cursorPos = new Vector2f(e.getX(), this.cursorSize.y() - e.getY());
}
// For compatibility of the Android system :
boolean findOne = false;
for (int iii = 0; iii < ContextLWJGLAWT.MAX_MANAGE_INPUT; iii++) {
for (int iii = 0; iii < MAX_MANAGE_INPUT; iii++) {
if (this.inputIsPressed[iii]) {
//LOGGER.debug("X11 event: bt=" << iii << " " << event.type << " = \"MotionNotify\" (" << m_cursorEventX << "," << m_cursorEventY << ")");
//Log.debug("X11 event: bt=" << iii << " " << event.type << " = \"MotionNotify\" (" << m_cursorEventX << "," << m_cursorEventY << ")");
operatingSystemSetInput(this.guiKeyBoardMode, KeyType.mouse, KeyStatus.move, iii, this.cursorPos);
findOne = true;
}
@ -504,10 +470,10 @@ public class ContextLWJGLAWT extends GaleContext
@Override
public void mousePressed(final MouseEvent e) {
LOGGER.info("Mouse pressed:" + e.getX() + " " + e.getY());
Log.info("Mouse pressed:" + e.getX() + " " + e.getY());
final int button = e.getButton();
this.cursorPos = new Vector2f(e.getX(), this.decoratedWindowsSize.y() - e.getY());
if (button < ContextLWJGLAWT.MAX_MANAGE_INPUT) {
this.cursorPos = new Vector2f(e.getX(), e.getY());
if (button < MAX_MANAGE_INPUT) {
this.inputIsPressed[button] = true;
}
operatingSystemSetInput(this.guiKeyBoardMode, KeyType.mouse, KeyStatus.down, button, this.cursorPos);
@ -515,11 +481,11 @@ public class ContextLWJGLAWT extends GaleContext
@Override
public void mouseReleased(final MouseEvent e) {
//LOGGER.info("Mouse release:" + e.getX() + " " + e.getY());
// LOGGER.info("mouse value: GLFW_RELEASE" + action + " bt=" + button);
//Log.info("Mouse release:" + e.getX() + " " + e.getY());
// Log.info("mouse value: GLFW_RELEASE" + action + " bt=" + button);
final int button = e.getButton();
this.cursorPos = new Vector2f(e.getX(), this.decoratedWindowsSize.y() - e.getY());
if (button < ContextLWJGLAWT.MAX_MANAGE_INPUT) {
this.cursorPos = new Vector2f(e.getX(), e.getY());
if (button < MAX_MANAGE_INPUT) {
this.inputIsPressed[button] = false;
}
operatingSystemSetInput(this.guiKeyBoardMode, KeyType.mouse, KeyStatus.up, button, this.cursorPos);
@ -527,8 +493,8 @@ public class ContextLWJGLAWT extends GaleContext
@Override
public void mouseWheelMoved(final MouseWheelEvent e) {
//LOGGER.info("wheel_event : " + e);
this.cursorPos = new Vector2f(e.getX(), this.decoratedWindowsSize.y() - e.getY());
//Log.info("wheel_event : " + e);
this.cursorPos = new Vector2f(e.getX(), e.getY());
if (e.getWheelRotation() < 0) {
this.inputIsPressed[5] = true;
operatingSystemSetInput(this.guiKeyBoardMode, KeyType.mouse, KeyStatus.down, 5, this.cursorPos);
@ -552,9 +518,7 @@ public class ContextLWJGLAWT extends GaleContext
System.exit(0);
return;
}
if (ContextLWJGLAWT.this.isInitialized) {
ContextLWJGLAWT.this.canvas.render();
}
// fps.toc();
// fps.draw();
SwingUtilities.invokeLater(this);
@ -619,31 +583,31 @@ public class ContextLWJGLAWT extends GaleContext
}
@Override
public void setFullScreenThreadGUI(final boolean status) {
public void setFullScreen(final boolean status) {
super.setFullScreen(status);
if (status) {
this.frame.setExtendedState(Frame.MAXIMIZED_BOTH);
this.frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.frame.setUndecorated(true);
} else {
this.frame.setExtendedState(Frame.NORMAL);
this.frame.setExtendedState(JFrame.NORMAL);
this.frame.setUndecorated(false);
}
}
@Override
public void setIconThreadGUI(final Uri inputFile) {
public void setIcon(final Uri inputFile) {
}
};
/****************************************************************************************/
@Override
public void setTitleThreadGUI(final String title) {
public void setTitle(final String title) {
this.frame.setTitle(title);
}
};
private void showCursor() {
this.frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
};
public void unInit() {

View File

@ -0,0 +1,75 @@
package org.atriasoft.gale.internal;
import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
public class Log {
private static final String LIB_NAME = "gale";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
public static void critical(final String data) {
if (PRINT_CRITICAL) {
Logger.critical(LIB_NAME_DRAW, data);
}
}
public static void critical(final String data, final Exception e) {
e.printStackTrace();
if (PRINT_CRITICAL) {
Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage());
}
}
public static void debug(final String data) {
if (PRINT_DEBUG) {
Logger.debug(LIB_NAME_DRAW, data);
}
}
public static void error(final String data) {
if (PRINT_ERROR) {
Logger.error(LIB_NAME_DRAW, data);
}
}
public static void info(final String data) {
if (PRINT_INFO) {
Logger.info(LIB_NAME_DRAW, data);
}
}
public static void print(final String data) {
if (PRINT_PRINT) {
Logger.print(LIB_NAME_DRAW, data);
}
}
public static void todo(final String data) {
if (PRINT_TODO) {
Logger.todo(LIB_NAME_DRAW, data);
}
}
public static void verbose(final String data) {
if (PRINT_VERBOSE) {
Logger.verbose(LIB_NAME_DRAW, data);
}
}
public static void warning(final String data) {
if (PRINT_WARNING) {
Logger.warning(LIB_NAME_DRAW, data);
}
}
private Log() {}
}

View File

@ -2,11 +2,9 @@ package org.atriasoft.gale.resource;
import org.atriasoft.etk.Uri;
import org.atriasoft.gale.context.GaleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.atriasoft.gale.internal.Log;
public abstract class Resource {
static final Logger LOGGER = LoggerFactory.getLogger(Resource.class);
protected static final String NO_NAME_RESOURCE = "---";
protected static final int MAXRESOURCELEVEL = 5;
private static int idGenerated = 10;
@ -32,20 +30,12 @@ public abstract class Resource {
}
protected Resource(final String name) {
if (name == null) {
this.name = "---";
} else {
this.name = name;
}
getManager().localAdd(this);
}
protected Resource(final Uri uri) {
if (uri == null) {
this.name = "---";
} else {
this.name = uri.toString();
}
getManager().localAdd(this);
}
@ -90,14 +80,14 @@ public abstract class Resource {
* User request the reload of all resources (usefull when the file depend on DATA:GUI:xxx ...
*/
public void reload() {
LOGGER.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
}
Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
};
/**
* The current OpenGl context is removing ==> remove yout own system data
*/
public void removeContext() {
LOGGER.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
}
/**
@ -105,7 +95,7 @@ public abstract class Resource {
* Just update your internal state
*/
public void removeContextToLate() {
LOGGER.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
}
/**
@ -123,7 +113,7 @@ public abstract class Resource {
* @return false The context is not updated
*/
public boolean updateContext() {
LOGGER.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)");
return true;
}
}

View File

@ -9,13 +9,10 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.internal.Log;
import org.lwjgl.BufferUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ResourceColored3DObject extends Resource {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceColored3DObject.class);
public static ResourceColored3DObject create() {
final ResourceColored3DObject resource = new ResourceColored3DObject();
getManager().localAdd(resource);
@ -30,10 +27,10 @@ public class ResourceColored3DObject extends Resource {
private int oGLMatrixView;
protected ResourceColored3DObject() {
super();
// get the shader resource :
this.oGLPosition = 0;
this.program = ResourceProgram.create(new Uri("DATA", "simple3D.vert", "gale"),
new Uri("DATA", "simple3D.frag", "gale"));
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");
@ -59,16 +56,12 @@ public class ResourceColored3DObject extends Resource {
return out;
}
public void draw(
final List<Vector3f> vertices,
final Color color,
final boolean updateDepthBuffer,
final boolean depthtest) {
public void draw(final List<Vector3f> vertices, final Color color, final boolean updateDepthBuffer, final boolean depthtest) {
if (vertices.size() <= 0) {
return;
}
if (this.program == null) {
LOGGER.error("No shader ...");
Log.error("No shader ...");
return;
}
if (depthtest) {
@ -77,7 +70,7 @@ public class ResourceColored3DObject extends Resource {
OpenGL.setDeathMask(false);
}
}
//LOGGER.debug(" display " << this.coord.size() << " elements" );
//Log.debug(" display " << this.coord.size() << " elements" );
this.program.use();
final Matrix4f projectionMatrix = OpenGL.getMatrix();
final Matrix4f viewMatrix = OpenGL.getCameraMatrix();
@ -94,7 +87,7 @@ public class ResourceColored3DObject extends Resource {
OpenGL.enable(OpenGL.Flag.flag_blend);
}
// Request the draw of the elements:
OpenGL.drawArrays(OpenGL.RenderMode.TRIANGLE, 0, vertices.size());
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size());
if (color.a() < 1.0f) {
OpenGL.disable(OpenGL.Flag.flag_blend);
}
@ -110,17 +103,12 @@ public class ResourceColored3DObject extends Resource {
}
}
public void draw(
final List<Vector3f> vertices,
final Color color,
final Matrix4f transformationMatrix,
final boolean updateDepthBuffer,
final boolean depthtest) {
public void draw(final List<Vector3f> vertices, final Color color, final Matrix4f transformationMatrix, final boolean updateDepthBuffer, final boolean depthtest) {
if (vertices.size() <= 0) {
return;
}
if (this.program == null) {
LOGGER.error("No shader ...");
Log.error("No shader ...");
return;
}
if (depthtest) {
@ -129,7 +117,7 @@ public class ResourceColored3DObject extends Resource {
OpenGL.setDeathMask(false);
}
}
//LOGGER.debug(" display " << this.coord.size() << " elements" );
//Log.debug(" display " << this.coord.size() << " elements" );
this.program.use();
// set Matrix: translation/positionMatrix
final Matrix4f projectionMatrix = OpenGL.getMatrix();
@ -141,13 +129,13 @@ public class ResourceColored3DObject extends Resource {
final FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices));
this.program.sendAttribute(this.oGLPosition, 3, buffer, 3);
// color :
//LOGGER.info("color= " + color + " " + this.oGLPosition);
//Log.info("color= " + color + " " + this.oGLPosition);
this.program.uniformColor(this.oGLColor, color);
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());
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size());
if (color.a() < 1.0f) {
OpenGL.disable(OpenGL.Flag.flag_blend);
}
@ -160,13 +148,7 @@ public class ResourceColored3DObject extends Resource {
}
}
public void drawCapsule(
final float radius,
final float size,
int lats,
final int longs,
final Matrix4f transformationMatrix,
final Color tmpColor) {
public void drawCapsule(final float radius, final float size, int lats, final int longs, final Matrix4f transformationMatrix, final Color tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>();
lats = lats / 2 * 2;
@ -262,13 +244,7 @@ public class ResourceColored3DObject extends Resource {
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
}
public void drawCone(
final float radius,
final float size,
final int lats,
final int longs,
final Matrix4f transformationMatrix,
final Color tmpColor) {
public void drawCone(final float radius, final float size, final int lats, final int longs, final Matrix4f transformationMatrix, final Color tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>();
// center to border (TOP)
for (int jjj = 0; jjj < longs; ++jjj) {
@ -308,13 +284,7 @@ public class ResourceColored3DObject extends Resource {
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
}
public void drawCubeLine(
final Vector3f min,
final Vector3f max,
final Color color,
final Matrix4f transformationMatrix,
final boolean updateDepthBuffer,
final boolean depthtest) {
public void drawCubeLine(final Vector3f min, final Vector3f max, final Color color, final Matrix4f transformationMatrix, final boolean updateDepthBuffer, final boolean depthtest) {
final List<Vector3f> vertices = new ArrayList<>();
vertices.add(new Vector3f(min.x(), min.y(), min.z()));
vertices.add(new Vector3f(max.x(), min.y(), min.z()));
@ -354,25 +324,7 @@ public class ResourceColored3DObject extends Resource {
drawLine(vertices, color, transformationMatrix, updateDepthBuffer, depthtest);
}
public void drawCylinder(
final float radius,
final float size,
final int lats,
final int longs,
final Matrix4f transformationMatrix,
final Color tmpColor) {
drawCylinder(radius, size, lats, longs, transformationMatrix, tmpColor, true, true);
}
public void drawCylinder(
final float radius,
final float size,
final int lats,
final int longs,
final Matrix4f transformationMatrix,
final Color tmpColor,
final boolean updateDepthBuffer,
final boolean depthtest) {
public void drawCylinder(final float radius, final float size, final int lats, final int longs, final Matrix4f transformationMatrix, final Color tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>();
// center to border (TOP)
@ -439,20 +391,15 @@ public class ResourceColored3DObject extends Resource {
tmpVertices.add(v2);
tmpVertices.add(v3);
}
draw(tmpVertices, tmpColor, transformationMatrix, updateDepthBuffer, depthtest);
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
}
public void drawLine(
final List<Vector3f> vertices,
final Color color,
final Matrix4f transformationMatrix,
final boolean updateDepthBuffer,
final boolean depthtest) {
public void drawLine(final List<Vector3f> vertices, final Color color, final Matrix4f transformationMatrix, final boolean updateDepthBuffer, final boolean depthtest) {
if (vertices.size() <= 0) {
return;
}
if (this.program == null) {
LOGGER.error("No shader ...");
Log.error("No shader ...");
return;
}
if (depthtest) {
@ -461,7 +408,7 @@ public class ResourceColored3DObject extends Resource {
OpenGL.setDeathMask(false);
}
}
//LOGGER.debug(" display " << this.coord.size() << " elements" );
//Log.debug(" display " << this.coord.size() << " elements" );
this.program.use();
// set Matrix: translation/positionMatrix
final Matrix4f projectionMatrix = OpenGL.getMatrix();
@ -478,7 +425,7 @@ public class ResourceColored3DObject extends Resource {
OpenGL.enable(OpenGL.Flag.flag_blend);
}
// Request the draw od the elements:
OpenGL.drawArrays(OpenGL.RenderMode.LINE, 0, vertices.size());
OpenGL.drawArrays(OpenGL.RenderMode.line, 0, vertices.size());
if (color.a() < 1.0f) {
OpenGL.disable(OpenGL.Flag.flag_blend);
}
@ -491,12 +438,7 @@ public class ResourceColored3DObject extends Resource {
}
}
public void drawSphere(
final float radius,
final int lats,
final int longs,
final Matrix4f transformationMatrix,
final Color tmpColor) {
public void drawSphere(final float radius, final int lats, final int longs, final Matrix4f transformationMatrix, final Color tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>();
for (int iii = 0; iii <= lats; ++iii) {
final float lat0 = (float) Math.PI * (-0.5f + (float) (iii - 1) / lats);
@ -534,12 +476,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()),
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()) };
tmpVertices.clear();
for (int iii = 0; iii < 36; iii += 3) {
@ -553,43 +492,20 @@ public class ResourceColored3DObject extends Resource {
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
}
public void drawTriangle(
final Vector3f p1,
final Vector3f p2,
final Vector3f p3,
final Matrix4f transformationMatrix,
final Color tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>();
tmpVertices.add(p1);
tmpVertices.add(p2);
tmpVertices.add(p3);
//LOGGER.info("display " << tmpVertices.size() << " vertices form " << indice.size());
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
}
public void drawTriangles(
final List<Vector3f> vertex,
final List<Integer> indice,
final Matrix4f transformationMatrix,
final Color tmpColor) {
public void drawTriangles(final List<Vector3f> vertex, final List<Integer> indice, final Matrix4f transformationMatrix, final Color tmpColor) {
drawTriangles(vertex, indice, transformationMatrix, tmpColor, new Vector3f(0.0f, 0.0f, 0.1f));
}
public void drawTriangles(
final List<Vector3f> vertex,
final List<Integer> indice,
final Matrix4f transformationMatrix,
final Color tmpColor,
final Vector3f offset) {
public void drawTriangles(final List<Vector3f> vertex, final List<Integer> indice, final Matrix4f transformationMatrix, final Color tmpColor, final Vector3f offset) {
final List<Vector3f> tmpVertices = new ArrayList<>();
for (int iii = 0; iii < indice.size() / 3; ++iii) {
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));
//LOGGER.info(" indices " << indice[iii*3 + 0] << " " << indice[iii*3 + 1] << " " << indice[iii*3 + 2]);
//LOGGER.info(" triangle " << vertex[indice[iii*3 + 0]] << " " << vertex[indice[iii*3 + 1]] << " " << vertex[indice[iii*3 + 2]]);
//Log.info(" indices " << indice[iii*3 + 0] << " " << indice[iii*3 + 1] << " " << indice[iii*3 + 2]);
//Log.info(" triangle " << vertex[indice[iii*3 + 0]] << " " << vertex[indice[iii*3 + 1]] << " " << vertex[indice[iii*3 + 2]]);
}
//LOGGER.info("display " << tmpVertices.size() << " vertices form " << indice.size());
//Log.info("display " << tmpVertices.size() << " vertices form " << indice.size());
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
}

View File

@ -4,11 +4,9 @@ import java.util.ArrayList;
import java.util.List;
import org.atriasoft.etk.Uri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.atriasoft.gale.internal.Log;
public class ResourceManager {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceManager.class);
private static final int MAX_RESOURCE_LEVEL = 9;
private final List<Resource> resourceList = new ArrayList<>();
private List<Resource> resourceListToUpdate = new ArrayList<>();
@ -31,7 +29,7 @@ public class ResourceManager {
}
public synchronized void cleanInternalRemoved() {
//LOGGER.info("remove object in Manager");
//Log.info("remove object in Manager");
updateContext();
// TODO ...
// for (auto it(this.resourceList.begin()); it!=this.resourceList.end(); ++it) {
@ -46,13 +44,11 @@ public class ResourceManager {
* This is to inform the resources manager that we have no more openGl context ...
*/
public synchronized void contextHasBeenDestroyed() {
synchronized (this.resourceList) {
for (final Resource it : this.resourceList) {
if (it.getCount() > 0) {
it.removeContextToLate();
}
}
}
// no context preent ...
this.contextHasBeenRemoved = true;
}
@ -61,29 +57,22 @@ public class ResourceManager {
* display in the log all the resources loaded ...
*/
public synchronized void display() {
LOGGER.info("Resources loaded : ");
Log.info("Resources loaded : ");
// remove all resources ...
synchronized (this.resourceList) {
for (final Resource it : this.resourceList) {
LOGGER.info(" [" + it.getId() + "]" + it.getClass().getCanonicalName() + "='" + it.getName() + "' "
+ it.getCount() + " elements");
Log.info(" [" + it.getId() + "]" + it.getClass().getCanonicalName() + "='" + it.getName() + "' " + it.getCount() + " elements");
}
}
LOGGER.info("Resources ---");
Log.info("Resources ---");
}
public synchronized void localAdd(final Resource object) {
// add at the end if no slot is free
synchronized (this.resourceList) {
this.resourceList.add(object);
}
}
// internal API to extent eResources in extern Soft
public synchronized Resource localKeep(final String filename) {
synchronized (this.resourceList) {
LOGGER.trace("KEEP (DEFAULT) : file : '" + filename + "' in " + this.resourceList.size() + " resources");
Log.verbose("KEEP (DEFAULT) : file : '" + filename + "' in " + this.resourceList.size() + " resources");
for (final Resource it : this.resourceList) {
if (it == null) {
continue;
@ -91,7 +80,7 @@ public class ResourceManager {
if (it.getName() == null) {
continue;
}
//LOGGER.trace("compare : " + filename + " ==???== " + it.getName());
//Log.verbose("compare : " + filename + " ==???== " + it.getName());
if (it.getName().contentEquals(Resource.NO_NAME_RESOURCE)) {
continue;
}
@ -99,7 +88,6 @@ public class ResourceManager {
return it;
}
}
}
return null;
}
@ -113,24 +101,22 @@ public class ResourceManager {
* @note If file is reference at THEMEXXX:///filename if the Theme change the file will reload the newOne
*/
public synchronized void reLoadResources() {
LOGGER.info("------------- Resources re-loaded -------------");
Log.info("------------- Resources re-loaded -------------");
// remove all resources ...
for (long jjj = 0; jjj < ResourceManager.MAX_RESOURCE_LEVEL; jjj++) {
LOGGER.info(" Reload level : " + jjj + "/" + (ResourceManager.MAX_RESOURCE_LEVEL - 1));
synchronized (this.resourceList) {
for (long jjj = 0; jjj < MAX_RESOURCE_LEVEL; jjj++) {
Log.info(" Reload level : " + jjj + "/" + (MAX_RESOURCE_LEVEL - 1));
for (final Resource it : this.resourceList) {
if (jjj == it.getResourceLevel()) {
if (it.getCount() > 0) {
it.reload();
LOGGER.info(" [" + it.getId() + "]=" + it.getClass().getCanonicalName());
}
Log.info(" [" + it.getId() + "]=" + it.getClass().getCanonicalName());
}
}
}
}
// TODO UNderstand why it is set here ...
//gale::requestUpdateSize();
LOGGER.info("------------- Resources -------------");
Log.info("------------- Resources -------------");
}
/**
@ -145,14 +131,11 @@ public class ResourceManager {
display();
this.resourceListToUpdate.clear();
// remove all resources ...
synchronized (this.resourceList) {
for (final Resource it : this.resourceList) {
LOGGER.warn("Find a resource that is not removed : [" + it.getId() + "]" + "='" + it.getName() + "' "
+ it.getCount() + " elements");
Log.warning("Find a resource that is not removed : [" + it.getId() + "]" + "='" + it.getName() + "' " + it.getCount() + " elements");
}
this.resourceList.clear();
}
}
/**
* Call by the system to send all the needed data on the graphic card chen they change ...
@ -177,10 +160,10 @@ public class ResourceManager {
*/
public void updateContext() {
if (this.exiting) {
LOGGER.error("Request update after application EXIT ...");
Log.error("Request update after application EXIT ...");
return;
}
// TODO Check the number of call this ... LOGGER.info("update open-gl context ... ");
// TODO Check the number of call this ... Log.info("update open-gl context ... ");
if (this.contextHasBeenRemoved) {
// need to update all ...
this.contextHasBeenRemoved = false;
@ -189,12 +172,11 @@ public class ResourceManager {
}
synchronized (this.resourceList) {
if (this.resourceList.size() != 0) {
for (long jjj = 0; jjj < ResourceManager.MAX_RESOURCE_LEVEL; jjj++) {
LOGGER.trace(" updateContext level (D) : " + jjj + "/"
+ (ResourceManager.MAX_RESOURCE_LEVEL - 1));
for (long jjj = 0; jjj < MAX_RESOURCE_LEVEL; jjj++) {
Log.verbose(" updateContext level (D) : " + jjj + "/" + (MAX_RESOURCE_LEVEL - 1));
for (final Resource it : this.resourceList) {
if (jjj == it.getResourceLevel()) {
//LOGGER.debug("Update context named : " + lresourceList[iii].getName());
//Log.debug("Update context named : " + lresourceList[iii].getName());
if (!it.updateContext()) {
// Lock error ==> postponned
synchronized (this.resourceListToUpdate) {
@ -213,9 +195,8 @@ public class ResourceManager {
this.resourceListToUpdate = new ArrayList<>();
}
if (resourceListToUpdate.size() != 0) {
for (long jjj = 0; jjj < ResourceManager.MAX_RESOURCE_LEVEL; jjj++) {
LOGGER.trace(
" updateContext level (U) : " + jjj + "/" + (ResourceManager.MAX_RESOURCE_LEVEL - 1));
for (long jjj = 0; jjj < MAX_RESOURCE_LEVEL; jjj++) {
Log.verbose(" updateContext level (U) : " + jjj + "/" + (MAX_RESOURCE_LEVEL - 1));
for (final Resource it : resourceListToUpdate) {
if (jjj == it.getResourceLevel()) {
if (!it.updateContext()) {

View File

@ -11,41 +11,37 @@ import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.etk.math.Vector3i;
import org.atriasoft.etk.math.Vector4f;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.internal.Log;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.lwjgl.opengl.GL40;
class ProgAttributeElement {
public String name; // !< Name of the element
public int elementId; // !< openGl Id if this element == > can not exist ==> @ref m_isLinked
public boolean isAttribute; // !< true if it was an attribute element, otherwite it was an uniform
public boolean isLinked; // !< if this element does not exist this is false
}
};
public class ResourceProgram extends Resource {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceProgram.class);
static final boolean DEBUG = false; // TODO externalize this ...
public static ResourceProgram create(final Uri uriVertexShader, final Uri uriFragmentShader) {
ResourceProgram resource;
final String name = uriVertexShader.getValue() + "<-->" + uriFragmentShader.getValue();
final Resource resource2 = Resource.getManager().localKeep(name);
Resource resource2 = getManager().localKeep(name);
if (resource2 != null) {
if (resource2 instanceof ResourceProgram) {
resource2.keep();
return (ResourceProgram) resource2;
}
LOGGER.error("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
System.exit(-1);
Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
return null;
}
resource = new ResourceProgram(uriVertexShader, uriFragmentShader);
Resource.getManager().localAdd(resource);
getManager().localAdd(resource);
return resource;
}
@ -101,23 +97,25 @@ public class ResourceProgram extends Resource {
protected ResourceProgram(final Uri uriVertexShader, final Uri uriFragmentShader) {
super(uriVertexShader.getValue() + "<-->" + uriFragmentShader.getValue());
this.resourceLevel = 1;
LOGGER.debug("OGL : load PROGRAM '" + uriVertexShader + "' && '" + uriFragmentShader + "'");
Log.debug("OGL : load PROGRAM '" + uriVertexShader + "' && '" + uriFragmentShader + "'");
this.shaderVertex = ResourceShader.create(uriVertexShader);
if (this.shaderVertex == null) {
LOGGER.error("Error while getting a specific shader filename: " + uriVertexShader);
Log.error("Error while getting a specific shader filename: " + uriVertexShader);
return;
} else {
Log.debug("Add shader on program: '" + uriFragmentShader + "'");
}
LOGGER.debug("Add shader on program: '" + uriFragmentShader + "'");
this.shaderFragment = ResourceShader.create(uriFragmentShader);
if (this.shaderFragment == null) {
LOGGER.error("Error while getting a specific shader filename: " + uriFragmentShader);
Log.error("Error while getting a specific shader filename: " + uriFragmentShader);
return;
} else {
Log.debug("Add shader on program : " + uriFragmentShader + "frag");
}
LOGGER.debug("Add shader on program : " + uriFragmentShader + "frag");
if (OpenGL.hasContext()) {
updateContext();
} else {
Resource.getManager().update(this);
getManager().update(this);
}
}
@ -133,16 +131,15 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
return;
}
LOGGER.error("[" + this.elementList.get(idElem).name + "] send on oglID=" + vbo.getOpenGlId(vboId)
+ " VBOindex=" + vboId);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo.getOpenGlId(vboId));
Log.error("[" + this.elementList.get(idElem).name + "] send on oglID=" + vbo.getOpenGlId(vboId) + " VBOindex=" + vboId);
GL20.glBindBuffer(GL20.GL_ARRAY_BUFFER, vbo.getOpenGlId(vboId));
GL20.glEnableVertexAttribArray(this.elementList.get(idElem).elementId);
this.listOfVBOUsed.add(this.elementList.get(idElem).elementId);
}
@ -219,19 +216,17 @@ public class ResourceProgram extends Resource {
tmp.name = elementName;
tmp.isAttribute = true;
if (!OpenGL.hasContext()) {
Resource.getManager().update(this);
getManager().update(this);
tmp.elementId = -1;
tmp.isLinked = false;
} else if (this.exist) {
tmp.elementId = OpenGL.programGetAttributeLocation(this.program, tmp.name);
tmp.isLinked = true;
if (tmp.elementId < 0) {
LOGGER.warn(" {" + this.program + "}[" + this.elementList.size() + "] glGetAttribLocation(\""
+ tmp.name + "\") = " + tmp.elementId);
Log.warning(" {" + this.program + "}[" + this.elementList.size() + "] glGetAttribLocation(\"" + tmp.name + "\") = " + tmp.elementId);
tmp.isLinked = false;
} else {
LOGGER.debug(" {" + this.program + "}[" + this.elementList.size() + "] glGetAttribLocation(\""
+ tmp.name + "\") = " + tmp.elementId);
Log.debug(" {" + this.program + "}[" + this.elementList.size() + "] glGetAttribLocation(\"" + tmp.name + "\") = " + tmp.elementId);
}
} else {
// program is not loaded ==> just local reister ...
@ -267,19 +262,17 @@ public class ResourceProgram extends Resource {
tmp.name = elementName;
tmp.isAttribute = false;
if (!OpenGL.hasContext()) {
Resource.getManager().update(this);
getManager().update(this);
tmp.elementId = -1;
tmp.isLinked = false;
} else if (this.exist) {
tmp.elementId = OpenGL.programGetUniformLocation(this.program, tmp.name);
tmp.isLinked = true;
if (tmp.elementId < 0) {
LOGGER.warn(" {" + this.program + "}[" + this.elementList.size() + "] glGetUniformLocation(\""
+ tmp.name + "\") = " + tmp.elementId);
Log.warning(" {" + this.program + "}[" + this.elementList.size() + "] glGetUniformLocation(\"" + tmp.name + "\") = " + tmp.elementId);
tmp.isLinked = false;
} else {
LOGGER.debug(" {" + this.program + "}[" + this.elementList.size() + "] glGetUniformLocation(\""
+ tmp.name + "\") = " + tmp.elementId);
Log.debug(" {" + this.program + "}[" + this.elementList.size() + "] glGetUniformLocation(\"" + tmp.name + "\") = " + tmp.elementId);
}
} else {
// program is not loaded ==> just local reister ...
@ -300,14 +293,14 @@ public class ResourceProgram extends Resource {
public void reload() {
/*
* TODO ... etk::file file(this.name, etk::FILETYPEDATA); if (file.Exist() ==
* false) { LOGGER.error("File does not Exist :"" + file + "\""); return; }
* false) { Log.error("File does not Exist :"" + file + "\""); return; }
*
* int fileSize = file.size(); if (fileSize == 0) {
* LOGGER.error("This file is empty : " + file); return; } if (file.fOpenRead() ==
* false) { LOGGER.error("Can not open the file : " + file); return; } // remove
* Log.error("This file is empty : " + file); return; } if (file.fOpenRead() ==
* false) { Log.error("Can not open the file : " + file); return; } // remove
* previous data ... if (this.fileData != null) { del ete[] this.fileData;
* this.fileData = 0; } // allocate data this.fileData = ne w char[fileSize+5];
* if (this.fileData == null) { LOGGER.error("Error Memory allocation size=" +
* if (this.fileData == null) { Log.error("Error Memory allocation size=" +
* fileSize); return; } memset(this.fileData, 0, (fileSize+5)*sizeof(char)); //
* load data from the file : file.fRead(this.fileData, 1, fileSize); // close
* the file: file.fClose();
@ -360,7 +353,7 @@ public class ResourceProgram extends Resource {
// }
// if ( idElem < 0
// || (long)idElem > this.elementList.size()) {
// LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1)
// Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1)
// + "]");
// return;
// }
@ -369,7 +362,7 @@ public class ResourceProgram extends Resource {
// }
// FloatBuffer buffer = storeDataInFloatBuffer(data);
// //GL40.glBindVertexArray(this.elementList.get(idElem).elementId);
// LOGGER.error("[" + this.elementList.get(idElem).name + "] send " + data.length +
// Log.error("[" + this.elementList.get(idElem).name + "] send " + data.length +
// " element");
// GL40.glVertexAttribPointer(
// this.elementList.get(idElem).elementId,
@ -388,29 +381,24 @@ public class ResourceProgram extends Resource {
// public void sendAttribute(int idElem, List<Vector3f> data) {
// sendAttribute3fv(idElem, convertInFloat(data));
// }
public void sendAttribute(
final int idElem,
final int nbElement,
final FloatBuffer data,
final int jumpBetweenSample) {
public void sendAttribute(final int idElem, final int nbElement, final FloatBuffer data, final int jumpBetweenSample) {
if (!this.exist) {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
return;
}
// GL40.glBindVertexArray(this.elementList.get(idElem).elementId);
// LOGGER.error("[" + this.elementList.get(idElem).name + "] send " + 3 + "
// Log.error("[" + this.elementList.get(idElem).name + "] send " + 3 + "
// element");
GL20.glVertexAttribPointer(this.elementList.get(idElem).elementId, nbElement, GL11.GL_FLOAT, false,
jumpBetweenSample * 4, /* 4 is the size of float in the generic system... */
GL40.glVertexAttribPointer(this.elementList.get(idElem).elementId, nbElement, GL40.GL_FLOAT, false, jumpBetweenSample * 4, /* 4 is the size of float in the generic system... */
data);
// checkGlError("glVertexAttribPointer", LINE, idElem);
GL20.glEnableVertexAttribArray(this.elementList.get(idElem).elementId);
GL40.glEnableVertexAttribArray(this.elementList.get(idElem).elementId);
// checkGlError("glEnableVertexAttribArray", LINE, idElem);
}
@ -432,7 +420,7 @@ public class ResourceProgram extends Resource {
// }
// if ( idElem < 0
// || (long)idElem > this.elementList.size()) {
// LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1)
// Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1)
// + "]");
// return;
// }
@ -441,17 +429,17 @@ public class ResourceProgram extends Resource {
// }
// // check error of the VBO goog enought ...
// if (vbo.getElementSize(index) <= 0) {
// LOGGER.error("Can not bind a VBO Buffer with an element size of : " +
// Log.error("Can not bind a VBO Buffer with an element size of : " +
// vbo.getElementSize(index) + " named=" + vbo.getName());
// return;
// }
//
// LOGGER.trace("[" + this.elementList.get(idElem).name + "] send " +
// Log.verbose("[" + this.elementList.get(idElem).name + "] send " +
// vbo.getElementSize(index) + " element on oglID=" + vbo.getGLID(index) + "
// VBOindex=" + index);
// OpenGL.bindBuffer(vbo.getGLID(index));
// LOGGER.trace(" id=" + this.elementList.get(idElem).elementId);
// LOGGER.trace(" eleme size=" + vbo.getElementSize(index));
// Log.verbose(" id=" + this.elementList.get(idElem).elementId);
// Log.verbose(" eleme size=" + vbo.getElementSize(index));
// OpenGL.bufferData(data, Usage.staticDraw);
// OpenGL.vertexAttribPointerFloat(this.elementList.get(idElem).elementId,
// vbo.getElementSize(index)); // Pointer on the buffer
@ -466,20 +454,19 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
return;
}
LOGGER.trace("[" + this.elementList.get(idElem).name + "] send on oglID=" + vbo.getOpenGlId(index)
+ " VBOindex=" + index);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo.getOpenGlId(index));
Log.verbose("[" + this.elementList.get(idElem).name + "] send on oglID=" + vbo.getOpenGlId(index) + " VBOindex=" + index);
GL20.glBindBuffer(GL20.GL_ARRAY_BUFFER, vbo.getOpenGlId(index));
// checkGlError("glBindBuffer", __LINE__, _idElem);
LOGGER.trace(" id=" + this.elementList.get(idElem).elementId);
LOGGER.trace(" jump sample=" + jumpBetweenSample);
LOGGER.trace(" offset=" + offset);
Log.verbose(" id=" + this.elementList.get(idElem).elementId);
Log.verbose(" jump sample=" + jumpBetweenSample);
Log.verbose(" offset=" + offset);
GL20.glVertexAttribPointer(this.elementList.get(idElem).elementId, // attribute ID of openGL
vbo.getElementSize(index), // number of elements per vertex, here (r,g,b,a)
GL11.GL_FLOAT, // the type of each element
@ -538,7 +525,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -547,20 +534,6 @@ public class ResourceProgram extends Resource {
OpenGL.programLoadUniformColor(this.elementList.get(idElem).elementId, value);
}
public void uniformColorRGB(final int idElem, final Color value) {
if (!this.exist) {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
return;
}
OpenGL.programLoadUniformColorRGB(this.elementList.get(idElem).elementId, value);
}
/**
* Send 1 float uniform element to the spefified ID (not send if does not
* really exist in the openGL program)
@ -572,7 +545,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -594,7 +567,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -617,7 +590,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -635,18 +608,13 @@ public class ResourceProgram extends Resource {
* @param value3 Value to send at the Uniform
* @param value4 Value to send at the Uniform
*/
public void uniformFloat(
final int idElem,
final float value1,
final float value2,
final float value3,
final float value4) {
public void uniformFloat(final int idElem, final float value1, final float value2, final float value3, final float value4) {
if (!this.exist) {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -667,7 +635,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -689,7 +657,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -712,7 +680,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -736,7 +704,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -763,13 +731,13 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
return;
}
// LOGGER.error("[" + this.elementList.get(idElem).name + "] send 1 matrix");
// Log.error("[" + this.elementList.get(idElem).name + "] send 1 matrix");
// note : Android des not supported the transposition of the matrix, then we
// will done it oursef:
/*
@ -786,7 +754,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -800,7 +768,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -814,7 +782,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -828,21 +796,7 @@ public class ResourceProgram extends Resource {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
return;
}
OpenGL.programLoadUniformVector(this.elementList.get(idElem).elementId, value);
}
public void uniformVector(final int idElem, final Vector4f value) {
if (!this.exist) {
return;
}
if (idElem < 0 || (long) idElem > this.elementList.size()) {
LOGGER.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size() - 1) + "]");
return;
}
if (!this.elementList.get(idElem).isLinked) {
@ -855,7 +809,7 @@ public class ResourceProgram extends Resource {
* Stop the processing of this program
*/
public void unUse() {
// LOGGER.trace("Will UN-use program : " + this.program);
// Log.verbose("Will UN-use program : " + this.program);
if (!this.exist) {
return;
@ -878,7 +832,7 @@ public class ResourceProgram extends Resource {
// Do nothing == > too dangerous ...
} else {
// create the Shader
LOGGER.debug("Create the Program ...'" + this.name + "'");
Log.debug("Create the Program ...'" + this.name + "'");
this.program = OpenGL.programCreate();
if (this.program < 0) {
return true;
@ -892,13 +846,12 @@ public class ResourceProgram extends Resource {
}
OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_POSITIONS, "in_position");
OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_TEXTURE_COORDINATES,
"in_extureCoords");
OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_TEXTURE_COORDINATES, "tin_extureCoords");
OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_NORMALS, "in_normal");
OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_COLORS, "in_colors");
if (!OpenGL.programCompile(this.program)) {
LOGGER.error("Could not compile'PROGRAM':'" + this.name + "'");
Log.error("Could not compile'PROGRAM':'" + this.name + "'");
OpenGL.programRemove(this.program);
return true;
}
@ -909,23 +862,19 @@ public class ResourceProgram extends Resource {
it.elementId = OpenGL.programGetAttributeLocation(this.program, it.name);
it.isLinked = true;
if (it.elementId < 0) {
LOGGER.warn(" {" + this.program + "}[" + iii + "] openGL::getAttributeLocation(\"" + it.name
+ "\") = " + it.elementId);
Log.warning(" {" + this.program + "}[" + iii + "] openGL::getAttributeLocation(\"" + it.name + "\") = " + it.elementId);
it.isLinked = false;
} else {
LOGGER.debug(" {" + this.program + "}[" + iii + "] openGL::getAttributeLocation(\"" + it.name
+ "\") = " + it.elementId);
Log.debug(" {" + this.program + "}[" + iii + "] openGL::getAttributeLocation(\"" + it.name + "\") = " + it.elementId);
}
} else {
it.elementId = OpenGL.programGetUniformLocation(this.program, it.name);
it.isLinked = true;
if (it.elementId < 0) {
LOGGER.warn(" {" + this.program + "}[" + iii + "] openGL::getUniformLocation(\"" + it.name
+ "\") = " + it.elementId);
Log.warning(" {" + this.program + "}[" + iii + "] openGL::getUniformLocation(\"" + it.name + "\") = " + it.elementId);
it.isLinked = false;
} else {
LOGGER.debug(" {" + this.program + "}[" + iii + "] openGL::getUniformLocation(\"" + it.name
+ "\") = " + it.elementId);
Log.debug(" {" + this.program + "}[" + iii + "] openGL::getUniformLocation(\"" + it.name + "\") = " + it.elementId);
}
}
iii++;
@ -940,7 +889,7 @@ public class ResourceProgram extends Resource {
* Request the processing of this program
*/
public void use() {
// LOGGER.trace("Will use program : " + this.program);
// Log.verbose("Will use program : " + this.program);
// event if it was 0 == > set it to prevent other use of the previous shader
// display ...
OpenGL.programUse(this.program);

View File

@ -3,11 +3,9 @@ package org.atriasoft.gale.resource;
import org.atriasoft.etk.Uri;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.ShaderType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.atriasoft.gale.internal.Log;
public class ResourceShader extends Resource {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceShader.class);
public static ResourceShader create(final Uri uriShader) {
ResourceShader resource;
@ -16,7 +14,7 @@ public class ResourceShader extends Resource {
if (!name.isEmpty() && !name.equals("---")) {
resource2 = getManager().localKeep(name);
} else {
LOGGER.error("Can not create a shader without a filaname");
Log.error("Can not create a shader without a filaname");
return null;
}
if (resource2 != null) {
@ -24,8 +22,7 @@ public class ResourceShader extends Resource {
resource2.keep();
return (ResourceShader) resource2;
}
LOGGER.error("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
System.exit(-1);
Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
return null;
}
resource = new ResourceShader(uriShader);
@ -46,18 +43,16 @@ public class ResourceShader extends Resource {
super(uri);
this.uri = uri;
this.resourceLevel = 0;
LOGGER.debug("OGL : load SHADER '" + uri + "'");
Log.debug("OGL : load SHADER '" + uri + "'");
// load data from file "all the time ..."
if (uri.get().endsWith(".frag")) {
this.type = ShaderType.FRAGMENT;
this.type = ShaderType.fragment;
} else if (uri.get().endsWith(".vert")) {
this.type = ShaderType.VERTEX;
this.type = ShaderType.vertex;
} else {
LOGGER.error(
"File does not have extention '.vert' for Vertex Shader or '.frag' for Fragment Shader. but : \""
+ uri + "\"");
this.type = ShaderType.VERTEX;
Log.error("File does not have extention '.vert' for Vertex Shader or '.frag' for Fragment Shader. but : \"" + uri + "\"");
this.type = ShaderType.vertex;
return;
}
reload();
@ -95,16 +90,15 @@ public class ResourceShader extends Resource {
@Override
public void reload() {
//!< A copy of the data loaded from the file (useful only when opengl context is removed)
final String fileData = "";
LOGGER.trace("load shader:\n-----------------------------------------------------------------\n" + fileData
+ "\n-----------------------------------------------------------------");
String fileData = "";
Log.verbose("load shader:\n-----------------------------------------------------------------\n" + fileData + "\n-----------------------------------------------------------------");
// now change the OGL context ...
if (OpenGL.hasContext()) {
LOGGER.debug("OGL : load SHADER '" + this.name + "' ==> call update context (direct)");
Log.debug("OGL : load SHADER '" + this.name + "' ==> call update context (direct)");
removeContext();
updateContext();
} else {
LOGGER.debug("OGL : load SHADER '" + this.name + "' ==> tagged has update context needed");
Log.debug("OGL : load SHADER '" + this.name + "' ==> tagged has update context needed");
// TODO Check this, this is a leek ==> in the GPU ... really bad ...
this.exist = false;
this.shader = 0;

View File

@ -6,30 +6,23 @@ import org.atriasoft.egami.ImageByteRGBA;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.internal.Log;
import org.atriasoft.gale.tools.ImageLoader;
import org.atriasoft.gale.tools.ImageRawData;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL30;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated
public class ResourceTexture extends Resource {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceTexture.class);
public enum TextureColorMode {
rgb, //!< red/green/blue data
rgba //!< red/green/blue/alpha data
}
private static int[] textureIdBinding = { GL13.GL_TEXTURE0, GL13.GL_TEXTURE1, GL13.GL_TEXTURE2, GL13.GL_TEXTURE3,
GL13.GL_TEXTURE4, GL13.GL_TEXTURE5, GL13.GL_TEXTURE6, GL13.GL_TEXTURE7, GL13.GL_TEXTURE8, GL13.GL_TEXTURE9,
GL13.GL_TEXTURE10, GL13.GL_TEXTURE11, GL13.GL_TEXTURE12, GL13.GL_TEXTURE13, GL13.GL_TEXTURE14,
GL13.GL_TEXTURE15, GL13.GL_TEXTURE16, GL13.GL_TEXTURE17, GL13.GL_TEXTURE18, GL13.GL_TEXTURE19,
GL13.GL_TEXTURE20, GL13.GL_TEXTURE21, GL13.GL_TEXTURE22, GL13.GL_TEXTURE23, GL13.GL_TEXTURE24,
GL13.GL_TEXTURE25, GL13.GL_TEXTURE26, GL13.GL_TEXTURE27, GL13.GL_TEXTURE28, GL13.GL_TEXTURE29,
GL13.GL_TEXTURE30, GL13.GL_TEXTURE31 };;
private static int[] textureIdBinding = { GL13.GL_TEXTURE0, GL13.GL_TEXTURE1, GL13.GL_TEXTURE2, GL13.GL_TEXTURE3, GL13.GL_TEXTURE4, GL13.GL_TEXTURE5, GL13.GL_TEXTURE6, GL13.GL_TEXTURE7,
GL13.GL_TEXTURE8, GL13.GL_TEXTURE9, GL13.GL_TEXTURE10, GL13.GL_TEXTURE11, GL13.GL_TEXTURE12, GL13.GL_TEXTURE13, GL13.GL_TEXTURE14, GL13.GL_TEXTURE15, GL13.GL_TEXTURE16, GL13.GL_TEXTURE17,
GL13.GL_TEXTURE18, GL13.GL_TEXTURE19, GL13.GL_TEXTURE20, GL13.GL_TEXTURE21, GL13.GL_TEXTURE22, GL13.GL_TEXTURE23, GL13.GL_TEXTURE24, GL13.GL_TEXTURE25, GL13.GL_TEXTURE26,
GL13.GL_TEXTURE27, GL13.GL_TEXTURE28, GL13.GL_TEXTURE29, GL13.GL_TEXTURE30, GL13.GL_TEXTURE31 };;
public static ResourceTexture createFromPng(final Uri uriTexture) {
return createFromPng(uriTexture, 1);
@ -42,7 +35,7 @@ public class ResourceTexture extends Resource {
if (!name.isEmpty() && !name.equals("---")) {
resource2 = getManager().localKeep(name);
} else {
LOGGER.error("Can not create a shader without a filaname");
Log.error("Can not create a shader without a filaname");
return null;
}
if (resource2 != null) {
@ -50,22 +43,14 @@ public class ResourceTexture extends Resource {
resource2.keep();
return (ResourceTexture) resource2;
}
LOGGER.error("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
System.exit(-1);
Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
return null;
}
resource = new ResourceTexture(uriTexture, textureUnit);
ImageRawData decodedData;
try {
decodedData = ImageLoader.decodePngFile(uriTexture);
} catch (final Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
final ImageByteRGBA img = new ImageByteRGBA(decodedData.getWidth(), decodedData.getHeight());
final ByteBuffer mlklmklm = decodedData.getBuffer();
final byte[] elemData = new byte[mlklmklm.remaining()];
final ImageRawData decodedData = ImageLoader.decodePngFile(uriTexture);
ImageByteRGBA img = new ImageByteRGBA(decodedData.getWidth(), decodedData.getHeight());
ByteBuffer mlklmklm = decodedData.getBuffer();
byte[] elemData = new byte[mlklmklm.remaining()];
mlklmklm.get(elemData);
if (decodedData.isHasAlpha()) {
for (int yyy = 0; yyy < decodedData.getHeight(); yyy++) {
@ -79,15 +64,14 @@ public class ResourceTexture extends Resource {
} else {
for (int yyy = 0; yyy < decodedData.getHeight(); yyy++) {
for (int xxx = 0; xxx < decodedData.getWidth(); xxx++) {
img.setAByte(xxx, yyy, (byte) 0xFF);
img.setAFloat(xxx, yyy, 0xFF);
img.setRByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 3 + 0]);
img.setGByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 3 + 1]);
img.setBByte(xxx, yyy, elemData[(yyy * decodedData.getWidth() + xxx) * 3 + 2]);
}
}
}
resource.setTexture(img, new Vector2i(decodedData.getWidth(), decodedData.getHeight()),
(decodedData.isHasAlpha() ? TextureColorMode.rgba : TextureColorMode.rgb), textureUnit);
resource.setTexture(img, new Vector2i(decodedData.getWidth(), decodedData.getHeight()), (decodedData.isHasAlpha() ? TextureColorMode.rgba : TextureColorMode.rgb), textureUnit);
resource.flush();
return resource;
}
@ -105,8 +89,7 @@ public class ResourceTexture extends Resource {
}
val *= 2;
}
LOGGER.error("impossible CASE....");
System.exit(-1);
Log.critical("impossible CASE....");
return val;
}
@ -126,7 +109,9 @@ public class ResourceTexture extends Resource {
// number of lines and colomns in the texture (multiple texturing in a single texture)
private int textureUnit = 0;
protected ResourceTexture() {}
protected ResourceTexture() {
super();
}
protected ResourceTexture(final Uri filename, final int textureUnit) {
super(filename.toString() + "__" + textureUnit);
@ -153,7 +138,7 @@ public class ResourceTexture extends Resource {
// Flush the data to send it at the openGl system
public synchronized void flush() {
// request to the manager to be call at the next update ...
LOGGER.trace("Request UPDATE of Element");
Log.verbose("Request UPDATE of Element");
getManager().update(this);
}
@ -173,7 +158,7 @@ public class ResourceTexture extends Resource {
public synchronized void removeContext() {
if (this.loaded) {
// Request remove texture ...
LOGGER.info("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
Log.info("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
// TODO Check if we are in the correct thread
OpenGL.glDeleteTextures(this.texId);
this.loaded = false;
@ -186,11 +171,7 @@ public class ResourceTexture extends Resource {
this.texId = -1;
}
public void setTexture(
final ImageByteRGBA data,
final Vector2i size,
final TextureColorMode dataColorSpace,
final int textureUnit) {
public void setTexture(final ImageByteRGBA data, final Vector2i size, final TextureColorMode dataColorSpace, final int textureUnit) {
this.data = data;
this.size = size;
this.textureUnit = textureUnit;
@ -222,15 +203,13 @@ public class ResourceTexture extends Resource {
// All RGB bytes are aligned to each other and each component is 1 byte
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
LOGGER.info("TEXTURE: add [" + getId() + "]=" + this.size + " OGlId=" + this.texId);
Log.info("TEXTURE: add [" + getId() + "]=" + this.size + " OGlId=" + this.texId);
if (this.dataColorSpace == TextureColorMode.rgb) {
OpenGL.glTexImage2D(0, GL11.GL_RGBA, this.size.x(), this.size.y(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,
this.data.getRaw());
OpenGL.glTexImage2D(0, GL11.GL_RGBA, this.size.x(), this.size.y(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, this.data.getRaw());
//The local image has not RGB but only RGBA data ...
//OpenGL.glTexImage2D(0, GL11.GL_RGBA, this.size.x(), this.size.y(), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, this.data.getRaw());
} else {
OpenGL.glTexImage2D(0, GL11.GL_RGBA, this.size.x(), this.size.y(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,
this.data.getRaw());
OpenGL.glTexImage2D(0, GL11.GL_RGBA, this.size.x(), this.size.y(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, this.data.getRaw());
}
// generate multi-texture mapping
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);

View File

@ -12,73 +12,57 @@ import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.RenderMode;
import org.atriasoft.gale.backend3d.OpenGL.Usage;
import org.atriasoft.gale.internal.Log;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import models.RawModel;
public class ResourceVirtualArrayObject extends Resource {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceVirtualArrayObject.class);
public static final int INDICE_VBO_POSITIONS = 0;
public static final int INDICE_VBO_TEXTURE_COORDINATES = 1;
public static final int INDICE_VBO_NORMALS = 2;
public static final int INDICE_VBO_COLORS = 3;
public static int[] convertIntegers(final List<Integer> integers) {
final int[] ret = new int[integers.size()];
final Iterator<Integer> iterator = integers.iterator();
int[] ret = new int[integers.size()];
Iterator<Integer> iterator = integers.iterator();
for (int i = 0; i < ret.length; i++) {
ret[i] = iterator.next().intValue();
}
return ret;
}
public static ResourceVirtualArrayObject create(
final float[] positions,
final float[] colors,
final float[] textureCoordinates,
final float[] normals,
final int[] indices) {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject(positions, colors,
textureCoordinates, normals, indices, indices.length);
Resource.getManager().localAdd(resource);
public static ResourceVirtualArrayObject create(final float[] positions, final float[] colors, final float[] textureCoordinates, final float[] normals, final int[] indices) {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject(positions, colors, textureCoordinates, normals, indices, indices.length);
getManager().localAdd(resource);
return resource;
}
public static ResourceVirtualArrayObject create(
final float[] positions,
final float[] textureCoordinates,
final float[] normals,
final int[] indices) {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject(positions, null, textureCoordinates,
normals, indices, indices.length);
Resource.getManager().localAdd(resource);
public static ResourceVirtualArrayObject create(final float[] positions, final float[] textureCoordinates, final float[] normals, final int[] indices) {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject(positions, null, textureCoordinates, normals, indices, indices.length);
getManager().localAdd(resource);
return resource;
}
public static ResourceVirtualArrayObject create(
final float[] positions,
final float[] colors,
final int[] indices) {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject(positions, colors, null, null,
indices, indices.length);
Resource.getManager().localAdd(resource);
public static ResourceVirtualArrayObject create(final float[] positions, final float[] colors, final int[] indices) {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject(positions, colors, null, null, indices, indices.length);
getManager().localAdd(resource);
return resource;
}
public static ResourceVirtualArrayObject create(final float[] positions, final int dimentions) {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject(positions, null, null, null, null,
positions.length / dimentions);
Resource.getManager().localAdd(resource);
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject(positions, null, null, null, null, positions.length / dimentions);
getManager().localAdd(resource);
return resource;
}
public static ResourceVirtualArrayObject createDynamic() {
final ResourceVirtualArrayObject resource = new ResourceVirtualArrayObject();
Resource.getManager().localAdd(resource);
getManager().localAdd(resource);
return resource;
}
@ -115,13 +99,14 @@ public class ResourceVirtualArrayObject extends Resource {
int vertexCount = -1;
protected ResourceVirtualArrayObject() {
super();
this.resourceLevel = 3;
this.dynamic = true;
LOGGER.debug("OGL: load VBO count (dynamic)");
Log.debug("OGL: load VBO count (dynamic)");
}
protected ResourceVirtualArrayObject(final float[] positions, final float[] colors,
final float[] textureCoordinates, final float[] normals, final int[] indices, final int vertexCount) {
protected ResourceVirtualArrayObject(final float[] positions, final float[] colors, final float[] textureCoordinates, final float[] normals, final int[] indices, final int vertexCount) {
super();
this.resourceLevel = 3;
this.positions = positions;
this.colors = colors;
@ -129,7 +114,7 @@ public class ResourceVirtualArrayObject extends Resource {
this.normals = normals;
this.indices = indices;
this.vertexCount = vertexCount;
LOGGER.debug("OGL: load VBO count");
Log.debug("OGL: load VBO count");
}
public void bindForRendering() {
@ -138,17 +123,17 @@ public class ResourceVirtualArrayObject extends Resource {
}
GL30.glBindVertexArray(this.vaoID);
if (this.positions != null) {
GL20.glEnableVertexAttribArray(ResourceVirtualArrayObject.INDICE_VBO_POSITIONS);
//LOGGER.info("unbind POSITION");
GL20.glEnableVertexAttribArray(INDICE_VBO_POSITIONS);
//Log.info("unbind POSITION");
}
if (this.textureCoordinates != null) {
GL20.glEnableVertexAttribArray(ResourceVirtualArrayObject.INDICE_VBO_TEXTURE_COORDINATES);
GL20.glEnableVertexAttribArray(INDICE_VBO_TEXTURE_COORDINATES);
}
if (this.normals != null) {
GL20.glEnableVertexAttribArray(ResourceVirtualArrayObject.INDICE_VBO_NORMALS);
GL20.glEnableVertexAttribArray(INDICE_VBO_NORMALS);
}
if (this.colors != null) {
GL20.glEnableVertexAttribArray(ResourceVirtualArrayObject.INDICE_VBO_COLORS);
GL20.glEnableVertexAttribArray(INDICE_VBO_COLORS);
}
}
@ -156,7 +141,7 @@ public class ResourceVirtualArrayObject extends Resource {
final int vboId = OpenGL.genBuffers();
this.vbo.add(vboId);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboId);
final IntBuffer buffer = ResourceVirtualArrayObject.storeDataInIntBuffer(indices);
final IntBuffer buffer = storeDataInIntBuffer(indices);
if (this.dynamic) {
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_DYNAMIC_DRAW);
} else {
@ -176,7 +161,7 @@ public class ResourceVirtualArrayObject extends Resource {
* clear buffers
*/
public void clear() {
//LOGGER.trace(" Clear: [" + getId() + "] '" + getName() + "' (size=" + buffer.get(0).length + ")");
//Log.verbose(" Clear: [" + getId() + "] '" + getName() + "' (size=" + buffer.get(0).length + ")");
this.positions = null;
this.colors = null;
this.textureCoordinates = null;
@ -186,7 +171,7 @@ public class ResourceVirtualArrayObject extends Resource {
}
private void createVAO() {
LOGGER.trace("create VAO...");
Log.verbose("create VAO...");
this.vaoID = GL30.glGenVertexArrays();
GL30.glBindVertexArray(this.vaoID);
}
@ -196,8 +181,8 @@ public class ResourceVirtualArrayObject extends Resource {
*/
public void flush() {
// request to the manager to be call at the next update ...
Resource.getManager().update(this);
LOGGER.trace("Request flush of VAO: [" + getId() + "] '" + getName() + "'");
getManager().update(this);
Log.verbose("Request flush of VBO: [" + getId() + "] '" + getName() + "'");
}
/**
@ -213,55 +198,51 @@ public class ResourceVirtualArrayObject extends Resource {
}
public void loadAgainToVAO() {
GL30.glBindVertexArray(this.vaoID);
LOGGER.trace("push VAO: [" + getId() + "] '" + getName() + "'");
createVAO();
if (this.indices != null) {
LOGGER.trace("Set indices");
Log.verbose("Set indices");
bindIndicesBuffer(this.indices);
}
if (this.positions != null) {
LOGGER.trace("Set positions");
storeDataInAttributeList(ResourceVirtualArrayObject.INDICE_VBO_POSITIONS, 3, this.positions);
Log.verbose("Set positions");
storeDataInAttributeList(0, 3, this.positions);
}
if (this.textureCoordinates != null) {
LOGGER.trace("Set textureCoordinates");
storeDataInAttributeList(ResourceVirtualArrayObject.INDICE_VBO_TEXTURE_COORDINATES, 2,
this.textureCoordinates);
Log.verbose("Set textureCoordinates");
storeDataInAttributeList(1, 2, this.textureCoordinates);
}
if (this.normals != null) {
LOGGER.trace("Set normals");
storeDataInAttributeList(ResourceVirtualArrayObject.INDICE_VBO_NORMALS, 3, this.normals);
Log.verbose("Set normals");
storeDataInAttributeList(2, 3, this.normals);
}
if (this.colors != null) {
LOGGER.trace("Set colors");
storeDataInAttributeList(ResourceVirtualArrayObject.INDICE_VBO_COLORS, 4, this.colors);
Log.verbose("Set colors");
storeDataInAttributeList(3, 4, this.colors);
}
unbindVAO();
}
public void loadToVAO() {
createVAO();
LOGGER.trace("push VAO: [" + getId() + "] '" + getName() + "'");
GL30.glBindVertexArray(this.vaoID);
if (this.indices != null) {
LOGGER.trace("Set indices");
Log.verbose("Set indices");
bindIndicesBuffer(this.indices);
}
if (this.positions != null) {
LOGGER.trace("Set positions");
storeDataInAttributeList(ResourceVirtualArrayObject.INDICE_VBO_POSITIONS, 3, this.positions);
Log.verbose("Set positions");
storeDataInAttributeList(0, 3, this.positions);
}
if (this.textureCoordinates != null) {
LOGGER.trace("Set textureCoordinates");
storeDataInAttributeList(ResourceVirtualArrayObject.INDICE_VBO_TEXTURE_COORDINATES, 2,
this.textureCoordinates);
Log.verbose("Set textureCoordinates");
storeDataInAttributeList(1, 2, this.textureCoordinates);
}
if (this.normals != null) {
LOGGER.trace("Set normals");
storeDataInAttributeList(ResourceVirtualArrayObject.INDICE_VBO_NORMALS, 3, this.normals);
Log.verbose("Set normals");
storeDataInAttributeList(2, 3, this.normals);
}
if (this.colors != null) {
LOGGER.trace("Set colors");
storeDataInAttributeList(ResourceVirtualArrayObject.INDICE_VBO_COLORS, 4, this.colors);
Log.verbose("Set colors");
storeDataInAttributeList(3, 4, this.colors);
}
unbindVAO();
}
@ -299,16 +280,12 @@ public class ResourceVirtualArrayObject extends Resource {
}
public void render(final RenderMode mode) {
LOGGER.trace("request rendering indices : " + this.vertexCount);
Log.verbose("request rendering indices : " + this.vertexCount);
OpenGL.drawElements(mode, this.vertexCount);
}
public void render(final RenderMode mode, final int start, final int stop) {
OpenGL.drawArrays(mode, start, stop);
}
public void renderArrays(final RenderMode mode) {
LOGGER.trace("request rendering direct : " + this.vertexCount);
Log.verbose("request rendering direct : " + this.vertexCount);
OpenGL.drawArrays(mode, 0, this.vertexCount);
}
@ -320,17 +297,12 @@ public class ResourceVirtualArrayObject extends Resource {
this.colors = colors;
}
public void setColors(final List<Color> colors) {
setColors(colors.toArray(Color[]::new));
}
public void setIndices(final int[] indices) {
this.indices = indices;
}
public void setIndices(final List<Integer> indices) {
this.indices = ResourceVirtualArrayObject.convertIntegers(indices);
this.indices = convertIntegers(indices);
this.vertexCount = this.indices.length;
}
@ -338,10 +310,6 @@ public class ResourceVirtualArrayObject extends Resource {
this.normals = normals;
}
public void setNormals(final List<Vector3f> normals) {
setNormals(normals.toArray(Vector3f[]::new));
}
public void setNormals(final Vector3f[] normals) {
this.normals = normals;
}
@ -350,11 +318,6 @@ public class ResourceVirtualArrayObject extends Resource {
this.positions = positions;
}
public void setPosition(final List<Vector3f> outPosition) {
setPosition(outPosition.toArray(Vector3f[]::new));
}
public void setPosition(final Vector3f[] positions) {
this.positions = positions;
}
@ -363,10 +326,6 @@ public class ResourceVirtualArrayObject extends Resource {
this.textureCoordinates = textureCoordinates;
}
public void setTextureCoordinate(final List<Vector2f> outTexturePosition) {
setTextureCoordinate(outTexturePosition.toArray(Vector2f[]::new));
}
public void setTextureCoordinate(final Vector2f[] textureCoordinates) {
this.textureCoordinates = textureCoordinates;
}
@ -384,18 +343,18 @@ public class ResourceVirtualArrayObject extends Resource {
usage = Usage.streamDraw;
}
// select the buffer to set data inside it ...
if (data instanceof final float[] buffer) {
if (data instanceof float[]buffer) {
OpenGL.bufferData(buffer, usage);
} else if (data instanceof final int[] buffer) {
} else if (data instanceof int[]buffer) {
OpenGL.bufferData(buffer, usage);
} else if (data instanceof final Vector2f[] buffer) {
} else if (data instanceof Vector2f[]buffer) {
OpenGL.bufferData(buffer, usage);
} else if (data instanceof final Vector3f[] buffer) {
} else if (data instanceof Vector3f[]buffer) {
OpenGL.bufferData(buffer, usage);
} else if (data instanceof final Color[] buffer) {
} else if (data instanceof Color[]buffer) {
OpenGL.bufferData(buffer, usage);
} else {
LOGGER.error("Not managed VBO model : " + data.getClass().getCanonicalName());
Log.error("Not managed VBO model : " + data.getClass().getCanonicalName());
}
GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
@ -406,22 +365,22 @@ public class ResourceVirtualArrayObject extends Resource {
return;
}
if (this.positions != null) {
GL20.glDisableVertexAttribArray(ResourceVirtualArrayObject.INDICE_VBO_POSITIONS);
GL20.glDisableVertexAttribArray(INDICE_VBO_POSITIONS);
}
if (this.textureCoordinates != null) {
GL20.glDisableVertexAttribArray(ResourceVirtualArrayObject.INDICE_VBO_TEXTURE_COORDINATES);
GL20.glDisableVertexAttribArray(INDICE_VBO_TEXTURE_COORDINATES);
}
if (this.normals != null) {
GL20.glDisableVertexAttribArray(ResourceVirtualArrayObject.INDICE_VBO_NORMALS);
GL20.glDisableVertexAttribArray(INDICE_VBO_NORMALS);
}
if (this.colors != null) {
GL20.glDisableVertexAttribArray(ResourceVirtualArrayObject.INDICE_VBO_COLORS);
GL20.glDisableVertexAttribArray(INDICE_VBO_COLORS);
}
GL30.glBindVertexArray(0);
}
private void unbindVAO() {
LOGGER.trace("Unbind VAO ...");
Log.verbose("Unbind VAO ...");
GL30.glBindVertexArray(0);
}
@ -430,22 +389,21 @@ public class ResourceVirtualArrayObject extends Resource {
*/
@Override
public boolean updateContext() {
LOGGER.trace(" Start: [" + getId() + "] '" + getName() + "' (size=" + this.vertexCount
+ ") ********************************");
Log.verbose(" Start: [" + getId() + "] '" + getName() + "' (size=" + this.vertexCount + ") ********************************");
if (!this.exist) {
LOGGER.trace(" ==> ALLOCATE new handle");
Log.error(" ==> ALLOCATE new handle");
// Allocate and assign a Vertex Array Object to our handle
loadToVAO();
} else {
// Update VAO (only for dynamic:
if (!this.dynamic) {
LOGGER.error(" Request update a VAO with a static buffer !!!" + this.name);
Log.error(" Request update a VAO with a static buffer !!!" + this.name);
}
loadAgainToVAO();
}
this.exist = true;
LOGGER.trace(" Stop: [" + getId() + "] '" + getName() + "'");
Log.verbose(" Stop: [" + getId() + "] '" + getName() + "'");
return true;
}

View File

@ -12,14 +12,12 @@ import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.Usage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.atriasoft.gale.internal.Log;
/**
* 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 {
static final Logger LOGGER = LoggerFactory.getLogger(ResourceVirtualBufferObject.class);
public static ResourceVirtualBufferObject create(final int count) {
return new ResourceVirtualBufferObject(count);
@ -34,9 +32,10 @@ public class ResourceVirtualBufferObject extends Resource {
* @param accesMode Access mode : ???
*/
protected ResourceVirtualBufferObject(final int number) {
super();
this.vbo = new int[number]; // 0
this.buffer = new Object[number];
LOGGER.debug("OGL : load VBO count=\"" + number + "\"");
Log.debug("OGL : load VBO count=\"" + number + "\"");
this.resourceLevel = 3;
}
@ -45,8 +44,7 @@ public class ResourceVirtualBufferObject extends Resource {
// select the buffer to set data inside it ...
if (this.buffer[vboidcoord] instanceof float[]) {
return ((float[]) (this.buffer[vboidcoord])).length;
}
if (this.buffer[vboidcoord] instanceof int[]) {
} else if (this.buffer[vboidcoord] instanceof int[]) {
return ((int[]) (this.buffer[vboidcoord])).length;
} else if (this.buffer[vboidcoord] instanceof Vector2f[]) {
return ((Vector2f[]) (this.buffer[vboidcoord])).length;
@ -55,7 +53,7 @@ public class ResourceVirtualBufferObject extends Resource {
} else if (this.buffer[vboidcoord] instanceof Color[]) {
return ((Color[]) (this.buffer[vboidcoord])).length;
} else {
LOGGER.error("Not managed VBO model : " + this.buffer[vboidcoord].getClass().getCanonicalName());
Log.error("Not managed VBO model : " + this.buffer[vboidcoord].getClass().getCanonicalName());
}
}
return 0;
@ -70,7 +68,7 @@ public class ResourceVirtualBufferObject extends Resource {
* clear buffers
*/
public void clear() {
LOGGER.trace(" Clear: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.length + ")");
Log.verbose(" Clear: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.length + ")");
// DO not clear the this.vbo indexed in the graphic cards ...
Arrays.fill(this.buffer, null);
}
@ -80,8 +78,8 @@ public class ResourceVirtualBufferObject extends Resource {
*/
public synchronized void flush() {
// request to the manager to be call at the next update ...
Resource.getManager().update(this);
LOGGER.trace("Request flush of VBO: [" + getId() + "] '" + getName() + "'");
getManager().update(this);
Log.verbose("Request flush of VBO: [" + getId() + "] '" + getName() + "'");
}
public int getElementSize(final int index) {
@ -89,8 +87,7 @@ public class ResourceVirtualBufferObject extends Resource {
// select the buffer to set data inside it ...
if (this.buffer[index] instanceof float[]) {
return 1;
}
if (this.buffer[index] instanceof int[]) {
} else if (this.buffer[index] instanceof int[]) {
return 1;
} else if (this.buffer[index] instanceof Vector2f[]) {
return 2;
@ -99,7 +96,7 @@ public class ResourceVirtualBufferObject extends Resource {
} else if (this.buffer[index] instanceof Color[]) {
return 4;
} else {
LOGGER.error("Not managed VBO model : " + this.buffer[index].getClass().getCanonicalName());
Log.error("Not managed VBO model : " + this.buffer[index].getClass().getCanonicalName());
}
}
return 1;
@ -147,7 +144,7 @@ public class ResourceVirtualBufferObject extends Resource {
* get the data from the graphic card.
*/
public void retreiveData() {
LOGGER.error("TODO ... ");
Log.error("TODO ... ");
}
public void setVboData(final int vboId, final Color[] data) {
@ -175,25 +172,23 @@ public class ResourceVirtualBufferObject extends Resource {
*/
@Override
public synchronized boolean updateContext() {
LOGGER.trace(
"updateContext (VBO Start: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.length + ")");
Log.warning("updateContext (VBO Start: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.length + ")");
/*
if (lock.tryLock() == false) {
//Lock error ==> try later ...
LOGGER.warn(" ==> Lock error on VBO");
Log.warning(" ==> Lock error on VBO");
return false;
}
*/
if (!this.exist) {
LOGGER.debug(" ==> ALLOCATE new handle");
Log.debug(" ==> ALLOCATE new handle");
// Allocate and assign a Vertex Array Object to our handle
OpenGL.genBuffers(this.vbo);
}
this.exist = true;
for (int iii = 0; iii < this.vbo.length; iii++) {
if (this.buffer[iii] != null) {
LOGGER.trace("VBO : add [" + getId() + "]=" + this.buffer[iii].getClass().getCanonicalName()
+ "*sizeof(float) OGl_Id=" + this.vbo[iii]);
Log.verbose("VBO : add [" + getId() + "]=" + this.buffer[iii].getClass().getCanonicalName() + "*sizeof(float) OGl_Id=" + this.vbo[iii]);
OpenGL.bindBuffer(this.vbo[iii]);
// select the buffer to set data inside it ...
if (this.buffer[iii] instanceof float[]) {
@ -207,13 +202,13 @@ public class ResourceVirtualBufferObject extends Resource {
} else if (this.buffer[iii] instanceof Color[]) {
OpenGL.bufferData((Color[]) (this.buffer[iii]), Usage.streamDraw);
} else {
LOGGER.error("Not managed VBO model : " + this.buffer[iii].getClass().getCanonicalName());
Log.error("Not managed VBO model : " + this.buffer[iii].getClass().getCanonicalName());
}
}
}
// un-bind it to permet to have no error in the next display ...
OpenGL.unbindBuffer();
LOGGER.trace(" Stop: [" + getId() + "] '" + getName() + "'");
Log.verbose(" Stop: [" + getId() + "] '" + getName() + "'");
return true;
}
}

View File

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

View File

@ -14,11 +14,8 @@ import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Sample1Application extends GaleApplication {
static final Logger LOGGER = LoggerFactory.getLogger(Sample1Application.class);
//float[] vertices = { 0.2f, 0.1f, 0.0f, 0.3f, 0.4f, 0.0f, 0.1f, 0.4f, 0.0f };
private static final float[] VERTICES = { -0.5f, -0.5f, -1.0f, 0.0f, 0.5f, -1.0f, 0.5f, -0.5f, -1.0f };
private static final float[] COLORS = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, };
@ -55,41 +52,41 @@ public class Sample1Application extends GaleApplication {
this.verticesVBO.setName("[VBO] of basic SAMPLE");
// update all the VBO elements ...
this.verticesVBO.flush();
LOGGER.info("==> Init APPL (END)");
Log.info("==> Init APPL (END)");
}
@Override
public void onDraw(final GaleContext context) {
this.angle += 0.01;
//LOGGER.info("==> appl Draw ...");
final Vector2f size = getSize();
//Log.info("==> appl Draw ...");
Vector2f size = getSize();
// set the basic openGL view port: (position drawed in the windows)
OpenGL.setViewPort(Vector2f.ZERO, size);
// Clear all the stacked matrix ...
OpenGL.setBasicMatrix(Matrix4f.IDENTITY);
// clear background
final Color bgColor = Color.CYAN;
Color bgColor = Color.CYAN;
OpenGL.clearColor(bgColor);
// real clear request:
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
// create a local matrix environment.
OpenGL.push();
final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-getAspectRatio(), getAspectRatio(), -1, 1, -50, 50);
Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-getAspectRatio(), getAspectRatio(), -1, 1, -50, 50);
//Matrix4f tmpProjection = Matrix4f.IDENTITY;
// set internal matrix system:
OpenGL.setMatrix(tmpProjection);
if (this.oGLprogram == null) {
LOGGER.info("No shader ...");
Log.info("No shader ...");
return;
}
//EWOL_DEBUG(" display " + this.coord.size() + " elements" );
this.oGLprogram.use();
// set Matrix: translation/positionMatrix
final Matrix4f projectionMatrix = tmpProjection; //OpenGL.getMatrix();
final Matrix4f transforamtionMatrix = Matrix4f.createMatrixRotate(new Vector3f(0, 0, 1), this.angle);
final Matrix4f viewMatrix = OpenGL.getCameraMatrix();
Matrix4f projectionMatrix = tmpProjection; //OpenGL.getMatrix();
Matrix4f transforamtionMatrix = Matrix4f.createMatrixRotate(new Vector3f(0, 0, 1), this.angle);
Matrix4f viewMatrix = OpenGL.getCameraMatrix();
//Matrix4f tmpMatrix = projMatrix * camMatrix;
this.verticesVBO.bindForRendering();
@ -100,9 +97,9 @@ public class Sample1Application extends GaleApplication {
// Request the draw of the elements:
if (TEST_STATIC_MODE) {
this.verticesVBO.render(OpenGL.RenderMode.TRIANGLE);
this.verticesVBO.render(OpenGL.RenderMode.triangle);
} else {
this.verticesVBO.renderArrays(OpenGL.RenderMode.TRIANGLE);
this.verticesVBO.renderArrays(OpenGL.RenderMode.triangle);
}
this.verticesVBO.unBindForRendering();
this.oGLprogram.unUse();
@ -121,27 +118,18 @@ public class Sample1Application extends GaleApplication {
}
@Override
public void onKeyboard(
final KeySpecial special,
final KeyKeyboard type,
final Character value,
final KeyStatus state) {
LOGGER.info("Keyboard event: special=" + special);
LOGGER.info(" type=" + type);
LOGGER.info(" value='" + value + "'");
LOGGER.info(" state=" + state);
public void onKeyboard(final KeySpecial special, final KeyKeyboard type, final Character value, final KeyStatus state) {
Log.info("Keyboard event: special=" + special);
Log.info(" type=" + type);
Log.info(" value='" + value + "'");
Log.info(" state=" + state);
}
@Override
public void onPointer(
final KeySpecial special,
final KeyType type,
final int pointerID,
final Vector2f pos,
final KeyStatus state) {
// LOGGER.info("input event: type=" + type);
// LOGGER.info(" id=" + pointerID);
// LOGGER.info(" pos=" + pos);
// LOGGER.info(" state=" + state);
public void onPointer(final KeySpecial special, final KeyType type, final int pointerID, final Vector2f pos, final KeyStatus state) {
// Log.info("input event: type=" + type);
// Log.info(" id=" + pointerID);
// Log.info(" pos=" + pos);
// Log.info(" state=" + state);
}
}

View File

@ -15,11 +15,8 @@ import org.atriasoft.gale.key.KeyType;
import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceTexture;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Sample2Application extends GaleApplication {
static final Logger LOGGER = LoggerFactory.getLogger(Sample2Application.class);
private ResourceProgram oGLprogram;
private int oGLMatrixTransformation;
private int oGLMatrixProjection;
@ -40,7 +37,7 @@ public class Sample2Application extends GaleApplication {
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
}
//@formatter:off
final float[] vertices = {
float[] vertices = {
-0.5f,0.5f,-0.5f,
-0.5f,-0.5f,-0.5f,
0.5f,-0.5f,-0.5f,
@ -73,7 +70,7 @@ public class Sample2Application extends GaleApplication {
};
final float[] textureCoords = {
float[] textureCoords = {
0,0, 0,1, 1,1, 1,0,
0,0, 0,1, 1,1, 1,0,
0,0, 0,1, 1,1, 1,0,
@ -82,7 +79,7 @@ public class Sample2Application extends GaleApplication {
0,0, 0,1, 1,1, 1,0
};
final int[] indices = {
int[] indices = {
1,0,3, 1,3,2,
4,5,7, 7,5,6,
9,8,11, 9,11,10,
@ -102,10 +99,10 @@ public class Sample2Application extends GaleApplication {
this.texture = ResourceTexture.createFromPng(new Uri("DATA", "tree_sample.png"));
if (this.texture == null) {
LOGGER.error("can not instanciate Texture ...");
Log.error("can not instanciate Texture ...");
return;
}
LOGGER.info("==> Init APPL (END)");
Log.info("==> Init APPL (END)");
}
@Override
@ -113,15 +110,15 @@ public class Sample2Application extends GaleApplication {
this.angleX += 0.001;
this.angleY += 0.005;
this.angleZ += 0.01;
//LOGGER.info("==> appl Draw ...");
final Vector2f size = getSize();
//LOGGER.info("==> Windows size = " + size);
//Log.info("==> appl Draw ...");
Vector2f size = getSize();
//Log.info("==> Windows size = " + size);
// 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);
// clear background
final Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f);
Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f);
OpenGL.enable(OpenGL.Flag.flag_depthTest);
OpenGL.clearColor(bgColor);
// real clear request:
@ -131,28 +128,24 @@ public class Sample2Application extends GaleApplication {
OpenGL.push();
//Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-getAspectRatio(), getAspectRatio(), -1, 1, -50, 50);
final Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(1.30f, getAspectRatio(), 1, 50);
Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(1.30f, getAspectRatio(), 1, 50);
// set internal matrix system:
OpenGL.setMatrix(tmpProjection);
if (this.oGLprogram == null) {
LOGGER.info("No shader ...");
Log.info("No shader ...");
return;
}
//EWOL_DEBUG(" display " + this.coord.size() + " elements" );
this.oGLprogram.use();
// set Matrix : translation/positionMatrix
final Matrix4f projectionMatrix = tmpProjection; //OpenGL.getMatrix();
Matrix4f projectionMatrix = tmpProjection; //OpenGL.getMatrix();
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));
final Matrix4f viewMatrix = OpenGL.getCameraMatrix()
.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0, 0, -2)));
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);
@ -163,7 +156,7 @@ public class Sample2Application extends GaleApplication {
// update of flags is done asyncronously ==> need update befor drawing...
OpenGL.updateAllFlags();
// Request the draw od the elements:
this.verticesVBO.render(OpenGL.RenderMode.TRIANGLE);
this.verticesVBO.render(OpenGL.RenderMode.triangle);
this.verticesVBO.unBindForRendering();
this.texture.unBindForRendering();
@ -174,27 +167,18 @@ public class Sample2Application extends GaleApplication {
}
@Override
public void onKeyboard(
final KeySpecial special,
final KeyKeyboard type,
final Character value,
final KeyStatus state) {
LOGGER.info("Keyboard event: special=" + special);
LOGGER.info(" type=" + type);
LOGGER.info(" value='" + value + "'");
LOGGER.info(" state=" + state);
public void onKeyboard(final KeySpecial special, final KeyKeyboard type, final Character value, final KeyStatus state) {
Log.info("Keyboard event: special=" + special);
Log.info(" type=" + type);
Log.info(" value='" + value + "'");
Log.info(" state=" + state);
}
@Override
public void onPointer(
final KeySpecial special,
final KeyType type,
final int pointerID,
final Vector2f pos,
final KeyStatus state) {
// LOGGER.info("input event: type=" + type);
// LOGGER.info(" id=" + pointerID);
// LOGGER.info(" pos=" + pos);
// LOGGER.info(" state=" + state);
public void onPointer(final KeySpecial special, final KeyType type, final int pointerID, final Vector2f pos, final KeyStatus state) {
// Log.info("input event: type=" + type);
// Log.info(" id=" + pointerID);
// Log.info(" pos=" + pos);
// Log.info(" state=" + state);
}
}

View File

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

View File

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

2
test/.gitignore vendored
View File

@ -1,3 +1 @@
/__pycache__/
/bin/

View File

@ -0,0 +1,59 @@
package test.atriasoft.gale;
import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
public class Log {
private static final String LIB_NAME = "gale-test";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
private Log() {}
public static void print(String data) {
if (PRINT_PRINT)
Logger.print(LIB_NAME_DRAW, data);
}
public static void critical(String data) {
if (PRINT_CRITICAL)
Logger.critical(LIB_NAME_DRAW, data);
}
public static void error(String data) {
if (PRINT_ERROR)
Logger.error(LIB_NAME_DRAW, data);
}
public static void warning(String data) {
if (PRINT_WARNING)
Logger.warning(LIB_NAME_DRAW, data);
}
public static void info(String data) {
if (PRINT_INFO)
Logger.info(LIB_NAME_DRAW, data);
}
public static void debug(String data) {
if (PRINT_DEBUG)
Logger.debug(LIB_NAME_DRAW, data);
}
public static void verbose(String data) {
if (PRINT_VERBOSE)
Logger.verbose(LIB_NAME_DRAW, data);
}
public static void todo(String data) {
if (PRINT_TODO)
Logger.todo(LIB_NAME_DRAW, data);
}
}

View File

@ -0,0 +1,18 @@
package test.atriasoft.gale;
import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
public class Log2 {
private static final String LIB_NAME = "gale-test-2";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
private Log2() {}
public static void debug(String data) {
if (PRINT_DEBUG)
Logger.debug(LIB_NAME_DRAW, data);
}
}

View File

@ -11,18 +11,20 @@ package test.atriasoft.gale;
import java.util.ArrayList;
import java.util.List;
import io.scenarium.logger.Logger;
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)
public class TestBasicLog {
// JUST keep a kanva ...
@Test
@Order(1)
public void aaFirstInitialisation() {
final List<String> args = new ArrayList<>();
List<String> args = new ArrayList<>();
args.add("--log-level=999");
args.add("--log-level=1");
args.add("--log-no-color");
@ -35,6 +37,66 @@ public class TestBasicLog {
args.add("--log-lib=sc-log-test");
args.add("--log-with-stupid-parameter=sdkfjsqdlkf");
args.add("--help");
Logger.init(args);
}
@Test
@Order(2)
public void bbSecondInitialisation() {
List<String> args = new ArrayList<>();
Logger.init(args);
}
@Test
@Order(3)
public void ccBasicLogCall() {
Log.print("Simple print");
Log.todo("Simple todo");
Log.error("Simple error");
Log.warning("Simple warning");
Log.info("Simple info");
Log.debug("Simple debug");
Log.verbose("Simple verbose");
}
// TODO REFACTO REMOVE this and set it in the Test of the logger.
public static String getAAAAAAA(int dfsdf) {
int hhh = 0;
for (int kkk = 0; kkk < dfsdf; kkk++)
for (int iii = 0; iii < 10000; iii++)
for (int jjj = 0; jjj < 100000; jjj++)
for (int lll = 0; lll < 100000; lll++)
hhh++;
return "kkk" + hhh;
}
public static void testLog() {
Log.print("test direct [START]");
// test de 10 secondes contre 0.0?? second quand le niveau n'est pas assez grand ...
long timeStart = System.currentTimeMillis();
for (int iii = 0; iii < 100000000; iii++)
Log2.debug("test direct");
long timeStop = System.currentTimeMillis();
Log.print("test direct [END] : " + timeStart + " to " + timeStop + " ==> delta=" + (timeStop - timeStart));
Log.print("test concat [START]");
// C'est très long dans les 2 cas ...
timeStart = System.currentTimeMillis();
for (int iii = 0; iii < 6; iii++)
Log2.debug("test concat: non fonctionnel, il applelle le get a chaque log ... " + getAAAAAAA(iii));
timeStop = System.currentTimeMillis();
Log.print("test concat [END] : " + timeStart + " to " + timeStop + " ==> delta=" + (timeStop - timeStart));
}
@Test
@Order(4)
public void ddTestSimpleLog() {
testLog();
}
@Test
@Order(4)
public void eeUsage() {
Logger.usage();
}
}