Compare commits

...

No commits in common. "main" and "gh-pages" have entirely different histories.

355 changed files with 8407 additions and 19794 deletions

64
.gitignore vendored
View File

@ -1,64 +0,0 @@
###################################
# folders
###################################
CVS
.svn
Object_*
doxygen/API/
doxygen/ALL/
###################################
# backup files
###################################
*~
*.swp
*.old
*.bck
###################################
# Compiled source #
###################################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc
tags
#ewol
out
ewol_debug
ewol_release
###################################
# Packages #
###################################
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
###################################
# Logs and databases #
###################################
*.log
*.sql
*.sqlite
###################################
# OS generated files #
###################################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db
Sources/libewol/ewol/os/AndroidAbstraction.cpp
org_ewol_EwolConstants.h

View File

@ -1,7 +1,6 @@
language: cpp
sudo: required
dist: trusty
sudo: false
branches:
only:
@ -15,9 +14,9 @@ addons:
packages:
- g++-4.9
- expect
- binutils-mingw-w64-x86-64 # 64bit MinGW
- gcc-mingw-w64-x86-64
- g++-mingw-w64-x86-64
#- binutils-mingw-w64-x86-64 # 64bit MinGW
#- gcc-mingw-w64-x86-64
#- g++-mingw-w64-x86-64
matrix:
include:
@ -27,9 +26,9 @@ matrix:
- os: linux
env: CONF=debug BUILDER=clang TARGET=Linux
compiler: clang
- os: linux
env: CONF=release BUILDER=gcc TARGET=Windows TAG=Mingw
compiler: x86_64-w64-mingw32-gcc
#- os: linux
# env: CONF=release BUILDER=gcc TARGET=Windows TAG=Mingw
# compiler: x86_64-w64-mingw32-gcc
- os: linux
env: CONF=release BUILDER=gcc TARGET=Android TAG=Android DISABLE_PACKAGE=-p
compiler: gcc
@ -76,14 +75,14 @@ before_script:
- ./ci/build_send.py --tag=$TAG --status=START;
script:
- lutin -w -j4 -C -P -t$TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE gale gale-sample; STATUS=$?
- lutin -w -j4 -C -P -t$TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE gale gale-sample-basic; STATUS=$?
- ./ci/build_send.py --tag=$TAG --status="$STATUS";
after_script:
- if [ "$GCOV" != "" ]; then
./ci/warning_send.py --find-path ./out/Linux_x86_64/$CONF/build/$BUILDER/gale/;
fi
#- ./out/Linux_x86_64/$CONF/staging/$BUILDER/gale-sample-basic/gale-sample.app/bin/gale-sample --elog-level=6 | tee out_test.txt
- ./out/Linux_x86_64/$CONF/staging/$BUILDER/gale-sample-basic/gale-sample-basic.app/bin/gale-sample-basic --etk-log-level=6 | tee out_test.txt
- if [ "$GCOV" != "" ]; then
./ci/test_send.py --file=out_test.txt;
lutin -C -P -t $TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF -p gale?gcov;

373
LICENSE
View File

@ -1,373 +0,0 @@
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.

View File

@ -1,98 +1,4 @@
gale
====
------------------------------
`gale` is an abtracter of the low level graphic windowing (like the SDL but in C++11)
Nothing else ...
It is designed to abstract systems
- Linux
- MacOs
- Windows
- Android
- Ios
Release (master)
----------------
[![Build Status](https://travis-ci.org/atria-soft/gale.svg?branch=master)](https://travis-ci.org/atria-soft/gale)
[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/gale.svg?branch=master)](http://atria-soft.com/ci/atria-soft/gale)
[![Test Status](http://atria-soft.com/ci/test/atria-soft/gale.svg?branch=master)](http://atria-soft.com/ci/atria-soft/gale)
[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/gale.svg?branch=master)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=master&tag=Linux)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=master&tag=MacOs)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=master&tag=Mingw)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=master&tag=Android)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=master&tag=IOs)](http://atria-soft.com/ci/atria-soft/gale)
Developement (dev)
------------------
[![Build Status](https://travis-ci.org/atria-soft/gale.svg?branch=dev)](https://travis-ci.org/atria-soft/gale)
[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/gale.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/gale)
[![Test Status](http://atria-soft.com/ci/test/atria-soft/gale.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/gale)
[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/gale.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=dev&tag=Linux)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=dev&tag=MacOs)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=dev&tag=Mingw)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=dev&tag=Android)](http://atria-soft.com/ci/atria-soft/gale)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/gale.svg?branch=dev&tag=IOs)](http://atria-soft.com/ci/atria-soft/gale)
Instructions
============
download Build system:
----------------------
sudo pip install lutin
sudo pip install pillow
need google repo:
-----------------
see: http://source.android.com/source/downloading.html#installing-repo
mkdir ~/.bin
PATH=~/.bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+x ~/.bin/repo
download the software:
----------------------
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
repo init -u git://github.com/atria-soft/manifest.git
repo sync -j8
Compile software:
-----------------
cd WORKING_DIRECTORY
lutin gale-sample-basic
License (MPL v2.0)
=====================
Copyright gale Edouard DUPIN
Licensed under the Mozilla Public License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.mozilla.org/MPL/2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# gale
(MPL v2.0) Graphic Abstraction Layer for Ewol: abstract the OpenGL/... interface and mouse/touch/keyboard for multiple system (Linux, Android, MacOs, Windows, Ios)

View File

@ -1,142 +0,0 @@
/**
* @author Edouard DUPIN, Kevin BILLONNEAU
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
package org.gale;
import android.app.Activity;
import android.service.wallpaper.WallpaperService;
import android.service.wallpaper.WallpaperService.Engine;
import android.util.Log;
public class Gale {
private int m_instanceID = -1; // local and private instance ID
private boolean m_hardKeyboardHidden = true;
public <T extends GaleCallback> Gale(T _activityInstance, int _typeApplication) {
m_instanceID = -1;
m_hardKeyboardHidden = true;
m_instanceID = EWsetJavaVirtualMachineStart(_activityInstance, _typeApplication);
Log.d("Gale", "new : " + m_instanceID);
}
public void setJavaVirtualMachineStop() {
EWsetJavaVirtualMachineStop(m_instanceID);
}
public void paramSetArchiveDir(int _mode, String _myString, String _applicationName) {
EWparamSetArchiveDir(m_instanceID, _mode, _myString, _applicationName);
}
public boolean getHardKeyboardHidden() {
return m_hardKeyboardHidden;
}
public void setHardKeyboardHidden(boolean _val) {
m_hardKeyboardHidden = _val;
}
// activity status
public void onCreate() {
EWonCreate(m_instanceID);
}
public void onStart() {
EWonStart(m_instanceID);
}
public void onReStart() {
EWonReStart(m_instanceID);
}
public void onResume() {
EWonResume(m_instanceID);
}
public void onPause() {
EWonPause(m_instanceID);
}
public void onStop() {
EWonStop(m_instanceID);
}
public void onDestroy() {
EWonDestroy(m_instanceID);
}
// set display properties :
public void displayPropertyMetrics(float _ratioX, float _ratioY) {
EWdisplayPropertyMetrics(m_instanceID, _ratioX, _ratioY);
}
// IO native function :
// Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same)
public void inputEventMotion(int _pointerID, float _x, float _y) {
EWinputEventMotion(m_instanceID, _pointerID, _x, _y);
}
public void inputEventState(int _pointerID, boolean _isDown, float _x, float _y) {
EWinputEventState(m_instanceID, _pointerID, _isDown, _x, _y);
}
// Specific for the type of input : TOOL_TYPE_MOUSE
public void mouseEventMotion(int _pointerID, float _x, float _y) {
EWmouseEventMotion(m_instanceID, _pointerID, _x, _y);
}
public void mouseEventState(int _pointerID, boolean _isDown, float _x, float _y) {
EWmouseEventState(m_instanceID, _pointerID, _isDown, _x, _y);
}
// other unknow event ...
public void unknowEvent(int _eventID) {
EWunknowEvent(m_instanceID, _eventID);
}
public void keyboardEventMove(int _type, boolean _isDown) {
EWkeyboardEventMove(m_instanceID, _type, _isDown);
}
public void keyboardEventKey(int _uniChar, boolean _isDown) {
EWkeyboardEventKey(m_instanceID, _uniChar, _isDown);
}
public boolean keyboardEventKeySystem(int _keyVal, boolean _isDown) {
return EWkeyboardEventKeySystem(m_instanceID, _keyVal, _isDown);
}
// renderer Event :
public void renderInit() {
EWrenderInit(m_instanceID);
}
public void renderResize(int _w, int _h) {
EWrenderResize(m_instanceID, _w, _h);
}
public void renderDraw() {
EWrenderDraw(m_instanceID);
}
private native <T extends GaleCallback> int EWsetJavaVirtualMachineStart(T _activityInstance, int _typeApplication);
private native void EWsetJavaVirtualMachineStop(int _instanceId);
private native void EWparamSetArchiveDir(int _instanceId, int _mode, String _myString, String _applicationName);
// activity status
private native void EWonCreate(int _instanceId);
private native void EWonStart(int _instanceId);
private native void EWonReStart(int _instanceId);
private native void EWonResume(int _instanceId);
private native void EWonPause(int _instanceId);
private native void EWonStop(int _instanceId);
private native void EWonDestroy(int _instanceId);
// set display properties :
private native void EWdisplayPropertyMetrics(int _instanceId, float _ratioX, float _ratioY);
// IO native function :
// Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same)
private native void EWinputEventMotion(int _instanceId, int _pointerID, float _x, float _y);
private native void EWinputEventState(int _instanceId, int _pointerID, boolean _isDown, float _x, float _y);
// Specific for the type of input : TOOL_TYPE_MOUSE
private native void EWmouseEventMotion(int _instanceId, int _pointerID, float _x, float _y);
private native void EWmouseEventState(int _instanceId, int _pointerID, boolean _isDown, float _x, float _y);
// other unknow event ...
private native void EWunknowEvent(int _instanceId, int _eventID);
private native void EWkeyboardEventMove(int _instanceId, int _type, boolean _isDown);
private native void EWkeyboardEventKey(int _instanceId, int _uniChar, boolean _isDown);
private native boolean EWkeyboardEventKeySystem(int _instanceId, int _keyVal, boolean _isDown);
// renderer Event :
private native void EWrenderInit(int _instanceId);
private native void EWrenderResize(int _instanceId, int _w, int _h);
private native void EWrenderDraw(int _instanceId);
}

View File

@ -1,317 +0,0 @@
/**
* @author Edouard DUPIN, Kevin BILLONNEAU
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
package org.gale;
import android.app.Activity;
import android.content.Context;
import android.Manifest;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.KeyEvent;
// For No Title :
import android.view.Window;
// For the full screen :
import android.view.WindowManager;
// for the keyboard event :
import android.view.inputmethod.InputMethodManager;
import android.Manifest;
import java.io.File;
import android.content.Context;
import android.content.res.Configuration;
// For the getting apk name :
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.util.DisplayMetrics;
import android.util.Log;
// copy past events :
import android.content.ClipboardManager;
import android.content.ClipData;
import android.net.Uri;
import android.content.Intent;
import android.content.ActivityNotFoundException;
import java.io.IOException;
//import activityRootView
import org.gale.Gale;
/**
* @brief Class :
*
*/
public abstract class GaleActivity extends Activity implements GaleCallback, GaleConstants {
private static Context m_context;
protected GaleSurfaceViewGL m_glView = null;
private Gale m_galeNative;
// clipboard section
private String tmpClipBoard; // TODO : Remove this ==> clipboard acces does not work
public static Context getAppContext() {
return GaleActivity.m_context;
}
public GaleActivity() {
// set the java evironement in the C sources :
m_galeNative = new Gale(this, GALE_APPL_TYPE_ACTIVITY);
tmpClipBoard = "";
}
protected void initApkPath(String _org, String _vendor, String _project, String _applName) {
StringBuilder sb = new StringBuilder();
sb.append(_org).append(".");
sb.append(_vendor).append(".");
sb.append(_project);
String apkFilePath = null;
ApplicationInfo appInfo = null;
PackageManager packMgmr = getPackageManager();
try {
appInfo = packMgmr.getApplicationInfo(sb.toString(), 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
throw new RuntimeException("Unable to locate assets, aborting...");
}
apkFilePath = appInfo.sourceDir;
m_galeNative.paramSetArchiveDir(0, apkFilePath, _applName);
}
@Override protected void onCreate(Bundle _savedInstanceState) {
super.onCreate(_savedInstanceState);
//setListnerToRootView();
GaleActivity.m_context = getApplicationContext();
// Load the application directory
m_galeNative.paramSetArchiveDir(1, getFilesDir().toString(), "");
m_galeNative.paramSetArchiveDir(2, getCacheDir().toString(), "");
// to enable extarnal storage: add in the manifest the restriction needed ...
//packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED;
//Gale.paramSetArchiveDir(3, getExternalCacheDir().toString(), "");
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
m_galeNative.displayPropertyMetrics(metrics.xdpi, metrics.ydpi);
// call C init ...
m_galeNative.onCreate();
// Remove the title of the current display :
requestWindowFeature(Window.FEATURE_NO_TITLE);
// set full screen Mode:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// display keyboard:
//getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
// hide keyboard:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
// create bsurface system
m_glView = new GaleSurfaceViewGL(this, m_galeNative);
setContentView(m_glView);
}
@Override protected void onStart() {
Log.w("GaleActivity", "onStart (START)");
super.onStart();
m_galeNative.onStart();
Log.w("GaleActivity", "onStart (STOP)");
}
@Override protected void onRestart() {
Log.w("GaleActivity", "onRestart (START)");
super.onRestart();
m_galeNative.onReStart();
Log.w("GaleActivity", "onRestart (STOP)");
}
@Override protected void onResume() {
Log.w("GaleActivity", "onResume (START)");
super.onResume();
m_glView.onResume();
m_galeNative.onResume();
Log.w("GaleActivity", "onResume (STOP)");
}
@Override protected void onPause() {
Log.w("GaleActivity", "onPause (START)");
super.onPause();
m_glView.onPause();
m_galeNative.onPause();
Log.w("GaleActivity", "onPause (STOP)");
}
@Override protected void onStop() {
Log.w("GaleActivity", "onStop (START)");
super.onStop();
// call C
m_galeNative.onStop();
Log.w("GaleActivity", "onStop (STOP)");
}
@Override protected void onDestroy() {
Log.w("GaleActivity", "onDestroy (START)");
super.onDestroy();
// call C
m_galeNative.onDestroy();
// Remove the java Virtual machine pointer form the C code
m_galeNative.setJavaVirtualMachineStop();
Log.w("GaleActivity", "onDestroy (STOP)");
}
@Override protected void finalize() throws Throwable {
super.finalize();
// cleanup your object here
}
@Override
public void onConfigurationChanged(Configuration _newConfig) {
Log.e("GaleActivity", "Receive event ... ");
super.onConfigurationChanged(_newConfig);
// Checks whether a hardware keyboard is available
if (_newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
m_galeNative.setHardKeyboardHidden(false);
Log.e("GaleActivity", "HARD Keyboard active = " + !m_galeNative.getHardKeyboardHidden() + " (visible)");
} else if (_newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
m_galeNative.setHardKeyboardHidden(true);
Log.e("GaleActivity", "HARD Keyboard active = " + !m_galeNative.getHardKeyboardHidden() + " (hidden)");
}
}
public void keyboardUpdate(boolean _show) {
Log.i("GaleActivity", "set keyboard status visibility :" + _show);
final InputMethodManager imm;
try {
imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
} catch(Exception e) {
Log.e("GaleActivity", "Can not get keyboard manager ...");
return;
}
Log.i("GaleActivity", "Get input manager done");
if(_show == true) {
try {
imm.showSoftInput(m_glView, InputMethodManager.SHOW_IMPLICIT);
} catch(Exception e) {
Log.e("GaleActivity", "Can not set keyboard state ... (exeption !!!!)");
}
Log.i("GaleActivity", "Display it Done");
} else {
// this is a little sutid this ==> display keyboard to be sure that it toggle in the hide state ...
try {
imm.showSoftInput(m_glView, InputMethodManager.SHOW_IMPLICIT);
} catch(Exception e) {
Log.e("GaleActivity", "Can not set keyboard state ... (exeption !!!!)");
}
Log.i("GaleActivity", "Display it Done");
try {
imm.toggleSoftInput(0 ,InputMethodManager.HIDE_IMPLICIT_ONLY + InputMethodManager.HIDE_NOT_ALWAYS);
} catch(Exception e) {
Log.e("GaleActivity", "Can not set keyboard state ... (exeption !!!!)");
}
Log.i("GaleActivity", "Toggle it Done");
}
}
public void eventNotifier(String[] _args) {
// TODO : ...
}
public void orientationUpdate(int _screenMode) {
Context localContext = getAppContext();
int result = localContext.checkCallingOrSelfPermission(Manifest.permission.SET_ORIENTATION);
if (result != PackageManager.PERMISSION_GRANTED) {
if (_screenMode == GALE_ORIENTATION_LANDSCAPE) {
//Force landscape
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
} else if (_screenMode == GALE_ORIENTATION_PORTRAIT) {
//Force portrait
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
} else {
//Force auto Rotation
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}
} else {
Log.e("GaleActivity", "Not the right 'SET_ORIENTATION' to access on the screen orientation...");
}
}
public void titleSet(String _value) {
setTitle(_value);
}
public void openURI(String _uri) {
try {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(_uri));
startActivity(myIntent);
} catch (ActivityNotFoundException e) {
Log.e("GaleActivity", "Can not request an URL");
}
}
public void stop() {
Log.w("GaleActivity", "Application stop requested (START)");
// end application is requested ...
finish();
Log.w("GaleActivity", "Application stop requested (STOP)");
}
//http://developer.android.com/guide/topics/text/copy-paste.html
public String getClipBoardString() {
return tmpClipBoard;
// TODO : Rework this it does not work
/*
// Gets a handle to the clipboard service.
ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
// If the clipboard doesn't contain data, disable the paste menu item.
// If it does contain data, decide if you can handle the data.
if (!(clipboard.hasPrimaryClip())) {
return "";
}
// Examines the item on the clipboard. If getText() does not return null, the clip item contains the
// text. Assumes that this application can only handle one item at a time.
ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
if (item == null) {
return "";
}
// Gets the clipboard as text.
String pasteData = item.getText().toString();;
// If the string contains data, then the paste operation is done
if (pasteData != null) {
return pasteData;
}
return "";
*/
}
public void setClipBoardString(String _data) {
tmpClipBoard = _data;
return;
// TODO : Rework this it does not work
/*
// Gets a handle to the clipboard service.
ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
// Creates a new text clip to put on the clipboard
ClipData clip = ClipData.newPlainText("simple text", data);
// Set the clipboard's primary clip.
clipboard.setPrimaryClip(clip);
*/
}
}

View File

@ -1,19 +0,0 @@
/**
* @author Edouard DUPIN, Kevin BILLONNEAU
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
package org.gale;
import android.util.Log;
public interface GaleCallback {
public void openURI(String _uri);
public void keyboardUpdate(boolean _show);
public void eventNotifier(String[] _args);
public void orientationUpdate(int _screenMode);
public void titleSet(String _value);
public void stop();
}

View File

@ -1,67 +0,0 @@
/**
* @author Edouard DUPIN, Kevin BILLONNEAU
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
package org.gale;
public interface GaleConstants {
public static final int GALE_SYSTEM_KEY_VOLUME_UP = 1;
public static final int GALE_SYSTEM_KEY_VOLUME_DOWN = 2;
public static final int GALE_SYSTEM_KEY_MENU = 3;
public static final int GALE_SYSTEM_KEY_CAMERA = 4;
public static final int GALE_SYSTEM_KEY_HOME = 5;
public static final int GALE_SYSTEM_KEY_POWER = 6;
// the back key is wrapped in the <esc> key to simplify PC validation ...
public static final int GALE_SYSTEM_KEY_BACK = 0x1B;
public static final int GALE_SYSTEM_KEY_DEL = 0x08;
public static final int GALE_ORIENTATION_AUTO = 0;
public static final int GALE_ORIENTATION_LANDSCAPE = 1;
public static final int GALE_ORIENTATION_PORTRAIT = 2;
public static final int GALE_APPL_TYPE_ACTIVITY = 0;
public static final int GALE_APPL_TYPE_WALLPAPER = 1;
// Key binding of the element gale::key::keyboard :
public static final int GALE_MOVE_KEY_LEFT = 2;
public static final int GALE_MOVE_KEY_RIGHT = 3;
public static final int GALE_MOVE_KEY_UP = 4;
public static final int GALE_MOVE_KEY_DOWN = 5;
public static final int GALE_MOVE_KEY_PAGE_UP = 6;
public static final int GALE_MOVE_KEY_PAGE_DOWN = 7;
public static final int GALE_MOVE_KEY_START = 8;
public static final int GALE_MOVE_KEY_END = 9;
public static final int GALE_MOVE_KEY_PRINT = 10;
public static final int GALE_MOVE_KEY_STOP_DEFIL = 11;
public static final int GALE_MOVE_KEY_WAIT = 12;
public static final int GALE_MOVE_KEY_INSERT = 13;
public static final int GALE_MOVE_KEY_F1 = 14;
public static final int GALE_MOVE_KEY_F2 = 15;
public static final int GALE_MOVE_KEY_F3 = 16;
public static final int GALE_MOVE_KEY_F4 = 17;
public static final int GALE_MOVE_KEY_F5 = 18;
public static final int GALE_MOVE_KEY_F6 = 19;
public static final int GALE_MOVE_KEY_F7 = 20;
public static final int GALE_MOVE_KEY_F8 = 21;
public static final int GALE_MOVE_KEY_F9 = 22;
public static final int GALE_MOVE_KEY_F10 = 23;
public static final int GALE_MOVE_KEY_F11 = 24;
public static final int GALE_MOVE_KEY_F12 = 25;
public static final int GALE_MOVE_KEY_CAP_LOCK = 26;
public static final int GALE_MOVE_KEY_SHIFT_LEFT = 27;
public static final int GALE_MOVE_KEY_SHIFT_RIGHT = 28;
public static final int GALE_MOVE_KEY_CTRL_LEFT = 29;
public static final int GALE_MOVE_KEY_CTRL_RIGHT = 30;
public static final int GALE_MOVE_KEY_META_LEFT = 31;
public static final int GALE_MOVE_KEY_META_RIGHT = 32;
public static final int GALE_MOVE_KEY_ALT = 33;
public static final int GALE_MOVE_KEY_ALT_GR = 34;
public static final int GALE_MOVE_KEY_CONTEXT_MENU = 35;
public static final int GALE_MOVE_KEY_NUM_LOCK = 36;
}

View File

@ -1,48 +0,0 @@
/**
* @author Edouard DUPIN, Kevin BILLONNEAU
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
package org.gale;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.os.Process;
// import the gale package :
/* no need in same package... */
//import org.gale.Gale;
import org.gale.Gale;
/**
* @brief Class :
*
*/
public class GaleRendererGL implements GLSurfaceView.Renderer
{
private Gale m_galeNative;
public GaleRendererGL(Gale _galeInstance) {
m_galeNative = _galeInstance;
}
public void onSurfaceCreated(GL10 _gl, EGLConfig _config) {
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);
m_galeNative.renderInit();
}
public void onSurfaceChanged(GL10 _gl, int _w, int _h) {
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);
m_galeNative.renderResize(_w, _h);
}
public void onDrawFrame(GL10 _gl) {
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY);
m_galeNative.renderDraw();
}
}

View File

@ -1,308 +0,0 @@
/**
* @author Edouard DUPIN, Kevin BILLONNEAU
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
package org.gale;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.KeyEvent;
import android.util.Log;
import org.gale.Gale;
/**
* @brief Class :
*
*/
public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants {
public static final int SDK_VERSION = android.os.Build.VERSION.SDK_INT;
private GaleRendererGL m_galeDrawer = null;
private boolean inputDown1 = false;
private boolean inputDown2 = false;
private boolean inputDown3 = false;
private Gale m_galeNative;
public GaleSurfaceViewGL(Context _context, Gale _galeInstance) {
// super must be first statement in constructor
super(_context);
m_galeNative = _galeInstance;
/*
List of the Android API :
Android 9.0 28 Pie
Android 8.0 - 8.1 26 Oreo
Android 7.0 - 7.1.2 24 Nougat
Android 6.0 - 6.0.1 23 Marshmallow
Android 5.0 - 5.1.1 21 LOLIPOP
Android 4.4 - 4.4.4 19 KIT-KAT
Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights
Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights
Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH
Android 3.2 13 HONEYCOMB_MR2
Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights
Android 3.0.x 11 HONEYCOMB Platform Highlights
Android 2.3.4
Android 2.3.3 10 GINGERBREAD_MR1 Platform Highlights
Android 2.3.2
Android 2.3.1
Android 2.3 9 GINGERBREAD
Android 2.2.x 8 FROYO Platform Highlights
Android 2.1.x 7 ECLAIR_MR1 Platform Highlights
Android 2.0.1 6 ECLAIR_0_1
Android 2.0 5 ECLAIR
Android 1.6 4 DONUT Platform Highlights
Android 1.5 3 CUPCAKE Platform Highlights
Android 1.1 2 BASE_1_1
Android 1.0 1 BASE
*/
// Create an OpenGL ES 2.0 context
setEGLContextClientVersion(2);
// je n'ai pas compris ...
m_galeDrawer = new GaleRendererGL(m_galeNative);
setRenderer(m_galeDrawer);
// Can get the focus ==> get keyboard from JAVA :
setFocusable(true);
setFocusableInTouchMode(true);
}
public boolean onTouchEvent(final MotionEvent _event) {
// Wrapper on input events :
int tmpActionType = _event.getAction();
if (tmpActionType == MotionEvent.ACTION_MOVE) {
final int pointerCount = _event.getPointerCount();
for (int p = 0; p < pointerCount; p++) {
if (SDK_VERSION>=14) {
final int typeOfPointer = _event.getToolType(p);
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventMotion(_event.getPointerId(p), (float)_event.getX(p), (float)_event.getY(p));
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventMotion(_event.getPointerId(p), (float)_event.getX(p), (float)_event.getY(p));
}
} else {
m_galeNative.inputEventMotion(_event.getPointerId(p), (float)_event.getX(p), (float)_event.getY(p));
}
}
} else if ( tmpActionType == MotionEvent.ACTION_POINTER_1_DOWN
|| tmpActionType == MotionEvent.ACTION_DOWN) {
if (SDK_VERSION>=14) {
final int typeOfPointer = _event.getToolType(0);
if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventState(_event.getPointerId(0), true, (float)_event.getX(0), (float)_event.getY(0));
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventState(_event.getPointerId(0), true, (float)_event.getX(0), (float)_event.getY(0));
}
} else {
m_galeNative.inputEventState(_event.getPointerId(0), true, (float)_event.getX(0), (float)_event.getY(0));
}
inputDown1 = true;
} else if (tmpActionType == MotionEvent.ACTION_POINTER_1_UP) {
if (SDK_VERSION >= 14) {
final int typeOfPointer = _event.getToolType(0);
if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
} else if (typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
}
} else {
m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
}
inputDown1 = false;
} else if (tmpActionType == MotionEvent.ACTION_POINTER_2_DOWN) {
if (SDK_VERSION>=14) {
final int typeOfPointer = _event.getToolType(1);
if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventState(_event.getPointerId(1), true, (float)_event.getX(1), (float)_event.getY(1));
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventState(_event.getPointerId(1), true, (float)_event.getX(1), (float)_event.getY(1));
}
} else {
m_galeNative.inputEventState(_event.getPointerId(1), true, (float)_event.getX(1), (float)_event.getY(1));
}
inputDown2 = true;
} else if (tmpActionType == MotionEvent.ACTION_POINTER_2_UP) {
if (SDK_VERSION>=14) {
final int typeOfPointer = _event.getToolType(1);
if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventState(_event.getPointerId(1), false, (float)_event.getX(1), (float)_event.getY(1));
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventState(_event.getPointerId(1), false, (float)_event.getX(1), (float)_event.getY(1));
}
} else {
m_galeNative.inputEventState(_event.getPointerId(1), false, (float)_event.getX(1), (float)_event.getY(1));
}
inputDown2 = false;
} else if (tmpActionType == MotionEvent.ACTION_POINTER_3_DOWN) {
if (SDK_VERSION >= 14) {
final int typeOfPointer = _event.getToolType(2);
if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventState(_event.getPointerId(2), true, (float)_event.getX(2), (float)_event.getY(2));
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventState(_event.getPointerId(2), true, (float)_event.getX(2), (float)_event.getY(2));
}
} else {
m_galeNative.inputEventState(_event.getPointerId(2), true, (float)_event.getX(2), (float)_event.getY(2));
}
inputDown3 = true;
} else if (tmpActionType == MotionEvent.ACTION_POINTER_3_UP) {
if (SDK_VERSION >= 14) {
final int typeOfPointer = _event.getToolType(2);
if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventState(_event.getPointerId(2), false, (float)_event.getX(2), (float)_event.getY(2));
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventState(_event.getPointerId(2), false, (float)_event.getX(2), (float)_event.getY(2));
}
} else {
m_galeNative.inputEventState(_event.getPointerId(2), false, (float)_event.getX(2), (float)_event.getY(2));
}
inputDown3 = false;
} else if(tmpActionType == MotionEvent.ACTION_UP){
if (inputDown1) {
if (SDK_VERSION >= 14) {
final int typeOfPointer = _event.getToolType(0);
if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
}
} else {
m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
}
inputDown1 = false;
} else if (inputDown2) {
if (SDK_VERSION >= 14) {
final int typeOfPointer = _event.getToolType(0);
if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
}
} else {
m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
}
inputDown2 = false;
} else {
if (SDK_VERSION >= 14) {
final int typeOfPointer = _event.getToolType(0);
if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
m_galeNative.mouseEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
}
} else {
m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0));
}
inputDown3 = false;
}
}
return true;
}
private boolean keyboardEvent(int keyCode, KeyEvent _event, boolean _isDown) {
int actionDone = _event.getAction();
Log.i("Surface GL", "get event : " + keyCode + " is down : " + _isDown);
switch(keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
return m_galeNative.keyboardEventKeySystem(GALE_SYSTEM_KEY_VOLUME_DOWN, _isDown);
case KeyEvent.KEYCODE_VOLUME_UP:
return m_galeNative.keyboardEventKeySystem(GALE_SYSTEM_KEY_VOLUME_UP, _isDown);
case KeyEvent.KEYCODE_MENU:
return m_galeNative.keyboardEventKeySystem(GALE_SYSTEM_KEY_MENU, _isDown);
case KeyEvent.KEYCODE_CAMERA:
return m_galeNative.keyboardEventKeySystem(GALE_SYSTEM_KEY_CAMERA, _isDown);
case KeyEvent.KEYCODE_HOME:
return m_galeNative.keyboardEventKeySystem(GALE_SYSTEM_KEY_HOME, _isDown);
case KeyEvent.KEYCODE_POWER:
return m_galeNative.keyboardEventKeySystem(GALE_SYSTEM_KEY_POWER, _isDown);
case KeyEvent.KEYCODE_BACK:
// the back key is wrapped in the <esc> key to simplify PC validation ...
return m_galeNative.keyboardEventKeySystem(GALE_SYSTEM_KEY_BACK, _isDown);
/*
m_galeNative.keyboardEventKey(GALE_SYSTEM_KEY_BACK, _isDown);
return false;
*/
case KeyEvent.KEYCODE_DEL:
m_galeNative.keyboardEventKey(GALE_SYSTEM_KEY_DEL, _isDown);
return true;
// Joystick event :
case KeyEvent.KEYCODE_DPAD_UP: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_UP, _isDown); return true;
case KeyEvent.KEYCODE_DPAD_DOWN: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_DOWN, _isDown); return true;
case KeyEvent.KEYCODE_DPAD_LEFT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_LEFT, _isDown); return true;
case KeyEvent.KEYCODE_DPAD_RIGHT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_RIGHT, _isDown); return true;
case KeyEvent.KEYCODE_PAGE_UP: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_PAGE_UP, _isDown); return true;
case KeyEvent.KEYCODE_PAGE_DOWN: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_PAGE_DOWN, _isDown); return true;
case KeyEvent.KEYCODE_MOVE_HOME: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_START, _isDown); return true;
case KeyEvent.KEYCODE_MOVE_END: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_END, _isDown); return true;
case KeyEvent.KEYCODE_SYSRQ: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_PRINT, _isDown); return true;
//case KeyEvent.: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_STOP_DEFIL, _isDown); return true;
case KeyEvent.KEYCODE_BREAK: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_WAIT, _isDown); return true;
case KeyEvent.KEYCODE_INSERT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_INSERT, _isDown); return true;
case KeyEvent.KEYCODE_F1: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F1, _isDown); return true;
case KeyEvent.KEYCODE_F2: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F2, _isDown); return true;
case KeyEvent.KEYCODE_F3: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F3, _isDown); return true;
case KeyEvent.KEYCODE_F4: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F4, _isDown); return true;
case KeyEvent.KEYCODE_F5: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F5, _isDown); return true;
case KeyEvent.KEYCODE_F6: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F6, _isDown); return true;
case KeyEvent.KEYCODE_F7: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F7, _isDown); return true;
case KeyEvent.KEYCODE_F8: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F8, _isDown); return true;
case KeyEvent.KEYCODE_F9: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F9, _isDown); return true;
case KeyEvent.KEYCODE_F10: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F10, _isDown); return true;
case KeyEvent.KEYCODE_F11: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F11, _isDown); return true;
case KeyEvent.KEYCODE_F12: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_F12, _isDown); return true;
case KeyEvent.KEYCODE_CAPS_LOCK: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_CAP_LOCK, _isDown); return true;
case KeyEvent.KEYCODE_SHIFT_LEFT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_SHIFT_LEFT, _isDown); return true;
case KeyEvent.KEYCODE_SHIFT_RIGHT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_SHIFT_RIGHT, _isDown); return true;
case KeyEvent.KEYCODE_CTRL_LEFT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_CTRL_LEFT, _isDown); return true;
case KeyEvent.KEYCODE_CTRL_RIGHT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_CTRL_RIGHT, _isDown); return true;
case KeyEvent.KEYCODE_META_LEFT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_META_LEFT, _isDown); return true;
case KeyEvent.KEYCODE_META_RIGHT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_META_RIGHT, _isDown); return true;
case KeyEvent.KEYCODE_ALT_LEFT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_ALT, _isDown); return true;
case KeyEvent.KEYCODE_ALT_RIGHT: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_ALT_GR, _isDown); return true;
case KeyEvent.KEYCODE_NUM_LOCK: m_galeNative.keyboardEventMove(GALE_MOVE_KEY_NUM_LOCK, _isDown); return true;
default:
break;
}
// key wrapping :
if ( (actionDone == KeyEvent.ACTION_DOWN)
|| (actionDone == KeyEvent.ACTION_MULTIPLE)
|| (actionDone == KeyEvent.ACTION_UP)) {
// convert the key in UniChar to prevent errors ...
int uchar = _event.getUnicodeChar();
// pb on the return methode ... in java it is like windows ...
if (uchar == '\r') {
uchar = '\n';
}
// send it to gale ...
m_galeNative.keyboardEventKey(uchar, _isDown);
return true;
}
return false;
}
public boolean onKeyDown(int _keyCode, KeyEvent _event) {
return keyboardEvent(_keyCode, _event, true);
}
public boolean onKeyUp(int _keyCode, KeyEvent _event) {
return keyboardEvent(_keyCode, _event, false);
}
}

View File

@ -1,203 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
package org.gale;
import android.app.ActivityManager;
import android.content.pm.ApplicationInfo;
import android.content.pm.ConfigurationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;
import android.os.Build;
import android.service.wallpaper.WallpaperService;
import android.util.Log;
import android.view.SurfaceHolder;
import org.gale.GaleSurfaceViewGL;
import android.view.MotionEvent;
import android.net.Uri;
import android.content.Intent;
import android.content.ActivityNotFoundException;
import org.gale.Gale;
public abstract class GaleWallpaper extends WallpaperService implements GaleCallback, GaleConstants
{
private GLEngine mGLView;
private Gale m_galeNative;
protected void initApkPath(String _org, String _vendor, String _project, String _applName) {
StringBuilder sb = new StringBuilder();
sb.append(_org).append(".");
sb.append(_vendor).append(".");
sb.append(_project);
String apkFilePath = null;
ApplicationInfo appInfo = null;
PackageManager packMgmr = getPackageManager();
try {
appInfo = packMgmr.getApplicationInfo(sb.toString(), 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
throw new RuntimeException("Unable to locate assets, aborting...");
}
apkFilePath = appInfo.sourceDir;
m_galeNative.paramSetArchiveDir(0, apkFilePath, _applName);
}
@Override public Engine onCreateEngine() {
// set the java evironement in the C sources :
m_galeNative = new Gale(this, GALE_APPL_TYPE_WALLPAPER);
// Load the application directory
m_galeNative.paramSetArchiveDir(1, getFilesDir().toString(), "");
m_galeNative.paramSetArchiveDir(2, getCacheDir().toString(), "");
// to enable extarnal storage: add in the manifest the restriction needed ...
//packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED;
//Gale.paramSetArchiveDir(3, getExternalCacheDir().toString());
//! DisplayMetrics metrics = new DisplayMetrics();
//! getWindowManager().getDefaultDisplay().getMetrics(metrics);
//! m_galeNative.displayPropertyMetrics(metrics.xdpi, metrics.ydpi);
// call C init ...
m_galeNative.onCreate();
// create bsurface system
mGLView = new GLEngine(m_galeNative);
return mGLView;
}
public class GLEngine extends Engine {
private Gale m_galeNative;
public GLEngine(Gale _galeInstance) {
m_galeNative = _galeInstance;
}
class WallpaperGLSurfaceView extends GaleSurfaceViewGL {
private static final String TAG = "WallpaperGLSurfaceView";
WallpaperGLSurfaceView(Context _context, Gale _galeInstance) {
super(_context, _galeInstance);
Log.d(TAG, "WallpaperGLSurfaceView(" + _context + ")");
}
@Override public SurfaceHolder getHolder() {
Log.d(TAG, "getHolder(): returning " + getSurfaceHolder());
return getSurfaceHolder();
}
public void onDestroy() {
Log.d(TAG, "onDestroy()");
super.onDetachedFromWindow();
}
}
private static final String TAG = "GLEngine";
private WallpaperGLSurfaceView glSurfaceView;
@Override public void onCreate(SurfaceHolder _surfaceHolder) {
Log.d(TAG, "onCreate(" + _surfaceHolder + ")");
super.onCreate(_surfaceHolder);
glSurfaceView = new WallpaperGLSurfaceView(GaleWallpaper.this, m_galeNative);
// Check if the system supports OpenGL ES 2.0.
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
if (supportsEs2 == false) {
Log.d("LiveWallpaper", "does not support board with only open GL ES 1");
return;
}
// Request an OpenGL ES 2.0 compatible context.
//setEGLContextClientVersion(2);
// On Honeycomb+ devices, this improves the performance when
// leaving and resuming the live wallpaper.
//setPreserveEGLContextOnPause(true);
}
@Override public void onTouchEvent(MotionEvent _event) {
glSurfaceView.onTouchEvent(_event);
}
@Override public void onVisibilityChanged(boolean _visible) {
Log.d(TAG, "onVisibilityChanged(" + _visible + ")");
super.onVisibilityChanged(_visible);
if (_visible == true) {
glSurfaceView.onResume();
// call C
m_galeNative.onResume();
} else {
glSurfaceView.onPause();
// call C
m_galeNative.onPause();
}
}
@Override public void onDestroy() {
Log.d(TAG, "onDestroy()");
super.onDestroy();
// call C
m_galeNative.onStop();
m_galeNative.onDestroy();
glSurfaceView.onDestroy();
}
protected void setPreserveEGLContextOnPause(boolean _preserve) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
Log.d(TAG, "setPreserveEGLContextOnPause(" + _preserve + ")");
glSurfaceView.setPreserveEGLContextOnPause(_preserve);
}
}
protected void setEGLContextClientVersion(int _version) {
Log.d(TAG, "setEGLContextClientVersion(" + _version + ")");
glSurfaceView.setEGLContextClientVersion(_version);
}
}
public void keyboardUpdate(boolean _show) {
// never display keyboard on wallpaer...
Log.d("GaleCallback", "KEABOARD UPDATE is not implemented ...");
}
public void eventNotifier(String[] _args) {
// just for the test ...
Log.d("GaleCallback", "EVENT NOTIFIER is not implemented ...");
}
public void orientationUpdate(int _screenMode) {
Log.d("GaleCallback", "SET ORIENTATION is not implemented ...");
}
public void titleSet(String _value) {
// no title in the wallpaper ...
Log.d("GaleCallback", "SET TITLE is not implemented ...");
}
public void openURI(String _uri) {
try {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(_uri));
startActivity(myIntent);
} catch (ActivityNotFoundException e) {
Log.e("GaleActivity", "Can not request an URL");
}
}
public void stop() {
Log.d("GaleCallback", "STOP is not implemented ...");
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -1 +0,0 @@
MR Edouard DUPIN <yui.heero@gmail.com>

BIN
bc_s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

BIN
bdwn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
closed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

377
customdoxygen.css Normal file
View File

@ -0,0 +1,377 @@
#navrow1, #navrow2, #navrow3, #navrow4, #navrow5{
border-bottom: 1px solid #EEEEEE;
}
.adjust-right {
margin-left: 30px !important;
font-size: 1.15em !important;
}
.navbar{
border: 0px solid #222 !important;
}
/* Sticky footer styles
-------------------------------------------------- */
html,
body {
counter-reset: h1counter;
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
h1, .h1, h2, .h2, h3, .h3{
font-weight: bold !important;
}
h1:before {
content: counter(h1counter) ".\0000a0\0000a0";
counter-increment: h1counter;
counter-reset: h2counter;
}
h2:before {
content: counter(h1counter) "." counter(h2counter) ".\0000a0\0000a0";
counter-increment: h2counter;
counter-reset: h3counter;
}
h3:before {
content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) ".\0000a0\0000a0";
counter-increment: h3counter;
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto;
/* Negative indent footer by its height */
margin: 0 auto -60px;
/* Pad bottom by footer height */
padding: 0 0 60px;
}
/* Set the fixed height of the footer here */
#footer {
font-size: 0.9em;
padding: 8px 0px;
background-color: #f5f5f5;
}
.footer-row {
line-height: 44px;
}
#footer > .container {
padding-left: 15px;
padding-right: 15px;
}
.footer-follow-icon {
margin-left: 3px;
text-decoration: none !important;
}
.footer-follow-icon img {
width: 20px;
}
.footer-link {
padding-top: 5px;
display: inline-block;
color: #999999;
text-decoration: none;
}
.footer-copyright {
text-align: center;
}
@media (min-width: 992px) {
.footer-row {
text-align: left;
}
.footer-icons {
text-align: right;
}
}
@media (max-width: 991px) {
.footer-row {
text-align: center;
}
.footer-icons {
text-align: center;
}
}
/* DOXYGEN Code Styles
----------------------------------- */
a.qindex {
font-weight: bold;
}
a.qindexHL {
font-weight: bold;
background-color: #9CAFD4;
color: #ffffff;
border: 1px double #869DCA;
}
.contents a.qindexHL:visited {
color: #ffffff;
}
a.code, a.code:visited, a.line, a.line:visited {
color: #4665A2;
}
a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited {
color: #4665A2;
}
/* @end */
dl.el {
margin-left: -1cm;
}
pre.fragment {
border: 1px solid #C4CFE5;
background-color: #FBFCFD;
padding: 4px 6px;
margin: 4px 8px 4px 2px;
overflow: auto;
word-wrap: break-word;
font-size: 9pt;
line-height: 125%;
font-family: monospace, fixed;
font-size: 105%;
}
div.fragment {
padding: 4px 6px;
margin: 4px 8px 4px 2px;
border: 1px solid #C4CFE5;
}
div.line {
font-family: monospace, fixed;
font-size: 13px;
min-height: 13px;
line-height: 1.0;
text-wrap: unrestricted;
white-space: -moz-pre-wrap; /* Moz */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: pre-wrap; /* CSS3 */
word-wrap: break-word; /* IE 5.5+ */
text-indent: -53px;
padding-left: 53px;
padding-bottom: 0px;
margin: 0px;
-webkit-transition-property: background-color, box-shadow;
-webkit-transition-duration: 0.5s;
-moz-transition-property: background-color, box-shadow;
-moz-transition-duration: 0.5s;
-ms-transition-property: background-color, box-shadow;
-ms-transition-duration: 0.5s;
-o-transition-property: background-color, box-shadow;
-o-transition-duration: 0.5s;
transition-property: background-color, box-shadow;
transition-duration: 0.5s;
}
div.line.glow {
background-color: cyan;
box-shadow: 0 0 10px cyan;
}
span.lineno {
padding-right: 4px;
text-align: right;
border-right: 2px solid #0F0;
background-color: #E8E8E8;
white-space: pre;
}
span.lineno a {
background-color: #D8D8D8;
}
span.lineno a:hover {
background-color: #C8C8C8;
}
div.groupHeader {
margin-left: 16px;
margin-top: 12px;
font-weight: bold;
}
div.groupText {
margin-left: 16px;
font-style: italic;
}
/* @group Code Colorization */
span.keyword {
color: #008000
}
span.keywordtype {
color: #604020
}
span.keywordflow {
color: #e08000
}
span.comment {
color: #800000
}
span.preprocessor {
color: #806020
}
span.stringliteral {
color: #002080
}
span.charliteral {
color: #008080
}
span.vhdldigit {
color: #ff00ff
}
span.vhdlchar {
color: #000000
}
span.vhdlkeyword {
color: #700070
}
span.vhdllogic {
color: #ff0000
}
blockquote {
background-color: #F7F8FB;
border-left: 2px solid #9CAFD4;
margin: 0 24px 0 4px;
padding: 0 12px 0 16px;
}
/*---------------- Search Box */
#search-box {
margin: 10px 0px;
}
#search-box .close {
display: none;
position: absolute;
right: 0px;
padding: 6px 12px;
z-index: 5;
}
/*---------------- Search results window */
#search-results-window {
display: none;
}
iframe#MSearchResults {
width: 100%;
height: 15em;
}
.SRChildren {
padding-left: 3ex; padding-bottom: .5em
}
.SRPage .SRChildren {
display: none;
}
a.SRScope {
display: block;
}
a.SRSymbol:focus, a.SRSymbol:active,
a.SRScope:focus, a.SRScope:active {
text-decoration: underline;
}
span.SRScope {
padding-left: 4px;
}
.SRResult {
display: none;
}
/* class and file list */
.directory .icona,
.directory .arrow {
height: auto;
}
.directory .icona .icon {
height: 16px;
}
.directory .icondoc {
background-position: 0px 0px;
height: 20px;
}
.directory .iconfopen {
background-position: 0px 0px;
}
.directory td.entry {
padding: 7px 8px 6px 8px;
}
.table > tbody > tr > td.memSeparator {
line-height: 0;
padding: 0;
}
.memItemLeft, .memTemplItemLeft {
white-space: normal;
}
/* enumerations */
.panel-body thead > tr {
background-color: #e0e0e0;
}
/* todo lists */
.todoname,
.todoname a {
font-weight: bold;
}
/* Class title */
.summary {
margin-top: 25px;
}
.page-header {
margin: 20px 0px !important;
}
.page-header {
#display: inline-block;
}
.title {
text-align: center;
color: orange;
}
.page-header .pull-right {
margin-top: 0.3em;
margin-left: 0.5em;
}
.page-header .label {
font-size: 50%;
}
#main-nav {
display: none;
}

BIN
doc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

View File

@ -1,92 +0,0 @@
Build lib & build sample {#gale_build}
========================
@tableofcontents
Download: {#gale_build_download}
=========
gale use some tools to manage source and build it:
need google repo: {#gale_build_download_repo}
-----------------
see: http://source.android.com/source/downloading.html#installing-repo
On all platform:
```{.sh}
mkdir ~/.bin
PATH=~/.bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+x ~/.bin/repo
```
On ubuntu
```{.sh}
sudo apt-get install repo
```
On archlinux
```{.sh}
sudo pacman -S repo
```
lutin (build-system): {#gale_build_download_lutin}
---------------------
```{.sh}
pip install lutin --user
# optionnal dependency of lutin (manage image changing size for application release)
pip install pillow --user
```
dependency: {#gale_build_download_dependency}
-----------
```{.sh}
mkdir -p WORKING_DIRECTORY/framework
cd WORKING_DIRECTORY/framework
repo init -u git://github.com/atria-soft/manifest.git
repo sync -j8
cd ../..
```
sources: {#gale_build_download_sources}
--------
They are already download in the repo manifest in:
```{.sh}
cd WORKING_DIRECTORY/framework/atria-soft/gale
```
Build: {#gale_build_build}
======
you must stay in zour working directory...
```{.sh}
cd WORKING_DIRECTORY
```
library: {#gale_build_build_library}
--------
```{.sh}
lutin -mdebug gale
```
Sample: {#gale_build_build_sample}
-------
```{.sh}
lutin -mdebug gale-sample
```
Run sample: {#gale_build_run_sample}
===========
in distinct bash:
```{.sh}
lutin -mdebug gale-sample?run
```

View File

@ -1,68 +0,0 @@
GALE library {#mainpage}
===============
@tableofcontents
What is GALE? {#gale_mainpage_what}
=============
GALE, or "Graphic Abstraction Layer for Ewol" is a simple Interface with the OS Gui interface (openGL) and basic interface.
For example, on android we use java interface, on linux we use X11, ....
Gale abstract all of this and provide an inetrface in C++ on all of these platform.
Gale abstact the Keybord, mouse and touch event on all of these platform (when availlable: no touch on linux X11)
Gale is a low level abstraction interface. you can user upper interface:
- [EWOL](http://atria-soft.github.io/ewol) It provide some basic widgets and gui management
With Gale you have the Graphyc abstraction. We provide some abstraction for the audio interface:
- [audio-orchastra](https://musicdsp.github.io/audio-orchestra) That is the dual of gale but for audio.
- [audio-river](https://musicdsp.github.io/audio-river) That is the dual of ewol but for audio.
Where can I use it? {#gale_mainpage_where}
-------------------
Everywhere! GALE is cross-platform devolopped to support bases OS:
- Linux (X11) (mouse)
- Windows (mouse) (build on linux...)
- MacOs (mouse)
- Android (mouse + touch)
- IOs (touch)
What languages are supported? {#gale_mainpage_language}
=============================
GALE is written in C++.
Are there any licensing restrictions? {#gale_mainpage_restriction}
=====================================
GALE is **FREE software** and _all sub-library are FREE and staticly linkable !!!_
License (MPL v2.0) {#gale_mainpage_license}
==================
Copyright gale Edouard DUPIN
Licensed under the Mozilla Public License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
<https://www.mozilla.org/MPL/2.0>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Other pages {#gale_mainpage_sub_page}
===========
- @ref gale_build
- @ref gale_tutorial
- [**ewol coding style**](http://atria-soft.github.io/ewol/ewol_coding_style.html)

View File

@ -1,42 +0,0 @@
Tutorial {#gale_tutorial}
========
@tableofcontents
Base: {#gale_tutorial_declare}
=====
To understand some choise, I designe this software to acces on all system (that provide openGL interface).
But on some embended interface, we have only openGL-es ==> then I limit all the design on OpenGL-ES (need to think to change this maybe)
All is based on the heritage of the single class: gale::Application.
For your fist application you just need to declare an application and create the smallest main that ever exit:
Application declatration: {#gale_tutorial_base_main}
-------------------------
We declare the application:
```{.c}
class MainApplication : public gale::Application {
// application implementation here ...
}
```
We create application on the main()
@snippet basic.cpp gale_declare_main
At this point I need to explain one point on Android:
Android have an internal state engine that can create multiple aplication, then GALE can call a second time the main() if needed...
Then never forget to not use global value and singleton. We provide other mechanism to do it. (for exemple, you can acces at you Application intance everywhere you are).
Compleate Sample: {#gale_tutorial_compleate_sample}
=================
@snippet basic.cpp gale_sample_all

264
doxy-boot.js Normal file
View File

@ -0,0 +1,264 @@
$( document ).ready(function() {
$("div.headertitle").addClass("page-header");
$("div.title").addClass("h1");
$('li > a[href="index.html"] > span').before("<i class='fa fa-cog'></i> ");
$('li > a[href="modules.html"] > span').before("<i class='fa fa-square'></i> ");
$('li > a[href="namespaces.html"] > span').before("<i class='fa fa-bars'></i> ");
$('li > a[href="annotated.html"] > span').before("<i class='fa fa-list-ul'></i> ");
$('li > a[href="classes.html"] > span').before("<i class='fa fa-book'></i> ");
$('li > a[href="inherits.html"] > span').before("<i class='fa fa-sitemap'></i> ");
$('li > a[href="functions.html"] > span').before("<i class='fa fa-list'></i> ");
$('li > a[href="functions_func.html"] > span').before("<i class='fa fa-list'></i> ");
$('li > a[href="functions_vars.html"] > span').before("<i class='fa fa-list'></i> ");
$('li > a[href="functions_enum.html"] > span').before("<i class='fa fa-list'></i> ");
$('li > a[href="functions_eval.html"] > span').before("<i class='fa fa-list'></i> ");
$('img[src="ftv2ns.png"]').replaceWith('<span class="label label-danger">N</span> ');
$('img[src="ftv2cl.png"]').replaceWith('<span class="label label-danger">C</span> ');
$("ul.tablist").addClass("nav nav-pills nav-justified");
$("ul.tablist").css("margin-top", "0.5em");
$("ul.tablist").css("margin-bottom", "0.5em");
$("li.current").addClass("active");
$("iframe").attr("scrolling", "yes");
$("#nav-path > ul").addClass("breadcrumb");
$("table.params").addClass("table");
$("div.ingroups").wrapInner("<small></small>");
$("div.levels").css("margin", "0.5em");
$("div.levels > span").addClass("btn btn-default btn-xs");
$("div.levels > span").css("margin-right", "0.25em");
$("table.directory").addClass("table table-striped");
$("div.summary > a").addClass("btn btn-default btn-xs");
$("table.fieldtable").addClass("table");
$(".fragment").addClass("well");
$(".memitem").addClass("panel panel-default");
$(".memproto").addClass("panel-heading");
$(".memdoc").addClass("panel-body");
$("span.mlabel").addClass("label label-info");
$("table.memberdecls").addClass("table");
$("[class^=memitem]").addClass("active");
$("div.ah").addClass("btn btn-default");
$("span.mlabels").addClass("pull-right");
$("table.mlabels").css("width", "100%")
$("td.mlabels-right").addClass("pull-right");
$("div.ttc").addClass("panel panel-primary");
$("div.ttname").addClass("panel-heading");
$("div.ttname a").css("color", 'white');
$("div.ttdef,div.ttdoc,div.ttdeci").addClass("panel-body");
$('div.fragment.well div.line:first').css('margin-top', '15px');
$('div.fragment.well div.line:last').css('margin-bottom', '15px');
$('table.doxtable').removeClass('doxtable').addClass('table table-striped table-bordered').each(function(){
$(this).prepend('<thead></thead>');
$(this).find('tbody > tr:first').prependTo($(this).find('thead'));
$(this).find('td > span.success').parent().addClass('success');
$(this).find('td > span.warning').parent().addClass('warning');
$(this).find('td > span.danger').parent().addClass('danger');
});
if($('div.fragment.well div.ttc').length > 0)
{
$('div.fragment.well div.line:first').parent().removeClass('fragment well');
}
//merge left ad right element in the fuction table item
/*
$('table.memberdecls').find('.memItemRight').each(function(){
$(this).contents().appendTo($(this).siblings('.memItemLeft'));
$(this).siblings('.memItemLeft').attr('align', 'left');
});
*/
function getOriginalWidthOfImg(img_element) {
var t = new Image();
t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src;
return t.width;
}
$('div.dyncontent').find('img').each(function(){
if(getOriginalWidthOfImg($(this)[0]) > $('#content>div.container').width())
$(this).css('width', '100%');
});
/* responsive search box */
$('#MSearchBox').parent().remove();
var nav_container = $('<div class="row"></div>');
$('#navrow1').parent().prepend(nav_container);
var left_nav = $('<div class="col-md-9"></div>');
for (i = 0; i < 6; i++) {
var navrow = $('#navrow' + i + ' > ul.tablist').detach();
left_nav.append(navrow);
$('#navrow' + i).remove();
}
var right_nav = $('<div class="col-md-3"></div>').append('\
<div id="search-box" class="input-group">\
<div class="input-group-btn">\
<button aria-expanded="false" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">\
<span class="glyphicon glyphicon-search"></span> <span class="caret"></span>\
</button>\
<ul class="dropdown-menu">\
</ul>\
</div>\
<button id="search-close" type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>\
<input id="search-field" class="form-control" accesskey="S" onkeydown="searchBox.OnSearchFieldChange(event);" placeholder="Search ..." type="text">\
</div>');
$(nav_container).append(left_nav);
$(nav_container).append(right_nav);
$('#MSearchSelectWindow .SelectionMark').remove();
var search_selectors = $('#MSearchSelectWindow .SelectItem');
for (var i = 0; i < search_selectors.length; i += 1) {
var element_a = $('<a href="#"></a>').text($(search_selectors[i]).text());
element_a.click(function(){
$('#search-box .dropdown-menu li').removeClass('active');
$(this).parent().addClass('active');
searchBox.OnSelectItem($('#search-box li a').index(this));
searchBox.Search();
return false;
});
var element = $('<li></li>').append(element_a);
$('#search-box .dropdown-menu').append(element);
}
$('#MSearchSelectWindow').remove();
$('#search-box .close').click(function (){
searchBox.CloseResultsWindow();
});
$('body').append('<div id="MSearchClose"></div>');
$('body').append('<div id="MSearchBox"></div>');
$('body').append('<div id="MSearchSelectWindow"></div>');
searchBox.searchLabel = '';
searchBox.DOMSearchField = function() {
return document.getElementById("search-field");
}
searchBox.DOMSearchClose = function(){
return document.getElementById("search-close");
}
/* search results */
var results_iframe = $('#MSearchResults').detach();
$('#MSearchResultsWindow')
.attr('id', 'search-results-window')
.addClass('panel panel-default')
.append(
'<div class="panel-heading">\
<h3 class="panel-title">Search Results</h3>\
</div>\
<div class="panel-body"></div>'
);
$('#search-results-window .panel-body').append(results_iframe);
searchBox.DOMPopupSearchResultsWindow = function() {
return document.getElementById("search-results-window");
}
function update_search_results_window() {
$('#search-results-window').removeClass('panel-default panel-success panel-warning panel-danger')
var status = $('#MSearchResults').contents().find('.SRStatus:visible');
if (status.length > 0) {
switch(status.attr('id')) {
case 'Loading':
case 'Searching':
$('#search-results-window').addClass('panel-warning');
break;
case 'NoMatches':
$('#search-results-window').addClass('panel-danger');
break;
default:
$('#search-results-window').addClass('panel-default');
}
} else {
$('#search-results-window').addClass('panel-success');
}
}
$('#MSearchResults').load(function() {
$('#MSearchResults').contents().find('link[href="search.css"]').attr('href','../doxygen.css');
$('#MSearchResults').contents().find('head').append(
'<link href="../customdoxygen.css" rel="stylesheet" type="text/css">');
update_search_results_window();
// detect status changes (only for search with external search backend)
var observer = new MutationObserver(function(mutations) {
update_search_results_window();
});
var config = {
attributes: true
};
var targets = $('#MSearchResults').contents().find('.SRStatus');
for (i = 0; i < targets.length; i++) {
observer.observe(targets[i], config);
}
});
/* enumerations */
$('table.fieldtable').removeClass('fieldtable').addClass('table table-striped table-bordered').each(function(){
$(this).prepend('<thead></thead>');
$(this).find('tbody > tr:first').prependTo($(this).find('thead'));
$(this).find('td > span.success').parent().addClass('success');
$(this).find('td > span.warning').parent().addClass('warning');
$(this).find('td > span.danger').parent().addClass('danger');
});
/* todo list */
var todoelements = $('.contents > .textblock > dl.reflist > dt, .contents > .textblock > dl.reflist > dd');
for (var i = 0; i < todoelements.length; i += 2) {
$('.contents > .textblock').append(
'<div class="panel panel-default active">'
+ "<div class=\"panel-heading todoname\">" + $(todoelements[i]).html() + "</div>"
+ "<div class=\"panel-body\">" + $(todoelements[i+1]).html() + "</div>"
+ '</div>');
}
$('.contents > .textblock > dl').remove();
$(".memitem").removeClass('memitem');
$(".memproto").removeClass('memproto');
$(".memdoc").removeClass('memdoc');
$("span.mlabel").removeClass('mlabel');
$("table.memberdecls").removeClass('memberdecls');
$("[class^=memitem]").removeClass('memitem');
$("span.mlabels").removeClass('mlabels');
$("table.mlabels").removeClass('mlabels');
$("td.mlabels-right").removeClass('mlabels-right');
$(".navpath").removeClass('navpath');
$("li.navelem").removeClass('navelem');
$("a.el").removeClass('el');
$("div.ah").removeClass('ah');
$("div.header").removeClass("header");
$('.mdescLeft').each(function(){
if($(this).html()=="&nbsp;") {
$(this).siblings('.mdescRight').attr('colspan', 2);
$(this).remove();
}
});
$('td.memItemLeft').each(function(){
if($(this).siblings('.memItemRight').html()=="") {
$(this).attr('colspan', 2);
$(this).siblings('.memItemRight').remove();
}
});
});

View File

@ -1,35 +0,0 @@
#!/usr/bin/python
import os
import doxy.module as module
import doxy.debug as debug
import doxy.tools as tools
def create(target, module_name):
my_module = module.Module(__file__, module_name)
my_module.set_version("version.txt")
my_module.set_title("Gale: Graphic Abstraction Layer for Ewol")
my_module.set_website("http://atria-soft.github.io/" + module_name)
my_module.set_website_sources("http://github.com/atria-soft/" + module_name)
my_module.add_path([
module_name,
"doc"
])
my_module.add_sample_path([
"sample"
])
my_module.add_depend([
'elog',
'etk'
])
my_module.add_exclude_symbols([
'*operator<<*',
])
my_module.add_exclude_file([
'debug.hpp',
])
my_module.add_file_patterns([
'*.hp',
'*.md',
])
return my_module

1508
doxygen.css Normal file

File diff suppressed because it is too large Load Diff

BIN
doxygen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

97
dynsections.js Normal file
View File

@ -0,0 +1,97 @@
function toggleVisibility(linkObj)
{
var base = $(linkObj).attr('id');
var summary = $('#'+base+'-summary');
var content = $('#'+base+'-content');
var trigger = $('#'+base+'-trigger');
var src=$(trigger).attr('src');
if (content.is(':visible')===true) {
content.hide();
summary.show();
$(linkObj).addClass('closed').removeClass('opened');
$(trigger).attr('src',src.substring(0,src.length-8)+'closed.png');
} else {
content.show();
summary.hide();
$(linkObj).removeClass('closed').addClass('opened');
$(trigger).attr('src',src.substring(0,src.length-10)+'open.png');
}
return false;
}
function updateStripes()
{
$('table.directory tr').
removeClass('even').filter(':visible:even').addClass('even');
}
function toggleLevel(level)
{
$('table.directory tr').each(function() {
var l = this.id.split('_').length-1;
var i = $('#img'+this.id.substring(3));
var a = $('#arr'+this.id.substring(3));
if (l<level+1) {
i.removeClass('iconfopen iconfclosed').addClass('iconfopen');
a.html('&#9660;');
$(this).show();
} else if (l==level+1) {
i.removeClass('iconfclosed iconfopen').addClass('iconfclosed');
a.html('&#9658;');
$(this).show();
} else {
$(this).hide();
}
});
updateStripes();
}
function toggleFolder(id)
{
// the clicked row
var currentRow = $('#row_'+id);
// all rows after the clicked row
var rows = currentRow.nextAll("tr");
var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
// only match elements AFTER this one (can't hide elements before)
var childRows = rows.filter(function() { return this.id.match(re); });
// first row is visible we are HIDING
if (childRows.filter(':first').is(':visible')===true) {
// replace down arrow by right arrow for current row
var currentRowSpans = currentRow.find("span");
currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
currentRowSpans.filter(".arrow").html('&#9658;');
rows.filter("[id^=row_"+id+"]").hide(); // hide all children
} else { // we are SHOWING
// replace right arrow by down arrow for current row
var currentRowSpans = currentRow.find("span");
currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen");
currentRowSpans.filter(".arrow").html('&#9660;');
// replace down arrows by right arrows for child rows
var childRowsSpans = childRows.find("span");
childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
childRowsSpans.filter(".arrow").html('&#9658;');
childRows.show(); //show all children
}
updateStripes();
}
function toggleInherit(id)
{
var rows = $('tr.inherit.'+id);
var img = $('tr.inherit_header.'+id+' img');
var src = $(img).attr('src');
if (rows.filter(':first').is(':visible')===true) {
rows.css('display','none');
$(img).attr('src',src.substring(0,src.length-8)+'closed.png');
} else {
rows.css('display','table-row'); // using show() causes jump in firefox
$(img).attr('src',src.substring(0,src.length-10)+'open.png');
}
}

BIN
folderclosed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

BIN
folderopen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

View File

@ -1,171 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp>
#include <gale/Application.hpp>
#include <gale/context/Context.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::Application);
gale::Application::Application() :
m_canDraw(false),
m_needRedraw(true),
m_title("gale"),
m_iconName(""),
m_cursor(gale::context::cursor::arrow),
m_orientation(gale::orientation::screenAuto) {
GALE_VERBOSE("Constructor Gale Application");
}
gale::Application::~Application() {
GALE_VERBOSE("destructor of Gale Application");
}
void gale::Application::onCreate(gale::Context& _context) {
GALE_VERBOSE("Create Gale Application");
}
void gale::Application::onStart(gale::Context& _context) {
GALE_VERBOSE("Start Gale Application");
}
void gale::Application::onResume(gale::Context& _context) {
GALE_VERBOSE("Resume Gale Application");
}
void gale::Application::onRegenerateDisplay(gale::Context& _context) {
GALE_VERBOSE("Regenerate Gale Application");
markDrawingIsNeeded();
}
void gale::Application::markDrawingIsNeeded() {
m_needRedraw = true;
}
bool gale::Application::isDrawingNeeded() {
bool tmp = m_needRedraw;
m_needRedraw = false;
return tmp;
}
void gale::Application::onDraw(gale::Context& _context) {
GALE_VERBOSE("draw Gale Application");
}
void gale::Application::onPause(gale::Context& _context) {
GALE_VERBOSE("Pause Gale Application");
}
void gale::Application::onStop(gale::Context& _context) {
GALE_VERBOSE("Stop Gale Application");
}
void gale::Application::onDestroy(gale::Context& _context) {
GALE_VERBOSE("Destroy Gale Application");
}
void gale::Application::onKillDemand(gale::Context& _context) {
GALE_INFO("Gale request auto destroy ==> no applification specification");
exit(0);
}
void gale::Application::exit(int32_t _value) {
GALE_VERBOSE("Exit Requested " << _value);
gale::getContext().stop();
}
void gale::Application::onPointer(enum gale::key::type _type, int32_t _pointerID, const vec2& _pos, gale::key::status _state) {
}
void gale::Application::onKeyboard(const gale::key::Special& _special,
enum gale::key::keyboard _type,
char32_t _value,
gale::key::status _state) {
}
void gale::Application::keyboardShow() {
gale::getContext().keyboardShow();
}
void gale::Application::keyboardHide() {
gale::getContext().keyboardHide();
}
void gale::Application::onResize(const ivec2& _size) {
}
void gale::Application::setSize(const vec2& _size) {
gale::Context& context = gale::getContext();
context.setSize(_size);
}
vec2 gale::Application::getSize() const {
gale::Context& context = gale::getContext();
return context.getSize();
}
void gale::Application::onMovePosition(const vec2& _size) {
}
void gale::Application::setPosition(const vec2& _size) {
}
vec2 gale::Application::getPosition() const {
return vec2(0,0);
}
void gale::Application::setTitle(const etk::String& _title) {
m_title = _title;
gale::Context& context = gale::getContext();
context.setTitle(m_title);
}
etk::String gale::Application::getTitle() {
return m_title;
}
void gale::Application::setIcon(const etk::Uri& _iconFile) {
m_iconName = _iconFile;
gale::Context& context = gale::getContext();
context.setIcon(m_iconName);
}
const etk::Uri& gale::Application::getIcon() {
return m_iconName;
}
void gale::Application::setCursor(enum gale::context::cursor _newCursor) {
m_cursor = _newCursor;
gale::Context& context = gale::getContext();
context.setCursor(m_cursor);
}
enum gale::context::cursor gale::Application::getCursor() {
return m_cursor;
}
void gale::Application::openURL(const etk::String& _url) {
gale::Context& context = gale::getContext();
context.openURL(_url);
}
void gale::Application::setOrientation(enum gale::orientation _orientation) {
m_orientation = _orientation;
gale::Context& context = gale::getContext();
context.forceOrientation(m_orientation);
}
enum gale::orientation gale::Application::getOrientation() {
return m_orientation;
}
void gale::Application::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) {
}

View File

@ -1,219 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <ememory/memory.hpp>
#include <etk/types.hpp>
#include <etk/uri/uri.hpp>
#include <etk/math/Vector2D.hpp>
#include <gale/orientation.hpp>
#include <gale/key/status.hpp>
#include <gale/key/type.hpp>
#include <gale/key/Special.hpp>
#include <gale/context/cursor.hpp>
#include <gale/context/clipBoard.hpp>
#include <echrono/Clock.hpp>
namespace gale {
class Context;
class Application : public ememory::EnableSharedFromThis<gale::Application> {
public:
Application();
virtual ~Application();
public:
bool m_canDraw;
/**
* @brief The application is created.
* @param[in] _context Current gale context.
*/
virtual void onCreate(gale::Context& _context);
/**
* @brief The application is started.
* @param[in] _context Current gale context.
*/
virtual void onStart(gale::Context& _context);
/**
* @brief The application is resumed (now visible).
* @param[in] _context Current gale context.
*/
virtual void onResume(gale::Context& _context);
/**
* @brief call application to precalculate drawing.
* @param[in] _context Current gale context.
*/
virtual void onRegenerateDisplay(gale::Context& _context);
/**
* @brief Real draw of the application
* @param[in] _context Current gale context.
*/
virtual void onDraw(gale::Context& _context);
/**
* @brief The application is Hide / not visible.
* @param[in] _context Current gale context.
*/
virtual void onPause(gale::Context& _context);
/**
* @brief The application is stopped.
* @param[in] _context Current gale context.
*/
virtual void onStop(gale::Context& _context);
/**
* @brief The application is removed (call destructor just adter it.).
* @param[in] _context Current gale context.
*/
virtual void onDestroy(gale::Context& _context);
/**
* @brief The user request application removing.
* @param[in] _context Current gale context.
*/
virtual void onKillDemand(gale::Context& _context);
/**
* @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[in] _value value to return on the program
*/
virtual void exit(int32_t _value);
private:
bool m_needRedraw;
public:
virtual void markDrawingIsNeeded();
virtual bool isDrawingNeeded();
public:
/**
* @brief Get touch/mouse/... event.
* @param[in] _type Type of pointer event
* @param[in] _pointerID Pointer id of the touch event.
* @param[in] _pos Position of the event (can be <0 if out of window).
* @param[in] _state Key state (up/down/move)
*/
virtual void onPointer(enum gale::key::type _type,
int32_t _pointerID,
const vec2& _pos,
gale::key::status _state);
/**
* @brief Get keyborad value input.
* @param[in] _special Current special key status (ctrl/alt/shift ...).
* @param[in] _type Type of the event.
* @param[in] _value Unicode value of the char pushed (viable only if _type==gale::key::keyboard::character).
* @param[in] _state State of the key (up/down/upRepeate/downRepeate)
*/
virtual void onKeyboard(const gale::key::Special& _special,
enum gale::key::keyboard _type,
char32_t _value,
gale::key::status _state);
/**
* @brief Show the virtal keyboard (if possible : only on iOs/Android)
*/
virtual void keyboardShow();
/**
* @brief Hide the virtal keyboard (if possible : only on iOs/Android)
*/
virtual void keyboardHide();
public:
/**
* @brief Event generated when user change the size of the window.
* @param[in] _size New size of the window.
*/
virtual void onResize(const ivec2& _size);
/**
* @brief Set the size of the window (if possible: Android and Ios does not support it)
* @param[in] _size New size of the window.
* @return
*/
virtual void setSize(const vec2& _size);
/**
* @brief Get the size of the window.
* @return Current size of the window.
*/
virtual vec2 getSize() const;
public:
/**
* @brief Event generated when user change the position of the window.
* @param[in] _size New position of the window.
*/
virtual void onMovePosition(const vec2& _size);
/**
* @brief Set the position of the window (if possible: Android and Ios does not support it)
* @param[in] _size New position of the window.
*/
virtual void setPosition(const vec2& _size);
/**
* @brief Get the position of the window.
* @return Current position of the window.
*/
virtual vec2 getPosition() const;
private:
etk::String m_title;
public:
/**
* @brief Set the title of the application
* @param[in] _title New title to set at the application (if possible: Android and Ios does not support it)
*/
virtual void setTitle(const etk::String& _title);
/**
* @brief Get the current title of the application
* @return Current title
*/
virtual etk::String getTitle();
private:
etk::Uri m_iconName;
public:
/**
* @brief set the Icon of the application.
* @param[in] _iconFile File name icon (.bmp/.png).
*/
virtual void setIcon(const etk::Uri& _iconFile);
/**
* @brief Get the current filename of the application.
* @return Filename of the icon.
*/
virtual const etk::Uri& getIcon();
private:
enum gale::context::cursor m_cursor;
public:
/**
* @brief Set the cursor type.
* @param[in] _newCursor Selected cursor.
*/
virtual void setCursor(enum gale::context::cursor _newCursor);
/**
* @brief Get the cursor type.
* @return the current cursor.
*/
virtual enum gale::context::cursor getCursor();
public:
/**
* @brief Open an URL on an internal brother.
* @param[in] _url URL to open.
*/
virtual void openURL(const etk::String& _url);
private:
enum gale::orientation m_orientation;
public:
/**
* @brief set the screen orientation (if possible : only on iOs/Android)
* @param[in] _orientation New orientation.
*/
virtual void setOrientation(enum gale::orientation _orientation);
/**
* @brief get the screen orientation (if possible : only on iOs/Android)
* @return Current orientation.
*/
virtual enum gale::orientation getOrientation();
public:
/**
* @brief A clipboard data is back (apear after a request of a new clipboard).
* @param[in] _clipboardId Id of the clipboard.
*/
virtual void onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId);
public:
/**
* @brief Call every time a draw is called (not entirely periodic, but faster at we can ...
* @param[in] _time Current time of the call;
*/
virtual void onPeriod(const echrono::Clock& _time) {};
};
}

View File

@ -1,325 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/Dimension.hpp>
#include <gale/debug.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::distance);
ETK_DECLARE_TYPE(gale::Dimension);
// TODO : set this in a super class acced in a statin fuction...
// ratio in milimeter :
static bool isInit = false;
static vec2 ratio(9999999,888888);
static vec2 invRatio(1,1);
static gale::Dimension windowsSize(vec2(9999999,888888), gale::distance::pixel);
static const float inchToMillimeter = 1.0f/25.4f;
static const float footToMillimeter = 1.0f/304.8f;
static const float meterToMillimeter = 1.0f/1000.0f;
static const float centimeterToMillimeter = 1.0f/10.0f;
static const float kilometerToMillimeter = 1.0f/1000000.0f;
static const float millimeterToInch = 25.4f;
static const float millimeterToFoot = 304.8f;
static const float millimeterToMeter =1000.0f;
static const float millimeterToCentimeter = 10.0f;
static const float millimeterToKilometer = 1000000.0f;
void gale::Dimension::init() {
if (true == isInit) {
return;
}
gale::Dimension conversion(vec2(72,72), gale::distance::inch);
ratio = conversion.getMillimeter();
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
windowsSize.set(vec2(200,200), gale::distance::pixel);
isInit = true;
}
void gale::Dimension::unInit() {
isInit = false;
ratio.setValue(9999999,888888);
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
windowsSize.set(vec2(9999999,88888), gale::distance::pixel);
}
void gale::Dimension::setPixelRatio(const vec2& _ratio, enum gale::distance _type) {
gale::Dimension::init();
GALE_INFO("Set a new screen ratio for the screen : ratio=" << _ratio << " type=" << _type);
gale::Dimension conversion(_ratio, _type);
GALE_INFO(" == > " << conversion);
ratio = conversion.getMillimeter();
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
GALE_INFO("Set a new screen ratio for the screen : ratioMm=" << ratio);
}
void gale::Dimension::setPixelWindowsSize(const vec2& _size) {
windowsSize = _size;
GALE_VERBOSE("Set a new Windows property size " << windowsSize << "px");
}
vec2 gale::Dimension::getWindowsSize(enum gale::distance _type) {
return windowsSize.get(_type);
}
float gale::Dimension::getWindowsDiag(enum gale::distance _type) {
vec2 size = gale::Dimension::getWindowsSize(_type);
return size.length();
}
gale::Dimension::Dimension() :
m_data(0,0),
m_type(gale::distance::pixel) {
// notinh to do ...
}
gale::Dimension::Dimension(const vec2& _size, enum gale::distance _type) :
m_data(0,0),
m_type(gale::distance::pixel) {
set(_size, _type);
}
void gale::Dimension::set(etk::String _config) {
m_data.setValue(0,0);
m_type = gale::distance::pixel;
enum distance type = gale::distance::pixel;
if (etk::end_with(_config, "%", false) == true) {
type = gale::distance::pourcent;
_config.erase(_config.size()-1, 1);
} else if (etk::end_with(_config, "px",false) == true) {
type = gale::distance::pixel;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "ft",false) == true) {
type = gale::distance::foot;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "in",false) == true) {
type = gale::distance::inch;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "km",false) == true) {
type = gale::distance::kilometer;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "mm",false) == true) {
type = gale::distance::millimeter;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "cm",false) == true) {
type = gale::distance::centimeter;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "m",false) == true) {
type = gale::distance::meter;
_config.erase(_config.size()-1, 1);
} else {
GALE_CRITICAL("Can not parse dimention : \"" << _config << "\"");
return;
}
vec2 tmp = _config;
set(tmp, type);
GALE_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
}
gale::Dimension::~Dimension() {
// nothing to do ...
}
gale::Dimension::operator etk::String() const {
etk::String str;
str = get(getType());
switch(getType()) {
case gale::distance::pourcent:
str += "%";
break;
case gale::distance::pixel:
str += "px";
break;
case gale::distance::meter:
str += "m";
break;
case gale::distance::centimeter:
str += "cm";
break;
case gale::distance::millimeter:
str += "mm";
break;
case gale::distance::kilometer:
str += "km";
break;
case gale::distance::inch:
str += "in";
break;
case gale::distance::foot:
str += "ft";
break;
}
return str;
}
vec2 gale::Dimension::get(enum gale::distance _type) const {
switch(_type) {
case gale::distance::pourcent:
return getPourcent();
case gale::distance::pixel:
return getPixel();
case gale::distance::meter:
return getMeter();
case gale::distance::centimeter:
return getCentimeter();
case gale::distance::millimeter:
return getMillimeter();
case gale::distance::kilometer:
return getKilometer();
case gale::distance::inch:
return getInch();
case gale::distance::foot:
return getFoot();
}
return vec2(0,0);
}
void gale::Dimension::set(const vec2& _size, enum gale::distance _type) {
// set min max on input to limit error :
vec2 size(etk::avg(0.0f,_size.x(),9999999.0f),
etk::avg(0.0f,_size.y(),9999999.0f));
switch(_type) {
case gale::distance::pourcent: {
vec2 size2(etk::avg(0.0f,_size.x(),100.0f),
etk::avg(0.0f,_size.y(),100.0f));
m_data = vec2(size2.x()*0.01f, size2.y()*0.01f);
//GALE_VERBOSE("Set % : " << size2 << " == > " << m_data);
break;
}
case gale::distance::pixel:
m_data = size;
break;
case gale::distance::meter:
m_data = vec2(size.x()*meterToMillimeter*ratio.x(), size.y()*meterToMillimeter*ratio.y());
break;
case gale::distance::centimeter:
m_data = vec2(size.x()*centimeterToMillimeter*ratio.x(), size.y()*centimeterToMillimeter*ratio.y());
break;
case gale::distance::millimeter:
m_data = vec2(size.x()*ratio.x(), size.y()*ratio.y());
break;
case gale::distance::kilometer:
m_data = vec2(size.x()*kilometerToMillimeter*ratio.x(), size.y()*kilometerToMillimeter*ratio.y());
break;
case gale::distance::inch:
m_data = vec2(size.x()*inchToMillimeter*ratio.x(), size.y()*inchToMillimeter*ratio.y());
break;
case gale::distance::foot:
m_data = vec2(size.x()*footToMillimeter*ratio.x(), size.y()*footToMillimeter*ratio.y());
break;
}
m_type = _type;
}
vec2 gale::Dimension::getPixel() const {
if (m_type!=gale::distance::pourcent) {
return m_data;
} else {
vec2 windDim = windowsSize.getPixel();
vec2 res = vec2(windDim.x()*m_data.x(), windDim.y()*m_data.y());
//GALE_DEBUG("Get % : " << m_data << " / " << windDim << " == > " << res);
return res;
}
}
vec2 gale::Dimension::getPourcent() const {
if (m_type!=gale::distance::pourcent) {
vec2 windDim = windowsSize.getPixel();
//GALE_DEBUG(" windows dimention : " /*<< windowsSize*/ << " == > " << windDim << "px"); // ==> infinite loop ...
//printf(" windows dimention : %f,%f", windDim.x(),windDim.y());
//printf(" data : %f,%f", m_data.x(),m_data.y());
return vec2((m_data.x()/windDim.x())*100.0f, (m_data.y()/windDim.y())*100.0f);
}
return vec2(m_data.x()*100.0f, m_data.y()*100.0f);;
}
vec2 gale::Dimension::getMeter() const {
return gale::Dimension::getMillimeter()*millimeterToMeter;
}
vec2 gale::Dimension::getCentimeter() const {
return gale::Dimension::getMillimeter()*millimeterToCentimeter;
}
vec2 gale::Dimension::getMillimeter() const {
return gale::Dimension::getPixel()*invRatio;
}
vec2 gale::Dimension::getKilometer() const {
return gale::Dimension::getMillimeter()*millimeterToKilometer;
}
vec2 gale::Dimension::getInch() const {
return gale::Dimension::getMillimeter()*millimeterToInch;
}
vec2 gale::Dimension::getFoot() const {
return gale::Dimension::getMillimeter()*millimeterToFoot;
}
etk::Stream& gale::operator <<(etk::Stream& _os, enum gale::distance _obj) {
switch(_obj) {
case gale::distance::pourcent:
_os << "%";
break;
case gale::distance::pixel:
_os << "px";
break;
case gale::distance::meter:
_os << "m";
break;
case gale::distance::centimeter:
_os << "cm";
break;
case gale::distance::millimeter:
_os << "mm";
break;
case gale::distance::kilometer:
_os << "km";
break;
case gale::distance::inch:
_os << "in";
break;
case gale::distance::foot:
_os << "ft";
break;
}
return _os;
}
etk::Stream& gale::operator <<(etk::Stream& _os, const gale::Dimension& _obj) {
_os << _obj.get(_obj.getType()) << _obj.getType();
return _os;
}
namespace etk {
template<> etk::String toString<gale::Dimension>(const gale::Dimension& _obj) {
return _obj;
}
template<> etk::UString toUString<gale::Dimension>(const gale::Dimension& _obj) {
return etk::toUString(etk::toString(_obj));
}
template<> bool from_string<gale::Dimension>(gale::Dimension& _variableRet, const etk::String& _value) {
_variableRet = gale::Dimension(_value);
return true;
}
template<> bool from_string<gale::Dimension>(gale::Dimension& _variableRet, const etk::UString& _value) {
return from_string(_variableRet, etk::toString(_value));
}
};
#ifdef GALE_BUILD_ESIGNAL
#include <esignal/details/Signal.hxx>
ESIGNAL_DECLARE_SIGNAL(gale::Dimension);
#endif
#ifdef GALE_BUILD_EPROPERTY
//#include <eproperty/details/Range.hxx>
#include <eproperty/details/Value.hxx>
//template class eproperty::Range<gale::Dimension>;
template class eproperty::Value<gale::Dimension>;
#endif

View File

@ -1,205 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <etk/math/Vector2D.hpp>
namespace gale {
enum class distance {
pourcent=0,
pixel,
meter,
centimeter,
millimeter,
kilometer,
inch,
foot,
};
/**
* @brief in the dimention class we store the data as the more usefull unit (pixel)
* but one case need to be dynamic the %, then when requested in % the register the % value
*/
class Dimension {
public:
private:
vec2 m_data;
enum distance m_type;
public:
/**
* @brief Constructor (default :0,0 mode pixel)
*/
Dimension();
/**
* @brief Constructor
* @param[in] _size Requested dimention
* @param[in] _type Unit of the Dimention
*/
Dimension(const vec2& _size, enum gale::distance _type=gale::distance::pixel);
/**
* @brief Constructor
* @param[in] _config dimension configuration.
*/
Dimension(const etk::String& _config) :
m_data(0,0),
m_type(gale::distance::pixel) {
set(_config);
};
/**
* @brief Constructor
* @param[in] _config dimension configuration.
*/
Dimension(const char* _config) :
m_data(0,0),
m_type(gale::distance::pixel) {
set(_config);
};
/**
* @brief Destructor
*/
~Dimension();
/**
* @brief string cast :
*/
operator etk::String() const;
/**
* @brief get the current dimention in requested type
* @param[in] _type Type of unit requested.
* @return dimention requested.
*/
vec2 get(enum distance _type) const;
/**
* @brief set the current dimention in requested type
* @param[in] _size Dimention to set
* @param[in] _type Type of unit requested.
*/
void set(const vec2& _size, enum distance _type);
private:
/**
* @brief set the current dimention in requested type
* @param[in] _config dimension configuration.
*/
void set(etk::String _config);
public:
/**
* @brief get the current dimention in pixel
* @return dimention in Pixel
*/
vec2 getPixel() const;
/**
* @brief get the current dimention in Pourcent
* @return dimention in Pourcent
*/
vec2 getPourcent() const;
/**
* @brief get the current dimention in Meter
* @return dimention in Meter
*/
vec2 getMeter() const;
/**
* @brief get the current dimention in Centimeter
* @return dimention in Centimeter
*/
vec2 getCentimeter() const;
/**
* @brief get the current dimention in Millimeter
* @return dimention in Millimeter
*/
vec2 getMillimeter() const;
/**
* @brief get the current dimention in Kilometer
* @return dimention in Kilometer
*/
vec2 getKilometer() const;
/**
* @brief get the current dimention in Inch
* @return dimention in Inch
*/
vec2 getInch() const;
/**
* @brief get the current dimention in Foot
* @return dimention in Foot
*/
vec2 getFoot() const;
/*****************************************************
* = assigment
*****************************************************/
const Dimension& operator= (const Dimension& _obj ) {
if (this!=&_obj) {
m_data = _obj.m_data;
m_type = _obj.m_type;
}
return *this;
}
/*****************************************************
* == operator
*****************************************************/
bool operator == (const Dimension& _obj) const {
if( m_data == _obj.m_data
&& m_type == _obj.m_type) {
return true;
}
return false;
}
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const Dimension& _obj) const {
if( m_data != _obj.m_data
|| m_type != _obj.m_type) {
return true;
}
return false;
}
/**
* @breif get the dimension type
* @return the type
*/
enum distance getType() const {
return m_type;
};
public : // Global static access :
/**
* @brief basic init
*/
static void init();
/**
* @brief basic un-init
*/
static void unInit();
/**
* @brief set the Milimeter ratio for calculation
* @param[in] Ratio Milimeter ration for the screen calculation interpolation
* @param[in] type Unit type requested.
* @note: same as @ref setPixelPerInch (internal manage convertion)
*/
static void setPixelRatio(const vec2& _ratio, enum gale::distance _type);
/**
* @brief set the current Windows size
* @param[in] size size of the current windows in pixel.
*/
static void setPixelWindowsSize(const vec2& _size);
/**
* @brief get the Windows size in the request unit
* @param[in] type Unit type requested.
* @return the requested size
*/
static vec2 getWindowsSize(enum gale::distance _type);
/**
* @brief get the Windows diagonal size in the request unit
* @param[in] type Unit type requested.
* @return the requested size
*/
static float getWindowsDiag(enum gale::distance _type);
};
etk::Stream& operator <<(etk::Stream& _os, enum gale::distance _obj);
etk::Stream& operator <<(etk::Stream& _os, const gale::Dimension& _obj);
}

View File

@ -1,110 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/Thread.hpp>
#include <gale/debug.hpp>
#include <gale/context/Context.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::Thread);
gale::Thread::Thread() :
m_state(state::stop),
m_context(0) {
GALE_INFO("Create new Thread");
}
gale::Thread::~Thread() {
GALE_INFO("Remove Thread [START]");
stop();
GALE_INFO("Remove Thread [STOP]");
}
void gale::Thread::start() {
if (m_state == state::stop) {
GALE_DEBUG("Allocate ethread::Thread [START]");
m_state = state::starting;
m_context = &gale::getContext();
m_thread = ememory::makeShared<ethread::Thread>([=](){this->threadCall();}, "galeThread");
if (m_thread == null) {
GALE_ERROR("Can not create thread ...");
return;
}
GALE_DEBUG("Allocate ethread::Thread [Set priority]");
// set priority
GALE_DEBUG("Allocate ethread::Thread [Register context]");
// set association with the gale context ...
//gale::contextRegisterThread(m_thread);
GALE_DEBUG("Allocate ethread::Thread [set State]");
m_state = state::running;
GALE_DEBUG("Allocate ethread::Thread [STOP]");
}
}
void gale::Thread::stop() {
if (m_state == state::stop) {
return;
}
// Request thread stop ==> other wise, we waint indefinitly ...
m_state = state::stopping;
while ( m_state == state::running
|| m_state == state::starting) {
// requesting a stop ...
GALE_INFO("wait Thread stopping");
ethread::sleepMilliSeconds((100));
}
GALE_DEBUG("stop ethread::Thread [START]");
m_thread->join();
//gale::contextUnRegisterThread(m_thread);
GALE_DEBUG("stop ethread::Thread [delete]");
m_thread.reset();
GALE_DEBUG("stop ethread::Thread [set state]");
m_state = state::stop;
GALE_INFO("stop ethread::Thread [STOP]");
}
void gale::Thread::threadCall() {
GALE_DEBUG("THREAD MAIN [START]");
if (m_name != "") {
ethread::setName(m_name);
m_lastUpdatateName = echrono::Steady::now();
}
gale::setContext(m_context);
while (m_state != state::stopping) {
if (m_state == state::starting) {
GALE_DEBUG("run ethread::Thread [NOTHING to do]");
ethread::sleepMilliSeconds((1));
continue;
}
if (m_name != "") {
if ((echrono::Steady::now()-m_lastUpdatateName) > echrono::seconds(10)) {
m_lastUpdatateName = echrono::Steady::now();
ethread::setName(m_name);
}
}
if (onThreadCall() == true) {
GALE_DEBUG("run ethread::Thread [AUTO STOP]");
m_state = state::stopping;
return;
}
}
GALE_DEBUG("THREAD MAIN [STOP]");
gale::setContext(null);
m_state = state::stopping;
}
bool gale::Thread::onThreadCall() {
return true;
};
enum gale::Thread::state gale::Thread::getState() {
return m_state;
}
void gale::Thread::setName(etk::String _name) {
m_name = _name;
}

View File

@ -1,80 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <ethread/tools.hpp>
#include <gale/context/Context.hpp>
#include <ethread/Thread.hpp>
namespace gale {
/**
* @brief We have our own thread in gale to manage gale context folowing and manage android rong management of ethread::Thread when calling java.
*/
class Thread : public ememory::EnableSharedFromThis<Thread> {
public:
/**
* @brief Internal state capabilities of the thread.
*/
enum class state {
stop, //!< The thread is not active
starting, //!< The thread is in creation state
running, //!< The current thread is activate
stopping //!< The thread is stoping
};
private:
enum state m_state; //!< Current state of the thread.
public:
/**
* @brief Get the current state of the thread
* @return The state of the thread
*/
enum gale::Thread::state getState();
private:
ememory::SharedPtr<ethread::Thread> m_thread; //!< Current handle on the thread
gale::Context* m_context; //!< Copy of the gale context (permit to get current gale interface)
public:
/**
* @brief Constructor
*/
Thread();
/**
* @brief Destructor
*/
virtual ~Thread();
/**
* @brief Start the Thread (create thread here)
*/
virtual void start();
/**
* @brief Stop the Thread (destroy thread here)
*/
virtual void stop();
private:
etk::String m_name; //!< thread Name
echrono::Steady m_lastUpdatateName;
public:
/**
* @brief change name of the thread
* @param[in] _name Name of the thread
*/
void setName(etk::String m_name);
private:
/**
* @brief Internal periodic call of the thead
*/
void threadCall();
protected:
/**
* @brief Periodic call of the thread process
* @return true The thread has ended process and need to be destroyed
* @return false Need an other cycle if user does not request stop
*/
virtual bool onThreadCall();
};
}

View File

@ -1,960 +0,0 @@
/** @file
* @author Edouard DUPIN, Kevin BILLONNEAU
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <jni.h>
#include <sys/time.h>
#include <time.h>
extern "C" {
#include <stdint.h>
}
#include <pthread.h>
#include <ethread/Mutex.hpp>
#include <gale/debug.hpp>
#include <gale/context/Context.hpp>
#include <gale/Dimension.hpp>
/* include auto generated file */
#include <org_gale_GaleConstants.h>
#include <jvm-basics/jvm-basics.hpp>
// jni doc : /usr/lib/jvm/java-1.6.0-openjdk/include
ethread::Mutex g_interfaceMutex;
class AndroidContext : public gale::Context {
public:
enum application {
appl_unknow,
appl_application,
appl_wallpaper
};
private:
enum application m_javaApplicationType;
// get a resources from the java environement :
JNIEnv* m_JavaVirtualMachinePointer; //!< the JVM
jclass m_javaClassGale; //!< main activity class (android ...)
jclass m_javaClassGaleCallback;
jobject m_javaObjectGaleCallback;
jmethodID m_javaMethodGaleCallbackStop; //!< Stop function identifier
jmethodID m_javaMethodGaleCallbackEventNotifier; //!< basic methode to call ...
jmethodID m_javaMethodGaleCallbackKeyboardUpdate; //!< basic methode to call ...
jmethodID m_javaMethodGaleCallbackOrientationUpdate;
jmethodID m_javaMethodGaleActivitySetTitle;
jmethodID m_javaMethodGaleActivityOpenURI;
jmethodID m_javaMethodGaleActivitySetClipBoardString;
jmethodID m_javaMethodGaleActivityGetClipBoardString;
jclass m_javaDefaultClassString; //!< default string class
int32_t m_currentHeight;
gale::key::Special m_guiKeyBoardSpecialKeyMode;//!< special key of the android system :
bool m_clipBoardOwnerStd;
private:
bool safeInitMethodID(jmethodID& _mid, jclass& _cls, const char* _name, const char* _sign) {
_mid = m_JavaVirtualMachinePointer->GetMethodID(_cls, _name, _sign);
if(_mid == null) {
GALE_ERROR("C->java : Can't find the method " << _name);
/* remove access on the virtual machine : */
m_JavaVirtualMachinePointer = null;
return false;
}
return true;
}
public:
AndroidContext(gale::Application* _application, JNIEnv* _env, jclass _classBase, jobject _objCallback, enum application _typeAPPL) :
gale::Context(_application),
m_javaApplicationType(_typeAPPL),
m_JavaVirtualMachinePointer(null),
m_javaClassGale(0),
m_javaClassGaleCallback(0),
m_javaObjectGaleCallback(0),
m_javaMethodGaleCallbackStop(0),
m_javaMethodGaleCallbackEventNotifier(0),
m_javaMethodGaleCallbackKeyboardUpdate(0),
m_javaMethodGaleCallbackOrientationUpdate(0),
m_javaMethodGaleActivitySetTitle(0),
m_javaMethodGaleActivityOpenURI(0),
m_javaMethodGaleActivitySetClipBoardString(0),
m_javaMethodGaleActivityGetClipBoardString(0),
m_javaDefaultClassString(0),
m_currentHeight(0),
m_clipBoardOwnerStd(false) {
GALE_DEBUG("*******************************************");
if (m_javaApplicationType == appl_application) {
GALE_DEBUG("** set JVM Pointer (application) **");
} else {
GALE_DEBUG("** set JVM Pointer (LiveWallpaper) **");
}
GALE_DEBUG("*******************************************");
m_JavaVirtualMachinePointer = _env;
// get default needed all time elements :
if (null != m_JavaVirtualMachinePointer) {
GALE_DEBUG("C->java : try load org/gale/Gale class");
m_javaClassGale = m_JavaVirtualMachinePointer->FindClass("org/gale/Gale" );
if (m_javaClassGale == 0) {
GALE_ERROR("C->java : Can't find org/gale/Gale class");
// remove access on the virtual machine :
m_JavaVirtualMachinePointer = null;
return;
}
/* The object field extends Activity and implement GaleCallback */
m_javaClassGaleCallback = m_JavaVirtualMachinePointer->GetObjectClass(_objCallback);
if(m_javaClassGaleCallback == null) {
GALE_ERROR("C->java : Can't find org/gale/GaleCallback class");
// remove access on the virtual machine :
m_JavaVirtualMachinePointer = null;
return;
}
bool functionCallbackIsMissing = false;
bool ret= false;
ret = safeInitMethodID(m_javaMethodGaleActivitySetTitle,
m_javaClassGaleCallback,
"titleSet",
"(Ljava/lang/String;)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
GALE_ERROR("system can not start without function : titleSet");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodGaleActivityOpenURI,
m_javaClassGaleCallback,
"openURI",
"(Ljava/lang/String;)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
GALE_ERROR("system can not start without function : openURI");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodGaleCallbackStop,
m_javaClassGaleCallback,
"stop",
"()V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
GALE_ERROR("system can not start without function : stop");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodGaleCallbackEventNotifier,
m_javaClassGaleCallback,
"eventNotifier",
"([Ljava/lang/String;)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
GALE_ERROR("system can not start without function : eventNotifier");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodGaleCallbackKeyboardUpdate,
m_javaClassGaleCallback,
"keyboardUpdate",
"(Z)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
GALE_ERROR("system can not start without function : keyboardUpdate");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodGaleCallbackOrientationUpdate,
m_javaClassGaleCallback,
"orientationUpdate",
"(I)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
GALE_ERROR("system can not start without function : orientationUpdate");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodGaleActivitySetClipBoardString,
m_javaClassGaleCallback,
"setClipBoardString",
"(Ljava/lang/String;)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
GALE_ERROR("system can not start without function : setClipBoardString");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodGaleActivityGetClipBoardString,
m_javaClassGaleCallback,
"getClipBoardString",
"()Ljava/lang/String;");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
GALE_ERROR("system can not start without function : getClipBoardString");
functionCallbackIsMissing = true;
}
m_javaObjectGaleCallback = _env->NewGlobalRef(_objCallback);
//javaObjectGaleCallbackAndActivity = objCallback;
if (m_javaObjectGaleCallback == null) {
functionCallbackIsMissing = true;
}
m_javaDefaultClassString = m_JavaVirtualMachinePointer->FindClass("java/lang/String" );
if (m_javaDefaultClassString == 0) {
GALE_ERROR("C->java : Can't find java/lang/String" );
// remove access on the virtual machine :
m_JavaVirtualMachinePointer = null;
functionCallbackIsMissing = true;
}
if (functionCallbackIsMissing == true) {
GALE_CRITICAL(" mission one function ==> system can not work withut it...");
}
}
}
~AndroidContext() {
// TODO ...
}
void unInit(JNIEnv* _env) {
_env->DeleteGlobalRef(m_javaObjectGaleCallback);
m_javaObjectGaleCallback = null;
}
int32_t run() {
// might never be called !!!
return -1;
}
void stop() {
GALE_DEBUG("C->java : send message to the java : STOP REQUESTED");
int status;
if(!java_attach_current_thread(&status)) {
return;
}
//Call java ...
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectGaleCallback, m_javaMethodGaleCallbackStop);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
void clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
// this is to force the local system to think we have the buffer
// TODO : remove this 2 line when code will be writen
m_clipBoardOwnerStd = true;
switch (_clipboardID) {
case gale::context::clipBoard::clipboardSelection:
// NOTE : Windows does not support the middle button the we do it internaly
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(_clipboardID);
break;
case gale::context::clipBoard::clipboardStd:
if (false == m_clipBoardOwnerStd) {
// generate a request TO the OS
// TODO : Send the message to the OS "We disire to receive the copy buffer ...
} else {
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(_clipboardID);
}
break;
default:
GALE_ERROR("Request an unknow ClipBoard ...");
break;
}
}
void clipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
switch (_clipboardID) {
case gale::context::clipBoard::clipboardSelection:
// NOTE : nothing to do : Windows deas ot supported Middle button
break;
case gale::context::clipBoard::clipboardStd:
// Request the clipBoard :
GALE_DEBUG("C->java : set clipboard");
if (m_javaApplicationType == appl_application) {
int status;
if(!java_attach_current_thread(&status)) {
return;
}
//Call java ...
jstring data = m_JavaVirtualMachinePointer->NewStringUTF(gale::context::clipBoard::get(_clipboardID).c_str());
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectGaleCallback, m_javaMethodGaleActivityGetClipBoardString, data);
m_JavaVirtualMachinePointer->DeleteLocalRef(data);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
} else {
GALE_ERROR("C->java : can not set clipboard");
}
break;
default:
GALE_ERROR("Request an unknow ClipBoard ...");
break;
}
}
private:
bool java_attach_current_thread(int *_rstatus) {
GALE_DEBUG("C->java : call java");
if (jvm_basics::getJavaVM() == null) {
GALE_ERROR("C->java : JVM not initialised");
m_JavaVirtualMachinePointer = null;
return false;
}
*_rstatus = jvm_basics::getJavaVM()->GetEnv((void **) &m_JavaVirtualMachinePointer, JNI_VERSION_1_6);
if (*_rstatus == JNI_EDETACHED) {
JavaVMAttachArgs lJavaVMAttachArgs;
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
lJavaVMAttachArgs.name = "GaleNativeThread";
lJavaVMAttachArgs.group = null;
int status = jvm_basics::getJavaVM()->AttachCurrentThread(&m_JavaVirtualMachinePointer, &lJavaVMAttachArgs);
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
if (status != JNI_OK) {
GALE_ERROR("C->java : AttachCurrentThread failed : " << status);
m_JavaVirtualMachinePointer = null;
return false;
}
}
return true;
}
void java_detach_current_thread(int _status) {
if(_status == JNI_EDETACHED) {
jvm_basics::getJavaVM()->DetachCurrentThread();
m_JavaVirtualMachinePointer = null;
}
}
void sendJavaKeyboardUpdate(jboolean _showIt) {
int status;
if(!java_attach_current_thread(&status)) {
GALE_ERROR("Can not attach thread ...");
return;
}
//Call java ...
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectGaleCallback, m_javaMethodGaleCallbackKeyboardUpdate, _showIt);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
void keyboardShow() {
GALE_VERBOSE("Call Keyboard SHOW");
sendJavaKeyboardUpdate(JNI_TRUE);
};
void keyboardHide() {
GALE_VERBOSE("Call Keyboard HIDE");
sendJavaKeyboardUpdate(JNI_FALSE);
};
// mode 0 : auto; 1 landscape, 2 portrait
void forceOrientation(enum gale::orientation _orientation) {
int status;
if(!java_attach_current_thread(&status)) {
return;
}
jint param = (jint)_orientation;
//Call java ...
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectGaleCallback, m_javaMethodGaleCallbackOrientationUpdate, param);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
void setTitle(const etk::String& _title) {
GALE_DEBUG("C->java : send message to the java : \"" << _title << "\"");
if (m_javaApplicationType == appl_application) {
int status;
if(!java_attach_current_thread(&status)) {
return;
}
//Call java ...
jstring title = m_JavaVirtualMachinePointer->NewStringUTF(_title.c_str());
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectGaleCallback, m_javaMethodGaleActivitySetTitle, title);
m_JavaVirtualMachinePointer->DeleteLocalRef(title);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
} else {
GALE_ERROR("C->java : can not set title on appliation that is not real application");
}
}
void openURL(const etk::String& _url) {
GALE_DEBUG("C->java : send message to the java : open URL'" << _url << "'");
int status;
if(!java_attach_current_thread(&status)) {
return;
}
//Call java ...
jstring url = m_JavaVirtualMachinePointer->NewStringUTF(_url.c_str());
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectGaleCallback, m_javaMethodGaleActivityOpenURI, url);
m_JavaVirtualMachinePointer->DeleteLocalRef(url);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
void sendSystemMessage(const char* _dataString) {
GALE_DEBUG("C->java : send message to the java : \"" << _dataString << "\"");
int status;
if(!java_attach_current_thread(&status)) {
return;
}
GALE_DEBUG("C->java : 222");
if (null == _dataString) {
GALE_ERROR("C->java : No data to send ...");
return;
}
GALE_DEBUG("C->java : 333");
// create the string to the java
jstring jstr = m_JavaVirtualMachinePointer->NewStringUTF(_dataString);
if (jstr == 0) {
GALE_ERROR("C->java : Out of memory" );
return;
}
GALE_DEBUG("C->java : 444");
// create argument list
jobjectArray args = m_JavaVirtualMachinePointer->NewObjectArray(1, m_javaDefaultClassString, jstr);
if (args == 0) {
GALE_ERROR("C->java : Out of memory" );
return;
}
GALE_DEBUG("C->java : 555");
//Call java ...
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectGaleCallback, m_javaMethodGaleCallbackEventNotifier, args);
GALE_DEBUG("C->java : 666");
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
public:
void OS_SetInput(enum gale::key::type _type,
enum gale::key::status _status,
int32_t _pointerID,
const vec2& _pos) {
GALE_VERBOSE("OS_SetInput [BEGIN]");
gale::Context::OS_SetInput(_type, _status, _pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()));
GALE_VERBOSE("OS_SetInput [END]");
}
void ANDROID_SetKeyboard(char32_t _myChar, bool _isDown, bool _isARepeateKey=false) {
GALE_VERBOSE("ANDROID_SetKeyboard [BEGIN]");
OS_setKeyboard(m_guiKeyBoardSpecialKeyMode,
gale::key::keyboard::character,
(_isDown==true?gale::key::status::down:gale::key::status::up),
_isARepeateKey,
_myChar);
GALE_VERBOSE("ANDROID_SetKeyboard [END]");
}
bool ANDROID_systemKeyboradEvent(enum gale::key::keyboard _key, bool _isDown) {
GALE_VERBOSE("ANDROID_systemKeyboradEvent [BEGIN]");
OS_setKeyboard(m_guiKeyBoardSpecialKeyMode,
_key,
(_isDown==true?gale::key::status::down:gale::key::status::up));
GALE_VERBOSE("ANDROID_systemKeyboradEvent [END]");
return false;
}
void ANDROID_SetKeyboardMove(int _move, bool _isDown, bool _isARepeateKey=false) {
GALE_VERBOSE("ANDROID_SetKeyboardMove [BEGIN]");
// direct wrapping :
enum gale::key::keyboard move = (enum gale::key::keyboard)_move;
m_guiKeyBoardSpecialKeyMode.update(move, _isDown);
OS_setKeyboard(m_guiKeyBoardSpecialKeyMode,
move,
(_isDown==true?gale::key::status::down:gale::key::status::up),
_isARepeateKey);
GALE_VERBOSE("ANDROID_SetKeyboardMove [END]");
}
void OS_Resize(const vec2& _size) {
GALE_INFO("OS_Resize [BEGIN]");
m_currentHeight = _size.y();
gale::Context::OS_Resize(_size);
GALE_INFO("OS_Resize [END]");
}
void ANDROID_start() {
GALE_INFO("ANDROID_start [BEGIN]");
GALE_INFO("ANDROID_start [END]");
}
void ANDROID_reStart() {
GALE_INFO("ANDROID_reStart [BEGIN]");
GALE_INFO("ANDROID_reStart [END]");
}
void ANDROID_create() {
GALE_INFO("ANDROID_create [BEGIN]");
start2ndThreadProcessing();
GALE_INFO("ANDROID_create [END]");
}
void ANDROID_destroy() {
GALE_INFO("ANDROID_destroy [BEGIN]");
GALE_INFO("ANDROID_destroy [END]");
}
};
static etk::Vector<AndroidContext*> s_listInstance;
gale::Application* s_applicationInit = NULL;
extern "C" {
/* Call to initialize the graphics state */
void Java_org_gale_Gale_EWparamSetArchiveDir(JNIEnv* _env,
jclass _cls,
jint _id,
jint _mode,
jstring _myString,
jstring _applicationName) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
//GALE_CRITICAL(" call with ID : " << _id);
// direct setting of the date in the string system ...
jboolean isCopy;
const char* str = _env->GetStringUTFChars(_myString, &isCopy);
jboolean isCopy2;
const char* str2 = _env->GetStringUTFChars(_applicationName, &isCopy2);
s_listInstance[_id]->setArchiveDir(_mode, str, str2);
if (isCopy == JNI_TRUE) {
// from here str is reset ...
_env->ReleaseStringUTFChars(_myString, str);
str = null;
}
if (isCopy2 == JNI_TRUE) {
// from here str is reset ...
_env->ReleaseStringUTFChars(_applicationName, str2);
str2 = null;
}
}
// declare main application instance like an application:
int main(int argc, char**argv);
jint Java_org_gale_Gale_EWsetJavaVirtualMachineStart(JNIEnv* _env,
jclass _classBase,
jobject _objCallback,
int _typeApplication) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG("*******************************************");
GALE_DEBUG("** Creating GALE context **");
GALE_DEBUG("*******************************************");
AndroidContext* tmpContext = null;
s_applicationInit = NULL;
gale::Application* localApplication = NULL;
// call the basic init of all application (that call us ...)
main(0, NULL);
localApplication = s_applicationInit;
s_applicationInit = NULL;
if (org_gale_GaleConstants_GALE_APPL_TYPE_ACTIVITY == _typeApplication) {
tmpContext = ETK_NEW(AndroidContext, localApplication, _env, _classBase, _objCallback, AndroidContext::appl_application);
} else if (org_gale_GaleConstants_GALE_APPL_TYPE_WALLPAPER == _typeApplication) {
tmpContext = ETK_NEW(AndroidContext, localApplication, _env, _classBase, _objCallback, AndroidContext::appl_wallpaper);
} else {
GALE_CRITICAL(" try to create an instance with no apply type: " << _typeApplication);
return -1;
}
if (tmpContext == null) {
GALE_ERROR("Can not allocate the main context instance _id=" << (s_listInstance.size()-1));
return -1;
}
// for future case : all time this ...
s_listInstance.pushBack(tmpContext);
int32_t newID = s_listInstance.size()-1;
return newID;
}
void Java_org_gale_Gale_EWsetJavaVirtualMachineStop(JNIEnv* _env, jclass _cls, jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG("*******************************************");
GALE_DEBUG("** remove JVM Pointer **");
GALE_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
return;
}
if (s_listInstance[_id] == null) {
GALE_ERROR("the requested instance _id=" << (int32_t)_id << " is already removed ...");
return;
}
s_listInstance[_id]->unInit(_env);
ETK_DELETE(AndroidContext, s_listInstance[_id]);
s_listInstance[_id]=null;
}
void Java_org_gale_Gale_EWtouchEvent(JNIEnv* _env, jobject _thiz, jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG(" == > Touch Event");
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id] == null) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
jvm_basics::checkExceptionJavaVM(_env);
}
void Java_org_gale_Gale_EWonCreate(JNIEnv* _env, jobject _thiz, jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG("*******************************************");
GALE_DEBUG("** Activity on Create **");
GALE_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id] == null) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->ANDROID_create();
//s_listInstance[_id]->init();
}
void Java_org_gale_Gale_EWonStart(JNIEnv* _env, jobject _thiz, jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG("*******************************************");
GALE_DEBUG("** Activity on Start **");
GALE_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id]== null) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->ANDROID_start();
//SendSystemMessage(" testmessages ... ");
}
void Java_org_gale_Gale_EWonReStart(JNIEnv* _env, jobject _thiz, jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG("*******************************************");
GALE_DEBUG("** Activity on Re-Start **");
GALE_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id] == null) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->ANDROID_reStart();
}
void Java_org_gale_Gale_EWonResume(JNIEnv* _env, jobject _thiz, jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG("*******************************************");
GALE_DEBUG("** Activity on resume **");
GALE_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id] == null) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_Resume();
}
void Java_org_gale_Gale_EWonPause(JNIEnv* _env, jobject _thiz, jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG("*******************************************");
GALE_DEBUG("** Activity on pause **");
GALE_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id] == null) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
// All the openGl has been destroyed ...
s_listInstance[_id]->getResourcesManager().contextHasBeenDestroyed();
s_listInstance[_id]->OS_Suspend();
}
void Java_org_gale_Gale_EWonStop(JNIEnv* _env, jobject _thiz, jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG("*******************************************");
GALE_DEBUG("** Activity on Stop **");
GALE_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id] == null) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_Stop();
}
void Java_org_gale_Gale_EWonDestroy(JNIEnv* _env, jobject _thiz, jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_DEBUG("*******************************************");
GALE_DEBUG("** Activity on Destroy **");
GALE_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id] == null) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->ANDROID_destroy();
//s_listInstance[_id]->UnInit();
}
/* **********************************************************************************************
* ** IO section :
* ********************************************************************************************** */
void Java_org_gale_Gale_EWinputEventMotion(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID,
jfloat _x,
jfloat _y) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id] == null) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_SetInput(gale::key::type::finger,
gale::key::status::move,
_pointerID+1,
vec2(_x,_y));
}
void Java_org_gale_Gale_EWinputEventState(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID,
jboolean _isDown,
jfloat _x,
jfloat _y) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id < 0
|| s_listInstance[_id] == null ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_SetInput(gale::key::type::finger,
(_isDown==true?gale::key::status::down:gale::key::status::up),
_pointerID+1,
vec2(_x,_y));
}
void Java_org_gale_Gale_EWmouseEventMotion(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID,
jfloat _x,
jfloat _y) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_SetInput(gale::key::type::mouse,
gale::key::status::move,
_pointerID+1,
vec2(_x,_y));
}
void Java_org_gale_Gale_EWmouseEventState(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID,
jboolean _isDown,
jfloat _x,
jfloat _y) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_SetInput(gale::key::type::mouse,
(_isDown==true?gale::key::status::down:gale::key::status::up),
_pointerID+1,
vec2(_x,_y));
}
void Java_org_gale_Gale_EWunknowEvent(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
GALE_DEBUG("Unknown IO event : " << _pointerID << " ???");
}
void Java_org_gale_Gale_EWkeyboardEventMove(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _type,
jboolean _isdown) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
GALE_DEBUG("IO keyboard Move event : \"" << _type << "\" is down=" << _isdown);
s_listInstance[_id]->ANDROID_SetKeyboardMove(_type, _isdown);
}
void Java_org_gale_Gale_EWkeyboardEventKey(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _uniChar,
jboolean _isdown) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
GALE_DEBUG("IO keyboard Key event : \"" << _uniChar << "\" is down=" << _isdown);
s_listInstance[_id]->ANDROID_SetKeyboard(_uniChar, _isdown);
}
void Java_org_gale_Gale_EWdisplayPropertyMetrics(JNIEnv* _env,
jobject _thiz,
jint _id,
jfloat _ratioX,
jfloat _ratioY) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
// set the internal system ratio properties ...
gale::Dimension::setPixelRatio(vec2(_ratioX,_ratioY), gale::distance::inch);
}
// TODO : set a return true or false if we want to grep this event ...
bool Java_org_gale_Gale_EWkeyboardEventKeySystem(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _keyVal,
jboolean _isdown) {
ethread::UniqueLock lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return false;
}
switch (_keyVal) {
case org_gale_GaleConstants_GALE_SYSTEM_KEY_VOLUME_UP:
GALE_VERBOSE("IO keyboard Key system \"VOLUME_UP\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(gale::key::keyboard::volumeUp, _isdown);
case org_gale_GaleConstants_GALE_SYSTEM_KEY_VOLUME_DOWN:
GALE_DEBUG("IO keyboard Key system \"VOLUME_DOWN\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(gale::key::keyboard::volumeDown, _isdown);
case org_gale_GaleConstants_GALE_SYSTEM_KEY_MENU:
GALE_DEBUG("IO keyboard Key system \"MENU\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(gale::key::keyboard::menu, _isdown);
case org_gale_GaleConstants_GALE_SYSTEM_KEY_CAMERA:
GALE_DEBUG("IO keyboard Key system \"CAMERA\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(gale::key::keyboard::camera, _isdown);
case org_gale_GaleConstants_GALE_SYSTEM_KEY_HOME:
GALE_DEBUG("IO keyboard Key system \"HOME\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(gale::key::keyboard::home, _isdown);
case org_gale_GaleConstants_GALE_SYSTEM_KEY_POWER:
GALE_DEBUG("IO keyboard Key system \"POWER\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(gale::key::keyboard::power, _isdown);
case org_gale_GaleConstants_GALE_SYSTEM_KEY_BACK:
GALE_DEBUG("IO keyboard Key system \"BACK\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(gale::key::keyboard::back, _isdown);
default:
GALE_ERROR("IO keyboard Key system event : \"" << _keyVal << "\" is down=" << _isdown);
break;
}
return false;
}
/* **********************************************************************************************
* ** Renderer section :
* ********************************************************************************************** */
void Java_org_gale_Gale_EWrenderInit(JNIEnv* _env,
jobject _thiz,
jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_VERBOSE("Java_org_gale_Gale_EWrenderInit [BEGIN]");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
GALE_VERBOSE("Java_org_gale_Gale_EWrenderInit [END]");
}
void Java_org_gale_Gale_EWrenderResize(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _w,
jint _h) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_VERBOSE("Java_org_gale_Gale_EWrenderResize [BEGIN]");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_Resize(vec2(_w, _h));
GALE_VERBOSE("Java_org_gale_Gale_EWrenderResize [END]");
}
// TODO : Return true or false to not redraw when the under draw has not be done (processing gain of time)
void Java_org_gale_Gale_EWrenderDraw(JNIEnv* _env,
jobject _thiz,
jint _id) {
ethread::UniqueLock lock(g_interfaceMutex);
GALE_VERBOSE("Java_org_gale_Gale_EWrenderDraw [BEGIN]");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| null == s_listInstance[_id] ) {
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_Draw(true);
GALE_VERBOSE("Java_org_gale_Gale_EWrenderDraw [END]");
}
};
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
s_applicationInit = _application;
return 0;
}

View File

@ -1,29 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#if 0
namespace gale {
namespace context {
namespace Android {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,318 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/os/Fifo.hpp>
#include <etk/uri/uri.hpp>
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/key/key.hpp>
#include <gale/resource/Manager.hpp>
#include <gale/Application.hpp>
#include <gale/context/clipBoard.hpp>
#include <gale/context/commandLine.hpp>
#include <gale/context/Fps.hpp>
#include <gale/Thread.hpp>
#include <ememory/memory.hpp>
#include <gale/orientation.hpp>
#include <gale/context/clipBoard.hpp>
#include <ethread/tools.hpp>
#include <ethread/MutexRecursive.hpp>
#include <echrono/Steady.hpp>
#define MAX_MANAGE_INPUT (15)
namespace gale {
class Thread;
class PeriodicThread;
class Context {
friend class gale::PeriodicThread;
protected:
ethread::MutexRecursive m_mutex;
ememory::SharedPtr<gale::Thread> m_periodicThread;
private:
ememory::SharedPtr<gale::Application> m_application; //!< Application handle
public:
ememory::SharedPtr<gale::Application> getApplication() {
return m_application;
}
private:
gale::context::CommandLine m_commandLine; //!< Start command line information
public:
gale::context::CommandLine& getCmd() {
return m_commandLine;
};
private:
gale::resource::Manager m_resourceManager; //!< global resources Manager
public:
gale::resource::Manager& getResourcesManager() {
return m_resourceManager;
};
public:
Context(gale::Application* _application, int32_t _argc=0, const char* _argv[]=null);
virtual ~Context();
/**
* @brief StartProcessing (2nd thread).
* @note to call when all the Context is started
*/
void start2ndThreadProcessing();
protected:
/**
* @brief set the curent interface.
* @note this lock the main mutex
*/
void lockContext();
/**
* @brief set the curent interface at null.
* @note this un-lock the main mutex
*/
void unLockContext();
protected:
// simulation area:
bool m_simulationActive;
etk::Uri m_simulationUri;
ememory::SharedPtr<etk::io::Interface> m_simulationFile;
private:
echrono::Steady m_previousDisplayTime; // this is to limit framerate ... in case...
etk::Fifo<etk::Function<void(gale::Context& _context)> > m_msgSystem;
bool m_displayFps;
gale::context::Fps m_FpsSystemEvent;
gale::context::Fps m_FpsSystemContext;
gale::context::Fps m_FpsSystem;
gale::context::Fps m_FpsFlush;
/**
* @brief Processing all the event arrived ... (commoly called in draw function)
*/
void processEvents();
public:
void postAction(etk::Function<void(gale::Context& _context)> _action);
public:
virtual void setArchiveDir(int _mode, const char* _str, const char* _applName=null);
virtual void OS_SetInput(enum gale::key::type _type,
enum gale::key::status _status,
int32_t _pointerID,
const vec2& _pos);
virtual void OS_setKeyboard(const gale::key::Special& _special,
enum gale::key::keyboard _type,
enum gale::key::status _state,
bool _isARepeateKey = false,
char32_t _char = u32char::Null);
/**
* @brief The current context is suspended
*/
virtual void OS_Suspend();
/**
* @brief The current context is resumed
*/
virtual void OS_Resume();
/**
* @brief The current context is set in foreground (framerate is maximum speed)
*/
virtual void OS_Foreground();
/**
* @brief The current context is set in background (framerate is slowing down (max fps)/5 # 4fps)
*/
virtual void OS_Background();
public:
void requestUpdateSize();
public:
// return true if a flush is needed
bool OS_Draw(bool _displayEveryTime);
public:
/**
* @brief reset event management for the IO like Input ou Mouse or keyborad
*/
void resetIOEvent();
/**
* @brief The OS inform that the openGL constext has been destroy == > use to automaticly reload the texture and other thinks ...
*/
void OS_OpenGlContextDestroy();
/**
* @brief The OS Inform that the Window has been killed
*/
void OS_Stop();
/**
* @brief The application request that the Window will be killed
*/
virtual void stop();
protected:
ivec2 m_windowsSize; //!< current size of the system
public:
/**
* @brief get the current windows size
* @return the current size ...
*/
const ivec2& getSize() {
return m_windowsSize;
};
/**
* @brief The OS inform that the current windows has change his size.
* @param[in] _size new size of the windows.
*/
virtual void OS_Resize(const vec2& _size);
/**
* @brief The application request a change of his curent size.
* @param[in] _size new Requested size of the windows.
*/
virtual void setSize(const vec2& _size);
/**
* @brief The application request a change of his current size force the fullscreen mode.
* @param[in] _status status of the fullscreen mode.
*/
virtual void setFullScreen(bool _status);
protected:
ivec2 m_windowsPos; //!< current size of the system
public:
/**
* @brief The OS inform that the current windows has change his position.
* @param[in] _pos New position of the Windows.
*/
void OS_Move(const vec2& _pos);
/**
* @brief The Application request that the current windows will change his position.
* @param[in] _pos New position of the Windows requested.
*/
virtual void setPos(const vec2& _pos);
/**
* @brief The Application request the current position of the windows.
* @return Turrent position of the Windows.
*/
virtual vec2 getPos();
/**
* @brief The OS inform that the Windows is now Hidden.
*/
void OS_Hide();
/**
* @brief The Application request that the Windows will be Hidden.
*/
virtual void hide();
/**
* @brief The OS inform that the Windows is now visible.
*/
void OS_Show();
/**
* @brief The Application request that the Windows will be visible.
*/
virtual void show();
/**
* @brief Redraw all the windows
*/
void forceRedrawAll();
/**
* @brief display the virtal keyboard (for touch system only)
*/
virtual void keyboardShow();
/**
* @brief Hide the virtal keyboard (for touch system only)
*/
virtual void keyboardHide();
/**
* @brief Inform the Gui that we want to have a copy of the clipboard
* @param[in] _clipboardID ID of the clipboard (STD/SELECTION) only apear here
*/
virtual void clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID);
/**
* @brief Inform the Gui that we are the new owner of the clipboard
* @param[in] _clipboardID ID of the clipboard (STD/SELECTION) only apear here
*/
virtual void clipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID);
/**
* @brief Call by the OS when a clipboard arrive to US (previously requested by a widget)
* @param[in] Id of the clipboard
*/
void OS_ClipBoardArrive(enum gale::context::clipBoard::clipboardListe _clipboardID);
/**
* @brief set the new title of the windows
* @param[in] title New desired title
*/
virtual void setTitle(const etk::String& _title);
/**
* @brief Open an URL on an eternal brother.
* @param[in] _url URL to open.
*/
virtual void openURL(const etk::String& _url) { };
/**
* @brief force the screen orientation (availlable on portable elements ...
* @param[in] _orientation Selected orientation.
*/
virtual void forceOrientation(enum gale::orientation _orientation) { };
/**
* @brief get all Keyboard event from the X system (like many time use of META)
* @param[in] _status "true" if all the event will be get, false if we want only ours.
*/
virtual void grabKeyboardEvents(bool _status) {}
/**
* @brief get all Mouse/Touch events from the X system
* @param[in] _status "true" if all the event will be get, false if we want only ours.
* @param[in] _forcedPosition the position where the mouse might be reset at every events ...
*/
virtual void grabPointerEvents(bool _status, const vec2& _forcedPosition) { };
/**
* @brief set the cursor display type.
* @param[in] _newCursor selected new cursor.
*/
virtual void setCursor(enum gale::context::cursor _newCursor) { };
/**
* @brief set the Icon of the program
* @param[in] _inputFile new filename icon of the curent program.
*/
virtual void setIcon(const etk::Uri& _inputFile) { };
/**
* @brief Enable or Disable the decoration on the Windows (availlable only on Desktop)
* @param[in] _status "true" to enable decoration / false otherwise
*/
virtual void setWindowsDecoration(bool _status) {};
private:
// TODO : set user argument here ....
public:
/**
* @brief This is the only one things the User might done in his main();
* @note : must be implemented in all system OPS implementation
* @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[in] _argc Standard argc
* @param[in] _argv Standard argv
* @return normal error int for the application error management
*/
static int main(int _argc, const char *_argv[]);
public:
/**
* @brief Internal API to run the processing of the event loop ...
* @return The Exit value of the program
* @note INTERNAL API
*/
virtual int32_t run() = 0;
};
/**
* @brief From everyware in the program, we can get the context inteface.
* @return current reference on the instance.
*/
Context& getContext();
/**
* @brief Set a context of the current thread.
* @param[in] _context Current context to associate.
*/
void setContext(gale::Context* _context);
/**
* @brief When a new thread is created, it is needed to register it in the gale context interface to permit to get the context associated on it ...
* @param[in] _thread generic C++11 thread handle
*/
void contextRegisterThread(ethread::Thread* _thread);
/**
* @brief Remove an associated thread
* @param[in] _thread generic C++11 thread handle
*/
void contextUnRegisterThread(ethread::Thread* _thread);
}

View File

@ -1,138 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <echrono/Steady.hpp>
#include <echrono/Duration.hpp>
namespace gale {
namespace context {
/**
* @brief This class is designed to count the number of frame per second in the main renderer system
* @not_in_doc
*/
class Fps {
private:
echrono::Steady m_startTime;
int64_t m_nbCallTime;
int64_t m_nbDisplayTime;
echrono::Duration m_min;
echrono::Duration m_avg;
echrono::Duration m_max;
echrono::Duration m_min_idle;
echrono::Duration m_avg_idle;
echrono::Duration m_max_idle;
echrono::Steady m_ticTime;
echrono::Steady m_lastDrawTime;
bool m_display;
bool m_drawingDone;
const char * m_displayName;
bool m_displayFPS;
public:
/**
* @brief Constructor
*/
Fps(const char* _displayName, bool _displayFPS):
m_nbCallTime(0),
m_nbDisplayTime(0),
m_min(99999999,0),
m_avg(0,0),
m_max(0,0),
m_min_idle(99999999,0),
m_avg_idle(0,0),
m_max_idle(0,0),
m_display(false),
m_drawingDone(false),
m_displayName(_displayName),
m_displayFPS(_displayFPS) {
m_lastDrawTime = echrono::Steady::now();
}
/**
* @brief Destructor
*/
~Fps() {
}
/**
* @brief this might be call every time a diplay start
*/
void tic() {
echrono::Steady currentTime = echrono::Steady::now();
m_ticTime = currentTime;
m_nbCallTime++;
if (m_startTime == echrono::Steady()) {
m_startTime = currentTime;
}
//GALE_DEBUG("current : " << currentTime << "time diff : " << (currentTime - m_startTime));
if ( (currentTime - m_startTime) > echrono::seconds(10)) {
m_display = true;
}
}
/**
* @brief this might be call every time a diplay stop, it do the display every second
* @param[in] displayTime display curent time of the frame.
*/
void toc(bool _displayTime = false) {
echrono::Steady currentTime = echrono::Steady::now();
echrono::Duration processTimeLocal = (currentTime - m_ticTime);
if (_displayTime == true) {
GALE_PRINT(m_displayName << ": processTime: " << processTimeLocal);
}
if (m_drawingDone == true) {
m_min = etk::min(m_min, processTimeLocal);
m_max = etk::max(m_max, processTimeLocal);
m_avg += processTimeLocal;
m_drawingDone = false;
} else {
m_min_idle = etk::min(m_min_idle, processTimeLocal);
m_max_idle = etk::max(m_max_idle, processTimeLocal);
m_avg_idle += processTimeLocal;
}
}
/**
* @brief this might be call when a display is really done
*/
void incrementCounter() {
m_nbDisplayTime++;
m_drawingDone = true;
}
/**
* @brief draw debug display ...
*/
void draw() {
if (m_display == true) {
if (m_nbDisplayTime > 0) {
GALE_PRINT(m_displayName << " : Active : "
<< m_min << " | "
<< m_avg / m_nbDisplayTime << " | "
<< m_max << " ");
}
if (m_nbCallTime-m_nbDisplayTime>0) {
GALE_PRINT(m_displayName << " : idle : "
<< m_min_idle << " | "
<< m_avg_idle / (m_nbCallTime-m_nbDisplayTime) << " | "
<< m_max_idle << " ");
}
if (m_displayFPS == true) {
float nbSeconds = (echrono::Steady::now() - m_lastDrawTime).toSeconds();
m_lastDrawTime = echrono::Steady::now();
GALE_PRINT("FPS : " << m_nbDisplayTime << "/" << m_nbCallTime << " frames ==> " << (float(m_nbDisplayTime)/nbSeconds) << "fps");
}
m_max = echrono::Duration(0);
m_min = echrono::Duration(99999999,0);
m_avg = echrono::Duration(0);
m_max_idle = echrono::Duration(0);
m_min_idle = echrono::Duration(99999999,0);
m_avg_idle = echrono::Duration(0);
m_nbCallTime = 0;
m_nbDisplayTime = 0;
m_startTime = echrono::Steady();
m_display = false;
}
}
};
}
}

View File

@ -1,18 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#import <UIKit/UIKit.h>
@class OpenglView;
@interface AppDelegate : UIResponder <UIApplicationDelegate> {
UIWindow *window;
OpenglView *glView;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet OpenglView *glView;
@end

View File

@ -1,95 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#import <UIKit/UIKit.h>
#include "gale/context/IOs/Interface.h"
#import <gale/context/IOs/OpenglView.hpp>
#import <gale/context/IOs/AppDelegate.hpp>
#include <gale/context/IOs/Context.hpp>
#include <gale/debug.hpp>
@implementation AppDelegate
@synthesize window;
@synthesize glView;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
NSLog(@"Start with screeen bounds : %fx%f\n", screenBounds.size.width, screenBounds.size.height);
CGSize currentSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
//screenBounds.size.width *= screenScale;
//screenBounds.size.height *= screenScale;
NSLog(@"Start with screeen bounds : %fx%f\n", screenBounds.size.width, screenBounds.size.height);
window = [[UIWindow alloc] initWithFrame:screenBounds];
window.contentMode = UIViewContentModeRedraw;
glView = [[OpenglView alloc] initWithFrame:window.bounds];
glView.contentMode = UIViewContentModeRedraw;
[window addSubview:glView];
[window makeKeyAndVisible];
// Create interface of gale here ....
NSLog(@"CREATE GALE interface creation\n");
IOs::createInterface();
IOs::resize(currentSize.width, currentSize.height);
IOs::start();
}
/*
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
*/
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
GALE_INFO("move windows in applicationWillResignActive");
[glView speedSlow];
IOs::background();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
GALE_INFO("move windows in applicationDidEnterBackground");
[glView stopDisplayLink];
IOs::suspend();
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
GALE_INFO("move windows in applicationWillEnterForeground");
IOs::resume();
[glView startDisplayLink];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
GALE_INFO("move windows in applicationDidBecomeActive");
[glView speedNormal];
IOs::foreground();
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Create interface of gale here ....
GALE_INFO("move windows in applicationWillTerminate");
IOs::stop();
IOs::releaseInterface();
}
/*
- (void)dealloc {
[window release];
[glView release];
[super dealloc];
}
*/
@end

View File

@ -1,274 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/key/key.hpp>
#include <gale/context/commandLine.hpp>
#include <etk/types.hpp>
#include <etk/uri/uri.hpp>
#include <gale/resource/Manager.hpp>
#include <gale/context/Context.hpp>
#include <gale/context/IOs/Interface.h>
#include <gale/context/IOs/Context.hpp>
extern "C" {
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
}
#include <sys/times.h>
#include <mach/clock.h>
#include <mach/mach.h>
#include <etk/etk.hpp>
class MacOSInterface : public gale::Context {
private:
gale::key::Special m_guiKeyBoardMode;
public:
MacOSInterface(gale::Application* _application, int32_t _argc, const char* _argv[]) :
gale::Context(_application, _argc, _argv) {
// nothing to do ...
start2ndThreadProcessing();
}
int32_t Run() {
return 0;
}
virtual void stop() {
mm_exit();
}
public:
//interface MacOS :
bool MAC_Draw(bool _displayEveryTime) {
return OS_Draw(_displayEveryTime);
}
void MAC_Resize(float _x, float _y) {
OS_Resize(vec2(_x,_y));
}
void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) {
OS_SetInput(gale::key::type::mouse,
(_isDown==true?gale::key::status::down:gale::key::status::up),
_id,
vec2(_x, _y));
}
void MAC_SetMouseMotion(int32_t _id, float _x, float _y) {
OS_SetInput(gale::key::type::mouse,
gale::key::status::move,
_id,
vec2(_x, _y));
}
void MAC_SetInputState(int32_t _id, bool _isDown, float _x, float _y) {
OS_SetInput(gale::key::type::finger,
(_isDown==true?gale::key::status::down:gale::key::status::up),
_id,
vec2(_x, _y));
}
void MAC_SetInputMotion(int32_t _id, float _x, float _y) {
OS_SetInput(gale::key::type::finger,
gale::key::status::move,
_id,
vec2(_x, _y));
}
void MAC_SetKeyboard(gale::key::Special _special, int32_t _unichar, bool _isDown, bool _isARepeateKey) {
if (_unichar == u32char::Delete) {
_unichar = u32char::Suppress;
} else if (_unichar == u32char::Suppress) {
_unichar = u32char::Delete;
}
if (_unichar == u32char::CarrierReturn) {
_unichar = u32char::Return;
}
//GALE_DEBUG("key: " << _unichar << " up=" << !_isDown);
if (_unichar <= 4) {
enum gale::key::keyboard move;
switch(_unichar) {
case 0:
move = gale::key::keyboard::up;
break;
case 1:
move = gale::key::keyboard::down;
break;
case 2:
move = gale::key::keyboard::left;
break;
case 3:
move = gale::key::keyboard::right;
break;
}
OS_setKeyboard(_special,
move,
(_isDown==false?gale::key::status::down:gale::key::status::up),
_isARepeateKey);
} else {
OS_setKeyboard(_special,
gale::key::keyboard::character,
(_isDown==false?gale::key::status::down:gale::key::status::up),
_isARepeateKey,
_unichar);
}
}
void MAC_SetKeyboardMove(gale::key::Special& _special,
enum gale::key::keyboard _move,
bool _isDown) {
OS_setKeyboard(_special,
_move,
(_isDown==true?gale::key::status::down:gale::key::status::up));
}
void openURL(const etk::String& _url) {
mm_openURL(_url.c_str());
}
};
MacOSInterface* interface = null;
bool IOs::draw(bool _displayEveryTime) {
if (interface == null) {
return false;
}
return interface->MAC_Draw(_displayEveryTime);
}
void IOs::resize(float _x, float _y) {
if (interface == null) {
return;
}
interface->MAC_Resize(_x, _y);
}
void IOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) {
if (interface == null) {
return;
}
interface->MAC_SetMouseState(_id, _isDown, _x, _y);
}
void IOs::setMouseMotion(int32_t _id, float _x, float _y) {
if (interface == null) {
return;
}
interface->MAC_SetMouseMotion(_id, _x, _y);
}
void IOs::setInputState(int32_t _id, bool _isDown, float _x, float _y) {
if (interface == null) {
return;
}
interface->MAC_SetInputState(_id, _isDown, _x, _y);
}
void IOs::setInputMotion(int32_t _id, float _x, float _y) {
if (interface == null) {
return;
}
interface->MAC_SetInputMotion(_id, _x, _y);
}
void IOs::setKeyboard(gale::key::Special _special, int32_t _unichar, bool _isDown, bool _isARepeateKey) {
if (interface == null) {
return;
}
interface->MAC_SetKeyboard(_special, _unichar, _isDown, _isARepeateKey);
}
void IOs::setKeyboardMove(gale::key::Special& _special, enum gale::key::keyboard _move, bool _isDown) {
if (interface == null) {
return;
}
interface->MAC_SetKeyboardMove(_special, _move, _isDown);
}
void IOs::start() {
if (interface == null) {
return;
}
//interface->OS_Start();
}
void IOs::resume() {
if (interface == null) {
return;
}
interface->OS_Resume();
}
void IOs::suspend() {
if (interface == null) {
return;
}
interface->OS_Suspend();
}
void IOs::stop() {
if (interface == null) {
return;
}
interface->OS_Stop();
}
void IOs::background() {
if (interface == null) {
return;
}
interface->OS_Background();
}
void IOs::foreground() {
if (interface == null) {
return;
}
interface->OS_Foreground();
}
static int l_argc = 0;
static const char **l_argv = null;
static gale::Application* l_application;
/**
* @brief Main of the program
* @param std IO
* @return std IO
*/
int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
l_argc = _argc;
l_argv = _argv;
l_application = _application;
return mm_main(_argc, _argv);
}
// Creat and relaese gale::Context interface:
void IOs::createInterface() {
etk::init(l_argc, l_argv);
GALE_INFO("Create new interface");
interface = ETK_NEW(MacOSInterface, l_application, l_argc, l_argv);
l_application = null;
if (interface == null) {
GALE_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return;
}
}
void IOs::releaseInterface() {
if (interface != null) {
GALE_INFO("Remove interface");
}
ETK_DELETE(MacOSInterface, interface);
interface = null;
}

View File

@ -1,56 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/key/key.hpp>
namespace IOs {
// Create and relaese gale::Context interface:
void createInterface();
void releaseInterface();
// return true if a flush is needed
bool draw(bool _displayEveryTime);
/**
* @brief The OS inform that the current windows has change his size.
* @param[in] _size new size of the windows.
*/
void resize(float _x, float _y);
void setMouseState(int32_t _id, bool _isDown, float _x, float _y);
void setMouseMotion(int32_t _id, float _x, float _y);
void setInputState(int32_t _id, bool _isDown, float _x, float _y);
void setInputMotion(int32_t _id, float _x, float _y);
void setKeyboard(gale::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
void setKeyboardMove(gale::key::Special& _keyboardMode, enum gale::key::keyboard _move, bool _isDown);
void start();
void stop();
void foreground();
void background();
void resume();
void suspend();
}
#if 0
namespace gale {
namespace context {
namespace ios {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}
#endif

View File

@ -1,19 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
int mm_main(int _argc, const char *_argv[]);
void mm_exit();
void mm_openURL(const char *_url);
#ifdef __cplusplus
}
#endif

View File

@ -1,31 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
#import <UIKit/UIKit.h>
#import <gale/context/IOs/AppDelegate.hpp>
//#import "AppDelegate.h"
int mm_main(int argc, const char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, (char**)argv, nil, NSStringFromClass([AppDelegate class]));
}
// return no error
return 0;
}
void mm_exit(void) {
[[NSThread mainThread] cancel];
}
void mm_openURL(const char *_url) {
NSString* url = [[NSString alloc] initWithUTF8String:_url];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

View File

@ -1,41 +0,0 @@
//
// EAGLView.h
// OpenGLBasics
//
// Created by Charlie Key on 6/24/09.
//
#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
/*
This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
The view content is basically an EAGL surface you render your OpenGL scene into.
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
*/
@interface OpenglView : UIView {
@private
CAEAGLLayer* _eaglLayer;
EAGLContext *_context;
GLuint _colorRenderBuffer;
GLuint _depthRenderBuffer;
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
GLuint viewRenderbuffer, viewFramebuffer;
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
GLuint depthRenderbuffer;
CGSize m_currentSize;
CADisplayLink* displayLink; //!< link to start and stop display of the view...
int deltaDisplay;
int displayCounter;
}
- (void)stopDisplayLink;
- (void)startDisplayLink;
- (void)speedSlow;
- (void)speedNormal;
@end

View File

@ -1,281 +0,0 @@
//
// EAGLView.m
// OpenGLBasics
//
// Created by Charlie Key on 6/24/09.
//
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGLDrawable.h>
#include <gale/context/IOs/Context.hpp>
#include <gale/Dimension.hpp>
#include <sys/types.h>
#include <sys/sysctl.h>
#import "OpenglView.hpp"
#include <gale/debug.hpp>
@interface OpenglView ()
@end
@implementation OpenglView
// You must implement this method (it does not work without it)
+ (Class)layerClass {
return [CAEAGLLayer class];
}
- (NSString *) platform {
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = (char*)malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
free(machine);
return platform;
}
- (NSString *) platformString {
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,3"]) return @"Verizon iPhone 4";
if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (GSM)";
if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (GSM)";
if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (GSM)";
if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (GSM+CDMA)";
if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G";
if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G";
if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G";
if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G";
if ([platform isEqualToString:@"iPod5,1"]) return @"iPod Touch 5G";
if ([platform isEqualToString:@"iPad1,1"]) return @"iPad";
if ([platform isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,2"]) return @"iPad 2 (GSM)";
if ([platform isEqualToString:@"iPad2,3"]) return @"iPad 2 (CDMA)";
if ([platform isEqualToString:@"iPad2,4"]) return @"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,5"]) return @"iPad Mini (WiFi)";
if ([platform isEqualToString:@"iPad2,6"]) return @"iPad Mini (GSM)";
if ([platform isEqualToString:@"iPad2,7"]) return @"iPad Mini (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,1"]) return @"iPad 3 (WiFi)";
if ([platform isEqualToString:@"iPad3,2"]) return @"iPad 3 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,3"]) return @"iPad 3 (GSM)";
if ([platform isEqualToString:@"iPad3,4"]) return @"iPad 4 (WiFi)";
if ([platform isEqualToString:@"iPad3,5"]) return @"iPad 4 (GSM)";
if ([platform isEqualToString:@"iPad3,6"]) return @"iPad 4 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad4,1"]) return @"iPad Air (WiFi)";
if ([platform isEqualToString:@"iPad4,2"]) return @"iPad Air (Cellular)";
if ([platform isEqualToString:@"iPad4,4"]) return @"iPad mini 2G (WiFi)";
if ([platform isEqualToString:@"iPad4,5"]) return @"iPad mini 2G (Cellular)";
if ([platform isEqualToString:@"i386"]) return @"Simulator";
if ([platform isEqualToString:@"x86_64"]) return @"Simulator";
return platform;
}
- (float)getScreenPPP {
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return 326.0f; //@"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return 326.0f; //@"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return 326.0f; //@"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"]) return 326.0f; //@"iPhone 4";
if ([platform isEqualToString:@"iPhone3,3"]) return 326.0f; //@"Verizon iPhone 4";
if ([platform isEqualToString:@"iPhone4,1"]) return 326.0f; //@"iPhone 4S";
if ([platform isEqualToString:@"iPhone5,1"]) return 326.0f; //@"iPhone 5 (GSM)";
if ([platform isEqualToString:@"iPhone5,2"]) return 326.0f; //@"iPhone 5 (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,3"]) return 326.0f; //@"iPhone 5c (GSM)";
if ([platform isEqualToString:@"iPhone5,4"]) return 326.0f; //@"iPhone 5c (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone6,1"]) return 326.0f; //@"iPhone 5s (GSM)";
if ([platform isEqualToString:@"iPhone6,2"]) return 326.0f; //@"iPhone 5s (GSM+CDMA)";
if ([platform isEqualToString:@"iPod1,1"]) return 326.0f; //@"iPod Touch 1G";
if ([platform isEqualToString:@"iPod2,1"]) return 326.0f; //@"iPod Touch 2G";
if ([platform isEqualToString:@"iPod3,1"]) return 326.0f; //@"iPod Touch 3G";
if ([platform isEqualToString:@"iPod4,1"]) return 326.0f; //@"iPod Touch 4G";
if ([platform isEqualToString:@"iPod5,1"]) return 326.0f; //@"iPod Touch 5G";
if ([platform isEqualToString:@"iPad1,1"]) return 264.0f; //@"iPad";
if ([platform isEqualToString:@"iPad2,1"]) return 264.0f; //@"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,2"]) return 264.0f; //@"iPad 2 (GSM)";
if ([platform isEqualToString:@"iPad2,3"]) return 264.0f; //@"iPad 2 (CDMA)";
if ([platform isEqualToString:@"iPad2,4"]) return 264.0f; //@"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,5"]) return 163.0f; //@"iPad Mini (WiFi)";
if ([platform isEqualToString:@"iPad2,6"]) return 163.0f; //@"iPad Mini (GSM)";
if ([platform isEqualToString:@"iPad2,7"]) return 163.0f; //@"iPad Mini (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,1"]) return 264.0f; //@"iPad 3 (WiFi)";
if ([platform isEqualToString:@"iPad3,2"]) return 264.0f; //@"iPad 3 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,3"]) return 264.0f; //@"iPad 3 (GSM)";
if ([platform isEqualToString:@"iPad3,4"]) return 264.0f; //@"iPad 4 (WiFi)";
if ([platform isEqualToString:@"iPad3,5"]) return 264.0f; //@"iPad 4 (GSM)";
if ([platform isEqualToString:@"iPad3,6"]) return 264.0f; //@"iPad 4 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad4,1"]) return 264.0f; //@"iPad Air (WiFi)";
if ([platform isEqualToString:@"iPad4,2"]) return 264.0f; //@"iPad Air (Cellular)";
if ([platform isEqualToString:@"iPad4,4"]) return 326.0f; //@"iPad mini 2G (WiFi)";
if ([platform isEqualToString:@"iPad4,5"]) return 326.0f; //@"iPad mini 2G (Cellular)";
if ([platform isEqualToString:@"i386"]) return 200.0f; //@"Simulator";
if ([platform isEqualToString:@"x86_64"]) return 326.0f; //@"Simulator";
return 326.0f;
}
- (void)setNeedsDisplay {
GALE_INFO("**** setNeedsDisplay:" << vec2(self.frame.size.width, self.frame.size.height));
// TODO : SIZE change ...
}
- (void)configureAspectRatio {
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
m_currentSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
//self.frame.size = m_currentSize;
GALE_INFO("**** screen size:" << vec2(m_currentSize.width, m_currentSize.height));
float ratio = [self getScreenPPP];
GALE_INFO("**** pixel ratio: " << ratio);
gale::Dimension::setPixelRatio(vec2(1.0f/ratio, 1.0f/ratio), gale::distance::inch);
IOs::resize(m_currentSize.width, m_currentSize.height);
CGRect localBounds = [self bounds];
GALE_INFO("**** localBounds:" << vec2(localBounds.size.width, localBounds.size.height));
}
- (void)setupLayer {
_eaglLayer = (CAEAGLLayer*) self.layer;
CGFloat screenScale = [[UIScreen mainScreen] scale];
_eaglLayer.contentsScale = screenScale;
_eaglLayer.opaque = YES;
}
- (void)setupContext {
EAGLRenderingAPI api = kEAGLRenderingAPIOpenGLES2;
_context = [[EAGLContext alloc] initWithAPI:api];
if (!_context) {
NSLog(@"Failed to initialize OpenGLES 2.0 context");
exit(1);
}
if (![EAGLContext setCurrentContext:_context]) {
NSLog(@"Failed to set current OpenGL context");
exit(1);
}
}
- (void)setupRenderBuffer {
glGenRenderbuffers(1, &_colorRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderBuffer);
[_context renderbufferStorage:GL_RENDERBUFFER fromDrawable:_eaglLayer];
}
- (void)setupDepthBuffer {
glGenRenderbuffers(1, &_depthRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _depthRenderBuffer);
CGFloat screenScale = [[UIScreen mainScreen] scale];
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, self.frame.size.width*screenScale, self.frame.size.height*screenScale);
}
- (void)setupFrameBuffer {
GLuint framebuffer;
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorRenderBuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _depthRenderBuffer);
}
- (void)render:(CADisplayLink*)displayLink {
displayCounter++;
if (displayCounter >= deltaDisplay) {
displayCounter = 0;
IOs::draw(true);
[_context presentRenderbuffer:GL_RENDERBUFFER];
}
}
- (void)speedSlow {
deltaDisplay = 5;
}
- (void)speedNormal {
deltaDisplay = 1;
}
- (void)startDisplayLink {
if (displayLink != NULL) {
return;
}
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render:)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
- (void)stopDisplayLink {
if (displayLink == NULL) {
return;
}
[displayLink removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
displayLink = NULL;
}
- (id)initWithFrame:(CGRect)frame {
deltaDisplay = 1;
displayCounter = 0;
NSLog(@"INIT with size : %fx%f, %fx%f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
self = [super initWithFrame:frame];
self.contentScaleFactor = 1.0f;
// TODO : Enable multi touch ==> but this generate many sub errors ... 3 touch can be appear in 1 event ...
//self.multipleTouchEnabled = YES;
if (self) {
[self configureAspectRatio];
[self setupLayer];
[self setupContext];
[self setupDepthBuffer];
[self setupRenderBuffer];
[self setupFrameBuffer];
[self startDisplayLink];
}
return self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self];
CGRect localBounds = [self bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale);
GALE_DEBUG(touches.count << " touchesBegan: " << positionEvent);
IOs::setInputState(1, true, positionEvent.x(), positionEvent.y());
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self];
CGRect localBounds = [self bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale);
GALE_DEBUG(touches.count << " touchesEnded: " << positionEvent);
IOs::setInputState(1, false, positionEvent.x(), positionEvent.y());
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self];
CGRect localBounds = [self bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale);
GALE_DEBUG(touches.count << " touchesMoved: " << positionEvent);
IOs::setInputMotion(1, positionEvent.x(), positionEvent.y());
}
- (void)layoutSubviews {
[EAGLContext setCurrentContext:_context];
}
- (void)dealloc {
if ([EAGLContext currentContext] == _context) {
[EAGLContext setCurrentContext:nil];
}
}
@end

View File

@ -1,426 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp>
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/context/Context.hpp>
#include <gale/context/InputManager.hpp>
#include <gale/Application.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::context::InputManager);
ETK_DECLARE_TYPE(gale::context::InputPoperty);
ETK_DECLARE_TYPE(gale::context::InputLimit);
#define EVENT_DEBUG GALE_VERBOSE
//#define EVENT_DEBUG GALE_DEBUG
void gale::context::InputManager::calculateLimit() {
m_eventInputLimit.sepatateTime = 300000; // µs
m_eventInputLimit.DpiOffset = m_dpi*100;
m_eventMouseLimit.sepatateTime = 300000; // µs
m_eventMouseLimit.DpiOffset = (float)m_dpi*(float)0.1;
}
void gale::context::InputManager::setDpi(int32_t newDPI) {
m_dpi = newDPI;
// recalculate the DPI system ...
calculateLimit();
}
bool gale::context::InputManager::localEventInput(enum gale::key::type _type,
ememory::SharedPtr<gale::Application> _destApplication,
int32_t _IdInput,
enum gale::key::status _status,
vec2 _pos) {
if (null != _destApplication) {
if (_type == gale::key::typeMouse || _type == gale::key::typeFinger) {
// create the system Event :
gale::event::InputSystem tmpEventSystem(_type, _status, _IdInput, _pos, _destApplication, 0, m_specialKey); // TODO : set the real ID ...
// generate the event :
return _destApplication->systemEventInput(tmpEventSystem);
} else {
return false;
}
}
return false;
}
void gale::context::InputManager::abortElement(InputPoperty *_eventTable,
int32_t _idInput,
enum gale::key::type _type) {
if (null == _eventTable) {
return;
}
if (_eventTable[_idInput].isUsed == true) {
localEventInput(_type,
_eventTable[_idInput].curentApplicationEvent.lock(),
_eventTable[_idInput].destinationInputId,
gale::key::statusAbort,
_eventTable[_idInput].posEvent);
}
}
void gale::context::InputManager::cleanElement(InputPoperty *_eventTable,
int32_t _idInput) {
if (null == _eventTable) {
return;
}
//GALE_INFO("CleanElement[" << idInput << "] = @" << (int64_t)eventTable);
_eventTable[_idInput].isUsed = false;
_eventTable[_idInput].destinationInputId = 0;
_eventTable[_idInput].lastTimeEvent = 0;
_eventTable[_idInput].curentApplicationEvent.reset();
_eventTable[_idInput].origin.setValue(0,0);
_eventTable[_idInput].size.setValue(99999999,99999999);
_eventTable[_idInput].downStart.setValue(0,0);
_eventTable[_idInput].isDown = false;
_eventTable[_idInput].isInside = false;
_eventTable[_idInput].nbClickEvent = 0;
_eventTable[_idInput].posEvent.setValue(0,0);
}
gale::context::InputManager::InputManager(gale::Context& _context) :
m_grabApplication(),
m_context(_context) {
setDpi(200);
GALE_INFO("Init (start)");
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
// remove the property of this input ...
cleanElement(m_eventInputSaved, iii);
cleanElement(m_eventMouseSaved, iii);
}
GALE_INFO("Init (end)");
}
gale::context::InputManager::~InputManager() {
GALE_INFO("Un-Init (start)");
GALE_INFO("Un-Init (end)");
}
int32_t gale::context::InputManager::localGetDestinationId(enum gale::key::type _type,
ememory::SharedPtr<gale::Application> _destApplication,
int32_t _realInputId) {
if (_type == gale::key::typeFinger) {
int32_t lastMinimum = 0;
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
if (true == m_eventInputSaved[iii].isUsed) {
ememory::SharedPtr<gale::Application> tmpApplication = m_eventInputSaved[iii].curentApplicationEvent.lock();
if (tmpApplication == _destApplication) {
if (iii != _realInputId) {
lastMinimum = etk::max(lastMinimum, m_eventInputSaved[iii].destinationInputId);
}
}
}
}
return lastMinimum+1;
}
return _realInputId;
}
// note if id<0 == > the it was finger event ...
void gale::context::InputManager::motion(enum gale::key::type _type,
int _pointerID,
vec2 _pos) {
EVENT_DEBUG("motion event : " << _type << " " << _pointerID << " " << _pos);
if (MAX_MANAGE_INPUT <= _pointerID) {
// reject pointer == > out of IDs...
return;
}
InputPoperty *eventTable = null;
if (_type == gale::key::typeMouse) {
eventTable = m_eventMouseSaved;
} else if (_type == gale::key::typeFinger) {
eventTable = m_eventInputSaved;
} else {
GALE_ERROR("Unknown type of event");
return;
}
if( _pointerID > MAX_MANAGE_INPUT
|| _pointerID < 0) {
// not manage input
return;
}
ememory::SharedPtr<gale::Application::Windows> tmpWindows = m_context.getWindows();
// special case for the mouse event 0 that represent the hover event of the system :
if (_type == gale::key::typeMouse && _pointerID == 0) {
// this event is all time on the good Application ... and manage the enter and leave ...
// NOTE : the "layer Application" force us to get the Application at the specific position all the time :
ememory::SharedPtr<gale::Application> tmpApplication;
if (m_grabApplication.lock() != null) {
// grab all events ...
tmpApplication = m_grabApplication.lock();
} else {
if (null != tmpWindows) {
tmpApplication = tmpWindows->getApplicationAtPos(_pos);
}
}
if( tmpApplication != eventTable[_pointerID].curentApplicationEvent.lock()
|| ( true == eventTable[_pointerID].isInside
&& ( eventTable[_pointerID].origin.x() > _pos.x()
|| eventTable[_pointerID].origin.y() > _pos.y()
|| (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x()
|| (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) ) ) {
eventTable[_pointerID].isInside = false;
EVENT_DEBUG("GUI : Input ID=" << _pointerID << " == >" << eventTable[_pointerID].destinationInputId << " [LEAVE] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentApplicationEvent.lock(),
eventTable[_pointerID].destinationInputId,
gale::key::statusLeave,
_pos);
}
if (eventTable[_pointerID].isInside == false) {
// set the element inside ...
eventTable[_pointerID].isInside = true;
// get destination Application :
eventTable[_pointerID].curentApplicationEvent = tmpApplication;
if (tmpApplication == null) {
eventTable[_pointerID].isInside = false;
} else {
eventTable[_pointerID].origin = tmpApplication->getOrigin();
eventTable[_pointerID].size = tmpApplication->getSize();
}
eventTable[_pointerID].destinationInputId = 0;
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [ENTER] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
tmpApplication,
eventTable[_pointerID].destinationInputId,
gale::key::statusEnter,
_pos);
}
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [MOVE] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
tmpApplication,
eventTable[_pointerID].destinationInputId,
gale::key::statusMove,
_pos);
} else if (true == eventTable[_pointerID].isUsed) {
if (true == eventTable[_pointerID].isInside) {
if( eventTable[_pointerID].origin.x() > _pos.x()
|| eventTable[_pointerID].origin.y() > _pos.y()
|| (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x()
|| (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) {
eventTable[_pointerID].isInside = false;
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [LEAVE] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentApplicationEvent.lock(),
eventTable[_pointerID].destinationInputId,
gale::key::statusLeave,
_pos);
}
} else {
if( ( eventTable[_pointerID].origin.x() <= _pos.x()
&& (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) >= _pos.x() )
&& ( eventTable[_pointerID].origin.y() <= _pos.y()
&& (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) >= _pos.y() ) ) {
eventTable[_pointerID].isInside = true;
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [ENTER] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentApplicationEvent.lock(),
eventTable[_pointerID].destinationInputId,
gale::key::statusEnter,
_pos);
}
}
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [MOVE] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentApplicationEvent.lock(),
eventTable[_pointerID].destinationInputId,
gale::key::statusMove,
_pos);
}
}
void gale::context::InputManager::state(enum gale::key::type _type,
int _pointerID,
bool _isDown,
vec2 _pos)
{
if (MAX_MANAGE_INPUT <= _pointerID) {
// reject pointer == > out of IDs...
return;
}
EVENT_DEBUG("event pointerId=" << _pointerID);
// convert position in open-GL coordonates ...
InputPoperty *eventTable = null;
InputLimit localLimit;
if (_type == gale::key::typeMouse) {
eventTable = m_eventMouseSaved;
localLimit = m_eventMouseLimit;
} else if (_type == gale::key::typeFinger) {
eventTable = m_eventInputSaved;
localLimit = m_eventInputLimit;
} else {
GALE_ERROR("Unknown type of event");
return;
}
if( _pointerID > MAX_MANAGE_INPUT
|| _pointerID <= 0) {
// not manage input
return;
}
// get the curent time ...
int64_t currentTime = gale::getTime();
ememory::SharedPtr<gale::Application::Windows> tmpWindows = m_context.getWindows();
if (true == _isDown) {
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [DOWN] " << _pos);
if(true == eventTable[_pointerID].isUsed) {
// we have an event previously ... check delay between click and offset position
if (currentTime - eventTable[_pointerID].lastTimeEvent > localLimit.sepatateTime) {
cleanElement(eventTable, _pointerID);
} else if( abs(eventTable[_pointerID].downStart.x() - _pos.x()) >= localLimit.DpiOffset
|| abs(eventTable[_pointerID].downStart.y() - _pos.y()) >= localLimit.DpiOffset ){
cleanElement(eventTable, _pointerID);
}
}
if(true == eventTable[_pointerID].isUsed) {
// save start time
eventTable[_pointerID].lastTimeEvent = currentTime;
// generate DOWN Event
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [DOWN] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentApplicationEvent.lock(),
eventTable[_pointerID].destinationInputId,
gale::key::statusDown,
_pos);
} else {
// Mark it used :
eventTable[_pointerID].isUsed = true;
// Save current position :
eventTable[_pointerID].downStart = _pos;
// save start time
eventTable[_pointerID].lastTimeEvent = currentTime;
// set the element inside ...
eventTable[_pointerID].isInside = true;
ememory::SharedPtr<gale::Application> tmpApplication = m_grabApplication.lock();
// get destination Application :
if(null != tmpWindows) {
if ( tmpApplication != null
&& _type == gale::key::typeMouse) {
eventTable[_pointerID].curentApplicationEvent = tmpApplication;
} else {
eventTable[_pointerID].curentApplicationEvent = tmpWindows->getApplicationAtPos(_pos);
}
} else {
eventTable[_pointerID].curentApplicationEvent.reset();
}
tmpApplication = eventTable[_pointerID].curentApplicationEvent.lock();
if (tmpApplication != null) {
eventTable[_pointerID].origin = tmpApplication->getOrigin();
eventTable[_pointerID].size = tmpApplication->getSize();
eventTable[_pointerID].destinationInputId = localGetDestinationId(_type, tmpApplication, _pointerID);
} else {
eventTable[_pointerID].destinationInputId = -1;
}
// generate DOWN Event
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [DOWN] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
tmpApplication,
eventTable[_pointerID].destinationInputId,
gale::key::statusDown,
_pos);
}
} else {
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [UP] " << _pos);
if(false == eventTable[_pointerID].isUsed) {
// bad case ... ???
GALE_DEBUG("Up event without previous down ... ");
// Mark it un-used :
eventTable[_pointerID].isUsed = false;
// revove the Application ...
eventTable[_pointerID].curentApplicationEvent.reset();
} else {
ememory::SharedPtr<gale::Application> tmpApplication = eventTable[_pointerID].curentApplicationEvent.lock();
// generate UP Event
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [UP] " << _pos);
eventTable[_pointerID].posEvent = _pos;
// send up event after the single event to prevent multiple Application getting elements
localEventInput(_type,
tmpApplication,
_pointerID,
gale::key::statusUp,
_pos);
// generate event (single)
if( abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset
&& abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){
// Save current position :
eventTable[_pointerID].downStart = _pos;
// save start time
eventTable[_pointerID].lastTimeEvent = currentTime;
int32_t nbClickMax = 0;
if(tmpApplication != null) {
nbClickMax = tmpApplication->getMouseLimit();
if (nbClickMax>5) {
nbClickMax = 5;
}
}
// in grab mode the single to quinte event are not generated ....
if( ( m_grabApplication.lock() == null
|| _type != gale::key::typeMouse )
&& eventTable[_pointerID].nbClickEvent < nbClickMax) {
// generate event SINGLE :
eventTable[_pointerID].nbClickEvent++;
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [" << eventTable[_pointerID].nbClickEvent << "] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
tmpApplication,
eventTable[_pointerID].destinationInputId,
(enum gale::key::status)(gale::key::statusSingle + eventTable[_pointerID].nbClickEvent-1),
_pos);
if( eventTable[_pointerID].nbClickEvent >= nbClickMax) {
eventTable[_pointerID].nbClickEvent = 0;
}
} else {
eventTable[_pointerID].nbClickEvent = 0;
}
}
// send up event after the single event to prevent multiple Application getting elements
localEventInput(_type,
tmpApplication,
_pointerID,
gale::key::statusUpAfter,
_pos);
// specific for tuch event
if (_type == gale::key::typeFinger) {
cleanElement(eventTable, _pointerID);
}
}
}
}

View File

@ -1,100 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/Application.hpp>
namespace gale {
namespace context {
/**
* @brief internal structure
* @not_in_doc
*/
class InputPoperty {
public:
bool isUsed;
int32_t destinationInputId;
int64_t lastTimeEvent;
ememory::WeakPtr<gale::Application> curentApplicationEvent;
vec2 origin;
vec2 size;
vec2 downStart;
vec2 posEvent;
bool isDown;
bool isInside;
int32_t nbClickEvent; // 0 .. 1 .. 2 .. 3
};
/**
* @brief internal structure
* @not_in_doc
*/
class InputLimit {
public:
int32_t sepatateTime;
int32_t DpiOffset;
};
class Context;
class InputManager {
// special grab pointer mode :
private:
ememory::WeakPtr<gale::Application> m_grabApplication; //!< Application that grab the curent pointer.
private:
int32_t m_dpi;
InputLimit m_eventInputLimit;
InputLimit m_eventMouseLimit;
void calculateLimit();
InputPoperty m_eventInputSaved[MAX_MANAGE_INPUT];
InputPoperty m_eventMouseSaved[MAX_MANAGE_INPUT];
void abortElement(InputPoperty* _eventTable, int32_t _idInput, enum gale::key::type _type);
void cleanElement(InputPoperty* _eventTable, int32_t _idInput);
/**
* @brief generate the event on the destinated Application.
* @param[in] _type Type of the event that might be sended.
* @param[in] _destApplication Pointer on the requested Application that element might be sended
* @param[in] _IdInput Id of the event (PC : [0..9] and touch : [1..9])
* @param[in] _typeEvent type of the eventg generated
* @param[in] _pos position of the event
* @return true if event has been greped
*/
bool localEventInput(enum gale::key::type _type,
ememory::SharedPtr<gale::Application> _destApplication,
int32_t _IdInput,
enum gale::key::status _typeEvent,
vec2 _pos);
/**
* @brief convert the system event id in the correct GALE id depending of the system management mode
* This function find the next input id unused on the specifiic Application
* == > on PC, the ID does not change (GUI is not the same)
* @param[in] _type Type of the kay event.
* @param[in] _destApplication Pointer of the Application destination
* @param[in] _realInputId system Id
* @return the gale input id
*/
int32_t localGetDestinationId(enum gale::key::type _type,
ememory::SharedPtr<gale::Application> _destApplication,
int32_t _realInputId);
private:
gale::Context& m_context;
public:
InputManager(gale::Context& _context);
~InputManager();
void setDpi(int32_t _newDPI);
// note if id<0 == > the it was finger event ...
void motion(enum gale::key::type _type, int _pointerID, vec2 _pos );
void state(enum gale::key::type _type, int _pointerID, bool _isDown, vec2 _pos);
private:
gale::key::Special m_specialKey;
public:
void setLastKeyboardSpecial(const gale::key::Special& _specialKey) {
m_specialKey = _specialKey;
}
};
}
}

View File

@ -1,14 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#import <Cocoa/Cocoa.h>
@interface MacOsAppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
- (void)sendEvent:(NSEvent *)event;
- (void)applicationWillResignActive:(MacOsAppDelegate *)application;
@end

View File

@ -1,74 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#import <gale/context/MacOs/AppDelegate.hpp>
#import <gale/context/MacOs/OpenglView.hpp>
#include <gale/debug.hpp>
@implementation MacOsAppDelegate
@synthesize window=_window;
- (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] frame]];
return YES;
}
- (void)applicationWillResignActive:(MacOsAppDelegate *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
GALE_INFO("move windows in applicationWillResignActive");
}
- (void)applicationDidEnterBackground:(MacOsAppDelegate *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
*/
GALE_INFO("move windows in applicationDidEnterBackground");
}
- (void)applicationWillEnterForeground:(MacOsAppDelegate *)application {
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
GALE_INFO("move windows in applicationWillEnterForeground");
}
- (void)applicationDidBecomeActive:(MacOsAppDelegate *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
GALE_INFO("move windows in applicationDidBecomeActive");
}
- (void)applicationWillTerminate:(MacOsAppDelegate *)application {
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
GALE_INFO("move windows in applicationWillTerminate");
}
- (void)dealloc {
[_window release];
[super dealloc];
}
- (void)sendEvent:(NSEvent *)event {
GALE_WARNING(" EVENT ... ");
}
@end

View File

@ -1,49 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/key/key.hpp>
#include <ememory/SharedPtr.hpp>
#include <gale/context/Context.hpp>
namespace MacOs {
// return true if a flush is needed
bool draw(bool _displayEveryTime);
/**
* @brief The OS inform that the current windows has change his size.
* @param[in] _size new size of the windows.
*/
void resize(float _x, float _y);
void setMouseState(int32_t _id, bool _isDown, float _x, float _y);
void setMouseMotion(int32_t _id, float _x, float _y);
void setKeyboard(gale::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
void setKeyboardMove(gale::key::Special& _keyboardMode, enum gale::key::keyboard _move, bool _isDown, bool _isAReapeateKey);
void stopRequested();
/*
void setRedrawCallback(const etk::Function<void()>& _func);
*/
}
namespace gale {
namespace context {
namespace macos {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

View File

@ -1,219 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/key/key.hpp>
#include <gale/context/commandLine.hpp>
#include <gale/context/clipBoard.hpp>
#include <etk/types.hpp>
#include <etk/uri/uri.hpp>
#include <gale/resource/Manager.hpp>
#include <gale/context/Context.hpp>
#include <gale/context/MacOs/Interface.hpp>
#include <gale/context/MacOs/Context.hpp>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/times.h>
#include <mach/clock.h>
#include <mach/mach.h>
#include <etk/etk.hpp>
#import <Cocoa/Cocoa.h>
class MacOSInterface : public gale::Context {
private:
gale::key::Special m_guiKeyBoardMode;
public:
MacOSInterface(gale::Application* _application, int _argc, const char* _argv[]) :
gale::Context(_application, _argc, _argv) {
mm_main(_argc, _argv);
start2ndThreadProcessing();
}
int32_t run() {
return mm_run();
}
public:
//interface MacOS :
bool MAC_Draw(bool _displayEveryTime) {
return OS_Draw(_displayEveryTime);
}
void MAC_Resize(float _x, float _y) {
OS_Resize(vec2(_x,_y));
}
void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) {
OS_SetInput(gale::key::type::mouse,
(_isDown==true?gale::key::status::down:gale::key::status::up),
_id,
vec2(_x, _y));
}
void MAC_SetMouseMotion(int32_t _id, float _x, float _y) {
OS_SetInput(gale::key::type::mouse,
gale::key::status::move,
_id,
vec2(_x, _y));
}
void MAC_SetKeyboard(gale::key::Special _special, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
if (char32_t(_unichar) == u32char::Delete) {
_unichar = u32char::Suppress;
} else if (char32_t(_unichar) == u32char::Suppress) {
_unichar = u32char::Delete;
}
if (char32_t(_unichar) == u32char::CarrierReturn) {
_unichar = u32char::Return;
}
//GALE_DEBUG("key: " << _unichar << " up=" << !_isDown);
if (_unichar <= 4) {
enum gale::key::keyboard move;
switch(_unichar) {
case 0:
move = gale::key::keyboard::up;
break;
case 1:
move = gale::key::keyboard::down;
break;
case 2:
move = gale::key::keyboard::left;
break;
case 3:
move = gale::key::keyboard::right;
break;
}
OS_setKeyboard(_special, move, (_isDown==true?gale::key::status::down:gale::key::status::up), _isAReapeateKey);
} else {
OS_setKeyboard(_special, gale::key::keyboard::character, (_isDown==true?gale::key::status::down:gale::key::status::up), _isAReapeateKey, _unichar);
}
}
void MAC_SetKeyboardMove(gale::key::Special& _special,
enum gale::key::keyboard _move,
bool _isDown,
bool _isAReapeateKey) {
OS_setKeyboard(_special, _move, (_isDown==true?gale::key::status::down:gale::key::status::up), _isAReapeateKey);
}
void openURL(const etk::String& _url) {
etk::String req = "open " + _url;
system(req.c_str());
}
void MAC_Stop() {
OS_Stop();
}
void stop() {
mm_stopApplication();
}
void clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
if (_clipboardID == gale::context::clipBoard::clipboardStd) {
NSPasteboard* myPasteboard = [NSPasteboard generalPasteboard];
NSString* myString = [myPasteboard stringForType:NSPasteboardTypeString];
etk::String val([myString UTF8String]);
gale::context::clipBoard::setSystem(_clipboardID, val);
if (val.size() != 0) {
OS_ClipBoardArrive(_clipboardID);
}
} else {
gale::Context::clipBoardGet(_clipboardID);
}
}
void clipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
if (_clipboardID == gale::context::clipBoard::clipboardStd) {
NSPasteboard* myPasteboard = [NSPasteboard generalPasteboard];
[myPasteboard clearContents];
//GALE_ERROR(" copy: " << gale::context::clipBoard::get(_clipboardID));
NSString *text = [[NSString alloc] initWithUTF8String:gale::context::clipBoard::get(_clipboardID).c_str()];
BOOL err = [myPasteboard setString:text forType:NSPasteboardTypeString];
if (err == FALSE) {
GALE_ERROR("copy to clipboard can not be done ...");
}
} else {
gale::Context::clipBoardSet(_clipboardID);
}
}
};
MacOSInterface* interface = null;
bool MacOs::draw(bool _displayEveryTime) {
GALE_VERBOSE("draw request " << uint64_t(interface) << " " << _displayEveryTime);
if (interface == null) {
return false;
}
return interface->MAC_Draw(_displayEveryTime);
}
void MacOs::resize(float _x, float _y) {
if (interface == null) {
return;
}
interface->MAC_Resize(_x, _y);
}
void MacOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) {
if (interface == null) {
return;
}
interface->MAC_SetMouseState(_id, _isDown, _x, _y);
}
void MacOs::setMouseMotion(int32_t _id, float _x, float _y) {
if (interface == null) {
return;
}
interface->MAC_SetMouseMotion(_id, _x, _y);
}
void MacOs::setKeyboard(gale::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
if (interface == null) {
return;
}
interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey);
}
void MacOs::setKeyboardMove(gale::key::Special& _keyboardMode, enum gale::key::keyboard _move, bool _isDown, bool _isAReapeateKey) {
if (interface == null) {
return;
}
interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown, _isAReapeateKey);
}
void MacOs::stopRequested() {
if (interface == null) {
return;
}
interface->MAC_Stop();
}
/*
void MacOs::setRedrawCallback(const etk::Function<void()>& _func) {
if (interface == null) {
return;
}
interface->getWidgetManager().setCallbackonRedrawNeeded(_func);
}
*/
bool gale::context::macos::isBackendPresent() {
// TODO : Do it better...
return true;
}
ememory::SharedPtr<gale::Context> gale::context::macos::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
ememory::SharedPtr<MacOSInterface> tmp = ememory::makeShared<MacOSInterface>(_application, _argc, _argv);
interface = tmp.get();
return tmp;
}

View File

@ -1,18 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
int mm_main(int _argc, const char* _argv[]);
int mm_run();
void mm_stopApplication();
#ifdef __cplusplus
}
#endif

View File

@ -1,112 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include "Context.hpp"
#import <Cocoa/Cocoa.h>
#include "gale/context/MacOs/Interface.hpp"
#import <gale/context/MacOs/OpenglView.hpp>
#import <gale/context/MacOs/Windows.hpp>
#import <gale/context/MacOs/AppDelegate.hpp>
#import <gale/debug.hpp>
id window = nil;
void callbackSomeThingToDo() {
//GALE_CRITICAL("ksdjlkqjsdlfkjsqdlkfjslqkdjflqksjdf");
[window UpdateScreenRequested];
}
int mm_main(int _argc, const char* _argv[]) {
[NSAutoreleasePool new];
[NSApplication sharedApplication];
// set the quit policy and all stadard for Mac
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
// ---------------------------------------------------------------
// -- basic menu bar creation :
// ---------------------------------------------------------------
// set the basic menu bar (stadard on Mac OSX)
id menubar = [[NSMenu new] autorelease];
//add an item
id appMenuItem = [[NSMenuItem new] autorelease];
// add the item to the menu bar:
[menubar addItem:appMenuItem];
// set the main menu in the menu bar ...
[NSApp setMainMenu:menubar];
id appMenu = [[NSMenu new] autorelease];
id appName = [[NSProcessInfo processInfo] processName];
// create the label to qui the application :
id quitTitle = [@"Quit " stringByAppendingString:appName];
// create the item to quit the appllication with META+q at shortCut
id quitMenuItem = [ [ [NSMenuItem alloc] initWithTitle:quitTitle
action:@selector(stop:) keyEquivalent:@"q"] autorelease];
// add the item to the menu:
[appMenu addItem:quitMenuItem];
// set the application menu to the main app menu ...
[appMenuItem setSubmenu:appMenu];
// ---------------------------------------------------------------
// -- basic windows creation :
// ---------------------------------------------------------------
// create a windows of size 800/600
#ifdef __MAC_10_12
window = [ [ [GaleMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
styleMask:(NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskClosable) backing:NSBackingStoreBuffered defer:NO]
autorelease];
#else
window = [ [ [GaleMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
autorelease];
#endif
[window setAcceptsMouseMovedEvents:YES];
//id window = [ [MacOsAppDelegate alloc] autorelease];
// set the windows at a specific position :
[window cascadeTopLeftFromPoint:NSMakePoint(50,50)];
// set the windows resizable
#ifdef __MAC_10_12
[window setStyleMask:[window styleMask] | NSWindowStyleMaskResizable];
#else
[window setStyleMask:[window styleMask] | NSResizableWindowMask];
#endif
// oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask];
// set the title
[window setTitle:appName];
[window setAcceptsMouseMovedEvents:YES];
// ???
[window makeKeyAndOrderFront:nil];
[NSApp activateIgnoringOtherApps:YES];
NSRect window_frame = [window frame];
OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)];
NSTrackingArea *track = [[NSTrackingArea alloc] initWithRect:window_frame options: NSTrackingMouseMoved | NSTrackingActiveWhenFirstResponder | NSTrackingActiveInKeyWindow
owner:window userInfo:nil];
[view addTrackingArea:track];
[window setContentView:view];
[view setAutoresizesSubviews:YES];
return 0;
}
int mm_run(void) {
GALE_ERROR("Start to run");
[NSApp run];
GALE_DEBUG("END of application");
// return no error
return 0;
}
void mm_stopApplication() {
GALE_DEBUG("NSApp terminate start.");
[window closeRequestGale];
[NSApp stop:nil];
GALE_DEBUG("NSApp terminate done");
}

View File

@ -1,19 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h>
@interface OpenGLView : NSOpenGLView<NSWindowDelegate> {
NSTimer* _refreshTimer;
bool _redraw;
}
- (void)prepareOpenGL;
- (void)drawRect:(NSRect) bounds;
- (void)UpdateScreenRequested;
@end

View File

@ -1,68 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#import <gale/context/MacOs/OpenglView.hpp>
#include <OpenGL/gl.h>
#include <gale/context/MacOs/Context.hpp>
#include <gale/debug.hpp>
#include <gale/Dimension.hpp>
@implementation OpenGLView
- (void) prepareOpenGL {
GALE_INFO("prepare");
GLint swapInt = 1;
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
// set system dpi size :
NSScreen *screen = [NSScreen mainScreen];
NSDictionary *description = [screen deviceDescription];
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize displayPhysicalSize = CGDisplayScreenSize([[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
gale::Dimension::setPixelRatio(vec2((float)displayPixelSize.width/(float)displayPhysicalSize.width,
(float)displayPixelSize.height/(float)displayPhysicalSize.height),
gale::distance::millimeter);
_refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ;
_redraw = true;
}
- (void)UpdateScreenRequested {
_redraw = true;
}
-(void) drawRect: (NSRect) bounds {
if ( ! _refreshTimer ) {
_refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ;
GALE_WARNING("create timer ... ");
}
MacOs::draw(false);
}
/**
* Service the animation timer.
*/
- (void) animationTimerFired: (NSTimer *) timer {
if (_redraw == true) {
//_redraw = false;
[self setNeedsDisplay:YES];
//GALE_WARNING("view refresh ..." );
}
}
-(void)reshape {
GALE_INFO("view reshape (" << [self frame].size.width << "," << [self frame].size.height << ")" );
// window resize; width and height are in pixel coordinates
// but they are floats
float width = [self frame].size.width;
float height = [self frame].size.height;
MacOs::resize(width,height);
}
@end

View File

@ -1,47 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#import <Cocoa/Cocoa.h>
#import <gale/context/MacOs/OpenglView.hpp>
#include <gale/key/key.hpp>
@interface GaleMainWindows : NSWindow {
OpenGLView* _view;
}
+ (id)alloc;
- (id)init;
+ (void)dealloc;
+ (void)performClose:(id)sender;
// All mouse events:
- (void)mouseDown:(NSEvent *) event;
- (void)mouseDragged:(NSEvent *) event;
- (void)mouseUp:(NSEvent *)event;
- (void)mouseMoved:(NSEvent *)event;
- (void)mouseEntered:(NSEvent *)event;
- (void)mouseExited:(NSEvent *)event;
- (void)rightMouseDown:(NSEvent *)event;
- (void)rightMouseDragged:(NSEvent *)event;
- (void)rightMouseUp:(NSEvent *)event;
- (void)otherMouseDown:(NSEvent *)event;
- (void)otherMouseDragged:(NSEvent *)event;
- (void)otherMouseUp:(NSEvent *)event;
// keyboard eevnts:
- (void)keyDown:(NSEvent *)theEvent;
- (void)flagsChanged:(NSEvent *)theEvent;
- (void)closeRequestGale;
- (void)UpdateScreenRequested;
/**
* @brief Check if we have the need to change the internal flag of shift, ctrl ...
* @param[in] bitField MacOs bit field
* @param[in] flags Patern to check
* @param[in] key Gale key
*/
- (void)flagsUpdate:(uint32_t) bitField
:(uint32_t) flags
:(enum gale::key::keyboard) key;
@end

View File

@ -1,478 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#import <gale/context/MacOs/Windows.hpp>
#include <gale/context/MacOs/Context.hpp>
#include <gale/key/key.hpp>
#include <gale/debug.hpp>
#include <etk/stdTools.hpp>
@implementation GaleMainWindows
+ (id)alloc {
id windowsID = [super alloc];
GALE_DEBUG("ALLOCATE ...");
return windowsID;
}
- (id)init {
id windowsID = [super init];
//[NSApp setDelegate: self];
GALE_DEBUG("INIT ...");
// set the windows at a specific position :
[windowsID cascadeTopLeftFromPoint:NSMakePoint(50,50)];
// set the windows resizable
#ifdef __MAC_10_12
[windowsID setStyleMask:[windowsID styleMask] | NSWindowStyleMaskResizable];
#else
[windowsID setStyleMask:[windowsID styleMask] | NSResizableWindowMask];
#endif
// oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask];
// set the title
id appName = [[NSProcessInfo processInfo] processName];
[windowsID setTitle:appName];
[windowsID setAcceptsMouseMovedEvents:YES];
// ???
[windowsID makeKeyAndOrderFront:nil];
[NSApp activateIgnoringOtherApps:YES];
NSRect window_frame = [windowsID frame];
_view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)];
[windowsID setContentView:_view];
[_view setAutoresizesSubviews:YES];
// Override point for customization after application launch.
//[window addSubview:view];
//[window addChildWindow:view];
//[window makeKeyAndVisible];
//[windowsID setDelegate:view];
return windowsID;
}
+ (void)dealloc {
GALE_ERROR("FREE ...");
//[_window release];
[super dealloc];
}
+ (void)performClose:(id)sender {
GALE_ERROR("perform close ...");
}
static gale::key::Special guiKeyBoardMode;
static etk::Vector<etk::Pair<uint16_t,unichar>> g_listlasteventDown;
-(void)localKeyEvent:(NSEvent*)theEvent isDown:(bool)_isDown {
bool thisIsAReapeateKey = false;
if ([theEvent isARepeat]) {
thisIsAReapeateKey = true;
}
//[self flagsChanged:theEvent];
NSString *str = [theEvent charactersIgnoringModifiers];
// TODO : set if for every char in the string !!!
unichar c = [str characterAtIndex:0];
uint16_t keycode = [theEvent keyCode];
// special case for \t + shift:
if ( guiKeyBoardMode.getShift() == true
&& c == 25) {
// We remap it to the correct tabulation.
c = 9;
}
GALE_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown << " keycode=" << keycode);
bool find = true;
enum gale::key::keyboard keyInput;
switch (c) {
case NSUpArrowFunctionKey: keyInput = gale::key::keyboard::up; break;
case NSDownArrowFunctionKey: keyInput = gale::key::keyboard::down; break;
case NSLeftArrowFunctionKey: keyInput = gale::key::keyboard::left; break;
case NSRightArrowFunctionKey: keyInput = gale::key::keyboard::right; break;
case NSPageUpFunctionKey: keyInput = gale::key::keyboard::pageUp; break;
case NSPageDownFunctionKey: keyInput = gale::key::keyboard::pageDown; break;
case NSBeginFunctionKey:
case NSHomeFunctionKey: keyInput = gale::key::keyboard::start; break;
case NSEndFunctionKey: keyInput = gale::key::keyboard::end; break;
case NSScrollLockFunctionKey: keyInput = gale::key::keyboard::stopDefil; break;
case NSPauseFunctionKey: keyInput = gale::key::keyboard::wait; break;
case NSPrintScreenFunctionKey: keyInput = gale::key::keyboard::print; break;
case 16: keyInput = gale::key::keyboard::contextMenu; break;
case 63302:
case NSInsertFunctionKey:
find = false;
keyInput = gale::key::keyboard::insert;
if(_isDown == false) {
if (true == guiKeyBoardMode.getInsert()) {
guiKeyBoardMode.setInsert(false);
} else {
guiKeyBoardMode.setInsert(true);
}
}
GALE_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown);
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, true, thisIsAReapeateKey);
GALE_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << !_isDown);
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, false, thisIsAReapeateKey);
break;
//case 84: keyInput = gale::key::keyboardCenter; break; // Keypad
case NSF1FunctionKey: keyInput = gale::key::keyboard::f1; break;
case NSF2FunctionKey: keyInput = gale::key::keyboard::f2; break;
case NSF3FunctionKey: keyInput = gale::key::keyboard::f3; break;
case NSF4FunctionKey: keyInput = gale::key::keyboard::f4; break;
case NSF5FunctionKey: keyInput = gale::key::keyboard::f5; break;
case NSF6FunctionKey: keyInput = gale::key::keyboard::f6; break;
case NSF7FunctionKey: keyInput = gale::key::keyboard::f7; break;
case NSF8FunctionKey: keyInput = gale::key::keyboard::f8; break;
case NSF9FunctionKey: keyInput = gale::key::keyboard::f9; break;
case NSF10FunctionKey: keyInput = gale::key::keyboard::f10; break;
case NSF11FunctionKey: keyInput = gale::key::keyboard::f11; break;
case NSF12FunctionKey: keyInput = gale::key::keyboard::f12; break;
case NSF13FunctionKey:
case NSF14FunctionKey:
case NSF15FunctionKey:
case NSF16FunctionKey:
case NSF17FunctionKey:
case NSF18FunctionKey:
case NSF19FunctionKey:
case NSF20FunctionKey:
case NSF21FunctionKey:
case NSF22FunctionKey:
case NSF23FunctionKey:
case NSF24FunctionKey:
case NSF25FunctionKey:
case NSF26FunctionKey:
case NSF27FunctionKey:
case NSF28FunctionKey:
case NSF29FunctionKey:
case NSF30FunctionKey:
case NSF31FunctionKey:
case NSF32FunctionKey:
case NSF33FunctionKey:
case NSF34FunctionKey:
case NSF35FunctionKey:
find = false;
break;
case NSDeleteFunctionKey: // Suppress
find = false;
MacOs::setKeyboard(guiKeyBoardMode, u32char::Delete, _isDown, thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
MacOs::setKeyboard(guiKeyBoardMode, u32char::Delete, !_isDown, thisIsAReapeateKey);
}
break;
default:
find = false;
{
if (guiKeyBoardMode.getAlt() == true) {
// special keyboard transcription ...
str = [theEvent characters];
c = [str characterAtIndex:0];
GALE_VERBOSE("Key Event ALT " << c << " = '" << char(c) << "' isDown=" << _isDown << " nb in list=" << g_listlasteventDown.size());
} else {
GALE_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown);
}
// MacOs have a problem of synchronizing the correct key with the modifier...
if (_isDown == false) {
for (auto it = g_listlasteventDown.begin();
it != g_listlasteventDown.end();
++it) {
if (it->first == keycode) {
c = it->second;
g_listlasteventDown.erase(it);
GALE_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown << " (override)");
break;
}
}
} else {
// remove a previous occurence of this element (case where Macos does not send the UP)...
for (auto it = g_listlasteventDown.begin();
it != g_listlasteventDown.end();
++it) {
if (it->first == keycode) {
g_listlasteventDown.erase(it);
break;
}
}
g_listlasteventDown.push_back(etk::makePair(keycode, c));
}
MacOs::setKeyboard(guiKeyBoardMode, c, _isDown, thisIsAReapeateKey);
if (thisIsAReapeateKey == true) {
MacOs::setKeyboard(guiKeyBoardMode, c, !_isDown, thisIsAReapeateKey);
}
}
break;
}
if (find == true) {
GALE_VERBOSE("eventKey Move type : " << keyInput );
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, _isDown, thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, !_isDown, thisIsAReapeateKey);
}
}
}
- (void)keyDown:(NSEvent *)theEvent {
[self localKeyEvent:theEvent isDown:true];
}
- (void)keyUp:(NSEvent *)theEvent {
[self localKeyEvent:theEvent isDown:false];
}
- (void)flagsUpdate:(uint32_t) bitField
:(uint32_t) flags
:(enum gale::key::keyboard) key {
if ((bitField & flags) != 0) {
GALE_VERBOSE("Flag change: " << key);
if (guiKeyBoardMode.get(key) == false) {
GALE_VERBOSE(" " << key << " DOWN");
guiKeyBoardMode.update(key, true);
MacOs::setKeyboardMove(guiKeyBoardMode, key, true, false);
}
} else {
if (guiKeyBoardMode.get(key) == true) {
GALE_VERBOSE(" " << key << " UP");
guiKeyBoardMode.update(key, false);
MacOs::setKeyboardMove(guiKeyBoardMode, key, false, false);
}
}
}
- (void)flagsChanged:(NSEvent *)theEvent {
uint32_t bitField = [theEvent modifierFlags];
GALE_VERBOSE("flagsChanged : " << etk::toBin([theEvent modifierFlags], 32));
#ifdef __MAC_10_12
[self flagsUpdate:bitField: NSEventModifierFlagCapsLock: gale::key::keyboard::capLock];
#else
[self flagsUpdate:bitField: NSAlphaShiftKeyMask: gale::key::keyboard::capLock];
#endif
#ifdef __MAC_10_12
//[self flagsUpdate:bitField: NSEventModifierFlagShift: gale::key::keyboard::shiftLeft];
[self flagsUpdate:bitField: 0x02: gale::key::keyboard::shiftLeft];
[self flagsUpdate:bitField: 0x04: gale::key::keyboard::shiftRight];
#else
[self flagsUpdate:bitField: NSShiftKeyMask: gale::key::keyboard::shiftLeft];
#endif
#ifdef __MAC_10_12
//[self flagsUpdate:bitField: NSEventModifierFlagControl: gale::key::keyboard::ctrlLeft];
[self flagsUpdate:bitField: 0x0001: gale::key::keyboard::ctrlLeft];
[self flagsUpdate:bitField: 0x2000: gale::key::keyboard::ctrlRight];
#else
[self flagsUpdate:bitField: NSControlKeyMask: gale::key::keyboard::ctrlLeft];
#endif
#ifdef __MAC_10_12
//[self flagsUpdate:bitField: NSEventModifierFlagOption: gale::key::keyboard::altLeft];
[self flagsUpdate:bitField: 0x0020: gale::key::keyboard::altLeft];
[self flagsUpdate:bitField: 0x0040: gale::key::keyboard::altRight];
#else
[self flagsUpdate:bitField: NSAlternateKeyMask: gale::key::keyboard::altLeft];
#endif
#ifdef __MAC_10_12
//[self flagsUpdate:bitField: NSEventModifierFlagCommand: gale::key::keyboard::metaLeft];
[self flagsUpdate:bitField: 0x0008: gale::key::keyboard::metaLeft];
[self flagsUpdate:bitField: 0x0010: gale::key::keyboard::metaRight];
#else
[self flagsUpdate:bitField: NSCommandKeyMask: gale::key::keyboard::metaLeft];
#endif
#ifdef __MAC_10_12
[self flagsUpdate:bitField: NSEventModifierFlagNumericPad: gale::key::keyboard::numLock];
#else
[self flagsUpdate:bitField: NSNumericPadKeyMask: gale::key::keyboard::numLock];
#endif
#ifdef __MAC_10_12
if ((bitField & NSEventModifierFlagFunction) != 0) {
#else
if ((bitField & NSFunctionKeyMask) != 0) {
#endif
GALE_VERBOSE("NSEventModifierFlagFunction");
MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::contextMenu, true, false);
MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::contextMenu, false, false);
}
GALE_VERBOSE(" ==> new state special: " << etk::to_string(guiKeyBoardMode));
}
// this generate all the event entry availlable ==> like a big keep focus ...
- (BOOL)acceptsFirstResponder {
return YES;
}
- (BOOL)becomeFirstResponder {
return YES;
}
-(void)mouseMoved:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("mouseMoved : " << float(point.x) << " " << (float)point.y);
MacOs::setMouseMotion(0, point.x, point.y);
}
-(void)mouseEntered:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("mouseEntered : " << float(point.x) << " " << (float)point.y);
}
-(void)mouseExited:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("mouseExited : " << float(point.x) << " " << float(point.y));
}
-(void)mouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("mouseDown : " << float(point.x) << " " << float(point.y));
MacOs::setMouseState(1, true, point.x, point.y);
}
-(void)mouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("mouseDragged : " << float(point.x) << " " << float(point.y));
MacOs::setMouseMotion(1, point.x, point.y);
}
-(void)mouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("mouseUp : " << float(point.x) << " " << float(point.y));
MacOs::setMouseState(1, false, point.x, point.y);
}
-(void)rightMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("rightMouseDown : " << float(point.x) << " " << float(point.y));
MacOs::setMouseState(3, true, point.x, point.y);
}
-(void)rightMouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("rightMouseDragged : " << float(point.x) << " " << float(point.y));
MacOs::setMouseMotion(3, point.x, point.y);
}
-(void)rightMouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("rightMouseUp : " << float(point.x) << " " << float(point.y));
MacOs::setMouseState(3, false, point.x, point.y);
}
-(void)otherMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
GALE_VERBOSE("otherMouseDown : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(btNumber, true, point.x, point.y);
}
-(void)otherMouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
GALE_VERBOSE("otherMouseDragged : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(btNumber, point.x, point.y);
}
-(void)otherMouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
GALE_VERBOSE("otherMouseUp: id=" << btNumber );
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
GALE_VERBOSE("otherMouseUp : " << (float)point.x << " " << (float)point.y << " bt id=" << btNumber );
MacOs::setMouseState(btNumber, false, point.x, point.y);
}
- (void)scrollWheel:(NSEvent *)event {
NSPoint point = [event locationInWindow];
GALE_VERBOSE("scrollWheel : " << (float)point.x << " " << (float)point.y << " delta(" << (float)([event deltaX]) << "," << (float)([event deltaY]) << ")");
float deltaY = [event deltaY];
int32_t idEvent = 4;
if (deltaY < 0) {
idEvent = 5;
}
if (fabs(deltaY) < 0.1f) {
return;
}
for (float iii=fabs(deltaY) ; iii>=0.0f ; iii-=1.0f) {
MacOs::setMouseState(idEvent, true , point.x, point.y);
MacOs::setMouseState(idEvent, false, point.x, point.y);
}
}
- (void)closeRequestGale {
GALE_VERBOSE("closeRequestGale: BEGIN");
[super close];
GALE_VERBOSE("closeRequestGale: END");
}
- (void)close {
GALE_VERBOSE("close:");
MacOs::stopRequested();
}
- (void)UpdateScreenRequested {
[_view UpdateScreenRequested];
}
@end

View File

@ -1,335 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
extern "C" {
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
}
#include <etk/types.hpp>
#include <etk/uri/uri.hpp>
#include <etk/tool.hpp>
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/key/key.hpp>
#include <gale/context/commandLine.hpp>
#include <gale/resource/Manager.hpp>
#include <gale/context/Context.hpp>
#include <gale/Dimension.hpp>
#include <etk/etk.hpp>
#include <GL/gl.h>
#include <GL/glut.h>
#include <emscripten.h>
bool hasDisplay = false;
#define DEBUG_GLUT_EVENT
#ifdef DEBUG_GLUT_EVENT
#define GLUT_DEBUG GALE_DEBUG
#define GLUT_VERBOSE GALE_VERBOSE
#define GLUT_INFO GALE_INFO
#define GLUT_CRITICAL GALE_CRITICAL
#else
#define GLUT_DEBUG GALE_VERBOSE
#define GLUT_VERBOSE GALE_VERBOSE
#define GLUT_INFO GALE_VERBOSE
#define GLUT_CRITICAL GALE_VERBOSE
#endif
#ifdef GALE_BUILD_EGAMI
#include <egami/egami.hpp>
#endif
class GLUTInterface : public gale::Context {
private:
gale::key::Special m_guiKeyBoardMode;
int32_t m_originX;
int32_t m_originY;
vec2 m_cursorEventPos;
vec2 m_currentSize;
bool m_doubleBuffered;
bool m_run;
//forcing the position
bool m_grabAllEvent; //!< grab mode enable...
vec2 m_forcePos; //!< position to reset the cursor
bool m_positionChangeRequested; //!< the position modifiquation has been requested
vec2 m_curentGrabDelta; //!< the position in GLUT will arrive by pool
bool m_inputIsPressed[MAX_MANAGE_INPUT];
etk::String m_uniqueWindowsName;
enum gale::context::cursor m_currentCursor; //!< select the current cursor to display :
char32_t m_lastKeyPressed; //!< The last element key presed...
public:
GLUTInterface(gale::Application* _application, int32_t _argc, const char* _argv[]) :
gale::Context(_application, _argc, _argv),
m_originX(0),
m_originY(0),
m_cursorEventPos(0,0),
m_currentSize(640,480),
m_doubleBuffered(0),
m_run(false),
m_grabAllEvent(false),
m_forcePos(0,0),
m_positionChangeRequested(false),
m_curentGrabDelta(0,0),
m_currentCursor(gale::context::cursor::arrow),
m_lastKeyPressed(0) {
GLUT_INFO("GLUT:INIT");
for (int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
m_inputIsPressed[iii] = false;
}
if (m_doubleBuffered) {
//XSync(m_display,0);
}
OS_Resize(m_currentSize);
// Configure the DPI of the screen:
{
vec2 dpi(0,0);
dpi.setX(75);
dpi.setY(75);
gale::Dimension::setPixelRatio(dpi, gale::distance::inch);
GALE_INFO("monitor property : dpi=" << dpi << " px/inch");
}
m_run = true;
start2ndThreadProcessing();
}
~GLUTInterface() {
//GLUT_Quit();
}
int32_t draw() {
GLUT_INFO("RUN");
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GLUT_INFO("RUN 2");
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLUT_INFO("RUN 3");
//glLoadIdentity();
GLUT_INFO("Draw [START]");
OS_Draw(true);
GLUT_INFO("Draw [STOP]");
glutSwapBuffers();
//ethread::sleepMilliSeconds((1000));
return 0;
}
/****************************************************************************************/
virtual void stop() {
GLUT_INFO("GLUT-API: Stop");
m_run = false;
}
void reshape(int _width, int _height) {
glViewport(0, 0, (GLint) _width, (GLint) _height);
m_currentSize = vec2(_width, _height);
OS_Resize(vec2(_width, _height));
}
void special(int _special) {
GALE_INFO("Value=" << _special);
bool find = true;
enum gale::key::keyboard keyInput = gale::key::keyboard::unknow;
switch (_special) {
//case 80: // keypad
case GLUT_KEY_UP: keyInput = gale::key::keyboard::up; break;
//case 83: // keypad
case GLUT_KEY_LEFT: keyInput = gale::key::keyboard::left; break;
//case 85: // keypad
case GLUT_KEY_RIGHT: keyInput = gale::key::keyboard::right; break;
//case 88: // keypad
case GLUT_KEY_DOWN: keyInput = gale::key::keyboard::down; break;
//case 81: // keypad
case GLUT_KEY_PAGE_UP: keyInput = gale::key::keyboard::pageUp; break;
//case 89: // keypad
case GLUT_KEY_PAGE_DOWN: keyInput = gale::key::keyboard::pageDown; break;
//case 79: // keypad
case GLUT_KEY_HOME: keyInput = gale::key::keyboard::start; break;
//case 87: // keypad
case GLUT_KEY_END: keyInput = gale::key::keyboard::end; break;
// TODO: case 78: keyInput = gale::key::keyboard::stopDefil; break;
// TODO: case 127: keyInput = gale::key::keyboard::wait; break;
//case 90: // keypad
case GLUT_KEY_INSERT: keyInput = gale::key::keyboard::insert; break;
//case 84: keyInput = gale::key::keyboardCenter; break; // Keypad
case GLUT_KEY_F1: keyInput = gale::key::keyboard::f1; break;
case GLUT_KEY_F2: keyInput = gale::key::keyboard::f2; break;
case GLUT_KEY_F3: keyInput = gale::key::keyboard::f3; break;
case GLUT_KEY_F4: keyInput = gale::key::keyboard::f4; break;
case GLUT_KEY_F5: keyInput = gale::key::keyboard::f5; break;
case GLUT_KEY_F6: keyInput = gale::key::keyboard::f6; break;
case GLUT_KEY_F7: keyInput = gale::key::keyboard::f7; break;
case GLUT_KEY_F8: keyInput = gale::key::keyboard::f8; break;
case GLUT_KEY_F9: keyInput = gale::key::keyboard::f9; break;
case GLUT_KEY_F10: keyInput = gale::key::keyboard::f10; break;
case GLUT_KEY_F11: keyInput = gale::key::keyboard::f11; break;
case GLUT_KEY_F12: keyInput = gale::key::keyboard::f12; break;
case 112: keyInput = gale::key::keyboard::shiftLeft; break;
case 114: keyInput = gale::key::keyboard::ctrlLeft; break;
case 116: keyInput = gale::key::keyboard::alt; break;
case 111: // Suppr
find = false;
OS_setKeyboard(m_guiKeyBoardMode,
gale::key::keyboard::character,
gale::key::status::down,
false,
0x7F);
OS_setKeyboard(m_guiKeyBoardMode,
gale::key::keyboard::character,
gale::key::status::up,
false,
0x7F);
break;
case 120: // delete
find = false;
OS_setKeyboard(m_guiKeyBoardMode,
gale::key::keyboard::character,
gale::key::status::down,
false,
0x08);
OS_setKeyboard(m_guiKeyBoardMode,
gale::key::keyboard::character,
gale::key::status::up,
false,
0x08);
break;
default:
find = false;
GALE_ERROR("Not find special:" << _special);
}
if (find == true) {
OS_setKeyboard(m_guiKeyBoardMode,
keyInput,
gale::key::status::down,
false);
OS_setKeyboard(m_guiKeyBoardMode,
keyInput,
gale::key::status::up,
false);
}
/* case GLUT_KEY_F11:
glutFullScreen();
break;
*/
GALE_ERROR("eventKey Move type : " << keyInput );
}
void keyboard(unsigned char _key) {
GALE_ERROR("keyboard: " << int(_key));
OS_setKeyboard(m_guiKeyBoardMode,
gale::key::keyboard::character,
gale::key::status::down,
false,
_key);
OS_setKeyboard(m_guiKeyBoardMode,
gale::key::keyboard::character,
gale::key::status::up,
false,
_key);
}
void mouse(int _button, bool _up, const vec2& _pos) {
GALE_ERROR("mouse: " << _button << " " << (_up==true?"up":"down") << " " << _pos);
m_cursorEventPos = vec2(_pos.x(), m_currentSize.y() - _pos.y());
OS_SetInput(gale::key::type::mouse,
(_up==true?gale::key::status::up:gale::key::status::down),
_button+1,
m_cursorEventPos);
m_inputIsPressed[_button+1] = !_up;
}
void mousePasive(const vec2& _pos) {
GALE_ERROR("mouse: " << _pos);
m_cursorEventPos = vec2(_pos.x(), m_currentSize.y() - _pos.y());
// For compatibility of the Android system :
bool findOne = false;
for (int32_t iii=0; iii<MAX_MANAGE_INPUT ; iii++) {
if (m_inputIsPressed[iii] == true) {
OS_SetInput(gale::key::type::mouse,
gale::key::status::move,
iii,
m_cursorEventPos);
findOne = true;
}
}
if (findOne == false) {
OS_SetInput(gale::key::type::mouse,
gale::key::status::move,
0,
m_cursorEventPos);
}
}
int32_t run() {
glutMainLoop();
return 0;
}
};
GLUTInterface* g_interface = null;
static void gale_glut_idle() {
glutPostRedisplay();
//g_interface->idle();
}
static void gale_glut_reshape(int _width, int _height) {
g_interface->reshape(_width, _height);
}
static void gale_glut_draw() {
g_interface->draw();
}
static void gale_glut_special(int _special, int _x, int _y) {
g_interface->special(_special);
}
static void gale_glut_keyboard(unsigned char _key, int _x, int _y) {
g_interface->keyboard(_key);
}
static void gale_glut_mouse(int _button, int _state, int _x, int _y) {
g_interface->mouse( _button, bool(_state), vec2(_x, _y));
}
static void gale_glut_mouse_pasive(int _x, int _y) {
g_interface->mousePasive(vec2(_x, _y));
}
#include <gale/context/SDL/Context.hpp>
bool gale::context::sdl::isBackendPresent() {
// TODO : Do it better...
return true;
}
ememory::SharedPtr<gale::Context> gale::context::sdl::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
#ifndef __EMSCRIPTEN__
// include GL stuff, to check that we can compile hybrid 2d/GL apps
extern void glBegin(int mode);
extern void glBindBuffer(int target, int buffer);
if (_argc == 9876) {
glBegin(0);
glBindBuffer(0, 0);
}
#endif
ememory::SharedPtr<gale::Context> out; ememory::makeShared<X11Interface>(_application, _argc, _argv);
/* Initialize the window */
glutInit(&_argc, (char**)_argv);
glutInitWindowSize(600, 450);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("coucou, name to change ...");
/* Set up glut callback functions */
glutIdleFunc(gale_glut_idle);
glutReshapeFunc(gale_glut_reshape);
glutDisplayFunc(gale_glut_draw);
glutSpecialFunc(gale_glut_special);
//glutEntryFunc(gale_glut_entry);
glutKeyboardFunc(gale_glut_keyboard);
glutMouseFunc(gale_glut_mouse);
glutMotionFunc(gale_glut_mouse_pasive);
GALE_DEBUG("7987984654654\n");
return out;
}

View File

@ -1,638 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/Dimension.hpp>
#include <etk/types.hpp>
#include <etk/uri/uri.hpp>
#include <etk/math/Vector2D.hpp>
#include <etk/math/Vector3D.hpp>
#include <gale/key/key.hpp>
#include <gale/resource/Texture.hpp>
#include <gale/context/Context.hpp>
#include <gale/renderer/openGL/openGL.hpp>
#include <gale/renderer/openGL/openGL-include.hpp>
#include <sys/time.h>
#include <windows.h>
#include <windowsx.h>
#include <etk/etk.hpp>
static etk::String GetLastErrorAsString() {
//Get the error message, if any.
DWORD errorMessageID = ::GetLastError();
if(errorMessageID == 0) {
return etk::String(); //No error message has been recorded
}
LPSTR messageBuffer = null;
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);
etk::String message(messageBuffer, size);
//Free the buffer.
LocalFree(messageBuffer);
return message;
}
class WindowsContext;
// This is a bad hook to get the wurrent windows pointer (it is unique ...):
static WindowsContext * galeWindowsContext = null;
// Window Procedure
static LRESULT CALLBACK WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam);
class WindowsContext : public gale::Context {
private:
int32_t m_currentHeight = 0;
bool m_inputIsPressed[MAX_MANAGE_INPUT];
gale::key::Special m_guiKeyBoardMode;
bool m_run;
bool m_clipBoardOwnerStd;
// windows specific instance ....
HINSTANCE m_hInstance;
HWND m_hWnd;
HDC m_hDC;
HGLRC m_hRC;
public:
WindowsContext(gale::Application* _application, int32_t _argc, const char* _argv[]) :
gale::Context(_application, _argc, _argv),
m_run(true),
m_clipBoardOwnerStd(false),
m_hInstance(GetModuleHandle(null)),
m_hWnd(0),
m_hDC(0),
m_hRC(0) {
galeWindowsContext = this;
for (int32_t iii=0; iii<MAX_MANAGE_INPUT; ++iii) {
m_inputIsPressed[iii] = false;
}
configure();
start2ndThreadProcessing();
}
~WindowsContext() {
galeWindowsContext = null;
release();
}
void configure() {
// register a new windows class (need it to define external callback)
WNDCLASSEX windowClass;
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_OWNDC;//CS_HREDRAW | CS_VREDRAW;//CS_OWNDC;
windowClass.lpfnWndProc = WndProc;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = m_hInstance;
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = "GaleMainWindows";
//Register window class
if (RegisterClassEx(&windowClass) == 0) {
GALE_ERROR("Can not register windows class: '" << GetLastErrorAsString() << "'" );
MessageBox(m_hWnd, "Error creating window class\n(gale internal error #65231)", "Error", MB_ICONEXCLAMATION);
PostQuitMessage(0);
return;
}
// Now we use the created windows class "GaleMainWindows" to create the wew windows with callback ... ==> use "STATIC" to not use generic callback ...
m_hWnd = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // The extended window style of the window being created.
"GaleMainWindows", // A null-terminated string or a class atom created by a previous call to the RegisterClass or RegisterClassEx function.
"Gale ... TODO Title", // The window name.
0
//| WS_OVERLAPPEDWINDOW //
| WS_CAPTION // Enable title bar
//| WS_DISABLED // Disable receive Windows event !! need to active EnableWindow
| WS_POPUPWINDOW // The window is a pop-up window
//| WS_POPUP // The windows is a pop-up window
//| WS_VISIBLE // Start in visible mode
//| WS_CLIPSIBLINGS //
//| WS_CLIPCHILDREN //
| WS_SIZEBOX //
, // The style of the window being created.
10, 10, // start position
800, 600, // start size
null, // A handle to the parent or owner window of the window being created
null, // A handle to a menu, or specifies a child-window identifier, depending on the window style
m_hInstance, // A handle to the instance of the module to be associated with the window.
null //A pointer to a value to be passed to the window through the CREATESTRUCT structure
);
if(m_hWnd == null) {
GALE_ERROR("Can not create windows '" << GetLastErrorAsString() << "'" );
MessageBox(m_hWnd, "Error creating window\n(gale internal error #45211)", "Error", MB_ICONEXCLAMATION);
PostQuitMessage(0);
}
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
int title_size = GetSystemMetrics(SM_CYCAPTION);
m_currentHeight = 600-2*border_thickness -title_size;
OS_Resize(vec2(800-2*border_thickness, m_currentHeight));
// enable openGL for the window
enableOpenGL(m_hWnd, &m_hDC, &m_hRC);
GLenum err = glewInit();
if (GLEW_OK != err) {
// Problem: glewInit failed, something is seriously wrong.
GALE_CRITICAL("Error: '" << glewGetErrorString(err) << "'" );
MessageBox(m_hWnd, "Error initilizing open GL\n(gale internal error #8421)", "Error", MB_ICONEXCLAMATION);
PostQuitMessage(0);
}
if (!glewIsSupported("GL_VERSION_2_0")) {
GALE_ERROR("OpenGL 2.0 not available '" << glewGetErrorString(err) << "'" );
MessageBox(m_hWnd, "Error initilizing open GL\n OPENGL 2.0 not availlable ...\n(gale internal error #75124)", "Error", MB_ICONEXCLAMATION);
PostQuitMessage(0);
}
// Configure the DPI of the screen:
{
vec2 dpi(0,0);
dpi.setX(GetDeviceCaps(m_hDC, LOGPIXELSX));
dpi.setY(GetDeviceCaps(m_hDC, LOGPIXELSY));
gale::Dimension::setPixelRatio(dpi, gale::distance::inch);
GALE_INFO("monitor property : dpi=" << dpi << " px/inch");
}
// Get monitor Size
{
HMONITOR monitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO info;
info.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(monitor, &info);
int monitor_width = info.rcMonitor.right - info.rcMonitor.left;
int monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
GALE_INFO("monitor property: size=" << ivec2(monitor_width, monitor_height) << " px");
}
ShowCursor(TRUE);
}
int32_t run() {
// Now we can show it ...
ShowWindow(m_hWnd, SW_SHOW);
//EnableWindow(m_hWnd, TRUE);
// Force update of the windows
UpdateWindow(m_hWnd);
MSG msg;
// program main loop
while(m_run == true) {
// check for messages
if (PeekMessage(&msg, null, 0, 0, PM_REMOVE)) {
// handle or dispatch messages
if (msg.message == WM_QUIT) {
m_run = false;
} else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} else {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
OS_Draw(true);
SwapBuffers(m_hDC);
}
}
return msg.wParam;
}
void release() {
// TODO : We destroy the OpenGL context before cleaning GALE : Do it Better ...
getResourcesManager().contextHasBeenDestroyed();
// shutdown openGL
disableOpenGL(m_hWnd, m_hDC, m_hRC);
// destroy the window explicitly
DestroyWindow(m_hWnd);
}
/****************************************************************************************/
void stop() {
m_run = false;
// To exit program ...
PostQuitMessage(0);
}
/****************************************************************************************/
void setSize(const vec2& _size) {
float border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
float title_size = GetSystemMetrics(SM_CYCAPTION);
vec2 newSize(_size.x() + border_thickness*2.0f,
_size.y() + border_thickness*2.0f + title_size);
//m_currentHeight = size.y;
// TODO : Later
}
/****************************************************************************************/
void ClipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
// this is to force the local system to think we have the buffer
// TODO : remove this 2 line when code will be writen
m_clipBoardOwnerStd = true;
switch (_clipboardID) {
case gale::context::clipBoard::clipboardSelection:
// NOTE : Windows does not support the middle button the we do it internaly
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(gale::context::clipBoard::clipboardSelection);
break;
case gale::context::clipBoard::clipboardStd:
// TODO : never done reset at false ...
if (m_clipBoardOwnerStd == false) {
char* buffer = null;
if(OpenClipboard(m_hWnd)) {
buffer = (char*)GetClipboardData(CF_TEXT);
etk::String tmpppp((char*)buffer);
// TODO : Check if we need to free buffer ...
gale::context::clipBoard::setSystem(gale::context::clipBoard::clipboardSelection, tmpppp);
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(gale::context::clipBoard::clipboardStd);
}
CloseClipboard();
} else {
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(gale::context::clipBoard::clipboardStd);
}
break;
default:
GALE_ERROR("Request an unknow ClipBoard ...");
break;
}
}
/****************************************************************************************/
void ClipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
switch (_clipboardID) {
case gale::context::clipBoard::clipboardSelection:
// NOTE : nothing to do : Windows deas ot supported Middle button
break;
case gale::context::clipBoard::clipboardStd:
// Request the clipBoard :
if (m_clipBoardOwnerStd == false) {
etk::String tmpData = gale::context::clipBoard::get(_clipboardID);
//put your text in source
if(OpenClipboard(m_hWnd)) {
HGLOBAL clipbuffer;
char * buffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, tmpData.size()+1);
buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, tmpData.c_str());
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT, clipbuffer);
CloseClipboard();
}
m_clipBoardOwnerStd = true;
}
break;
default:
GALE_ERROR("Request an unknow ClipBoard ...");
break;
}
}
// enable openGL
void enableOpenGL(HWND _hWnd, HDC* _hDC, HGLRC* _hRC) {
// get the device context (DC)
*_hDC = GetDC(_hWnd);
// Configure the color set ...
PIXELFORMATDESCRIPTOR pfd;
// set the pixel format for the DC
ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_TYPE_RGBA;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
int format = ChoosePixelFormat(*_hDC, &pfd);
SetPixelFormat(*_hDC, format, &pfd);
// create and enable the render context(RC)
*_hRC = wglCreateContext(*_hDC);
wglMakeCurrent(*_hDC, *_hRC);
if (wglGetCurrentContext() == null) {
GALE_ERROR("can not create OPEN gL context...");
MessageBox(_hWnd, "Error initilizing open GL\n openGL context creation error...\n(gale internal error #3526)", "Error", MB_ICONEXCLAMATION);
PostQuitMessage(0);
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// | GL_STENCIL_BUFFER_BIT);
}
// disable openGL (fisnish application ...
void disableOpenGL(HWND _hWnd, HDC _hDC, HGLRC _hRC) {
wglMakeCurrent(null, null);
wglDeleteContext(_hRC);
ReleaseDC(_hWnd, _hDC);
}
LRESULT CALLBACK WndProcReal(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam) {
bool buttonIsDown = true;
int32_t mouseButtonId = 0;
ivec2 pos;
// to know all _message : http://wiki.winehq.org/List_Of_Windows__messages
switch (_message) {
/* **************************************************************************
* Gui event
* **************************************************************************/
case WM_CREATE:
GALE_DEBUG("WM_CREATE");
break;
case WM_CLOSE:
GALE_DEBUG("WM_CLOSE");
OS_Stop();
return 0;
case WM_DESTROY:
GALE_DEBUG("WM_DESTROY");
m_run = false;
break;
case WM_MOVE:
GALE_DEBUG("WM_MOVE");
break;
case WM_SIZE:
GALE_DEBUG("WM_SIZE");
break;
/*
case WM_GETMINMAXINFO:
{
MINMAXINFO* tmpVal = (MINMAXINFO*)lParam;
GALE_DEBUG("WM_GETMINMAXINFO : ");
GALE_DEBUG(" ptMaxSize : " << tmpVal->ptMaxSize.x << "," << tmpVal->ptMaxSize.y << ")");
GALE_DEBUG(" ptMaxPosition : " << tmpVal->ptMaxPosition.x << "," << tmpVal->ptMaxPosition.y << ")");
GALE_DEBUG(" ptMinTrackSize : " << tmpVal->ptMinTrackSize.x << "," << tmpVal->ptMinTrackSize.y << ")");
GALE_DEBUG(" ptMaxTrackSize : " << tmpVal->ptMaxTrackSize.x << "," << tmpVal->ptMaxTrackSize.y << ")");
}
break;
*/
case WM_WINDOWPOSCHANGING: {
WINDOWPOS* tmpVal = (WINDOWPOS*)_lParam;
if (tmpVal == null) {
break;
}
GALE_VERBOSE("WM_WINDOWPOSCHANGING : : (" << tmpVal->x << "," << tmpVal->y << ") ( " << tmpVal->cx << "," << tmpVal->cy << ")");
if ( tmpVal->cx == 0
&& tmpVal->cy == 0) {
// special case for start application and hide application
break;
}
// in windows system, we need to remove the size of the border elements:
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
int title_size = GetSystemMetrics(SM_CYCAPTION);
m_currentHeight = tmpVal->cy - 2*border_thickness - title_size;
float width = tmpVal->cx-2*border_thickness;
OS_Resize(vec2(width, m_currentHeight));
break;
}
// these message are not parse by us ...
case WM_SETCURSOR: // Call the windows if we want the mouse event :
case WM_NCHITTEST: // inform the application the position of the mouse is moving
break;
/* **************************************************************************
* Keyboard management
* **************************************************************************/
case WM_KEYUP:
buttonIsDown = false;
case WM_KEYDOWN: {
char32_t tmpChar = 0;
enum gale::key::keyboard keyInput;
switch (_wParam) {
//case 80: // keypad
case VK_UP: keyInput = gale::key::keyboard::up; break;
//case 83: // keypad
case VK_LEFT: keyInput = gale::key::keyboard::left; break;
//case 85: // keypad
case VK_RIGHT: keyInput = gale::key::keyboard::right; break;
//case 88: // keypad
case VK_DOWN: keyInput = gale::key::keyboard::down; break;
//case 81: // keypad
case VK_PRIOR: keyInput = gale::key::keyboard::pageUp; break;
//case 89: // keypad
case VK_NEXT: keyInput = gale::key::keyboard::pageDown; break;
//case 79: // keypad
case VK_HOME: keyInput = gale::key::keyboard::start; break;
//case 87: // keypad
case VK_END: keyInput = gale::key::keyboard::end; break;
//case VK_: keyInput = gale::key::keyboardStopDefil; break;
case VK_PAUSE: keyInput = gale::key::keyboard::wait; break;
//case 90: // keypad
case VK_INSERT:
keyInput = gale::key::keyboard::insert;
m_guiKeyBoardMode.setInsert(buttonIsDown);
break;
case VK_F1: keyInput = gale::key::keyboard::f1; break;
case VK_F2: keyInput = gale::key::keyboard::f2; break;
case VK_F3: keyInput = gale::key::keyboard::f3; break;
case VK_F4: keyInput = gale::key::keyboard::f4; break;
case VK_F5: keyInput = gale::key::keyboard::f5; break;
case VK_F6: keyInput = gale::key::keyboard::f6; break;
case VK_F7: keyInput = gale::key::keyboard::f7; break;
case VK_F8: keyInput = gale::key::keyboard::f8; break;
case VK_F9: keyInput = gale::key::keyboard::f9; break;
case VK_F10: keyInput = gale::key::keyboard::f10; break;
case VK_F11: keyInput = gale::key::keyboard::f11; break;
case VK_F12:
case VK_F13:
case VK_F14:
case VK_F15:
case VK_F16:
case VK_F17:
case VK_F18:
case VK_F19:
case VK_F20:
case VK_F21:
case VK_F22:
case VK_F23:
case VK_F24: keyInput = gale::key::keyboard::f12; break;
case VK_CAPITAL:
keyInput = gale::key::keyboard::capLock;
m_guiKeyBoardMode.setCapsLock(buttonIsDown);
break;
case VK_SHIFT:
case VK_LSHIFT:
keyInput = gale::key::keyboard::shiftLeft;
m_guiKeyBoardMode.setShift(buttonIsDown);
break;
case VK_RSHIFT:
keyInput = gale::key::keyboard::shiftRight;
m_guiKeyBoardMode.setShift(buttonIsDown);
break;
case VK_CONTROL:
case VK_LCONTROL:
keyInput = gale::key::keyboard::ctrlLeft;
m_guiKeyBoardMode.setCtrl(buttonIsDown);
break;
case VK_RCONTROL:
keyInput = gale::key::keyboard::ctrlRight;
m_guiKeyBoardMode.setCtrl(buttonIsDown);
break;
case VK_LWIN:
keyInput = gale::key::keyboard::metaLeft;
m_guiKeyBoardMode.setMeta(buttonIsDown);
break;
case VK_RWIN:
keyInput = gale::key::keyboard::metaRight;
m_guiKeyBoardMode.setMeta(buttonIsDown);
break;
case VK_MENU:
case VK_LMENU:
keyInput = gale::key::keyboard::alt;
m_guiKeyBoardMode.setAlt(buttonIsDown);
break;
case VK_RMENU:
keyInput = gale::key::keyboard::altGr;
m_guiKeyBoardMode.setAltGr(buttonIsDown);
break;
//case : keyInput = gale::key::keyboardContextMenu; break;
case VK_NUMLOCK:
keyInput = gale::key::keyboard::numLock;
m_guiKeyBoardMode.setNumLock(buttonIsDown);
break;
case VK_BACK: // DEL
tmpChar = 0x08;
break;
// TODO : Really strang, need to understand why ...
case 46: // Suppr
tmpChar = 0x7F;
break;
case VK_TAB: // special case for TAB
tmpChar = 0x09;
break;
case VK_RETURN: // special case for TAB
tmpChar = '\n';
break;
default:
{
BYTE kbd[256];
GetKeyboardState(kbd);
const int BUFFER_LENGTH = 8; //Length of the buffer
WCHAR chars[BUFFER_LENGTH];
ToUnicode(_wParam, _lParam, kbd, chars,BUFFER_LENGTH,0);
tmpChar = utf8::convertChar32((char*)chars);
}
break;
}
GALE_VERBOSE("Keyboard Value = " << _wParam << " '" << char(tmpChar) << "'");
if (tmpChar == 0) {
//GALE_DEBUG("eventKey Move type : " << getCharTypeMoveEvent(keyInput) );
OS_setKeyboard(m_guiKeyBoardMode,
keyInput,
(buttonIsDown==true?gale::key::status::down:gale::key::status::up));
} else {
OS_setKeyboard(m_guiKeyBoardMode,
gale::key::keyboard::character,
(buttonIsDown==true?gale::key::status::down:gale::key::status::up),
false,
tmpChar);
}
break;
}
/* **************************************************************************
* Mouse management
* **************************************************************************/
case WM_LBUTTONUP:
buttonIsDown = false;
case WM_LBUTTONDOWN:
mouseButtonId = 1;
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
m_inputIsPressed[mouseButtonId] = buttonIsDown;
OS_SetInput(gale::key::type::mouse,
(buttonIsDown==true?gale::key::status::down:gale::key::status::up),
mouseButtonId,
vec2(pos.x(),pos.y()));
break;
case WM_MBUTTONUP:
buttonIsDown = false;
case WM_MBUTTONDOWN:
mouseButtonId = 2;
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
m_inputIsPressed[mouseButtonId] = buttonIsDown;
OS_SetInput(gale::key::type::mouse,
(buttonIsDown==true?gale::key::status::down:gale::key::status::up),
mouseButtonId,
vec2(pos.x(),pos.y()));
break;
case WM_RBUTTONUP:
buttonIsDown = false;
case WM_RBUTTONDOWN:
mouseButtonId = 3;
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
m_inputIsPressed[mouseButtonId] = buttonIsDown;
OS_SetInput(gale::key::type::mouse,
(buttonIsDown==true?gale::key::status::down:gale::key::status::up),
mouseButtonId,
vec2(pos.x(),pos.y()));
break;
case WM_MOUSEWHEEL:
if (_wParam & 0x200000) {
GALE_DEBUG("event SCROOL UP");
mouseButtonId = 4;
} else {
GALE_DEBUG("event SCROOL DOWN");
mouseButtonId = 5;
}
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
OS_SetInput(gale::key::type::mouse,
gale::key::status::down,
mouseButtonId,
vec2(pos.x(),pos.y()));
OS_SetInput(gale::key::type::mouse,
gale::key::status::up,
mouseButtonId,
vec2(pos.x(),pos.y()));
break;
case WM_MOUSEHOVER:
case WM_MOUSEMOVE:
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
for (int32_t iii=0; iii<MAX_MANAGE_INPUT ; iii++) {
if (true == m_inputIsPressed[iii]) {
GALE_VERBOSE("Windows event: bt=" << iii << " " << _message << " = \"WM_MOUSEMOVE\" " << pos );
OS_SetInput(gale::key::type::mouse,
gale::key::status::move,
iii,
vec2(pos.x(),pos.y()));
return 0;
}
}
GALE_VERBOSE("Windows event: bt=" << 0 << " " << _message << " = \"WM_MOUSEMOVE\" " << pos );
OS_SetInput(gale::key::type::mouse,
gale::key::status::move,
0,
vec2(pos.x(),pos.y()));
break;
default:
GALE_DEBUG("event ..." << _message );
break;
}
return DefWindowProc(_hWnd, _message, _wParam, _lParam);
}
/****************************************************************************************/
void setTitle(const etk::String& _title) {
GALE_VERBOSE("Windows: set Title (START)");
SetWindowText(m_hWnd, _title.c_str());
GALE_VERBOSE("Windows: set Title (END)");
}
};
static LRESULT CALLBACK WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam) {
// TODO : set this function really work...
if (galeWindowsContext == null) {
return 0;
}
return galeWindowsContext->WndProcReal(_hWnd, _message, _wParam, _lParam);
}
#include <gale/context/Windows/Context.hpp>
bool gale::context::windows::isBackendPresent() {
// TODO : Do it better...
return true;
}
ememory::SharedPtr<gale::Context> gale::context::windows::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
return ememory::makeShared<WindowsContext>(_application, _argc, _argv);
}

View File

@ -1,26 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
namespace gale {
namespace context {
namespace windows {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
namespace gale {
namespace context {
namespace x11 {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

View File

@ -1,141 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp>
#include <gale/debug.hpp>
#include <gale/context/clipBoard.hpp>
#include <gale/context/Context.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::context::clipBoard::clipboardListe);
/*
note: copy id data :
0 : copy standard
[1..9] : copy internal
10 : middle button
*/
//!< Local copy of the clipboards
static etk::String myCopy[gale::context::clipBoard::clipboardCount];
static const char* clipboardDescriptionString[gale::context::clipBoard::clipboardCount+1] = {
"clipboard0",
"clipboard1",
"clipboard2",
"clipboard3",
"clipboard4",
"clipboard5",
"clipboard6",
"clipboard7",
"clipboard8",
"clipboard9",
"clipboardStd",
"clipboardSelection",
"clipboardCount"
};
etk::Stream& gale::operator <<(etk::Stream& _os, enum gale::context::clipBoard::clipboardListe _obj) {
if (_obj >= 0 && _obj <gale::context::clipBoard::clipboardCount) {
_os << clipboardDescriptionString[int32_t(_obj)];
} else {
_os << "[ERROR]";
}
return _os;
}
namespace etk {
template<> etk::String toString<enum gale::context::clipBoard::clipboardListe>(const enum gale::context::clipBoard::clipboardListe& _obj) {
return clipboardDescriptionString[int32_t(_obj)];
}
template <> bool from_string<enum gale::context::clipBoard::clipboardListe>(enum gale::context::clipBoard::clipboardListe& _variableRet, const etk::String& _value) {
for (size_t iii=0; iii< sizeof(clipboardDescriptionString); ++iii) {
if (_value == clipboardDescriptionString[iii]) {
_variableRet = (enum gale::context::clipBoard::clipboardListe)iii;
return true;
}
}
return false;
}
}
void gale::context::clipBoard::init() {
GALE_INFO("Initialyse ClipBoards");
for(int32_t iii=0; iii<gale::context::clipBoard::clipboardCount; ++iii) {
myCopy[iii].clear();
}
}
void gale::context::clipBoard::unInit() {
GALE_INFO("Initialyse ClipBoards");
for(int32_t i=0; i<gale::context::clipBoard::clipboardCount; i++) {
myCopy[i].clear();
}
}
void gale::context::clipBoard::set(enum gale::context::clipBoard::clipboardListe _clipboardID, const etk::String& _data) {
// check if ID is correct
if(0 == _data.size()) {
GALE_INFO("request a copy of nothing");
return;
} else
if(_clipboardID >= gale::context::clipBoard::clipboardCount) {
GALE_WARNING("request ClickBoard id error");
return;
}
gale::context::clipBoard::setSystem(_clipboardID, _data);
if( gale::context::clipBoard::clipboardStd == _clipboardID
|| gale::context::clipBoard::clipboardSelection == _clipboardID) {
gale::getContext().clipBoardSet(_clipboardID);
}
}
void gale::context::clipBoard::request(enum gale::context::clipBoard::clipboardListe _clipboardID) {
if(_clipboardID >= gale::context::clipBoard::clipboardCount) {
GALE_WARNING("request ClickBoard id error");
return;
}
if( gale::context::clipBoard::clipboardStd == _clipboardID
|| gale::context::clipBoard::clipboardSelection == _clipboardID) {
gale::getContext().clipBoardGet(_clipboardID);
} else {
// generate an event on the main thread ...
gale::getContext().OS_ClipBoardArrive(_clipboardID);
}
}
void gale::context::clipBoard::setSystem(enum gale::context::clipBoard::clipboardListe _clipboardID, const etk::String& _data) {
if(_clipboardID >= gale::context::clipBoard::clipboardCount) {
GALE_WARNING("request ClickBoard id error");
return;
}
// Copy datas ...
myCopy[_clipboardID] = _data;
}
const etk::String& gale::context::clipBoard::get(enum gale::context::clipBoard::clipboardListe _clipboardID) {
static const etk::String emptyString("");
if(_clipboardID >= gale::context::clipBoard::clipboardCount) {
GALE_WARNING("request ClickBoard id error");
return emptyString;
}
// Copy datas ...
return myCopy[_clipboardID];
}

View File

@ -1,76 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/debug.hpp>
// TODO : Remove this ... ==> set it in the context ....
namespace gale {
namespace context {
namespace clipBoard {
enum clipboardListe {
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
clipboardCount, //!< Total number of clipboard
};
/**
* @brief set the string data on a specific clipboard. The Gui system is notify that the clipboard "SELECTION" and "COPY" are change
* @param[in] _clipboardID Select the specific ID of the clipboard
* @param[in] _data The string that might be send to the clipboard
*/
void set(enum gale::context::clipBoard::clipboardListe _clipboardID, const etk::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[in] _clipboardID the needed clipboard ID
*/
void request(enum gale::context::clipBoard::clipboardListe _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[in] _clipboardID selected clipboard ID
* @param[in] _data new buffer data
*/
void setSystem(enum gale::context::clipBoard::clipboardListe _clipboardID,const etk::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[in] _clipboardID selected clipboard ID
* @return the requested buffer
*/
const etk::String& get(enum gale::context::clipBoard::clipboardListe _clipboardID);
// internal section
/**
* @brief initialize the clipboard system (done by gale)
*/
void init();
/**
* @brief Un-Initialize the clipboard system (done by gale)
*/
void unInit();
};
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
etk::Stream& operator <<(etk::Stream& _os, const enum gale::context::clipBoard::clipboardListe _obj);
}

View File

@ -1,41 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/debug.hpp>
#include <gale/context/commandLine.hpp>
#include <etk/Vector.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::context::CommandLine);
void gale::context::CommandLine::parse(int32_t _argc, const char* _argv[]) {
for (int32_t i=1 ; i<_argc; i++) {
GALE_INFO("commandLine : \"" << _argv[i] << "\"" );
m_listArgs.pushBack(_argv[i]);
}
}
int32_t gale::context::CommandLine::size() {
return m_listArgs.size();
}
const etk::String& gale::context::CommandLine::get(int32_t _id) {
static const etk::String errorArg("");
if ( _id < 0
&& _id >= (int64_t)m_listArgs.size()) {
return errorArg;
}
return m_listArgs[_id];
}
void gale::context::CommandLine::add(const etk::String& _newElement) {
m_listArgs.pushBack(_newElement);
}
void gale::context::CommandLine::remove(int32_t _id) {
m_listArgs.erase(m_listArgs.begin()+_id);
}

View File

@ -1,43 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/debug.hpp>
namespace gale {
namespace context {
class CommandLine {
private:
etk::Vector<etk::String> m_listArgs; //!< list of all argument parsed
public:
/**
* @brief Parse the command line parameters
*/
void parse(int32_t _argc, const char* _argv[]);
/**
* @brief get the number of element in the Command line
* @return the number of element
*/
int32_t size();
/**
* @brief get an element with a specific ID
* @return _id The cmdLine Id element
*/
const etk::String& get(int32_t _id);
/**
* @brief add one element at the Command line
* @param[in] _newElement String in the input that might be added.
*/
void add(const etk::String& _newElement);
/**
* @brief remove an element
* @param[in] _id Id of the element
*/
void remove(int32_t _id);
};
}
}

View File

@ -1,40 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/context/cursor.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::context::cursor);
static const char* cursorDescriptionString[] = {
"cursor::arrow",
"cursor::leftArrow",
"cursor::info",
"cursor::destroy",
"cursor::help",
"cursor::cycle",
"cursor::spray",
"cursor::wait",
"cursor::text",
"cursor::crossHair",
"cursor::slideUpDown",
"cursor::slideLeftRight",
"cursor::resizeUp",
"cursor::resizeDown",
"cursor::resizeLeft",
"cursor::resizeRight",
"cursor::cornerTopLeft",
"cursor::cornerTopRight",
"cursor::cornerButtomLeft",
"cursor::cornerButtomRight",
"cursor::none"
};
etk::Stream& gale::context::operator <<(etk::Stream& _os, enum gale::context::cursor _obj) {
_os << cursorDescriptionString[int32_t(_obj)];
return _os;
}

View File

@ -1,41 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/debug.hpp>
namespace gale {
namespace context {
enum class 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
};
/**
* @brief Debug operator To display the curent element in a Human readable information
*/
etk::Stream& operator <<(etk::Stream& _os, enum gale::context::cursor _obj);
}
}

View File

@ -1,483 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
/*
notes :
sudo edn /etc/udev/rules.d/framebuffer.rules
KERNEL == "fb0", OWNER="root", MODE="0660"
sudo usermod -a -G video username
sudo usermod -a -G tty username
sudo fbset -i
sudo chmod o+wr /dev/fb0
http://mail.directfb.org/pipermail/directfb-users/2010-February/002115.html
on X11 :
http://stackoverflow.com/questions/521957/how-to-develop-a-directfb-app-without-leaving-x-11-environment
$ sudo apt-get install libdirectfb-extra # for Debian and Ubuntu, anyhow
$ cat ~/.directfbrc
system=x11
force-windowed
*/
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/key.hpp>
#include <gale/config.hpp>
#include <gale/commandLine.hpp>
#include <etk/types.hpp>
#include <etk/unicode.hpp>
#include <gale/widget/Manager.hpp>
#include <gale/renderer/ResourceManager.hpp>
#include <gale/renderer/eSystem.hpp>
#include <gale/openGL/openGL.hpp>
extern "C" {
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
}
#include <directfb.h>
#include <directfbgl.h>
int64_t guiInterface::getTime() {
struct timespec now;
int ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
// Error to get the time ...
now.tv_sec = time(null);
now.tv_nsec = 0;
}
//GALE_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000);
}
static gale::SpecialKey guiKeyBoardMode;
bool inputIsPressed[20];
bool m_run = true;
bool m_grabAllEvent = false;
// the super interface
IDirectFB *dfb = null;
// the primary surface (surface of primary layer)
IDirectFBSurface *primary = null;
// the GL context
IDirectFBGL *primary_gl = null;
// event buffer
IDirectFBEventBuffer *events = null;
static int screen_width =800;
static int screen_height = 600;
/**
* @brief set the new title of the windows
* @param title New desired title
* @return ---
*/
void guiInterface::setTitle(etk::String& title) {
// TODO : ...
}
void guiInterface::setIcon(etk::String inputFile) {
// TODO : ...
}
void DirectFB_Init(int argc, const char *argv[]) {
GALE_INFO("DirectFB init (START)");
DFBResult err;
DFBSurfaceDescription dsc;
GALE_INFO("call DirectFBInit");
int argc2 = 1;
err = DirectFBInit(&argc2, (char***)&argv);
if (DFB_OK!=err) {
GALE_ERROR("DirectFBInit");
DirectFBErrorFatal("DirectFBInit", err);
exit(-1);
}
GALE_INFO("call DirectFBCreate");
// create the super interface
err = DirectFBCreate(&dfb);
if (DFB_OK!=err) {
GALE_ERROR("DirectFBCreate");
DirectFBErrorFatal("DirectFBCreate", err);
exit(-1);
}
GALE_INFO("call setCooperativeLevel");
// set our cooperative level to DFSCL_FULLSCREEN for exclusive access to the primary layer
dfb->setCooperativeLevel(dfb, DFSCL_FULLSCREEN);
//dfb->setCooperativeLevel(dfb, DFSCL_NORMAL);
// get the primary surface, i.e. the surface of the primary layer we have exclusive access to
dsc.flags = (DFBSurfaceDescriptionFlags)(DSDESC_CAPS);// | DSDESC_PIXELFORMAT);
//dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | DSCAPS_DOUBLE | DSCAPS_DEPTH); // DSCAPS_SHARED
dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | DSCAPS_DOUBLE | DSCAPS_GL);// | DSCAPS_FLIPPING);
//dsc.caps = (DFBSurfaceCapabilities) (DSCAPS_SUBSURFACE | DSCAPS_VIDEOONLY | DSCAPS_PREMULTIPLIED | DSCAPS_FLIPPING);
dsc.pixelformat = DSPF_ARGB;
dsc.width = 600;
dsc.height = 400;
GALE_INFO("call CreateSurface");
err = dfb->CreateSurface(dfb, &dsc, &primary);
if (DFB_OK!=err) {
GALE_ERROR("dfb->CreateSurface");
DirectFBErrorFatal("dfb->CreateSurface", err);
exit(-1);
}
primary->setBlittingFlags(primary, DSBLIT_BLEND_ALPHACHANNEL);
primary->setPorterDuff( primary, DSPD_ADD );
primary->setDstBlendFunction(primary, DSBF_SRCALPHA);
primary->setDrawingFlags(primary, DSDRAW_BLEND);
primary->Blit(primary, primary, null, 0, 0);
GALE_INFO("call getSize");
// get the size of the surface and fill it
err = primary->getSize(primary, &screen_width, &screen_height);
if (DFB_OK!=err) {
GALE_ERROR("primary->getSize");
DirectFBErrorFatal("primary->getSize", err);
exit(-1);
}
GALE_INFO("call CreateInputEventBuffer");
// create an event buffer for all devices with these caps
err = dfb->CreateInputEventBuffer(dfb, (DFBInputDeviceCapabilities)(DICAPS_KEYS | DICAPS_AXES), DFB_FALSE, &events);
if (DFB_OK!=err) {
GALE_ERROR("dfb->CreateInputEventBuffer");
DirectFBErrorFatal("CreateInputEventBuffer", err);
exit(-1);
}
GALE_INFO("call Flip");
primary->Flip(primary, null, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
// NOTE : we need to force it on X11 display ...
GALE_INFO("call getGL");
// get the GL context
err = primary->getGL(primary, &primary_gl);
if (DFB_OK!=err) {
GALE_ERROR("primary->getGL");
DirectFBErrorFatal("GetGL", err);
exit(-1);
}
GALE_INFO("DirectFB init (STOP)");
}
void DirectFB_UnInit() {
// release our interfaces to shutdown DirectFB
primary_gl->release(primary_gl);
primary->release(primary);
events->release(events);
dfb->release(dfb);
}
void DirectFB_Run() {
GALE_INFO("X11 configure windows size : (" << screen_height << "," << screen_width << ")");
eSystem::Resize(screen_width, screen_height);
DFBResult err;
int32_t position = 0;
while (true == m_run) {
DFBInputEvent evt;
unsigned long t;
/*
primary->setColor (primary, 0x00, 0x00, 0x00, 0xFF);
primary->FillRectangle(primary, 0, 0, screen_width, screen_height);
primary->setColor (primary, 0xFF, (uint8_t)position, 0x00, 0xFF);
primary->FillRectangle(primary, position, position, 300, 300);
primary->Flip(primary, null, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
position++;
if (position>600) {
position = 0;
}
*/
if(true == m_run) {
err = primary_gl->Lock(primary_gl);
if (DFB_OK!=err) {
GALE_ERROR("primary_gl->Lock");
DirectFBErrorFatal("primary_gl->Lock", err);
}
// TODO : set at false
bool hasDisplay = eSystem::draw(true);
if (true == hasDisplay) {
glFinish();
}
err = primary_gl->Unlock(primary_gl);
if (DFB_OK!=err) {
GALE_ERROR("primary_gl->Unlock");
DirectFBErrorFatal("primary_gl->Unlock", err);
}
primary->Flip(primary, null, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
}
while (events->getEvent(events, DFB_EVENT(&evt)) == DFB_OK) {
switch (evt.type) {
default:
case DIET_UNKNOWN: /* unknown event */
GALE_DEBUG("event unknown type : " << evt.type << " symbole=\"" << (char)evt.key_symbol << "\"=" << ((int32_t)evt.key_symbol) << " ...");
break;
case DIET_KEYPRESS: /* a key is been pressed */
case DIET_KEYRELEASE: /* a key is been released */
{
bool isPressed = (evt.type == DIET_KEYPRESS);
//GALE_DEBUG("event KeyBoard isPressed : " << isPressed << " symbole=\"" << (char)evt.key_symbol << "\"=" << ((int32_t)evt.key_symbol) << " ...");
if( 1 <= evt.key_symbol && evt.key_symbol <= 0x7F ) {
eSystem::setKeyboard(guiKeyBoardMode, evt.key_symbol, isPressed, false);
} else {
GALE_DEBUG("event KeyBoard isPressed : " << isPressed << " symbole=\"" << (char)evt.key_symbol << "\"=" << ((int32_t)evt.key_symbol) << " == > not managed key");
}
}
break;
case DIET_AXISMOTION: /* mouse/joystick movement */
{
/*
if (evt.flags & DIEF_AXISREL) {
switch (evt.axis) {
case DIAI_X:
//view_roty += evt.axisrel / 2.0;
break;
case DIAI_Y:
//view_rotx += evt.axisrel / 2.0;
break;
case DIAI_Z:
//view_rotz += evt.axisrel / 2.0;
break;
default:
;
}
}
*/
GALE_DEBUG("event mouse motion flag" << (char)evt.flags << " axis=" << evt.axis << " value=" << evt.axisrel);
}
break;
case DIET_BUTTONPRESS: /* a (mouse) button is been pressed */
case DIET_BUTTONRELEASE: /* a (mouse) button is been released */
{
bool isPressed = (evt.type == DIET_KEYPRESS);
GALE_DEBUG("event mouse event pressed=" << isPressed << " flag" << (char)evt.flags << " axis=" << evt.axis << " value=" << evt.axisrel);
}
break;
/*
case DIET_KEYPRESS:
switch (evt.key_symbol) {
case DIKS_ESCAPE:
m_run = false;
break;
case DIKS_CURSOR_UP:
//inc_rotx = 5.0;
break;
case DIKS_CURSOR_DOWN:
//inc_rotx = -5.0;
break;
case DIKS_CURSOR_LEFT:
//inc_roty = 5.0;
break;
case DIKS_CURSOR_RIGHT:
//inc_roty = -5.0;
break;
case DIKS_PAGE_UP:
//inc_rotz = 5.0;
break;
case DIKS_PAGE_DOWN:
//inc_rotz = -5.0;
break;
default:
;
}
break;
case DIET_KEYRELEASE:
switch (evt.key_symbol) {
case DIKS_CURSOR_UP:
//inc_rotx = 0;
break;
case DIKS_CURSOR_DOWN:
//inc_rotx = 0;
break;
case DIKS_CURSOR_LEFT:
//inc_roty = 0;
break;
case DIKS_CURSOR_RIGHT:
//inc_roty = 0;
break;
case DIKS_PAGE_UP:
//inc_rotz = 0;
break;
case DIKS_PAGE_DOWN:
//inc_rotz = 0;
break;
default:
;
}
break;
case DIET_AXISMOTION:
if (evt.flags & DIEF_AXISREL) {
switch (evt.axis) {
case DIAI_X:
//view_roty += evt.axisrel / 2.0;
break;
case DIAI_Y:
//view_rotx += evt.axisrel / 2.0;
break;
case DIAI_Z:
//view_rotz += evt.axisrel / 2.0;
break;
default:
;
}
}
break;
default:
;
*/
}
}
}
// Note : if we not stop like this the system break ...
exit(-1);
};
// -------------------------------------------------------------------------
// ClipBoard AREA :
// -------------------------------------------------------------------------
void guiInterface::ClipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
// TODO : ...
}
void guiInterface::ClipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
// TODO : ...
}
void guiInterface::Stop() {
GALE_INFO("X11-API: Stop");
m_run = false;
}
void guiInterface::KeyboardShow() {
// nothing to do : No keyboard on computer ...
}
void guiInterface::KeyboardHide() {
// nothing to do : No keyboard on computer ...
}
void guiInterface::changeSize(ivec2 _size) {
// TODO : ...
}
void guiInterface::changePos(ivec2 _pos) {
// TODO : ...
}
void guiInterface::getAbsPos(ivec2& _pos) {
// TODO : ...
}
void guiInterface::setCursor(enum gale::cursorDisplay _newCursor) {
// TODO : ...
}
void guiInterface::GrabPointerEvents(bool _isGrabbed, vec2 _forcedPosition) {
// TODO : ...
}
/**
* @brief Main of the program
* @param std IO
* @return std IO
*/
int guiInterface::main(int argc, const char *argv[]) {
GALE_INFO("Main (START)");
for (int32_t iii=0; iii<NB_MAX_INPUT; iii++) {
inputIsPressed[iii] = false;
}
m_grabAllEvent = false;
// start X11 thread ...
DirectFB_Init(argc, argv);
//start the basic thread :
eSystem::init();
// Run ...
DirectFB_Run();
// UnInit:
DirectFB_UnInit();
// close X11 :
guiInterface::Stop();
// uninit ALL :
eSystem::UnInit();
GALE_INFO("Main (STOP)");
return 0;
}
void guiInterface::forceOrientation(enum gale::orientation _orientation) {
// nothing to do ...
}
/*
static void init(int argc, char *argv[]) {
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
for (i=1; i<argc; i++)
{
if (strcmp(argv[i],"-info") == 0)
{
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
else if (strcmp(argv[i],"-exit") == 0)
{
autoexit = 30;
printf("Auto Exit after %i seconds.\n", autoexit );
}
}
// make the gears
gear1 = gear(1.0, 4.0, 1.0, 20, 0.7, red);
gear2 = gear(0.5, 2.0, 2.0, 10, 0.7, green);
gear3 = gear(1.3, 2.0, 0.5, 10, 0.7, blue);
}
*/

View File

@ -1,230 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
extern "C" {
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
}
#include <etk/types.hpp>
#include <etk/uri/uri.hpp>
#include <etk/tool.hpp>
#include <gale/debug.hpp>
#include <gale/gale.hpp>
#include <gale/key/key.hpp>
#include <gale/context/commandLine.hpp>
#include <gale/resource/Manager.hpp>
#include <gale/context/Context.hpp>
#include <gale/Dimension.hpp>
#include <etk/etk.hpp>
#include <gale/renderer/openGL/openGL.hpp>
#include <gale/renderer/openGL/openGL-include.hpp>
static etk::Vector<etk::String> localSplit(const etk::String& _input) {
etk::Vector<etk::String> out;
char lastValue = '\0';
etk::String tmpInput;
for(auto &it : _input) {
if ( lastValue == ':'
&& it == ':') {
tmpInput += "::";
lastValue = '\0';
continue;
} else if (lastValue == ':') {
out.pushBack(tmpInput);
tmpInput = "";
tmpInput += it;
} else if (it == ':') {
// nothing to do ...
} else {
tmpInput += it;
}
lastValue = it;
}
if (tmpInput!="") {
out.pushBack(tmpInput);
}
return out;
}
class SimulationInterface : public gale::Context {
private:
gale::key::Special m_guiKeyBoardMode;
bool m_run;
public:
SimulationInterface(gale::Application* _application, int32_t _argc, const char* _argv[]) :
gale::Context(_application, _argc, _argv) {
GALE_INFO("SIMU:INIT");
m_run = true;
start2ndThreadProcessing();
}
~SimulationInterface() {
// TODO : ...
}
int32_t run() {
m_simulationFile = etk::uri::get(m_simulationUri);
// Try to open the file of simulation:
if ( m_simulationFile == null
|| m_simulationFile->open(etk::io::OpenMode::Read) == false) {
GALE_ERROR("can not open the simulation file");
return -1;
}
etk::String action;
// main cycle
while(m_run == true) {
bool lineIsOk = m_simulationFile->gets(action);
if (lineIsOk == false) {
// reach end of simulation file;
return 0;
}
if (action.size() == 0) {
continue;
}
GALE_VERBOSE("SIM-EVENT : '" << action << "'");
etk::Vector<etk::String> pads = localSplit(action);
GALE_DEBUG(" " << pads);
// The first is the time ...
if (pads.size() < 2) {
GALE_ERROR("Simu: Can not parse: '" << action << "'");
continue;
}
uint64_t time = etk::string_to_uint64_t(pads[0]);
etk::String localAction = pads[1];
if (localAction == "INIT") {
// nothing to do ...
} else if (localAction == "RECALCULATE_SIZE") {
//requestUpdateSize();
} else if (localAction == "RESIZE") {
// vec2
OS_Resize(vec2(pads[2]));
} else if (localAction == "INPUT") {
// string type
// string status
// int32_t pointerID
// vec2 pos
enum gale::key::type type;
etk::from_string(type, pads[2]);
enum gale::key::status status;
etk::from_string(status, pads[3]);
int32_t pointerID = etk::string_to_int32_t(pads[4]);
vec2 pos(pads[5]);
OS_SetInput(type, status, pointerID, pos);
} else if (localAction == "KEYBOARD") {
// string special
// string type
// int32_t state
// vec2 value
gale::key::Special special;
etk::from_string(special, pads[2]);
enum gale::key::keyboard type;
etk::from_string(type, pads[3]);
enum gale::key::status status;
etk::from_string(status, pads[4]);
char32_t valChar = etk::string_to_uint64_t(pads[5]);
OS_setKeyboard(special, type, status, false, valChar);
} else if (localAction == "VIEW") {
// bool ==> hide, show ...
if (etk::string_to_bool(pads[2]) == true) {
OS_Show();
} else {
OS_Hide();
}
} else if (localAction == "CLIPBOARD_ARRIVE") {
// int32_t clipboard ID
enum gale::context::clipBoard::clipboardListe clipboardId;
etk::from_string(clipboardId, pads[2]);
OS_ClipBoardArrive(clipboardId);
} else if (localAction == "DRAW") {
// bool ==> display every time ...
OS_Draw(etk::string_to_bool(pads[2]));
} else {
GALE_ERROR("unknow event : '" << localAction << "'");
}
}
m_simulationFile->close();
return 0;
}
/****************************************************************************************/
virtual void stop() {
GALE_INFO("SIMU-API: Stop");
m_run = false;
}
/****************************************************************************************/
virtual void setSize(const vec2& _size) {
GALE_INFO("SIMU-API: changeSize=" << _size);
}
/****************************************************************************************/
void setFullScreen(bool _status) {
GALE_INFO("SIMU-API: changeFullscreen=" << _status);
}
/****************************************************************************************/
virtual void grabKeyboardEvents(bool _status) {
}
/****************************************************************************************/
virtual void setWindowsDecoration(bool _status) {
GALE_INFO("SIMU-API: setWindows Decoration :" << _status);
};
/****************************************************************************************/
virtual void setPos(const vec2& _pos) {
GALE_INFO("SIMU-API: changePos=" << _pos);
}
/****************************************************************************************/
virtual void setCursor(enum gale::context::cursor _newCursor) {
GALE_INFO("SIMU-API: setCursor=" << _newCursor);
}
/****************************************************************************************/
void grabPointerEvents(bool _status, const vec2& _forcedPosition) {
GALE_DEBUG("SIMU-API: Grab Events");
}
/****************************************************************************************/
void setIcon(const etk::String& _inputFile) {
GALE_DEBUG("SIMU set icon " << _inputFile);
}
/****************************************************************************************/
void setTitle(const etk::String& _title) {
GALE_INFO("SIMU: set Title " << _title);
}
void openURL(const etk::String& _url) {
GALE_INFO("SIMU: open URL " << _url);
}
/****************************************************************************************/
void clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
GALE_INFO("SIMU: clipBoardGet " << _clipboardID);
}
/****************************************************************************************/
void clipBoardSet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
GALE_INFO("SIMU: clipBoardSet " << _clipboardID);
}
};
#include <gale/context/simulation/Context.hpp>
bool gale::context::simulation::isBackendPresent() {
// TODO : Do it better...
return true;
}
ememory::SharedPtr<gale::Context> gale::context::simulation::createInstance(gale::Application* _application, int _argc, const char *_argv[]) {
// Disable openGL:
gale::openGL::startSimulationMode();
return ememory::makeShared<SimulationInterface>(_application, _argc, _argv);
}

View File

@ -1,26 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
namespace gale {
namespace context {
namespace simulation {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
namespace gale {
namespace context {
namespace wayland {
/**
* @brief Check if the backend can be instanciate
* @return true if the backend is availlable (false otherwise)
*/
bool isBackendPresent();
/**
* @brief Create the context main intance
* @param[in] _application pointer on the application
* @param[in] _argc number of parameter
* @param[in] _argv araay of pointer of each parameters
* @return instance on the generic created context
*/
ememory::SharedPtr<gale::Context> createInstance(gale::Application* _application, int _argc, const char *_argv[]);
}
}
}

View File

@ -1,12 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/debug.hpp>
int32_t gale::getLogId() {
static int32_t g_val = elog::registerInstance("gale");
return g_val;
}

View File

@ -1,38 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <elog/log.hpp>
namespace gale {
int32_t getLogId();
};
#define GALE_BASE(info,data) ELOG_BASE(gale::getLogId(),info,data)
#define GALE_PRINT(data) GALE_BASE(-1, data)
#define GALE_CRITICAL(data) GALE_BASE(1, data)
#define GALE_ERROR(data) GALE_BASE(2, data)
#define GALE_WARNING(data) GALE_BASE(3, data)
#ifdef DEBUG
#define GALE_INFO(data) GALE_BASE(4, data)
#define GALE_DEBUG(data) GALE_BASE(5, data)
#define GALE_VERBOSE(data) GALE_BASE(6, data)
#define GALE_TODO(data) GALE_BASE(4, "TODO : " << data)
#else
#define GALE_INFO(data) do { } while(false)
#define GALE_DEBUG(data) do { } while(false)
#define GALE_VERBOSE(data) do { } while(false)
#define GALE_TODO(data) do { } while(false)
#endif
#define GALE_ASSERT(cond,data) \
do { \
if (!(cond)) { \
GALE_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)

View File

@ -1,45 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/gale.hpp>
#include <gale/context/Context.hpp>
#include <gale/context/commandLine.hpp>
#include <etk/uri/uri.hpp>
#include <gale/Dimension.hpp>
#ifndef GALE_VERSION
#define GALE_VERSION "0.0.0"
#endif
etk::String gale::getCompilationMode() {
#ifdef MODE_RELEASE
return "Release";
#else
return "Debug";
#endif
}
etk::String gale::getBoardType() {
#ifdef __TARGET_OS__Linux
return "Linux";
#elif defined(__TARGET_OS__Android)
return "Android";
#elif defined(__TARGET_OS__Windows)
return "Windows";
#elif defined(__TARGET_OS__IOs)
return "IOs";
#elif defined(__TARGET_OS__MacOs)
return "MacOs";
#else
return "Unknown";
#endif
}
etk::String gale::getVersion() {
return GALE_VERSION;
}

View File

@ -1,41 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <gale/Application.hpp>
namespace 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[in] _application just created instance of the applicationo
* @param[in] _argc Standard argc
* @param[in] _argv Standard argv
* @return normal error int for the application error management
*/
int32_t run(gale::Application* _application, int32_t _argc = 0, const char* _argv[] = null);
/**
* @brief get GALE version
* @return The string that describe gale version
*/
etk::String getVersion();
/**
* @brief get compilation mode (release/debug)
* @return the string of the mode of commpilation
*/
etk::String getCompilationMode();
/**
* @brief get the board type (Android/Linux/MacOs/...)
* @return the string of the mode of commpilation
*/
etk::String getBoardType();
}

View File

@ -1,329 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/key/Special.hpp>
#include <etk/stdTools.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::key::Special);
#define GALE_FLAG_KEY_CAPS_LOCK 0x00000001
#define GALE_FLAG_KEY_SHIFT 0x00000030
#define GALE_FLAG_KEY_SHIFT_LEFT 0x00000010
#define GALE_FLAG_KEY_SHIFT_RIGHT 0x00000020
#define GALE_FLAG_KEY_CTRL 0x00000300
#define GALE_FLAG_KEY_CTRL_LEFT 0x00000100
#define GALE_FLAG_KEY_CTRL_RIGHT 0x00000200
#define GALE_FLAG_KEY_META 0x00003000
#define GALE_FLAG_KEY_META_LEFT 0x00001000
#define GALE_FLAG_KEY_META_RIGHT 0x00002000
#define GALE_FLAG_KEY_ALT 0x00030000
#define GALE_FLAG_KEY_ALT_LEFT 0x00010000
#define GALE_FLAG_KEY_ALT_RIGHT 0x00020000
#define GALE_FLAG_KEY_NUM_LOCK 0x00000002
#define GALE_FLAG_KEY_INSERT 0x00000003
// TODO : Update to support the Left and right of some key ...
gale::key::Special::Special() :
m_value(0) {
}
void gale::key::Special::update(enum gale::key::keyboard _move, bool _isDown) {
switch (_move) {
case keyboard::insert:
setInsert(_isDown);
break;
case keyboard::capLock:
setCapsLock(_isDown);
break;
case keyboard::shiftLeft:
setShiftLeft(_isDown);
break;
case keyboard::shiftRight:
setShiftRight(_isDown);
break;
case keyboard::ctrlLeft:
setCtrlLeft(_isDown);
break;
case keyboard::ctrlRight:
setCtrlRight(_isDown);
break;
case keyboard::metaLeft:
setMetaLeft(_isDown);
break;
case keyboard::metaRight:
setMetaRight(_isDown);
break;
case keyboard::altLeft:
setAltLeft(_isDown);
break;
case keyboard::altRight:
setAltRight(_isDown);
break;
case keyboard::numLock:
setNumLock(_isDown);
break;
default:
break;
}
}
bool gale::key::Special::get(enum gale::key::keyboard _move) {
switch (_move) {
case keyboard::insert:
return getInsert();
case keyboard::capLock:
return getCapsLock();
case keyboard::shiftLeft:
return getShiftLeft();
case keyboard::shiftRight:
return getShiftRight();
case keyboard::ctrlLeft:
return getCtrlLeft();
case keyboard::ctrlRight:
return getCtrlRight();
case keyboard::metaLeft:
return getMetaLeft();
case keyboard::metaRight:
return getMetaRight();
case keyboard::altLeft:
return getAltLeft();
case keyboard::altRight:
return getAltRight();
case keyboard::numLock:
return getNumLock();
default:
break;
}
return false;
}
void gale::key::Special::setFlag(uint32_t _flag, bool _isDown) {
if ((m_value & _flag) != 0) {
if (_isDown == false) {
m_value -= _flag;
}
} else {
if (_isDown == true) {
m_value += _flag;
}
}
}
bool gale::key::Special::getFlag(uint32_t _flag) const {
if ((m_value & _flag) != 0) {
return true;
}
return false;
};
bool gale::key::Special::getCapsLock() const {
return getFlag(GALE_FLAG_KEY_CAPS_LOCK);
}
void gale::key::Special::setCapsLock(bool _value) {
setFlag(GALE_FLAG_KEY_CAPS_LOCK, _value);
}
bool gale::key::Special::getShift() const {
return getFlag(GALE_FLAG_KEY_SHIFT);
}
bool gale::key::Special::getShiftLeft() const {
return getFlag(GALE_FLAG_KEY_SHIFT_LEFT);
}
bool gale::key::Special::getShiftRight() const {
return getFlag(GALE_FLAG_KEY_SHIFT_RIGHT);
}
void gale::key::Special::setShiftLeft(bool _value) {
setFlag(GALE_FLAG_KEY_SHIFT_LEFT, _value);
}
void gale::key::Special::setShiftRight(bool _value) {
setFlag(GALE_FLAG_KEY_SHIFT_RIGHT, _value);
}
bool gale::key::Special::getCtrl() const {
return getFlag(GALE_FLAG_KEY_CTRL);
}
bool gale::key::Special::getCtrlLeft() const {
return getFlag(GALE_FLAG_KEY_CTRL_LEFT);
}
bool gale::key::Special::getCtrlRight() const {
return getFlag(GALE_FLAG_KEY_CTRL_RIGHT);
}
void gale::key::Special::setCtrlLeft(bool _value) {
setFlag(GALE_FLAG_KEY_CTRL_LEFT, _value);
}
void gale::key::Special::setCtrlRight(bool _value) {
setFlag(GALE_FLAG_KEY_CTRL_RIGHT, _value);
}
bool gale::key::Special::getMeta() const {
return getFlag(GALE_FLAG_KEY_META);
}
bool gale::key::Special::getMetaLeft() const {
return getFlag(GALE_FLAG_KEY_META_LEFT);
}
bool gale::key::Special::getMetaRight() const {
return getFlag(GALE_FLAG_KEY_META_RIGHT);
}
void gale::key::Special::setMetaLeft(bool _value) {
setFlag(GALE_FLAG_KEY_META_LEFT, _value);
}
void gale::key::Special::setMetaRight(bool _value) {
setFlag(GALE_FLAG_KEY_META_RIGHT, _value);
}
bool gale::key::Special::getAlt() const {
return getFlag(GALE_FLAG_KEY_ALT);
}
bool gale::key::Special::getAltLeft() const {
return getFlag(GALE_FLAG_KEY_ALT_LEFT);
}
bool gale::key::Special::getAltRight() const {
return getFlag(GALE_FLAG_KEY_ALT_RIGHT);
}
void gale::key::Special::setAltLeft(bool _value) {
setFlag(GALE_FLAG_KEY_ALT_LEFT, _value);
}
void gale::key::Special::setAltRight(bool _value) {
setFlag(GALE_FLAG_KEY_ALT_RIGHT, _value);
}
bool gale::key::Special::getNumLock() const {
return getFlag(GALE_FLAG_KEY_NUM_LOCK);
}
void gale::key::Special::setNumLock(bool _value) {
setFlag(GALE_FLAG_KEY_NUM_LOCK, _value);
}
bool gale::key::Special::getInsert() const {
return getFlag(GALE_FLAG_KEY_INSERT);
}
void gale::key::Special::setInsert(bool _value) {
setFlag(GALE_FLAG_KEY_INSERT, _value);
}
etk::Stream& gale::key::operator <<(etk::Stream& _os, const gale::key::Special& _obj) {
_os << " capLock=" << _obj.getCapsLock();
_os << " shift=" << _obj.getShift();
_os << " ctrl=" << _obj.getCtrl();
_os << " meta=" << _obj.getMeta();
_os << " alt=" << _obj.getAlt();
_os << " verNum=" << _obj.getNumLock();
_os << " insert=" << _obj.getInsert();
return _os;
}
namespace etk {
template<> etk::String toString<gale::key::Special>(const gale::key::Special& _obj) {
etk::String out;
if (_obj.getCapsLock() == true) {
out += "CAPS";
}
if (_obj.getShift() == true) {
if (out.size() > 0) {
out += "|";
}
out += "SHIFT";
if (_obj.getShiftLeft() == false) {
out += "-RIGHT";
} else if (_obj.getShiftRight() == false) {
out += "-LEFT";
}
}
if (_obj.getCtrl() == true) {
if (out.size() > 0) {
out += "|";
}
out += "CTRL";
if (_obj.getCtrlLeft() == false) {
out += "-RIGHT";
} else if (_obj.getCtrlRight() == false) {
out += "-LEFT";
}
}
if (_obj.getMeta() == true) {
if (out.size() > 0) {
out += "|";
}
out += "META";
if (_obj.getMetaLeft() == false) {
out += "-RIGHT";
} else if (_obj.getMetaRight() == false) {
out += "-LEFT";
}
}
if (_obj.getAlt() == true) {
if (out.size() > 0) {
out += "|";
}
out += "ALT";
if (_obj.getAltLeft() == false) {
out += "-RIGHT";
} else if (_obj.getAltRight() == false) {
out += "-LEFT";
}
}
if (_obj.getNumLock() == true) {
if (out.size() > 0) {
out += "|";
}
out += "NUM_LOCK";
}
if (_obj.getInsert() == true) {
if (out.size() > 0) {
out += "|";
}
out += "INSERT";
}
return out;
}
template <> bool from_string<gale::key::Special>(gale::key::Special& _variableRet, const etk::String& _value) {
gale::key::Special out;
etk::Vector<etk::String> listElem = _value.split('|');
for (auto &it : listElem) {
if (it == "CAPS") {
out.setCapsLock(true);
} else if (it == "SHIFT") {
out.setShiftLeft(true);
out.setShiftRight(true);
} else if (it == "SHIFT-LEFT") {
out.setShiftLeft(true);
} else if (it == "SHIFT-RIGHT") {
out.setShiftRight(true);
} else if (it == "CTRL") {
out.setCtrlLeft(true);
out.setCtrlRight(true);
} else if (it == "CTRL-LEFT") {
out.setCtrlLeft(true);
} else if (it == "CTRL-RIGHT") {
out.setCtrlRight(true);
} else if (it == "META") {
out.setMetaLeft(true);
out.setMetaRight(true);
} else if (it == "META-LEFT") {
out.setMetaLeft(true);
} else if (it == "META-RIGHT") {
out.setMetaRight(true);
} else if (it == "ALT") {
out.setAltLeft(true);
out.setAltRight(true);
} else if (it == "ALT-LEFT") {
out.setAltLeft(true);
} else if (it == "ALT-RIGHT") {
out.setAltRight(true);
} else if (it == "NUM_LOCK") {
out.setNumLock(true);
} else if (it == "INSERT") {
out.setInsert(true);
} else {
GALE_ERROR("unknow element '" << it << "'");
return false;
}
}
_variableRet = out;
return true;
}
}

View File

@ -1,199 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/debug.hpp>
#include <gale/key/keyboard.hpp>
namespace gale {
namespace key {
/**
* @brief This class consider generic special keyborad key (insert, control, shift ...)
*/
class Special {
private:
uint32_t m_value;
public:
/**
* @brief Main constructor
*/
Special();
/**
* @brief get the current CapLock Status
* @return The CapLock value
*/
bool getCapsLock() const;
/**
* @brief set the current CapLock Status
* @param[in] _value The new CapLock value
*/
void setCapsLock(bool _value);
/**
* @brief Get the current Shift key status
* @return The Shift value
*/
bool getShift() const;
/**
* @brief Get the current Shift left key status
* @return The Shift value
*/
bool getShiftLeft() const;
/**
* @brief Get the current Shift right key status
* @return The Shift value
*/
bool getShiftRight() const;
/**
* @brief Set the current Shift left key status
* @param[in] _value The new Shift value
*/
void setShiftLeft(bool _value);
/**
* @brief Set the current Shift right key status
* @param[in] _value The new Shift value
*/
void setShiftRight(bool _value);
/**
* @brief Get the Current Control key status
* @return The Control value
*/
bool getCtrl() const;
/**
* @brief Get the Current Control left key status
* @return The Control value
*/
bool getCtrlLeft() const;
/**
* @brief Get the Current Control right key status
* @return The Control value
*/
bool getCtrlRight() const;
/**
* @brief Set the Current Control left key status
* @param[in] _value The new Control value
*/
void setCtrlLeft(bool _value);
/**
* @brief Set the Current Control right key status
* @param[in] _value The new Control value
*/
void setCtrlRight(bool _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 ...)
*/
bool getMeta() const;
/**
* @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 ...)
*/
bool getMetaLeft() const;
/**
* @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 ...)
*/
bool getMetaRight() const;
/**
* @brief Set the current Meta left key status (also named windows or apple key)
* @param[in] _value The new Meta value (name Windows key, apple key, command key ...)
*/
void setMetaLeft(bool _value);
/**
* @brief Set the current Meta right key status (also named windows or apple key)
* @param[in] _value The new Meta value (name Windows key, apple key, command key ...)
*/
void setMetaRight(bool _value);
/**
* @brief Get the current Alt key status
* @return The Alt value
*/
bool getAlt() const;
/**
* @brief Get the current Alt left key status
* @return The Alt value
*/
bool getAltLeft() const;
/**
* @brief Get the current Alt right key status (alt-gr)
* @return The Alt value
*/
bool getAltRight() const;
/**
* @brief Set the current Alt left key status
* @param[in] _value The new Alt value
*/
void setAltLeft(bool _value);
/**
* @brief Set the current Alt right key status (alt-gr)
* @param[in] _value The new Alt value
*/
void setAltRight(bool _value);
/**
* @brief Get the current Alt-Gr key status
* @return The Alt-gr value (does not exist on MacOs)
*/
bool getAltGr() const {
return getAltRight();
}
/**
* @brief Set the current Alt-Gr key status
* @param[in] _value The new Alt-gr value (does not exist on MacOs)
*/
void setAltGr(bool _value) {
setAltRight(_value);
}
/**
* @brief Get the current Ver-num key status
* @return The Numerical Lock value
*/
bool getNumLock() const;
/**
* @brief Set the current Ver-num key status
* @param[in] _value The new Numerical Lock value
*/
void setNumLock(bool _value);
/**
* @brief Get the current Intert key status
* @return The Insert value
*/
bool getInsert() const;
/**
* @brief Set the current Intert key status
* @param[in] _value The new Insert value
*/
void setInsert(bool _value);
/**
* @brief Update the internal value with the input moving key.
* @param[in] _move Moving key.
* @param[in] _isDown The key is pressed or not.
*/
void update(enum gale::key::keyboard _move, bool _isDown);
/**
* @brief Get the value with the input moving key.
* @param[in] _move Moving key.
* @return true The key is pressed.
* @return false The key is released.
*/
bool get(enum gale::key::keyboard _move);
protected:
/**
* @brief Set the internal value with the input moving FLAG.
* @param[in] _flag Moving Flag.
* @param[in] _isDown The key is pressed or not.
*/
void setFlag(uint32_t _flag, bool _isDown);
/**
* @brief Get the value with the input moving FLAG.
* @param[in] _flag Moving internal FLAG.
* @return true The key is pressed.
* @return false The key is released.
*/
bool getFlag(uint32_t _flag) const;
};
etk::Stream& operator <<(etk::Stream& _os, const gale::key::Special& _obj);
}
}

View File

@ -1,11 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/key/keyboard.hpp>
#include <gale/key/Special.hpp>
#include <gale/key/status.hpp>
#include <gale/key/type.hpp>

View File

@ -1,80 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/key/keyboard.hpp>
#include <etk/stdTools.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(enum gale::key::keyboard);
static const char* keyboardDescriptionString[] = {
"keyboard::unknow",
"keyboard::character",
"keyboard::left",
"keyboard::right",
"keyboard::up",
"keyboard::down",
"keyboard::pageUp",
"keyboard::pageDown",
"keyboard::start",
"keyboard::end",
"keyboard::print",
"keyboard::stopDefil",
"keyboard::wait",
"keyboard::insert",
"keyboard::f1",
"keyboard::f2",
"keyboard::f3",
"keyboard::f4",
"keyboard::f5",
"keyboard::f6",
"keyboard::f7",
"keyboard::f8",
"keyboard::f9",
"keyboard::f10",
"keyboard::f11",
"keyboard::f12",
"keyboard::capLock",
"keyboard::shiftLeft",
"keyboard::shiftRight",
"keyboard::ctrlLeft",
"keyboard::ctrlRight",
"keyboard::metaLeft",
"keyboard::metaRight",
"keyboard::altLeft",
"keyboard::altRight",
"keyboard::contextMenu",
"keyboard::numLock",
// harware section:
"keyboard::volumeUp",
"keyboard::volumeDown",
"keyboard::menu",
"keyboard::camera",
"keyboard::home",
"keyboard::power",
"keyboard::back",
};
etk::Stream& gale::key::operator <<(etk::Stream& _os, const enum gale::key::keyboard _obj) {
_os << keyboardDescriptionString[int32_t(_obj)];
return _os;
}
namespace etk {
template<> etk::String toString<enum gale::key::keyboard>(const enum gale::key::keyboard& _obj) {
return keyboardDescriptionString[int32_t(_obj)];
}
template <> bool from_string<enum gale::key::keyboard>(enum gale::key::keyboard& _variableRet, const etk::String& _value) {
for (size_t iii=0; iii< sizeof(keyboardDescriptionString); ++iii) {
if (keyboardDescriptionString[iii] == _value) {
_variableRet = (enum gale::key::keyboard)iii;
return true;
}
}
return false;
}
}

View File

@ -1,71 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/debug.hpp>
namespace gale {
namespace key {
/**
* @brief Keybord event or joystick event
* @warning If you modify Id of these element check the java interface file of constant : GaleConstant.java
*/
enum class keyboard {
unknow = 0, //!< 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.
alt = altLeft, //!< Alt key. Same as altLeft.
altRight, //!< Alt right key.
altGr = altRight, //!< Alt ground key. Same as AltRight
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
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
etk::Stream& operator <<(etk::Stream& _os, const enum gale::key::keyboard _obj);
}
}

View File

@ -1,50 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/key/status.hpp>
#include <etk/stdTools.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(enum gale::key::status);
static const char* statusDescriptionString[] = {
"status::unknow",
"status::down",
"status::downRepeate",
"status::move",
"status::pressSingle",
"status::pressDouble",
"status::pressTriple",
"status::pressQuad",
"status::pressQuinte",
"status::up",
"status::upRepeate",
"status::upAfter",
"status::enter",
"status::leave",
"status::abort",
"status::transfert"
};
etk::Stream& gale::key::operator <<(etk::Stream& _os, const enum gale::key::status _obj) {
_os << statusDescriptionString[int32_t(_obj)];
return _os;
}
namespace etk {
template<> etk::String toString<enum gale::key::status>(const enum gale::key::status& _obj) {
return statusDescriptionString[int32_t(_obj)];
}
template <> bool from_string<enum gale::key::status>(enum gale::key::status& _variableRet, const etk::String& _value) {
for (size_t iii=0; iii< sizeof(statusDescriptionString); ++iii) {
if (statusDescriptionString[iii] == _value) {
_variableRet = (enum gale::key::status)iii;
return true;
}
}
return false;
}
}

View File

@ -1,39 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/debug.hpp>
namespace gale {
namespace key {
/**
* @brief Keybord event or joyestick event
*/
enum class status {
unknow = 0,
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)
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
etk::Stream& operator <<(etk::Stream& _os, const enum gale::key::status _obj);
}
}

View File

@ -1,38 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <gale/key/type.hpp>
#include <etk/stdTools.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(enum gale::key::type);
static const char* typeDescriptionString[] = {
"type::unknow",
"type::mouse",
"type::finger",
"type::stylet"
};
etk::Stream& gale::key::operator <<(etk::Stream& _os, const enum gale::key::type _obj) {
_os << typeDescriptionString[int32_t(_obj)];
return _os;
}
namespace etk {
template<> etk::String toString<enum gale::key::type>(const enum gale::key::type& _obj) {
return typeDescriptionString[int32_t(_obj)];
}
template <> bool from_string<enum gale::key::type>(enum gale::key::type& _variableRet, const etk::String& _value) {
for (size_t iii=0; iii< sizeof(typeDescriptionString); ++iii) {
if (typeDescriptionString[iii] == _value) {
_variableRet = (enum gale::key::type)iii;
return true;
}
}
return false;
}
}

View File

@ -1,27 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/debug.hpp>
namespace gale {
namespace key {
/**
* @brief type of input : Note that the keyboard is not prevent due to the fact that data is too different
*/
enum class type {
unknow = 0, //!< Unknow input Type
mouse, //!< Mouse type
finger, //!< Finger type
stylet, //!< Stylet type
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
etk::Stream& operator <<(etk::Stream& _os, enum gale::key::type _obj);
}
}

View File

@ -1,24 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp>
#include <gale/orientation.hpp>
#include <etk/String.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(enum gale::orientation);
static const char* listValues[] = {
"orientation::screenAuto",
"orientation::screenLandscape",
"orientation::screenPortrait"
};
etk::Stream& gale::operator <<(etk::Stream& _os, const enum gale::orientation _obj) {
_os << listValues[int32_t(_obj)];
return _os;
}

View File

@ -1,18 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <etk/Stream.hpp>
namespace gale {
enum class orientation {
screenAuto = 0,
screenLandscape,
screenPortrait
};
etk::Stream& operator <<(etk::Stream& _os, enum gale::orientation _obj);
}

View File

@ -1,41 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
extern "C" {
#if defined(__TARGET_OS__Linux)
// TO ENABLE THE SHADER api ...
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
// TODO : Check it it work
// This is to prevent the use of these element that is not allowed in the openGL ES
#undef glVertexPointer
#undef glTexCoordPointer
#undef glColorPointer
#undef glPopMatrix
#undef glPushMatrix
#undef glMatrixMode
#undef glLoadIdentity
#undef glTranslatef
#elif defined(__TARGET_OS__Android)
// Include openGL ES 2
#include <GLES3/gl3.h>
#include <GLES2/gl2ext.h>
#elif defined(__TARGET_OS__Windows)
// TO ENABLE THE SHADER api ...
//#define GL_GLEXT_PROTOTYPES
#define GLEW_STATIC
#include <GL/glew.h>
#elif defined(__TARGET_OS__MacOs)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#elif defined(__TARGET_OS__IOs)
#include <OpenGLES/ES2/gl.h>
#else
#error you need to specify a __TAGET_OS__ ...
#endif
}

File diff suppressed because it is too large Load Diff

View File

@ -1,239 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <etk/Vector.hpp>
#include <etk/math/Matrix4x4.hpp>
#include <etk/math/Vector2D.hpp>
#include <etk/Color.hpp>
namespace gale {
namespace openGL {
#ifdef GALE_BUILD_SIMULATION
/**
* @brief Start the simulation mode of Open GL (can be usebull when no HW is availlable for testing System like buildfarm (eg: travis-ci)
* This generate a non access on the openGL IO, and all function work corectly.
*/
void startSimulationMode();
#endif
/**
* @brief Get the current thread context status.
* @return true The thread can acces to openGL.
* @return false The Thread Can not acces to OpenGL.
*/
bool hasContext();
/**
* @brief must be called by the thread that has openGl context to notify the system
* @note Call @ref gale::openGL::threadHasNoMoreContext when ended
*/
void threadHasContext();
/**
* @brief At the end of the thread exection, set the thead has no more openGL cotext
*/
void threadHasNoMoreContext();
/**
* @brief Lock the openGL context for one user only == > better to keep flags and other things ...
*/
void lock();
/**
* @brief Un-lock the openGL context for an other user...
*/
void 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[in] _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
*/
void setBasicMatrix(const mat4& _newOne);
/**
* @brief this funtion configure the current use matrix for the renderer (call @ref Push before, and @ref Pop when no more needed).
* @param[in] _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
*/
void setMatrix(const mat4& _newOne);
/**
* @brief store current matrix in the matrix stack.
*/
void push();
/**
* @brief remove the current matrix and get the last one from the matrix stack.
*/
void pop();
/**
* @brief get a reference on the current matrix destinate to opengl renderer.
* @return The requested matrix.
*/
const mat4& getMatrix();
/**
* @brief get a reference on the current matrix camera destinate to opengl renderer.
* @return The requested matrix.
*/
const mat4& getCameraMatrix();
/**
* @brief set a reference on the current camera to opengl renderer.
* @param[in] _newOne The requested matrix.
*/
void setCameraMatrix(const mat4& _newOne);
/**
* @brief
*/
void finish();
/**
* @brief
*/
void flush();
/**
* @brief
*/
void swap();
void setViewPort(const ivec2& _start, const ivec2& _stop);
void setViewPort(const vec2& _start, const vec2& _stop);
/**
* @brief Specifies the clear color value When clear is requested
* @param[in] _value to set [0..1]
*/
void clearColor(const etk::Color<float>& _color);
/**
* @brief Specifies the depth value used when the depth buffer is cleared. The initial value is 1.
* @param[in] _value to set [0..1]
*/
void clearDepth(float _value);
/**
* @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[in] _value
*/
void clearStencil(int32_t _value);
enum clearFlag {
clearFlag_colorBuffer = 1<<0, //!< Indicates the buffers currently enabled for color writing.
clearFlag_depthBuffer = 1<<1, //!< Indicates the depth buffer.
clearFlag_stencilBuffer = 1<<2 //!< Indicates the stencil buffer.
};
/**
* @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[in] _flags This is the bitwise OR of several values indicating which buffer is to be cleared.
*/
void clear(uint32_t _flags);
enum flag {
flag_blend = 1<<0, //!< If enabled, blend the computed fragment color values with the values in the color buffers. See glBlendFunc.
flag_clipDistanceI = 1<<1, //!< If enabled, clip geometry against user-defined half space i.
flag_colorLogigOP = 1<<2, //!< If enabled, apply the currently selected logical operation to the computed fragment color and color buffer values. See glLogicOp.
flag_cullFace = 1<<3, //!< If enabled, cull polygons based on their winding in window coordinates. See glCullFace.
flag_debugOutput = 1<<4, //!< 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 GL_DEBUG_OUTPUT is enabled.
flag_debugOutputSynchronous = 1<<5, //!< 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 = 1<<6, //!< If enabled, the -wc≤zc≤wc plane equation is ignored by view volume clipping (effectively, there is no near or far plane clipping). See glDepthRange.
flag_depthTest = 1<<7, //!< 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 = 1<<8, //!< If enabled, dither color components or indices before they are written to the color buffer.
flag_framebufferSRGB = 1<<9, //!< If enabled and the value of GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer attachment corresponding to the destination buffer is GL_SRGB, 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 = 1<<10, //!< If enabled, draw lines with correct filtering. Otherwise, draw aliased lines. See glLineWidth.
flag_multisample = 1<<11, //!< If enabled, use multiple fragment samples in computing the final color of a pixel. See glSampleCoverage.
flag_polygonOffsetFill = 1<<12, //!< If enabled, and if the polygon is rendered in GL_FILL mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See glPolygonOffset.
flag_polygonOffsetLine = 1<<13, //!< If enabled, and if the polygon is rendered in GL_LINE mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See glPolygonOffset.
flag_polygonOffsetPoint = 1<<14, //!< 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 GL_POINT mode. See glPolygonOffset.
flag_polygonSmooth = 1<<15, //!< 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 = 1<<16, //!< 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 = 1<<17, //!< 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 GL_UNSIGNED_BYTE, 16 for GL_UNSIGNED_SHORT and 32 for GL_UNSIGNED_INT.
flag_sampleAlphaToCoverage = 1<<18, //!< 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 = 1<<19, //!< If enabled, each sample alpha value is replaced by the maximum representable alpha value.
flag_sampleCoverage = 1<<20, //!< If enabled, the fragment's coverage is ANDed with the temporary coverage value. If GL_SAMPLE_COVERAGE_INVERT is set to GL_TRUE, invert the coverage value. See glSampleCoverage.
flag_sampleShading = 1<<21, //!< 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 GL_MIN_SAMPLE_SHADING_VALUE. See glMinSampleShading.
flag_sampleMask = 1<<22, //!< If enabled, the sample coverage mask generated for a fragment during rasterization will be ANDed with the value of GL_SAMPLE_MASK_VALUE before shading occurs. See glSampleMaski.
flag_scissorTest = 1<<23, //!< If enabled, discard fragments that are outside the scissor rectangle. See glScissor.
flag_stencilTest = 1<<24, //!< If enabled, do stencil testing and update the stencil buffer. See glStencilFunc and glStencilOp. GL_TEXTURE_CUBE_MAP_SEAMLESS = 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 construct the final sample value.
flag_programPointSize = 1<<25, //!< If enabled and a vertex or geometry shader is active, then the derived point size is taken from the (potentially clipped) shader builtin gl_PointSize and clamped to the implementation-dependent point size range.
flag_texture2D = 1<<26, //!<
flag_alphaTest = 1<<27, //!<
flag_fog = 1<<28, //!<
};
enum class 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
};
/**
* @brief enable a flag on the system
* @param[in] flagID The flag requested
*/
void enable(enum flag _flagID);
/**
* @brief disable a flag on the system
* @param[in] flagID The flag requested
*/
void disable(enum flag _flagID);
/**
* @brieg update all the internal flag needed to be set from tre previous element set ...
*/
void updateAllFlags();
/**
* @brief enable Texture on the system
* @param[in] flagID The flag requested
*/
void activeTexture(uint32_t _flagID);
/**
* @brief disable Texture on the system
* @param[in] flagID The flag requested
*/
// TODO : rename Disable
void desActiveTexture(uint32_t _flagID);
/**
* @brief draw a specific array == > this enable mode difference ...
*/
void drawArrays(enum renderMode _mode, int32_t _first, int32_t _count);
void drawElements (enum renderMode _mode, const etk::Vector<uint32_t>& _indices);
void drawElements16(enum renderMode _mode, const etk::Vector<uint16_t>& _indices);
void drawElements8 (enum renderMode _mode, const etk::Vector<uint8_t>& _indices);
/**
* @brief Use openGL program
* @param[in] id Id of the program that might be used
*/
void useProgram(int32_t _id);
void reset();
bool genBuffers(etk::Vector<uint32_t>& _buffers);
bool deleteBuffers(etk::Vector<uint32_t>& _buffers);
bool bindBuffer(uint32_t _bufferId);
enum class usage {
streamDraw,
staticDraw,
dynamicDraw
};
bool bufferData(size_t _size, const void* _data, enum gale::openGL::usage _usage);
bool unbindBuffer();
/* Shader wrapping : */
namespace shader {
enum class type {
vertex,
fragment
};
int64_t create(enum gale::openGL::shader::type _type);
void remove(int64_t& _shader);
bool compile(int64_t _shader, const etk::String& _data);
};
namespace program {
int64_t create();
void remove(int64_t& _prog);
bool attach(int64_t _prog, int64_t _shader);
bool compile(int64_t _prog);
int32_t getAttributeLocation(int64_t _prog, const etk::String& _name);
int32_t getUniformLocation(int64_t _prog, const etk::String& _name);
};
etk::Stream& operator <<(etk::Stream& _os, enum openGL::flag _obj);
etk::Stream& operator <<(etk::Stream& _os, enum openGL::renderMode _obj);
}
}

View File

@ -1,231 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp>
#include <gale/debug.hpp>
#include <gale/resource/Manager.hpp>
#include <gale/gale.hpp>
#include <gale/renderer/openGL/openGL.hpp>
#include <gale/context/Context.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::resource::Manager);
gale::resource::Manager::Manager() :
m_contextHasBeenRemoved(true),
m_exiting(false) {
// nothing to do ...
}
gale::resource::Manager::~Manager() {
ethread::RecursiveLock lock(m_mutex);
bool hasError = false;
if (m_resourceListToUpdate.size()!=0) {
GALE_ERROR("Must not have anymore resources to update !!!");
hasError = true;
}
// TODO : Remove unneeded elements
if (m_resourceList.size()!=0) {
GALE_ERROR("Must not have anymore resources !!!");
hasError = true;
}
if (true == hasError) {
GALE_ERROR("Check if the function UnInit has been called !!!");
}
}
void gale::resource::Manager::unInit() {
ethread::RecursiveLock lock(m_mutex);
display();
m_resourceListToUpdate.clear();
// remove all resources ...
auto it(m_resourceList.begin());
while(it != m_resourceList.end()) {
ememory::SharedPtr<gale::Resource> tmpRessource = (*it).lock();
if (tmpRessource != null) {
GALE_WARNING("Find a resource that is not removed : [" << tmpRessource->getId() << "]"
<< "=\"" << tmpRessource->getName() << "\" "
<< tmpRessource.useCount() << " elements");
}
m_resourceList.erase(it);
it = m_resourceList.begin();
}
m_resourceList.clear();
}
void gale::resource::Manager::display() {
GALE_INFO("Resources loaded : ");
// remove all resources ...
ethread::RecursiveLock lock(m_mutex);
for (auto &it : m_resourceList) {
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
if (tmpRessource != null) {
GALE_INFO(" [" << tmpRessource->getId() << "]"
<< tmpRessource->getType()
<< "=\"" << tmpRessource->getName() << "\" "
<< tmpRessource.useCount() << " elements");
}
}
GALE_INFO("Resources ---");
}
void gale::resource::Manager::reLoadResources() {
GALE_INFO("------------- Resources re-loaded -------------");
// remove all resources ...
ethread::RecursiveLock lock(m_mutex);
if (m_resourceList.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
GALE_INFO(" Reload level : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
for (auto &it : m_resourceList) {
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
if(tmpRessource != null) {
if (jjj == tmpRessource->getResourceLevel()) {
tmpRessource->reload();
GALE_INFO(" [" << tmpRessource->getId() << "]="<< tmpRessource->getType());
}
}
}
}
}
// TODO : UNderstand why it is set here ...
//gale::requestUpdateSize();
GALE_INFO("------------- Resources -------------");
}
void gale::resource::Manager::update(const ememory::SharedPtr<gale::Resource>& _object) {
// chek if not added before
ethread::RecursiveLock lock(m_mutex);
for (auto &it : m_resourceListToUpdate) {
if ( it != null
&& it == _object) {
// just prevent some double add ...
return;
}
}
// add it ...
m_resourceListToUpdate.pushBack(_object);
}
// Specific to load or update the data in the openGl context == > system use only
void gale::resource::Manager::updateContext() {
if (m_exiting == true) {
GALE_ERROR("Request update after application EXIT ...");
return;
}
// TODO : Check the number of call this ... GALE_INFO("update open-gl context ... ");
if (m_contextHasBeenRemoved == true) {
// need to update all ...
m_contextHasBeenRemoved = false;
etk::Vector<ememory::WeakPtr<gale::Resource>> resourceList;
{
ethread::RecursiveLock lock(m_mutex);
// Clean the update list
m_resourceListToUpdate.clear();
resourceList = m_resourceList;
}
if (resourceList.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
GALE_VERBOSE(" updateContext level (D) : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
for (auto &it : resourceList) {
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
if( tmpRessource != null
&& jjj == tmpRessource->getResourceLevel()) {
//GALE_DEBUG("Update context named : " << l_resourceList[iii]->getName());
if (tmpRessource->updateContext() == false) {
// Lock error ==> postponned
ethread::RecursiveLock lock(m_mutex);
m_resourceListToUpdate.pushBack(tmpRessource);
}
}
}
}
}
} else {
etk::Vector<ememory::SharedPtr<gale::Resource>> resourceListToUpdate;
{
ethread::RecursiveLock lock(m_mutex);
resourceListToUpdate = m_resourceListToUpdate;
// Clean the update list
m_resourceListToUpdate.clear();
}
if (resourceListToUpdate.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
GALE_VERBOSE(" updateContext level (U) : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
for (auto &it : resourceListToUpdate) {
if ( it != null
&& jjj == it->getResourceLevel()) {
if (it->updateContext() == false) {
ethread::RecursiveLock lock(m_mutex);
// Lock error ==> postponned
m_resourceListToUpdate.pushBack(it);
}
}
}
}
}
}
}
// in this case, it is really too late ...
void gale::resource::Manager::contextHasBeenDestroyed() {
ethread::RecursiveLock lock(m_mutex);
for (auto &it : m_resourceList) {
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
if (tmpRessource != null) {
tmpRessource->removeContextToLate();
}
}
// no context preent ...
m_contextHasBeenRemoved = true;
}
void gale::resource::Manager::applicationExiting() {
contextHasBeenDestroyed();
m_exiting = true;
}
// internal generic keeper ...
ememory::SharedPtr<gale::Resource> gale::resource::Manager::localKeep(const etk::String& _filename) {
ethread::RecursiveLock lock(m_mutex);
GALE_VERBOSE("KEEP (DEFAULT) : file : '" << _filename << "' in " << m_resourceList.size() << " resources");
for (auto &it : m_resourceList) {
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
if (tmpRessource != null) {
if (tmpRessource->getName() == _filename) {
return tmpRessource;
}
}
}
return null;
}
// internal generic keeper ...
void gale::resource::Manager::localAdd(const ememory::SharedPtr<gale::Resource>& _object) {
ethread::RecursiveLock lock(m_mutex);
//Add ... find empty slot
for (auto &it : m_resourceList) {
ememory::SharedPtr<gale::Resource> tmpRessource = it.lock();
if (tmpRessource == null) {
it = _object;
return;
}
}
// add at the end if no slot is free
m_resourceList.pushBack(_object);
}
// in case of error ...
void gale::resource::Manager::cleanInternalRemoved() {
ethread::RecursiveLock lock(m_mutex);
//GALE_INFO("remove object in Manager");
updateContext();
for (auto it(m_resourceList.begin()); it!=m_resourceList.end(); ++it) {
if ((*it).expired() == true) {
m_resourceList.erase(it);
it = m_resourceList.begin();
}
}
}

View File

@ -1,71 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/Vector.hpp>
#include <etk/types.hpp>
#include <ethread/MutexRecursive.hpp>
#include <gale/debug.hpp>
#include <gale/resource/Resource.hpp>
namespace gale {
namespace resource {
class Manager{
private:
etk::Vector<ememory::WeakPtr<gale::Resource>> m_resourceList;
etk::Vector<ememory::SharedPtr<gale::Resource>> m_resourceListToUpdate;
bool m_contextHasBeenRemoved;
bool m_exiting;
ethread::MutexRecursive m_mutex;
public:
/**
* @brief initialize the internal variable
*/
Manager();
/**
* @brief Uninitiamize the resource manager, free all resources previously requested
* @note when not free == > generate warning, because the segfault can appear after...
*/
virtual ~Manager();
/**
* @brief remove all resources (un-init) out of the destructor (due to the system implementation)
*/
void unInit();
/**
* @brief display in the log all the resources loaded ...
*/
void display();
/**
* @brief Reload all resources from files, and send there in openGL card if needed.
* @note If file is reference at THEME_XXX:///filename if the Theme change the file will reload the newOne
*/
void reLoadResources();
/**
* @brief Call by the system to send all the needed data on the graphic card chen they change ...
* @param[in] _object The resources that might be updated
*/
void update(const ememory::SharedPtr<gale::Resource>& _object);
/**
* @brief Call by the system chen the openGL Context has been unexpectially removed == > This reload all the texture, VBO and other ....
*/
void updateContext();
/**
* @brief This is to inform the resources manager that we have no more openGl context ...
*/
void contextHasBeenDestroyed();
/**
* @brief special end of application
*/
void applicationExiting();
public:
// internal API to extent eResources in extern Soft
ememory::SharedPtr<gale::Resource> localKeep(const etk::String& _filename);
void localAdd(const ememory::SharedPtr<gale::Resource>& _object);
virtual void cleanInternalRemoved();
};
}
}

View File

@ -1,900 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp>
#include <gale/debug.hpp>
#include <gale/resource/Program.hpp>
#include <gale/resource/Manager.hpp>
#include <etk/uri/uri.hpp>
#include <gale/gale.hpp>
#include <gale/renderer/openGL/openGL-include.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(gale::resource::Program);
//#define LOCAL_DEBUG GALE_VERBOSE
#define LOCAL_DEBUG GALE_DEBUG
gale::resource::Program::Program() :
gale::Resource(),
m_exist(false),
m_program(0),
m_hasTexture(false),
m_hasTexture1(false) {
addResourceType("gale::resource::Program");
m_resourceLevel = 1;
}
void gale::resource::Program::init(const etk::Uri& _uri) {
gale::Resource::init(_uri.get());
ethread::RecursiveLock lock(m_mutex);
GALE_DEBUG("OGL : load PROGRAM '" << _uri << "'");
// load data from file "all the time ..."
if (etk::uri::exist(_uri) == false) {
GALE_DEBUG("File does not Exist : \"" << _uri << "\" == > automatic load of framment and shader with same names... ");
etk::Uri tmpUri = _uri;
tmpUri.setPath(_uri.getPath().getExtentionRemoved() + ".vert");
ememory::SharedPtr<gale::resource::Shader> tmpShader = gale::resource::Shader::create(tmpUri.get());
if (tmpShader == null) {
GALE_ERROR("Error while getting a specific shader filename : " << tmpUri);
return;
} else {
GALE_DEBUG("Add shader on program : "<< tmpUri << "vert");
m_shaderList.pushBack(tmpShader);
}
tmpUri.setPath(_uri.getPath().getExtentionRemoved() + ".frag");
tmpShader = gale::resource::Shader::create(tmpUri.get());
if (tmpShader == null) {
GALE_ERROR("Error while getting a specific shader filename : " << tmpUri);
return;
} else {
GALE_DEBUG("Add shader on program : "<< tmpUri << "frag");
m_shaderList.pushBack(tmpShader);
}
} else {
if (_uri.getPath().getExtention() != "prog") {
GALE_ERROR("File does not have extention \".prog\" for program but : \"" << _uri.getPath() << "\"");
return;
}
auto fileIO = etk::uri::get(_uri);
if ( fileIO == null
|| fileIO->open(etk::io::OpenMode::Read) == false) {
GALE_ERROR("Can not open the file : \"" << _uri << "\"");
return;
}
etk::String tmpData;
GALE_DEBUG("===========================================================");
while (fileIO->gets(tmpData) != false) {
GALE_DEBUG("data: " << tmpData);
int32_t len = tmpData.size();
if( tmpData[len-1] == '\n'
|| tmpData[len-1] == '\r') {
tmpData[len-1] = '\0';
len--;
}
GALE_DEBUG(" Read data : \"" << tmpData << "\"");
if (len == 0) {
continue;
}
if (tmpData[0] == '#') {
continue;
}
// get it with relative position:
etk::Uri tmpUri = _uri;
tmpUri.setPath(_uri.getPath().getParent() / tmpData);
GALE_VERBOSE("base path: " << _uri);
GALE_VERBOSE("base path: " << _uri.getPath());
GALE_VERBOSE("base path: " << _uri.getPath().getParent());
GALE_VERBOSE("new path: " << _uri.getPath().getParent() / tmpData);
GALE_VERBOSE("create shader: " << tmpUri);
ememory::SharedPtr<gale::resource::Shader> tmpShader = gale::resource::Shader::create(tmpUri.get());
if (tmpShader == null) {
GALE_ERROR("Error while getting a specific shader filename : " << tmpUri);
} else {
GALE_DEBUG("Add shader on program : "<< tmpUri);
m_shaderList.pushBack(tmpShader);
}
}
GALE_DEBUG("===========================================================");
// close the file:
fileIO->close();
}
if (gale::openGL::hasContext() == true) {
updateContext();
} else {
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
}
}
gale::resource::Program::~Program() {
m_shaderList.clear();
removeContext();
m_elementList.clear();
m_hasTexture = false;
m_hasTexture1 = false;
}
etk::Stream& gale::resource::operator <<(etk::Stream& _os, const gale::resource::progAttributeElement& _obj) {
_os << "{";
_os << "[" << _obj.m_name << "] ";
_os << _obj.m_elementId << " ";
_os << _obj.m_isLinked;
_os << "}";
return _os;
}
etk::Stream& gale::resource::operator <<(etk::Stream& _os, const etk::Vector<gale::resource::progAttributeElement>& _obj){
_os << "{";
for (auto &it : _obj) {
_os << it;
}
_os << "}";
return _os;
}
void gale::resource::Program::checkGlError(const char* _op, int32_t _localLine, int32_t _idElem) {
#ifdef DEBUG
bool isPresent = false;
for (GLint error = glGetError(); error; error = glGetError()) {
GALE_ERROR("after " << _op << "() line=" << _localLine << " glError(" << error << ")");
isPresent = true;
}
if (isPresent == true) {
GALE_ERROR(" in program name : " << m_name);
GALE_ERROR(" program OpenGL ID =" << m_program);
GALE_ERROR(" List Uniform:");
int32_t id = 0;
for (auto &it : m_elementList) {
if (it.m_isAttribute == false) {
GALE_ERROR(" " << (id==_idElem?"*":" ") << " name :" << it.m_name << " OpenGL ID=" << it.m_elementId << " is linked=" << it.m_isLinked);
}
id++;
}
GALE_ERROR(" List Attribute:");
id = 0;
for (auto &it : m_elementList) {
if (it.m_isAttribute == true) {
GALE_ERROR(" " << (id==_idElem?"*":" ") << " name :" << it.m_name << " OpenGL ID=" << it.m_elementId << " is linked=" << it.m_isLinked);
}
id++;
}
GALE_CRITICAL("Stop on openGL ERROR");
}
#endif
}
#define LOG_OGL_INTERNAL_BUFFER_LEN (8192)
static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
bool gale::resource::Program::checkIdValidity(int32_t _idElem) {
ethread::RecursiveLock lock(m_mutex);
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
return false;
}
return m_elementList[_idElem].m_isLinked;
}
int32_t gale::resource::Program::getAttribute(etk::String _elementName) {
ethread::RecursiveLock lock(m_mutex);
// check if it exist previously :
for(size_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == _elementName) {
return iii;
}
}
progAttributeElement tmp;
tmp.m_name = _elementName;
tmp.m_isAttribute = true;
if (gale::openGL::hasContext() == false) {
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
tmp.m_elementId = -1;
tmp.m_isLinked = false;
} else if (m_exist == true) {
tmp.m_elementId = gale::openGL::program::getAttributeLocation(m_program, tmp.m_name);
tmp.m_isLinked = true;
if (tmp.m_elementId<0) {
GALE_WARNING(" {" << m_program << "}[" << m_elementList.size() << "] glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
tmp.m_isLinked = false;
} else {
GALE_DEBUG(" {" << m_program << "}[" << m_elementList.size() << "] glGetAttribLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
}
} else {
// program is not loaded ==> just local reister ...
tmp.m_elementId = -1;
tmp.m_isLinked = false;
}
m_elementList.pushBack(tmp);
return m_elementList.size()-1;
}
int32_t gale::resource::Program::getUniform(const etk::String& _elementName) {
ethread::RecursiveLock lock(m_mutex);
// check if it exist previously :
for(size_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == _elementName) {
return iii;
}
}
progAttributeElement tmp;
tmp.m_name = _elementName;
tmp.m_isAttribute = false;
if (gale::openGL::hasContext() == false) {
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
tmp.m_elementId = -1;
tmp.m_isLinked = false;
} else if (m_exist == true) {
tmp.m_elementId = gale::openGL::program::getUniformLocation(m_program, tmp.m_name);
tmp.m_isLinked = true;
if (tmp.m_elementId<0) {
GALE_WARNING(" {" << m_program << "}[" << m_elementList.size() << "] glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
tmp.m_isLinked = false;
} else {
GALE_DEBUG(" {" << m_program << "}[" << m_elementList.size() << "] glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
}
} else {
// program is not loaded ==> just local reister ...
tmp.m_elementId = -1;
tmp.m_isLinked = false;
}
m_elementList.pushBack(tmp);
return m_elementList.size()-1;
}
bool gale::resource::Program::updateContext() {
ethread::RecursiveLock lock(m_mutex, true);
if (lock.tryLock() == false) {
//Lock error ==> try later ...
return false;
}
if (m_exist == true) {
// Do nothing == > too dangerous ...
} else {
// create the Shader
GALE_DEBUG("Create the Program ... \"" << m_name << "\"");
m_program = gale::openGL::program::create();
if (m_program < 0) {
return true;
}
// first attach vertex shader, and after fragment shader
for (size_t iii=0; iii<m_shaderList.size(); iii++) {
if (m_shaderList[iii] != null) {
if (m_shaderList[iii]->getShaderType() == gale::openGL::shader::type::vertex) {
gale::openGL::program::attach(m_program, m_shaderList[iii]->getGL_ID());
}
}
}
for (size_t iii=0; iii<m_shaderList.size(); iii++) {
if (m_shaderList[iii] != null) {
if (m_shaderList[iii]->getShaderType() == gale::openGL::shader::type::fragment) {
gale::openGL::program::attach(m_program, m_shaderList[iii]->getGL_ID());
}
}
}
if (gale::openGL::program::compile(m_program) == false) {
GALE_ERROR("Could not compile \"PROGRAM\": \"" << m_name << "\"");
gale::openGL::program::remove(m_program);
return true;
}
// now get the old attribute requested priviously ...
size_t iii = 0;
for(auto &it : m_elementList) {
if (it.m_isAttribute == true) {
it.m_elementId = gale::openGL::program::getAttributeLocation(m_program, it.m_name);
it.m_isLinked = true;
if (it.m_elementId<0) {
GALE_WARNING(" {" << m_program << "}[" << iii << "] openGL::getAttributeLocation(\"" << it.m_name << "\") = " << it.m_elementId);
it.m_isLinked = false;
} else {
GALE_DEBUG(" {" << m_program << "}[" << iii << "] openGL::getAttributeLocation(\"" << it.m_name << "\") = " << it.m_elementId);
}
} else {
it.m_elementId = gale::openGL::program::getUniformLocation(m_program, it.m_name);
it.m_isLinked = true;
if (it.m_elementId < 0) {
GALE_WARNING(" {" << m_program << "}[" << iii << "] openGL::getUniformLocation(\"" << it.m_name << "\") = " << it.m_elementId);
it.m_isLinked = false;
} else {
GALE_DEBUG(" {" << m_program << "}[" << iii << "] openGL::getUniformLocation(\"" << it.m_name << "\") = " << it.m_elementId);
}
}
iii++;
}
// It will existed only when all is updated...
m_exist = true;
}
return true;
}
void gale::resource::Program::removeContext() {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == true) {
gale::openGL::program::remove(m_program);
m_program = 0;
m_exist = false;
for(auto &it : m_elementList) {
it.m_elementId=0;
it.m_isLinked = false;
}
}
}
void gale::resource::Program::removeContextToLate() {
ethread::RecursiveLock lock(m_mutex);
m_exist = false;
m_program = 0;
}
void gale::resource::Program::reload() {
/* TODO : ...
etk::file file(m_name, etk::FILE_TYPE_DATA);
if (file.Exist() == false) {
GALE_ERROR("File does not Exist : \"" << file << "\"");
return;
}
int32_t fileSize = file.size();
if (fileSize == 0) {
GALE_ERROR("This file is empty : " << file);
return;
}
if (file.fOpenRead() == false) {
GALE_ERROR("Can not open the file : " << file);
return;
}
// remove previous data ...
if (m_fileData != null) {
del ete[] m_fileData;
m_fileData = 0;
}
// allocate data
m_fileData = ne w char[fileSize+5];
if (m_fileData == null) {
GALE_ERROR("Error Memory allocation size=" << fileSize);
return;
}
memset(m_fileData, 0, (fileSize+5)*sizeof(char));
// load data from the file :
file.fRead(m_fileData, 1, fileSize);
// close the file:
file.fClose();
*/
// now change the OGL context ...
removeContext();
updateContext();
}
//////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::sendAttribute(int32_t _idElem,
int32_t _nbElement,
const void* _pointer,
int32_t _jumpBetweenSample) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
//GALE_ERROR("[" << m_elementList[_idElem].m_name << "] send " << _nbElement << " element");
glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL
_nbElement, // number of elements per vertex, here (r,g,b,a)
GL_FLOAT, // the type of each element
GL_FALSE, // take our values as-is
_jumpBetweenSample, // no extra data between each position
_pointer); // Pointer on the buffer
checkGlError("glVertexAttribPointer", __LINE__, _idElem);
glEnableVertexAttribArray(m_elementList[_idElem].m_elementId);
checkGlError("glEnableVertexAttribArray", __LINE__, _idElem);
}
void gale::resource::Program::sendAttributePointer(int32_t _idElem,
const ememory::SharedPtr<gale::resource::VirtualBufferObject>& _vbo,
int32_t _index,
int32_t _jumpBetweenSample,
int32_t _offset) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
// check error of the VBO goog enought ...
if (_vbo->getElementSize(_index) <= 0) {
GALE_ERROR("Can not bind a VBO Buffer with an element size of : " << _vbo->getElementSize(_index) << " named=" << _vbo->getName());
return;
}
GALE_VERBOSE("[" << m_elementList[_idElem].m_name << "] send " << _vbo->getElementSize(_index) << " element on oglID=" << _vbo->getGL_ID(_index) << " VBOindex=" << _index);
glBindBuffer(GL_ARRAY_BUFFER, _vbo->getGL_ID(_index));
checkGlError("glBindBuffer", __LINE__, _idElem);
GALE_VERBOSE(" id=" << m_elementList[_idElem].m_elementId);
GALE_VERBOSE(" eleme size=" << _vbo->getElementSize(_index));
GALE_VERBOSE(" jump sample=" << _jumpBetweenSample);
GALE_VERBOSE(" offset=" << _offset);
glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL
_vbo->getElementSize(_index), // number of elements per vertex, here (r,g,b,a)
GL_FLOAT, // the type of each element
GL_FALSE, // take our values as-is
_jumpBetweenSample, // no extra data between each position
(GLvoid *)_offset); // Pointer on the buffer
checkGlError("glVertexAttribPointer", __LINE__, _idElem);
glEnableVertexAttribArray(m_elementList[_idElem].m_elementId);
m_listOfVBOUsed.pushBack(m_elementList[_idElem].m_elementId);
checkGlError("glEnableVertexAttribArray", __LINE__, _idElem);
}
//////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniformMatrix(int32_t _idElem, const mat4& _matrix, bool _transpose) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
return;
}
//GALE_ERROR("[" << m_elementList[_idElem].m_name << "] send 1 matrix");
// note : Android des not supported the transposition of the matrix, then we will done it oursef:
if (_transpose == true) {
mat4 tmp = _matrix;
tmp.transpose();
glUniformMatrix4fv(m_elementList[_idElem].m_elementId, 1, GL_FALSE, tmp.m_mat);
} else {
glUniformMatrix4fv(m_elementList[_idElem].m_elementId, 1, GL_FALSE, _matrix.m_mat);
}
checkGlError("glUniformMatrix4fv", __LINE__, _idElem);
}
//////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniform1f(int32_t _idElem, float _value1) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if (_idElem<0 || (size_t)_idElem>m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
return;
}
glUniform1f(m_elementList[_idElem].m_elementId, _value1);
checkGlError("glUniform1f", __LINE__, _idElem);
}
void gale::resource::Program::uniform2f(int32_t _idElem, float _value1, float _value2) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if (_idElem<0 || (size_t)_idElem>m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
return;
}
glUniform2f(m_elementList[_idElem].m_elementId, _value1, _value2);
checkGlError("glUniform2f", __LINE__, _idElem);
}
void gale::resource::Program::uniform3f(int32_t _idElem, float _value1, float _value2, float _value3) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if (_idElem<0 || (size_t)_idElem>m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
return;
}
glUniform3f(m_elementList[_idElem].m_elementId, _value1, _value2, _value3);
checkGlError("glUniform3f", __LINE__, _idElem);
}
void gale::resource::Program::uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if (_idElem<0 || (size_t)_idElem>m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
return;
}
glUniform4f(m_elementList[_idElem].m_elementId, _value1, _value2, _value3, _value4);
checkGlError("glUniform4f", __LINE__, _idElem);
}
//////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniform1i(int32_t _idElem, int32_t _value1) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if (_idElem<0 || (size_t)_idElem>m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
return;
}
glUniform1i(m_elementList[_idElem].m_elementId, _value1);
checkGlError("glUniform1i", __LINE__, _idElem);
}
void gale::resource::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if (_idElem<0 || (size_t)_idElem>m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
return;
}
glUniform2i(m_elementList[_idElem].m_elementId, _value1, _value2);
checkGlError("glUniform2i", __LINE__, _idElem);
}
void gale::resource::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if (_idElem<0 || (size_t)_idElem>m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
return;
}
glUniform3i(m_elementList[_idElem].m_elementId, _value1, _value2, _value3);
checkGlError("glUniform3i", __LINE__, _idElem);
}
void gale::resource::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if (_idElem<0 || (size_t)_idElem>m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
return;
}
glUniform4i(m_elementList[_idElem].m_elementId, _value1, _value2, _value3, _value4);
checkGlError("glUniform4i", __LINE__, _idElem);
}
//////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
if (_nbElement == 0) {
GALE_ERROR("No element to send at open GL ...");
return;
}
if (_value == null) {
GALE_ERROR("null Input pointer to send at open GL ...");
return;
}
glUniform1fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
checkGlError("glUniform1fv", __LINE__, _idElem);
}
void gale::resource::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
if (_nbElement == 0) {
GALE_ERROR("No element to send at open GL ...");
return;
}
if (_value == null) {
GALE_ERROR("null Input pointer to send at open GL ...");
return;
}
glUniform2fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
checkGlError("glUniform2fv", __LINE__, _idElem);
}
void gale::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
if (_nbElement == 0) {
GALE_ERROR("No element to send at open GL ...");
return;
}
if (_value == null) {
GALE_ERROR("null Input pointer to send at open GL ...");
return;
}
GALE_VERBOSE("[" << m_elementList[_idElem].m_name << "] send " << _nbElement << " vec3");
glUniform3fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
checkGlError("glUniform3fv", __LINE__, _idElem);
}
void gale::resource::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
if (_nbElement == 0) {
GALE_ERROR("No element to send at open GL ...");
return;
}
if (_value == null) {
GALE_ERROR("null Input pointer to send at open GL ...");
return;
}
GALE_VERBOSE("[" << m_elementList[_idElem].m_name << "] send " << _nbElement << " vec4");
glUniform4fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
checkGlError("glUniform4fv", __LINE__, _idElem);
}
//////////////////////////////////////////////////////////////////////////////////////////////
void gale::resource::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
if (_nbElement == 0) {
GALE_ERROR("No element to send at open GL ...");
return;
}
if (_value == null) {
GALE_ERROR("null Input pointer to send at open GL ...");
return;
}
glUniform1iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
checkGlError("glUniform1iv", __LINE__, _idElem);
}
void gale::resource::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
if (_nbElement == 0) {
GALE_ERROR("No element to send at open GL ...");
return;
}
if (_value == null) {
GALE_ERROR("null Input pointer to send at open GL ...");
return;
}
glUniform2iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
checkGlError("glUniform2iv", __LINE__, _idElem);
}
void gale::resource::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
if (_nbElement == 0) {
GALE_ERROR("No element to send at open GL ...");
return;
}
if (_value == null) {
GALE_ERROR("null Input pointer to send at open GL ...");
return;
}
glUniform3iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
checkGlError("glUniform3iv", __LINE__, _idElem);
}
void gale::resource::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
GALE_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
if (_nbElement == 0) {
GALE_ERROR("No element to send at open GL ...");
return;
}
if (_value == null) {
GALE_ERROR("null Input pointer to send at open GL ...");
return;
}
glUniform4iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
checkGlError("glUniform4iv", __LINE__, _idElem);
}
//#define PROGRAM_DISPLAY_SPEED
//////////////////////////////////////////////////////////////////////////////////////////////
#ifdef PROGRAM_DISPLAY_SPEED
int64_t g_startTime = 0;
#endif
void gale::resource::Program::use() {
GALE_VERBOSE("Will use program : " << m_program);
#ifdef PROGRAM_DISPLAY_SPEED
g_startTime = gale::getTime();
#endif
// event if it was 0 == > set it to prevent other use of the previous shader display ...
gale::openGL::useProgram(m_program);
checkGlError("glUseProgram", __LINE__);
}
void gale::resource::Program::setTexture0(int32_t _idElem, int64_t _textureOpenGlID) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
#if 0
gale::openGL::enable(GL_TEXTURE_2D);
checkGlError("glEnable", __LINE__);
#endif
gale::openGL::activeTexture(GL_TEXTURE0);
checkGlError("glActiveTexture", __LINE__, _idElem);
// set the textureID
glBindTexture(GL_TEXTURE_2D, _textureOpenGlID);
checkGlError("glBindTexture", __LINE__, _idElem);
// set the texture on the uniform attribute
glUniform1i(m_elementList[_idElem].m_elementId, /*GL_TEXTURE*/0);
checkGlError("glUniform1i", __LINE__, _idElem);
m_hasTexture = true;
}
void gale::resource::Program::setTexture1(int32_t _idElem, int64_t _textureOpenGlID) {
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
return;
}
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
#if 0
gale::openGL::enable(GL_TEXTURE_2D);
checkGlError("glEnable", __LINE__);
#endif
gale::openGL::activeTexture(GL_TEXTURE1);
checkGlError("glActiveTexture", __LINE__, _idElem);
// set the textureID
glBindTexture(GL_TEXTURE_2D, _textureOpenGlID);
checkGlError("glBindTexture", __LINE__, _idElem);
// set the texture on the uniform attribute
glUniform1i(m_elementList[_idElem].m_elementId, /*GL_TEXTURE*/1);
checkGlError("glUniform1i", __LINE__, _idElem);
m_hasTexture1 = true;
}
void gale::resource::Program::unUse() {
GALE_VERBOSE("Will UN-use program : " << m_program);
ethread::RecursiveLock lock(m_mutex);
if (m_exist == false) {
return;
}
for (auto &it : m_listOfVBOUsed) {
glDisableVertexAttribArray(it);
}
m_listOfVBOUsed.clear();
#if 0
if (m_hasTexture == true) {
gale::openGL::disable(GL_TEXTURE_2D);
//checkGlError("glDisable", __LINE__);
m_hasTexture = false;
}
#endif
// no need to disable program == > this only generate perturbation on speed ...
gale::openGL::useProgram(-1);
#ifdef PROGRAM_DISPLAY_SPEED
float localTime = (float)(gale::getTime() - g_startTime) / 1000.0f;
if (localTime>1) {
GALE_ERROR(" prog : " << localTime << "ms resource=\"" << m_name << "\"");
} else {
GALE_DEBUG(" prog : " << localTime << "ms resource=\"" << m_name << "\"");
}
#endif
checkGlError("glUseProgram", __LINE__);
}

Some files were not shown because too many files have changed in this diff Show More