diff --git a/.checkstyle b/.checkstyle new file mode 100644 index 0000000..34ed486 --- /dev/null +++ b/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..096b7ab --- /dev/null +++ b/.classpath @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d075be7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +/bin/ +/Operator/ +/DrawerProperties/ +*.pdfd +*.dbc +SchedulerConfig.txt +scenicView.properties +ScenariumConfig.txt +*.class +*~ +*.bck +build.number +/extern/ +/out/ +/.settings/ +/junit/ +/target/ diff --git a/.project b/.project new file mode 100644 index 0000000..d129442 --- /dev/null +++ b/.project @@ -0,0 +1,24 @@ + + + atriasoft-gale + + + atriasoft-gale + + + + org.eclipse.jdt.core.javabuilder + + + + + net.sf.eclipsecs.core.CheckstyleBuilder + + + + + + org.eclipse.jdt.core.javanature + net.sf.eclipsecs.core.CheckstyleNature + + diff --git a/CheckStyle.xml b/CheckStyle.xml new file mode 100755 index 0000000..d68aedd --- /dev/null +++ b/CheckStyle.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CleanUp.xml b/CleanUp.xml new file mode 100644 index 0000000..9df98d2 --- /dev/null +++ b/CleanUp.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Formatter.xml b/Formatter.xml new file mode 100644 index 0000000..79dcbb8 --- /dev/null +++ b/Formatter.xml @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a612ad9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/lib/jogamp-fat.jar b/lib/jogamp-fat.jar new file mode 100644 index 0000000..2426cf1 Binary files /dev/null and b/lib/jogamp-fat.jar differ diff --git a/lib/lwjgl/LICENSE b/lib/lwjgl/LICENSE new file mode 100644 index 0000000..a17ad0a --- /dev/null +++ b/lib/lwjgl/LICENSE @@ -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. \ No newline at end of file diff --git a/lib/lwjgl/assimp_license.txt b/lib/lwjgl/assimp_license.txt new file mode 100644 index 0000000..262606a --- /dev/null +++ b/lib/lwjgl/assimp_license.txt @@ -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 +.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. diff --git a/lib/lwjgl/build.txt b/lib/lwjgl/build.txt new file mode 100644 index 0000000..feb8a24 --- /dev/null +++ b/lib/lwjgl/build.txt @@ -0,0 +1 @@ +LWJGL 3.2.3 SNAPSHOT build 13 \ No newline at end of file diff --git a/lib/lwjgl/dyncall_license.txt b/lib/lwjgl/dyncall_license.txt new file mode 100644 index 0000000..6984164 --- /dev/null +++ b/lib/lwjgl/dyncall_license.txt @@ -0,0 +1,14 @@ +Copyright (c) 2007-2015 Daniel Adler , + Tassilo Philipp + +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. \ No newline at end of file diff --git a/lib/lwjgl/glfw_license.txt b/lib/lwjgl/glfw_license.txt new file mode 100644 index 0000000..8a60e1d --- /dev/null +++ b/lib/lwjgl/glfw_license.txt @@ -0,0 +1,21 @@ +Copyright (c) 2002-2006 Marcus Geelnard +Copyright (c) 2006-2010 Camilla Berglund + +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. diff --git a/lib/lwjgl/khronos_license.txt b/lib/lwjgl/khronos_license.txt new file mode 100644 index 0000000..d7e6e9d --- /dev/null +++ b/lib/lwjgl/khronos_license.txt @@ -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. +*/ \ No newline at end of file diff --git a/lib/lwjgl/lwjgl-assimp-natives-linux.jar b/lib/lwjgl/lwjgl-assimp-natives-linux.jar new file mode 100644 index 0000000..2c4ef0a Binary files /dev/null and b/lib/lwjgl/lwjgl-assimp-natives-linux.jar differ diff --git a/lib/lwjgl/lwjgl-assimp-sources.jar b/lib/lwjgl/lwjgl-assimp-sources.jar new file mode 100644 index 0000000..403ff77 Binary files /dev/null and b/lib/lwjgl/lwjgl-assimp-sources.jar differ diff --git a/lib/lwjgl/lwjgl-assimp.jar b/lib/lwjgl/lwjgl-assimp.jar new file mode 100644 index 0000000..eddf6e3 Binary files /dev/null and b/lib/lwjgl/lwjgl-assimp.jar differ diff --git a/lib/lwjgl/lwjgl-egl-sources.jar b/lib/lwjgl/lwjgl-egl-sources.jar new file mode 100644 index 0000000..ecdabbe Binary files /dev/null and b/lib/lwjgl/lwjgl-egl-sources.jar differ diff --git a/lib/lwjgl/lwjgl-egl.jar b/lib/lwjgl/lwjgl-egl.jar new file mode 100644 index 0000000..65a59fe Binary files /dev/null and b/lib/lwjgl/lwjgl-egl.jar differ diff --git a/lib/lwjgl/lwjgl-glfw-natives-linux.jar b/lib/lwjgl/lwjgl-glfw-natives-linux.jar new file mode 100644 index 0000000..e3b7ae7 Binary files /dev/null and b/lib/lwjgl/lwjgl-glfw-natives-linux.jar differ diff --git a/lib/lwjgl/lwjgl-glfw-sources.jar b/lib/lwjgl/lwjgl-glfw-sources.jar new file mode 100644 index 0000000..f6cd77a Binary files /dev/null and b/lib/lwjgl/lwjgl-glfw-sources.jar differ diff --git a/lib/lwjgl/lwjgl-glfw.jar b/lib/lwjgl/lwjgl-glfw.jar new file mode 100644 index 0000000..b8bb451 Binary files /dev/null and b/lib/lwjgl/lwjgl-glfw.jar differ diff --git a/lib/lwjgl/lwjgl-jawt-sources.jar b/lib/lwjgl/lwjgl-jawt-sources.jar new file mode 100644 index 0000000..c1ac84e Binary files /dev/null and b/lib/lwjgl/lwjgl-jawt-sources.jar differ diff --git a/lib/lwjgl/lwjgl-jawt.jar b/lib/lwjgl/lwjgl-jawt.jar new file mode 100644 index 0000000..42deb21 Binary files /dev/null and b/lib/lwjgl/lwjgl-jawt.jar differ diff --git a/lib/lwjgl/lwjgl-natives-linux.jar b/lib/lwjgl/lwjgl-natives-linux.jar new file mode 100644 index 0000000..7b10e46 Binary files /dev/null and b/lib/lwjgl/lwjgl-natives-linux.jar differ diff --git a/lib/lwjgl/lwjgl-openal-natives-linux.jar b/lib/lwjgl/lwjgl-openal-natives-linux.jar new file mode 100644 index 0000000..1211dae Binary files /dev/null and b/lib/lwjgl/lwjgl-openal-natives-linux.jar differ diff --git a/lib/lwjgl/lwjgl-openal-sources.jar b/lib/lwjgl/lwjgl-openal-sources.jar new file mode 100644 index 0000000..ee98039 Binary files /dev/null and b/lib/lwjgl/lwjgl-openal-sources.jar differ diff --git a/lib/lwjgl/lwjgl-openal.jar b/lib/lwjgl/lwjgl-openal.jar new file mode 100644 index 0000000..482d924 Binary files /dev/null and b/lib/lwjgl/lwjgl-openal.jar differ diff --git a/lib/lwjgl/lwjgl-opengl-natives-linux.jar b/lib/lwjgl/lwjgl-opengl-natives-linux.jar new file mode 100644 index 0000000..f48041b Binary files /dev/null and b/lib/lwjgl/lwjgl-opengl-natives-linux.jar differ diff --git a/lib/lwjgl/lwjgl-opengl-sources.jar b/lib/lwjgl/lwjgl-opengl-sources.jar new file mode 100644 index 0000000..836432e Binary files /dev/null and b/lib/lwjgl/lwjgl-opengl-sources.jar differ diff --git a/lib/lwjgl/lwjgl-opengl.jar b/lib/lwjgl/lwjgl-opengl.jar new file mode 100644 index 0000000..3a3da08 Binary files /dev/null and b/lib/lwjgl/lwjgl-opengl.jar differ diff --git a/lib/lwjgl/lwjgl-opengles-natives-linux.jar b/lib/lwjgl/lwjgl-opengles-natives-linux.jar new file mode 100644 index 0000000..47f1b9c Binary files /dev/null and b/lib/lwjgl/lwjgl-opengles-natives-linux.jar differ diff --git a/lib/lwjgl/lwjgl-opengles-sources.jar b/lib/lwjgl/lwjgl-opengles-sources.jar new file mode 100644 index 0000000..be254b7 Binary files /dev/null and b/lib/lwjgl/lwjgl-opengles-sources.jar differ diff --git a/lib/lwjgl/lwjgl-opengles.jar b/lib/lwjgl/lwjgl-opengles.jar new file mode 100644 index 0000000..e1b4ea2 Binary files /dev/null and b/lib/lwjgl/lwjgl-opengles.jar differ diff --git a/lib/lwjgl/lwjgl-sources.jar b/lib/lwjgl/lwjgl-sources.jar new file mode 100644 index 0000000..aa60368 Binary files /dev/null and b/lib/lwjgl/lwjgl-sources.jar differ diff --git a/lib/lwjgl/lwjgl-stable-custom-zip.json b/lib/lwjgl/lwjgl-stable-custom-zip.json new file mode 100644 index 0000000..89fd16e --- /dev/null +++ b/lib/lwjgl/lwjgl-stable-custom-zip.json @@ -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" + ] +} \ No newline at end of file diff --git a/lib/lwjgl/lwjgl-stb-natives-linux.jar b/lib/lwjgl/lwjgl-stb-natives-linux.jar new file mode 100644 index 0000000..b37e98e Binary files /dev/null and b/lib/lwjgl/lwjgl-stb-natives-linux.jar differ diff --git a/lib/lwjgl/lwjgl-stb-sources.jar b/lib/lwjgl/lwjgl-stb-sources.jar new file mode 100644 index 0000000..4de978a Binary files /dev/null and b/lib/lwjgl/lwjgl-stb-sources.jar differ diff --git a/lib/lwjgl/lwjgl-stb.jar b/lib/lwjgl/lwjgl-stb.jar new file mode 100644 index 0000000..c80908b Binary files /dev/null and b/lib/lwjgl/lwjgl-stb.jar differ diff --git a/lib/lwjgl/lwjgl.jar b/lib/lwjgl/lwjgl.jar new file mode 100644 index 0000000..b147f38 Binary files /dev/null and b/lib/lwjgl/lwjgl.jar differ diff --git a/lib/lwjgl/openal_soft_license.txt b/lib/lwjgl/openal_soft_license.txt new file mode 100644 index 0000000..5bc8fb2 --- /dev/null +++ b/lib/lwjgl/openal_soft_license.txt @@ -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. + + + Copyright (C) + + 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. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/lib/lwjgl3-awt-0.1.7-javadoc.jar b/lib/lwjgl3-awt-0.1.7-javadoc.jar new file mode 100644 index 0000000..0d35f41 Binary files /dev/null and b/lib/lwjgl3-awt-0.1.7-javadoc.jar differ diff --git a/lib/lwjgl3-awt-0.1.7-sources.jar b/lib/lwjgl3-awt-0.1.7-sources.jar new file mode 100644 index 0000000..16098aa Binary files /dev/null and b/lib/lwjgl3-awt-0.1.7-sources.jar differ diff --git a/lib/lwjgl3-awt-0.1.7.jar b/lib/lwjgl3-awt-0.1.7.jar new file mode 100644 index 0000000..a22019d Binary files /dev/null and b/lib/lwjgl3-awt-0.1.7.jar differ diff --git a/lib/pngdecoder.jar b/lib/pngdecoder.jar new file mode 100644 index 0000000..fc39e9b Binary files /dev/null and b/lib/pngdecoder.jar differ diff --git a/src/module-info.java b/src/module-info.java new file mode 100644 index 0000000..97e4096 --- /dev/null +++ b/src/module-info.java @@ -0,0 +1,38 @@ +/** 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.event; + exports org.atriasoft.gale.key; + exports org.atriasoft.gale.resource; + requires transitive org.atriasoft.etk; + + //requires transitive vecmath; + requires transitive org.lwjgl; + requires transitive org.lwjgl.natives; + requires transitive org.lwjgl.glfw; + requires transitive org.lwjgl.glfw.natives; + requires transitive org.lwjgl.assimp; + requires transitive org.lwjgl.assimp.natives; +// requires transitive org.lwjgl.openal; +// requires transitive org.lwjgl.openal.natives; + requires transitive org.lwjgl.stb; + requires transitive org.lwjgl.stb.natives; + requires transitive org.lwjgl.jawt; + //requires transitive org.lwjgl.opengl.awt; + requires transitive org.lwjgl.opengl; + requires transitive org.lwjgl.opengl.natives; + //requires org.lwjgl.openvr; + + //requires transitive jogamp.fat; + + requires transitive java.desktop; + requires transitive pngdecoder; + requires transitive lwjgl3.awt; +} diff --git a/src/org/atriasoft/gale/Application.java b/src/org/atriasoft/gale/Application.java new file mode 100644 index 0000000..4b18165 --- /dev/null +++ b/src/org/atriasoft/gale/Application.java @@ -0,0 +1,292 @@ +package org.atriasoft.gale; + +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.gale.context.ClipboardList; +import org.atriasoft.gale.context.Context; +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; + +public class Application { + public boolean canDraw = false; + private boolean needRedraw = true; + private String title = "gale"; + private Uri iconName = new Uri(""); + private Cursor cursor = Cursor.arrow; + private Orientation orientation = Orientation.screenAuto; + Vector2f windowsSize = new Vector2f(800,600); + + public Application() { + Log.verbose("Constructor Gale Application"); + } + /** + * @brief The application is created. + * @param context Current gale context. + */ + public void onCreate(Context context) { + Log.verbose("Create Gale Application"); + } + /** + * @brief The application is started. + * @param context Current gale context. + */ + public void onStart(Context context){ + Log.verbose("Start Gale Application"); + } + /** + * @brief The application is resumed (now visible). + * @param context Current gale context. + */ + public void onResume(Context context){ + Log.verbose("Start Gale Application"); + } + /** + * @brief call application to precalculate drawing. + * @param context Current gale context. + */ + public void onRegenerateDisplay(Context context) { + //Log.verbose("Regenerate Gale Application"); + markDrawingIsNeeded(); + } + + /** + * @brief Real draw of the application + * @param context Current gale context. + */ + public void onDraw(Context context) { + Log.verbose("draw Gale Application"); + } + /** + * @brief The application is Hide / not visible. + * @param context Current gale context. + */ + public void onPause(Context context) { + Log.verbose("Pause Gale Application"); + } + /** + * @brief The application is stopped. + * @param context Current gale context. + */ + public void onStop(Context context) { + Log.verbose("Stop Gale Application"); + } + /** + * @brief The application is removed (call destructor just adter it.). + * @param context Current gale context. + */ + public void onDestroy(Context context) { + Log.verbose("Destroy Gale Application"); + } + /** + * @brief The user request application removing. + * @param context Current gale context. + */ + public void onKillDemand(Context context) { + Log.info("Gale request auto destroy ==> no applification specification"); + System.exit(0); + } + /** + * @brief Exit the application (not availlable on IOs, ==> the user will not understand the comportement. He will think the application has crashed (Apple philosophie)) + * @param value value to return on the program + */ + public void exit(int value) { + Log.verbose("Exit Requested " + value); + Gale.getContext().stop(); + } + + + public void markDrawingIsNeeded() { + this.needRedraw = true; + } + public boolean isDrawingNeeded() { + boolean tmp = this.needRedraw; + this.needRedraw = false; + return tmp; + } + /** + * @brief Get touch/mouse/... event. + * @param type Type of pointer event + * @param pointerID Pointer id of the touch event. + * @param pos Position of the event (can be <0 if out of window). + * @param state Key state (up/down/move) + */ + public void onPointer(KeySpecial special, + KeyType type, + int pointerID, + Vector2f pos, + KeyStatus state) { + + } + /** + * @brief Get keyborad value input. + * @param special Current special key status (ctrl/alt/shift ...). + * @param type Type of the event. + * @param value Unicode value of the char pushed (viable only if type==gale::key::keyboard::character). + * @param state State of the key (up/down/upRepeate/downRepeate) + */ + public void onKeyboard(KeySpecial special, + KeyKeyboard type, + Character value, + KeyStatus state) { + + } + /** + * @brief Show the virtal keyboard (if possible : only on iOs/Android) + */ + public void keyboardShow() { + Context context = Gale.getContext(); + if (context == null) { + return; + } + context.keyboardShow(); + } + /** + * @brief Hide the virtal keyboard (if possible : only on iOs/Android) + */ + public void keyboardHide() { + Context context = Gale.getContext(); + if (context == null) { + return; + } + context.keyboardHide(); + } + /** + * @brief Event generated when user change the size of the window. + * @param size New size of the window. + */ + public void onResize(Vector2f size) { + if (size == null) { + Log.error("Try to set a null size ..."); + return; + } + windowsSize = size; + } + /** + * @brief Set the size of the window (if possible: Android and Ios does not support it) + * @param size New size of the window. + * @return + */ + public void setSize(Vector2f size) { + windowsSize = size; + Context context = Gale.getContext(); + if (context == null) { + return; + } + context.setSize(size); + } + /** + * @brief Get the size of the window. + * @return Current size of the window. + */ + public Vector2f getSize() { + return windowsSize; + } + public float getAspectRatio() { + return windowsSize.x/windowsSize.y; + } + + /** + * @brief Event generated when user change the position of the window. + * @param size New position of the window. + */ + public void onMovePosition(Vector2f size) { + + } + /** + * @brief Set the position of the window (if possible: Android and Ios does not support it) + * @param size New position of the window. + */ + public void setPosition(Vector2f size) { + + } + /** + * @brief Get the position of the window. + * @return Current position of the window. + */ + public Vector2f getPosition() { + return new Vector2f(0,0); + } + + /** + * @brief Set the title of the application + * @param title New title to set at the application (if possible: Android and Ios does not support it) + */ + public void setTitle(String title) { + this.title = title; + Context context = Gale.getContext(); + if (context == null) { + return; + } + context.setTitle(this.title); + } + /** + * @brief Get the current title of the application + * @return Current title + */ + public String getTitle() { + return this.title; + } + /** + * @brief set the Icon of the application. + * @param iconFile File name icon (.bmp/.png). + */ + public void setIcon(Uri iconFile) { + this.iconName = iconFile; + Gale.getContext().setIcon(this.iconName); + } + /** + * @brief Get the current filename of the application. + * @return Filename of the icon. + */ + public Uri getIcon() { + return this.iconName; + } + + /** + * @brief Set the cursor type. + * @param newCursor Selected cursor. + */ + public void setCursor(Cursor newCursor) { + Gale.getContext().setCursor(this.cursor); + } + /** + * @brief Get the cursor type. + * @return the current cursor. + */ + public Cursor getCursor() { + return this.cursor; + } + /** + * @brief set the screen orientation (if possible : only on iOs/Android) + * @param orientation New orientation. + */ + public void setOrientation(Orientation orientation) { + this.orientation = orientation; + Gale.getContext().forceOrientation(this.orientation); + } + /** + * @brief get the screen orientation (if possible : only on iOs/Android) + * @return Current orientation. + */ + public Orientation getOrientation() { + return this.orientation; + } + + /** + * @brief A clipboard data is back (apear after a request of a new clipboard). + * @param clipboardId Id of the clipboard. + */ + public void onClipboardEvent(ClipboardList clipboardId) { + + } + + /** + * @brief Call every time a draw is called (not entirely periodic, but faster at we can ... + * @param time Current time of the call; + */ + public void onPeriod(long time) {}; +} diff --git a/src/org/atriasoft/gale/DisplayManagerDraw.java b/src/org/atriasoft/gale/DisplayManagerDraw.java new file mode 100644 index 0000000..967434b --- /dev/null +++ b/src/org/atriasoft/gale/DisplayManagerDraw.java @@ -0,0 +1,5 @@ +package org.atriasoft.gale; + +public class DisplayManagerDraw { + public void draw() {} +} diff --git a/src/org/atriasoft/gale/Fps.java b/src/org/atriasoft/gale/Fps.java new file mode 100644 index 0000000..238f10e --- /dev/null +++ b/src/org/atriasoft/gale/Fps.java @@ -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; + } + } +} diff --git a/src/org/atriasoft/gale/Gale.java b/src/org/atriasoft/gale/Gale.java new file mode 100644 index 0000000..f1f8ca6 --- /dev/null +++ b/src/org/atriasoft/gale/Gale.java @@ -0,0 +1,50 @@ +package org.atriasoft.gale; + +import org.atriasoft.gale.context.Context; +//import org.atriasoft.gale.context.JOGL.ContextJOGL; +import org.atriasoft.gale.context.LWJG_AWT.ContextLWJGLAWT; +//import org.atriasoft.gale.context.LWJGL.ContextLWJGL; +import org.atriasoft.gale.internal.Log; + +public class Gale { + private Gale() {} + /** + * @brief This is the only one things the User might done in his main(); + * @note To answare you before you ask the question, this is really simple: + * Due to the fect that the current system is multiple-platform, you "main" + * Does not exist in the android platform, then gale call other start + * and stop function, to permit to have only one code + * @note The main can not be in the gale, due to the fact thet is an librairy + * @param _application just created instance of the applicationo + * @param _argc Standard argc + * @param _argv Standard argv + * @return normal error int for the application error management + */ + public static int run(Application application, String[] arg) { + //etk::init(_argc, _argv); + Context context = null; + String request = ""; + + //context = ContextLWJGL.create(application, arg); + //context = ContextJOGL.create(application, arg); + context = ContextLWJGLAWT.create(application, arg); + if (context == null) { + Log.error("Can not allocate the interface of the GUI ..."); + return -1; + } + return context.run(); + } + + /** + * @brief get GALE version + * @return The string that describe gale version + */ + public static String getVersion() { + return "J-0.5"; + } + + public static Context getContext() { + // TODO Auto-generated method stub + return Context.getContext(); + } +} diff --git a/src/org/atriasoft/gale/Orientation.java b/src/org/atriasoft/gale/Orientation.java new file mode 100644 index 0000000..9900017 --- /dev/null +++ b/src/org/atriasoft/gale/Orientation.java @@ -0,0 +1,7 @@ +package org.atriasoft.gale; + +public enum Orientation { + screenAuto, + screenLandscape, + screenPortrait +} diff --git a/src/org/atriasoft/gale/backend3d/OpenGL.java b/src/org/atriasoft/gale/backend3d/OpenGL.java new file mode 100644 index 0000000..9d0a143 --- /dev/null +++ b/src/org/atriasoft/gale/backend3d/OpenGL.java @@ -0,0 +1,877 @@ +package org.atriasoft.gale.backend3d; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.nio.FloatBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL13; +import org.lwjgl.opengl.GL15; +import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL30; +import org.lwjgl.opengl.GL40; +import org.atriasoft.etk.math.Matrix4f; +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.Color; +import org.atriasoft.gale.internal.Log; + +public class OpenGL { + private OpenGL() {} + static final boolean DEBUG = false; // TODO externalize this ... + static final boolean CHECKERROROPENGL = false; // TODO externalize this ... + static final boolean DIRECT_MODE = false; // TODO externalize this ... + + public static void checkGlError(String op) { +// int localLine = Thread.currentThread().getStackTrace()[2].getLineNumber(); +// if (CHECKERROROPENGL == true) { +// boolean hasError = false; +// for (int error = GL11.glGetError(); error!=null; error = GL11.glGetError()) { +// Log.error("after " + op + "():" + localLine + " glError(" + error + ")"); +// hasError = true; +// } +// if (hasError == true) { +// Log.critical("plop"); +// } +// for (GLint error = glGetError(); error; error = glGetError()) { +// Log.error("after " + op + "() glError (" + error + ")"); +// } +// } + } + + private static List matrixList = new ArrayList(); + private static Matrix4f matrixCamera = new Matrix4f(); + private static int programId = 0; + + // We map all the flag, but not all is supported by all platform... + public static enum Flag { + flag_blend, //!< If enabled, blend the computed fragment color values with the values in the color buffers. + //See glBlendFunc. + flag_clipDistanceI, //!< If enabled, clip geometry against user-defined half space i. + flag_colorLogigOP, //!< If enabled, apply the currently selected logical operation to the computed fragment color and color buffer values. See glLogicOp. + flag_cullFace, //!< If enabled, cull polygons based on their winding in window coordinates. See glCullFace. + flag_debugOutput, //!< If enabled, debug messages are produced by a debug context. When disabled, the debug message log is silenced. Note that in a non-debug context, very few, if any messages might be produced, even when GLDEBUGOUTPUT is enabled. + flag_debugOutputSynchronous, //!< If enabled, debug messages are produced synchronously by a debug context. If disabled, debug messages may be produced asynchronously. In particular, they may be delayed relative to the execution of GL commands, and the debug callback function may be called from a thread other than that in which the commands are executed. See glDebugMessageCallback. + flag_depthClamp, //!< If enabled, the -wcdzcdwc plane equation is ignored by view volume clipping (effectively, there is no near or far plane clipping). See glDepthRange. + flag_depthTest, //!< If enabled, do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. See glDepthFunc and glDepthRange. + flag_dither, //!< If enabled, dither color components or indices before they are written to the color buffer. + flag_framebufferSRGB, //!< If enabled and the value of GLFRAMEBUFFERATTACHMENTCOLORENCODING for the framebuffer attachment corresponding to the destination buffer is GLSRGB, the R, G, and B destination color values (after conversion from fixed-point to floating-point) are considered to be encoded for the sRGB color space and hence are linearized prior to their use in blending. + flag_lineSmooth, //!< If enabled, draw lines with correct filtering. Otherwise, draw aliased lines. See glLineWidth. + flag_multisample, //!< If enabled, use multiple fragment samples in computing the final color of a pixel. See glSampleCoverage. + flag_polygonOffsetFill, //!< If enabled, and if the polygon is rendered in GLFILL mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See glPolygonOffset. + flag_polygonOffsetLine, //!< If enabled, and if the polygon is rendered in GLLINE mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See glPolygonOffset. + flag_polygonOffsetPoint, //!< If enabled, an offset is added to depth values of a polygon's fragments before the depth comparison is performed, if the polygon is rendered in GLPOINT mode. See glPolygonOffset. + flag_polygonSmooth, //!< If enabled, draw polygons with proper filtering. Otherwise, draw aliased polygons. For correct antialiased polygons, an alpha buffer is needed and the polygons must be sorted front to back. + flag_primitiveRestart, //!< enables primitive restarting. If enabled, any one of the draw commands which transfers a set of generic attribute array elements to the GL will restart the primitive when the index of the vertex is equal to the primitive restart index. See glPrimitiveRestartIndex. + flag_primitiveRestartFixedIndex, //!< enables primitive restarting with a fixed index. If enabled, any one of the draw commands which transfers a set of generic attribute array elements to the GL will restart the primitive when the index of the vertex is equal to the fixed primitive index for the specified index type. The fixed index is equal to 2n1 where n is equal to 8 for GLUNSIGNEDBYTE, 16 for GLUNSIGNEDSHORT and 32 for GLUNSIGNEDINT. + flag_sampleAlphaToCoverage, //!< If enabled, compute a temporary coverage value where each bit is determined by the alpha value at the corresponding sample location. The temporary coverage value is then ANDed with the fragment coverage value. + flag_sampleAlphaToOne, //!< If enabled, each sample alpha value is replaced by the maximum representable alpha value. + flag_sampleCoverage, //!< If enabled, the fragment's coverage is ANDed with the temporary coverage value. If GLSAMPLECOVERAGEINVERT is set to GLTRUE, invert the coverage value. See glSampleCoverage. + flag_sampleShading, //!< If enabled, the active fragment shader is run once for each covered sample, or at fraction of this rate as determined by the current value of GLMINSAMPLESHADINGVALUE. See glMinSampleShading. + flag_sampleMask, //!< If enabled, the sample coverage mask generated for a fragment during rasterization will be ANDed with the value of GLSAMPLEMASKVALUE before shading occurs. See glSampleMaski. + flag_scissorTest, //!< If enabled, discard fragments that are outside the scissor rectangle. See glScissor. + flag_stencilTest, //!< If enabled, do stencil testing and update the stencil buffer. See glStencilFunc and glStencilOp. GLTEXTURECUBEMAPSEAMLESS = 1+0, //!< If enabled, cubemap textures are sampled such that when linearly sampling from the border between two adjacent faces, texels from both faces are used to generate the final sample value. When disabled, texels from only a single face are used to ruct the final sample value. + flag_programPointSize, //!< If enabled and a vertex or geometry shader is active, then the derived point size is taken from the (potentially clipped) shader builtin gthis.PointSize and clamped to the implementation-dependent point size range. + flag_texture2D, //!< + flag_alphaTest, //!< + flag_fog, + flag_back + }; + public enum RenderMode { + point, + line, + lineStrip, //!< Not supported in GALE (TODO Later) + lineLoop, + triangle, + triangleStrip, //!< Not supported in GALE (TODO Later) + triangleFan, //!< Not supported in GALE (TODO Later) + quad, //!< Not supported in OpenGL-ES2 + quadStrip, //!< Not supported in OpenGL-ES2 + polygon //!< Not supported in OpenGL-ES2 + }; + + private static final Map CONVERT_RENDER_MODE = Map.of( + RenderMode.point, GL11.GL_POINTS, + RenderMode.line, GL11.GL_LINES, + RenderMode.lineStrip, GL11.GL_LINE_STRIP, + RenderMode.lineLoop, GL11.GL_LINE_LOOP, + RenderMode.triangle, GL11.GL_TRIANGLES, + RenderMode.triangleStrip, GL11.GL_TRIANGLE_STRIP, + RenderMode.triangleFan, GL11.GL_TRIANGLE_FAN, + RenderMode.quad, GL11.GL_QUADS, + RenderMode.quadStrip, GL11.GL_QUAD_STRIP, + RenderMode.polygon, GL11.GL_POLYGON + ); + private static Map basicFlag; + public static class StateFlag { + public boolean current = false; + public boolean mustBeSet = false; + } + private static boolean flagsStatesChange = false; + private static Map flagsStates = new HashMap(); + + public enum Usage { + streamDraw, + staticDraw, + dynamicDraw + } + public static Map convertUsage; + static { + flagsStates.put(Flag.flag_blend, new StateFlag()); + flagsStates.put(Flag.flag_clipDistanceI, new StateFlag()); + flagsStates.put(Flag.flag_colorLogigOP, new StateFlag()); + flagsStates.put(Flag.flag_cullFace, new StateFlag()); + flagsStates.put(Flag.flag_debugOutput, new StateFlag()); + flagsStates.put(Flag.flag_debugOutputSynchronous, new StateFlag()); + flagsStates.put(Flag.flag_depthClamp, new StateFlag()); + flagsStates.put(Flag.flag_depthTest, new StateFlag()); + flagsStates.put(Flag.flag_dither, new StateFlag()); + flagsStates.put(Flag.flag_framebufferSRGB, new StateFlag()); + flagsStates.put(Flag.flag_lineSmooth, new StateFlag()); + flagsStates.put(Flag.flag_multisample, new StateFlag()); + flagsStates.put(Flag.flag_polygonOffsetFill, new StateFlag()); + flagsStates.put(Flag.flag_polygonOffsetLine, new StateFlag()); + flagsStates.put(Flag.flag_polygonOffsetPoint, new StateFlag()); + flagsStates.put(Flag.flag_polygonSmooth, new StateFlag()); + flagsStates.put(Flag.flag_primitiveRestart, new StateFlag()); + flagsStates.put(Flag.flag_primitiveRestartFixedIndex, new StateFlag()); + flagsStates.put(Flag.flag_sampleAlphaToCoverage, new StateFlag()); + flagsStates.put(Flag.flag_sampleAlphaToOne, new StateFlag()); + flagsStates.put(Flag.flag_sampleCoverage, new StateFlag()); + flagsStates.put(Flag.flag_sampleShading, new StateFlag()); + flagsStates.put(Flag.flag_sampleMask, new StateFlag()); + flagsStates.put(Flag.flag_scissorTest, new StateFlag()); + flagsStates.put(Flag.flag_stencilTest, new StateFlag()); + flagsStates.put(Flag.flag_programPointSize, new StateFlag()); + flagsStates.put(Flag.flag_texture2D, new StateFlag()); + flagsStates.put(Flag.flag_alphaTest, new StateFlag()); + flagsStates.put(Flag.flag_fog, new StateFlag()); + flagsStates.put(Flag.flag_back, new StateFlag()); + basicFlag = new HashMap(); + basicFlag.put(Flag.flag_blend, GL11.GL_BLEND); + // basicFlag.put(Flag.flag_clipDistanceI, GL_CLIP_DISTANCE0); + // basicFlag.put(Flag.flag_colorLogigOP, GL_COLOR_LOGIC_OP); + basicFlag.put(Flag.flag_cullFace, GL11.GL_CULL_FACE); + // basicFlag.put(Flag.flag_debugOutput, GLDEBUGOUTPUT); + // basicFlag.put(Flag.flag_debugOutputSynchronous, GLDEBUGOUTPUTSYNCHRONOUS); + // basicFlag.put(Flag.flag_depthClamp, GLDEPTHCLAMP); + basicFlag.put(Flag.flag_depthTest, GL11.GL_DEPTH_TEST); + basicFlag.put(Flag.flag_dither, GL11.GL_DITHER); + // basicFlag.put(Flag.flag_framebufferSRGB, GLFRAMEBUFFERSRGB); + // basicFlag.put(Flag.flag_lineSmooth, GLLINESMOOTH); + // basicFlag.put(Flag.flag_multisample, GLMULTISAMPLE); + basicFlag.put(Flag.flag_polygonOffsetFill, GL11.GL_POLYGON_OFFSET_FILL); + // basicFlag.put(Flag.flag_polygonOffsetLine, GLPOLYGONOFFSETLINE); + // basicFlag.put(Flag.flag_polygonOffsetPoint, GLPOLYGONOFFSETPOINT); + // basicFlag.put(Flag.flag_polygonSmooth, GLPOLYGONSMOOTH); + // basicFlag.put(Flag.flag_primitiveRestart, GLPRIMITIVERESTART); + // basicFlag.put(Flag.flag_primitiveRestartFixedIndex, GLPRIMITIVERESTARTFIXEDINDEX); + basicFlag.put(Flag.flag_sampleAlphaToCoverage, GL20.GL_SAMPLE_ALPHA_TO_COVERAGE); + // basicFlag.put(Flag.flag_sampleAlphaToOne, GLSAMPLEALPHATOONE); + basicFlag.put(Flag.flag_sampleCoverage, GL30.GL_SAMPLE_COVERAGE); + // basicFlag.put(Flag.flag_sampleShading, GLSAMPLESHADING); + // basicFlag.put(Flag.flag_sampleMask, GLSAMPLEMASK); + basicFlag.put(Flag.flag_scissorTest, GL11.GL_SCISSOR_TEST); + basicFlag.put(Flag.flag_stencilTest, GL30.GL_STENCIL_TEST); + // basicFlag.put(Flag.flag_programPointSize, GLPROGRAMPOINTSIZE); + basicFlag.put(Flag.flag_texture2D, GL11.GL_TEXTURE_2D); + // basicFlag.put(Flag.flag_alphaTest, GLALPHATEST); + // basicFlag.put(Flag.flag_fog, GLFOG); + basicFlag.put(Flag.flag_back, GL11.GL_BACK); + convertUsage = new HashMap(); + convertUsage.put(Usage.streamDraw, GL20.GL_STREAM_DRAW); + convertUsage.put(Usage.staticDraw, GL20.GL_STATIC_DRAW); + convertUsage.put(Usage.dynamicDraw, GL20.GL_DYNAMIC_DRAW); + } + private static void clearFlagState() { + for (Map.Entry elem: flagsStates.entrySet()) { + elem.getValue().current = false; + elem.getValue().mustBeSet = false; + } + } + public static void resetFlagState() { + for (Map.Entry elem: flagsStates.entrySet()) { + elem.getValue().mustBeSet = false; + } + flagsStatesChange = true; + } + private static Map threadHasContext = new HashMap(); + /** + * @brief Get the current thread context status. + * @return true The threflagsStates.putn acces to openGL.flagsStates.put(Flag.@return false The Thread Can not acces to OpenGL. + */ + public static boolean hasContext() { + long curentThreadId = Thread.currentThread().getId(); + if (threadHasContext.containsKey(curentThreadId) == false) { + return false; + } + return threadHasContext.get(curentThreadId); + } + /** + * @brief must be called by the thread that has openGl context to notify the system + * @note Call @ref gale::openGL::threadHasNoMoreContext when ended + */ + public static void threadHasContext() { + long curentThreadId = Thread.currentThread().getId(); + threadHasContext.put(curentThreadId, true); + } + /** + * @brief At the end of the thread exection, set the thead has no more openGL cotext + */ + public static void threadHasNoMoreContext() { + long curentThreadId = Thread.currentThread().getId(); + threadHasContext.remove(curentThreadId); + } + /** + * @brief Lock the openGL context for one user only == > better to keep flags and other things ... + */ + public static void lock() { + //mutexOpenGl().lock(); + matrixList.clear(); + Matrix4f tmpMat = Matrix4f.identity(); + matrixList.add(tmpMat); + matrixCamera.setIdentity(); + clearFlagState(); + programId = -1; + } + /** + * @brief Un-lock the openGL context for an other user... + */ + public static void unLock() { + //mutexOpenGl().unLock(); + } + /** + * @brief When you will done an opengl rendering, you might call this reset matrix first. It remove all the stach of the matrix pushed. + * @param newOne the default matrix that might be set for the graphic card for renderer. if too more pop will be done, this is the last that mmight survived + */ + public static void setBasicMatrix( Matrix4f newOne) { + if (matrixList.size()!=1) { + Log.error("matrix is not corect size in the stack : " + matrixList.size()); + } + matrixList.clear(); + matrixList.add(newOne); + } + /** + * @brief this funtion configure the current use matrix for the renderer (call @ref Push before, and @ref Pop when no more needed). + * @param newOne The new current matrix use for the render. + * @note We did not use opengl standard system, due to the fact that is not supported in opengl ES-2 + */ + public static void setMatrix( Matrix4f newOne) { + if (matrixList.size() == 0) { + Log.error("set matrix list is not corect size in the stack : " + matrixList.size()); + matrixList.add(newOne); + return; + } + matrixList.set(matrixList.size()-1, newOne); + } + /** + * @brief store current matrix in the matrix stack. + */ + public static void push() { + if (matrixList.size() == 0) { + Log.error("set matrix list is not corect size in the stack : " + matrixList.size()); + matrixList.add(Matrix4f.identity()); + return; + } + Matrix4f tmp = matrixList.get(matrixList.size()-1); + matrixList.add(tmp); + } + /** + * @brief remove the current matrix and get the last one from the matrix stack. + */ + public static void pop() { + if (matrixList.size() <= 1) { + Log.error("set matrix list is not corect size in the stack : " + matrixList.size()); + matrixList.clear(); + matrixList.add(Matrix4f.identity()); + matrixCamera.setIdentity(); + return; + } + matrixList.remove(matrixList.size()-1); + matrixCamera.setIdentity(); + } + + /** + * @brief get a reference on the current matrix destinate to opengl renderer. + * @return The requested matrix. + */ + public static Matrix4f getMatrix() { + if (matrixList.size() == 0) { + Log.error("set matrix list is not corect size in the stack : " + matrixList.size()); + matrixList.add(Matrix4f.identity()); + } + return matrixList.get(matrixList.size()-1); + } + /** + * @brief get a reference on the current matrix camera destinate to opengl renderer. + * @return The requested matrix. + */ + public static Matrix4f getCameraMatrix(){ + return matrixCamera; + } + + /** + * @brief set a reference on the current camera to opengl renderer. + * @param newOne The requested matrix. + */ + public static void setCameraMatrix( Matrix4f newOne){ + matrixCamera = newOne; + } + /** + * @brief + */ + public static void finish(){ + programId = -1; + } + /** + * @brief + */ + public static void flush(){ + programId = -1; + GL11.glFlush(); + //checkGlError("glFlush"); + //Log.info("========================" ); + //Log.info("== FLUSH OPEN GL ==" ); + //Log.info("========================"); + } + + /** + * @brief + */ + public static void swap(){ + + } + public static void setViewPort( Vector2i start, Vector2i stop){ + //Log.info("setViewport " + start + " " + stop); + GL11.glViewport(start.x, start.y, stop.x, stop.y); + checkGlError("glViewport"); + } + public static void setViewPort( Vector2f start, Vector2f stop){ + //Log.info("setViewport " + start + " " + stop); + GL11.glViewport((int)start.x, (int)start.y, (int)stop.x, (int)stop.y); + checkGlError("glViewport"); + } + + /** + * @brief Specifies the clear color value When clear is requested + * @param value to set [0..1] + */ + public static void clearColor(Color color) { + GL11.glClearColor(color.r, color.g, color.b, color.a); + checkGlError("glClearColor"); + } + /** + * @brief Specifies the depth value used when the depth buffer is cleared. The initial value is 1. + * @param value to set [0..1] + */ + public static void clearDepth(float value) { + GL11.glClearDepth(value); + checkGlError("glClearDepth"); + } + /** + * @brief Specifies the index used by clear to clear the stencil buffer. s is masked with 2 m - 1 , where m is the number of bits in the stencil buffer. + * @param value + */ + public static void clearStencil(int value) { + GL11.glClearStencil(value); + checkGlError("glClearStencil"); + } + + + public static enum ClearFlag { + clearFlag_colorBuffer, //!< Indicates the buffers currently enabled for color writing. + clearFlag_depthBuffer, //!< Indicates the depth buffer. + clearFlag_stencilBuffer //!< Indicates the stencil buffer. + } + private static final Map BASIC_FLAG_CLEAR = Map.of( + ClearFlag.clearFlag_colorBuffer, GL11.GL_COLOR_BUFFER_BIT, + ClearFlag.clearFlag_depthBuffer, GL11.GL_DEPTH_BUFFER_BIT, + ClearFlag.clearFlag_stencilBuffer, GL11.GL_STENCIL_BUFFER_BIT ); + + /** + * @brief clear sets the bitplane area of the window to values previously selected by clearColor, clearDepth, and clearStencil. Multiple color buffers can be cleared simultaneously by selecting more than one buffer at a time using drawBuffer. + * The pixel ownership test, the scissor test, dithering, and the buffer writemasks affect the operation of clear. The scissor box bounds the cleared region. Alpha function, blend function, logical operation, stenciling, texture mapping, and depth-buffering are ignored by clear. + * @param flags This is the bitwise OR of several values indicating which buffer is to be cleared. + */ + public static void clear(ClearFlag flag){ + GL11.glClear(BASIC_FLAG_CLEAR.get(flag)); + checkGlError("glClear"); + } + + /** + * @brief enable a flag on the system + * @param flagID The flag requested + */ + public static void enable(Flag flagID){ + //Log.info("Enable : " + flagID); + if (DIRECT_MODE) { + GL11.glEnable(basicFlag.get(flagID)); + checkGlError("glEnable"); + } else { + //Log.debug("Enable FLAGS = " + this.flagsStates); + flagsStates.get(flagID).mustBeSet = true; + flagsStatesChange = true; + //Log.debug(" == >" + this.flagsStates); + } + } + /** + * @brief disable a flag on the system + * @param flagID The flag requested + */ + public static void disable(Flag flagID) { + //Log.info("Disable : " + flagID); + if (DIRECT_MODE) { + GL11.glDisable(basicFlag.get(flagID)); + checkGlError("glDisable"); + } else { + //Log.debug("Disable FLAGS = " + this.flagsStates); + flagsStates.get(flagID).mustBeSet = false; + flagsStatesChange = true; + //Log.debug(" == >" + this.flagsStates); + } + } + /** + * @brieg update all the internal flag needed to be set from tre previous element set ... + */ + public static void updateAllFlags() { + if (DIRECT_MODE) { + return; + } + // check if flags has change : + if (flagsStatesChange == false) { + return; + } + flagsStatesChange = false; + for (Map.Entry elem: flagsStates.entrySet()) { + StateFlag value = elem.getValue(); + if (value.current != value.mustBeSet) { + value.current = value.mustBeSet; + if (value.current == true) { + GL11.glEnable(basicFlag.get(elem.getKey())); + checkGlError("glEnable"); + //Log.info(" enable : " + elem.getKey() + " " + basicFlag.get(elem.getKey())); + } else { + GL11.glDisable(basicFlag.get(elem.getKey())); + checkGlError("glDisable"); + //Log.info(" disable : " + elem.getKey()); + } + } + } + } + /** + * @brief enable Texture on the system + * @param flagID The flag requested + */ + public static void activeTexture(int flagID) { + if (programId >= 0) { + GL13.glActiveTexture(flagID); + checkGlError("glActiveTexture"); + } else { + if (DEBUG) { + Log.error("try to bind texture with no program set"); + } + } + } + /** + * @brief disable Texture on the system + * @param flagID The flag requested + */ + // TODO rename Disable + public static void desActiveTexture(int flagID) { +// if (this.programId >= 0) { +// +// } + } + + /** + * @brief draw a specific array == > this enable mode difference ... + */ + public static void drawArrays(RenderMode mode, int first, int count) { + if (programId >= 0) { + updateAllFlags(); + GL20.glDrawArrays(CONVERT_RENDER_MODE.get(mode), first, count); + checkGlError("glDrawArrays"); + } + } +// public static void drawElements(RenderMode mode, List indices) { +// if (this.programId >= 0) { +// updateAllFlags(); +// //Log.debug("Request draw of " + indices.size() + "elements"); +// GL15.glDrawElements(convertRenderMode.get(mode), indices.size(), GL11.GL_UNSIGNED_INT);//, &indices[0]); +// checkGlError("glDrawElements"); +// } +// } +// public static void drawElements16(RenderMode mode, List indices) { +// if (this.programId >= 0) { +// updateAllFlags(); +// GL20.glDrawElements(convertRenderMode.get(mode), indices.size(), GLUNSIGNEDSHORT, &indices[0]); +// checkGlError("glDrawElements"); +// } +// } +// public static void drawElements8 (enum renderMode mode, List indices) { +// if (this.programId >= 0) { +// updateAllFlags(); +// GL20.glDrawElements(convertRenderMode[int(mode)], indices.size(), GLUNSIGNEDBYTE, &indices[0]); +// checkGlError("glDrawElements"); +// } +// } + /** + * @brief Use openGL program + * @param id Id of the program that might be used + */ + public static void programUse(int id) { + //Log.verbose("USE prog : " + id); + // note : In normal openGL case, the system might call with the program ID and at the end with 0, + // here, we wrap this use to prevent over call of glUseProgram == > then we set -1 when the + // user no more use this program, and just stop grnerating. (chen 0 == > this is an errored program ... + if (id == -1) { + // not used == > because it is unneded + return; + } + if (programId != id) { + programId = id; + GL20.glUseProgram(programId); + } + checkGlError("glUseProgram"); + } + public static void programUnUse(int id) { + // nothing to do ... + } + public static void reset() { + if (DIRECT_MODE) { + Log.error("TODO ..."); + } else { + clearFlagState(); + programId = -1; + updateAllFlags(); + } + } + + + public static boolean genBuffers(int[] buffers) { + if (buffers.length == 0) { + Log.warning("try to generate vector buffer with size 0"); + return true; + } + Log.info("Create N=" + buffers.length + " Buffer"); + GL20.glGenBuffers(buffers); + checkGlError("glGenBuffers"); + boolean hasError = false; + for (int iii=0; iii= 256) { +// tmpLog[idOut] = '\0'; +// Log.error(" == > " + tmpLog); +// idOut=0; +// } else { +// idOut++; +// } +// if (this.bufferDisplayError[iii] == '\0') { +// break; +// } +// } +// if (idOut != 0) { +// tmpLog[idOut] = '\0'; +// Log.error(" == > " + tmpLog); +// } +// return false; +// } + return true; + } + public static void programBindAttribute(int prog, int attribute, String variableName) { + if (prog < 0) { + Log.error("wrong program ID"); + return; + } + GL20.glBindAttribLocation(prog, attribute, variableName); + } + public static int programGetAttributeLocation(int prog, String name) { + if (prog < 0) { + Log.error("wrong program ID"); + return -1; + } + if (name.length() == 0) { + Log.error("wrong name of attribure"); + return -1; + }int val = GL20.glGetAttribLocation(prog, name); + if (val < 0) { + checkGlError("glGetAttribLocation"); + Log.warning("glGetAttribLocation('" + name + "') = " + val); + return -1; + } + return val; + } + public static int programGetUniformLocation(int prog, String name) { + if (prog < 0) { + Log.error("wrong program ID"); + return -1; + } + if (name.length() == 0) { + Log.error("wrong name of uniform"); + return -1; + } + int val = GL20.glGetUniformLocation(prog, name); + if (val == GL20.GL_INVALID_VALUE) { + checkGlError("glGetUniformLocation"); + Log.warning("glGetUniformLocation('" + name + "') = GL_INVALID_VALUE"); + } else if (val == GL20.GL_INVALID_OPERATION) { + checkGlError("glGetUniformLocation"); + Log.warning("glGetUniformLocation('" + name + "') = GL_INVALID_OPERATION"); + } else if (val < 0) { + checkGlError("glGetUniformLocation"); + Log.warning("glGetUniformLocation('" + name + "') = " + val); + } + return val; + }; + + + public static void programLoadUniformFloat(int location, float value) { + GL20.glUniform1f(location, value); + } + public static void programLoadUniformFloat(int location, float value, float value2) { + GL20.glUniform2f(location, value, value2); + } + public static void programLoadUniformFloat(int location, float value, float value2, float value3) { + GL20.glUniform3f(location, value, value2, value3); + } + public static void programLoadUniformFloat(int location, float value, float value2, float value3, float value4) { + GL20.glUniform4f(location, value, value2, value3, value4); + } + + public static void programLoadUniformInt(int location, int value) { + GL20.glUniform1i(location, value); + } + public static void programLoadUniformInt(int location, int value, int value2) { + GL20.glUniform2i(location, value, value2); + } + public static void programLoadUniformInt(int location, int value, int value2, int value3) { + GL20.glUniform3i(location, value, value2, value3); + } + public static void programLoadUniformInt(int location, int value, int value2, int value3, int value4) { + GL20.glUniform4i(location, value, value2, value3, value4); + } + + public static void programLoadUniformColor(int location, Color value) { + GL20.glUniform4f(location, value.r, value.g, value.b, value.a); + } + + public static void programLoadUniformVector(int location, Vector3f value) { + GL20.glUniform3f(location, value.x, value.y, value.z); + } + public static void programLoadUniformVector(int location, Vector3i value) { + GL20.glUniform3i(location, value.x, value.y, value.z); + } + + public static void programLoadUniformVector(int location, Vector2f value) { + GL20.glUniform2f(location, value.x, value.y); + } + public static void programLoadUniformVector(int location, Vector2i value) { + GL20.glUniform2i(location, value.x, value.y); + } + + public static void programLoadUniformBoolean(int location, boolean value) { + //System.out.println("set value " + value + " " + (value==true?1.0f:0.0f)); + GL20.glUniform1f(location, value==true?1.0f:0.0f); + } + + public static void programLoadUniformMatrix(int location, Matrix4f value) { + GL20.glUniformMatrix4fv(location, true, value.getTable()); + } + public static void programLoadUniformMatrix(int location, Matrix4f value, boolean transpose) { + GL20.glUniformMatrix4fv(location, transpose, value.getTable()); + } + public static void drawElements(RenderMode mode, int vertexCount) { + GL11.glDrawElements(CONVERT_RENDER_MODE.get(mode), vertexCount, GL11.GL_UNSIGNED_INT, 0); + } + public static void setDeathMask(boolean state) { + GL40.glDepthMask(state); + } + +} diff --git a/src/org/atriasoft/gale/context/ClipBoard.java b/src/org/atriasoft/gale/context/ClipBoard.java new file mode 100644 index 0000000..9fbb679 --- /dev/null +++ b/src/org/atriasoft/gale/context/ClipBoard.java @@ -0,0 +1,40 @@ +package org.atriasoft.gale.context; + +public class ClipBoard { + private ClipBoard() {} + /** + * @brief set the string data on a specific clipboard. The Gui system is notify that the clipboard "SELECTION" and "COPY" are change + * @param _clipboardID Select the specific ID of the clipboard + * @param _data The string that might be send to the clipboard + */ + public static void set(ClipboardList clipboardID, String data) { + } + /** + * @brief Call system to request the current clipboard. + * @note Due to some system that manage the clipboard request asynchronous (like X11) and gale managing the system with only one thread, + * we need the call the system to send us the buffer, this is really ambigous, but the widget (who has focus) receive the + * notification of the arrival of this buffer id + * @param _clipboardID the needed clipboard ID + */ + public static void request(ClipboardList clipboardID) { + } + /** + * @brief set the gale internal buffer (no notification at the GUI). This fuction might be use by the + * Gui abstraction to set the buffer we receive. The end user must not use it. + * @param _clipboardID selected clipboard ID + * @param _data new buffer data + */ + public static void setSystem(ClipboardList clipboardID, String data) { + } + /** + * @brief get the gale internal buffer of the curent clipboard. The end user can use it when he receive the event in + * the widget : @ref onEventClipboard == > we can nothe this function is the only one which permit it. + * @note if we call this fuction withoutcallin @ref gale::context::clipBoard::Request, we only get the previous clipboard + * @param _clipboardID selected clipboard ID + * @return the requested buffer + */ + public static String get(ClipboardList clipboardID) { + return null; + } + +} diff --git a/src/org/atriasoft/gale/context/ClipboardList.java b/src/org/atriasoft/gale/context/ClipboardList.java new file mode 100644 index 0000000..cfad612 --- /dev/null +++ b/src/org/atriasoft/gale/context/ClipboardList.java @@ -0,0 +1,16 @@ +package org.atriasoft.gale.context; + +public enum ClipboardList { + clipboard0, //!< internal clipboard 0 + clipboard1, //!< internal clipboard 1 + clipboard2, //!< internal clipboard 2 + clipboard3, //!< internal clipboard 3 + clipboard4, //!< internal clipboard 4 + clipboard5, //!< internal clipboard 5 + clipboard6, //!< internal clipboard 6 + clipboard7, //!< internal clipboard 7 + clipboard8, //!< internal clipboard 8 + clipboard9, //!< internal clipboard 9 + clipboardStd, //!< External clipboard represent the Copy/Cut/Past buffer + clipboardSelection, //!< External or internal clipboard depending on the OS, represent the middle button +} diff --git a/src/org/atriasoft/gale/context/CommandLine.java b/src/org/atriasoft/gale/context/CommandLine.java new file mode 100644 index 0000000..7ca1108 --- /dev/null +++ b/src/org/atriasoft/gale/context/CommandLine.java @@ -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 listArgs = new ArrayList(); + + public void parse(String[] args) { + for (int iii=1 ; iii rtfm ..."); + } + commandLine.parse(args); + Log.info(" == > Gale system init (BEGIN)"); + // create thread to manage real periodic event + this.periodicThread = new PeriodicThread(this); + + // By default we set 2 themes (1 color and 1 shape ...) : + //theme::setNameDefault("GUI", "shape/square/"); + //theme::setNameDefault("COLOR", "color/black/"); + + // parse the debug level: +// for(int iii=0; iii{ + Application appl = _context.getApplication(); + if (appl == null) { + return; + } + appl.onCreate(_context); + appl.onStart(_context); + appl.onResume(_context); + appl.canDraw = true; + }); + + // force a recalculation + requestUpdateSize(); + Log.info(" == > Gale system init (END)"); + } + /** + * @brief StartProcessing (2nd thread). + * @note to call when all the Context is started + */ + public void start2ndThreadProcessing() { + // set the current interface: + lockContext(); + this.periodicThread.threadStart(); + try { + Thread.sleep(1); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // release the current interface: + unLockContext(); + } + // simulation area: + private long previousDisplayTime; // this is to limit framerate ... in case... + private Vector msgSystem = new Vector(); + private boolean displayFps = true; + private Fps fpsSystemEvent = new Fps("SystemEvent", displayFps); + private Fps fpsSystemContext = new Fps("SystemContext", displayFps); + private Fps fpsSystem = new Fps("System", displayFps); + private Fps fpsFlush = new Fps("Flush", displayFps); + + + + private synchronized void postAction(ActionToDoInAsyncLoop data) { + msgSystem.addElement(data); + notify(); + //Later, when the necessary event happens, the thread that is running it calls notify() from a block synchronized on the same object. + } + + // Called by Consumer + public synchronized ActionToDoInAsyncLoop getAction() { + notify(); + while (msgSystem.size() == 0) { + try { + wait(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + }//By executing wait() from a synchronized block, a thread gives up its hold on the lock and goes to sleep. + } + ActionToDoInAsyncLoop message = (ActionToDoInAsyncLoop) msgSystem.firstElement(); + msgSystem.removeElement(message); + return message; + } + /** + * @brief Processing all the event arrived ... (commoly called in draw function) + */ + public void processEvents() { + int nbEvent = 0; + //Log.debug(" ******** Event " << this.msgSystem.count()); + while (this.msgSystem.size() > 0) { + nbEvent++; + //Log.verbose(" [" << nbEvent << "] event ..."); + ActionToDoInAsyncLoop func = getAction(); + if (func == null) { + continue; + } + func.run(this); + } + } +// gale::Context::~Context() { +// Log.info(" == > Gale system Un-Init (BEGIN)"); +// this.periodicThread.threadStart(); +// getResourcesManager().applicationExiting(); +// // TODO Clean the message list ... +// // set the current interface: +// lockContext(); +// // clean all widget and sub widget with their resources: +// //this.objectManager.cleanInternalRemoved(); +// // call application to uninit +// this.application.canDraw = false; +// this.application.onPause(*this); +// this.application.onStop(*this); +// this.application.onDestroy(*this); +// this.application.reset(); +// // clean all messages +// this.msgSystem.clean(); +// // internal clean elements +// //this.objectManager.cleanInternalRemoved(); +// this.resourceManager.cleanInternalRemoved(); +// +// 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(); +// // now All must be removed !!! +// //this.objectManager.unInit(); +// // release the current interface : +// unLockContext(); +// Log.info(" == > Gale system Un-Init (END)"); +// if (this.simulationActive) { +// // in simulation case: +// this.simulationFile.close(); +// } +// } + + public void operatingSystemSetInput(KeySpecial special, + KeyType type, + KeyStatus status, + int pointerID, + Vector2f pos){ + postAction((context)->{ + Application appl = context.getApplication(); + if (appl == null) { + return; + } + appl.onPointer(special, + type, + pointerID, + pos, + status); + }); + } + public void operatingSystemsetKeyboard( KeySpecial special, + KeyKeyboard type, + KeyStatus state, + boolean isARepeateKey) { + operatingSystemsetKeyboard(special, type, state, isARepeateKey, (char)0); + } + public void operatingSystemsetKeyboard( KeySpecial special, + KeyKeyboard type, + KeyStatus state, + boolean isARepeateKey, + Character charValue) { + KeyStatus tmpState = state; + if (isARepeateKey == true) { + if (tmpState == KeyStatus.down) { + tmpState = KeyStatus.downRepeate; + } else { + tmpState = KeyStatus.upRepeate; + } + } + operatingSystemsetKeyboard2(special, type, state, charValue); + } + public void operatingSystemsetKeyboard2( KeySpecial special, + KeyKeyboard type, + KeyStatus state, + Character charValue){ + postAction((context)->{ + Application appl = context.getApplication(); + if (appl == null) { + return; + } + appl.onKeyboard(special, + type, + charValue, + state); + }); + } + /** + * @brief The current context is suspended + */ + public void operatingSystemSuspend(){ + // set the current interface : + lockContext(); + Log.info("operatingSystemSuspend..."); + this.previousDisplayTime = 0; + +// if (this.windowsCurrent != null) { +// this.windowsCurrent.onStateSuspend(); +// } + // release the current interface : + unLockContext(); + } + /** + * @brief The current context is resumed + */ + public void operatingSystemResume(){ + // set the current interface : + 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(); + } + + /** + * @brief The current context is set in foreground (framerate is maximum speed) + */ + public void operatingSystemForeground(){ + // set the current interface : + lockContext(); + Log.info("operatingSystemForeground..."); + +// if (this.windowsCurrent != null) { +// this.windowsCurrent.onStateForeground(); +// } + // release the current interface : + unLockContext(); + } + /** + * @brief The current context is set in background (framerate is slowing down (max fps)/5 # 4fps) + */ + public void operatingSystemBackground(){ + // set the current interface : + lockContext(); + Log.info("operatingSystemBackground..."); +// if (this.windowsCurrent != null) { +// this.windowsCurrent.onStateBackground(); +// } + // release the current interface : + unLockContext(); + } + public void requestUpdateSize() { + postAction((context)->{ + //Log.debug("Receive MSG : THREAD_RESIZE"); + context.forceRedrawAll(); + }); + } + // return true if a flush is needed + private static int countMemeCheck = 0; + public boolean operatingSystemDraw(boolean displayEveryTime) { + if (countMemeCheck++ >= 10*16) { + countMemeCheck = 0; + } + //Log.verbose("Call draw"); + 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) { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + this.previousDisplayTime = currentTime; + OpenGL.threadHasContext(); + OpenGL.resetFlagState(); + // process the events + if (this.displayFps == true) { + this.fpsSystemEvent.tic(); + } + boolean needRedraw = false; + //! Event management section ... + { + // set the current interface: + lockContext(); + /* + Lock the event processing + + Wait end of current processing + + Display ... + + Release the event processing + + */ + if (this.application != null) { + // Redraw all needed elements + //Log.debug("Regenerate Display"); + this.application.onRegenerateDisplay(this); + needRedraw = this.application.isDrawingNeeded(); + } + if (this.displayFps) { + this.fpsSystemEvent.incrementCounter(); + this.fpsSystemEvent.toc(); + } + // release the current interface : + unLockContext(); + } + boolean hasDisplayDone = false; + //! drawing section: + { + // Lock openGl context: + OpenGL.lock(); + if (this.displayFps == true) { + this.fpsSystemContext.tic(); + } + if( needRedraw = true + || displayEveryTime == true) { + //Log.debug(" ==> real Draw"); + lockContext(); + this.resourceManager.updateContext(); + unLockContext(); + if (this.displayFps == true) { + this.fpsSystemContext.incrementCounter(); + } + } + if (this.displayFps == true) { + this.fpsSystemContext.toc(); + this.fpsSystem.tic(); + } + if (this.application != null) { + if( needRedraw == true + || displayEveryTime == true) { + this.fpsSystem.incrementCounter(); + // set the current interface : + lockContext(); + if (this.application.canDraw == true) { + this.application.onDraw(this); + } + unLockContext(); + hasDisplayDone = true; + } + } + if (this.displayFps == true) { + this.fpsSystem.toc(); + this.fpsFlush.tic(); + } + if (hasDisplayDone == true) { + //Log.info("lklklklklk " << _displayEveryTime); + if (this.displayFps == true) { + this.fpsFlush.incrementCounter(); + } + OpenGL.flush(); + } + if (this.displayFps == true) { + this.fpsFlush.toc(); + } + // release open GL Context + OpenGL.unLock(); + } + if (this.displayFps == true) { + this.fpsSystemEvent.draw(); + this.fpsSystemContext.draw(); + this.fpsSystem.draw(); + this.fpsFlush.draw(); + } + { + // set the current interface: + lockContext(); + // release open GL Context + OpenGL.lock(); + // while The Gui is drawing in OpenGl, we do some not realTime things + this.resourceManager.updateContext(); + // release open GL Context + OpenGL.unLock(); + // TODO this.objectManager.cleanInternalRemoved(); + this.resourceManager.cleanInternalRemoved(); + // release the current interface: + unLockContext(); + } + OpenGL.threadHasNoMoreContext(); + return hasDisplayDone; + } + /** + * @brief reset event management for the IO like Input ou Mouse or keyborad + */ + public void resetIOEvent() { + // TODO this.input.newLayerSet(); + } + /** + * @brief The OS inform that the openGL ext has been destroy == > use to automaticly reload the texture and other thinks ... + */ + public void operatingSystemOpenGlContextDestroy(){ + this.resourceManager.contextHasBeenDestroyed(); + } + /** + * @brief The OS Inform that the Window has been killed + */ + public void operatingSystemStop(){ + // set the current interface : + lockContext(); + Log.info("operatingSystemStop..."); + if (this.application == null) { + stop(); + return; + } + this.application.onKillDemand(this); + // release the current interface : + unLockContext(); + } + /** + * @brief The application request that the Window will be killed + */ + public void stop() { + Log.warning("stop: NOT implemented for this platform..."); + } + protected Vector2f windowsSize = new Vector2f(0,0); //!< current size of the system + /** + * @brief get the current windows size + * @return the current size ... + */ + public Vector2f getSize() { + return this.windowsSize; + }; + /** + * @brief The OS inform that the current windows has change his size. + * @param _size new size of the windows. + */ + public void operatingSystemResize( Vector2f _size){ + if (this.windowsSize == _size) { + return; + } + // TODO Better in the thread ... ==> but generate some init error ... + //gale::Dimension::setPixelWindowsSize(_size); + postAction((context) -> { + Log.debug("Receive MSG : THREAD_RESIZE : " + context.windowsSize + " ==> " + _size); + context.windowsSize = _size; + //gale::Dimension::setPixelWindowsSize(_context.windowsSize); + Application tmpAppl = context.getApplication(); + if (tmpAppl != null) { + tmpAppl.onResize(context.windowsSize); + } + // call application inside .. + context.forceRedrawAll(); + }); + } + /** + * @brief The application request a change of his current size. + * @param _size new Requested size of the windows. + */ + public void setSize( Vector2f size){ + Log.info("setSize: NOT implemented ..."); + }; + protected boolean fullscreen = false; + /** + * @brief The application request a change of his current size force the fullscreen mode. + * @param _status status of the fullscreen mode. + */ + public void setFullScreen(boolean status){ + fullscreen = status; + }; + public boolean getFullScreen(){ + return fullscreen; + }; + protected Vector2f windowsPos; //!< current size of the system + /** + * @brief The OS inform that the current windows has change his position. + * @param _pos New position of the Windows. + */ + public void operatingSystemMove( Vector2f _pos){ + if (this.windowsPos.isEqual(_pos)) { + return; + } + postAction((context) -> { + Log.debug("Receive MSG : THREAD_MOVE : " + context.windowsPos + " ==> " + _pos); + context.windowsPos = _pos; + Application appl = context.getApplication(); + if (appl == null) { + return; + } + appl.onMovePosition(context.windowsPos); + }); + } + /** + * @brief The Application request that the current windows will change his position. + * @param _pos New position of the Windows requested. + */ + public void setPos( Vector2f pos){ + Log.info("setPos: NOT implemented ..."); + } + /** + * @brief The Application request the current position of the windows. + * @return Turrent position of the Windows. + */ + public Vector2f getPos(){ + return this.windowsPos; + } + /** + * @brief The OS inform that the Windows is now Hidden. + */ + public void operatingSystemHide() { + postAction((context) -> { + /* + Application> appl = _context.getApplication(); + if (appl == null) { + return; + } + appl.onKeyboard(_special, + _type, + _char, + _state); + */ + Log.todo("HIDE ... "); + }); + } + /** + * @brief The Application request that the Windows will be Hidden. + */ + public void hide(){ + Log.info("hide: NOT implemented ..."); + }; + /** + * @brief The OS inform that the Windows is now visible. + */ + public void operatingSystemShow(){ + postAction((context) -> { + /* + Application> appl = _context.getApplication(); + if (appl == null) { + return; + } + appl.onKeyboard(_special, + _type, + _char, + _state); + */ + Log.todo("SHOW ... "); + }); + } + /** + * @brief The Application request that the Windows will be visible. + */ + public void show(){ + Log.info("show: NOT implemented ..."); + } + /** + * @brief Redraw all the windows + */ + public void forceRedrawAll() { + if (this.application == null) { + return; + } + this.application.onResize(this.windowsSize); + } + /** + * @brief display the virtal keyboard (for touch system only) + */ + public void keyboardShow(){ + Log.info("keyboardShow: NOT implemented ..."); + } + /** + * @brief Hide the virtal keyboard (for touch system only) + */ + public void keyboardHide(){ + Log.info("keyboardHide: NOT implemented ..."); + } + + /** + * @brief Inform the Gui that we want to have a copy of the clipboard + * @param _clipboardID ID of the clipboard (STD/SELECTION) only apear here + */ + public void clipBoardGet( ClipboardList clipboardID){ + // just transmit an event , we have the data in the system + operatingSystemClipBoardArrive(clipboardID); + } + /** + * @brief Inform the Gui that we are the new owner of the clipboard + * @param _clipboardID ID of the clipboard (STD/SELECTION) only apear here + */ + public void clipBoardSet( ClipboardList clipboardID){ + // nothing to do, data is already copyed in the GALE clipborad center + } + /** + * @brief Call by the OS when a clipboard arrive to US (previously requested by a widget) + * @param Id of the clipboard + */ + public void operatingSystemClipBoardArrive(ClipboardList clipboardID) { + postAction((context) -> { + Application appl = context.getApplication(); + if (appl != null) { + appl.onClipboardEvent(clipboardID); + } + }); + } + /** + * @brief set the new title of the windows + * @param title New desired title + */ + public void setTitle( String title){ + Log.info("setTitle: NOT implemented ..."); + } + /** + * @brief Open an URL on an eternal brother. + * @param _url URL to open. + */ + public void openURL( String url) { }; + /** + * @brief force the screen orientation (availlable on portable elements ... + * @param _orientation Selected orientation. + */ + public void forceOrientation(Orientation orientation) { }; + /** + * @brief get all Keyboard event from the X system (like many time use of META) + * @param _status "true" if all the event will be get, false if we want only ours. + */ + public void grabKeyboardEvents(boolean status) {} + /** + * @brief get all Mouse/Touch events from the X system + * @param _status "true" if all the event will be get, false if we want only ours. + * @param _forcedPosition the position where the mouse might be reset at every events ... + */ + public void grabPointerEvents(boolean status, Vector2f forcedPosition) { }; + public boolean isGrabPointerEvents() { return false; }; + /** + * @brief set the cursor display type. + * @param NewCursor selected new cursor. + */ + public void setCursor( Cursor newCursor) { }; + /** + * @brief set the Icon of the program + * @param _inputFile new filename icon of the current program. + */ + public void setIcon(Uri inputFile) { }; + /** + * @brief Enable or Disable the decoration on the Windows (availlable only on Desktop) + * @param _status "true" to enable decoration / false otherwise + */ + public void setWindowsDecoration(boolean status) {}; + /** + * @brief Internal API to run the processing of the event loop ... + * @return The Exit value of the program + * @note INTERNAL API + */ + public abstract int run(); + +} diff --git a/src/org/atriasoft/gale/context/Cursor.java b/src/org/atriasoft/gale/context/Cursor.java new file mode 100644 index 0000000..7df1487 --- /dev/null +++ b/src/org/atriasoft/gale/context/Cursor.java @@ -0,0 +1,25 @@ +package org.atriasoft.gale.context; + +public enum Cursor { + arrow, // this is the normal arrow ... + leftArrow, + info, + destroy, + help, + cycle, + spray, + wait, + text, + crossHair, + slideUpDown, //!< change the position (slide) vertical + slideLeftRight, //!< change the position (slide) horizontal + resizeUp, + resizeDown, + resizeLeft, + resizeRight, + cornerTopLeft, + cornerTopRight, + cornerButtomLeft, + cornerButtomRight, + none +} diff --git a/src/org/atriasoft/gale/context/LWJG_AWT/ContextLWJGLAWT.java b/src/org/atriasoft/gale/context/LWJG_AWT/ContextLWJGLAWT.java new file mode 100644 index 0000000..b9afefb --- /dev/null +++ b/src/org/atriasoft/gale/context/LWJG_AWT/ContextLWJGLAWT.java @@ -0,0 +1,618 @@ +package org.atriasoft.gale.context.LWJG_AWT; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.awt.image.MemoryImageSource; +import java.util.ArrayList; +import java.util.List; +import java.awt.Robot; + +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.gale.Application; +import org.atriasoft.gale.DisplayManagerDraw; +import org.atriasoft.gale.Fps; +import org.atriasoft.gale.context.Context; +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.internal.Log; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.awt.AWTGLCanvas; +//import org.lwjgl.Version; +//import org.lwjgl.glfw.GLFWErrorCallback; +//import org.lwjgl.glfw.GLFWVidMode; +//import org.lwjgl.opengl.GL; +//import org.lwjgl.system.MemoryStack; +import org.lwjgl.opengl.awt.GLData; + +import static org.lwjgl.opengl.GL.createCapabilities; +import static org.lwjgl.opengl.GL11.glClearColor; + +public class ContextLWJGLAWT extends Context implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { + private boolean[] inputIsPressed = new boolean[MAX_MANAGE_INPUT]; + private Vector2f decoratedWindowsSize = new Vector2f(0, 0); + private Vector2f cursorPos = new Vector2f(0, 0); + private Vector2f cursorSize = new Vector2f(0, 0); + private static final int WIDTH = 800; + private static final int HEIGHT = 600; + private static final String TITLE = "Gale basic UI"; + + private static long lastFrameTime; + private static float delta; + + private Fps fps = new Fps("Main Loop", true); + + private DisplayManagerDraw drawer = null; + private static double whellOffsetY; + private static double whellOffsetX; + private static boolean rightButtonStateDown = false; + private static boolean leftButtonStateDown = false; + private static double lastMousePositionX = 0; + private static double lastMousePositionY = 0; + private static double currentMousePositionX = 0; + private static double currentMousePositionY = 0; + + // The window handle + private long window = 0; + private KeySpecial guiKeyBoardMode = new KeySpecial(); + + // Generic UI properties + private JFrame frame; + private GLData glData; + private AWTGLCanvas canvas; + private Robot robot = null; + public ContextLWJGLAWT(Application application, String[] args) { + super(application, args); + System.out.println("Hello JOGL !"); + initWindows(); + start2ndThreadProcessing(); + } + + + public void setDrawer(DisplayManagerDraw drawer) { + this.drawer = drawer; + } + + public void unInit() { + + } + + @SuppressWarnings("serial") + private void initWindows() { + frame = new JFrame("Gale base"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setLayout(new BorderLayout()); + frame.setPreferredSize(new Dimension(800, 600)); + glData = new GLData(); + glData.samples = 4; + glData.swapInterval = 0; + frame.add(canvas = new AWTGLCanvas(glData) { + public void initGL() { + System.out.println("OpenGL version: " + effective.majorVersion + "." + effective.minorVersion + " (Profile: " + effective.profile + ")"); + createCapabilities(); + glClearColor(0.3f, 0.4f, 0.5f, 1); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + public void paintGL() { + //Log.warning("Draw ... "); + int w = getWidth(); + int h = getHeight(); + if (decoratedWindowsSize.x != w || decoratedWindowsSize.y != h) { + decoratedWindowsSize.x = w; + decoratedWindowsSize.y = h; + Rectangle bounds = canvas.getBounds(); + windowsSize.x = bounds.width; + windowsSize.y = bounds.height; + operatingSystemResize(windowsSize); + } + operatingSystemDraw(true); + swapBuffers(); + } + }, BorderLayout.CENTER); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + canvas.requestFocus(); + canvas.addMouseListener(this); + canvas.addMouseMotionListener(this); + canvas.addKeyListener(this); + canvas.addMouseWheelListener(this); + frame.transferFocus(); + + lastFrameTime = getCurrentTime(); + + } + @Override + public void mouseClicked(MouseEvent e) { +// System.out.println(e.getX()); +// System.out.println(e.getY()); + Log.info("Mouse clicked:" + e.getX() + " " + e.getY()); + } + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + //Log.info("Mouse entered:" + e.getX() + " " + e.getY()); + cursorPos.x = e.getX(); + cursorPos.y = e.getY(); + operatingSystemSetInput(guiKeyBoardMode, + KeyType.mouse, + KeyStatus.enter, + 0, + cursorPos); + } + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + //Log.info("Mouse exited:" + e.getX() + " " + e.getY()); + cursorPos.x = e.getX(); + cursorPos.y = e.getY(); + operatingSystemSetInput(guiKeyBoardMode, + KeyType.mouse, + KeyStatus.leave, + 0, + cursorPos); + //this.frame.mouseMove(e, 200, 200); + } + @Override + public void mousePressed(MouseEvent e) { + Log.info("Mouse pressed:" + e.getX() + " " + e.getY()); + int button = e.getButton(); + cursorPos.x = e.getX(); + cursorPos.y = e.getY(); + if (button < MAX_MANAGE_INPUT) { + inputIsPressed[button] = true; + } + operatingSystemSetInput(guiKeyBoardMode, + KeyType.mouse, + KeyStatus.down, + button, + cursorPos); + } + @Override + public void mouseReleased(MouseEvent e) { + //Log.info("Mouse release:" + e.getX() + " " + e.getY()); +// Log.info("mouse value: GLFW_RELEASE" + action + " bt=" + button); + int button = e.getButton(); + cursorPos.x = e.getX(); + cursorPos.y = e.getY(); + if (button < MAX_MANAGE_INPUT) { + inputIsPressed[button] = false; + } + operatingSystemSetInput(guiKeyBoardMode, + KeyType.mouse, + KeyStatus.up, + button, + cursorPos); + } + + @Override + public void mouseDragged(MouseEvent e) { + //Log.error("mouse drag ... " + e); + mouseMoved(e); + } + public void mouseMoved(MouseEvent e) { + //Log.info("Mouse moved:" + e.getX() + " " + e.getY() + " " + e); + if (this.robot != null) { + Rectangle bounds = frame.getBounds(); + //Log.error(" " + bounds + " windows=" + windowsSize + " deco= " + decoratedWindowsSize); + float refPosX = bounds.x + bounds.width/2; + float refPosY = bounds.y + bounds.height/2; + if (e.getXOnScreen() == (int)refPosX + && e.getYOnScreen() == (int)refPosY) { + cursorPos.x = 0; + cursorPos.y = 0; + return; + } else { + //Log.error(" " + bounds + " windows=" + windowsSize + " deco= " + decoratedWindowsSize); + cursorPos.x = -((float)e.getXOnScreen() - refPosX); + cursorPos.y = (float)e.getYOnScreen() - refPosY; + robot.mouseMove((int)refPosX, (int)refPosY); + } + Log.info("delta moved:" + cursorPos); + } else { + // TODO use real size ... !!!! + cursorPos.x = (float)e.getX(); + cursorPos.y = cursorSize.y - (float)e.getY(); + } + // For compatibility of the Android system : + boolean findOne = false; + for (int iii=0; iii pressedKey = new ArrayList(); + + private int getUniqueIndex(KeyEvent e) { + int internalKeyValue = e.getKeyCode(); + if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) { + internalKeyValue += 100000000; + } else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) { + internalKeyValue += 200000000; + } else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD) { + internalKeyValue += 300000000; + } else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_STANDARD) { + internalKeyValue += 400000000; + } + return internalKeyValue; + } + public void keyPressed(KeyEvent e) { + int internalKeyValue = getUniqueIndex(e); + int index = pressedKey.indexOf(internalKeyValue); + if (index == -1) { + pressedKey.add(internalKeyValue); + } + keyEvent(e, true, index != -1); + } + public void keyReleased(KeyEvent e) { + int internalKeyValue = getUniqueIndex(e); + int index = pressedKey.indexOf(internalKeyValue); + if (index == -1) { + pressedKey.remove(internalKeyValue); + } + keyEvent(e, false, false); + } + public void keyEvent(KeyEvent e, boolean pressed, boolean thisIsAReapeateKey) { + //Log.info("event " + thisIsAReapeateKey + " " + e.getKeyCode() + " " + e); + boolean find = true; + KeyKeyboard keyInput = KeyKeyboard.unknow; + //Log.error("keyboard input " + e.getWhen() + " " + e.getKeyCode() + " " + e.getKeyLocation()); + switch (e.getKeyCode()) { + //case 328: // keypad + case KeyEvent.VK_UP: keyInput = KeyKeyboard.up; break; + //case 324: // keypad + case KeyEvent.VK_LEFT: keyInput = KeyKeyboard.left; break; + //case 326: // keypad + case KeyEvent.VK_RIGHT: keyInput = KeyKeyboard.right; break; + //case 323: // keypad + case KeyEvent.VK_DOWN: keyInput = KeyKeyboard.down; break; + //case 329: // keypad + case KeyEvent.VK_PAGE_UP: keyInput = KeyKeyboard.pageUp; break; + //case 323: // keypad + case KeyEvent.VK_PAGE_DOWN: keyInput = KeyKeyboard.pageDown; break; + //case 327: // keypad + case KeyEvent.VK_HOME: keyInput = KeyKeyboard.start; break; + //case 321: // keypad + case KeyEvent.VK_END: keyInput = KeyKeyboard.end; break; + case KeyEvent.VK_PRINTSCREEN:keyInput = KeyKeyboard.stopDefil; break; + case KeyEvent.VK_PAUSE: keyInput = KeyKeyboard.wait; break; + //case 320: // keypad + case KeyEvent.VK_INSERT: + keyInput = KeyKeyboard.insert; + if(pressed == false) { + if (guiKeyBoardMode.getInsert() == true) { + guiKeyBoardMode.setInsert(false); + } else { + guiKeyBoardMode.setInsert(true); + } + } + break; + //case 84: keyInput = KeyboardCenter; break; // Keypad + case KeyEvent.VK_F1: keyInput = KeyKeyboard.f1; break; + case KeyEvent.VK_F2: keyInput = KeyKeyboard.f2; break; + case KeyEvent.VK_F3: keyInput = KeyKeyboard.f3; break; + case KeyEvent.VK_F4: keyInput = KeyKeyboard.f4; break; + case KeyEvent.VK_F5: keyInput = KeyKeyboard.f5; break; + case KeyEvent.VK_F6: keyInput = KeyKeyboard.f6; break; + case KeyEvent.VK_F7: keyInput = KeyKeyboard.f7; break; + case KeyEvent.VK_F8: keyInput = KeyKeyboard.f8; break; + case KeyEvent.VK_F9: keyInput = KeyKeyboard.f9; break; + case KeyEvent.VK_F10: keyInput = KeyKeyboard.f10; break; + case KeyEvent.VK_F11: keyInput = KeyKeyboard.f11; break; + case KeyEvent.VK_F12: keyInput = KeyKeyboard.f12; break; + case KeyEvent.VK_CAPS_LOCK: + keyInput = KeyKeyboard.capLock; + guiKeyBoardMode.setCapsLock(pressed == true); + break; + case KeyEvent.VK_SHIFT: + if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) { + keyInput = KeyKeyboard.shiftLeft; guiKeyBoardMode.setShiftLeft (pressed == true); break; + } else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) { + keyInput = KeyKeyboard.shiftLeft; guiKeyBoardMode.setShiftRight (pressed == true); break; + } + case KeyEvent.VK_CONTROL: + if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) { + keyInput = KeyKeyboard.ctrlLeft; guiKeyBoardMode.setCtrlLeft (pressed == true); break; + } else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) { + keyInput = KeyKeyboard.ctrlRight; guiKeyBoardMode.setCtrlRight (pressed == true); break; + } + case KeyEvent.VK_META: + if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) { + keyInput = KeyKeyboard.metaLeft; guiKeyBoardMode.setMetaLeft (pressed == true); break; + } else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) { + keyInput = KeyKeyboard.metaRight; guiKeyBoardMode.setMetaRight (pressed == true); break; + } + case KeyEvent.VK_ALT: + keyInput = KeyKeyboard.altLeft; + guiKeyBoardMode.setAltLeft(pressed == true); + break; + case KeyEvent.VK_ALT_GRAPH: + keyInput = KeyKeyboard.altRight; + guiKeyBoardMode.setAltRight(pressed == true); + break; + case KeyEvent.VK_CONTEXT_MENU: + keyInput = KeyKeyboard.contextMenu; + break; + case KeyEvent.VK_NUM_LOCK: + keyInput = KeyKeyboard.numLock; + guiKeyBoardMode.setNumLock(pressed == true); + break; + case KeyEvent.VK_DELETE: // Suppr on keypad + find = false; + if(guiKeyBoardMode.getNumLock() == true){ + if (thisIsAReapeateKey == true) { + operatingSystemsetKeyboard(guiKeyBoardMode, + KeyKeyboard.character, + (pressed != true?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey, + '.'); + } + operatingSystemsetKeyboard(guiKeyBoardMode, + KeyKeyboard.character, + (pressed == true?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey, + '.'); + } else { + if (thisIsAReapeateKey == true) { + operatingSystemsetKeyboard(guiKeyBoardMode, + KeyKeyboard.character, + (pressed != true?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey, + (char)0x7F); + } + operatingSystemsetKeyboard(guiKeyBoardMode, + KeyKeyboard.character, + (pressed == true?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey, + (char)0x7F); + } + break; + case KeyEvent.VK_TAB: // special case for TAB + find = false; + if (thisIsAReapeateKey == true) { + operatingSystemsetKeyboard(guiKeyBoardMode, + KeyKeyboard.character, + (pressed==false?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey, + (char)0x09); + } + operatingSystemsetKeyboard(guiKeyBoardMode, + KeyKeyboard.character, + (pressed == true?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey, + (char)0x09); + break; + default: + find = false; + if (thisIsAReapeateKey == true) { + operatingSystemsetKeyboard(guiKeyBoardMode, + KeyKeyboard.character, + (pressed==false?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey, + e.getKeyChar()); + } + operatingSystemsetKeyboard(guiKeyBoardMode, + KeyKeyboard.character, + (pressed==true?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey, + e.getKeyChar()); + } + if (find == true) { + if (thisIsAReapeateKey == true) { + operatingSystemsetKeyboard(guiKeyBoardMode, + keyInput, + (pressed==false?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey); + } + operatingSystemsetKeyboard(guiKeyBoardMode, + keyInput, + (pressed == true?KeyStatus.down:KeyStatus.up), + thisIsAReapeateKey); + } + } + + public void keyTyped(KeyEvent e) { + // not needed with my model ... + //Log.info(" typed " + e.getKeyChar() + " " + e); + } + + + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + //Log.info("wheel_event : " + e); + cursorPos.x = e.getX(); + cursorPos.y = e.getY(); + if (e.getWheelRotation()<0) { + inputIsPressed[5] = true; + operatingSystemSetInput(guiKeyBoardMode, + KeyType.mouse, + KeyStatus.down, + 5, + cursorPos); + inputIsPressed[5] = false; + operatingSystemSetInput(guiKeyBoardMode, + KeyType.mouse, + KeyStatus.up, + 5, + cursorPos); + } else if (e.getWheelRotation()>0) { + inputIsPressed[4] = true; + operatingSystemSetInput(guiKeyBoardMode, + KeyType.mouse, + KeyStatus.down, + 4, + cursorPos); + inputIsPressed[4] = false; + operatingSystemSetInput(guiKeyBoardMode, + KeyType.mouse, + KeyStatus.up, + 4, + cursorPos); + } + } + public static float getFrameTimeSecconds() { + return delta; + } + + private static long getCurrentTime() { + return System.currentTimeMillis(); + } + + @Override + public int run() { + Runnable renderLoop = new Runnable() { + public void run() { +// fps.tic(); + if (!canvas.isValid()) { + System.exit(0); + return; + } + canvas.render(); +// fps.toc(); +// fps.draw(); + SwingUtilities.invokeLater(this); + } + }; + SwingUtilities.invokeLater(renderLoop); + + +// while (canvas != null && canvas.isValid()) { +// canvas.render(); +// try { +// Thread.sleep(10); +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + + // Run the rendering loop until the user has attempted to close + // the window or has pressed the ESCAPE key. +// while ( !glfwWindowShouldClose(window) ) { +// /* +// fps.tic(); +// long currentFrameTime = getCurrentTime(); +// delta = (currentFrameTime-lastFrameTime)/1000f; +// lastFrameTime = currentFrameTime; +// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer +// if (this.drawer != null) { +// fps.incrementCounter(); +// this.drawer.draw(); +// } +// lastMousePositionX = currentMousePositionX; +// lastMousePositionY = currentMousePositionY; +// whellOffsetY = 0; +// whellOffsetY = 0; +// glfwSwapBuffers(window); // swap the color buffers +// // Poll for window events. The key callback above will only be +// // invoked during this call. +// glfwPollEvents(); +// fps.toc(); +// fps.draw(); +// */ +// +// glfwSwapBuffers(window); // swap the color buffers +// glfwPollEvents(); +// /* +// if (specialEventThatNeedARedraw) { +// X11_INFO("specialEventThatNeedARedraw = " << specialEventThatNeedARedraw); +// } +// hasDisplay = operatingSystemDraw(specialEventThatNeedARedraw); +// if (hasDisplay) { +// // need to request it every time needed to have a redrawing (this can take some time if the application filter the drfaw periodicity) +// specialEventThatNeedARedraw = false; +// } +// */ +// } + //System.exit(0); + return 0; + } + /****************************************************************************************/ + @Override + public void setTitle(String title) { + this.frame.setTitle(title); + } + @Override + public void setIcon(Uri inputFile) { + + } + private void hideCursor() { + int[] pixels = new int[16 * 16]; + Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16)); + Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0), "invisiblecursor"); + frame.setCursor(transparentCursor); + } + private void showCursor() { + frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + @Override + public void grabPointerEvents(boolean _status, Vector2f _forcedPosition) { + if (_status == true) { + try { + this.robot = new Robot(); + hideCursor(); + } catch (AWTException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + this.robot = null; + showCursor(); + } + }; + @Override + public boolean isGrabPointerEvents() { return this.robot != null; }; + @Override + public void setFullScreen(boolean status){ + super.setFullScreen(status); + if (status == true) { + frame.setExtendedState(JFrame.MAXIMIZED_BOTH); + frame.setUndecorated(true); + } else { + frame.setExtendedState(JFrame.NORMAL); + frame.setUndecorated(false); + } + }; + + public static Context create(Application application, String[] arg) { + // TODO Auto-generated method stub + return new ContextLWJGLAWT(application, arg); + } + + + +} diff --git a/src/org/atriasoft/gale/event/EventEntry.java b/src/org/atriasoft/gale/event/EventEntry.java new file mode 100644 index 0000000..cc6f4d2 --- /dev/null +++ b/src/org/atriasoft/gale/event/EventEntry.java @@ -0,0 +1,50 @@ +package org.atriasoft.gale.event; + +import org.atriasoft.gale.key.KeyKeyboard; +import org.atriasoft.gale.key.KeyStatus; +import org.atriasoft.gale.key.KeySpecial; + +public class EventEntry { + private KeySpecial specialKey; //!< input key status (prevent change in time..) + private KeyKeyboard type; //!< type of hardware event + private KeyStatus status; //!< status of hardware event + private Character unicodeData; //!< Unicode data (in some case) + public EventEntry(KeySpecial specialKey, + KeyKeyboard type, + KeyStatus status, + Character charValue) { + this.type = type; + this.status = status; + this.specialKey = specialKey; + this.unicodeData = charValue; + } + public void setType(KeyKeyboard type) { + this.type = type; + } + public KeyKeyboard getType() { + return this.type; + } + public void setStatus(KeyStatus status) { + this.status = status; + } + public KeyStatus getStatus() { + return this.status; + }; + public void setSpecialKey(KeySpecial specialKey) { + this.specialKey = specialKey; + } + public KeySpecial getSpecialKey() { + return this.specialKey; + } + public void setChar(Character charValue) { + this.unicodeData = charValue; + } + public Character getChar() { + return this.unicodeData; + } + @Override + public String toString() { + return "EventEntry [type=" + type + ", status=" + status + ", unicodeData=" + + unicodeData + ", specialKey=" + specialKey + "]"; + } +} diff --git a/src/org/atriasoft/gale/event/EventInput.java b/src/org/atriasoft/gale/event/EventInput.java new file mode 100644 index 0000000..41ece79 --- /dev/null +++ b/src/org/atriasoft/gale/event/EventInput.java @@ -0,0 +1,57 @@ +package org.atriasoft.gale.event; + +import org.atriasoft.gale.key.KeyType; +import org.atriasoft.gale.key.KeyStatus; +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.gale.key.KeySpecial; + +public class EventInput { + private KeyType type; + private KeyStatus status; + private int inputId; + private Vector2f position; + private KeySpecial specialKey; //!< input key status (prevent change in time..) + public EventInput(KeyType type, KeyStatus status, int inputId, Vector2f position, KeySpecial specialKey) { + this.type = type; + this.status = status; + this.inputId = inputId; + this.position = position; + this.specialKey = specialKey; + } + public KeyType getType() { + return type; + } + public void setType(KeyType type) { + this.type = type; + } + public KeyStatus getStatus() { + return status; + } + public void setStatus(KeyStatus status) { + this.status = status; + } + public int getInputId() { + return inputId; + } + public void setInputId(int inputId) { + this.inputId = inputId; + } + public Vector2f getPosition() { + return position; + } + public void setPosition(Vector2f position) { + this.position = position; + } + public KeySpecial getSpecialKey() { + return specialKey; + } + public void setSpecialKey(KeySpecial specialKey) { + this.specialKey = specialKey; + } + @Override + public String toString() { + return "EventInput [type=" + type + ", status=" + status + ", inputId=" + inputId + ", position=" + position + + ", specialKey=" + specialKey + "]"; + } + +} diff --git a/src/org/atriasoft/gale/event/EventTime.java b/src/org/atriasoft/gale/event/EventTime.java new file mode 100644 index 0000000..265111e --- /dev/null +++ b/src/org/atriasoft/gale/event/EventTime.java @@ -0,0 +1,51 @@ +package org.atriasoft.gale.event; + +public class EventTime { + private long timeSystem; //!< Current system time (micro-second) + private long timeUpAppl; //!< Current application wake up-time (micro-second) + private long timeDelta; //!< Time from the last cycle call of the system (main appl tick) (micro-second) + private long timeDeltaCall; //!< Time from the last call (when we can manage periodic call with specifying periode) (micro-second) + public EventTime(long timeSystem, long timeUpAppl, long timeDelta, long timeDeltaCall) { + super(); + this.timeSystem = timeSystem; + this.timeUpAppl = timeUpAppl; + this.timeDelta = timeDelta; + this.timeDeltaCall = timeDeltaCall; + } + public long getTimeSystem() { + return timeSystem; + } + public void setTimeSystem(long timeSystem) { + this.timeSystem = timeSystem; + } + public long getTimeUpAppl() { + return timeUpAppl; + } + public void setTimeUpAppl(long timeUpAppl) { + this.timeUpAppl = timeUpAppl; + } + public long getTimeDelta() { + return timeDelta; + } + public float getTimeDeltaSecond() { + return (float)timeDelta*0.0000001f; + } + public void setTimeDelta(long timeDelta) { + this.timeDelta = timeDelta; + } + public long getTimeDeltaCall() { + return timeDeltaCall; + } + public float getTimeDeltaCallSecond() { + return (float)timeDeltaCall*0.0000001f; + } + public void setTimeDeltaCall(long timeDeltaCall) { + this.timeDeltaCall = timeDeltaCall; + } + @Override + public String toString() { + return "EventTime [timeSystem=" + timeSystem + "us, timeUpAppl=" + timeUpAppl + "us, timeDelta=" + timeDelta + + "us, timeDeltaCall=" + timeDeltaCall + "us]"; + } + +} diff --git a/src/org/atriasoft/gale/internal/Log.java b/src/org/atriasoft/gale/internal/Log.java new file mode 100644 index 0000000..bc4ae50 --- /dev/null +++ b/src/org/atriasoft/gale/internal/Log.java @@ -0,0 +1,60 @@ +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); + + private Log() {} + + public static void print(String data) { + if (PRINT_PRINT) + Logger.print(LIB_NAME_DRAW, data); + } + + public static void todo(String data) { + if (PRINT_TODO) + Logger.todo(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); + } + +} diff --git a/src/org/atriasoft/gale/key/KeyKeyboard.java b/src/org/atriasoft/gale/key/KeyKeyboard.java new file mode 100644 index 0000000..be06b97 --- /dev/null +++ b/src/org/atriasoft/gale/key/KeyKeyboard.java @@ -0,0 +1,50 @@ +package org.atriasoft.gale.key; + +public enum KeyKeyboard { + unknow, //!< Unknown keyboard key + character, //!< Char input is arrived ... + left, //!< Left key <-- + right, //!< Right key --> + up, //!< Up key ^ + down, //!< Down key \/ + pageUp, //!< Page Up key + pageDown, //!< page down key + start, //!< Start key + end, //!< End key + print, //!< print screen key. + stopDefil, //!< Stop display key. + wait, //!< Wait key. + insert, //!< insert key. + f1, //!< F1 key. + f2, //!< F2 key. + f3, //!< F3 key. + f4, //!< F4 key. + f5, //!< F5 key. + f6, //!< F6 key. + f7, //!< F7 key. + f8, //!< F8 key. + f9, //!< F9 key. + f10, //!< F10 key. + f11, //!< F11 key. + f12, //!< F12 key. + capLock, //!< Capital Letter Lock key. + shiftLeft, //!< Shift left key. + shiftRight, //!< Shift right key. + ctrlLeft, //!< Control left key. + ctrlRight, //!< Control right key. + metaLeft, //!< Meta left key (apple key or windows key). + metaRight, //!< Meta right key (apple key or windows key). + altLeft, //!< Alt left key. + altRight, //!< Alt right key. + contextMenu, //!< Contextual menu key. + numLock, //!< Numerical Lock key + // harware section: + volumeUp, //!< Hardware volume UP key + volumeDown, //!< Hardware volume DOWN key + menu, //!< Hardware Menu key + camera, //!< Hardware Camera key + home, //!< Hardware Home key + power, //!< Hardware Power key + back //!< Hardware Back key + +} diff --git a/src/org/atriasoft/gale/key/KeySpecial.java b/src/org/atriasoft/gale/key/KeySpecial.java new file mode 100644 index 0000000..63e9f6e --- /dev/null +++ b/src/org/atriasoft/gale/key/KeySpecial.java @@ -0,0 +1,304 @@ +package org.atriasoft.gale.key; + +public class KeySpecial { + private boolean valueCapLock = false; + private boolean valueShiftLeft = false; + private boolean valueShiftRight = false; + private boolean valueCtrlLeft = false; + private boolean valueCtrlRight = false; + private boolean valueMetaLeft = false; + private boolean valueMetaRight = false; + private boolean valueAltLeft = false; + private boolean valueAltRight = false; + private boolean valueNumLock = false; + private boolean valueInsert = false; + /** + * @brief Main ructor + */ + public KeySpecial() { + + } + /** + * @brief get the current CapLock Status + * @return The CapLock value + */ + public boolean getCapsLock() { + return valueCapLock; + } + /** + * @brief set the current CapLock Status + * @param value The new CapLock value + */ + public void setCapsLock(boolean value) { + valueCapLock = value; + } + /** + * @brief Get the current Shift key status + * @return The Shift value + */ + public boolean getShift() { + return valueShiftLeft || valueShiftRight; + } + /** + * @brief Get the current Shift left key status + * @return The Shift value + */ + public boolean getShiftLeft() { + return valueShiftLeft; + } + /** + * @brief Get the current Shift right key status + * @return The Shift value + */ + public boolean getShiftRight() { + return valueShiftRight; + } + /** + * @brief Set the current Shift left key status + * @param value The new Shift value + */ + public void setShiftLeft(boolean value) { + valueShiftLeft = value; + } + /** + * @brief Set the current Shift right key status + * @param value The new Shift value + */ + public void setShiftRight(boolean value) { + valueShiftRight = value; + } + /** + * @brief Get the Current Control key status + * @return The Control value + */ + public boolean getCtrl() { + return valueCtrlLeft || valueCtrlRight; + } + /** + * @brief Get the Current Control left key status + * @return The Control value + */ + public boolean getCtrlLeft() { + return valueCtrlLeft; + } + /** + * @brief Get the Current Control right key status + * @return The Control value + */ + public boolean getCtrlRight() { + return valueCtrlRight; + } + /** + * @brief Set the Current Control left key status + * @param value The new Control value + */ + public void setCtrlLeft(boolean value){ + valueCtrlLeft = value; + } + /** + * @brief Set the Current Control right key status + * @param value The new Control value + */ + public void setCtrlRight(boolean value) { + valueCtrlRight = value; + } + /** + * @brief Get the current Meta key status (also named windows or apple key) + * @return The Meta value (name Windows key, apple key, command key ...) + */ + public boolean getMeta() { + return valueMetaLeft || valueMetaRight; + } + /** + * @brief Get the current Meta left key status (also named windows or apple key) + * @return The Meta value (name Windows key, apple key, command key ...) + */ + public boolean getMetaLeft() { + return valueMetaLeft; + } + /** + * @brief Get the current Meta right key status (also named windows or apple key) + * @return The Meta value (name Windows key, apple key, command key ...) + */ + public boolean getMetaRight() { + return valueMetaRight; + } + /** + * @brief Set the current Meta left key status (also named windows or apple key) + * @param value The new Meta value (name Windows key, apple key, command key ...) + */ + public void setMetaLeft(boolean value) { + valueMetaLeft = value; + } + /** + * @brief Set the current Meta right key status (also named windows or apple key) + * @param value The new Meta value (name Windows key, apple key, command key ...) + */ + public void setMetaRight(boolean value) { + valueMetaRight = value; + } + /** + * @brief Get the current Alt key status + * @return The Alt value + */ + public boolean getAlt() { + return valueAltLeft || valueAltRight; + } + /** + * @brief Get the current Alt left key status + * @return The Alt value + */ + public boolean getAltLeft() { + return valueAltLeft; + } + /** + * @brief Get the current Alt right key status (alt-gr) + * @return The Alt value + */ + public boolean getAltRight() { + return valueAltRight; + } + /** + * @brief Set the current Alt left key status + * @param value The new Alt value + */ + public void setAltLeft(boolean value) { + valueAltLeft = value; + } + /** + * @brief Set the current Alt right key status (alt-gr) + * @param value The new Alt value + */ + public void setAltRight(boolean value) { + valueAltRight = value; + } + /** + * @brief Get the current Alt-Gr key status + * @return The Alt-gr value (does not exist on MacOs) + */ + public boolean getAltGr() { + return getAltRight(); + } + /** + * @brief Set the current Alt-Gr key status + * @param value The new Alt-gr value (does not exist on MacOs) + */ + public void setAltGr(boolean value) { + setAltRight(value); + } + /** + * @brief Get the current Ver-num key status + * @return The Numerical Lock value + */ + public boolean getNumLock() { + return valueNumLock; + } + /** + * @brief Set the current Ver-num key status + * @param value The new Numerical Lock value + */ + public void setNumLock(boolean value) { + valueNumLock = value; + } + /** + * @brief Get the current Intert key status + * @return The Insert value + */ + public boolean getInsert() { + return valueInsert; + } + /** + * @brief Set the current Intert key status + * @param value The new Insert value + */ + public void setInsert(boolean value) { + valueInsert = value; + } + /** + * @brief Update the internal value with the input moving key. + * @param move Moving key. + * @param isDown The key is pressed or not. + */ + public void update(KeyKeyboard move, boolean isDown) { + switch (move) { + case insert: + setInsert(isDown); + break; + case capLock: + setCapsLock(isDown); + break; + case shiftLeft: + setShiftLeft(isDown); + break; + case shiftRight: + setShiftRight(isDown); + break; + case ctrlLeft: + setCtrlLeft(isDown); + break; + case ctrlRight: + setCtrlRight(isDown); + break; + case metaLeft: + setMetaLeft(isDown); + break; + case metaRight: + setMetaRight(isDown); + break; + case altLeft: + setAltLeft(isDown); + break; + case altRight: + setAltRight(isDown); + break; + case numLock: + setNumLock(isDown); + break; + default: + break; + } + } + /** + * @brief Get the value with the input moving key. + * @param move Moving key. + * @return true The key is pressed. + * @return false The key is released. + */ + public boolean get(KeyKeyboard move) { + switch (move) { + case insert: + return getInsert(); + case capLock: + return getCapsLock(); + case shiftLeft: + return getShiftLeft(); + case shiftRight: + return getShiftRight(); + case ctrlLeft: + return getCtrlLeft(); + case ctrlRight: + return getCtrlRight(); + case metaLeft: + return getMetaLeft(); + case metaRight: + return getMetaRight(); + case altLeft: + return getAltLeft(); + case altRight: + return getAltRight(); + case numLock: + return getNumLock(); + default: + break; + } + return false; + } + @Override + public String toString() { + return "Special [CapLock=" + valueCapLock + ", Shift=(" + valueShiftLeft + "," + + valueShiftRight + "), Ctrl=(" + valueCtrlLeft + "," + valueCtrlRight + + "), Meta=(" + valueMetaLeft + "," + valueMetaRight + "), Alt=(" + + valueAltLeft + "," + valueAltRight + "), NumLock=" + valueNumLock + + ", Insert=" + valueInsert + "]"; + } +} diff --git a/src/org/atriasoft/gale/key/KeyStatus.java b/src/org/atriasoft/gale/key/KeyStatus.java new file mode 100644 index 0000000..99a7135 --- /dev/null +++ b/src/org/atriasoft/gale/key/KeyStatus.java @@ -0,0 +1,20 @@ +package org.atriasoft.gale.key; + +public enum KeyStatus { + unknow, + down, // availlable on Keyboard too + downRepeate, // availlable on Keyboard too: the down event us in repeate cycle + move, + pressSingle, + pressDouble, + pressTriple, + pressQuad, + pressQuinte, + up, // availlable on Keyboard too + upRepeate, // availlable on Keyboard too: the up event us in repeate cycle + upAfter, // mouse input & finger input this appear after the single event (depending on some case...) + enter, + leave, + abort, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has lost the events) + transfert // Appeare when an event is tranfert betwwen widgets (the widget which receive this has receive the transfert of the event) +} diff --git a/src/org/atriasoft/gale/key/KeyType.java b/src/org/atriasoft/gale/key/KeyType.java new file mode 100644 index 0000000..0c25744 --- /dev/null +++ b/src/org/atriasoft/gale/key/KeyType.java @@ -0,0 +1,8 @@ +package org.atriasoft.gale.key; + +public enum KeyType { + unknow, //!< Unknow input Type + mouse, //!< Mouse type + finger, //!< Finger type + stylet, //!< Stylet type +} diff --git a/src/org/atriasoft/gale/resource/Resource.java b/src/org/atriasoft/gale/resource/Resource.java new file mode 100644 index 0000000..7818354 --- /dev/null +++ b/src/org/atriasoft/gale/resource/Resource.java @@ -0,0 +1,161 @@ +package org.atriasoft.gale.resource; + +import java.util.ArrayList; +import java.util.List; + +import org.atriasoft.etk.Uri; +import org.atriasoft.gale.internal.Log; +import org.atriasoft.gale.context.Context; + +public abstract class Resource { + protected static final String NO_NAME_RESOURCE = "---"; + protected static final int MAXRESOURCELEVEL = 5; + private static int idGenerated = 10; + protected long uid = -1; //!< unique ID definition + protected int count = 1; + protected int resourceLevel = MAXRESOURCELEVEL-1; //!< Level of the resource ==> for update priority [0..5] 0 must be update first. + protected String name = NO_NAME_RESOURCE; //!< name of the resource ... + protected boolean resourceHasBeenInit = false; //!< Know if the init function has bben called + protected List listType = new ArrayList(); + /** + * @brief generic protected contructor (use factory to create this class) + */ + protected Resource() { + this.uid = idGenerated++; + this.addResourceType("gale::Resource"); + this.resourceHasBeenInit = true; + } + protected Resource(String name) { + this.resourceHasBeenInit = true; + this.name = name; + } + protected Resource( Uri uri) { + this.resourceHasBeenInit = true; + this.name = uri.getValue(); + } + public void keep() { + this.count++; + } + public int getCount() { + return this.count; + } + public void release() { + this.count--; + if (this.count == 0) { + + } + } + public abstract void cleanUp(); + public long getId() { + return this.uid; + } + public boolean resourceHasBeenCorectlyInit() { + return this.resourceHasBeenInit; + } + /** + * @brief get the current type of the Resource + * @return the last type name of the element + */ + public String getType() { + if (this.listType.size() == 0) { + return "gale::Resource"; + } + return this.listType.get(this.listType.size()-1); + } + /** + * @brief Get the herarchic of the Resource type. + * @return descriptive string. + */ + public String getTypeDescription() { + String ret = "gale::Resource"; + for(String element : this.listType) { + ret += "|"; + ret += element; + } + return ret; + } + /** + * @brief check if the element herited from a specific type + * @param type Type to check. + * @return true if the element is compatible. + */ + public boolean isTypeCompatible( String type) { + if (type == "gale::Resource") { + return true; + } + for(String element : this.listType) { + if (type == element) { + return true; + } + } + return false; + } + /** + * @brief Add a type of the list of Object. + * @param type Type to add. + */ + protected void addResourceType(String type) { + if (type == null) { + Log.error(" try to add a type with no value..."); + return; + } + this.listType.add(type); + } + /** + * @brief get the resource name + * @return The requested name + */ + public String getName() { + return this.name; + } + /** + * @brief get the resource name + * @param name The name to set. + */ + public void setName( String name) { + this.name = name; + } + /** + * @brief Get the current resource level; + * @return value in [0..5] + */ + public int getResourceLevel() { + return this.resourceLevel; + }; + /** + * @brief Call when need to send data on the harware (openGL) + * @note This is done asynchronously with the create of the Resource. + * @return true The context is updated + * @return false The context is not updated + */ + public boolean updateContext() { + Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)"); + return true; + } + + /** + * @brief The current OpenGl context is removing ==> remove yout own system data + */ + public void removeContext() { + Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)"); + } + /** + * @brief The notification of the Context removing is too late, we have no more acces on the OpenGl context (thank you Android). + * Juste update your internal state + */ + public void removeContextToLate() { + Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)"); + } + /** + * @brief User request the reload of all resources (usefull when the file depend on DATA:GUI:xxx ... + */ + public void reload() { + Log.debug("Not set for : [" + getId() + "]" + getName() + " loaded ??? time(s)"); + } + /** + * @brief Get the current resource Manager + */ + protected static ResourceManager getManager() { + return Context.getContext().getResourcesManager(); + } +} diff --git a/src/org/atriasoft/gale/resource/ResourceColored3DObject.java b/src/org/atriasoft/gale/resource/ResourceColored3DObject.java new file mode 100644 index 0000000..f4637a6 --- /dev/null +++ b/src/org/atriasoft/gale/resource/ResourceColored3DObject.java @@ -0,0 +1,555 @@ +package org.atriasoft.gale.resource; + +import java.nio.FloatBuffer; +import java.util.ArrayList; +import java.util.List; + +import org.atriasoft.etk.Color; +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Matrix4f; +import org.atriasoft.etk.math.Vector3f; +import org.atriasoft.gale.internal.Log; +import org.atriasoft.gale.backend3d.OpenGL; +import org.lwjgl.BufferUtils; + +public class ResourceColored3DObject extends Resource { + private ResourceProgram program; + private int oGLPosition; + private int oGLColor; + private int oGLMatrixTransformation; + private int oGLMatrixProjection; + private int oGLMatrixView; + protected ResourceColored3DObject() { + super(); + addResourceType("ResourceColored3DObject"); + // get the shader resource : + this.oGLPosition = 0; + this.program = ResourceProgram.create(new Uri("DATA_EGE", "simple3D.vert"), new Uri("DATA_EGE", "simple3D.frag")); + if (this.program != null) { + this.oGLMatrixTransformation = this.program.getUniform("in_matrixTransformation"); + this.oGLMatrixProjection = this.program.getUniform("in_matrixProjection"); + this.oGLMatrixView = this.program.getUniform("in_matrixView"); + this.oGLPosition = this.program.getAttribute("in_position"); + this.oGLColor = this.program.getUniform("in_colors"); + } + } + public void draw(List vertices, + Color color, + boolean updateDepthBuffer, + boolean depthtest) { + if (vertices.size() <= 0) { + return; + } + if (this.program == null) { + Log.error("No shader ..."); + return; + } + if (true == depthtest) { + OpenGL.enable(OpenGL.Flag.flag_depthTest); + if (false == updateDepthBuffer) { + OpenGL.setDeathMask(false); + } + } + //Log.debug(" display " << this.coord.size() << " elements" ); + this.program.use(); + Matrix4f projectionMatrix = OpenGL.getMatrix(); + Matrix4f viewMatrix = OpenGL.getCameraMatrix(); + Matrix4f transformationMatrix = Matrix4f.identity(); + this.program.uniformMatrix(this.oGLMatrixView, viewMatrix); + this.program.uniformMatrix(this.oGLMatrixProjection, projectionMatrix); + this.program.uniformMatrix(this.oGLMatrixTransformation, transformationMatrix); + // color : + this.program.uniformColor(this.oGLColor, color); + // position : + FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices)); + this.program.sendAttribute(this.oGLPosition, 3, buffer, 3); + if (color.a < 1.0f) { + OpenGL.enable(OpenGL.Flag.flag_blend); + } + // Request the draw of the elements: + OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size()); + if (color.a < 1.0f) { + OpenGL.disable(OpenGL.Flag.flag_blend); + } + this.program.unUse(); + // Request the draw od the elements: + //glDrawArrays(oGLLINES, 0, vertices.size()); + //this.oGLprogram.UnUse(); + if (true == depthtest) { + if (false == updateDepthBuffer) { + OpenGL.setDeathMask(true); + } + OpenGL.disable(OpenGL.Flag.flag_depthTest); + } + } + private float[] convertInFloat(List data) { + float[] out = new float[data.size()*3]; + for (int iii=0; iii vertices, + Color color, + Matrix4f transformationMatrix, + boolean updateDepthBuffer, + boolean depthtest) { + if (vertices.size() <= 0) { + return; + } + if (this.program == null) { + Log.error("No shader ..."); + return; + } + if (true == depthtest) { + OpenGL.enable(OpenGL.Flag.flag_depthTest); + if (false == updateDepthBuffer) { + OpenGL.setDeathMask(false); + } + } + //Log.debug(" display " << this.coord.size() << " elements" ); + this.program.use(); + // set Matrix: translation/positionMatrix + Matrix4f projectionMatrix = OpenGL.getMatrix(); + Matrix4f viewMatrix = OpenGL.getCameraMatrix(); + this.program.uniformMatrix(this.oGLMatrixView, viewMatrix); + this.program.uniformMatrix(this.oGLMatrixProjection, projectionMatrix); + this.program.uniformMatrix(this.oGLMatrixTransformation, transformationMatrix); + // position : + FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices)); + this.program.sendAttribute(this.oGLPosition, 3, buffer, 3); + // color : + //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()); + if (color.a < 1.0f) { + OpenGL.disable(OpenGL.Flag.flag_blend); + } + this.program.unUse(); + if (true == depthtest) { + if (false == updateDepthBuffer) { + OpenGL.setDeathMask(true); + } + OpenGL.disable(OpenGL.Flag.flag_depthTest); + } + } + public void drawLine(List vertices, + Color color, + Matrix4f transformationMatrix, + boolean updateDepthBuffer, + boolean depthtest) { + if (vertices.size() <= 0) { + return; + } + if (this.program == null) { + Log.error("No shader ..."); + return; + } + if (true == depthtest) { + OpenGL.enable(OpenGL.Flag.flag_depthTest); + if (false == updateDepthBuffer) { + OpenGL.setDeathMask(false); + } + } + //Log.debug(" display " << this.coord.size() << " elements" ); + this.program.use(); + // set Matrix: translation/positionMatrix + Matrix4f projectionMatrix = OpenGL.getMatrix(); + Matrix4f viewMatrix = OpenGL.getCameraMatrix(); + this.program.uniformMatrix(this.oGLMatrixView, viewMatrix); + this.program.uniformMatrix(this.oGLMatrixProjection, projectionMatrix); + this.program.uniformMatrix(this.oGLMatrixTransformation, transformationMatrix); + // position : + FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices)); + this.program.sendAttribute(this.oGLPosition, 3, buffer, 3); + // color : + this.program.uniformColor(this.oGLColor, color); + if (color.a < 1.0f) { + OpenGL.enable(OpenGL.Flag.flag_blend); + } + // Request the draw od the elements: + OpenGL.drawArrays(OpenGL.RenderMode.line, 0, vertices.size()); + if (color.a < 1.0f) { + OpenGL.disable(OpenGL.Flag.flag_blend); + } + this.program.unUse(); + if (true == depthtest) { + if (false == updateDepthBuffer) { + OpenGL.setDeathMask(true); + } + OpenGL.disable(OpenGL.Flag.flag_depthTest); + } + } + public void drawCubeLine(Vector3f min, + Vector3f max, + Color color, + Matrix4f transformationMatrix, + boolean updateDepthBuffer, + boolean depthtest) { + List vertices = new ArrayList(); + vertices.add(new Vector3f(min.x, min.y,min.z)); + vertices.add(new Vector3f(max.x, min.y,min.z)); + + vertices.add(new Vector3f(max.x, min.y,min.z)); + vertices.add(new Vector3f(max.x, min.y,max.z)); + + vertices.add(new Vector3f(max.x, min.y,max.z)); + vertices.add(new Vector3f(min.x, min.y,max.z)); + + vertices.add(new Vector3f(min.x, min.y,max.z)); + vertices.add(new Vector3f(min.x, min.y,min.z)); + + + vertices.add(new Vector3f(min.x, max.y,min.z)); + vertices.add(new Vector3f(max.x, max.y,min.z)); + + vertices.add(new Vector3f(max.x, max.y,min.z)); + vertices.add(new Vector3f(max.x, max.y,max.z)); + + vertices.add(new Vector3f(max.x, max.y,max.z)); + vertices.add(new Vector3f(min.x, max.y,max.z)); + + vertices.add(new Vector3f(min.x, max.y,max.z)); + vertices.add(new Vector3f(min.x, max.y,min.z)); + + + vertices.add(new Vector3f(min.x, min.y,min.z)); + vertices.add(new Vector3f(min.x, max.y,min.z)); + + vertices.add(new Vector3f(max.x, min.y,min.z)); + vertices.add(new Vector3f(max.x, max.y,min.z)); + + vertices.add(new Vector3f(max.x, min.y,max.z)); + vertices.add(new Vector3f(max.x, max.y,max.z)); + + vertices.add(new Vector3f(min.x, min.y,max.z)); + vertices.add(new Vector3f(min.x, max.y,max.z)); + drawLine(vertices, color, transformationMatrix, updateDepthBuffer, depthtest); + } + public void drawSquare(Vector3f size, + Matrix4f transformationMatrix, + Color tmpColor) { + List tmpVertices = new ArrayList(); + 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}; + Vector3f[] vertices={ new Vector3f(size.x,size.y,size.z), + new Vector3f(-size.x,size.y,size.z), + new Vector3f(size.x,-size.y,size.z), + new Vector3f(-size.x,-size.y,size.z), + new Vector3f(size.x,size.y,-size.z), + new Vector3f(-size.x,size.y,-size.z), + new Vector3f(size.x,-size.y,-size.z), + new Vector3f(-size.x,-size.y,-size.z)}; + tmpVertices.clear(); + for (int iii=0 ; iii<36 ; iii+=3) { + // normal calculation : + //btVector3 normal = (vertices[indices[iii+2]]-vertices[indices[iii]]).cross(vertices[indices[iii+1]]-vertices[indices[iii]]); + //normal.normalize (); + tmpVertices.add(vertices[indices[iii]]); + tmpVertices.add(vertices[indices[iii+1]]); + tmpVertices.add(vertices[indices[iii+2]]); + } + draw(tmpVertices, tmpColor, transformationMatrix, true, true); + } + public void drawSphere(float radius, + int lats, + int longs, + Matrix4f transformationMatrix, + Color tmpColor) { + List tmpVertices = new ArrayList(); + for(int iii=0; iii<=lats; ++iii) { + float lat0 = (float)Math.PI * (-0.5f + (float)(iii - 1) / lats); + float z0 = radius*(float)Math.sin(lat0); + float zr0 = radius*(float)Math.cos(lat0); + + float lat1 = (float)Math.PI * (-0.5f + (float)(iii) / lats); + float z1 = radius*(float)Math.sin(lat1); + float zr1 = radius*(float)Math.cos(lat1); + + for(int jjj=0; jjj tmpVertices = new ArrayList(); + // center to border (TOP) + + // center to border (TOP) + for(int jjj=0; jjj tmpVertices = new ArrayList(); + lats = (int)(lats / 2)*2; + + // center to border (TOP) + float offset = size*0.5f; + for(int iii=lats/2+1; iii<=lats; ++iii) { + float lat0 = (float)Math.PI * (-0.5f + (float)(iii - 1) / lats); + float z0 = radius*(float)Math.sin(lat0); + float zr0 = radius*(float)Math.cos(lat0); + + float lat1 = (float)Math.PI * (-0.5f + (float)(iii) / lats); + float z1 = radius*(float)Math.sin(lat1); + float zr1 = radius*(float)Math.cos(lat1); + + for(int jjj=0; jjj tmpVertices = new ArrayList(); + // center to border (TOP) + for(int jjj=0; jjj vertex, + List indice, + Matrix4f transformationMatrix, + Color tmpColor, + Vector3f offset) {// = new Vector3f(0,0,0.1f) + List tmpVertices = new ArrayList(); + for (int iii=0; iii resourceList = new ArrayList(); + private List resourceListToUpdate = new ArrayList(); + private boolean contextHasBeenRemoved = true; + private boolean exiting = false; + private static final int MAX_RESOURCE_LEVEL = 9; + /** + * @brief initialize the internal variable + */ + public ResourceManager() { + + } + /** + * @brief Uninitiamize the resource manager, free all resources previously requested + * @note when not free == > generate warning, because the segfault can appear after... + */ + //public ~Manager(); + /** + * @brief remove all resources (un-init) out of the destructor (due to the system implementation) + */ + public void unInit() { + display(); + this.resourceListToUpdate.clear(); + // remove all resources ... + for(Resource it : this.resourceList) { + Log.warning("Find a resource that is not removed : [" + it.getId() + "]" + + "='" + it.getName() + "' " + + it.getCount() + " elements"); + } + this.resourceList.clear(); + } + /** + * @brief display in the log all the resources loaded ... + */ + public void display(){ + Log.info("Resources loaded : "); + // remove all resources ... + for(Resource it : this.resourceList) { + Log.info(" [" + it.getId() + "]" + + it.getType() + + "='" + it.getName() + "' " + + it.getCount() + " elements"); + } + Log.info("Resources ---"); + } + /** + * @brief Reload all resources from files, and send there in openGL card if needed. + * @note If file is reference at THEMEXXX:///filename if the Theme change the file will reload the newOne + */ + public void reLoadResources() { + Log.info("------------- Resources re-loaded -------------"); + // remove all resources ... + for (long jjj=0; jjj 0) { + it.reload(); + Log.info(" [" + it.getId() + "]="+ it.getType()); + } + } + } + } + // TODO UNderstand why it is set here ... + //gale::requestUpdateSize(); + Log.info("------------- Resources -------------"); + } + + /** + * @brief Call by the system to send all the needed data on the graphic card chen they change ... + * @param object The resources that might be updated + */ + public void update(Resource object) { + // check if not added before + for (Resource it : this.resourceListToUpdate) { + if (it == object) { + // just prevent some double add ... + return; + } + } + // add it ... + this.resourceListToUpdate.add(object); + } + /** + * @brief Call by the system chen the openGL Context has been unexpectially removed == > This reload all the texture, VBO and other .... + */ + public void updateContext(){ + if (this.exiting == true) { + Log.error("Request update after application EXIT ..."); + return; + } + // TODO Check the number of call this ... Log.info("update open-gl context ... "); + if (this.contextHasBeenRemoved == true) { + // need to update all ... + this.contextHasBeenRemoved = false; + this.resourceListToUpdate.clear(); + synchronized(this.resourceList) { + if (this.resourceList.size() != 0) { + for (long jjj=0; jjj postponned + this.resourceListToUpdate.add(it); + } + } + } + } + } + } + } else { + List resourceListToUpdate = null; + synchronized(this.resourceListToUpdate) { + resourceListToUpdate = this.resourceListToUpdate; + this.resourceListToUpdate = new ArrayList(); + } + if (resourceListToUpdate.size() != 0) { + for (long jjj=0; jjj postponned + this.resourceListToUpdate.add(it); + } + } + } + } + } + } + } + /** + * @brief This is to inform the resources manager that we have no more openGl context ... + */ + public void contextHasBeenDestroyed() { + for (Resource it : this.resourceList) { + if (it.getCount() > 0) { + it.removeContextToLate(); + } + } + // no context preent ... + this.contextHasBeenRemoved = true; + } + /** + * @brief special end of application + */ + public void applicationExiting(){ + contextHasBeenDestroyed(); + this.exiting = true; + } + // internal API to extent eResources in extern Soft + public Resource localKeep(String filename) { + Log.verbose("KEEP (DEFAULT) : file : '" + filename + "' in " + this.resourceList.size() + " resources"); + for (Resource it : this.resourceList) { + if (it == null) { + continue; + } + if (it.getName() == null) { + continue; + } + //Log.verbose("compare : " + filename + " ==???== " + it.getName()); + if (it.getName().contentEquals(Resource.NO_NAME_RESOURCE)) { + continue; + } + if (it.getName().contentEquals(filename)) { + return it; + } + } + return null; + } + public void localAdd(Resource object) { + // add at the end if no slot is free + this.resourceList.add(object); + } + public void cleanInternalRemoved() { + //Log.info("remove object in Manager"); + updateContext(); + // TODO ... +// for (auto it(this.resourceList.begin()); it!=this.resourceList.end(); ++it) { +// if ((*it).expired() == true) { +// this.resourceList.erase(it); +// it = this.resourceList.begin(); +// } +// } + } + +} diff --git a/src/org/atriasoft/gale/resource/ResourceProgram.java b/src/org/atriasoft/gale/resource/ResourceProgram.java new file mode 100644 index 0000000..adf74a4 --- /dev/null +++ b/src/org/atriasoft/gale/resource/ResourceProgram.java @@ -0,0 +1,836 @@ +package org.atriasoft.gale.resource; + +import java.nio.FloatBuffer; +import java.util.ArrayList; +import java.util.List; + +import org.atriasoft.etk.Color; +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Matrix4f; +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.gale.internal.Log; +import org.atriasoft.gale.backend3d.OpenGL; +import org.lwjgl.BufferUtils; +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 boolean DEBUG = false; // TODO externalize this ... + private boolean exist = false; //!< the file existed + private int program = 0; //!< openGL id of the current program + private ResourceShader shaderVertex = null; + private ResourceShader shaderFragment = null; + private List elementList = new ArrayList(); //!< List of all the attribute requested by the user +// private List listOfVBOUsed = new ArrayList(); //!< retain the list of VBO used to disable it when unuse program ... +// private boolean hasTexture = false; //!< A texture has been set to the current shader +// private boolean hasTexture1 = false; //!< A texture has been set to the current shader + /** + * @brief Contructor of an opengl Program. + * @param uri Uri of the file + */ + protected ResourceProgram(Uri uriVertexShader, Uri uriFragmentShader) { + super(uriVertexShader.getValue() + "<-->" + uriFragmentShader.getValue()); + addResourceType("gale::resource::Program"); + this.resourceLevel = 1; + Log.debug("OGL : load PROGRAM '" + uriVertexShader + "' && '" + uriFragmentShader + "'"); + shaderVertex = ResourceShader.create(uriVertexShader); + if (shaderVertex == null) { + Log.error("Error while getting a specific shader filename: " + uriVertexShader); + return; + } else { + Log.debug("Add shader on program: '"+ uriFragmentShader + "'"); + } + shaderFragment = ResourceShader.create(uriFragmentShader); + if (shaderFragment == null) { + Log.error("Error while getting a specific shader filename: " + uriFragmentShader); + return; + } else { + Log.debug("Add shader on program : "+ uriFragmentShader + "frag"); + } + if (OpenGL.hasContext() == true) { + updateContext(); + } else { + getManager().update(this); + } + } + /** + * @brief Destructor, remove the current Program. + */ + @Override + public void cleanUp() { + removeContext(); + if (this.shaderFragment != null) { + this.shaderFragment.release(); + this.shaderFragment = null; + } + if (this.shaderVertex != null) { + this.shaderVertex.release(); + this.shaderVertex = null; + } + this.elementList.clear(); +// this.hasTexture = false; +// this.hasTexture1 = false; + } + /** + * @brief Check If an Id is valid in the shader or not (sometime the shader have not some attribute, then we need to display some error) + * @return idElem Id of the Attribute that might be sended. + * @return true The id is valid, false otherwise + */ + public boolean checkIdValidity(int idElem){ + if ( idElem < 0 + || idElem > this.elementList.size()) { + return false; + } + return this.elementList.get(idElem).isLinked; + } + /** + * @brief User request an attribute on this program. + * @note The attribute is send to the fragment shaders + * @param elementName Name of the requested attribute. + * @return An abstract ID of the current attribute (this value is all time availlable, even if the program will be reloaded) + */ + public int getAttribute(String elementName) { + // check if it exist previously : + for(int iii=0; iii data) { + float[] out = new float[data.size()*3]; + for (int iii=0; iii this.elementList.size()) { +// Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); +// return; +// } +// if (this.elementList.get(idElem).isLinked == false) { +// return; +// } +// FloatBuffer buffer = storeDataInFloatBuffer(data); +// //GL40.glBindVertexArray(this.elementList.get(idElem).elementId); +// Log.error("[" + this.elementList.get(idElem).name + "] send " + data.length + " element"); +// GL40.glVertexAttribPointer( +// this.elementList.get(idElem).elementId, +// data.length, +// GL40.GL_FLOAT, +// false, +// 0, +// buffer); +// //checkGlError("glVertexAttribPointer", LINE, idElem); +// GL40.glEnableVertexAttribArray(this.elementList.get(idElem).elementId); +// //checkGlError("glEnableVertexAttribArray", LINE, idElem); +// } +//// public void sendAttribute(int idElem, etk::Vector data) { +//// sendAttribute(idElem, 2/*u,v / x,y*/, data[0]); +//// } +// public void sendAttribute(int idElem, List data) { +// sendAttribute3fv(idElem, convertInFloat(data)); +// } + public void sendAttribute(int idElem, int nbElement, FloatBuffer data, int jumpBetweenSample) { + if (this.exist == false) { + return; + } + if ( idElem < 0 + || (long)idElem > this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (this.elementList.get(idElem).isLinked == false) { + return; + } + //GL40.glBindVertexArray(this.elementList.get(idElem).elementId); + //Log.error("[" + this.elementList.get(idElem).name + "] send " + 3 + " element"); + 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); + GL40.glEnableVertexAttribArray(this.elementList.get(idElem).elementId); + //checkGlError("glEnableVertexAttribArray", LINE, idElem); + } +// public void sendAttribute(int idElem, etk::Vector> data) { +// sendAttribute(idElem, 4/*r,g,b,a*/, data[0]); +// } +// public void sendAttribute(int idElem, etk::Vector data) { +// sendAttribute(idElem, 1, data[0]); +// } + /** + * @brief User request an Uniform on this program. + * @note uniform value is availlable for all the fragment shader in the program (only one value for all) + * @param elementName Name of the requested uniform. + * @return An abstract ID of the current uniform (this value is all time availlable, even if the program will be reloaded) + */ + public int getUniform(String elementName){ + // check if it exist previously : + for(int iii=0; iiithis.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformColor(this.elementList.get(idElem).elementId, value); + } + public void uniformVector(int idElem, Vector2f value) { + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformVector(this.elementList.get(idElem).elementId, value); + } + public void uniformVector(int idElem, Vector2i value) { + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformVector(this.elementList.get(idElem).elementId, value); + } + public void uniformVector(int idElem, Vector3f value) { + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformVector(this.elementList.get(idElem).elementId, value); + } + public void uniformVector(int idElem, Vector3i value) { + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformVector(this.elementList.get(idElem).elementId, value); + } + + /** + * @brief Send 1 float uniform element to the spefified ID (not send if does not really exist in the openGL program) + * @param idElem Id of the uniform that might be sended. + * @param value1 Value to send at the Uniform + */ + public void uniformFloat(int idElem, float value1){ + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformFloat(this.elementList.get(idElem).elementId, value1); + } + /** + * @brief Send 2 float uniform element to the spefified ID (not send if does not really exist in the openGL program) + * @param idElem Id of the uniform that might be sended. + * @param value1 Value to send at the Uniform + * @param value2 Value to send at the Uniform + */ + public void uniformFloat(int idElem, float value1, float value2) { + + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformFloat(this.elementList.get(idElem).elementId, value1, value2); + } + /** + * @brief Send 3 float uniform element to the spefified ID (not send if does not really exist in the openGL program) + * @param idElem Id of the uniform that might be sended. + * @param value1 Value to send at the Uniform + * @param value2 Value to send at the Uniform + * @param value3 Value to send at the Uniform + */ + public void uniformFloat(int idElem, float value1, float value2, float value3){ + + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformFloat(this.elementList.get(idElem).elementId, value1, value2, value3); + } + /** + * @brief Send 4 float uniform element to the spefified ID (not send if does not really exist in the openGL program) + * @param idElem Id of the uniform that might be sended. + * @param value1 Value to send at the Uniform + * @param value2 Value to send at the Uniform + * @param value3 Value to send at the Uniform + * @param value4 Value to send at the Uniform + */ + public void uniformFloat(int idElem, float value1, float value2, float value3, float value4) { + + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformFloat(this.elementList.get(idElem).elementId, value1, value2, value3, value4); + } + + /** + * @brief Send 1 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) + * @param idElem Id of the uniform that might be sended. + * @param value1 Value to send at the Uniform + */ + public void uniformInt(int idElem, int value1){ + + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformInt(this.elementList.get(idElem).elementId, value1); + } + /** + * @brief Send 2 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) + * @param idElem Id of the uniform that might be sended. + * @param value1 Value to send at the Uniform + * @param value2 Value to send at the Uniform + */ + public void uniformInt(int idElem, int value1, int value2) { + + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformInt(this.elementList.get(idElem).elementId, value1, value2); + } + /** + * @brief Send 3 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) + * @param idElem Id of the uniform that might be sended. + * @param value1 Value to send at the Uniform + * @param value2 Value to send at the Uniform + * @param value3 Value to send at the Uniform + */ + public void uniformInt(int idElem, int value1, int value2, int value3){ + + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformInt(this.elementList.get(idElem).elementId, value1, value2, value3); + } + /** + * @brief Send 4 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) + * @param idElem Id of the uniform that might be sended. + * @param value1 Value to send at the Uniform + * @param value2 Value to send at the Uniform + * @param value3 Value to send at the Uniform + * @param value4 Value to send at the Uniform + */ + public void uniformInt(int idElem, int value1, int value2, int value3, int value4){ + + if (this.exist == false) { + return; + } + if (idElem<0 || (long)idElem>this.elementList.size()) { + Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]"); + return; + } + if (false == this.elementList.get(idElem).isLinked) { + return; + } + OpenGL.programLoadUniformInt(this.elementList.get(idElem).elementId, value1, value2, value3, value4); + } + + /** + * @brief Request the processing of this program + */ + public void use() { + //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); + } +// /** +// * @brief set the testure Id on the specify uniform element. +// * @param idElem Id of the uniform that might be sended. +// * @param textureOpenGlID Real openGL texture ID +// */ +// public void setTexture0(int idElem, int textureOpenGlID){ +// +// if (!this.exist) { +// return; +// } +// if ( idElem < 0 +// || (long)idElem > this.elementList.size()) { +// return; +// } +// if (this.elementList.get(idElem).isLinked == false) { +// return; +// } +// OpenGL.activeTexture(GL13.GL_TEXTURE0); +// // set the textureID +// GL13.glBindTexture(GL13.GL_TEXTURE_2D, textureOpenGlID); +// // set the texture on the uniform attribute +// GL20.glUniform1i(this.elementList.get(idElem).elementId, /*GLTEXTURE*/0); +// this.hasTexture = true; +// } +// public void setTexture1(int idElem, int textureOpenGlID) { +// if (!this.exist) { +// return; +// } +// if ( idElem < 0 +// || (long)idElem > this.elementList.size()) { +// return; +// } +// if (this.elementList.get(idElem).isLinked == false) { +// return; +// } +// OpenGL.activeTexture(GL13.GL_TEXTURE1); +// // set the textureID +// GL13.glBindTexture(GL13.GL_TEXTURE_2D, textureOpenGlID); +// // set the texture on the uniform attribute +// GL20.glUniform1i(this.elementList.get(idElem).elementId, /*GLTEXTURE*/1); +// this.hasTexture1 = true; +// } + /** + * @brief Stop the processing of this program + */ + public void unUse() { + //Log.verbose("Will UN-use program : " + this.program); + + if (this.exist == false) { + return; + } +// for (Integer it : this.listOfVBOUsed) { +// GL20.glDisableVertexAttribArray(it); +// } +// this.listOfVBOUsed.clear(); + // no need to disable program == > this only generate perturbation on speed ... + OpenGL.programUse(-1); + } + + + /** + * @brief This load/reload the data in the opengl context, needed when removed previously. + */ + public boolean updateContext(){ + if (this.exist == true) { + // Do nothing == > too dangerous ... + } else { + // create the Shader + Log.debug("Create the Program ...'" + this.name + "'"); + this.program = OpenGL.programCreate(); + if (this.program < 0) { + return true; + } + // first attach vertex shader, and after fragment shader + if (this.shaderVertex != null) { + OpenGL.programAttach(this.program, this.shaderVertex.getGLID()); + } + if (this.shaderFragment != null) { + OpenGL.programAttach(this.program, this.shaderFragment.getGLID()); + } + + OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_POSITIONS, "in_position"); + 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) == false) { + Log.error("Could not compile'PROGRAM':'" + this.name + "'"); + OpenGL.programRemove(this.program); + return true; + } + // now get the old attribute requested priviously ... + long iii = 0; + for(ProgAttributeElement it : this.elementList) { + if (it.isAttribute == true) { + it.elementId = OpenGL.programGetAttributeLocation(this.program, it.name); + it.isLinked = true; + if (it.elementId<0) { + Log.warning(" {" + this.program + "}[" + iii + "] openGL::getAttributeLocation(\"" + it.name + "\") = " + it.elementId); + it.isLinked = false; + } else { + 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) { + Log.warning(" {" + this.program + "}[" + iii + "] openGL::getUniformLocation(\"" + it.name + "\") = " + it.elementId); + it.isLinked = false; + } else { + Log.debug(" {" + this.program + "}[" + iii + "] openGL::getUniformLocation(\"" + it.name + "\") = " + it.elementId); + } + } + iii++; + } + // It will existed only when all is updated... + this.exist = true; + } + return true; + } + /** + * @brief remove the data from the opengl context. + */ + public void removeContext(){ + if (this.exist == true) { + OpenGL.programRemove(this.program); + this.program = 0; + this.exist = false; + for(ProgAttributeElement it : this.elementList) { + it.elementId=0; + it.isLinked = false; + } + } + } + /** + * @brief Special android spec! It inform us that all context is removed and after notify us... + */ + public void removeContextToLate(){ + + this.exist = false; + this.program = 0; + } + /** + * @brief Relode the shader from the file. used when a request of resouces reload is done. + * @note this is really usefull when we tested the new themes or shader developpements. + */ + public void reload(){ + /* TODO ... + etk::file file(this.name, etk::FILETYPEDATA); + if (file.Exist() == false) { + Log.error("File does not Exist :"" + file + "\""); + return; + } + + int fileSize = file.size(); + if (fileSize == 0) { + 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) { + 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(); + */ + // now change the OGL context ... + removeContext(); + updateContext(); + } + + public static ResourceProgram create(Uri uriVertexShader, Uri uriFragmentShader) { + ResourceProgram resource; + Resource resource2 = null; + String name = uriVertexShader.getValue() + "<-->" + uriFragmentShader.getValue(); + if (name.isEmpty() == false && name != "---") { + resource2 = getManager().localKeep(name); + } + if (resource2 != null) { + if (resource2 instanceof ResourceProgram) { + resource2.keep(); + return (ResourceProgram)resource2; + } + Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)"); + return null; + } + resource = new ResourceProgram(uriVertexShader, uriFragmentShader); + if (resource.resourceHasBeenCorectlyInit() == false) { + Log.critical("resource Is not correctly init : ResourceProgram" ); + return null; + } + getManager().localAdd(resource); + return resource; + } + +} diff --git a/src/org/atriasoft/gale/resource/ResourceShader.java b/src/org/atriasoft/gale/resource/ResourceShader.java new file mode 100644 index 0000000..a2994b5 --- /dev/null +++ b/src/org/atriasoft/gale/resource/ResourceShader.java @@ -0,0 +1,141 @@ +package org.atriasoft.gale.resource; + +import org.atriasoft.etk.Uri; +import org.atriasoft.gale.internal.Log; +import org.atriasoft.gale.backend3d.OpenGL; +import org.atriasoft.gale.backend3d.OpenGL.ShaderType; + +public class ResourceShader extends Resource { + + private boolean exist = false; //!< The shader file existed and has been loaded + private String fileData = ""; //!< A copy of the data loaded from the file (usefull only when opengl context is removed) + private int shader = -1; //!< opengl id of this element + private final ShaderType type; //!< Type of the current shader(vertex/fragment) + private final Uri uri; + /** + * @brief Contructor of an opengl Shader + * @param filename Standard file name format. see @ref etk::FSNode + */ + protected ResourceShader(Uri uri) { + super(uri); + this.uri = uri; + addResourceType("gale::Shader"); + this.resourceLevel = 0; + Log.debug("OGL : load SHADER '" + uri + "'"); + // load data from file "all the time ..." + + if (uri.get().endsWith(".frag")) { + this.type = ShaderType.fragment; + } else if (uri.get().endsWith(".vert")) { + this.type = ShaderType.vertex; + } else { + Log.error("File does not have extention '.vert' for Vertex Shader or '.frag' for Fragment Shader. but : \"" + uri + "\""); + this.type = ShaderType.vertex; + return; + } + reload(); + } + /** + * @brief Destructor, remove the current Shader + */ + public void cleanUp() { + OpenGL.shaderRemove(this.shader); + this.exist = false; + } + /** + * @brief get the opengl reference id of this shader. + * @return The opengl id. + */ + public int getGLID() { + return this.shader; + }; + /** + * @brief get the opengl type of this shader. + * @return The type of this loaded shader. + */ + public ShaderType getShaderType() { + return this.type; + }; + /** + * @brief This load/reload the data in the opengl context, needed when removed previously. + */ + public boolean updateContext(){ + if (this.exist == true) { + // Do nothing == > too dangerous ... + } else { + this.shader = OpenGL.shaderLoad(this.uri.get(), type); + // create the Shader + if (this.shader < 0) { + return true; + } + this.exist = true; + } + return true; + } + /** + * @brief remove the data from the opengl context. + */ + public void removeContext(){ + if (true == this.exist) { + OpenGL.shaderRemove(this.shader); + this.shader = -1; + this.exist = false; + } + } + /** + * @brief Special android spec! It inform us that all context is removed and after notify us... + */ + public void removeContextToLate(){ + this.exist = false; + this.shader = -1; + } + /** + * @brief Relode the shader from the file. used when a request of resouces reload is done. + * @note this is really usefull when we tested the new themes or shader developpements. + */ + public void reload() { + Log.verbose("load shader:\n-----------------------------------------------------------------\n" + this.fileData + "\n-----------------------------------------------------------------"); + // now change the OGL context ... + if (OpenGL.hasContext() == true) { + Log.debug("OGL : load SHADER '" + this.name + "' ==> call update context (direct)"); + removeContext(); + updateContext(); + } else { + 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; + getManager().update(this); + } + } + public static ResourceShader create(Uri uriShader) { + ResourceShader resource; + Resource resource2; + String name = uriShader.getValue(); + if (name.isEmpty() == false && name != "---") { + resource2 = getManager().localKeep(name); + } else { + Log.error("Can not create a shader without a filaname"); + return null; + } + if (resource2 != null) { + if (resource2 instanceof ResourceShader) { + resource2.keep(); + return (ResourceShader)resource2; + } + Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)"); + return null; + } + resource = new ResourceShader(uriShader); + if (resource == null) { + Log.error("allocation error of a resource : " + name); + return null; + } + if (resource.resourceHasBeenCorectlyInit() == false) { + Log.critical("resource Is not correctly init : ResourceProgram" ); + return null; + } + getManager().localAdd(resource); + return resource; + } +} diff --git a/src/org/atriasoft/gale/resource/ResourceTexture.java b/src/org/atriasoft/gale/resource/ResourceTexture.java new file mode 100644 index 0000000..443e85e --- /dev/null +++ b/src/org/atriasoft/gale/resource/ResourceTexture.java @@ -0,0 +1,228 @@ +package org.atriasoft.gale.resource; + +import java.nio.ByteBuffer; + +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.etk.math.Vector2i; +import org.atriasoft.gale.internal.Log; +import org.atriasoft.gale.backend3d.OpenGL; +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; + +public class ResourceTexture extends Resource { + 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 enum TextureColorMode { + rgb, //!< red/green/blue data + rgba //!< red/green/blue/alpha data + }; + protected int texId = -1; //!< openGl textureID. + protected Vector2f endPointSize = new Vector2f(-1, -1); //!< 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 boolean loaded = false; //!< internal state of the openGl system. + // Image properties: + private ByteBuffer data = null; //!< pointer on the image data. + private Vector2i size = new Vector2i(-1,-1); //!< size of the image data. + private TextureColorMode dataColorSpace = TextureColorMode.rgb; //!< Color space of the image. + private int textureUnit = 0; // number of lines and colomns in the texture (multiple texturing in a single texture) + private String filename = ""; + /** + * @brief get the next power 2 if the input + * @param value Value that we want the next power of 2 + * @return result value + */ + private static int nextP2(int value) { + int val=1; + for (int iii=1; iii<31; iii++) { + if (value <= val) { + return val; + } + val *=2; + } + Log.critical("impossible CASE...."); + return val; + } + // Public API: + protected ResourceTexture(String filename, int textureUnit) { + super(filename + "__" + textureUnit); + this.filename = filename; + this.textureUnit = textureUnit; + addResourceType("gale::resource::Texture"); + } + protected ResourceTexture(Uri filename, int textureUnit) { + super(filename + "__" + textureUnit); + this.filename = filename.get(); + this.textureUnit = textureUnit; + addResourceType("gale::resource::Texture"); + } + protected ResourceTexture() { + super(); + addResourceType("gale::resource::Texture"); + } + public void cleanUp() { + removeContext(); + } + // Gale internal API: + @Override + public boolean updateContext() { + if (this.loaded == true) { + return true; + } + // Request a new texture at openGl : + texId = GL11.glGenTextures(); + GL13.glActiveTexture(textureUnit); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); + + // All RGB bytes are aligned to each other and each component is 1 byte + GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); + Log.info("TEXTURE: add [" + getId() + "]=" + this.size + " OGlId=" + this.texId); + if (dataColorSpace == TextureColorMode.rgb) { + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.size.x, this.size.y, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, data); + } else { + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.size.x, this.size.y, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data); + } + // generate multi-texture mapping + GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); + + // Setup the ST coordinate system + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); + + // Setup what to do when the texture has to be scaled + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); + // now the data is loaded + this.loaded = true; + return true; + } + public void removeContext() { + if (true == this.loaded) { + // Request remove texture ... + Log.info("TEXTURE: Rm [" + getId() + "] texId=" + this.texId); + // TODO Check if we are in the correct thread + GL11.glDeleteTextures(this.texId); + this.loaded = false; + } + } + public void removeContextToLate() { + this.loaded = false; + this.texId = -1; + } + public int getRendererId() { + return this.texId; + }; + public Vector2f getUsableSize() { + return this.endPointSize; + }; + public Vector2i getOpenGlSize() { + return this.size; + }; + // flush the data to send it at the openGl system + public void flush() { + // request to the manager to be call at the next update ... + getManager().update(this); + } + public void setTexture(ByteBuffer data, + Vector2i size, + TextureColorMode dataColorSpace, + int textureUnit) { + this.data = data; + this.size = size; + this.textureUnit = textureUnit; + this.endPointSize.x = (float)size.x; + this.endPointSize.y = (float)size.y; + this.dataColorSpace = dataColorSpace; + flush(); + } + public void bindForRendering(int idTexture) { + if (this.loaded == false) { + return; + } + GL13.glActiveTexture(textureIdBinding[idTexture]); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.texId); + if (dataColorSpace == TextureColorMode.rgb) { + OpenGL.enable(OpenGL.Flag.flag_cullFace); + OpenGL.enable(OpenGL.Flag.flag_back); + } + } + public void unBindForRendering() { + if (this.loaded == false) { + return; + } + if (dataColorSpace == TextureColorMode.rgb) { + OpenGL.disable(OpenGL.Flag.flag_cullFace); + OpenGL.disable(OpenGL.Flag.flag_back); + } + } + + public static ResourceTexture createFromPng(Uri uriTexture) { + return createFromPng(uriTexture, 1); + } + public static ResourceTexture createFromPng(Uri uriTexture, int textureUnit) { + ResourceTexture resource; + Resource resource2; + String name = uriTexture.getValue(); + if (name.isEmpty() == false && name != "---") { + resource2 = getManager().localKeep(name); + } else { + Log.error("Can not create a shader without a filaname"); + return null; + } + if (resource2 != null) { + if (resource2 instanceof ResourceTexture) { + resource2.keep(); + return (ResourceTexture)resource2; + } + Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)"); + return null; + } + resource = new ResourceTexture(uriTexture, textureUnit); + ImageRawData decodedData = ImageLoader.decodePngFile(uriTexture); + resource.setTexture(decodedData.getBuffer(), + new Vector2i(decodedData.getWidth(), decodedData.getHeight()), + (decodedData.isHasAlpha() == true?TextureColorMode.rgba:TextureColorMode.rgb), + textureUnit); + if (resource.resourceHasBeenCorectlyInit() == false) { + Log.critical("resource Is not correctly init : ResourceProgram" ); + return null; + } + resource.flush(); + return resource; + } + +} diff --git a/src/org/atriasoft/gale/resource/ResourceVirtualArrayObject.java b/src/org/atriasoft/gale/resource/ResourceVirtualArrayObject.java new file mode 100644 index 0000000..87a4629 --- /dev/null +++ b/src/org/atriasoft/gale/resource/ResourceVirtualArrayObject.java @@ -0,0 +1,265 @@ +package org.atriasoft.gale.resource; + +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.List; +import org.atriasoft.gale.internal.Log; +import org.atriasoft.gale.backend3d.OpenGL; +import org.atriasoft.gale.backend3d.OpenGL.RenderMode; +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 models.RawModel; + +public class ResourceVirtualArrayObject extends Resource { + private int vaoID = -1; + private boolean exist = false; //!< This data is availlable in the Graphic card + private List vbo = new ArrayList(); + float[] positions = null; + float[] colors = null; + float[] textureCoordinates = null; + float[] normals = null; + int[] indices = null; + int vertexCount = -1; + 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 void bindForRendering() { + if (exist == false) { + return; + } + GL30.glBindVertexArray(vaoID); + if (positions != null) { + GL20.glEnableVertexAttribArray(INDICE_VBO_POSITIONS); + //Log.info("unbind POSITION"); + } + if (textureCoordinates != null) { + GL20.glEnableVertexAttribArray(INDICE_VBO_TEXTURE_COORDINATES); + } + if (normals != null) { + GL20.glEnableVertexAttribArray(INDICE_VBO_NORMALS); + } + if (colors != null) { + GL20.glEnableVertexAttribArray(INDICE_VBO_COLORS); + } + } + + public void unBindForRendering() { + if (exist == false) { + return; + } + if (positions != null) { + GL20.glDisableVertexAttribArray(INDICE_VBO_POSITIONS); + } + if (textureCoordinates != null) { + GL20.glDisableVertexAttribArray(INDICE_VBO_TEXTURE_COORDINATES); + } + if (normals != null) { + GL20.glDisableVertexAttribArray(INDICE_VBO_NORMALS); + } + if (colors != null) { + GL20.glDisableVertexAttribArray(INDICE_VBO_COLORS); + } + GL30.glBindVertexArray(0); + } + + public void render(RenderMode mode) { + OpenGL.drawElements(mode, vertexCount); + } + + + private FloatBuffer storeDataInFloatBuffer(float[] data) { + FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length); + buffer.put(data); + buffer.flip(); + return buffer; + } + + private IntBuffer storeDataInIntBuffer(int[] data) { + IntBuffer buffer = BufferUtils.createIntBuffer(data.length); + buffer.put(data); + buffer.flip(); + return buffer; + } + + private void storeDataInAttributeList(int attributeNumber, int coordinateSize, float[] data) { + int vboID = GL15.glGenBuffers(); + vbo.add(vboID); + GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID); + FloatBuffer buffer = storeDataInFloatBuffer(data); + GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW); + GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0); + GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); + } + + private void bindIndicesBuffer(int[] indices) { + int vboId = GL15.glGenBuffers(); + vbo.add(vboId); + GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboId); + IntBuffer buffer = storeDataInIntBuffer(indices); + GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW); + } + + private void createVAO() { + vaoID = GL30.glGenVertexArrays(); + GL30.glBindVertexArray(vaoID); + } + private void unbindVAO() { + GL30.glBindVertexArray(0); + } + + public void loadToVAO() { + createVAO(); + if (indices != null) { + Log.info("Set indices"); + bindIndicesBuffer(indices); + } + if (positions != null) { + Log.info("Set positions"); + storeDataInAttributeList(0, 3, positions); + } + if (textureCoordinates != null) { + Log.info("Set textureCoordinates"); + storeDataInAttributeList(1, 2, textureCoordinates); + } + if (normals != null) { + Log.info("Set normals"); + storeDataInAttributeList(2, 3, normals); + } + if (colors != null) { + Log.info("Set colors"); + storeDataInAttributeList(3, 4, colors); + } + unbindVAO(); + } + /** + * @brief ructor of this VBO. + * @param accesMode Acces mode : ??? + */ + protected ResourceVirtualArrayObject(float[] positions, float[] colors, float[] textureCoordinates, float[] normals, int[] indices, int vertexCount) { + super(); + addResourceType("gale::VirtualBufferObject"); + this.resourceLevel = 3; + this.positions = positions; + this.colors = colors; + this.textureCoordinates = textureCoordinates; + this.normals = normals; + this.indices = indices; + this.vertexCount = vertexCount; + Log.debug("OGL: load VBO count"); + } + /** + * @brief Destructor of this VBO. + */ + @Override + public void cleanUp() { + removeContext(); + } + + /** + * @brief clear buffers + */ + public void clear() { + //Log.verbose(" Clear: [" + getId() + "] '" + getName() + "' (size=" + this.buffer.get(0).length + ")"); + // DO not clear the this.vbo indexed in the graphic cards ... + + } + /** + * @brief get the real openGL ID. + * @return the Ogl id reference of this VBO. + */ + public int getGLID() { + return this.vaoID; + }; + + /** + * @brief Send the data to the graphic card. + */ + public void flush() { + // request to the manager to be call at the next update ... + getManager().update(this); + Log.verbose("Request flush of VBO: [" + getId() + "] '" + getName() + "'"); + } + /** + * @brief This load/reload the data in the opengl context, needed when removed previously. + */ + public boolean updateContext() { + //Log.verbose(" Start: [" + getId() + "] '" + getName() + "' (size=" + this.indices.length + ") ********************************"); + if (this.exist == false) { + Log.debug(" ==> ALLOCATE new handle"); + // Allocate and assign a Vertex Array Object to our handle + loadToVAO(); + } + this.exist = true; + Log.verbose(" Stop: [" + getId() + "] '" + getName() + "'"); + return true; + } + /** + * @brief remove the data from the opengl context. + */ + public void removeContext() { + + if (this.exist == true) { + // OpenGL.deleteBuffers(this.vbo); + this.exist = false; + } + } + /** + * @brief Special android spec! It inform us that all context is removed and after notify us... + */ + public void removeContextToLate() { + + this.exist = false; +// for (int iii=0; iii Init APPL (END)"); + } + @Override + public void onDraw(Context context) { + this.angle += 0.01; + //Log.info("==> appl Draw ..."); + Vector2f size = getSize(); + // 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 + Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f); + OpenGL.clearColor(bgColor); + // real clear request: + OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer); + // create a local matrix environnement. + OpenGL.push(); + + Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-getAspectRatio(), getAspectRatio(), -1, 1, -50, 50); + // set internal matrix system: + OpenGL.setMatrix(tmpProjection); + if (this.oGLprogram == null) { + Log.info("No shader ..."); + return; + } + //EWOL_DEBUG(" display " + this.coord.size() + " elements" ); + this.oGLprogram.use(); + + // set Matrix : translation/positionMatrix + 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(); + this.oGLprogram.uniformMatrix(this.oGLMatrixView, viewMatrix); + this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projectionMatrix); + // Change the position for each element with the same pipeline you need to render ... + this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, transforamtionMatrix); + + // Request the draw od the elements: + this.verticesVBO.render(OpenGL.RenderMode.triangle); + + this.verticesVBO.unBindForRendering(); + this.oGLprogram.unUse(); + // Restore context of matrix + OpenGL.pop(); + this.markDrawingIsNeeded(); + } + @Override + public void onPointer(KeySpecial special, + KeyType type, + int pointerID, + Vector2f pos, + KeyStatus state) { +// Log.info("input event: type=" + type); +// Log.info(" id=" + pointerID); +// Log.info(" pos=" + pos); +// Log.info(" state=" + state); + } + @Override + public void onKeyboard( KeySpecial special, + KeyKeyboard type, + Character value, + KeyStatus state) { + Log.info("Keyboard event: special=" + special); + Log.info(" type=" + type); + Log.info(" value='" + value + "'"); + Log.info(" state=" + state); + } +} diff --git a/src/org/atriasoft/gale/test/sample1/basic.frag b/src/org/atriasoft/gale/test/sample1/basic.frag new file mode 100644 index 0000000..d290abb --- /dev/null +++ b/src/org/atriasoft/gale/test/sample1/basic.frag @@ -0,0 +1,16 @@ +#version 400 core + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +// input: +in vec4 io_color; + +// output: +out vec4 out_Color; + +void main(void) { + out_Color = io_color; +} diff --git a/src/org/atriasoft/gale/test/sample1/basic.vert b/src/org/atriasoft/gale/test/sample1/basic.vert new file mode 100644 index 0000000..00c9732 --- /dev/null +++ b/src/org/atriasoft/gale/test/sample1/basic.vert @@ -0,0 +1,21 @@ +#version 400 core + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +// Input: +in vec3 in_position; +in vec4 in_colors; +uniform mat4 in_matrixTransformation; +uniform mat4 in_matrixProjection; +uniform mat4 in_matrixView; + +// output: +out vec4 io_color; + +void main(void) { + gl_Position = in_matrixProjection * in_matrixView * in_matrixTransformation * vec4(in_position, 1.0); + f_color = in_colors; +} diff --git a/src/org/atriasoft/gale/test/sample2/Log.java b/src/org/atriasoft/gale/test/sample2/Log.java new file mode 100644 index 0000000..e682606 --- /dev/null +++ b/src/org/atriasoft/gale/test/sample2/Log.java @@ -0,0 +1,31 @@ +package org.atriasoft.gale.test.sample2; + +public class Log { + private Log() {} + private static final String LIBNAME = "Sample2"; + public static void print(String data) { + System.out.println(data); + } + public static void critical(String data) { + System.out.println("[C] " + LIBNAME + " | " + data); + System.exit(-1); + } + 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); + } +} diff --git a/src/org/atriasoft/gale/test/sample2/Main.java b/src/org/atriasoft/gale/test/sample2/Main.java new file mode 100644 index 0000000..a741fe0 --- /dev/null +++ b/src/org/atriasoft/gale/test/sample2/Main.java @@ -0,0 +1,12 @@ +package org.atriasoft.gale.test.sample2; + +import org.atriasoft.etk.Uri; +import org.atriasoft.gale.Gale; + +public class Main { + private Main() {} + public static void main(String[] args) { + Uri.setGroup("DATA", "src/org/atriasoft/gale/test/sample2/"); + Gale.run(new Sample2Application(), args); + } +} diff --git a/src/org/atriasoft/gale/test/sample2/Sample2Application.java b/src/org/atriasoft/gale/test/sample2/Sample2Application.java new file mode 100644 index 0000000..b9ec054 --- /dev/null +++ b/src/org/atriasoft/gale/test/sample2/Sample2Application.java @@ -0,0 +1,192 @@ +package org.atriasoft.gale.test.sample2; + +import org.atriasoft.etk.Color; +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Matrix4f; +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.etk.math.Vector3f; +import org.atriasoft.gale.Application; +import org.atriasoft.gale.backend3d.OpenGL; +import org.atriasoft.gale.context.Context; +import org.atriasoft.gale.resource.ResourceProgram; +import org.atriasoft.gale.resource.ResourceTexture; +import org.atriasoft.gale.resource.ResourceVirtualArrayObject; +import org.atriasoft.gale.key.KeyKeyboard; +import org.atriasoft.gale.key.KeySpecial; +import org.atriasoft.gale.key.KeyStatus; +import org.atriasoft.gale.key.KeyType; + +public class Sample2Application extends Application { + private ResourceProgram oGLprogram; + private int oGLMatrixTransformation; + private int oGLMatrixProjection; + private int oGLMatrixView; + private float angleX = 0; + private float angleY = 0; + private float angleZ = 0; + private ResourceVirtualArrayObject verticesVBO; + private ResourceTexture texture; + + + @Override + public void onCreate(Context context) { + this.canDraw = true; + setSize(new Vector2f(800, 600)); + this.oGLprogram = ResourceProgram.create(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag")); + if (this.oGLprogram != null) { + this.oGLMatrixTransformation = this.oGLprogram.getUniform("matrixTransformation"); + this.oGLMatrixProjection = this.oGLprogram.getUniform("matrixProjection"); + this.oGLMatrixView = this.oGLprogram.getUniform("matrixView"); + } + + float[] vertices = { + -0.5f,0.5f,-0.5f, + -0.5f,-0.5f,-0.5f, + 0.5f,-0.5f,-0.5f, + 0.5f,0.5f,-0.5f, + + -0.5f,0.5f,0.5f, + -0.5f,-0.5f,0.5f, + 0.5f,-0.5f,0.5f, + 0.5f,0.5f,0.5f, + + 0.5f,0.5f,-0.5f, + 0.5f,-0.5f,-0.5f, + 0.5f,-0.5f,0.5f, + 0.5f,0.5f,0.5f, + + -0.5f,0.5f,-0.5f, + -0.5f,-0.5f,-0.5f, + -0.5f,-0.5f,0.5f, + -0.5f,0.5f,0.5f, + + -0.5f,0.5f,0.5f, + -0.5f,0.5f,-0.5f, + 0.5f,0.5f,-0.5f, + 0.5f,0.5f,0.5f, + + -0.5f,-0.5f,0.5f, + -0.5f,-0.5f,-0.5f, + 0.5f,-0.5f,-0.5f, + 0.5f,-0.5f,0.5f + + }; + + 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, + 0,0, 0,1, 1,1, 1,0, + 0,0, 0,1, 1,1, 1,0, + 0,0, 0,1, 1,1, 1,0 + }; + + int[] indices = { + 0,1,3, 3,1,2, + 4,5,7, 7,5,6, + 8,9,11, 11,9,10, + 12,13,15, 15,13,14, + 16,17,19, 19,17,18, + 20,21,23, 23,21,22 + + }; + // this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=float "i"=integer + this.verticesVBO = ResourceVirtualArrayObject.create(vertices, textureCoords, null, indices); + if (this.verticesVBO == null) { + Log.error("can not instanciate VBO ..."); + return; + } + // TO facilitate some debugs we add a name of the VBO: + this.verticesVBO.setName("[VBO] of basic SAMPLE"); + // update all the VBO elements ... + this.verticesVBO.flush(); + + this.texture = ResourceTexture.createFromPng(new Uri("DATA", "tree_sample.png")); + if (this.texture == null) { + Log.error("can not instanciate Texture ..."); + return; + } + Log.info("==> Init APPL (END)"); + } + @Override + public void onDraw(Context context) { + this.angleX += 0.001; + this.angleY += 0.005; + this.angleZ += 0.01; + //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 + Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f); + OpenGL.enable(OpenGL.Flag.flag_depthTest); + OpenGL.clearColor(bgColor); + // real clear request: + OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer); + OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer); + // create a local matrix environnement. + OpenGL.push(); + + //Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-getAspectRatio(), getAspectRatio(), -1, 1, -50, 50); + Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(1.30f, getAspectRatio(), 1, 50); + // set internal matrix system: + OpenGL.setMatrix(tmpProjection); + if (this.oGLprogram == null) { + Log.info("No shader ..."); + return; + } + //EWOL_DEBUG(" display " + this.coord.size() + " elements" ); + this.oGLprogram.use(); + + // set Matrix : translation/positionMatrix + Matrix4f projectionMatrix = tmpProjection; //OpenGL.getMatrix(); + Matrix4f transforamtionMatrix = Matrix4f.identity(); + transforamtionMatrix.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-1))); + transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(1,0,0),this.angleX)); + transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,1,0),this.angleY)); + transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,0,1),this.angleZ)); + Matrix4f viewMatrix = OpenGL.getCameraMatrix().multiplyNew(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-2))); + //Matrix4f tmpMatrix = projMatrix * camMatrix; + this.verticesVBO.bindForRendering(); + this.oGLprogram.uniformMatrix(this.oGLMatrixView, viewMatrix); + this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projectionMatrix); + // Change the position for each element with the same pipeline you need to render ... + this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, transforamtionMatrix); + this.texture.bindForRendering(0); + // 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.unBindForRendering(); + this.texture.unBindForRendering(); + this.oGLprogram.unUse(); + // Restore context of matrix + OpenGL.pop(); + this.markDrawingIsNeeded(); + } + @Override + public void onPointer(KeySpecial special, + KeyType type, + int pointerID, + Vector2f pos, + KeyStatus state) { +// Log.info("input event: type=" + type); +// Log.info(" id=" + pointerID); +// Log.info(" pos=" + pos); +// Log.info(" state=" + state); + } + @Override + public void onKeyboard( KeySpecial special, + KeyKeyboard type, + Character value, + KeyStatus state) { + Log.info("Keyboard event: special=" + special); + Log.info(" type=" + type); + Log.info(" value='" + value + "'"); + Log.info(" state=" + state); + } +} diff --git a/src/org/atriasoft/gale/test/sample2/basic.frag b/src/org/atriasoft/gale/test/sample2/basic.frag new file mode 100644 index 0000000..13d2aa8 --- /dev/null +++ b/src/org/atriasoft/gale/test/sample2/basic.frag @@ -0,0 +1,17 @@ +#version 400 core + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +in vec2 io_textureCoords; + +uniform sampler2D in_textureBase; + +// output: +out vec4 out_Color; + +void main(void) { + out_Color = texture(in_textureBase, io_textureCoords); +} diff --git a/src/org/atriasoft/gale/test/sample2/basic.vert b/src/org/atriasoft/gale/test/sample2/basic.vert new file mode 100644 index 0000000..c0dcaa7 --- /dev/null +++ b/src/org/atriasoft/gale/test/sample2/basic.vert @@ -0,0 +1,21 @@ +#version 400 core + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +// Input: +in vec3 in_position; +in vec2 in_textureCoords; +uniform mat4 in_matrixTransformation; +uniform mat4 in_matrixProjection; +uniform mat4 in_matrixView; + +// output: +out vec2 io_textureCoords; + +void main(void) { + gl_Position = in_matrixProjection * in_matrixView * in_matrixTransformation * vec4(in_position, 1.0); + io_textureCoords = in_textureCoords; +} diff --git a/src/org/atriasoft/gale/test/sample2/tree_sample.png b/src/org/atriasoft/gale/test/sample2/tree_sample.png new file mode 100644 index 0000000..fbc2291 Binary files /dev/null and b/src/org/atriasoft/gale/test/sample2/tree_sample.png differ diff --git a/src/org/atriasoft/gale/tools/ImageLoader.java b/src/org/atriasoft/gale/tools/ImageLoader.java new file mode 100644 index 0000000..2118cbe --- /dev/null +++ b/src/org/atriasoft/gale/tools/ImageLoader.java @@ -0,0 +1,49 @@ +package org.atriasoft.gale.tools; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; + +import org.atriasoft.etk.Uri; + +import de.matthiasmann.twl.utils.PNGDecoder; +import de.matthiasmann.twl.utils.PNGDecoder.Format; + +public class ImageLoader { + private ImageLoader() {} + + public static ImageRawData decodePngFile(Uri filename) { + ByteBuffer buf = null; + int tWidth = 0; + int tHeight = 0; + boolean hasAlpha = false; + try { + // Open the PNG file as an InputStream + InputStream in = new FileInputStream(filename.get()); + // Link the PNG decoder to this stream + PNGDecoder decoder = new PNGDecoder(in); + // Get the width and height of the texture + tWidth = decoder.getWidth(); + tHeight = decoder.getHeight(); + hasAlpha = decoder.hasAlpha(); + // Decode the PNG file in a ByteBuffer + if (hasAlpha == true) { + buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight()); + //decoder.decodeFlipped(buf, decoder.getWidth() * 4, Format.RGBA); + decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA); + } else { + buf = ByteBuffer.allocateDirect(3 * decoder.getWidth() * decoder.getHeight()); + //decoder.decodeFlipped(buf, decoder.getWidth() * 4, Format.RGBA); + decoder.decode(buf, decoder.getWidth() * 3, Format.RGB); + } + buf.flip(); + in.close(); + } catch (IOException e) { + e.printStackTrace(); + System.err.println("try to load texture " + filename + ", didn't work"); + System.exit(-1); + } + return new ImageRawData(buf, tWidth, tHeight, hasAlpha); + } +} diff --git a/src/org/atriasoft/gale/tools/ImageRawData.java b/src/org/atriasoft/gale/tools/ImageRawData.java new file mode 100644 index 0000000..6fb0c62 --- /dev/null +++ b/src/org/atriasoft/gale/tools/ImageRawData.java @@ -0,0 +1,34 @@ +package org.atriasoft.gale.tools; + +import java.nio.ByteBuffer; + +public class ImageRawData { + + private int width; + private int height; + private ByteBuffer buffer; + private boolean hasAlpha; + + public ImageRawData(ByteBuffer buffer, int width, int height, boolean hasAlpha){ + this.buffer = buffer; + this.width = width; + this.height = height; + this.hasAlpha = hasAlpha; + } + + public int getWidth(){ + return width; + } + + public int getHeight(){ + return height; + } + + public ByteBuffer getBuffer(){ + return buffer; + } + + public boolean isHasAlpha() { + return hasAlpha; + } +} diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/test/src/test/atriasoft/gale/.keep b/test/src/test/atriasoft/gale/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/src/test/atriasoft/gale/Log.java b/test/src/test/atriasoft/gale/Log.java new file mode 100644 index 0000000..7b5ce22 --- /dev/null +++ b/test/src/test/atriasoft/gale/Log.java @@ -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); + } +} diff --git a/test/src/test/atriasoft/gale/Log2.java b/test/src/test/atriasoft/gale/Log2.java new file mode 100644 index 0000000..a7d6132 --- /dev/null +++ b/test/src/test/atriasoft/gale/Log2.java @@ -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); + } + +} diff --git a/test/src/test/atriasoft/gale/TestBasicLog.java b/test/src/test/atriasoft/gale/TestBasicLog.java new file mode 100644 index 0000000..552868f --- /dev/null +++ b/test/src/test/atriasoft/gale/TestBasicLog.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * Contributors: + * DUPIN Edouard - initial API and implementation + ******************************************************************************/ +package test.atriasoft.gale; + +import java.util.ArrayList; +import java.util.List; + +import io.scenarium.logger.Logger; + +import org.junit.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 { + + @Test + @Order(1) + public void aaFirstInitialisation() { + List args = new ArrayList<>(); + args.add("--log-level=999"); + args.add("--log-level=1"); + args.add("--log-no-color"); + args.add("--log-color"); + args.add("--log-lib=sc-log-test+6"); + args.add("--log-lib=sc-log-test/6"); + args.add("--log-lib=sc-log-test:6"); + args.add("--log-lib=sc-log-test:verbose"); + args.add("--log-lib=sc-log-test2+3"); + 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 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(); + } + +} diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..6c6aa7c --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.1.0 \ No newline at end of file