Compare commits

...

461 Commits

Author SHA1 Message Date
Torsten Dreyer
7489771ad2 Bump version to 2.11.0 2013-01-17 19:22:07 +01:00
Thomas Geymayer
ea8023e51f Canvas: Provide sane default bounding box (For Image & Text) 2013-01-09 12:11:19 +01:00
Thomas Geymayer
8a9693a28e Fix canvas mouse intersection test
Bounding box of drawables use other coordinate frame
then bounding sphere of MatrixTransform...
2013-01-05 00:44:19 +01:00
Thomas Geymayer
724fba4af9 canvas::Element: parse full 3x3 matrix
This doesn't change any existing behaviour but allows specifying
full 3x3 matrix to eg. perform a perspective transform needed
for some HUDs.
2013-01-01 14:18:39 +01:00
Thomas Geymayer
beca1cbf96 Allow nasal::Ghost to only wrap classes by their shared pointers
This removes support for exposing and managing classes by just
raw pointers as this made lifetime management of instances
from C++ to Nasal and especially the other way round nearly
impossible. Always using smart pointers saves us from a lot
of headaches.
2012-12-29 17:49:22 +01:00
James Turner
b74d2ae9fa Notify all requests on name lookup failures.
Since there's no active request during a name lookup failure, explicitly fail all sent and queued requests, so the Request subclasses can take regular failure action.
2012-12-29 14:36:38 +00:00
James Turner
ec82a0154b Expose the current members of a subsystem group. 2012-12-28 14:54:00 +00:00
James Turner
0ea8dbea10 Add SGPath to the Nasal conversion helpers. 2012-12-28 14:53:31 +00:00
James Turner
a131f44247 OS-X specific sleep helper, more stable. 2012-12-23 23:30:40 +00:00
Thomas Geymayer
0423aedffc Revert to old way of including everything from SGMath.hxx 2012-12-23 01:30:41 +01:00
James Turner
afc89cdd95 Tweak libSvn usage: fixes a crash on Mac.
Work-around a crash on certain Mac builds (I can't tell why other work fine) where the called parameters to apr_pool_create_ex are problematic. Explicitly pass the default values for the function.
2012-12-22 23:55:37 +00:00
Mathias Froehlich
541606e00d hla: Lower the log level of two alerts.
Trying to interpret the object template in a yet
unimplemented format is not worth an alert.
2012-12-22 10:12:45 +01:00
Torsten Dreyer
c53fd5fc9a feature freeze for 2.10.0, new version number 2012-12-18 21:57:02 +01:00
Thomas Geymayer
bc3dd06b26 Missing file... 2012-12-17 10:53:52 +01:00
Thomas Geymayer
fd39808ed8 Nasal cppbindings: automatic conversion of vec2 to/from Nasal 2012-12-17 00:29:14 +01:00
Thomas Geymayer
a1b7cb5330 Fix memory leak if nasal::Ghost creation fails 2012-12-16 21:31:19 +01:00
Thomas Geymayer
ac27fae712 Canvas: Remove old event handling code 2012-12-16 19:02:21 +01:00
Thomas Geymayer
f6270ec395 Canvas: create mouseover/mouseout events 2012-12-16 18:52:32 +01:00
James Turner
e9c70f8b1c Improve HTTP behaviour when name lookup fails.
Don't endlessly re-send requests when name lookup fails; inform the next layer up so it can decide whether to retry.
2012-12-15 15:09:33 +00:00
Thomas Geymayer
50688e1159 Rename simgear::Rect to SGRect and make interface more similar to SGBox 2012-12-13 23:37:21 +01:00
Thomas Geymayer
8417fea3bf Overload Rect::contains and add compound assignment operators to PropertyObject 2012-12-13 00:30:11 +01:00
James Turner
f5150d32af Whoops, fix bad #ifdef to disable sound. Bug #958 2012-12-12 11:16:29 +00:00
Thomas Geymayer
2263823f75 Create new FBO if Canvas render target size chanages
As doesnt seem to work to just resize the texture, if changing
the size of the Canvas render target a new FBO is created and
placed on all active placements.
2012-12-09 23:08:07 +01:00
Thomas Geymayer
a882263033 Canvas: MouseEvent now contains screen and client pos 2012-12-08 15:01:01 +01:00
James Turner
24d2431522 Work on making OpenAL a compile-time option.
ENABLE_SOUND=0 now works when configuring SimGear, and libSimGearScene can be linked without OpenAL. However, more testing of FlightGear in this mode is needed before it's officially supported!
2012-12-07 15:26:24 -05:00
Thomas Geymayer
fd27e7bd43 Canvas: basic support for rectangular clipping (like CSS clip property) 2012-12-07 18:36:37 +01:00
Thomas Geymayer
4dfe36cdc1 Canvas: Fix handling drag events and some cleanup. 2012-12-07 18:35:20 +01:00
Thomas Geymayer
fc49be1e05 Implement Canvas single/double/tripple click handling.
- Implement click event creation like specified in
   DOM Level 3:
   * Check for max move distance between mousedown/up
     and clicks
   * Check for click timeout
   * Count clicks and report double clicks
2012-12-06 23:16:36 +01:00
Thomas Geymayer
d06d94c767 Canvas: Propagate style changes on groups to children 2012-12-06 11:33:51 +01:00
Stuart Buchanan
66786651b0 Fix RNG so it is passed in from above rather than generating the same
seed continuously.
2012-12-05 22:10:45 +00:00
Thomas Geymayer
e9b499b82d Extend Canvas to retrieve bounding box of groups 2012-12-04 23:58:08 +01:00
Thomas Geymayer
e6e3e686c6 canvas::Element: print warning instead of crash on removing unknown transform 2012-12-02 23:55:34 +01:00
Mathias Froehlich
1e6ba0cdc4 hla: Add SGQuat data elements. 2012-12-02 17:30:08 +01:00
Mathias Froehlich
75db4c29b8 hla: Add integer valued vector types. 2012-12-02 17:30:08 +01:00
Mathias Froehlich
914d3e6a2b math: Add integer valued vector types. 2012-12-02 17:30:08 +01:00
Mathias Froehlich
ff678a5ad7 hla: Remove obsolete typedefs. 2012-12-02 17:30:08 +01:00
Thomas Geymayer
46442ef50c First working version of DOM like Canvas event handling
- Now it is possible to attach listeners to canvas
   elements and also the canvas itself, which get
   called upon different mouse events (Currently
   only basic mouse events supported. click/dblclick
   etc. are missing)
2012-12-02 13:22:37 +01:00
ThorstenB
7d8fde82e6 Fixed incomplete copy&paste issue. 2012-12-01 11:07:10 +01:00
ThorstenB
99cf057906 #946: some libraries not found on Ubuntu/Debian
Ubuntu/Debian introduced "multiarch" library directories, which is
unsupported by CMake <= 2.8.10. Add manual search paths as a workaround.
Currently it is only needed for libsvn, but it is needed for any lib
which is converted to the new directory standard.
2012-12-01 11:00:50 +01:00
Frederic Bouvier
59d3d66f91 Look for Boost 1.52.0 and OpenRTI under Windows 2012-12-01 10:59:58 +01:00
Mathias Froehlich
be73c0fe43 hla: Use a different extrapolation method for HLALocation. 2012-12-01 08:02:30 +01:00
Mathias Froehlich
e5afc6f029 SharedPtr: Avoid double dereference when calling clear(). 2012-12-01 08:02:29 +01:00
Thomas Geymayer
8816d0a9ac Add method canvas::Group::getElementById
- canvas::Group: New method to get a (possibly
   nested) child by its id.
 - nasal::Ghost: Also support recursive parent
   hashes.
2012-11-30 00:06:17 +01:00
Thomas Geymayer
229837b14c Fix some compiler warnings. size_t/int/unsigned conversions and extra ';' 2012-11-29 20:20:40 +01:00
Thomas Geymayer
94b068a40f Use better method names and add comments 2012-11-29 17:52:52 +01:00
Thomas Geymayer
2f0dfc4d74 Add methods to get arguments passed to function from Nasal 2012-11-29 01:23:15 +01:00
Christian Schmitt
3391c44107 SGThread: compile under MSVC 2012-11-28 18:29:15 +01:00
Peter Sadrozinski
35aae588b8 SGThread: Add capability to get current thread id 2012-11-28 11:23:30 +01:00
Thomas Geymayer
c19585e22a Simplify/Make VS happy 2012-11-27 15:14:54 +01:00
Thomas Geymayer
77946585b1 Canvas: Prepare for DOM Level 2 like event model. 2012-11-27 13:51:00 +01:00
Thomas Geymayer
88a35fd162 cppbind: Automatic conversion of derived ghosts and some cleanup/fixes 2012-11-27 13:02:36 +01:00
James Turner
7d8d4a03fb Make SGLockingQueue::pop usable.
Since there's no external lock, it was impossible to check the queue was non-empty before a pop, without a race condition. To avoid this, tolerate an empty queue and return a default constructed value.
2012-11-25 22:36:15 +00:00
Mathias Froehlich
1a68d34663 hla: For setting data types recurse into array data elements. 2012-11-25 22:27:14 +01:00
Mathias Froehlich
72a0ff706d hla: Use an implementation file for SGLocation. 2012-11-25 22:27:04 +01:00
Mathias Froehlich
420e43d47d sphere: Implement sphere inside sphere. 2012-11-24 09:55:34 +01:00
Mathias Froehlich
3c749d4774 hla: Route failures in message processing into the HLA layer. 2012-11-24 09:55:26 +01:00
Mathias Froehlich
d4310a7f3b hla: Make use of SGLocation. 2012-11-24 09:55:16 +01:00
Mathias Froehlich
f892d88c10 math: Implement SGLocation.
New simple class to encapsulate a cartesian position
and orientation pair with few handy methods.
2012-11-24 09:54:57 +01:00
ThorstenB
d226709836 Change logging class for tie/untie messages.
It's enough to see them in "general".
2012-11-23 20:44:17 +01:00
ThorstenB
fbfd03fe5c Add logging class for navaid systems. 2012-11-23 20:41:03 +01:00
ThorstenB
f513001798 #942 segfault with --log-level=debug when random buildings enabled 2012-11-22 21:55:11 +01:00
Christian Schmitt
31aa0ddabe Implement runway guard lights and tweak the hold short lights animation a bit 2012-11-22 16:42:56 +01:00
Thomas Geymayer
767184cf3c Extend CanvasSystemAdapter to provide access to Nasal gcSave and gcRelease 2012-11-22 00:54:56 +01:00
ThorstenB
fe86a9ed02 Fix compiler error with disabled sound support.
("source" is undefined in SGSampleGroup::stop).
Also fixes two related compiler warnings (unused var "sample").
2012-11-21 20:17:58 +01:00
Thomas Geymayer
9be53e746f Allow canvas::Placements to have own properties 2012-11-21 13:05:19 +01:00
Thomas Geymayer
8b6f50d0cc SGPropertyNode::fireCreatedRecursive: don't fire for node itself by default 2012-11-21 11:58:07 +01:00
James Turner
80dc28bfb5 Modernise the mat lib header, remove 'using std' 2012-11-20 17:10:13 +00:00
James Turner
983e1abf48 Work on ENABLE_SOUND.
Restructure SGSampleGroup, to make #ifdef-ing the OpenAL calls easier. No functionality change.
2012-11-20 12:20:21 +00:00
ThorstenB
ff65b82671 Keep (deprecated) SGTime::update method for a while
allowing dependent projects to adapt.
2012-11-19 23:42:51 +01:00
James Turner
0b26c69222 Remove duplicate members in SGSampleQueue.
Remove duplicate members shared by SGSoundSample and SGSampleQueue (which inherits from it). Change SGSoundSample to expose some members as protected data for access by the sample-queue, and hence share nearly all the methods. Also remove 'inline' keyword from virtual methods.
2012-11-19 15:33:53 +00:00
Thomas Geymayer
904d714d6d Get Canvas/PropertyBasedElement by name 2012-11-18 16:27:05 +01:00
James Turner
2aed93a576 Fix HTTP test for revised POST semantics. 2012-11-17 19:51:57 +00:00
James Turner
d1af42e9ad Tweak HTTP handling for POST requests.
Tolerate slightly malformed request URLs (no slash following the host specified), and use a better check when POST-ing to decide the request-body data source.
2012-11-17 18:08:38 +00:00
Thomas Geymayer
9f31addfa5 Fix for old gcc which got broken by fix for VS 2012-11-16 16:49:35 +01:00
Thomas Geymayer
d56ea7e6c4 Fix for VS bug 2012-11-16 15:49:43 +01:00
Thomas Geymayer
1cbe271ad5 Nasal bindings: Always pass object by reference 2012-11-16 12:24:47 +01:00
Thomas Geymayer
33db3c377f One more fix for old gcc 2012-11-15 23:31:18 +01:00
Thomas Geymayer
a0535ef64d Fix compile errors for old gcc 2012-11-15 22:17:43 +01:00
Thomas Geymayer
392ba18ff7 Canvas/C++ bindings: automatically detect dynamic type of polymorphic exposed classes 2012-11-15 21:17:33 +01:00
Thomas Geymayer
e872f9e928 Work around Visual Studio bug 2012-11-13 12:35:12 +01:00
Thomas Geymayer
04685a8179 C++/Nasal bindings: allow registering free function as member 2012-11-12 23:28:00 +01:00
Thomas Geymayer
55fbe68e62 Missing include and more doxygen improvements 2012-11-12 13:57:10 +01:00
Thomas Geymayer
f51e1f0cc8 Fix file headers 2012-11-12 12:25:08 +01:00
Thomas Geymayer
d31b62d44d Add nasal::Ghost class for exposing C++ classes to Nasal 2012-11-12 12:11:41 +01:00
Mathias Froehlich
9fd90e26f7 hla: Remove HLADataElement::Path based attribute handling. 2012-11-11 20:39:59 +01:00
ThorstenB
dbea0c9361 Geoff McLane: realpath for Windows using _fullpath.
Also switch cygwin to use POSIX call.
2012-11-11 19:26:51 +01:00
Mathias Froehlich
201cb61f84 hla: Use HLADataElementIndices for HLAInteractionClass. 2012-11-11 17:09:31 +01:00
Mathias Froehlich
71141e830a hla: Use HLADataElementIndices for HLALocation. 2012-11-11 14:27:35 +01:00
Mathias Froehlich
7dc8bf3aa4 hla: Fixes for the data element index implementation. 2012-11-11 14:27:34 +01:00
Thomas Geymayer
0fef94cfdb Add from_nasal helper and fix to_nasal for std::vector. 2012-11-10 14:34:18 +01:00
ThorstenB
a9b45967ce gz wrapper to write and read "container files".
Packs arbitrary data (strings, property trees, binary blobs, ...) into a
single file.
Use this for storing/loading user-data only, not for distribution files
(scenery, aircraft etc).
2012-11-10 10:44:19 +01:00
ThorstenB
0928bca531 Proper fix for gzfilebuf choking on some files.
When reading a new block of data, and the first byte of the new block is
0xff (_signed_ char -1), then this must be converted to _integer_ 0xff
(+255), not -1 - which would indicate an error condition (EOF==-1). All
valid _data_ character must be returned as non-negative, see
streambuf::underflow spec, or compare with
http://www.opensource.apple.com/source/zlib/zlib-12/zlib/contrib/iostream/zfstream.cpp
or
http://www.raspberryginger.com/jbailey/minix/html/zfstream_8cpp-source.html
2012-11-10 10:12:01 +01:00
ThorstenB
77f73a79df gzfilebuf choked when reading large, heavily compressed files.
Apparently a 4K buf isn't enough. 64K seem much better ;-).
Real solution may be an adaptive buffer size in gzfilebuf.
2012-11-09 22:04:11 +01:00
Stuart Buchanan
279445d6bc For clouds, use a RNG seed that only changes every 10 minutes.
This allows multi-process deploymentes to keep their clouds in sync.
2012-11-09 20:25:53 +00:00
Thomas Geymayer
54778ee1e1 Some basic C++/Nasal binding helpers
- Add nasal::to_nasal for converting different C++ types
   to the according Nasal types.
 - Add nasal::Hash, an OOP wrapper around Nasal hashes.
2012-11-09 19:28:27 +01:00
Thomas Geymayer
4efcda534d Workaround for VS10 Bug/Remove superfluous class qualification 2012-11-09 10:36:42 +01:00
Thomas Geymayer
45ac5cb2fa Canvas cleanup and restructuring
- Add some methods for easier using the Canvas from C++
 - Add some documentation to Nasal
2012-11-09 00:05:11 +01:00
Mathias Froehlich
6d045a9403 hla: Introduce HLADataElementIndex. 2012-11-08 22:51:02 +01:00
Mathias Froehlich
8c57a77d7e hla: catch exceptions in processMessages() 2012-11-08 22:50:52 +01:00
Mathias Froehlich
1f585d6719 hla: Use raw pointers for HLAFederate::_insert methods. 2012-11-08 22:50:39 +01:00
Mathias Froehlich
6c111f55aa hla: Warn about creating an object class or interactions classes twice. 2012-11-08 22:50:26 +01:00
Mathias Froehlich
b01693f426 Remove osg header from non simgearscene file. 2012-11-08 22:50:10 +01:00
ThorstenB
e37232aeb4 Disable build options unsupported for Windows. 2012-11-08 20:01:38 +01:00
ThorstenB
1c1c7dad7b zfstream: use the correct buffer size 2012-11-08 00:04:48 +01:00
ThorstenB
b70b81f4cc sgstream: implement gzipped output file stream (gzofstream)
Add missing output implementation for gzfilebuf.
2012-11-07 23:45:01 +01:00
ThorstenB
e3cf41a666 zfstream: fixed mixed white spaces
otherwise unchanged
2012-11-07 23:45:01 +01:00
James Turner
851a307c23 Test for, and fix, materials handling in BTG code.
It's possible (and happens!) to have less than 2^16 vertices or tex-coords, but more than 2^15 objects (tris) with the same materials. This was breaking our version 7 vs version 10 detection logic. Pete found the issue, I'm simply committing a version of his fix.
2012-11-07 21:10:00 +00:00
Thomas Geymayer
183d3749f0 Fix SGPropertyNode tests 2012-11-07 09:31:56 +01:00
ThorstenB
3fe513f9e0 Fix property find_last_child/addChild.
Initial "addChild" should have index #0 (not #1).
Also extend test cases.
(Test case shows addChild(append=false) isn't working as expected!?)
2012-11-07 00:53:32 +01:00
Thomas Geymayer
81bee2bbc6 Jenkins has some problems with bind and lambdas. Let's try it with ordinary function pointers... 2012-11-06 19:34:23 +01:00
Thomas Geymayer
34719da000 Clean up Canvas element creation 2012-11-06 18:48:00 +01:00
Thomas Geymayer
df8a3d9c60 SIMGEAR_HEADLESS define is not needed anymore 2012-11-05 18:06:13 +01:00
Thomas Geymayer
53dea9b069 Move parseColor to scene/util
parseColor is used to parse a CSS color string into an osg::Vec4
which is only available in SimGearScene. If someone needs the
function also in SimGear headless mode we have to think about
where to better place this function.
2012-11-05 17:58:24 +01:00
Thomas Geymayer
186bae2bd4 Proper headless build fix 2012-11-05 13:35:06 +01:00
Thomas Geymayer
f83c8828f0 Fix windows and headless build 2012-11-05 12:59:15 +01:00
Thomas Geymayer
509d064286 No need to link to ShivaVG anymore 2012-11-04 23:48:51 +01:00
Thomas Geymayer
2d039e393a Include ShivaVG into libSimGearScene 2012-11-04 20:00:53 +01:00
Thomas Geymayer
9ab88d9387 Commited too fast... 2012-11-04 19:22:37 +01:00
Thomas Geymayer
882a2a0e52 Remove OpenVG dependency from header file 2012-11-04 19:21:33 +01:00
Thomas Geymayer
c6ce1d8c67 Fix adding ShivaVG include directory 2012-11-04 16:51:07 +01:00
Thomas Geymayer
77e1a2e4be Fix signed/unsigned comparison warning 2012-11-04 15:26:41 +01:00
Thomas Geymayer
b99f53fda3 Refactor Canvas and add some helpers.
- Refactor Canvas from FlightGear and fix lazy rendering with
   recursive canvases.
 - New classes PropertyBasedElement and PropertyBasedManager for
   creating subsystems controlled by the property tree.
 - New method parseColor to parse CSS 3 conformant color strings
   (only basic color schemes supported)
 - New Rect class representing a rectangle.
2012-11-04 14:12:05 +01:00
Mathias Froehlich
a7f64cf7aa scenery: put stg loaded models under a common lod node. 2012-11-01 07:19:38 +01:00
Thomas Geymayer
8ebc0f2b24 Add VGInitOperation for initializing OpenVG 2012-10-31 01:38:59 +01:00
Thomas Geymayer
5330dc34bc Helper for property controlled subsystems
- Subsystem which manages a list of elements which
   are controlled through the property tree.
 - Fix a ShivaVG compiler warning.
 - Add some helper functions to trigger property removed/add
   events for a whole property tree.
2012-10-29 16:11:35 +01:00
Frederic Bouvier
4854a9e320 No bzero in MSVC 2012-10-29 08:48:55 +01:00
James Turner
71be1a9e28 HTTP enhancements.
Support content-encoding and improve pipelining support.
2012-10-27 18:03:51 +01:00
Thomas Geymayer
d0ae09c7e2 Link with ShivaVG 2012-10-25 01:02:38 +02:00
Thomas Geymayer
a25bd06138 ShivaVG: Support for pseudo non-zero fillrule 2012-10-25 01:02:23 +02:00
James Turner
1b55076897 Fix a Clang warning in Shiva. 2012-10-25 00:44:48 +02:00
Thomas Geymayer
5eac7974c9 Add missing glx.h include and fix some warnings. 2012-10-25 00:44:47 +02:00
James Turner
3afd6e9f51 Fix OS-X compilation. 2012-10-25 00:44:47 +02:00
Thomas Geymayer
05c107ba9c Allow filling paths and do some clean up/fixing. 2012-10-25 00:44:47 +02:00
Thomas Geymayer
99b00daf87 Add ShivaVG sources 2012-10-25 00:44:47 +02:00
Christian Schmitt
8ddb99f62f pt_lights: 9 seconds+ break for the ODALS flash sequence is a bit too much. Set it to 2 seconds. 2012-10-23 19:09:56 +02:00
Peter Sadrozinski
47dec485e5 Add SGGeod read and write to gzFile 2012-10-22 15:34:16 +02:00
Thomas Geymayer
f191b4f35c Move FGODGauge from FlightGear to SimGear.
This is a first step for moving the Canvas system to SimGear to
make it accessible to other applications (eg.FGRadar is going to
use it)
2012-10-19 11:56:32 +02:00
Thomas Geymayer
e24e3c0612 Add method SGPropertyNode::addChildren to create multiple children at once 2012-10-14 17:26:52 +02:00
ThorstenB
1dfac0a8b9 Avoid randomness when processing directories.
Order of files in file system order is random (maybe different for every
user). Determinsm is good, i.e. when loading Nasal scripts in a fixed,
known sequence, or config files, where the later may overrule settings of
the earlier.
2012-10-13 15:44:21 +02:00
Thomas Geymayer
f5cc151618 Extend addChild to allow using first unused index 2012-10-13 15:07:18 +02:00
ThorstenB
1ff3a61de6 Move uppercase function to strutils. 2012-10-10 21:31:57 +02:00
Stuart Buchanan
81d5b651d2 Change default tree-max-density-angle-deg to 30 and tree-zero-density-angle-deg to 45, as redommended by Thorsten Renk to account for our scenery generally rendering slopes shallower than they are IRL. 2012-10-10 19:57:16 +01:00
Stuart Buchanan
ea4ed7cdd1 Reduce tree and object cover on steep slopes, configurable through materials.xml 2012-10-05 21:59:13 +01:00
ThorstenB
e30ea5206f Fix Linux compile: "free" needs stdlib.h.
Also move to .cxx file to avoid another include dependency in the header.
2012-10-04 21:11:35 +02:00
James Turner
c188f6e3cb Initial work on making OpenAL private to the sound code. 2012-10-04 16:47:13 +01:00
Mathias Froehlich
2fb8999ac2 scenery: remove default zero reader writer options argument. 2012-10-03 22:04:47 +02:00
Mathias Froehlich
9c9bfc1a98 scenery: Make sure makeEffects has reader writer options. 2012-10-03 21:59:09 +02:00
James Turner
f7a87789ab Improve decode_bin output slightly. 2012-09-30 16:44:22 +01:00
Mathias Froehlich
7bcf02a0b4 Handle isnan at a more central place.
Do not distribute architecture specific
code across a lot of places.
2012-09-27 18:44:14 +02:00
Mathias Froehlich
fcd1733787 Fix line segment plane intersect. 2012-09-27 18:21:13 +02:00
Mathias Froehlich
c04ec5953f bvh: Build bigger leaf nodes for paged bvh nodes.
Flatten the leaf nodes in the paged bounding volume tree
as good as possible. The implementation still assumes a
whole world database which actually holds for our usual
scenery.
2012-09-27 18:21:13 +02:00
Mathias Froehlich
63aa16b97c scene: Factor out a common primitive functor.
This kind of work is done two times for different
flavours of bounding volume generation. Factor
out and use this in BVHPageNodeOSG.cxx and
BoundingVolumeBuildVisitor.hxx.
2012-09-27 18:21:13 +02:00
Mathias Froehlich
cafbf860be bvh: Make BVHPageNode::_Request fields private. 2012-09-27 18:21:13 +02:00
Frederic Bouvier
700b0bc776 Provide a definition for GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 2012-09-26 08:38:04 +02:00
Frederic Bouvier
98ca36e8f5 MSVC has no std::isnan 2012-09-26 08:36:56 +02:00
Stuart Buchanan
25130e3c82 Add alpha-to-coverage GL parameter to effects code. 2012-09-25 22:51:37 +01:00
James Turner
dc463d1c2c Macro to disable the copy-constructor.
Another toolkit I use has an explicit macro for this, which is nice for readability, so I've borrowed it here.
2012-09-24 23:18:57 +01:00
James Turner
89d30acbc5 SGTime: use SGGeod, quieter init.
It's common to use SGTime to calculate the the Julian Date, without providing time-zone information. Don't warn in these cases, since the behaviour is fine.
2012-09-24 00:02:11 +01:00
James Turner
be405d2311 Add another overload of SGGeodesy::direct 2012-09-23 21:43:42 +01:00
ThorstenB
acbe42775c Sound Manager: support subsystem reinit,
move initialization stuff to standard init phase.
Prevent AL calls when sound was never initialized.
2012-09-21 15:06:58 +02:00
ThorstenB
42d8772dd6 Avoid signed/unsigned compiler warning.
We don't really need a signed int here.
2012-09-21 12:55:40 +02:00
Christian Schmitt
81ef922f02 mat.cxx: fix an error reported by Valgrind 2012-09-19 10:10:14 +02:00
James Turner
d6e18c8a35 Support for incremental init of subsystems.
Allow subsystem init to be incremental, i.e requiring repeated init calls until a 'done' code is returned. Use this to support incremental init in groups and the manager. (It would also be possible to support it in an individual subsystem).

Note that if you use the existing init() calls, behaviour is unchanged.
2012-09-18 20:26:28 +01:00
Frederic Bouvier
4993a5c6c0 Sort fgfs source files in IDE folders - Don't work for headers though 2012-09-16 21:19:11 +02:00
Mathias Froehlich
052382af89 cmake: Make rti/hla compile again. 2012-09-16 21:13:56 +02:00
Mathias Froehlich
18f7102461 stg: Fix typo. 2012-09-16 18:43:05 +02:00
James Turner
ddbb2bea8a Option to use system, instead of built-in, expat
At least one Linux distribution packager of FG has complained that we're bundling expat in our binaries. To keep them happy, add the option (-DSYSTEM_EXPAT=1 at cmake time) to use the system expat instead.

For the moment (and simplicity), this requires building SIMGEAR_SHARED (which is fired to on by selecting the option).
2012-09-16 17:07:35 +01:00
ThorstenB
27131b43cb Add convenience method for tiedPropertyLists 2012-09-16 17:58:44 +02:00
James Turner
e8c2483432 De-virtualise SGSky to avoid a clang warning.
Clang was complaining that SGSky has virtual methods, but no virtual destructor. It turns out we're never subclassing SGSky - it's used directly. Hence, remove all the 'virtual' attributes from its methods.
2012-09-16 16:34:10 +01:00
James Turner
fd495574a4 Kill off MIPS compatibility header.
CMake has never supported the MIPS compatibility headers, or indeed building using MIPSpro. If someone wishes to re-add MIPS/IRIX support, I'm hoping they will be using a compiler with functional standard library headers!
2012-09-16 16:27:22 +01:00
James Turner
12f85b3d1f Add an SG_UNUSED macro to SimGear.
Imitate Q_UNSUED from Qt, and provide a Simgear 'unused var' warning suppression macro. Fix up one place where the previous warning suppression attempt (assigning to self) was still producing a warning under clang.
2012-09-16 16:25:11 +01:00
James Turner
47d88bcfa7 Standardise SimGear libraries, for static vs shared.
Always create only two SimGear libraries: SimGearCore and SimGearStatic, regardless of whether we're building static or shared. This requires an updated to FindSimGear.cmake module, for the static configuration.
2012-09-16 16:04:08 +01:00
Christian Schmitt
e4dacaf0d2 pt_lights: softly fade in and out the blinking lights 2012-09-14 17:07:07 +02:00
Christian Schmitt
2906a2d007 pt_lights: add some randomness to the blinking interval of the hold short lights 2012-09-14 10:14:31 +02:00
Stuart Buchanan
3000fdc33c Improve memory occupancy and load time of random buildings. 2012-09-12 22:45:12 +01:00
Christian Schmitt
076bde34a2 Scene: use better clipping mode for material textures.
This eliminates the black borders on runways between threshold and
designation textures and also between two designation numbers.

Thanks to Emilian for tracking this down!
2012-09-12 12:26:01 +02:00
Christian Schmitt
836c563c89 Signs: if the size is not allowed by the spec, print out a more meaningful warning
to help identify the problematic line.
2012-09-04 10:31:36 +02:00
ThorstenB
78c0419007 Fix libsvn detection for some Linux distros
Distros like Debian/Ubuntu use architecture-specific directory structures
(like /usr/lib/x86_64-linux-gnu) which we cannot hardcode/guess, so we
really need to search the default paths.
2012-09-03 23:51:38 +02:00
Frederic Bouvier
9dd5b91cea Support MS VS2012 2012-09-03 17:32:26 +02:00
Frederic Bouvier
b4c8b00c0e Try to discover the most recent Boost version installed in MSVC_ROOT (Windows only) 2012-09-02 12:43:21 +02:00
Frederic Bouvier
430e72b424 Ugly hack to please Boost 1.51.0 2012-09-02 12:22:20 +02:00
Christian Schmitt
135a8102f0 Remove plib dep references from documentation files 2012-08-29 12:08:27 +02:00
Christian Schmitt
c9cf4ad02a Remove plib reference 2012-08-28 13:04:25 +02:00
Christian Schmitt
3001809bc3 Remove unused source files 2012-08-28 12:59:33 +02:00
Julian Ospald
9e77ff328e CMake: fix underlinking 2012-08-28 11:30:49 +02:00
Mathias Froehlich
efddcb18a3 bvh: Fix headless build. 2012-08-27 18:00:01 +02:00
Mathias Froehlich
54ff2bec90 scene: Allow ground based elevations in stg files.
PLEASE do not use this feature for many objects over
fine tesselated ground. But for convenience make this work.
2012-08-26 15:08:55 +02:00
Mathias Froehlich
287ed83de7 btg: Lights are much better visible. 2012-08-26 15:08:48 +02:00
Mathias Froehlich
dd13924a67 bvh: add missing include. 2012-08-26 15:08:42 +02:00
Mathias Froehlich
a050a3b80f scenery: OptionsReadFileCallback for use with reader writer options.
The new callback has a default implementation of the callback
methods that do call back into the registrys callback before
calling the registrys implementation directly.
This is meant to be used together with ReaderWriterOptions that
still want to call back into the normal callback chain of the
registry.
2012-08-26 15:08:33 +02:00
Mathias Froehlich
f1201eaebc scene: Reorganize stg loading.
This is in preparation loading the non btg objects
in a seperate page node. Reorganize this code again.
2012-08-26 15:08:20 +02:00
Mathias Froehlich
68dd50ecbc stg: Add flag to load only specific parts of the stg files.
The flags are meant to be used for fgelev and for an ai
module that will probably only need ground elevation queries
in those reagions where the aircraft simulated there will roll
that is on airports.
2012-08-25 08:47:09 +02:00
Mathias Froehlich
2129cf5aa6 bvh: Implement paging for osg derived bvh trees. 2012-08-24 21:25:26 +02:00
Mathias Froehlich
cf1bdcef46 bvh: Add an abstract pager implementation.
Implement a paging implementation for bounding
volume hierarchy nodes. We will need this for
hla clients that need ground queries.
2012-08-24 21:25:17 +02:00
Mathias Froehlich
7a879e2abf bvh: Introduce BVHMaterial independent of SGMaterial.
The bounding volumes in core should not depend on scenery.
Therefore reference material properties relevant for the BVH
tree in BVHMaterial.
2012-08-24 21:25:11 +02:00
Mathias Froehlich
22878b6f89 bvh: Move the basic bounding volume tree functionality into core.
The basic boundignvolume implementation does only need math and
geometry. As such it is agnostic to the scenegraph being used.
Only the parts building this query structure from terrain
depend on the implementation of the terrain.
So, move this into the simgear core component.
2012-08-24 21:24:57 +02:00
James Turner
e99064ca18 Refactor mat.hxx header.
Avoid many includes in mat.hxx, so ground testing code (e.g., Yasim) doesn't end up pulling in many OSG and scene classes.
2012-08-22 19:02:46 +01:00
James Turner
b93661508e Fix more Linux warnings/errors.
(I'm away from the VM I would normally use to test such things before pushing, apologies for the churn)
2012-08-21 23:49:30 +01:00
James Turner
27ade6c420 Fix tests linkage when building static libs. 2012-08-21 22:55:04 +01:00
James Turner
473249d605 Unbreak Linux: malloc() needs <cstdlib> 2012-08-21 22:49:36 +01:00
James Turner
62cf65ce0f Remove a couple of lingering alut references. 2012-08-21 19:25:33 +01:00
James Turner
c4f6aa2f90 Remove ALUT usage from SimGear .
Adapt the freealut code into a WAV-file reader. As a side-effect, it would now be possible to deploy WAV files compressed with gzip, since we use ZLib's gzread functions to read from disk.
2012-08-21 13:24:35 +01:00
Frederic Bouvier
9ca112c362 Compatibility fix 2012-08-18 14:53:48 +02:00
ThorstenB
cdcc17ee37 Christoph Korn/PlayDeb.net: support additional architechtures 2012-08-17 23:48:41 +02:00
Frederic Bouvier
4f3e1587b1 Restore auto-detection of SVN libs on Windows 2012-08-15 23:02:29 +02:00
Mathias Froehlich
b18c92f515 hla: Add virtual method for creating data elements. 2012-08-12 12:06:42 +02:00
James Turner
3270edcf87 Mac changes for Subversion bundling. 2012-08-11 15:21:52 +01:00
Tim Moore
c0e8dd97ae change dynamic variance of effect attributes
Previously, any effect attribute that was set via effect parameters i.e., was
not a constant value, was marked with data variance DYNAMIC. Now, only
attributes that get their values from the property tree are so marked.
2012-08-06 11:04:42 +02:00
Mathias Froehlich
3a0ae3df58 hla: Do not call time advance with non positive increment. 2012-08-04 14:38:10 +02:00
Tim Moore
d6361dfee4 Merge branch 'timoore/optimizations' into next 2012-08-03 22:33:57 +02:00
Tim Moore
b61692b667 add libosgGA to OpenSceneGraph libraries used with tests
The DeletionManager needs osgGA. This becomes apparent when building shared
libraries.
2012-08-03 22:32:39 +02:00
Tim Moore
2815688c7e Merge branch 'timoore/optimizations' into next 2012-08-03 20:15:36 +02:00
Tim Moore
78a78a17cc DeletionManager
Class for safely deleting objects that may be active in different threads.
This is now used in the implementation of spin animations.
2012-08-03 20:10:53 +02:00
Tim Moore
e202d4e4a5 bug: 823 change rotation animation to use a subclass of SGRotateTransform
The animation is implemented in the computeWorldToLocalMatrix() and
computeLocalToWorldMatrix() virtual functions. Doing the animation in a cull
callback breaks picking.

Fix for http://code.google.com/p/flightgear-bugs/issues/detail?id=823
2012-08-03 20:10:00 +02:00
Stuart Buchanan
8b585db238 Allow a <parameters> section of a material definition, to pass parameters straight into the effect. 2012-08-01 21:06:59 +01:00
James Turner
e288549c9e Make dependent template lookups explicit.
Clang (in Xcode 4.4) is being strict about dependent lookup rules, so apply the recommended fix-it.
2012-07-31 00:57:09 +01:00
Mathias Froehlich
f71f129e3b hla: Remove reference to deprecated VariantDataType. 2012-07-29 20:58:07 +02:00
Mathias Froehlich
ee688166ab hla: Remove deprecated ObjectModelFactory interface. 2012-07-29 20:44:58 +02:00
Mathias Froehlich
ed66c37de2 hla: Remove deprecated AttributeCallback. 2012-07-29 17:33:19 +02:00
Mathias Froehlich
a5c6f8023b spt: Disable particle systems under a PagedLOD. 2012-07-21 12:55:53 +02:00
Mathias Froehlich
c82da8c9c8 hla: Add HLABoolDataElement. 2012-07-21 12:55:53 +02:00
Mathias Froehlich
07d1358e08 hla: Make HLAFixedRecordDataElement work with delayed data type setting. 2012-07-21 12:55:53 +02:00
Mathias Froehlich
1212109c03 math: Remove obsolete commented out code. 2012-07-21 12:55:53 +02:00
Mathias Froehlich
d4db4fcac3 hla: Remove deprecated methods from HLAObjectClass 2012-07-21 12:55:53 +02:00
Mathias Froehlich
1f46c79396 hla: Remove deprecated tick method. 2012-07-21 12:55:53 +02:00
Mathias Froehlich
199419ae62 hla: Remove deprecated types and methods from HLADataElement. 2012-07-21 12:55:53 +02:00
Mathias Froehlich
39a4d55866 hla: Remove deprecated HLAVariant* in favour of HLAVariantRecord* 2012-07-21 12:55:53 +02:00
Tim Moore
c84e1d0f0e Merge branch 'timoore/optimizations' into next
Some changes aimed at reducing the cost of the huge scene graph.
2012-07-20 00:37:39 +02:00
Tim Moore
302deeb122 set name string for update callbacks
This makes it easier to find nodes with update callbacks in the scene graph dump.
2012-07-20 00:34:47 +02:00
Tim Moore
b2a6cdec4e change optimizer options for models
Tristrips are old and busted, index meshes are the new hotness :)
2012-07-20 00:32:22 +02:00
Tim Moore
87676fad4d prune empty quadtree leaves created for random vegatation
A lot of empty primitive sets were being left in the per-tile random vegatation quadtree.
2012-07-20 00:30:53 +02:00
Tim Moore
75087095b1 Replace rotation animation update callbacks with cull callbacks
Update callbacks are expensive because they force large parts of the scenegraph to be traversed
by OSG.
2012-07-19 00:42:38 +02:00
ThorstenB
d0a5032723 Add warning for in-source-directory builds. 2012-07-17 19:18:05 +02:00
ThorstenB
2d6a7c2cf7 Add dot-files to gitignore. 2012-07-17 19:14:45 +02:00
ThorstenB
56e9158dee Bump simgear version to 2.9.0 2012-07-17 18:48:38 +02:00
Frederic Bouvier
3ba312116b Add a node mask bit for permanent lights (needed by Rembrandt) 2012-07-16 20:06:53 +02:00
Frederic Bouvier
e6ab3ddb7d More node mask fix 2012-07-14 13:00:30 +02:00
Stuart Buchanan
8ed0fec364 Fix degenerate random building placement case which resulted in buildings
being placed outside of the triangle bounds.
2012-07-13 20:00:06 +01:00
Frederic Bouvier
ddfdbd75b8 Precipitation don't cast shadows 2012-07-13 17:53:00 +02:00
Stuart Buchanan
00e21af5bb Correct index used by building.eff for lightmap. 2012-07-12 16:31:27 +01:00
ThorstenB
51a17a7a0f Suppress unnecessary "failed alias" warnings
when requested alias matches existing alias anyway (identical aliases can
be created on repeated sim resets)
2012-07-07 16:05:02 +02:00
Stuart Buchanan
fa58672f09 Fix bug where two references to a png object mask used against
a dds terrain texture resulted in the object mask being flipped twice,
having no overall effect!
2012-07-06 21:38:15 +01:00
Stuart Buchanan
4f7f5023df Fix further possible memory leaks by using osg::ref_ptr for vertex
arrays in random buildings and random vegetation.  Also change
normals on trees to be per-vertex as some graphics cards apparently
find this easier to deal with.
2012-07-05 00:10:07 +01:00
Stuart Buchanan
4838a9690e Fix a memory leak in random buildings. 2012-07-04 19:50:20 +01:00
ThorstenB
edcbfb52eb Add SimGear RPM package spec file.
Example for Linux package builders.
2012-07-02 21:51:40 +02:00
Frederic Bouvier
5af8bb7c8e Working 'noshadow' animation 2012-06-30 16:25:21 +02:00
ThorstenB
3fa835d74c Bump version to 2.8.0
since "next" is already frozen for 2.8 and is prepared for building the
first release candidate.
For details on versions see http://wiki.flightgear.org/Release_plan
2012-06-26 23:17:07 +02:00
ThorstenB
035ff3e1ea Update README/INSTALL documentation. 2012-06-26 22:43:48 +02:00
Frederic Bouvier
2c54237fe5 Don't render ocean tiles in the light pass 2012-06-25 17:55:46 +02:00
Frederic Bouvier
00c61204a4 Fix a typo 2012-06-25 11:58:49 +02:00
Frederic Bouvier
284aa3a444 Add header file to the cmake project 2012-06-25 11:58:22 +02:00
Frederic Bouvier
f0b7a27fd4 Duplicate light effect when animation is requested. Make dimmed lights work in multiplayer 2012-06-24 23:06:12 +02:00
ThorstenB
a781eea10e #744: Raise warning level when reporting missing svn library.
Status message are almost invisible - use warning message instead, so
builders/packagers actually notice a missing dependency.
Also add some useful hints.
2012-06-24 20:04:26 +02:00
ThorstenB
8e42e5bdba Fix error handling in SGSampleGroup::stop
Move error check to correct location: needs to be done immediately after
the alSourceStop call - and only if it was called at all.
2012-06-24 19:18:47 +02:00
James Turner
ad4a9eeaa5 Remove (un-maintained) MSVC projects from the tree prior to the next release. 2012-06-23 10:26:28 +02:00
Christian Schmitt
190e6b3958 Taxiway signs: print out more meaningful error messages on wrong size
settings and fall back to the default value in such cases.
2012-06-22 14:39:45 +02:00
James Turner
8a33223483 Use standard version of FindPackageStandardArgs, no need to copy it. 2012-06-21 10:21:26 +02:00
James Turner
0e4eab1569 Improve ALUT framework detection (for Mac)
Latest Xcode no longer searches /Library/Frameworks by default which exposed an issue here. Search for the header by the correct name to trigger special -F handling in cmake.
2012-06-20 19:44:16 +02:00
Stuart Buchanan
9d6e27c85c Do not attempt to reposition non-existant clouds.
Defensive workaround to Issue 678.
2012-06-19 22:04:17 +01:00
ThorstenB
9720f8ca16 Patch clean-up 2012-06-19 22:15:33 +02:00
Harald JOHNSEN
5b3dccc1f7 - stop sounds when removing a sound group 2012-06-19 22:14:14 +02:00
Markus Pargmann
e0df014acf Signs change <= to < 2012-06-18 20:47:05 +02:00
Markus Pargmann
de3d433ead Airport sign size 3 bugfix 2012-06-18 20:47:05 +02:00
Frederic Bouvier
3407db3dd6 Avoid an annoying OSG warning 2012-06-17 17:52:17 +02:00
Christian Schmitt
b10a40ff8d Taxiway signs: support all variants from the apt.dat 850 spec and
read size values from the optional stg column
2012-06-13 19:45:13 +02:00
Christian Schmitt
ec22623f1c Add helper method for optional stg values
Anders Gidenstam: Style and indentation.
2012-06-12 21:04:22 +02:00
Frederic Bouvier
7e8fb16507 Static or shared objects are not light volumes (but can include some) 2012-06-11 09:12:47 +02:00
Frederic Bouvier
a634d7c361 Terrain tiles are not light volumes 2012-06-11 09:11:52 +02:00
Harald JOHNSEN
aae77a7983 remove some warnings for MSVC
don't start to play sounds that are out of range of the listener
2012-06-08 15:23:54 +02:00
ThorstenB
3f6f34e7e1 Drop obsolete TODO 2012-06-08 13:53:15 +02:00
ThorstenB
eff1541ba3 Add INSTALL and README.cmake files. 2012-06-08 13:20:03 +02:00
Frederic Bouvier
e7e06c89e1 Fix lights when added as submodels 2012-05-31 20:22:40 +02:00
Frederic Bouvier
a41d5b1609 Restore lights in the Rembrandt renderer 2012-05-30 22:18:57 +02:00
James Turner
edbea633f3 Merge a tweak from Tat to keep Mac 10.5 from crashing on realpath 2012-05-30 11:08:11 +01:00
James Turner
950af5375c KIll of SimGear route code, it's no longer used by anything. 2012-05-30 11:07:36 +01:00
Stuart Buchanan
c6d2e32f05 Add logging for the total number of random buildings generated. 2012-05-25 19:47:45 +01:00
Mathias Froehlich
3796ce4d86 Runway signs: avoid adding empty group without signs. 2012-05-21 07:25:14 +02:00
Anders Gidenstam
ffb67f4014 Clement de l'Hamaide: Add support for pitch and roll for OBJECT_SHARED and OBJECT_STATIC in .stg files.
Pitch and roll behave the same as pitch-deg and roll-deg offsets in
model XML files.
2012-05-20 22:21:38 +02:00
Frederic Bouvier
d479686804 Try to exclude unwanted geometry in the additional light pass 2012-05-20 15:42:55 +02:00
Frederic Bouvier
1387f47a79 Remove redundant inclusion of SGMath.hxx 2012-05-20 11:49:31 +02:00
Frederic Bouvier
65784896e1 Revert "Hack to avoid redrawing the whole scene another time when only light volume are requested"
This reverts commit e692e7c119.
2012-05-19 20:41:58 +02:00
Frederic Bouvier
e692e7c119 Hack to avoid redrawing the whole scene another time when only light volume are requested 2012-05-19 19:39:38 +02:00
Mathias Froehlich
23d4628d88 ReaderWriterSPT: Cull out tiles that we look at from downside.
Add a cull callback that culls away complete tile areas that
we look at from the far away downside.
2012-05-19 16:09:58 +02:00
Frederic Bouvier
38c335c339 Allow to change texture buffer name on the fly 2012-05-18 12:27:08 +02:00
ThorstenB
e69d1b5a82 #767 related: fix sound resource management
Use _smgr->release_buffer instead of direct alDeleteBuffers.
2012-05-12 23:35:10 +02:00
Frederic Bouvier
6695b918ea Allow to specify buffer name from parameters in effects 2012-05-12 00:16:19 +02:00
Frederic Bouvier
2b9072417b Use names to identify deferred buffers
Change effect syntax for buffers
2012-05-12 00:16:17 +02:00
James Turner
6cf2224146 Updated sign case UV calculation from Christian. 2012-05-11 10:00:35 +01:00
James Turner
a1f74729ab build signs for an STG into single geometry. 2012-05-11 09:50:26 +01:00
James Turner
71443d1c9a Phase 1 - single geometry per material 2012-05-11 09:50:26 +01:00
Stuart Buchanan
a83f5deaac Updates to buildings and trees
1) Clean up after ourselves - remove memory leak
2) Face buildings the right way
2012-05-10 23:03:38 +01:00
Christian Schmitt
234e778e8f Add support for double-sided taxiway signs and create 3D models for them 2012-05-05 13:39:07 +02:00
Christian Schmitt
0bdeaeb4e2 Remove unused SGMakeRunwaySign function. 2012-05-05 13:39:07 +02:00
Frederic Bouvier
cc37713a66 Remove redundant inclusion of math/SGMath.hxx 2012-05-05 11:19:20 +02:00
ThorstenB
6129de31f0 Fix C compiler warning.
"no-overloaded-virtual" warnings are a CXX-compiler feature
2012-05-05 09:46:11 +02:00
ThorstenB
0908f86714 Fix rpmlint/Linux packager complaints
about outdated/invalid FSF address in some license headers.
2012-05-05 01:41:45 +02:00
ThorstenB
31ed79fe43 Fix rpmlint/Linux packager complaints
about outdated/invalid FSF address in some license headers.
2012-05-05 00:30:16 +02:00
ThorstenB
1af2ad12bf openSUSE "more architectures" patch
(Alpha anyone? ;-) )
2012-05-05 00:18:26 +02:00
ThorstenB
44db6d9e44 Move vector property templates to separate header file.
Fixes the "weirdness" with MSVC complaining about incomplete class specs,
since forward declarations (SGMathFwd.hxx) are used in props.hxx only.
Only the few extended (vector) property templates require including the
full SGMath.hxx (with MSVC) - and these are used in few places.
2012-05-05 00:07:07 +02:00
ThorstenB
6e662fe4d6 Ganael Laplanche: fix include dependencies for FreeBSD support 2012-05-04 23:24:10 +02:00
ThorstenB
067ff4f8ed Fix signed vs unsigned compiler warnings 2012-05-04 23:13:54 +02:00
Stuart Buchanan
91cf3d4def Fixes to Random Buildings:
1) Correct texture mapping so textures aren't flipped!
2) Add constraints to medium buildings (not taller than they are wide)
2012-05-04 21:12:41 +01:00
Frederic Bouvier
1eb846a93a Revert "Temporary hack to make the new version of expat build under windows"
A proper fix has been provided

This reverts commit 655971208f.
2012-05-04 20:48:04 +02:00
James Turner
56661afc05 Change how HAVE_EXPAT_CONFIG_H is defined, to hopefully fix MSVC properly. 2012-05-04 10:10:46 +01:00
Frederic Bouvier
655971208f Temporary hack to make the new version of expat build under windows 2012-05-04 09:09:11 +02:00
James Turner
d3ab2d3fbc Missed files from previous commit, needed for Windows. 2012-05-03 18:55:13 +01:00
James Turner
65aca6607e Update to latest expat for improved BOM / encoding handling.
(Related to http://code.google.com/p/flightgear-bugs/issues/detail?id=635)
2012-05-03 17:29:16 +01:00
Stuart Buchanan
e44eb39046 Emissive lighting for random buildings. Requires up to date fgdata. 2012-05-01 22:35:42 +01:00
ThorstenB
ab7d2a4bcc Allow "texture-path" XML entries to be present but empty.
This had worked with previous FG versions and is used by many models -
so it shouldn't be treated as an error now.
2012-04-30 18:29:44 +02:00
Frederic Bouvier
87c744b88b Use observer_ptr to cache light effects 2012-04-29 13:25:15 +02:00
Frederic Bouvier
dfc4b1564f Nasal is C code, not C++ 2012-04-29 00:17:38 +02:00
Stuart Buchanan
db6e99f885 Use Effects system for random buildings. 2012-04-28 23:11:52 +01:00
James Turner
35681e3adf Strange, somehow missed this file in last commit. 2012-04-28 23:08:05 +01:00
James Turner
a5ca531aac Nasal Ghosts can optionally specify member get/set functions. 2012-04-28 22:25:57 +01:00
Stuart Buchanan
2daf895d00 Reduce the number of Drawables generated by the random buildings by reducing the number of levels of the quad tree, and reducing the number of different
fade-out distances generated.
2012-04-28 20:02:42 +01:00
Stuart Buchanan
1041445a22 Change random object placement to a grid-like scheme to reduce building overlap. 2012-04-28 19:58:09 +01:00
Christian Schmitt
f712bc9294 Implement blinking hold-short line lights
This is supported by the apt.dat 850 format and latest TG
2012-04-26 15:02:33 +01:00
James Turner
2d174d0b14 Convert random buildings to avoid use of BIND_PER_PRIMITVE.
(which pushes me to a slow OSG path)
2012-04-26 00:18:47 +01:00
ThorstenB
dd54f6938e #717: Disabling advanced weather crashes the sim
Protect from a NULL-pointer segfault in SGCloudField::removeCloudFromTree
when disabling advanced weather (may just fix a symptom).
2012-04-25 21:08:37 +02:00
Frederic Bouvier
6e0e74a7d9 No round function for MSVC (forgot the template argument) 2012-04-25 08:59:04 +02:00
Frederic Bouvier
6a90696820 No round function for MSVC 2012-04-25 08:54:57 +02:00
Stuart Buchanan
f9bf403fc0 Random buildings - initial commit. 2012-04-24 22:00:35 +01:00
James Turner
0c13fb7ae4 Fix latent bug in Nasal hash cget / cset functions, where the embedded string length
was set to an incorrect marker value.
2012-04-23 22:29:54 +01:00
ThorstenB
9a113bdb44 Revert "Add virtual destructor to SGReferenced."
As suggested by Mathias, will use different solution.
This reverts commit 4abcf3215f.
2012-04-23 19:41:09 +02:00
James Turner
69ef461e6d Merge commit 'refs/merge-requests/22' of git://gitorious.org/fg/simgear into merge-requests/22 2012-04-23 12:21:50 +01:00
ThorstenB
4abcf3215f Add virtual destructor to SGReferenced. 2012-04-21 20:50:07 +02:00
Frederic Bouvier
4b607d6484 Revert "Remove ambient component of additional lights" because this was Yet Another Bad Idea
Ambient light is attenuated so it is possible to achieve smooth edges with it

This reverts commit fe8ba57c94.
2012-04-18 19:56:31 +02:00
Frederic Bouvier
fe8ba57c94 Remove ambient component of additional lights
It creates artifacts at edges of light volumes and should come from the main light source (sun and moon) anyway
2012-04-16 08:25:59 +02:00
Frederic Bouvier
de191107a9 light animation: avoid that similar effects are merged 2012-04-14 23:16:23 +02:00
Frederic Bouvier
77b8b278ea Ensure uniform are there before trying to use them 2012-04-14 18:00:42 +02:00
Frederic Bouvier
4758447370 Add a <dim-factor> parameter in the light animation
<dim-factor> contains a <property> element, and optionally <factor>,
<offset>, <expression>, <interpolation>, <min> and <max>
2012-04-14 09:57:20 +02:00
ThorstenB
77909577e4 Error messages when installing property aliases fails. 2012-04-05 20:03:07 +02:00
ThorstenB
1a835a2e1b performance monitor: start measurement interval with a fresh timestamp. 2012-04-05 19:30:00 +02:00
James Turner
8d0330675a Set the filename as the OSG object name on shaders - should have done this years ago :) 2012-04-04 16:44:23 +01:00
Frederic Bouvier
95a9d7a229 Revert "Disable LOD when rendering to the shadow map."
This reverts commit b95fb48a16.
2012-04-02 23:37:18 +02:00
ThorstenB
2fed46e222 performance monitor improvement
Record cumulative time consumed (all time) and current total time (current
measurement only) for subsystems.
2012-04-02 20:47:27 +02:00
ThorstenB
9ad070871a Use observer_ptr::lock for thread-safe pointer retrieval.
Also revert to using ref_ptr for the top-level EffectMap, since it holds
elements no one else references (and don't affect memory much).
2012-04-02 20:47:27 +02:00
Frederic Bouvier
b95fb48a16 Disable LOD when rendering to the shadow map.
Produce few NaNs at start
2012-04-01 23:06:32 +02:00
Mathias Froehlich
29462005b7 Fix typo in SGGeodesy.
Pointed out by Carl Godkin.
Thanks!
2012-04-01 17:50:49 +02:00
Frederic Bouvier
4de05629ee Shadow map now available in effects 2012-03-31 22:40:39 +02:00
ThorstenB
2b62411a78 Remove dead code. 2012-03-28 22:55:40 +02:00
ThorstenB
6fa4c7e138 Add file name to error message. 2012-03-28 22:54:27 +02:00
ThorstenB
ece38a6dbf Fix growing memory consumption issues
References in simgear's cache maps prevented effects, textures, clouds,
trees and lights from being unloaded at run-time (ref-counter could never
reach 0). Changed cache maps to use OSG 'observer' pointers instead, so
reference counters aren't influenced, though cache maps still hold an
(observing) pointer. Also take care when finding a cache entry with empty
content (i.e. texture was unloaded).
2012-03-28 22:53:30 +02:00
Mathias Froehlich
a592488f3e scenery: Remove redundant setting the property root.
The same value was extracted out of the same options value
in the code above. So, skip resetting to the same value.
2012-03-28 07:47:31 +02:00
Mathias Froehlich
191675cc79 scenery: Only run SGModelData in the topmost model.
It looks like that we loose the nasal script stored
in the property tree when this callback is issued
multiple times.

This should fix
 http://code.google.com/p/flightgear-bugs/issues/detail?id=714
2012-03-28 07:44:41 +02:00
Mathias Froehlich
df2e5bf39f Revert "scenery: Use correct property root in xml loading."
This helps for one symptom but it does not fix the
underlying problem. So ...

This reverts commit 986d2cc42a.
2012-03-28 07:34:36 +02:00
ThorstenB
ac29faf3bb osg::Uniform::get does not return a value on error.
Fixes "usage of uninitialized data" errors reported by valgrind.
2012-03-26 21:00:10 +02:00
Frederic Bouvier
94eabf6220 Merge Specular and Emission buffers 2012-03-25 14:14:14 +02:00
Frederic Bouvier
40bc0cbd48 Compile under MSVC 9 2012-03-25 14:14:12 +02:00
ThorstenB
b55e9df70a Don't crash when "avionics == NULL". 2012-03-22 23:54:01 +01:00
Mathias Froehlich
986d2cc42a scenery: Use correct property root in xml loading.
Really query for the root node when loading xml files.
This should fix
 http://code.google.com/p/flightgear-bugs/issues/detail?id=714
2012-03-22 08:38:16 +01:00
ThorstenB
0b8bfd9ed8 More checks/error messages for missing files,
checking return value of findDataFile.
2012-03-17 10:15:31 +01:00
ThorstenB
eff0c610e2 More consistent indentation. 2012-03-17 10:02:43 +01:00
ThorstenB
ca97e67511 Avoid segfault when a texture file is missing.
Always check the return value of "findDataFile". If it's empty, always
provide the _original_ path being searched in an error message. Otherwise
we eventually just get useless 'Can't find file "".' error messages
(and also a segfault here, since osgDB::readImageFile("") returns NULL).
2012-03-17 10:02:13 +01:00
James Goppert
47c2dce26d Removed include breaking headless build. 2012-03-16 23:04:24 +01:00
James Goppert
619163d40e Fixed mingw build. 2012-03-16 23:04:24 +01:00
Mathias Froehlich
b11c13fb9f scenery: Really, most people don't care for the noise. 2012-03-16 07:27:44 +01:00
Mathias Froehlich
a5435b7d8c scenery: Make stg loader files members of the loader. 2012-03-16 07:22:16 +01:00
Mathias Froehlich
b5fb829468 scenery: TileEntry and TileCache have moved back to flightgear. 2012-03-15 20:43:31 +01:00
Mathias Froehlich
43fceaf3a4 scenery: Move the stg read code.
Move the code reading the stg files
into ReaderWriterSTG.cxx.
2012-03-15 20:33:12 +01:00
Mathias Froehlich
8cb8395a24 scenery: ModelLoadHelper is no longer needed. 2012-03-15 20:08:38 +01:00
Mathias Froehlich
2a2be51b8f scenery: move static ReaderWriter proxies around.
Not yet sure where they end, but make sure they are currently pulled.
... now watching jenkins.
2012-03-15 19:45:51 +01:00
Mathias Froehlich
5a5d65134e scenery: Accumulate stg files until we find an OBJECT_BASE.
This should recover most of the old scenery loading behavior
before the last change. The z-fighting due to model duplication
does not happen over solid ground. Sea tiles are still broken.
2012-03-15 08:02:35 +01:00
Mathias Froehlich
0a96f4e145 scenery: Allow switching off particle systems on scenery load. 2012-03-11 14:20:33 +01:00
Mathias Froehlich
ba21713329 scenery: Allow switching off bvh generation. 2012-03-11 14:20:07 +01:00
Mathias Froehlich
32ef925a79 hla: Add convenience function to set version by string. 2012-03-11 09:21:47 +01:00
Mathias Froehlich
c62c778c88 hla: Enalble creating object instances without object class.
This enables creating HLAObjectInstance instances without
valid initial object class pointer. This is useful for local
implemented object instances.
2012-03-10 14:26:19 +01:00
Mathias Froehlich
2f0a6fdb67 hla: Remove old comment. 2012-03-10 08:30:02 +01:00
Torsten Dreyer
70ec13e10b Make the sky disable cutoff distance configurable 2012-03-09 20:58:24 +01:00
Mathias Froehlich
3693e3600c scenery: rework stg loading code.
This change reworks the code block loading the stg files.
It fixes a long standing problem where we end up loading
similar models from different entries of the scenery
path at the same geographic location. This usually results
in models that appear to have z figting, even if the isolated
model does not show z fighting at all.
As a result the lookup sequence for models and scenery has
changed a bit. This should be closer to what it supposed to
be and did not show any problems on the areas and sceneries
I tested.
2012-03-08 07:15:14 +01:00
Frederic Bouvier
69debc6777 Revert "Put airport lights in RenderBin to enable glow"
This reverts commit 1fa27f2d19.
2012-03-07 20:48:53 +01:00
Frederic Bouvier
84d7488061 Revert commit 7864516... Increase point sprite size for runway lights 2012-03-07 20:16:14 +01:00
Mathias Froehlich
fbb7c84409 scenery: Remove unused argument from runway signs. 2012-03-07 06:36:27 +01:00
Frederic Bouvier
a7379c88f4 Revert "Allow the not operator in expressions" - this is not required for
effects

This reverts commit 92074f0d3c.
2012-03-06 23:15:18 +01:00
Mathias Froehlich
cc8977b83d hla: include config.h and compiler.h in implementation files. 2012-03-05 06:59:37 +01:00
Mathias Froehlich
50380bc6c5 hla: Provide access to the parent federate. 2012-03-04 21:35:16 +01:00
Frederic Bouvier
92074f0d3c Allow the not operator in expressions 2012-03-04 21:24:54 +01:00
Frederic Bouvier
1e889c4d07 Implement point light 2012-03-04 20:21:52 +01:00
Frederic Bouvier
617a09d89a Fix path in include directive 2012-03-04 20:21:51 +01:00
Frederic Bouvier
2af409f54d Save work on shadows 2012-03-04 20:21:49 +01:00
Frederic Bouvier
6d3766e913 Move noise functions from scene/material to scene/util 2012-03-04 20:21:47 +01:00
Frederic Bouvier
9b130f099f Move Noise from scene/material to scene/util 2012-03-04 20:21:46 +01:00
Frederic Bouvier
20414e6ef4 Smaller point light for vasi 2012-03-04 20:21:44 +01:00
Frederic Bouvier
78645169bf Increase point sprite size for runway lights 2012-03-04 20:21:42 +01:00
Frederic Bouvier
a276e7e379 Remove now useless StateAttributeFactory::getNoiseNormalMap() 2012-03-04 20:21:41 +01:00
Frederic Bouvier
1dfde64ac2 Use bigger point sprites for airport lighting 2012-03-04 20:21:39 +01:00
Frederic Bouvier
1fa27f2d19 Put airport lights in RenderBin to enable glow 2012-03-04 20:21:37 +01:00
Frederic Bouvier
2822006d01 New buffer types for effects 2012-03-04 20:21:36 +01:00
Frederic Bouvier
288e63f0d8 Add noise texture and noise normal map to StateAttributeFactory 2012-03-04 20:21:34 +01:00
Frederic Bouvier
66c9187c95 Boolean uniforms are now updatable by properties 2012-03-04 20:21:32 +01:00
Frederic Bouvier
cbf8687e3d Add bloom buffer to effects 2012-03-04 20:21:31 +01:00
Frederic Bouvier
c9a80caff5 Create new buffer type : emission 2012-03-04 20:21:29 +01:00
Frederic Bouvier
f9857235fc Add new texture type in effects : lighting-buffer 2012-03-04 20:21:27 +01:00
Frederic Bouvier
c595a276a0 Include the light volume in the model 2012-03-04 20:21:26 +01:00
Frederic Bouvier
b582cd230e Implement a cache of light effects 2012-03-04 20:21:24 +01:00
Frederic Bouvier
ad6c04489c Add the light animation to the cmake system 2012-03-04 20:21:22 +01:00
Frederic Bouvier
ec7e59eda1 Full implementation of the spotlight by Effects 2012-03-04 20:21:21 +01:00
Frederic Bouvier
d929323e93 Add light animation to msvc9 project 2012-03-04 20:21:19 +01:00
Frederic Bouvier
5a96b283f6 Add preliminary spot light animation 2012-03-04 20:21:18 +01:00
Frederic Bouvier
d393e4a019 Add positioned uniforms and G-buffer textures to Effects 2012-03-04 20:21:16 +01:00
Mathias Froehlich
9700e46e47 spt: Make use of newly provided earth texture. 2012-03-04 20:10:22 +01:00
Mathias Froehlich
036c0034c3 hla: Fix the way derived classes accumulate attributes. 2012-03-04 19:56:43 +01:00
Mathias Froehlich
f5067b058c scenery: Do not use a seperate set of options for loading the model.
This fixes a problem introduced in commit
4e24095d8b.
Also this should fix Bug #698.
2012-03-04 17:09:24 +01:00
Mathias Froehlich
0d9b247da1 scenery: Only add trasnform matrices on successful loaded models. 2012-03-04 13:07:41 +01:00
Frederic Bouvier
a2b75e0d7a Compile SGReaderWriterOptions.cxx under Windows 2012-03-04 10:36:31 +01:00
Mathias Froehlich
c9165a565b Use an implementation file for SGReaderWriterOptions. 2012-03-04 08:40:56 +01:00
Mathias Froehlich
49d8b96768 Centralize osgDB::Option handling in SGReaderWriterOptions. 2012-03-04 08:33:21 +01:00
Mathias Froehlich
5ad6eb937b Make use of SGReaderWriterOptions::copyOrCreate in SGModelLib 2012-03-04 08:17:10 +01:00
Mathias Froehlich
f66e023ea8 Make use of SGReaderWriterOptions::copyOrCreate in SGMaterial. 2012-03-04 08:15:00 +01:00
Mathias Froehlich
72f1538ac2 Make use of SGReaderWriterOptions::copyOrCreate in ReaderWriterSTG. 2012-03-04 07:50:05 +01:00
Mathias Froehlich
4e24095d8b Make use of SGReaderWriterOptions::copyOrCreate in SGReaderWriterXML. 2012-03-04 07:42:31 +01:00
Mathias Froehlich
1473eabc7c Provide SGReaderWriterOptions::copyOrCreate(const osgDB::Options*).
This functions tries to preserve the database options as much
as possible and guarantees to return a non zero options
pointer.
2012-03-04 07:42:31 +01:00
Mathias Froehlich
11fd888ed8 Replace osgDB::ReaderWriter::Options to osgDB::Options.
This has changed in osg, so reflect that here.
2012-03-04 07:07:42 +01:00
Mathias Froehlich
8c78588ee1 Untangle osg singleton dependencies.
Take two. The ModelRegistry's are already derived from osg::Referenced.
So also introduce the osg dependent version in simgear/scene/util.
2012-03-03 18:57:48 +01:00
Mathias Froehlich
c74e212494 Revert "Use simgear internal stuff for the singleton class."
This reverts commit 80274596df.
2012-03-03 18:21:49 +01:00
ThorstenB
13f96cdcc9 Dir::tempDir not working on some systems.
Only worked when TMPDIR environment variable had a trailing slash (i.e.
"/tmp/" worked, but not "/tmp").
(Problem shown by simgear's "test suite". It's good to have tests!)
2012-03-03 17:06:51 +01:00
Mathias Froehlich
86e32035d7 Remove left over from osg/core dependencies.
This file should be obsolete doe to the latest changes.
2012-03-03 16:06:51 +01:00
Mathias Froehlich
80274596df Use simgear internal stuff for the singleton class.
This removes the other still present dependency on osg
in the future sgcore library.
It also remove the need for the NO_OPENSCENEGRAPH_INTERFACE
compile time definition.
2012-03-03 14:39:39 +01:00
Mathias Froehlich
2cc5e776b3 math: Remove SGMath osg dependency.
Move osg dependent stuff from SGMath into simgear/scene/util/OsgMath.hxx.
Update includes in simgear to reflect this change.
Note that this change also requires an updated flightgear version.
2012-03-03 13:35:20 +01:00
Mathias Froehlich
57a3b0fd1e math: Move lerp function into SGMisc. 2012-03-03 12:03:09 +01:00
Mathias Froehlich
9414874e1d scenery: inline SGGenTile into its single caller. 2012-03-03 12:03:09 +01:00
Mathias Froehlich
9e46820c57 scenery: Route loader options through the btg loader. 2012-03-03 12:03:09 +01:00
Stuart Buchanan
3020990121 Evaluate <condition> statements in materials.xml at tile loading time
rather than on startup.  This will allow changing between winter and
summer textures in-sim, and also allow more interesting regional
textures to be defined.
2012-03-02 23:04:18 +00:00
Mathias Froehlich
27219e0f58 hla: Fix timeAdvanceAvailable handling when no federate is regulating. 2012-03-02 22:25:47 +01:00
Mathias Froehlich
098441f5fb hla: Add propper attribute dirty handling. 2012-03-02 21:51:59 +01:00
Mathias Froehlich
a07ca86207 hla: Timestamp support down to the DataElements. 2012-03-02 21:36:08 +01:00
Stuart Buchanan
e4e3760b3d Fix masked rotation so that it's clockwise from above. 2012-02-28 21:05:54 +00:00
ThorstenB
811147d08e Fix string comparison 2012-02-28 08:39:19 +01:00
Mathias Froehlich
a563cfd0f2 hla: Fix buffer overrun in SGMath vector types. 2012-02-28 07:19:21 +01:00
Mathias Froehlich
92f7445bb9 hla: Rework toplevel HLA classes.
Better seperation between the rti and the hla level
of classes. Decouple object model setup from the
need to connect at a federate. Fix alignment computations
for the standard hla data types. Work towards an
interaction class abstraction. Add more flexibility in
deriving from the base classes and adding callbacks.
2012-02-28 07:16:11 +01:00
Stuart Buchanan
a72d858034 More robust checking of file extensions courtesy of the SGPath. Thanks to Mathias FROHLICH. 2012-02-27 21:27:27 +00:00
Stuart Buchanan
39d45e9e0a Handle dds object masks properly:
1) Only flip the object-mask if the texture xor the object mask is dds
2) Handle NTFS file systems where the extension may be .DDS rather than .dds.
2012-02-26 22:38:38 +00:00
Stuart Buchanan
4fae9039c1 Correct spacing between buildings. 2012-02-26 22:38:04 +00:00
Mathias Froehlich
124db3da8e hla: Introduce backend factory infrastructure.
Not finally ready, but provide a factory infrastructure
to improove plugability of different rti backend implementations.
2012-02-26 08:50:06 +01:00
ThorstenB
4bf4091ef7 Remove obsolete comment... 2012-02-24 22:47:18 +01:00
ThorstenB
b7fa1d4f02 #537 linker issues due to clock_gettime/librt dependencies
Simplify dependency check and make it work for Debian.
2012-02-24 22:20:37 +01:00
ThorstenB
f1c2afacc4 Revert "Try to fix MSVC template instantiation issue with SGVec dependencies."
This reverts commit 8aed0e75df.
2012-02-24 22:00:58 +01:00
ThorstenB
8aed0e75df Try to fix MSVC template instantiation issue with SGVec dependencies. 2012-02-24 21:47:00 +01:00
Stuart Buchanan
cf2619613d Stop objects from overlapping the edge of the triangle in which they are placed. This should stop buildings encroaching roads etc. 2012-02-23 20:10:02 +00:00
ThorstenB
2a9d39f201 Allow (ab)using findDataFile to also search directories again. 2012-02-19 14:39:19 +01:00
ThorstenB
ae0b8eb3b3 Make tsync part of libSimGearCore when building shared libraries 2012-02-19 14:39:19 +01:00
Mathias Froehlich
63081c94a1 hla: Add new header containing some enums. 2012-02-18 17:13:45 +01:00
Mathias Froehlich
c39926dd72 hla: Rename AttributePathPair to StringPathPair.
This way of addressing attribute data elements
should also be used for parameters. So, name it a little
more neutral.
2012-02-18 16:49:17 +01:00
Mathias Froehlich
4683e7e9c9 hla: Do not introduce an empty enumerated data type.
This fixes a bogous enumerated data type that is
up to now introduced into the data type map.
2012-02-18 13:20:25 +01:00
Mathias Froehlich
dc9163f801 hla: rename HLAVariantData* to HLAVariantRecordData*
Rename to the true name that is used in the standard.
2012-02-18 11:44:00 +01:00
Mathias Froehlich
42cc699263 HLAFederate: introduce read*ObjectModelTemplate.
Introduce read{RTI13,RTI1516,RTI1516E}ObjectModelTemplate
methods. Deprecate the current readObjectModelTemplate method
and provide a short term upgrade path.
2012-02-18 11:00:28 +01:00
ThorstenB
37457fcb33 Remove obsolete ignore pattern for automake generated headers. 2012-02-17 23:46:06 +01:00
Torsten Dreyer
441dc41715 Don't untie a property when loading from xml
executing the fgcommand loadxml implicitely untied every previously
tied property if a property type was given in the property element.
That made it impossible to autosave aircraft data for tied properties.
This patch should fix this. It adds an inconsitency, though:
if a property with a given type is read in which has been tied to
before and the property types do not match, the property type in the
xml file will be ignored.
2012-02-15 14:54:02 +01:00
ThorstenB
811f156ad1 #658: better bugfix for findDataFile issue
Fixes the more basic probelm of "SGModelLib::findDataFile" resolving an
empty file name to the fgdata (directory) path. findData_File_ should
never return a _directory_ path, only valid _file_ names.
2012-02-11 10:55:13 +01:00
ThorstenB
2a0e9d31e1 #658: avoid crash when Textures.high is missing
Don't resolve the empty file name, which would result in the fgdata
directory path (instead of a path to a file). Eventually this resulted in
a segfault, partly due to a bug in "osgDB::readImageFile", which reports
"success" when given a directory (instead of a file) path, though it
doesn't return a valid image object.
2012-02-11 10:00:03 +01:00
Stuart Buchanan
c473cd7213 Fall back to taking tree textures from Terrain/ if they are not found under
Terrain.high, consistent with the other textures in materials.xml.

Also fix comment.
2012-02-10 22:49:20 +00:00
Olaf Flebbe
1af8aacd1d disable annoying clang warning 2012-02-10 22:42:27 +01:00
ThorstenB
5eb9acd8b6 Olaf Flebbe: Avoid infinite recursion in simgear::Dir::create
when using it with a relative path.
2012-02-10 22:42:27 +01:00
Stuart Buchanan
6bc9eb950f Retire tree-density and wood-size, as they have been superseded by object masking. 2012-02-07 21:12:41 +00:00
Stuart Buchanan
593c884f14 Random object and vegetation masking based on bitmap file.
Also adds a property controlling vegetation density.
2012-02-05 23:05:57 +00:00
ThorstenB
9d20de068c Move JPEG dependency
Alas, JPEG_FACTORY is in SimGearScene, not SimGearCore...
2012-01-29 14:39:48 +01:00
ThorstenB
96c2e4d3ab Correct dependency of shared simgear libraries with enabled JPEG_FACTORY. 2012-01-29 14:28:49 +01:00
Mathias Froehlich
165d2ea978 Improve the compressed texture message. 2012-01-19 07:34:47 +01:00
Stuart Buchanan
0702272097 Switch Impostors off by default, set reasonabl LOD and Impostor ranges. 2012-01-17 22:15:14 +00:00
Stuart Buchanan
965c8ccfd2 Improved 3D clouds
1) Impostors
2) One drawable per cloud rather than a single drawable shared by all clouds.
2012-01-17 22:14:57 +00:00
Torsten Dreyer
b20a49b018 bump version number to 2.7.0 2012-01-17 08:35:57 +01:00
511 changed files with 43182 additions and 15202 deletions

5
.gitignore vendored
View File

@@ -1,6 +1,5 @@
.*
Makefile
INSTALL
SimGear.spec
*.o
lib*.a
.*.swp
@@ -12,5 +11,5 @@ CPackSourceConfig.cmake
cmake_uninstall.cmake
CTestTestfile.cmake
install_manifest.txt
build
build*
Build

View File

@@ -13,6 +13,14 @@ string(STRIP ${versionFile} SIMGEAR_VERSION)
# use simgear version also as the SO version (if building SOs)
SET(SIMGEAR_SOVERSION ${SIMGEAR_VERSION})
# Warning when build is not an out-of-source build.
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" InSourceBuild)
if(InSourceBuild)
message(WARNING "Avoid building inside the source tree!")
message(WARNING "Create a separate build directory instead (i.e. 'sgbuild') and call CMake from there: ")
message(WARNING " mkdir ../sgbuild && cd ../sgbuild && cmake ${CMAKE_SOURCE_DIR}")
endif(InSourceBuild)
#packaging
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
@@ -60,12 +68,48 @@ else(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
message(STATUS "Library installation directory: ${CMAKE_INSTALL_LIBDIR}")
option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
#####################################################################################
# Configure library search paths
#####################################################################################
if(NOT "${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "")
# Workaround for Ubuntu/Debian which introduced the "multiarch" library
# directory structure, which is unsupported by CMake < 2.8.10, so we need to
# add paths manually
# see http://www.cmake.org/Bug/view.php?id=12049 and
# http://www.cmake.org/Bug/view.php?id=12037
list(APPEND ADDITIONAL_LIBRARY_PATHS
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/lib/${CMAKE_LIBRARY_ARCHITECTURE})
message(STATUS "additional library directories: ${ADDITIONAL_LIBRARY_PATHS}")
endif()
if(NOT MSVC)
# TBD: are these really necessary? Aren't they considered by cmake automatically?
list(APPEND ADDITIONAL_LIBRARY_PATHS
/opt/local
/usr/local
/usr)
endif()
#####################################################################################
if (NOT MSVC)
option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
option(SYSTEM_EXPAT "Set to ON to build SimGear using the system libExpat" OFF)
else()
# Building SimGear DLLs is currently not supported for MSVC.
set(SIMGEAR_SHARED OFF)
# Using a system expat is currently not supported for MSVC - it would require shared simgear (DLL).
set(SYSTEM_EXPAT OFF)
endif()
option(SIMGEAR_HEADLESS "Set to ON to build SimGear without GUI/graphics support" OFF)
option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
option(ENABLE_LIBSVN "Set to ON to build SimGear with libsvnclient support" ON)
option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON)
option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
option(ENABLE_LIBSVN "Set to ON to build SimGear with libsvnclient support" ON)
option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON)
option(ENABLE_SOUND "Set to OFF to disable building SimGear's sound support" ON)
if (MSVC)
GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH)
@@ -86,11 +130,13 @@ endif (MSVC)
if (MSVC AND MSVC_3RDPARTY_ROOT)
message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
set( OSG_MSVC "msvc" )
if (${MSVC_VERSION} EQUAL 1600)
if (${MSVC_VERSION} EQUAL 1700)
set( OSG_MSVC ${OSG_MSVC}110 )
elseif (${MSVC_VERSION} EQUAL 1600)
set( OSG_MSVC ${OSG_MSVC}100 )
else (${MSVC_VERSION} EQUAL 1600)
else (${MSVC_VERSION} EQUAL 1700)
set( OSG_MSVC ${OSG_MSVC}90 )
endif (${MSVC_VERSION} EQUAL 1600)
endif (${MSVC_VERSION} EQUAL 1700)
if (CMAKE_CL_64)
set( OSG_MSVC ${OSG_MSVC}-64 )
set( MSVC_3RDPARTY_DIR 3rdParty.x64 )
@@ -98,57 +144,100 @@ if (MSVC AND MSVC_3RDPARTY_ROOT)
set( MSVC_3RDPARTY_DIR 3rdParty )
endif (CMAKE_CL_64)
set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib )
set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include)
set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/lib )
set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/include)
find_path(BOOST_ROOT boost/version.hpp
${MSVC_3RDPARTY_ROOT}/boost
${MSVC_3RDPARTY_ROOT}/boost_1_52_0
${MSVC_3RDPARTY_ROOT}/boost_1_51_0
${MSVC_3RDPARTY_ROOT}/boost_1_50_0
${MSVC_3RDPARTY_ROOT}/boost_1_49_0
${MSVC_3RDPARTY_ROOT}/boost_1_48_0
${MSVC_3RDPARTY_ROOT}/boost_1_47_0
${MSVC_3RDPARTY_ROOT}/boost_1_46_1
${MSVC_3RDPARTY_ROOT}/boost_1_46_0
${MSVC_3RDPARTY_ROOT}/boost_1_45_0
${MSVC_3RDPARTY_ROOT}/boost_1_44_0
)
# set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
message(STATUS "BOOST_ROOT is ${BOOST_ROOT}")
set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
set (ALUT_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
endif (MSVC AND MSVC_3RDPARTY_ROOT)
find_package(Boost REQUIRED)
set (BOOST_CXX_FLAGS "-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION")
find_package(ZLIB REQUIRED)
find_package(Threads REQUIRED)
if(SIMGEAR_HEADLESS)
message(STATUS "headless mode")
set(NO_OPENSCENEGRAPH_INTERFACE 1)
message(STATUS "SimGear mode: HEADLESS")
set(ENABLE_SOUND 0)
else()
message(STATUS "SimGear mode: NORMAL")
find_package(OpenGL REQUIRED)
find_package(OpenAL REQUIRED)
find_package(ALUT REQUIRED)
find_package(OpenSceneGraph 3.0.0 REQUIRED osgText osgSim osgDB osgParticle osgUtil)
if (ENABLE_SOUND)
find_package(OpenAL REQUIRED)
message(STATUS "Sound support: ENABLED")
endif(ENABLE_SOUND)
find_package(OpenSceneGraph 3.0.0 REQUIRED osgText osgSim osgDB osgParticle osgGA osgUtil)
endif(SIMGEAR_HEADLESS)
if(JPEG_FACTORY)
message(STATUS "JPEG-factory enabled")
message(STATUS "JPEG-factory: ENABLED")
find_package(JPEG REQUIRED)
include_directories(${JPEG_INCLUDE_DIR})
else()
message(STATUS "JPEG-factory: DISABLED")
endif(JPEG_FACTORY)
if(ENABLE_LIBSVN)
find_package(SvnClient)
find_package(SvnClient)
if(LIBSVN_FOUND)
message(STATUS "libsvn found, enabling in SimGear")
set(HAVE_SVN_CLIENT_H 1)
set(HAVE_LIBSVN_CLIENT_1 1)
else()
message(STATUS "Missing libsvn, unable to enable SVN in SimGear")
endif(LIBSVN_FOUND)
if(LIBSVN_FOUND)
message(STATUS "Subversion client support: ENABLED")
set(HAVE_SVN_CLIENT_H 1)
set(HAVE_LIBSVN_CLIENT_1 1)
else()
# Oops. ENABLE_LIBSVN is ON, but svn is still missing.
# Provide clearly visible warning/hint, so builders know what else they should install (or disable).
message(WARNING "Failed to enable subversion client support. Unable to find required subversion client library. Some features may not be available (scenery download).")
message(WARNING "Install 'libsvn' library/DLL (libsvn-devel/libsvnclient/...). Otherwise disable subversion support (set 'ENABLE_LIBSVN' to 'OFF').")
endif(LIBSVN_FOUND)
else()
message(STATUS "Subversion client support: DISABLED")
endif(ENABLE_LIBSVN)
find_package(ZLIB REQUIRED)
find_package(Threads REQUIRED)
if (SYSTEM_EXPAT)
message(STATUS "Requested to use system Expat library, forcing SIMGEAR_SHARED to true")
set(SIMGEAR_SHARED ON)
find_package(EXPAT REQUIRED)
include_directories(${EXPAT_INCLUDE_DIRS})
else()
message(STATUS "Using built-in expat code")
add_definitions(-DHAVE_EXPAT_CONFIG_H)
endif(SYSTEM_EXPAT)
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(windows.h HAVE_WINDOWS_H)
if(HAVE_INTTYPES_H)
# ShivaVG needs inttypes.h
add_definitions(-DHAVE_INTTYPES_H)
endif()
if(ENABLE_RTI)
# See if we have any rti library variant installed
# See if we have any rti library variant installed
message(STATUS "RTI: ENABLED")
find_package(RTI)
else()
message(STATUS "RTI: DISABLED")
endif(ENABLE_RTI)
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
@@ -156,6 +245,8 @@ check_function_exists(ftime HAVE_FTIME)
check_function_exists(timegm HAVE_TIMEGM)
check_function_exists(rint HAVE_RINT)
check_function_exists(mkdtemp HAVE_MKDTEMP)
check_function_exists(bcopy HAVE_BCOPY)
check_function_exists(mmap HAVE_MMAP)
if(HAVE_UNISTD_H)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
@@ -167,18 +258,15 @@ if(HAVE_UNISTD_H)
int main() { return 0; }
"
HAVE_CLOCK_GETTIME)
HAVE_CLOCK_GETTIME)
endif(HAVE_UNISTD_H)
set(RT_LIBRARY "")
if(HAVE_CLOCK_GETTIME)
check_function_exists(clock_gettime CLOCK_GETTIME_IN_LIBC)
if(NOT CLOCK_GETTIME_IN_LIBC)
check_library_exists(rt clock_gettime "" HAVE_RT)
if(HAVE_RT)
set(RT_LIBRARY rt)
endif(HAVE_RT)
endif(NOT CLOCK_GETTIME_IN_LIBC)
check_library_exists(rt clock_gettime "" HAVE_RT)
if(HAVE_RT)
set(RT_LIBRARY rt)
endif(HAVE_RT)
endif(HAVE_CLOCK_GETTIME)
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually 'd' on windows")
@@ -192,9 +280,15 @@ check_cxx_source_compiles(
void f() { isnan(0.0);} "
HAVE_ISNAN)
check_cxx_source_compiles(
"#include <cmath>
void f() { std::isnan(0.0);} "
HAVE_STD_ISNAN)
if(CMAKE_COMPILER_IS_GNUCXX)
set(WARNING_FLAGS -Wall)
set(WARNING_FLAGS_CXX "-Wall")
set(WARNING_FLAGS_C "-Wall")
# certain GCC versions don't provide the atomic builds, and hence
# require is to provide them in SGAtomic.cxx
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
@@ -203,15 +297,24 @@ if(CMAKE_COMPILER_IS_GNUCXX)
GCC_ATOMIC_BUILTINS_FOUND)
endif(CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(WARNING_FLAGS_CXX "-Wall -Wno-overloaded-virtual")
set(WARNING_FLAGS_C "-Wall")
endif()
if(WIN32)
if(MINGW)
add_definitions(-D_WIN32_WINNT=0x501)
endif()
if(MSVC)
# turn off various warnings
# foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
# SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
# endforeach(warning)
set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /wd4996")
set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /wd4996 /wd4250")
endif(MSVC)
# assumed on Windows
@@ -219,18 +322,19 @@ if(WIN32)
set( WINSOCK_LIBRARY "ws2_32.lib" )
set( RT_LIBRARY "winmm" )
endif(WIN32)
endif(WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS_C} ${MSVC_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_CXX} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}")
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include)
include_directories(${PROJECT_BINARY_DIR}/simgear)
include_directories(${PROJECT_BINARY_DIR}/simgear/xml)
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}
${ALUT_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} )
${OPENAL_INCLUDE_DIR} )
add_definitions(-DHAVE_CONFIG_H)
@@ -241,11 +345,19 @@ configure_file (
"${PROJECT_BINARY_DIR}/simgear/simgear_config.h"
)
if(ENABLE_TESTS)
# enable CTest / make test target
configure_file (
"${PROJECT_SOURCE_DIR}/simgear/xml/expat_config_cmake.in"
"${PROJECT_BINARY_DIR}/simgear/xml/expat_config.h"
)
include (Dart)
enable_testing()
if(ENABLE_TESTS)
# enable CTest / make test target
message(STATUS "Tests: ENABLED")
include (Dart)
enable_testing()
else()
message(STATUS "Tests: DISABLED")
endif(ENABLE_TESTS)
install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h DESTINATION include/simgear/)
@@ -260,4 +372,3 @@ CONFIGURE_FILE(
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

View File

@@ -1,67 +0,0 @@
# Locate ALUT
# This module defines
# ALUT_LIBRARY
# ALUT_FOUND, if false, do not try to link to ALUT
# ALUT_INCLUDE_DIR, where to find the headers
#
# $ALUTDIR is an environment variable that would
# correspond to the ./configure --prefix=$ALUTDIR
# used in building ALUT.
#
# Created by James Turner. This was influenced by the FindOpenAL.cmake module.
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
# Per my request, CMake should search for frameworks first in
# the following order:
# ~/Library/Frameworks/OpenAL.framework/Headers
# /Library/Frameworks/OpenAL.framework/Headers
# /System/Library/Frameworks/OpenAL.framework/Headers
#
# On OS X, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of
# OPENAL_LIBRARY to override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.
FIND_PATH(ALUT_INCLUDE_DIR alut.h
HINTS
$ENV{ALUTDIR}
PATH_SUFFIXES include/AL include/ALUT include
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/opt
)
FIND_LIBRARY(ALUT_LIBRARY
NAMES ALUT alut
HINTS
$ENV{ALUTDIR}
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/opt
)
SET(ALUT_FOUND "NO")
IF(ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
SET(ALUT_FOUND "YES")
ENDIF(ALUT_LIBRARY AND ALUT_INCLUDE_DIR)

View File

@@ -16,14 +16,20 @@ macro(find_static_component comp libs)
string(TOUPPER "${comp}" compLibBase)
set( compLibName ${compLibBase}_LIBRARY )
# NO_DEFAULT_PATH is important on Mac - we need to ensure subversion
# libraires in dist/ or Macports are picked over the Apple version
# in /usr, since that's what we will ship.
# On other platforms we do need default paths though, i.e. since Linux
# distros may use architecture-specific directories (like
# /usr/lib/x86_64-linux-gnu) which we cannot hardcode/guess here.
FIND_LIBRARY(${compLibName}
if(APPLE)
NO_DEFAULT_PATH
endif(APPLE)
NAMES ${compLib}
HINTS $ENV{PLIBDIR}
HINTS $ENV{LIBSVN_DIR} ${CMAKE_INSTALL_PREFIX} ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
PATHS
/usr/local
/usr
/opt
PATHS ${ADDITIONAL_LIBRARY_PATHS}
)
list(APPEND ${libs} ${${compLibName}})
@@ -49,13 +55,14 @@ endif(HAVE_APR_CONFIG)
if(HAVE_APR_CONFIG OR MSVC)
find_path(LIBSVN_INCLUDE_DIR svn_client.h
NO_DEFAULT_PATH
HINTS
$ENV{LIBSVN_DIR}
$ENV{LIBSVN_DIR} ${CMAKE_INSTALL_PREFIX} ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include
PATH_SUFFIXES include/subversion-1
PATHS
/opt/local
/usr/local
/usr
/opt
)
set(LIBSVN_LIBRARIES "")

View File

@@ -1,23 +1,21 @@
macro(simgear_component_common name includePath sourcesList sources headers)
if (SIMGEAR_SHARED)
set(fc${sourcesList} ${name})
set(fh${sourcesList} ${name})
foreach(s ${sources})
set_property(GLOBAL
APPEND PROPERTY ${sourcesList} "${CMAKE_CURRENT_SOURCE_DIR}/${s}")
set(fc${sourcesList} "${fc${sourcesList}}#${CMAKE_CURRENT_SOURCE_DIR}/${s}")
endforeach()
foreach(s ${sources})
set_property(GLOBAL
APPEND PROPERTY ${sourcesList} "${CMAKE_CURRENT_SOURCE_DIR}/${s}")
endforeach()
foreach(h ${headers})
set_property(GLOBAL
APPEND PROPERTY PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${h}")
set(fh${sourcesList} "${fh${sourcesList}}#${CMAKE_CURRENT_SOURCE_DIR}/${h}")
endforeach()
foreach(h ${headers})
set_property(GLOBAL
APPEND PROPERTY PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${h}")
endforeach()
else()
set(libName "sg${name}")
add_library(${libName} STATIC ${sources} ${headers})
install (TARGETS ${libName} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
set_property(GLOBAL APPEND PROPERTY FG_GROUPS_${sourcesList}_C "${fc${sourcesList}}@")
set_property(GLOBAL APPEND PROPERTY FG_GROUPS_${sourcesList}_H "${fh${sourcesList}}@")
install (FILES ${headers} DESTINATION include/simgear/${includePath})
endmacro()

View File

@@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -464,7 +464,7 @@ convey the exclusion of warranty; and each file should have at least the
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Also add information on how to contact you by electronic and paper mail.

56
INSTALL Normal file
View File

@@ -0,0 +1,56 @@
How to build SimGear
====================
SimGear uses the CMake build system to generate a platform-specific
build environment. CMake reads the CMakeLists.txt files that you'll
find throughout the source directories, checks for installed
dependencies and then generates the appropriate build system.
If you don't already have CMake installed on your system you can grab
it from http://www.cmake.org, use version 2.6.4 or later.
Under unices (i.e. Linux, Solaris, Free-BSD, HP-Ux, OSX) use the cmake
or ccmake command-line utils. Preferably, create an out-of-source
build directory and run cmake or ccmake from there. The advantage to
this approach is that the temporary files created by CMake won't
clutter the source directory, and also makes it possible to have
multiple independent build targets by creating multiple build
directories. In a directory alongside the SimGear source directory
use:
mkdir sgbuild
cd sgbuild
cmake ../simgear -DCMAKE_BUILD_TYPE=Release
make
sudo make install
Build Dependencies
==================
SimGear depends on a number of 3rd party libraries, the most notable
being:
* OpenSceneGraph (OSG) - see README.OSG
* zlib compression library - see README.zlib
* Open Audio Library (OpenAL) - see README.OpenAL
* Subversion Client Library (optional dependency)
Further information
===================
* README.cmake
for more detailed CMake instructions
* README.msvc
in the FlightGear source package for more Windows-specific instructions
* FlightGear Wiki
http://wiki.flightgear.org/Building_Flightgear
* FlightGear Forums
For help on building see: http://www.flightgear.org/forums
=> Support/Compiling
* FlightGear Mailing lists
http://wiki.flightgear.org/index.php/Mailing_list

16
README
View File

@@ -1 +1,15 @@
[ Nothing here at this time. ]
SimGear - Simulator Construction Tools
======================================
http://www.flightgear.org
SimGear is a set of open-source libraries designed to be used as building
blocks for quickly assembling 3d simulations, games, and visualization
applications.
SimGear is developed by the FlightGear project and also provides the base
for the FlightGear Flight Simulator.
Source code for SimGear is released under the GNU Library General Public
License (LGPL) - see COPYING for license details.
See INSTALL file for help on building SimGear.

View File

@@ -3,7 +3,7 @@
You *must* have OpenSceneGraph (OSG) installed to build this version of
FlightGear.
Notice that FlightGear 2.6.0 requires at least version 3.0.0.
Notice that this version of SimGear/FlightGear requires at least OSG 3.0.0.
You can get the latest version of OSG from:

View File

@@ -18,12 +18,3 @@ ccmake .
then press 'g' to generate and exit ]
The alut library is also required, but comes separately in the package
freelut-1.1.0.tar.gz. This package can be downloaded from the same page
(http://connect.creativelabs.com/openal/default.aspx). Download and run:
tar xzvf freelut-1.1.0.tar.gz
cd freealut-1.1.0
./configure
make
sudo make install

161
README.cmake Normal file
View File

@@ -0,0 +1,161 @@
Getting started with CMake
==========================
(These instructions apply to Unix-like systems, including Cygwin and Mac. To
build using Visual Studio or some other IDE supported by CMake, most of the
information below still applies. Otherwise see
http://wiki.flightgear.org/Building_Flightgear for Windows specific build
instructions.)
Always compile in a separate directory to the code. For example, if the
code (eg, from Git) is at /home/curt/projects/simgear, you might create
/home/curt/projects/sgbuild. Change into the new directory, and run
cmake ../simgear
To generate standard Unix Makefiles in sgbuild.
Probably you want to specify an install prefix:
cmake ../simgear -DCMAKE_INSTALL_PREFIX=/usr
Note the install prefix is automatically searched for required libraries
and header files, so if you install OpenSceneGraph to the same prefix,
most configuration options are unnecessary.
If for some reason you have a dependency (or several) at a different prefix,
you can specify one or more via CMAKE_PREFIX_PATH:
cmake ../simgear -DCMAKE_PREFIX_PATH="/opt/local;/opt/fgfs"
(note the use of semi-colons to specify multiple prefix paths)
Standard prefixes are searched automatically (/usr, /usr/local, /opt/local)
Most dependencies also expose an environment variable to specify their
installation directory explicitly eg OSG_DIR. Any of the methods
described above will work, but specifying an INSTALL_PREFIX or PREFIX_PATH is
usually simpler.
By default, we select a release build. To create a debug build, use
cmake ../simgear -DCMAKE_BUILD_TYPE=Debug
(or MinSizeRel, or RelWithDbg)
Debug builds will automatically use corresponding debug builds of required
libraries, if they are available. For example you can install debug builds of
OpenSceneGraph, and a debug SimGear build will use them.
(Debug builds of libraries have the 'd' suffix by default - Release builds
have no additional suffix)
Note most IDE projects (eg Xcode and Visual Studio) support building all the
build types from the same project, so you can omit the CMAKE_BUILD_TYPE option
when running cmake, and simply pick the build configuration as normal in the
IDE.
It's common to have several build directories with different build
configurations, eg
/home/curt/projects/simgear (the git clone)
/home/curt/projects/sgdebug
/home/curt/projects/sgrelease
/home/curt/projects/sg-with-svn-osg
To set an optional feature, do
cmake ../simgear -DFEATURE_NAME=ON
(or 'OFF' to disable )
To see the variables that can be configured / are currently defined, you can
run one of the GUI front ends, or the following command:
cmake ../simgear -L
Add 'A' to see all the options (including advanced options), or 'H' to see
the help for each option (similar to running configure --help under autoconf):
cmake ../simgear -LH
Build Targets
=============
For a Unix makefile build, 'make dist', 'make uninstall' and 'make test' are
all available and should work as expected. 'make clean' is also as normal,
but there is *no* 'make distclean' target. The equivalent is to completely
remove your build directory, and start with a fresh one.
Adding new files to the build
Add source files to the SOURCES list, and headers to the HEADERS list. Note
technically you only need to add source files, but omitting headers confuses
project generation and distribution / packaging targets.
For target conditional files, you can append to the SOURCES or HEADERS lists
inside an if() test, for example:
if(APPLE)
list(APPEND SOURCES extraFile1.cxx extraFile2.cxx)
endif()
Setting include directories
In any CMakeList.txt, you can do the following:
include_directories(${PROJECT_SOURCE_DIR}/some/path)
For example, this can be done in particular subdirectory, or at the project
root, or an intermediate level.
Setting target specific compile flags, includes or defines
Use set_target_property(), for example
set_target_property(fgfs PROPERTIES
COMPILE_DEFINITIONS FOO BAR=1)
You can set a property on an individual source file:
set_property(SOURCE myfile.cxx PROPERTY COMPILE_FLAGS "-Wno-unsigned-compare")
Detecting Features / Libraries
For most standard libraries (Gtk, wxWidget, Python, GDAL, Qt, libXml, Boost),
cmake provides a standard helper. To see the available modules, run:
cmake --help-module-list
In the root CMakeLists file, use a statement like:
find_package(OpenGL REQUIRED)
Each package helper sets various variables such aaa_FOUND, aaa_INCLUDE_DIR,
and aaa_LIBRARY. Depending on the complexity of the package, these variables
might have different names (eg, OPENSCENEGRAPH_LIBRARIES).
If there's no standard helper for a library you need, find a similar one, copy
it to CMakeModules/FindABC.cmake, and modify the code to fit. Generally this
is pretty straightforward. The built-in modules reside in the Cmake 'share'
directory, eg /usr/share/cmake/modules on Unix systems.
Note libraries support by pkg-config can be handled directly, with no need
to create a custom FindABC helper.
Adding a new executable target
add_executable(myexecutable ${SOURCES} ${HEADERS})
target_link_libraries(myexecutable .... libraries ... )
install(TARGETS myexecutable RUNTIME DESTINATION bin)
(If the executable should not be installed, omit the final line above)
If you add an additional line
add_test(testname ${EXECUTABLE_OUTPUT_PATH}/myexecutable)
Then running 'make test' will run your executable as a unit test. The
executable should return either a success or failure result code.

View File

@@ -1,32 +0,0 @@
[This file is mirrored in both the FlightGear and SimGear packages.]
You *must* have plib version 1.8.5 or later installed on your system
to build FlightGear!" Flight Gear is no longer compatible with the
earlier versions of the library.
You can get the latest version of plib from:
http://plib.sourceforge.net
Build notes:
You should be able to just run "./configure" to configure the package
and use all of plib's defaults. Then run "make" followed by "make
install". By default, plib installs itself into /usr so if you don't
like this, be sure to specify an alternate prefix such as --prefix=/usr/local
As of this writing (2007-11-18), many linux distributions are shipped with a
working version of plib, so chances are that this library is already
installed. It should be noted, that currently plib version no longer compiles
using recent versions of gcc (confirmed on version gcc 4.1.2, as shipped with
SuSe 10.2). As a workaround, it is possible to either use plib SVN. Run the
following commands:
svn co https://plib.svn.sourceforge.net/svnroot/plib/trunk plib
cd plib
./autogen.sh
./configure
make
make install

1
TODO
View File

@@ -1 +0,0 @@
03/25/2001 - Resolve location of Sky dome implimentation documentation.

13
package/RedHat/README Normal file
View File

@@ -0,0 +1,13 @@
Building a SimGear RPM package for Red Hat
Please see the "package/openSUSE" directory for an
example how to build a SimGear RPM package with
shared SimGear libraries.
You may need to adapt the names (exact spelling) of some
of the package dependencies in the openSUSE RPM spec,
since these may slightly differ for Red Hat.
(If you have a working and tested Red Hat RPM spec,
you're welcome to contribute it to this project.)

23
package/openSUSE/README Normal file
View File

@@ -0,0 +1,23 @@
Building a SimGear RPM package for openSUSE
(Last tested with openSUSE 11.4+12.1)
This directory contains the files which, along with
the source code tar files, can be used to build
an RPM package targeted at an openSUSE Linux system.
To build SimGear from source do the following:
1. obtain simgear-2.8.0.tar.bz2 (adapt version if
necessary) and copy it into ~/rpmbuild/SOURCES
2. look in the BuildRequires section of SimGear.spec
and check that all the packages referred to are
installed (note, some of these packages may be part
of openSUSE's "games" repository).
3. run 'rpmbuild -ba simgear.spec' and find the RPM
build result in ~/rpmbuild/RPMS
That's all!

View File

@@ -0,0 +1,63 @@
Summary: Simulator Construction Gear
Name: SimGear
Version: 2.8.0
Release: 1
License: LGPL
URL: http://www.flightgear.org
Group: Amusements/Games/3D/Simulation
Source: http://mirrors.ibiblio.org/pub/mirrors/flightgear/ftp/Source/simgear-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: gcc, gcc-c++, cmake
BuildRequires: libopenal1-soft, openal-soft
BuildRequires: libOpenSceneGraph-devel >= 3.0
BuildRequires: zlib, zlib-devel
BuildRequires: libjpeg62, libjpeg62-devel
BuildRequires: boost-devel >= 1.37
BuildRequires: subversion-devel, libapr1-devel
Requires: OpenSceneGraph-plugins >= 3.0
%description
This package contains a tools and libraries useful for constructing
simulation and visualization applications such as FlightGear or TerraGear.
%package devel
Group: Development/Libraries/Other
Summary: Development header files for SimGear
Requires: SimGear = %{version}
%description devel
Development headers and libraries for building applications against SimGear.
%prep
%setup -T -q -n simgear-%{version} -b 0
%build
export CFLAGS="$RPM_OPT_FLAGS"
export CXXFLAGS="$RPM_OPT_FLAGS"
# build SHARED simgear libraries
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} -DSIMGEAR_SHARED:BOOL=ON -DENABLE_TESTS:BOOL=OFF -DJPEG_FACTORY:BOOL=ON
make %{?_smp_mflags}
%install
make DESTDIR=%{buildroot} install
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr (-, root, root, -)
%doc AUTHORS COPYING ChangeLog NEWS README
%{_libdir}/libSimGear*.so.*
%files devel
%defattr(-,root,root,-)
%dir %{_includedir}/simgear
%{_includedir}/simgear/*
%{_libdir}/libSimGear*.so
%changelog
* Mon Jul 02 2012 thorstenb@flightgear.org
- Initial version

View File

@@ -1,2 +0,0 @@
The handmade VS2010 project files have been replaced by the Cmake build system.
Please use Cmake to build FlightGear with Visual Studio 2010.

View File

@@ -1,3 +0,0 @@
*.user
Win32
x64

File diff suppressed because it is too large Load Diff

1
simgear/.gitignore vendored
View File

@@ -1,3 +1,2 @@
simgear_config.h
simgear_config.h.*
version.h

View File

@@ -3,6 +3,7 @@ file(WRITE ${PROJECT_BINARY_DIR}/simgear/version.h "#define SIMGEAR_VERSION ${SI
foreach( mylibfolder
bucket
bvh
debug
ephemeris
io
@@ -10,8 +11,8 @@ foreach( mylibfolder
math
misc
nasal
nasal/cppbind
props
route
serial
structure
threads
@@ -24,6 +25,7 @@ foreach( mylibfolder
endforeach( mylibfolder )
if(NOT SIMGEAR_HEADLESS)
add_subdirectory(canvas)
add_subdirectory(environment)
add_subdirectory(screen)
add_subdirectory(scene)
@@ -39,15 +41,19 @@ endif(ENABLE_RTI)
set(HEADERS compiler.h constants.h sg_inlines.h ${PROJECT_BINARY_DIR}/simgear/version.h)
install (FILES ${HEADERS} DESTINATION include/simgear/)
if(SIMGEAR_SHARED)
message(STATUS "building shared library")
get_property(coreSources GLOBAL PROPERTY CORE_SOURCES)
get_property(sceneSources GLOBAL PROPERTY SCENE_SOURCES)
get_property(publicHeaders GLOBAL PROPERTY PUBLIC_HEADERS)
get_property(coreSources GLOBAL PROPERTY CORE_SOURCES)
get_property(sceneSources GLOBAL PROPERTY SCENE_SOURCES)
get_property(publicHeaders GLOBAL PROPERTY PUBLIC_HEADERS)
if(LIBSVN_FOUND)
add_definitions(${APR_CFLAGS})
include_directories(${LIBSVN_INCLUDE_DIR})
endif()
if(SIMGEAR_SHARED)
message(STATUS "Library building mode: SHARED LIBRARIES")
add_library(SimGearCore SHARED ${coreSources})
set_property(TARGET SimGearCore PROPERTY COMPILE_FLAGS "-DNO_OPENSCENEGRAPH_INTERFACE=1")
# set_property(TARGET SimGearCore PROPERTY FRAMEWORK 1)
# message(STATUS "public header: ${publicHeaders}")
# set_property(TARGET SimGearCore PROPERTY PUBLIC_HEADER "${publicHeaders}")
@@ -56,42 +62,86 @@ if(SIMGEAR_SHARED)
set_property(TARGET SimGearCore PROPERTY VERSION ${SIMGEAR_VERSION})
set_property(TARGET SimGearCore PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
target_link_libraries(SimGearCore ${ZLIB_LIBRARY} ${RT_LIBRARY})
install(TARGETS SimGearCore LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(SimGearCore ${ZLIB_LIBRARY} ${RT_LIBRARY}
${EXPAT_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
if(LIBSVN_FOUND)
target_link_libraries(SimGearCore ${LIBSVN_LIBRARIES})
endif(LIBSVN_FOUND)
if(NOT SIMGEAR_HEADLESS)
if(LIBSVN_FOUND)
add_definitions(${APR_CFLAGS})
IF(APPLE)
set_property(SOURCE scene/tsync/terrasync.cxx PROPERTY COMPILE_FLAGS "-iwithsysroot ${LIBSVN_INCLUDE_DIR}")
ELSE()
include_directories(${LIBSVN_INCLUDE_DIR})
ENDIF(APPLE)
endif(LIBSVN_FOUND)
list(APPEND sceneSources scene/util/SGCoreOSGDependant.cxx)
add_library(SimGearScene SHARED ${sceneSources})
# set_property(TARGET SimGearScene PROPERTY FRAMEWORK 1)
# set_property(TARGET SimGearScene PROPERTY PUBLIC_HEADER "${publicHeaders}")
set_property(TARGET SimGearScene PROPERTY LINKER_LANGUAGE CXX)
set_property(TARGET SimGearScene PROPERTY VERSION ${SIMGEAR_VERSION})
set_property(TARGET SimGearScene PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
target_link_libraries(SimGearScene
SimGearCore
${ZLIB_LIBRARY}
${OPENSCENEGRAPH_LIBRARIES}
${OPENAL_LIBRARY} ${ALUT_LIBRARY}
${OPENGL_LIBRARY})
if(LIBSVN_FOUND)
target_link_libraries(SimGearScene ${LIBSVN_LIBRARIES})
endif(LIBSVN_FOUND)
target_link_libraries(SimGearScene
SimGearCore
${ZLIB_LIBRARY}
${OPENSCENEGRAPH_LIBRARIES}
${OPENAL_LIBRARY}
${OPENGL_LIBRARY}
${JPEG_LIBRARY})
install(TARGETS SimGearScene LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif(SIMGEAR_SHARED)
install(TARGETS SimGearCore LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
else()
message(STATUS "Library building mode: STATIC LIBRARIES")
get_property(FG_GROUPS_CORE_SOURCES_C GLOBAL PROPERTY FG_GROUPS_CORE_SOURCES_C)
string(REPLACE "@" ";" groups ${FG_GROUPS_CORE_SOURCES_C} )
foreach(g ${groups})
string(REPLACE "#" ";" g2 ${g})
list(GET g2 0 name)
list(REMOVE_AT g2 0)
source_group("${name}\\Sources" FILES ${g2})
endforeach()
get_property(FG_GROUPS_CORE_SOURCES_H GLOBAL PROPERTY FG_GROUPS_CORE_SOURCES_H)
string(REPLACE "@" ";" groups ${FG_GROUPS_CORE_SOURCES_H} )
foreach(g ${groups})
string(REPLACE "#" ";" g2 ${g})
list(GET g2 0 name)
list(REMOVE_AT g2 0)
source_group("${name}\\Headers" FILES ${g2})
endforeach()
add_library(SimGearCore STATIC ${coreSources})
install(TARGETS SimGearCore ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(NOT SIMGEAR_HEADLESS)
get_property(FG_GROUPS_SCENE_SOURCES_C GLOBAL PROPERTY FG_GROUPS_SCENE_SOURCES_C)
string(REPLACE "@" ";" groups ${FG_GROUPS_SCENE_SOURCES_C} )
foreach(g ${groups})
string(REPLACE "#" ";" g2 ${g})
list(GET g2 0 name)
list(REMOVE_AT g2 0)
source_group("${name}\\Sources" FILES ${g2})
endforeach()
get_property(FG_GROUPS_SCENE_SOURCES_H GLOBAL PROPERTY FG_GROUPS_SCENE_SOURCES_H)
string(REPLACE "@" ";" groups ${FG_GROUPS_SCENE_SOURCES_H} )
foreach(g ${groups})
string(REPLACE "#" ";" g2 ${g})
list(GET g2 0 name)
list(REMOVE_AT g2 0)
source_group("${name}\\Headers" FILES ${g2})
endforeach()
add_library(SimGearScene STATIC ${sceneSources})
install(TARGETS SimGearScene ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(NOT SIMGEAR_HEADLESS)
endif(SIMGEAR_SHARED)
if(ENABLE_RTI)
# Ugly first aid to make hla compile agian
set_property(SOURCE hla/RTI13InteractionClass.cxx hla/RTI13ObjectClass.cxx
hla/RTI13ObjectInstance.cxx hla/RTI13Federate.cxx
hla/RTI13FederateFactory.cxx
APPEND PROPERTY COMPILE_FLAGS "-I${RTI_INCLUDE_DIR}")
endif(ENABLE_RTI)

View File

@@ -23,6 +23,7 @@
#include "BVHVisitor.hxx"
#include "BVHNode.hxx"
#include "BVHGroup.hxx"
#include "BVHPageNode.hxx"
#include "BVHTransform.hxx"
#include "BVHMotionTransform.hxx"
#include "BVHLineGeometry.hxx"
@@ -45,6 +46,8 @@ public:
virtual void apply(BVHGroup& node)
{ expandBy(node.getBoundingSphere()); }
virtual void apply(BVHPageNode& node)
{ expandBy(node.getBoundingSphere()); }
virtual void apply(BVHTransform& node)
{ expandBy(node.getBoundingSphere()); }
virtual void apply(BVHMotionTransform& node)

View File

@@ -15,7 +15,10 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#include <simgear/math/SGMath.hxx>
#ifdef HAVE_CONFIG_H
# include <simgear_config.h>
#endif
#include "BVHLineSegmentVisitor.hxx"
#include <simgear/math/SGGeometry.hxx>
@@ -24,6 +27,7 @@
#include "BVHNode.hxx"
#include "BVHGroup.hxx"
#include "BVHPageNode.hxx"
#include "BVHTransform.hxx"
#include "BVHMotionTransform.hxx"
#include "BVHLineGeometry.hxx"
@@ -44,6 +48,14 @@ BVHLineSegmentVisitor::apply(BVHGroup& group)
return;
group.traverse(*this);
}
void
BVHLineSegmentVisitor::apply(BVHPageNode& pageNode)
{
if (!intersects(_lineSegment, pageNode.getBoundingSphere()))
return;
pageNode.traverse(*this);
}
void
BVHLineSegmentVisitor::apply(BVHTransform& transform)

View File

@@ -20,13 +20,14 @@
#include <simgear/math/SGGeometry.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/scene/material/mat.hxx>
#include "BVHVisitor.hxx"
#include "BVHNode.hxx"
namespace simgear {
class BVHMaterial;
class BVHLineSegmentVisitor : public BVHVisitor {
public:
BVHLineSegmentVisitor(const SGLineSegmentd& lineSegment,
@@ -54,12 +55,13 @@ public:
{ return _linearVelocity; }
const SGVec3d& getAngularVelocity() const
{ return _angularVelocity; }
const SGMaterial* getMaterial() const
const BVHMaterial* getMaterial() const
{ return _material; }
BVHNode::Id getId() const
{ return _id; }
virtual void apply(BVHGroup& group);
virtual void apply(BVHPageNode& node);
virtual void apply(BVHTransform& transform);
virtual void apply(BVHMotionTransform& transform);
virtual void apply(BVHLineGeometry&);
@@ -87,7 +89,7 @@ private:
SGVec3d _normal;
SGVec3d _linearVelocity;
SGVec3d _angularVelocity;
const SGMaterial* _material;
const BVHMaterial* _material;
BVHNode::Id _id;
bool _haveHit;

View File

@@ -1,5 +1,4 @@
// PathOptions.hxx -- make an osgDB Options object from a path
// Copyright (C) 2007 Tim Moore timoore@redhat.com
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -15,17 +14,22 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef PATHOPTIONSHXX
#define PATHOPTIONSHXX 1
#include "BVHMaterial.hxx"
#include <osgDB/ReaderWriter>
#include <simgear/misc/sg_path.hxx>
namespace simgear {
namespace simgear
BVHMaterial::BVHMaterial() :
_solid(true),
_friction_factor(1),
_rolling_friction(0.02),
_bumpiness(0),
_load_resistance(1e30)
{
osgDB::ReaderWriter::Options* makeOptionsFromPath(const SGPath&);
}
#endif
BVHMaterial::~BVHMaterial()
{
}
}

View File

@@ -0,0 +1,75 @@
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifndef BVHMaterial_hxx
#define BVHMaterial_hxx
#include <simgear/structure/SGReferenced.hxx>
namespace simgear {
class BVHMaterial : public SGReferenced {
public:
BVHMaterial();
virtual ~BVHMaterial();
/**
* Return if the surface material is solid, if it is not solid, a fluid
* can be assumed, that is usually water.
*/
bool get_solid () const { return _solid; }
/**
* Get the friction factor for that material
*/
double get_friction_factor () const { return _friction_factor; }
/**
* Get the rolling friction for that material
*/
double get_rolling_friction () const { return _rolling_friction; }
/**
* Get the bumpines for that material
*/
double get_bumpiness () const { return _bumpiness; }
/**
* Get the load resistance
*/
double get_load_resistance () const { return _load_resistance; }
protected:
// True if the material is solid, false if it is a fluid
bool _solid;
// the friction factor of that surface material
double _friction_factor;
// the rolling friction of that surface material
double _rolling_friction;
// the bumpiness of that surface material
double _bumpiness;
// the load resistance of that surface material
double _load_resistance;
};
}
#endif

View File

@@ -24,6 +24,7 @@
#include "BVHNode.hxx"
#include "BVHGroup.hxx"
#include "BVHPageNode.hxx"
#include "BVHTransform.hxx"
#include "BVHLineGeometry.hxx"
#include "BVHStaticGeometry.hxx"
@@ -52,6 +53,12 @@ public:
return;
leaf.traverse(*this);
}
virtual void apply(BVHPageNode& leaf)
{
if (!intersects(_sphere, leaf.getBoundingSphere()))
return;
leaf.traverse(*this);
}
virtual void apply(BVHTransform& transform)
{
if (!intersects(_sphere, transform.getBoundingSphere()))
@@ -140,7 +147,7 @@ public:
{ return _linearVelocity; }
const SGVec3d& getAngularVelocity() const
{ return _angularVelocity; }
const SGMaterial* getMaterial() const
const BVHMaterial* getMaterial() const
{ return _material; }
BVHNode::Id getId() const
{ return _id; }
@@ -155,7 +162,7 @@ private:
SGVec3d _point;
SGVec3d _linearVelocity;
SGVec3d _angularVelocity;
const SGMaterial* _material;
const BVHMaterial* _material;
BVHNode::Id _id;
bool _havePoint;

View File

@@ -26,6 +26,7 @@ namespace simgear {
class BVHGroup;
class BVHVisitor;
class BVHPageNode;
// Base for the tree nodes
class BVHNode : public SGReferenced {
@@ -55,6 +56,7 @@ public:
protected:
friend class BVHGroup;
friend class BVHPageNode;
void addParent(BVHNode* parent);
void removeParent(BVHNode* parent);

View File

@@ -0,0 +1,40 @@
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#include "BVHPageNode.hxx"
#include "BVHPager.hxx"
namespace simgear {
BVHPageNode::BVHPageNode() :
_useStamp(0),
_requested(false)
{
}
BVHPageNode::~BVHPageNode()
{
}
void
BVHPageNode::accept(BVHVisitor& visitor)
{
visitor.apply(*this);
}
}

View File

@@ -0,0 +1,66 @@
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifndef BVHPageNode_hxx
#define BVHPageNode_hxx
#include <list>
#include <simgear/structure/SGSharedPtr.hxx>
#include "BVHGroup.hxx"
#include "BVHVisitor.hxx"
namespace simgear {
class BVHPager;
class BVHPageRequest;
class BVHPageNode : public BVHGroup {
public:
BVHPageNode();
virtual ~BVHPageNode();
virtual void accept(BVHVisitor& visitor);
/// Return the usage stamp of the last access
unsigned getUseStamp() const
{ return _useStamp; }
virtual SGSphered computeBoundingSphere() const = 0;
virtual BVHPageRequest* newRequest() = 0;
protected:
virtual void invalidateBound() = 0;
bool getRequested() const
{ return _requested; }
void setRequested(bool requested)
{ _requested = requested; }
private:
friend class BVHPager;
std::list<SGSharedPtr<BVHPageNode> >::iterator _iterator;
unsigned _useStamp;
bool _requested;
};
}
#endif

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#include "BVHPageRequest.hxx"
namespace simgear {
BVHPageRequest::~BVHPageRequest()
{
}
}

View File

@@ -0,0 +1,42 @@
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifndef BVHPageRequest_hxx
#define BVHPageRequest_hxx
#include <simgear/structure/SGReferenced.hxx>
namespace simgear {
class BVHPageNode;
class BVHPageRequest : public SGReferenced {
public:
virtual ~BVHPageRequest();
/// Happens in the pager thread, do not modify the calling bvh tree
virtual void load() = 0;
/// Happens in the bvh main thread where the bvh is actually used.
/// So inside here it is safe to modify the paged node
virtual void insert() = 0;
/// The page node this request is for
virtual BVHPageNode* getPageNode() = 0;
};
}
#endif

236
simgear/bvh/BVHPager.cxx Normal file
View File

@@ -0,0 +1,236 @@
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#include "BVHPager.hxx"
#include <list>
#include <simgear/threads/SGThread.hxx>
#include <simgear/threads/SGGuard.hxx>
#include "BVHPageNode.hxx"
#include "BVHPageRequest.hxx"
namespace simgear {
struct BVHPager::_PrivateData : protected SGThread {
typedef SGSharedPtr<BVHPageRequest> _Request;
typedef std::list<_Request> _RequestList;
typedef std::list<SGSharedPtr<BVHPageNode> > _PageNodeList;
struct _LockedQueue {
void _push(const _Request& request)
{
SGGuard<SGMutex> scopeLock(_mutex);
_requestList.push_back(request);
}
_Request _pop()
{
SGGuard<SGMutex> scopeLock(_mutex);
if (_requestList.empty())
return _Request();
_Request request;
request.swap(_requestList.front());
_requestList.pop_front();
return request;
}
private:
SGMutex _mutex;
_RequestList _requestList;
};
struct _WorkQueue {
void _stop()
{
_push(_Request());
}
void _push(const _Request& request)
{
SGGuard<SGMutex> scopeLock(_mutex);
bool needSignal = _requestList.empty();
_requestList.push_back(request);
if (needSignal)
_waitCondition.signal();
}
_Request _pop()
{
SGGuard<SGMutex> scopeLock(_mutex);
while (_requestList.empty())
_waitCondition.wait(_mutex);
_Request request;
request.swap(_requestList.front());
_requestList.pop_front();
return request;
}
private:
SGMutex _mutex;
SGWaitCondition _waitCondition;
_RequestList _requestList;
};
_PrivateData() :
_started(false),
_useStamp(0)
{
}
virtual ~_PrivateData()
{
_stop();
}
virtual void run()
{
for (;;) {
_Request request = _pendingRequests._pop();
// This means stop working
if (!request.valid())
return;
request->load();
_processedRequests._push(request);
}
}
bool _start()
{
if (_started)
return true;
if (!start())
return false;
_started = true;
return true;
}
void _stop()
{
if (!_started)
return;
// send a stop request ...
_pendingRequests._stop();
// ... and wait for the thread to finish
join();
_started = false;
}
void _use(BVHPageNode& pageNode)
{
if (pageNode._requested) {
// move it forward in the lru list
_pageNodeList.splice(_pageNodeList.end(), _pageNodeList,
pageNode._iterator);
} else {
_Request request = pageNode.newRequest();
if (!request.valid())
return;
pageNode._iterator = _pageNodeList.insert(_pageNodeList.end(),
&pageNode);
pageNode._requested = true;
if (_started) {
_pendingRequests._push(request);
} else {
request->load();
request->insert();
}
}
pageNode._useStamp = _useStamp;
}
void _update(unsigned expiry)
{
// Insert all processed requests
for (;;) {
SGSharedPtr<BVHPageRequest> request;
request = _processedRequests._pop();
if (!request.valid())
break;
request->insert();
}
// ... and throw away stuff that is not used for a long time
unsigned useStamp = _useStamp - expiry;
_PageNodeList::iterator i = _pageNodeList.begin();
while (i != _pageNodeList.end()) {
// Ok, this means if the highest bit in the below difference
// is set which is aequivalent to having a negative difference
// but being wraparound save.
unsigned diff = (*i)->_useStamp - useStamp;
// test the sign bit of the difference
if (!(diff & (~((~0u) >> 1))))
break;
(*i)->clear();
(*i)->_requested = false;
i = _pageNodeList.erase(i);
}
}
bool _started;
unsigned _useStamp;
_WorkQueue _pendingRequests;
_LockedQueue _processedRequests;
// Store the rcu list of loaded nodes so that they can expire
_PageNodeList _pageNodeList;
};
BVHPager::BVHPager() :
_privateData(new _PrivateData)
{
}
BVHPager::~BVHPager()
{
delete _privateData;
_privateData = 0;
}
bool
BVHPager::start()
{
return _privateData->_start();
}
void
BVHPager::stop()
{
_privateData->_stop();
}
void
BVHPager::use(BVHPageNode& pageNode)
{
_privateData->_use(pageNode);
}
void
BVHPager::update(unsigned expiry)
{
_privateData->_update(expiry);
}
void
BVHPager::setUseStamp(unsigned stamp)
{
_privateData->_useStamp = stamp;
}
unsigned
BVHPager::getUseStamp() const
{
return _privateData->_useStamp;
}
}

60
simgear/bvh/BVHPager.hxx Normal file
View File

@@ -0,0 +1,60 @@
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#ifndef BVHPager_hxx
#define BVHPager_hxx
#include <simgear/structure/SGSharedPtr.hxx>
namespace simgear {
class BVHPageNode;
class BVHPageRequest;
class BVHPager {
public:
BVHPager();
~BVHPager();
/// Starts the pager thread
bool start();
/// Stops the pager thread
void stop();
/// Use this page node, if loaded make it as used, if not loaded schedule
void use(BVHPageNode& pageNode);
/// Call this from the main thread to incorporate the processed page
/// requests into the bounding volume tree
void update(unsigned expiry);
/// The usage stamp to mark usage of BVHPageNodes
void setUseStamp(unsigned stamp);
unsigned getUseStamp() const;
private:
BVHPager(const BVHPager&);
BVHPager& operator=(const BVHPager&);
struct _PrivateData;
_PrivateData* _privateData;
};
}
#endif

View File

@@ -22,11 +22,7 @@
#include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/math/SGGeometry.hxx>
/// FIXME, the SGMaterial class is too much tied to the scenegraph aspects of
/// the materials. Use some class more decribing the
/// nature of the surface we live on ...
class SGMaterial;
#include "BVHMaterial.hxx"
namespace simgear {
@@ -40,20 +36,20 @@ public:
{ return _vertices[i]; }
unsigned addMaterial(const SGMaterial* material)
unsigned addMaterial(const BVHMaterial* material)
{ _materials.push_back(material); return _materials.size() - 1; }
const SGMaterial* getMaterial(unsigned i) const
const BVHMaterial* getMaterial(unsigned i) const
{ if (_materials.size() <= i) return 0; return _materials[i]; }
void trim()
{
std::vector<SGVec3f>(_vertices).swap(_vertices);
std::vector<const SGMaterial*>(_materials).swap(_materials);
std::vector<SGSharedPtr<const BVHMaterial> >(_materials).swap(_materials);
}
private:
std::vector<SGVec3f> _vertices;
std::vector<const SGMaterial*> _materials;
std::vector<SGSharedPtr<const BVHMaterial> > _materials;
};
}

View File

@@ -78,16 +78,16 @@ public:
typedef std::set<SGVec3<unsigned> > TriangleSet;
TriangleSet _triangleSet;
void setCurrentMaterial(const SGMaterial* material)
void setCurrentMaterial(const BVHMaterial* material)
{
_currentMaterial = material;
_currentMaterialIndex = addMaterial(material);
}
const SGMaterial* getCurrentMaterial() const
const BVHMaterial* getCurrentMaterial() const
{
return _currentMaterial;
}
unsigned addMaterial(const SGMaterial* material)
unsigned addMaterial(const BVHMaterial* material)
{
MaterialMap::const_iterator i = _materialMap.find(material);
if (i != _materialMap.end())
@@ -97,9 +97,9 @@ public:
return index;
}
typedef std::map<const SGMaterial*, unsigned> MaterialMap;
typedef std::map<const BVHMaterial*, unsigned> MaterialMap;
MaterialMap _materialMap;
const SGMaterial* _currentMaterial;
const BVHMaterial* _currentMaterial;
unsigned _currentMaterialIndex;
void addTriangle(const SGVec3f& v1, const SGVec3f& v2, const SGVec3f& v3)

View File

@@ -59,6 +59,22 @@ BVHSubTreeCollector::apply(BVHGroup& group)
popNodeList(parentNodeList);
}
void
BVHSubTreeCollector::apply(BVHPageNode& group)
{
if (!intersects(_sphere, group.getBoundingSphere()))
return;
// The _nodeList content is somehow the 'return value' of the subtree.
// Set it to zero to see if we have something to collect down there.
NodeList parentNodeList;
pushNodeList(parentNodeList);
group.traverse(*this);
popNodeList(parentNodeList);
}
void
BVHSubTreeCollector::apply(BVHTransform& transform)
{

View File

@@ -43,6 +43,7 @@ public:
virtual ~BVHSubTreeCollector();
virtual void apply(BVHGroup&);
virtual void apply(BVHPageNode&);
virtual void apply(BVHTransform&);
virtual void apply(BVHMotionTransform&);
virtual void apply(BVHLineGeometry&);

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2008 - 2009 Mathias Froehlich - Mathias.Froehlich@web.de
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -23,6 +23,7 @@ namespace simgear {
class BVHStaticData;
class BVHGroup;
class BVHPageNode;
class BVHTransform;
class BVHMotionTransform;
class BVHStaticGeometry;
@@ -41,6 +42,7 @@ public:
// High level nodes to handle
virtual void apply(BVHGroup&) = 0;
virtual void apply(BVHPageNode&) = 0;
virtual void apply(BVHTransform&) = 0;
virtual void apply(BVHMotionTransform&) = 0;
virtual void apply(BVHLineGeometry&) = 0;

View File

@@ -1,14 +1,16 @@
include (SimGearComponent)
set(HEADERS
set(HEADERS
BVHBoundingBoxVisitor.hxx
BVHDebugCollectVisitor.hxx
BVHGroup.hxx
BVHLineGeometry.hxx
BVHLineSegmentVisitor.hxx
BVHMotionTransform.hxx
BVHNearestPointVisitor.hxx
BVHNode.hxx
BVHPageNode.hxx
BVHPageRequest.hxx
BVHPager.hxx
BVHStaticBinary.hxx
BVHStaticData.hxx
BVHStaticGeometry.hxx
@@ -17,23 +19,34 @@ set(HEADERS
BVHStaticNode.hxx
BVHStaticTriangle.hxx
BVHSubTreeCollector.hxx
BVHMaterial.hxx
BVHTransform.hxx
BVHVisitor.hxx
)
)
set(SOURCES
set(SOURCES
BVHGroup.cxx
BVHLineGeometry.cxx
BVHLineSegmentVisitor.cxx
BVHMotionTransform.cxx
BVHNode.cxx
BVHPageNode.cxx
BVHPageRequest.cxx
BVHPager.cxx
BVHStaticBinary.cxx
BVHStaticGeometry.cxx
BVHStaticLeaf.cxx
BVHStaticNode.cxx
BVHStaticTriangle.cxx
BVHSubTreeCollector.cxx
BVHTransform.cxx
)
BVHMaterial.cxx
BVHTransform.cxx
)
simgear_scene_component(bvh scene/bvh "${SOURCES}" "${HEADERS}")
simgear_component(bvh bvh "${SOURCES}" "${HEADERS}")
if(ENABLE_TESTS)
add_executable(bvhtest bvhtest.cxx)
target_link_libraries(bvhtest SimGearCore)
add_test(bvhtest ${EXECUTABLE_OUTPUT_PATH}/bvhtest)
endif(ENABLE_TESTS)

View File

@@ -0,0 +1,34 @@
include (SimGearComponent)
set(HEADERS
canvas_fwd.hxx
Canvas.hxx
CanvasEvent.hxx
CanvasEventListener.hxx
CanvasEventManager.hxx
CanvasEventTypes.hxx
CanvasEventVisitor.hxx
CanvasMgr.hxx
CanvasPlacement.hxx
CanvasSystemAdapter.hxx
MouseEvent.hxx
ODGauge.hxx
VGInitOperation.hxx
)
set(SOURCES
Canvas.cxx
CanvasEvent.cxx
CanvasEventListener.cxx
CanvasEventManager.cxx
CanvasEventVisitor.cxx
CanvasMgr.cxx
CanvasPlacement.cxx
ODGauge.cxx
VGInitOperation.cxx
)
add_subdirectory(ShivaVG/src)
add_subdirectory(elements)
simgear_scene_component(canvas canvas "${SOURCES}" "${HEADERS}")

552
simgear/canvas/Canvas.cxx Normal file
View File

@@ -0,0 +1,552 @@
// The canvas for rendering with the 2d API
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#include "Canvas.hxx"
#include "CanvasEventManager.hxx"
#include "CanvasEventVisitor.hxx"
#include <simgear/canvas/MouseEvent.hxx>
#include <simgear/canvas/CanvasPlacement.hxx>
#include <simgear/scene/util/parse_color.hxx>
#include <simgear/scene/util/RenderConstants.hxx>
#include <osg/Camera>
#include <osg/Geode>
#include <osgText/Text>
#include <osgViewer/Viewer>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/foreach.hpp>
#include <iostream>
namespace simgear
{
namespace canvas
{
//----------------------------------------------------------------------------
Canvas::CullCallback::CullCallback(const CanvasWeakPtr& canvas):
_canvas( canvas )
{
}
//----------------------------------------------------------------------------
void Canvas::CullCallback::operator()( osg::Node* node,
osg::NodeVisitor* nv )
{
if( (nv->getTraversalMask() & simgear::MODEL_BIT) && !_canvas.expired() )
_canvas.lock()->enableRendering();
traverse(node, nv);
}
//----------------------------------------------------------------------------
Canvas::Canvas(SGPropertyNode* node):
PropertyBasedElement(node),
_canvas_mgr(0),
_event_manager(new EventManager),
_size_x(-1),
_size_y(-1),
_view_width(-1),
_view_height(-1),
_status(node, "status"),
_status_msg(node, "status-msg"),
_sampling_dirty(false),
_render_dirty(true),
_visible(true),
_render_always(false)
{
_status = 0;
setStatusFlags(MISSING_SIZE_X | MISSING_SIZE_Y);
}
//----------------------------------------------------------------------------
Canvas::~Canvas()
{
}
//----------------------------------------------------------------------------
void Canvas::setSystemAdapter(const SystemAdapterPtr& system_adapter)
{
_system_adapter = system_adapter;
_texture.setSystemAdapter(system_adapter);
}
//----------------------------------------------------------------------------
SystemAdapterPtr Canvas::getSystemAdapter() const
{
return _system_adapter;
}
//----------------------------------------------------------------------------
void Canvas::setCanvasMgr(CanvasMgr* canvas_mgr)
{
_canvas_mgr = canvas_mgr;
}
//----------------------------------------------------------------------------
CanvasMgr* Canvas::getCanvasMgr() const
{
return _canvas_mgr;
}
//----------------------------------------------------------------------------
void Canvas::addDependentCanvas(const CanvasWeakPtr& canvas)
{
if( canvas.expired() )
{
SG_LOG
(
SG_GENERAL,
SG_WARN,
"Canvas::addDependentCanvas: got an expired Canvas dependent on "
<< _node->getPath()
);
return;
}
_dependent_canvases.insert(canvas);
}
//----------------------------------------------------------------------------
void Canvas::removeDependentCanvas(const CanvasWeakPtr& canvas)
{
_dependent_canvases.erase(canvas);
}
//----------------------------------------------------------------------------
GroupPtr Canvas::createGroup(const std::string& name)
{
return boost::dynamic_pointer_cast<Group>
(
_root_group->createChild("group", name)
);
}
//----------------------------------------------------------------------------
void Canvas::enableRendering(bool force)
{
_visible = true;
if( force )
_render_dirty = true;
}
//----------------------------------------------------------------------------
void Canvas::update(double delta_time_sec)
{
if( (!_texture.serviceable() && _status != STATUS_DIRTY)
|| (_status & CREATE_FAILED) )
return;
if( _status == STATUS_DIRTY )
{
_texture.setSize(_size_x, _size_y);
if( !_texture.serviceable() )
{
_texture.useImageCoords(true);
_texture.useStencil(true);
_texture.allocRT(/*_camera_callback*/);
}
else
{
// Resizing causes a new texture to be created so we need to reapply all
// existing placements
for(size_t i = 0; i < _placements.size(); ++i)
{
if( !_placements[i].empty() )
_dirty_placements.push_back( _placements[i].front()->getProps() );
}
}
osg::Camera* camera = _texture.getCamera();
osg::Vec4 clear_color(0.0f, 0.0f, 0.0f , 1.0f);
parseColor(_node->getStringValue("background"), clear_color);
camera->setClearColor(clear_color);
camera->addChild(_root_group->getMatrixTransform());
// Ensure objects are drawn in order of traversal
camera->getOrCreateStateSet()->setBinName("TraversalOrderBin");
if( _texture.serviceable() )
{
setStatusFlags(STATUS_OK);
setStatusFlags(STATUS_DIRTY, false);
_render_dirty = true;
}
else
{
setStatusFlags(CREATE_FAILED);
return;
}
}
if( _visible || _render_always )
{
if( _render_dirty )
{
// Also mark all dependent (eg. recursively used) canvases as dirty
BOOST_FOREACH(CanvasWeakPtr canvas, _dependent_canvases)
{
if( !canvas.expired() )
canvas.lock()->_render_dirty = true;
}
}
_texture.setRender(_render_dirty);
_render_dirty = false;
_visible = false;
}
else
_texture.setRender(false);
_root_group->update(delta_time_sec);
if( _sampling_dirty )
{
_texture.setSampling(
_node->getBoolValue("mipmapping"),
_node->getIntValue("coverage-samples"),
_node->getIntValue("color-samples")
);
_sampling_dirty = false;
_render_dirty = true;
}
while( !_dirty_placements.empty() )
{
SGPropertyNode *node = _dirty_placements.back();
_dirty_placements.pop_back();
if( node->getIndex() >= static_cast<int>(_placements.size()) )
// New placement
_placements.resize(node->getIndex() + 1);
else
// Remove possibly existing placements
_placements[ node->getIndex() ].clear();
// Get new placements
PlacementFactoryMap::const_iterator placement_factory =
_placement_factories.find( node->getStringValue("type", "object") );
if( placement_factory != _placement_factories.end() )
{
Placements& placements = _placements[ node->getIndex() ] =
placement_factory->second
(
node,
boost::static_pointer_cast<Canvas>(_self.lock())
);
node->setStringValue
(
"status-msg",
placements.empty() ? "No match" : "Ok"
);
}
else
node->setStringValue("status-msg", "Unknown placement type");
}
}
//----------------------------------------------------------------------------
naRef Canvas::addEventListener(const nasal::CallContext& ctx)
{
if( !_root_group.get() )
naRuntimeError(ctx.c, "Canvas: No root group!");
return _root_group->addEventListener(ctx);
}
//----------------------------------------------------------------------------
void Canvas::setSizeX(int sx)
{
if( _size_x == sx )
return;
_size_x = sx;
setStatusFlags(STATUS_DIRTY);
if( _size_x <= 0 )
setStatusFlags(MISSING_SIZE_X);
else
setStatusFlags(MISSING_SIZE_X, false);
// reset flag to allow creation with new size
setStatusFlags(CREATE_FAILED, false);
}
//----------------------------------------------------------------------------
void Canvas::setSizeY(int sy)
{
if( _size_y == sy )
return;
_size_y = sy;
setStatusFlags(STATUS_DIRTY);
if( _size_y <= 0 )
setStatusFlags(MISSING_SIZE_Y);
else
setStatusFlags(MISSING_SIZE_Y, false);
// reset flag to allow creation with new size
setStatusFlags(CREATE_FAILED, false);
}
//----------------------------------------------------------------------------
int Canvas::getSizeX() const
{
return _size_x;
}
//----------------------------------------------------------------------------
int Canvas::getSizeY() const
{
return _size_y;
}
//----------------------------------------------------------------------------
void Canvas::setViewWidth(int w)
{
if( _view_width == w )
return;
_view_width = w;
_texture.setViewSize(_view_width, _view_height);
}
//----------------------------------------------------------------------------
void Canvas::setViewHeight(int h)
{
if( _view_height == h )
return;
_view_height = h;
_texture.setViewSize(_view_width, _view_height);
}
//----------------------------------------------------------------------------
int Canvas::getViewWidth() const
{
return _view_width;
}
//----------------------------------------------------------------------------
int Canvas::getViewHeight() const
{
return _view_height;
}
//----------------------------------------------------------------------------
bool Canvas::handleMouseEvent(const MouseEventPtr& event)
{
if( !_root_group.get() )
return false;
EventVisitor visitor( EventVisitor::TRAVERSE_DOWN,
event->getClientPos(),
event->getDelta() );
if( !_root_group->accept(visitor) )
return false;
return _event_manager->handleEvent(event, visitor.getPropagationPath());
}
//----------------------------------------------------------------------------
void Canvas::childAdded( SGPropertyNode * parent,
SGPropertyNode * child )
{
if( parent != _node )
return;
if( child->getNameString() == "placement" )
_dirty_placements.push_back(child);
else if( _root_group.get() )
static_cast<Element*>(_root_group.get())->childAdded(parent, child);
}
//----------------------------------------------------------------------------
void Canvas::childRemoved( SGPropertyNode * parent,
SGPropertyNode * child )
{
_render_dirty = true;
if( parent != _node )
return;
if( child->getNameString() == "placement" )
_placements[ child->getIndex() ].clear();
else if( _root_group.get() )
static_cast<Element*>(_root_group.get())->childRemoved(parent, child);
}
//----------------------------------------------------------------------------
void Canvas::valueChanged(SGPropertyNode* node)
{
if( boost::starts_with(node->getNameString(), "status")
|| node->getParent()->getNameString() == "bounding-box" )
return;
_render_dirty = true;
bool handled = true;
if( node->getParent()->getParent() == _node
&& node->getParent()->getNameString() == "placement" )
{
bool placement_dirty = false;
BOOST_FOREACH(Placements& placements, _placements)
{
BOOST_FOREACH(PlacementPtr& placement, placements)
{
// check if change can be directly handled by placement
if( placement->getProps() == node->getParent()
&& !placement->childChanged(node) )
placement_dirty = true;
}
}
if( !placement_dirty )
return;
// prevent double updates...
for( size_t i = 0; i < _dirty_placements.size(); ++i )
{
if( node->getParent() == _dirty_placements[i] )
return;
}
_dirty_placements.push_back(node->getParent());
}
else if( node->getParent() == _node )
{
if( node->getNameString() == "background" )
{
osg::Vec4 color;
if( _texture.getCamera() && parseColor(node->getStringValue(), color) )
{
_texture.getCamera()->setClearColor(color);
_render_dirty = true;
}
}
else if( node->getNameString() == "mipmapping"
|| node->getNameString() == "coverage-samples"
|| node->getNameString() == "color-samples" )
{
_sampling_dirty = true;
}
else if( node->getNameString() == "render-always" )
{
_render_always = node->getBoolValue();
}
else if( node->getNameString() == "size" )
{
if( node->getIndex() == 0 )
setSizeX( node->getIntValue() );
else if( node->getIndex() == 1 )
setSizeY( node->getIntValue() );
}
else if( node->getNameString() == "view" )
{
if( node->getIndex() == 0 )
setViewWidth( node->getIntValue() );
else if( node->getIndex() == 1 )
setViewHeight( node->getIntValue() );
}
else if( node->getNameString() == "freeze" )
_texture.setRender( node->getBoolValue() );
else
handled = false;
}
else
handled = false;
if( !handled && _root_group.get() )
_root_group->valueChanged(node);
}
//----------------------------------------------------------------------------
osg::Texture2D* Canvas::getTexture() const
{
return _texture.getTexture();
}
//----------------------------------------------------------------------------
Canvas::CullCallbackPtr Canvas::getCullCallback() const
{
return _cull_callback;
}
//----------------------------------------------------------------------------
void Canvas::addPlacementFactory( const std::string& type,
PlacementFactory factory )
{
if( _placement_factories.find(type) != _placement_factories.end() )
SG_LOG
(
SG_GENERAL,
SG_WARN,
"Canvas::addPlacementFactory: replace existing factor for type " << type
);
_placement_factories[type] = factory;
}
//----------------------------------------------------------------------------
void Canvas::setSelf(const PropertyBasedElementPtr& self)
{
PropertyBasedElement::setSelf(self);
CanvasPtr canvas = boost::static_pointer_cast<Canvas>(self);
_root_group.reset( new Group(canvas, _node) );
_root_group->setSelf(_root_group);
// Remove automatically created property listener as we forward them on our
// own
_root_group->removeListener();
_cull_callback = new CullCallback(canvas);
}
//----------------------------------------------------------------------------
void Canvas::setStatusFlags(unsigned int flags, bool set)
{
if( set )
_status |= flags;
else
_status &= ~flags;
if( (_status & MISSING_SIZE_X) && (_status & MISSING_SIZE_Y) )
_status_msg = "Missing size";
else if( _status & MISSING_SIZE_X )
_status_msg = "Missing size-x";
else if( _status & MISSING_SIZE_Y )
_status_msg = "Missing size-y";
else if( _status & CREATE_FAILED )
_status_msg = "Creating render target failed";
else if( _status == STATUS_DIRTY )
_status_msg = "Creation pending...";
else
_status_msg = "Ok";
}
//----------------------------------------------------------------------------
Canvas::PlacementFactoryMap Canvas::_placement_factories;
} // namespace canvas
} // namespace simgear

182
simgear/canvas/Canvas.hxx Normal file
View File

@@ -0,0 +1,182 @@
// The canvas for rendering with the 2d API
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef CANVAS_HXX_
#define CANVAS_HXX_
#include "canvas_fwd.hxx"
#include "ODGauge.hxx"
#include <simgear/canvas/elements/CanvasGroup.hxx>
#include <simgear/props/PropertyBasedElement.hxx>
#include <simgear/props/propertyObject.hxx>
#include <osg/NodeCallback>
#include <osg/observer_ptr>
#include <memory>
#include <string>
namespace simgear
{
namespace canvas
{
class CanvasMgr;
class MouseEvent;
class Canvas:
public PropertyBasedElement
{
public:
enum StatusFlags
{
STATUS_OK,
STATUS_DIRTY = 1,
MISSING_SIZE_X = STATUS_DIRTY << 1,
MISSING_SIZE_Y = MISSING_SIZE_X << 1,
CREATE_FAILED = MISSING_SIZE_Y << 1
};
/**
* This callback is installed on every placement of the canvas in the
* scene to only render the canvas if at least one placement is visible
*/
class CullCallback:
public osg::NodeCallback
{
public:
CullCallback(const CanvasWeakPtr& canvas);
private:
CanvasWeakPtr _canvas;
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
};
typedef osg::ref_ptr<CullCallback> CullCallbackPtr;
Canvas(SGPropertyNode* node);
virtual ~Canvas();
void setSystemAdapter(const SystemAdapterPtr& system_adapter);
SystemAdapterPtr getSystemAdapter() const;
void setCanvasMgr(CanvasMgr* canvas_mgr);
CanvasMgr* getCanvasMgr() const;
/**
* Add a canvas which should be mared as dirty upon any change to this
* canvas.
*
* This mechanism is used to eg. redraw a canvas if it's displaying
* another canvas (recursive canvases)
*/
void addDependentCanvas(const CanvasWeakPtr& canvas);
/**
* Stop notifying the given canvas upon changes
*/
void removeDependentCanvas(const CanvasWeakPtr& canvas);
GroupPtr createGroup(const std::string& name = "");
/**
* Enable rendering for the next frame
*
* @param force Force redraw even if nothing has changed (if dirty flag
* is not set)
*/
void enableRendering(bool force = false);
void update(double delta_time_sec);
naRef addEventListener(const nasal::CallContext& ctx);
void setSizeX(int sx);
void setSizeY(int sy);
int getSizeX() const;
int getSizeY() const;
void setViewWidth(int w);
void setViewHeight(int h);
int getViewWidth() const;
int getViewHeight() const;
bool handleMouseEvent(const MouseEventPtr& event);
virtual void childAdded( SGPropertyNode * parent,
SGPropertyNode * child );
virtual void childRemoved( SGPropertyNode * parent,
SGPropertyNode * child );
virtual void valueChanged (SGPropertyNode * node);
osg::Texture2D* getTexture() const;
CullCallbackPtr getCullCallback() const;
static void addPlacementFactory( const std::string& type,
PlacementFactory factory );
protected:
SystemAdapterPtr _system_adapter;
CanvasMgr *_canvas_mgr;
std::auto_ptr<EventManager> _event_manager;
int _size_x,
_size_y,
_view_width,
_view_height;
PropertyObject<int> _status;
PropertyObject<std::string> _status_msg;
bool _sampling_dirty,
_render_dirty,
_visible;
ODGauge _texture;
GroupPtr _root_group;
CullCallbackPtr _cull_callback;
bool _render_always; //<! Used to disable automatic lazy rendering (culling)
std::vector<SGPropertyNode*> _dirty_placements;
std::vector<Placements> _placements;
std::set<CanvasWeakPtr> _dependent_canvases; //<! Canvases which use this
// canvas and should be
// notified about changes
typedef std::map<std::string, PlacementFactory> PlacementFactoryMap;
static PlacementFactoryMap _placement_factories;
virtual void setSelf(const PropertyBasedElementPtr& self);
void setStatusFlags(unsigned int flags, bool set = true);
private:
Canvas(const Canvas&); // = delete;
Canvas& operator=(const Canvas&); // = delete;
};
} // namespace canvas
} // namespace simgear
#endif /* CANVAS_HXX_ */

View File

@@ -0,0 +1,98 @@
// Canvas Event for event model similar to DOM Level 3 Event Model
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#include "CanvasEvent.hxx"
namespace simgear
{
namespace canvas
{
//----------------------------------------------------------------------------
Event::Event():
type(UNKNOWN),
propagation_stopped(false)
{
}
//----------------------------------------------------------------------------
Event::~Event()
{
}
//----------------------------------------------------------------------------
Event::Type Event::getType() const
{
return type;
}
//----------------------------------------------------------------------------
std::string Event::getTypeString() const
{
switch( type )
{
# define ENUM_MAPPING(name, str) case name: return str;
# include "CanvasEventTypes.hxx"
# undef ENUM_MAPPING
default:
return "unknown";
}
}
//----------------------------------------------------------------------------
ElementWeakPtr Event::getTarget() const
{
return target;
}
//----------------------------------------------------------------------------
double Event::getTime() const
{
return time;
}
//----------------------------------------------------------------------------
void Event::stopPropagation()
{
propagation_stopped = true;
}
//----------------------------------------------------------------------------
Event::Type Event::strToType(const std::string& str)
{
typedef std::map<std::string, Type> TypeMap;
static TypeMap type_map;
if( type_map.empty() )
{
# define ENUM_MAPPING(type, str) type_map[ str ] = type;
# include "CanvasEventTypes.hxx"
# undef ENUM_MAPPING
}
TypeMap::const_iterator it = type_map.find(str);
if( it == type_map.end() )
return UNKNOWN;
return it->second;
}
} // namespace canvas
} // namespace simgear

View File

@@ -0,0 +1,70 @@
// Canvas Event for event model similar to DOM Level 3 Event Model
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef CANVAS_EVENT_HXX_
#define CANVAS_EVENT_HXX_
#include "canvas_fwd.hxx"
namespace simgear
{
namespace canvas
{
class Event
{
public:
enum Type
{
UNKNOWN,
# define ENUM_MAPPING(name, str) name,
# include "CanvasEventTypes.hxx"
# undef ENUM_MAPPING
USER_TYPE ///<! first unused id to be used for user defined types (not
/// implemented yet)
};
Type type;
ElementWeakPtr target;
double time;
bool propagation_stopped;
Event();
// We need a vtable to allow nasal::Ghost to determine the dynamic type
// of the actual event instances.
virtual ~Event();
Type getType() const;
std::string getTypeString() const;
ElementWeakPtr getTarget() const;
double getTime() const;
void stopPropagation();
static Type strToType(const std::string& str);
};
} // namespace canvas
} // namespace simgear
#endif /* CANVAS_EVENT_HXX_ */

View File

@@ -0,0 +1,70 @@
// Listener for canvas (GUI) events being passed to a Nasal function/code
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#include "CanvasEvent.hxx"
#include "CanvasEventListener.hxx"
#include "CanvasSystemAdapter.hxx"
#include <simgear/nasal/cppbind/Ghost.hxx>
namespace simgear
{
namespace canvas
{
//----------------------------------------------------------------------------
EventListener::EventListener(naRef code, const SystemAdapterPtr& sys_adapter):
_code(code),
_gc_key(-1),
_sys(sys_adapter)
{
assert( sys_adapter );
if( !naIsCode(code)
&& !naIsCCode(code)
&& !naIsFunc(code) )
throw std::runtime_error
(
"canvas::EventListener: invalid function argument"
);
_gc_key = sys_adapter->gcSave(_code);
}
//----------------------------------------------------------------------------
EventListener::~EventListener()
{
assert( !_sys.expired() );
_sys.lock()->gcRelease(_gc_key);
}
//----------------------------------------------------------------------------
void EventListener::call(const canvas::EventPtr& event)
{
SystemAdapterPtr sys = _sys.lock();
naRef args[] = {
nasal::Ghost<EventPtr>::create(sys->getNasalContext(), event)
};
const int num_args = sizeof(args)/sizeof(args[0]);
sys->callMethod(_code, naNil(), num_args, args, naNil());
}
} // namespace canvas
} // namespace simgear

View File

@@ -0,0 +1,48 @@
// Listener for canvas (GUI) events being passed to a Nasal function/code
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef CANVAS_EVENT_LISTENER_HXX_
#define CANVAS_EVENT_LISTENER_HXX_
#include "canvas_fwd.hxx"
#include <simgear/nasal/naref.h>
namespace simgear
{
namespace canvas
{
class EventListener
{
public:
EventListener( naRef code,
const SystemAdapterPtr& sys_adapter );
~EventListener();
void call(const canvas::EventPtr& event);
protected:
naRef _code;
int _gc_key;
SystemAdapterWeakPtr _sys;
};
} // namespace canvas
} // namespace simgear
#endif /* CANVAS_EVENT_LISTENER_HXX_ */

View File

@@ -0,0 +1,270 @@
// Manage event handling inside a Canvas similar to the DOM Level 3 Event Model
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#include "CanvasEventManager.hxx"
#include "MouseEvent.hxx"
#include <simgear/canvas/elements/CanvasElement.hxx>
namespace simgear
{
namespace canvas
{
const unsigned int drag_threshold = 8;
const double multi_click_timeout = 0.4;
//----------------------------------------------------------------------------
EventManager::StampedPropagationPath::StampedPropagationPath():
time(0)
{
}
//----------------------------------------------------------------------------
EventManager::StampedPropagationPath::StampedPropagationPath(
const EventPropagationPath& path,
double time
):
path(path),
time(time)
{
}
//----------------------------------------------------------------------------
void EventManager::StampedPropagationPath::clear()
{
path.clear();
time = 0;
}
//----------------------------------------------------------------------------
bool EventManager::StampedPropagationPath::valid() const
{
return !path.empty() && time > 0;
}
//----------------------------------------------------------------------------
EventManager::EventManager():
_current_click_count(0)
{
}
//----------------------------------------------------------------------------
bool EventManager::handleEvent( const MouseEventPtr& event,
const EventPropagationPath& path )
{
switch( event->type )
{
case Event::MOUSE_DOWN:
_last_mouse_down = StampedPropagationPath(path, event->getTime());
break;
case Event::MOUSE_UP:
{
if( _last_mouse_down.path.empty() )
// Ignore mouse up without any previous mouse down
return false;
// normal mouseup
propagateEvent(event, path);
// now handle click/dblclick
if( checkClickDistance(path, _last_mouse_down.path) )
handleClick(event, getCommonAncestor(_last_mouse_down.path, path));
_last_mouse_down.clear();
return true;
}
case Event::DRAG:
if( !_last_mouse_down.valid() )
return false;
else
return propagateEvent(event, _last_mouse_down.path);
case Event::MOUSE_MOVE:
handleMove(event, path);
break;
case Event::MOUSE_LEAVE:
// Mouse leaves window and therefore also current mouseover element
handleMove(event, EventPropagationPath());
return true;
case Event::WHEEL:
break;
default:
return false;
}
return propagateEvent(event, path);
}
//----------------------------------------------------------------------------
void EventManager::handleClick( const MouseEventPtr& event,
const EventPropagationPath& path )
{
MouseEventPtr click(new MouseEvent(*event));
click->type = Event::CLICK;
if( event->getTime() > _last_click.time + multi_click_timeout )
_current_click_count = 1;
else
{
// Maximum current click count is 3
_current_click_count = (_current_click_count % 3) + 1;
if( _current_click_count > 1 )
{
// Reset current click count if moved too far
if( !checkClickDistance(path, _last_click.path) )
_current_click_count = 1;
}
}
click->click_count = _current_click_count;
MouseEventPtr dbl_click;
if( _current_click_count == 2 )
{
dbl_click.reset(new MouseEvent(*click));
dbl_click->type = Event::DBL_CLICK;
}
propagateEvent(click, path);
if( dbl_click )
propagateEvent(dbl_click, getCommonAncestor(_last_click.path, path));
_last_click = StampedPropagationPath(path, event->getTime());
}
//----------------------------------------------------------------------------
void EventManager::handleMove( const MouseEventPtr& event,
const EventPropagationPath& path )
{
if( _last_mouse_over.path == path )
return;
if( !_last_mouse_over.path.empty() )
{
MouseEventPtr mouseout(new MouseEvent(*event));
mouseout->type = Event::MOUSE_OUT;
propagateEvent(mouseout, _last_mouse_over.path);
}
if( !path.empty() )
{
MouseEventPtr mouseover(new MouseEvent(*event));
mouseover->type = Event::MOUSE_OVER;
propagateEvent(mouseover, path);
}
_last_mouse_over.path = path;
}
//----------------------------------------------------------------------------
bool EventManager::propagateEvent( const EventPtr& event,
const EventPropagationPath& path )
{
event->target = path.back().element;
MouseEventPtr mouse_event = boost::dynamic_pointer_cast<MouseEvent>(event);
// Event propagation similar to DOM Level 3 event flow:
// http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
// Capturing phase
// for( EventTargets::iterator it = _target_path.begin();
// it != _target_path.end();
// ++it )
// {
// if( it->element )
// std::cout << it->element->getProps()->getPath() << " "
// << "(" << it->local_pos.x() << "|" << it->local_pos.y() << ")\n";
// }
// Bubbling phase
for( EventPropagationPath::const_reverse_iterator
it = path.rbegin();
it != path.rend();
++it )
{
ElementPtr el = it->element.lock();
if( !el )
// Ignore element if it has been destroyed while traversing the event
// (eg. removed by another event handler)
continue;
// TODO provide functions to convert position and delta to local
// coordinates on demand. Events shouldn't contain informations in
// local coordinates as they might differe between different elements
// receiving the same event.
// if( mouse_event && event->type != Event::DRAG )
// {
// // TODO transform pos and delta for drag events. Maybe we should just
// // store the global coordinates and convert to local coordinates
// // on demand.
//
// // Position and delta are specified in local coordinate system of
// // current element
// mouse_event->pos = it->local_pos;
// mouse_event->delta = it->local_delta;
// }
el->callListeners(event);
if( event->propagation_stopped )
return true;
}
return true;
}
//----------------------------------------------------------------------------
bool
EventManager::checkClickDistance( const EventPropagationPath& path1,
const EventPropagationPath& path2 ) const
{
osg::Vec2 delta = path1.front().local_pos - path2.front().local_pos;
return delta.x() < drag_threshold
&& delta.y() < drag_threshold;
}
//----------------------------------------------------------------------------
EventPropagationPath
EventManager::getCommonAncestor( const EventPropagationPath& path1,
const EventPropagationPath& path2 ) const
{
if( path1.back().element.lock() == path2.back().element.lock() )
return path2;
EventPropagationPath path;
for( size_t i = 0; i < path1.size() && i < path2.size(); ++i )
{
if( path1[i].element.lock() != path2[i].element.lock() )
break;
path.push_back(path2[i]);
}
return path;
}
} // namespace canvas
} // namespace simgear

View File

@@ -0,0 +1,100 @@
// Manage event handling inside a Canvas similar to the DOM Level 3 Event Model
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef CANVAS_EVENT_MANAGER_HXX_
#define CANVAS_EVENT_MANAGER_HXX_
#include "canvas_fwd.hxx"
#include <deque>
namespace simgear
{
namespace canvas
{
struct EventTarget
{
ElementWeakPtr element;
osg::Vec2f local_pos,
local_delta;
};
typedef std::deque<EventTarget> EventPropagationPath;
inline bool operator==(const EventTarget& t1, const EventTarget& t2)
{
return t1.element.lock() == t2.element.lock();
}
class EventManager
{
public:
EventManager();
bool handleEvent( const MouseEventPtr& event,
const EventPropagationPath& path );
protected:
struct StampedPropagationPath
{
StampedPropagationPath();
StampedPropagationPath(const EventPropagationPath& path, double time);
void clear();
bool valid() const;
EventPropagationPath path;
double time;
};
// TODO if we really need the paths modify to not copy around the paths
// that much.
StampedPropagationPath _last_mouse_down,
_last_click,
_last_mouse_over;
size_t _current_click_count;
/**
* Propagate click event and handle multi-click (eg. create dblclick)
*/
void handleClick( const MouseEventPtr& event,
const EventPropagationPath& path );
/**
* Handle mouseover/enter/out/leave
*/
void handleMove( const MouseEventPtr& event,
const EventPropagationPath& path );
bool propagateEvent( const EventPtr& event,
const EventPropagationPath& path );
/**
* Check if two click events (either mousedown/up or two consecutive
* clicks) are inside a maximum distance to still create a click or
* dblclick event respectively.
*/
bool checkClickDistance( const EventPropagationPath& path1,
const EventPropagationPath& path2 ) const;
EventPropagationPath
getCommonAncestor( const EventPropagationPath& path1,
const EventPropagationPath& path2 ) const;
};
} // namespace canvas
} // namespace simgear
#endif /* CANVAS_EVENT_MANAGER_HXX_ */

View File

@@ -0,0 +1,33 @@
// Mapping between canvas gui Event types and their names
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef ENUM_MAPPING
# error "Don't include this file directly!"
#endif
ENUM_MAPPING(MOUSE_DOWN, "mousedown")
ENUM_MAPPING(MOUSE_UP, "mouseup")
ENUM_MAPPING(CLICK, "click")
ENUM_MAPPING(DBL_CLICK, "dblclick")
ENUM_MAPPING(DRAG, "drag")
ENUM_MAPPING(WHEEL, "wheel")
ENUM_MAPPING(MOUSE_MOVE, "mousemove")
ENUM_MAPPING(MOUSE_OVER, "mouseover")
ENUM_MAPPING(MOUSE_OUT, "mouseout")
ENUM_MAPPING(MOUSE_ENTER, "mouseenter")
ENUM_MAPPING(MOUSE_LEAVE, "mouseleave")

View File

@@ -0,0 +1,106 @@
// Visitor for traversing a canvas element hierarchy similar to the traversal
// of the DOM Level 3 Event Model
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#include "CanvasEvent.hxx"
#include "CanvasEventVisitor.hxx"
#include <simgear/canvas/elements/CanvasElement.hxx>
#include <iostream>
namespace simgear
{
namespace canvas
{
//----------------------------------------------------------------------------
EventVisitor::EventVisitor( TraverseMode mode,
const osg::Vec2f& pos,
const osg::Vec2f& delta ):
_traverse_mode( mode )
{
if( mode == TRAVERSE_DOWN )
{
EventTarget target = {ElementWeakPtr(), pos, delta};
_target_path.push_back(target);
}
}
//----------------------------------------------------------------------------
EventVisitor::~EventVisitor()
{
}
//----------------------------------------------------------------------------
bool EventVisitor::traverse(Element& el)
{
if( _traverse_mode == TRAVERSE_UP )
return el.ascend(*this);
else
return el.traverse(*this);
}
//----------------------------------------------------------------------------
bool EventVisitor::apply(Element& el)
{
// We only need to check for hits while traversing down
if( _traverse_mode == TRAVERSE_DOWN )
{
// Transform event to local coordinates
const osg::Matrix& m = el.getMatrixTransform()->getInverseMatrix();
const osg::Vec2f& pos = _target_path.back().local_pos;
const osg::Vec2f local_pos
(
m(0, 0) * pos[0] + m(1, 0) * pos[1] + m(3, 0),
m(0, 1) * pos[0] + m(1, 1) * pos[1] + m(3, 1)
);
// Don't check collision with root element (2nd element in _target_path)
// do event listeners attached to the canvas itself (its root group)
// always get called even if no element has been hit.
if( _target_path.size() > 2 && !el.hitBound(pos, local_pos) )
return false;
const osg::Vec2f& delta = _target_path.back().local_delta;
const osg::Vec2f local_delta
(
m(0, 0) * delta[0] + m(1, 0) * delta[1],
m(0, 1) * delta[0] + m(1, 1) * delta[1]
);
EventTarget target = {el.getWeakPtr(), local_pos, local_delta};
_target_path.push_back(target);
if( el.traverse(*this) || _target_path.size() <= 2 )
return true;
_target_path.pop_back();
return false;
}
else
return el.ascend(*this);
}
//----------------------------------------------------------------------------
const EventPropagationPath& EventVisitor::getPropagationPath() const
{
return _target_path;
}
} // namespace canvas
} // namespace simgear

View File

@@ -0,0 +1,61 @@
// Visitor for traversing a canvas element hierarchy similar to the traversal
// of the DOM Level 3 Event Model
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef CANVAS_EVENT_VISITOR_HXX_
#define CANVAS_EVENT_VISITOR_HXX_
#include "canvas_fwd.hxx"
#include "CanvasEventManager.hxx"
namespace simgear
{
namespace canvas
{
class EventVisitor
{
public:
enum TraverseMode
{
TRAVERSE_UP,
TRAVERSE_DOWN
};
EventVisitor( TraverseMode mode,
const osg::Vec2f& pos,
const osg::Vec2f& delta );
virtual ~EventVisitor();
virtual bool traverse(Element& el);
virtual bool apply(Element& el);
const EventPropagationPath& getPropagationPath() const;
protected:
TraverseMode _traverse_mode;
EventPropagationPath _target_path;
};
} // namespace canvas
} // namespace simgear
#endif /* CANVAS_EVENTVISITOR_HXX_ */

View File

@@ -0,0 +1,73 @@
// Canvas with 2D rendering API
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#include "CanvasMgr.hxx"
#include "Canvas.hxx"
#include <boost/bind.hpp>
namespace simgear
{
namespace canvas
{
/**
* Canvas factory
*/
CanvasPtr canvasFactory(SGPropertyNode* node)
{
return CanvasPtr(new Canvas(node));
}
//----------------------------------------------------------------------------
CanvasMgr::CanvasMgr( SGPropertyNode_ptr node,
SystemAdapterPtr system_adapter ):
PropertyBasedMgr(node, "texture", &canvasFactory),
_system_adapter(system_adapter)
{
}
//----------------------------------------------------------------------------
CanvasPtr CanvasMgr::createCanvas(const std::string& name)
{
return boost::static_pointer_cast<Canvas>( createElement(name) );
}
//----------------------------------------------------------------------------
CanvasPtr CanvasMgr::getCanvas(size_t index) const
{
return boost::static_pointer_cast<Canvas>( getElement(index) );
}
//----------------------------------------------------------------------------
CanvasPtr CanvasMgr::getCanvas(const std::string& name) const
{
return boost::static_pointer_cast<Canvas>( getElement(name) );
}
//----------------------------------------------------------------------------
void CanvasMgr::elementCreated(PropertyBasedElementPtr element)
{
CanvasPtr canvas = boost::static_pointer_cast<Canvas>(element);
canvas->setSystemAdapter(_system_adapter);
canvas->setCanvasMgr(this);
}
} // namespace canvas
} // namespace simgear

View File

@@ -0,0 +1,76 @@
// Canvas with 2D rendering API
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef SG_CANVAS_MGR_H_
#define SG_CANVAS_MGR_H_
#include "canvas_fwd.hxx"
#include <simgear/props/PropertyBasedMgr.hxx>
namespace simgear
{
namespace canvas
{
class CanvasMgr:
public PropertyBasedMgr
{
public:
/**
* @param node Root node of branch used to control canvasses
* @param system_adapter Adapter for connecting between canvas and
* application framework
*
*/
CanvasMgr( SGPropertyNode_ptr node,
SystemAdapterPtr system_adapter );
/**
* Create a new canvas
*
* @param name Name of the new canvas
*/
CanvasPtr createCanvas(const std::string& name = "");
/**
* Get ::Canvas by index
*
* @param index Index of texture node in /canvas/by-index/
*/
CanvasPtr getCanvas(size_t index) const;
/**
* Get ::Canvas by name
*
* @param name Value of child node "name" in
* /canvas/by-index/texture[i]/name
*/
CanvasPtr getCanvas(const std::string& name) const;
protected:
SystemAdapterPtr _system_adapter;
virtual void elementCreated(PropertyBasedElementPtr element);
};
} // namespace canvas
} // namespace simgear
#endif /* SG_CANVAS_MGR_H_ */

View File

@@ -0,0 +1,59 @@
// Base class for canvas placements
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#include "CanvasPlacement.hxx"
#include <simgear/props/props.hxx>
namespace simgear
{
namespace canvas
{
//----------------------------------------------------------------------------
Placement::Placement(SGPropertyNode* node):
_node(node)
{
}
//----------------------------------------------------------------------------
Placement::~Placement()
{
}
//----------------------------------------------------------------------------
SGConstPropertyNode_ptr Placement::getProps() const
{
return _node;
}
//----------------------------------------------------------------------------
SGPropertyNode_ptr Placement::getProps()
{
return _node;
}
//----------------------------------------------------------------------------
bool Placement::childChanged(SGPropertyNode* child)
{
return false;
}
} // namespace canvas
} // namespace simgear

View File

@@ -0,0 +1,51 @@
// Base class for canvas placements
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef CANVAS_PLACEMENT_HXX_
#define CANVAS_PLACEMENT_HXX_
#include <simgear/props/propsfwd.hxx>
namespace simgear
{
namespace canvas
{
class Placement
{
public:
Placement(SGPropertyNode* node);
virtual ~Placement() = 0;
SGConstPropertyNode_ptr getProps() const;
SGPropertyNode_ptr getProps();
virtual bool childChanged(SGPropertyNode* child);
protected:
SGPropertyNode_ptr _node;
private:
Placement(const Placement&) /* = delete */;
Placement& operator=(const Placement&) /* = delete */;
};
} // namespace canvas
} // namespace simgear
#endif /* CANVAS_PLACEMENT_HXX_ */

View File

@@ -0,0 +1,67 @@
// Adapter for using the canvas with different applications
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef SG_CANVAS_SYSTEM_ADAPTER_HXX_
#define SG_CANVAS_SYSTEM_ADAPTER_HXX_
#include "canvas_fwd.hxx"
#include <simgear/nasal/nasal.h>
namespace simgear
{
namespace canvas
{
class SystemAdapter
{
public:
virtual ~SystemAdapter() {}
virtual FontPtr getFont(const std::string& name) const = 0;
virtual void addCamera(osg::Camera* camera) const = 0;
virtual void removeCamera(osg::Camera* camera) const = 0;
virtual osg::Image* getImage(const std::string& path) const = 0;
virtual naContext getNasalContext() const = 0;
/**
* Save passed reference to Nasal object from being deleted by the
* garbage collector.
*/
virtual int gcSave(naRef r) = 0;
/**
* Release an object previously passed to ::gcSave to allow it being
* cleaned up by the garbage collector.
*/
virtual void gcRelease(int key) = 0;
/**
* Call a Nasal function with the given environment and arguments.
*/
virtual naRef callMethod( naRef code,
naRef self,
int argc,
naRef* args,
naRef locals ) = 0;
};
} // namespace canvas
} // namespace simgear
#endif /* SG_CANVAS_SYSTEM_ADAPTER_HXX_ */

View File

@@ -0,0 +1,68 @@
// Mouse event
//
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef CANVAS_MOUSE_EVENT_HXX_
#define CANVAS_MOUSE_EVENT_HXX_
#include "CanvasEvent.hxx"
#include <osgGA/GUIEventAdapter>
namespace simgear
{
namespace canvas
{
class MouseEvent:
public Event
{
public:
MouseEvent():
button(-1),
state(-1),
mod(-1),
click_count(0)
{}
osg::Vec2f getScreenPos() const { return screen_pos; }
osg::Vec2f getClientPos() const { return client_pos; }
osg::Vec2f getDelta() const { return delta; }
float getScreenX() const { return screen_pos.x(); }
float getScreenY() const { return screen_pos.y(); }
float getClientX() const { return client_pos.x(); }
float getClientY() const { return client_pos.y(); }
float getDeltaX() const { return delta.x(); }
float getDeltaY() const { return delta.y(); }
int getCurrentClickCount() const { return click_count; }
osg::Vec2f screen_pos, //<! Position in screen coordinates
client_pos, //<! Position in window/canvas coordinates
delta;
int button, //<! Button for this event
state, //<! Current button state
mod, //<! Keyboard modifier state
click_count; //<! Current click count
};
} // namespace canvas
} // namespace simgear
#endif /* CANVAS_MOUSE_EVENT_HXX_ */

306
simgear/canvas/ODGauge.cxx Normal file
View File

@@ -0,0 +1,306 @@
// Owner Drawn Gauge helper class
//
// Written by Harald JOHNSEN, started May 2005.
//
// Copyright (C) 2005 Harald JOHNSEN
//
// Ported to OSG by Tim Moore - Jun 2007
//
// Heavily modified to be usable for the 2d Canvas by Thomas Geymayer - April 2012
// Supports now multisampling/mipmapping, usage of the stencil buffer and placing
// the texture in the scene by certain filter criteria
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifdef HAVE_CONFIG_H
# include <simgear_config.h>
#endif
#include "ODGauge.hxx"
#include "CanvasSystemAdapter.hxx"
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/util/RenderConstants.hxx>
#include <osg/Texture2D>
#include <osg/AlphaFunc>
#include <osg/BlendFunc>
#include <osg/Camera>
#include <osg/Matrix>
#include <osg/PolygonMode>
#include <osg/ShadeModel>
#include <osg/StateSet>
#include <osg/FrameBufferObject> // for GL_DEPTH_STENCIL_EXT on Windows
#include <cassert>
namespace simgear
{
namespace canvas
{
//----------------------------------------------------------------------------
ODGauge::ODGauge():
_size_x( -1 ),
_size_y( -1 ),
_view_width( -1 ),
_view_height( -1 ),
_use_image_coords( false ),
_use_stencil( false ),
_use_mipmapping( false ),
_coverage_samples( 0 ),
_color_samples( 0 ),
rtAvailable( false )
{
}
//----------------------------------------------------------------------------
ODGauge::~ODGauge()
{
clear();
}
//----------------------------------------------------------------------------
void ODGauge::setSystemAdapter(const SystemAdapterPtr& system_adapter)
{
_system_adapter = system_adapter;
}
//----------------------------------------------------------------------------
void ODGauge::setSize(int size_x, int size_y)
{
_size_x = size_x;
_size_y = size_y < 0 ? size_x : size_y;
if( serviceable() )
reinit();
else if( texture )
texture->setTextureSize(_size_x, _size_y);
}
//----------------------------------------------------------------------------
void ODGauge::setViewSize(int width, int height)
{
_view_width = width;
_view_height = height < 0 ? width : height;
if( camera )
updateCoordinateFrame();
}
//----------------------------------------------------------------------------
void ODGauge::useImageCoords(bool use)
{
if( use == _use_image_coords )
return;
_use_image_coords = use;
if( texture )
updateCoordinateFrame();
}
//----------------------------------------------------------------------------
void ODGauge::useStencil(bool use)
{
if( use == _use_stencil )
return;
_use_stencil = use;
if( texture )
updateStencil();
}
//----------------------------------------------------------------------------
void ODGauge::setSampling( bool mipmapping,
int coverage_samples,
int color_samples )
{
if( _use_mipmapping == mipmapping
&& _coverage_samples == coverage_samples
&& _color_samples == color_samples )
return;
_use_mipmapping = mipmapping;
if( color_samples > coverage_samples )
{
SG_LOG
(
SG_GL,
SG_WARN,
"ODGauge::setSampling: color_samples > coverage_samples not allowed!"
);
color_samples = coverage_samples;
}
_coverage_samples = coverage_samples;
_color_samples = color_samples;
updateSampling();
}
//----------------------------------------------------------------------------
void ODGauge::setRender(bool render)
{
// Only the far camera should trigger this texture to be rendered.
camera->setNodeMask(render ? simgear::BACKGROUND_BIT : 0);
}
//----------------------------------------------------------------------------
bool ODGauge::serviceable(void)
{
return rtAvailable;
}
//----------------------------------------------------------------------------
void ODGauge::allocRT(osg::NodeCallback* camera_cull_callback)
{
camera = new osg::Camera;
camera->setDataVariance(osg::Object::DYNAMIC);
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setRenderOrder(osg::Camera::PRE_RENDER);
camera->setClearColor(osg::Vec4(0.0f, 0.0f, 0.0f , 0.0f));
camera->setClearStencil(0);
camera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT,
osg::Camera::FRAME_BUFFER );
if( camera_cull_callback )
camera->setCullCallback(camera_cull_callback);
setRender(true);
updateCoordinateFrame();
updateStencil();
osg::StateSet* stateSet = camera->getOrCreateStateSet();
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
stateSet->setMode(GL_FOG, osg::StateAttribute::OFF);
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
stateSet->setAttributeAndModes(
new osg::PolygonMode( osg::PolygonMode::FRONT_AND_BACK,
osg::PolygonMode::FILL ),
osg::StateAttribute::ON );
stateSet->setAttributeAndModes(
new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.0f),
osg::StateAttribute::ON );
stateSet->setAttribute(new osg::ShadeModel(osg::ShadeModel::FLAT));
stateSet->setAttributeAndModes(
new osg::BlendFunc( osg::BlendFunc::SRC_ALPHA,
osg::BlendFunc::ONE_MINUS_SRC_ALPHA),
osg::StateAttribute::ON );
if( !texture )
{
texture = new osg::Texture2D;
texture->setTextureSize(_size_x, _size_y);
texture->setInternalFormat(GL_RGBA);
}
updateSampling();
if( _system_adapter )
_system_adapter->addCamera(camera.get());
rtAvailable = true;
}
//----------------------------------------------------------------------------
void ODGauge::reinit()
{
osg::NodeCallback* cull_callback = camera ? camera->getCullCallback() : 0;
clear();
allocRT(cull_callback);
}
//----------------------------------------------------------------------------
void ODGauge::clear()
{
if( camera.valid() && _system_adapter )
_system_adapter->removeCamera(camera.get());
camera.release();
texture.release();
rtAvailable = false;
}
//----------------------------------------------------------------------------
void ODGauge::updateCoordinateFrame()
{
assert( camera );
if( _view_width < 0 )
_view_width = _size_x;
if( _view_height < 0 )
_view_height = _size_y;
camera->setViewport(0, 0, _size_x, _size_y);
if( _use_image_coords )
camera->setProjectionMatrix(
osg::Matrix::ortho2D(0, _view_width, _view_height, 0)
);
else
camera->setProjectionMatrix(
osg::Matrix::ortho2D( -_view_width/2., _view_width/2.,
-_view_height/2., _view_height/2. )
);
}
//----------------------------------------------------------------------------
void ODGauge::updateStencil()
{
assert( camera );
GLbitfield mask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
if( _use_stencil)
{
camera->attach( osg::Camera::PACKED_DEPTH_STENCIL_BUFFER,
GL_DEPTH_STENCIL_EXT );
mask |= GL_STENCIL_BUFFER_BIT;
}
else
{
camera->detach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER);
}
camera->setClearMask(mask);
}
//----------------------------------------------------------------------------
void ODGauge::updateSampling()
{
assert( camera );
assert( texture );
texture->setFilter(
osg::Texture2D::MIN_FILTER,
_use_mipmapping ? osg::Texture2D::LINEAR_MIPMAP_LINEAR
: osg::Texture2D::LINEAR
);
camera->attach(
osg::Camera::COLOR_BUFFER,
texture.get(),
0, 0,
_use_mipmapping,
_coverage_samples,
_color_samples
);
}
} // namespace canvas
} // namespace simgear

158
simgear/canvas/ODGauge.hxx Normal file
View File

@@ -0,0 +1,158 @@
// Owner Drawn Gauge helper class
//
// Written by Harald JOHNSEN, started May 2005.
//
// Copyright (C) 2005 Harald JOHNSEN - hjohnsen@evc.net
//
// Ported to OSG by Tim Moore - Jun 2007
//
// Heavily modified to be usable for the 2d Canvas by Thomas Geymayer - April 2012
// Supports now multisampling/mipmapping, usage of the stencil buffer and placing
// the texture in the scene by certain filter criteria
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef _SG_OD_GAUGE_HXX
#define _SG_OD_GAUGE_HXX
#include "canvas_fwd.hxx"
#include <osg/NodeCallback>
#include <osg/Group>
namespace osg
{
class Camera;
class Texture2D;
}
namespace simgear
{
namespace canvas
{
/**
* Owner Drawn Gauge (aka render-to-texture) helper class
*/
class ODGauge
{
public:
ODGauge();
virtual ~ODGauge();
void setSystemAdapter(const SystemAdapterPtr& system_adapter);
/**
* Set the size of the render target.
*
* @param size_x X size
* @param size_y Y size. Defaults to size_x if not specified
*/
void setSize(int size_x, int size_y = -1);
/**
* Set the size of the viewport
*
* @param width
* @param height Defaults to width if not specified
*/
void setViewSize(int width, int height = -1);
/**
* DEPRECATED
*
* Get size of squared texture
*/
int size() const { return _size_x; }
/**
* Set whether to use image coordinates or not.
*
* Default: origin == center of texture
* Image Coords: origin == top left corner
*/
void useImageCoords(bool use = true);
/**
* Enable/Disable using a stencil buffer
*/
void useStencil(bool use = true);
/**
* Set sampling parameters for mipmapping and coverage sampling
* antialiasing.
*
* @note color_samples is not allowed to be higher than coverage_samples
*
*/
void setSampling( bool mipmapping,
int coverage_samples = 0,
int color_samples = 0 );
/**
* Enable/Disable updating the texture (If disabled the contents of the
* texture remains with the outcome of the last rendering pass)
*/
void setRender(bool render);
/**
* Say if we can render to a texture.
* @return true if rtt is available
*/
bool serviceable(void);
/**
* Get the OSG camera for drawing this gauge.
*/
osg::Camera* getCamera() const { return camera.get(); }
osg::Texture2D* getTexture() const { return texture.get(); }
// Real initialization function. Bad name.
void allocRT(osg::NodeCallback* camera_cull_callback = 0);
void reinit();
void clear();
protected:
SystemAdapterPtr _system_adapter;
int _size_x,
_size_y,
_view_width,
_view_height;
bool _use_image_coords,
_use_stencil,
_use_mipmapping;
// Multisampling parameters
int _coverage_samples,
_color_samples;
bool rtAvailable;
osg::ref_ptr<osg::Camera> camera;
osg::ref_ptr<osg::Texture2D> texture;
void updateCoordinateFrame();
void updateStencil();
void updateSampling();
};
} // namespace canvas
} // namespace simgear
#endif // _SG_OD_GAUGE_HXX

View File

@@ -0,0 +1,12 @@
===============================================================================
ShivaVG - an open-source LGPL ANSI C implementation of the OpenVG specification
===============================================================================
Lead developer:
Ivan Leben <ivan.leben@gmail.com>
Occasional patches:
Daniel Turing
Vincenzo Pupillo

View File

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

View File

@@ -0,0 +1,67 @@
04 Feb 2008 Ivan Leben <ivan.leben@gmail.com>
* shImage.c: shCopyPixels uses memcpy when formats are
equal.
04 Feb 2008 Ivan Leben <ivan.leben@gmail.com>
* openvg.h: changed typedef of VGHandle to void*. Code
compiles with no warnings on 64-bit systems now and
it's much safer anyway.
03 Feb 2008 Ivan Leben <ivan.leben@gmail.com>
* shContest.c: fixed a bug in SHContext destructor where
resource deletion loop was iterating image array while
freeing paint objects
03 Feb 2008 Ivan Leben <ivan.leben@gmail.com>
* a patch by Vincenzo Pupillo fixes array constructor behavior
when it runs out of memory plus makes its destructor a bit
more robust
03 Feb 2008 Ivan Leben <ivan.leben@gmail.com>
* autogen.sh: added --force to autoreconf call
03 Feb 2008 Ivan Leben <ivan.leben@gmail.com>
* Removed automake/autoconf generated files. Added autogen.sh
to generate them.
03 Feb 2008 Ivan Leben <ivan.leben@gmail.com>
* configure.in: changed order of checks for glut library and
glXGetProcAddress in -lGL so that latter doesn't fail when
glut is not installed.
30 Jan 2008 Ivan Leben <ivan.leben@gmail.com>
* shGeometry.c: shStrokePath() fixed to handle zero-length line
segments gracefully
* fixed the image color component ordering to be valid against the
spec
* shImage.c, shImage.h: completely overhauled to support multiple
image formats. Everything but _PRE and _BW_1 now supported.
24 Jan 2008 Ivan Leben <ivan.leben@gmail.com>
* Moved release-related info from ChangeLog to NEWS. ChangeLog will
now include info regarding each commit to repository
* Rearranged the path tesselletaion and user-to-surface transformation
steps in the pipeline to produce higher curve resolution when path is
scaled up
* Using new pipeline design, transformed bound-box query can now return
really tight bounds
* Inserted empty/nop definitions for all non-implemented function so
that linking against the library doesn't fail.
22 Jan 2008 Ivan Leben <ivan.leben@gmail.com>
* Fixed a bug where vgGetError would always return VG_NO_ERROR

View File

@@ -0,0 +1,80 @@
shIsValid* functions do a search through array!!!
That is required because user handles are actually pointers and need to be found in the valid path array. Solution would be to use indices into an array of pointers for internal handle-to-pointer conversion. When a path is deleted, an empty space would be left in the array and used when the next path is created.
How to speed up image upload / manipulation
=============================================
1) shCopyPixels uses memcpy
First, manipulation can be speeded up by modifying shCopyPixels
to copy lines using memcpy directly when source and target
formats are equal. If stride is same too, than we can memcpy
the whole block of memory.
2) What about mapping image manipulation directly to OpenGL
texture manipulation calls? Which formats could support this?
PROBLEM: if NOPS textures are not supported, then writing
and reading the image data back results in a precision loss!
Even if PBO available we'd need to gluScaleImage into it.
--> means: no NOPS, need intermediate buffer anyway
=== Solution1: PBO are available ====
Extension required: EXT_pixel_buffer_object (ARB_pixel_buffer_object ?)
Complexity of implementation: really easy - PBO simply
replaces the buffer that would be used if NOPS were not there
Cannot just glBindBuffer(GL_PIXEL_UNPACK_BUFFER) and then
glReadPixels into client memory, because glPixelStore
doesn't allow for random row byte size ("stride" must be
a multiple of pixel byte size).
We can safely glMapBuffer and copy from it whatever we want
however we want, and do any kind of conversion inbetween.
Is glMapBuffer + memcpy into user memory faster than just
glGetTexImage? Probably yes, since glGetTexImage probably
first downloads the data from GPU anyway.
glMapBuffer better anyway, because we can directly do the format
conversions unsupported by OpenGL (premultiplied to unpremultiplied,
grayscale conversion with different per component coefficients
instead of simple averaging etc.). We use all the exact same code
as when NOPS not supported.
=== Solution2: no PBOs ===
- vgImageSubData => glTexSubImage2D
- vgGetImageSubData => glGetTexImage
- vgCopyImage => glGetTexImage, glTexSubImage2D
- vgSetPixels => glGetTexImage, glDrawPixels
(PROBLEM: for glGetTexImage, row length in glPixelStore must
be a multiple of pixel byte size!)
- when copying pixels to/from the texture, we still need to
manually clip the working pixel region to the intersection
of the source and destination rectangles, since opengl spec
says INVALID_VALUE error is generated for invalid regions
(e.g. dstX + copyW > dstW)
How to solve great slow-down when scaled up?
=============================================
Reasons:
- cpu is subdividing a loooong path
- fill-rate is a bad thing
1. By writing gradient shaders, there would be no need to
draw into stencil first and then fill the whole area where stencil
odd - at least not when drawing stroke (optimizes half of the pipeline)
2. Real tesselation would reduce fill rate for filled paths, but does
the CPU bottleneck outweight the gain?
3. Early path discarding (transformed bounds outside surface? maybe
early convex-hull rule removal?)

View File

@@ -0,0 +1,38 @@
version 0.2.0 to 0.2.1 (20 Mar 2009):
* Implemented scissoring for 1 scissor rectangle
version 0.2.0 (20 Jan 2008):
* Fixed a bug where rotation in the paint-to-user matrix broke radial
gradient fill.
* vgCreateContextSH interface changed to allow for specification of
surface width and height
* new extension: vgResizeSurfaceSH to be called whenever the surface
needs to be resized to match the new window size
* #define GL_GLEXT_LEGACY in shExtensions.h prior to including gl.h
so it doesn't include glext.h automatically, which enables us to
check for OpenGL version and define OpenGL extension functions
manually.
* Optimized image uploading by replacing the call to gluBuild2DMipmaps
with glTexImage2D and changing the filter used to GL_LINEAR
* Added detection of ARB_texture_non_power_of_two extension to upload
rectangular images directly instead of scaling them and loosing
precision
* Pattern paint implemented
* Include folder changed to "vg" (lowercase)
* Added a message to test_blend program to notify the user that it
has not been implemented yet (black screen is therefore fine)
* All the calls to glLoadMatrix replaced with glPushMatrix,
glMultMatrix, glPopMatrix.
* Replaced images used in example programs for royalty-free
* README file written

View File

@@ -0,0 +1,252 @@
ShivaVG
=============================
See AUTHORS for the list of contributors
ShivaVG is an open-source LGPL ANSI C implementation of the Khronos
Group OpenVG specification.
I. BUILD
II. TESTING
III. IMPLEMENTATION STATUS
IV. EXTENSIONS
I. BUILD
=============================
* Prerequisites:
OpenGL development libraries and headers should be installed.
Othe than that, since it's ANSI C should compile with any modern
C compiler. jpeglib needs to be installed for example programs
that use images.
* Compiling under UNIX systems:
Read the INSTALL file for more detailed (though generic) directions.
This library uses the standard ./configure ; make. The example
programs are automatically compiled. However, compilation of each
example program can be toggled by ./configure --with-example-xxx
command where xxx denotes the name of the example. Run ./configure
--help for a list of such options.
* Compiling on Mac:
No XCode project files provided yet. The easiest way is by just
using gcc, in which case look under UNIX compiling section.
* Compiling natively on Windows platform:
Solution files are provided for Visual C++ version 7 and 8. For
the example programs using images to compile, you will need the
appropriate build of jpeglib to match your Visual C++ version.
* Compiling in mingw / cygwin environment:
Might work just as fine as any UNIX-flavored system, but hasn't
been tested yet.
II. TESTING
=============================
There is no real testing suite yet. The example programs are there
just to play with what the implementation can currently do, but
can hardly provide any proper validation, since no reference images
are provided. Here is a description of each example program and
what features it highlights:
* test_vgu
Constructs some path primitives using the VGU API.
* test_tiger
The most simple performance test. It draws the well known svg
tiger using just simple stroke and fill of solid colors. It
consists of 240 paths.
* test_dash
Shows different stroke dashing modes.
* test_linear
A rectangle drawn using 3-color linear gradient fill paint
* test_radial
A rectangle drawn using 3-color radial gradient fill paint
* test_interpolate
Interpolates between two paths - an apple and a pear.
* test_image
Images are drawn using VG_DRAW_IMAGE_MULTIPLY image mode to be
multiplied with radial gradient fill paint.
* test_pattern
An image is drawn in multiply mode with an image pattern fill
paint.
III. IMPLEMENTATION STATUS
=============================
Khronos states in the OpenVG specification, that the contexts for all
their client APIs are expected to be created via the EGL API. Since
EGL to use with ShivaVG has not been implemented yet, there is a set
of extension functions provided for the task of creating, maintaining
and destroying the OpenVG context. (See next section EXTENSIONS for
details.)
What follows is a description of which functions or to what extent
a certain function has been implemented. When a function is marked
as PARTIALLY implemented, the TODO file or the comments in the code
itself would provide further clues.
* General:
vgGetError ............................ FULLY implemented
vgFlush ............................... FULLY implemented
vgFinish .............................. FULLY implemented
* Getters and setters:
vgSet ................................. FULLY implemented
vgSeti ................................ FULLY implemented
vgSetfv ............................... FULLY implemented
vgSetiv ............................... FULLY implemented
vgGetf ................................ FULLY implemented
vgGeti ................................ FULLY implemented
vgGetVectorSize ....................... FULLY implemented
vgGetfv ............................... FULLY implemented
vgGetiv ............................... FULLY implemented
vgSetParameterf ....................... FULLY implemented
vgSetParameteri ....................... FULLY implemented
vgSetParameterfv ...................... FULLY implemented
vgSetParameteriv ...................... FULLY implemented
vgGetParameterf ....................... FULLY implemented
vgGetParameteri ....................... FULLY implemented
vgGetParameterVectorSize............... FULLY implemented
vgGetParameterfv ...................... FULLY implemented
vgGetParameteriv ...................... FULLY implemented
* Matrix Manipulation:
vgLoadIdentity ........................ FULLY implemented
vgLoadMatrix .......................... FULLY implemented
vgGetMatrix ........................... FULLY implemented
vgMultMatrix .......................... FULLY implemented
vgTranslate ........................... FULLY implemented
vgScale ............................... FULLY implemented
vgShear ............................... FULLY implemented
vgRotate .............................. FULLY implemented
* Masking and Clearing:
vgMask ................................ NOT implemented
vgClear ............................... FULLY implemented
* Paths:
vgCreatePath .......................... FULLY implemented
vgClearPath ........................... FULLY implemented
vgDestroyPath ......................... FULLY implemented
vgRemovePathCapabilities .............. FULLY implemented
vgGetPathCapabilities ................. FULLY implemented
vgAppendPath .......................... FULLY implemented
vgAppendPathData ...................... FULLY implemented
vgModifyPathCoords .................... FULLY implemented
vgTransformPath ....................... FULLY implemented
vgInterpolatePath ..................... FULLY implemented
vgPathLength .......................... NOT implemented
vgPointAlongPath ...................... NOT implemented
vgPathBounds .......................... FULLY implemented
vgPathTransformedBounds ............... FULLY implemented
vgDrawPath ............................ PARTIALLY implemented
* Paint:
vgCreatePaint ......................... FULLY implemented
vgDestroyPaint ........................ FULLY implemented
vgSetPaint ............................ FULLY implemented
vgGetPaint ............................ FULLY implemented
vgSetColor ............................ FULLY implemented
vgGetColor ............................ FULLY implemented
vgPaintPattern ........................ FULLY implemented
* Images:
vgCreateImage ......................... PARTIALLY implemented
vgDestroyImage ........................ FULLY implemented
vgClearImage .......................... FULLY implemented
vgImageSubData ........................ PARTIALLY implemented
vgGetImageSubData ..................... PARTIALLY implemented
vgChildImage .......................... NOT implemented
vgGetParent ........................... NOT implemented
vgCopyImage ........................... FULLY implemented
vgDrawImage ........................... PARTIALLY implemented
vgSetPixels ........................... FULLY implemented
vgWritePixels ......................... FULLY implemented
vgGetPixels ........................... FULLY implemented
vgReadPixels .......................... FULLY implemented
vgCopyPixels .......................... FULLY implemented
* Image Filters:
vgColorMatrix ......................... NOT implemented
vgConvolve ............................ NOT implemented
vgSeparableConvolve ................... NOT implemented
vgGaussianBlur ........................ NOT implemented
vgLookup .............................. NOT implemented
vgLookupSingle ........................ NOT implemented
* Hardware Queries:
vgHardwareQuery ....................... NOT implemented
* Renderer and Extension Information:
vgGetString ........................... FULLY implemented
* VGU
vguLine ............................... FULLY implemented
vguPolygon ............................ FULLY implemented
vguRect ............................... FULLY implemented
vguRoundRect .......................... FULLY implemented
vguEllipse ............................ FULLY implemented
vguArc ................................ FULLY implemented
vguComputeWarpQuadToSquare ............ NOT implemented
vguComputeWarpSquareToQuad ............ NOT implemented
vguComputeWarpQuadToQuad .............. NOT implemented
IV. EXTENSIONS
=============================
There are three extensions to the API that manipulate the OpenVG
context as a temporary replacement for EGL:
VGboolean vgCreateContextSH(VGint width, VGint height)
Creates an OpenVG context on top of an existing OpenGL context
that should have been manually initialized by the user of the
library. Width and height specify the size of the rendering
surface. No multi-threading support has been implemented yet.
The context is created once per process.
void vgResizeSurfaceSH(VGint width, VGint height)
Should be called whenever the size of the surface changes (e.g.
the owner window of the OpenGL context is resized).
void vgDestroyContextSH()
Destroys the OpenVG context associated with the calling process.

View File

@@ -0,0 +1,42 @@
----------
Known bugs
----------
- outofmemory in arrays silently ignored
- blending doesn't use premultiplied colors (not porter-duff model)
- gradient color ramp is not interpolated in linear space
- linear and non-linear image formats behave both linearly
- radial gradient circle has got a fixed step instead of
proportional to its radius
-------------------------
Incomplete functionality:
-------------------------
- non-zero fill mode
- proper porter-duff blending
- masking
- scissoring
- child images
- VG_DRAW_IMAGE_STENCIL
- _PRE and BW_1 image formats
- VGU warp matrices
- EGL (image drawing targets)
- boundbox / point-on-path / tangent-on-path queries
- RENDERING_QUALITY_FASTER == RENDERING_QUALITY_BETTER
---------------------------
Possible portability issues
---------------------------
- GL_UNSIGNED_INT_8_8_8_8 and other for images
- GL_MIRRORED_REPEAT for gradients
- GL_CLAMP_TO_EDGE for gradients and pattern paints
- GL_CLAMP_TO_BORDER for pattern paints
- multitexturing for VG_DRAW_IMAGE_MULTIPLY, VG_DRAW_IMAGE_STENCIL
------
Bonus:
------
- gradient shaders? antialiasing shader?

View File

@@ -0,0 +1,637 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef _OPENVG_H
#define _OPENVG_H
#define OPENVG_VERSION_1_0_1 1
/* Type definitions */
/* TODO: we can't use config.h in this header so there
must be some other technique to assert the proper
size of the basic types */
typedef float VGfloat;
typedef char VGbyte;
typedef unsigned char VGubyte;
typedef short VGshort;
typedef int VGint;
typedef unsigned int VGuint;
typedef unsigned int VGbitfield;
typedef enum {
VG_FALSE = 0,
VG_TRUE = 1
} VGboolean;
#define VG_MAXSHORT ((VGshort)((~((unsigned)0)) >> 1))
#define VG_MAXINT ((VGint)((~((unsigned)0)) >> 1))
/* Define handle to be of same length as any pointer */
typedef void * VGHandle;
#define VG_INVALID_HANDLE ((VGHandle)NULL)
/* Enumerations */
typedef enum {
VG_NO_ERROR = 0,
VG_BAD_HANDLE_ERROR = 0x1000,
VG_ILLEGAL_ARGUMENT_ERROR = 0x1001,
VG_OUT_OF_MEMORY_ERROR = 0x1002,
VG_PATH_CAPABILITY_ERROR = 0x1003,
VG_UNSUPPORTED_IMAGE_FORMAT_ERROR = 0x1004,
VG_UNSUPPORTED_PATH_FORMAT_ERROR = 0x1005,
VG_IMAGE_IN_USE_ERROR = 0x1006,
VG_NO_CONTEXT_ERROR = 0x1007
} VGErrorCode;
typedef enum {
/* Mode settings */
VG_MATRIX_MODE = 0x1100,
VG_FILL_RULE = 0x1101,
VG_IMAGE_QUALITY = 0x1102,
VG_RENDERING_QUALITY = 0x1103,
VG_BLEND_MODE = 0x1104,
VG_IMAGE_MODE = 0x1105,
/* Scissoring rectangles */
VG_SCISSOR_RECTS = 0x1106,
/* Stroke parameters */
VG_STROKE_LINE_WIDTH = 0x1110,
VG_STROKE_CAP_STYLE = 0x1111,
VG_STROKE_JOIN_STYLE = 0x1112,
VG_STROKE_MITER_LIMIT = 0x1113,
VG_STROKE_DASH_PATTERN = 0x1114,
VG_STROKE_DASH_PHASE = 0x1115,
VG_STROKE_DASH_PHASE_RESET = 0x1116,
/* Edge fill color for VG_TILE_FILL tiling mode */
VG_TILE_FILL_COLOR = 0x1120,
/* Color for vgClear */
VG_CLEAR_COLOR = 0x1121,
/* Enable/disable alpha masking and scissoring */
VG_MASKING = 0x1130,
VG_SCISSORING = 0x1131,
/* Pixel layout information */
VG_PIXEL_LAYOUT = 0x1140,
VG_SCREEN_LAYOUT = 0x1141,
/* Source format selection for image filters */
VG_FILTER_FORMAT_LINEAR = 0x1150,
VG_FILTER_FORMAT_PREMULTIPLIED = 0x1151,
/* Destination write enable mask for image filters */
VG_FILTER_CHANNEL_MASK = 0x1152,
/* Implementation limits (read-only) */
VG_MAX_SCISSOR_RECTS = 0x1160,
VG_MAX_DASH_COUNT = 0x1161,
VG_MAX_KERNEL_SIZE = 0x1162,
VG_MAX_SEPARABLE_KERNEL_SIZE = 0x1163,
VG_MAX_COLOR_RAMP_STOPS = 0x1164,
VG_MAX_IMAGE_WIDTH = 0x1165,
VG_MAX_IMAGE_HEIGHT = 0x1166,
VG_MAX_IMAGE_PIXELS = 0x1167,
VG_MAX_IMAGE_BYTES = 0x1168,
VG_MAX_FLOAT = 0x1169,
VG_MAX_GAUSSIAN_STD_DEVIATION = 0x116A
} VGParamType;
typedef enum {
VG_RENDERING_QUALITY_NONANTIALIASED = 0x1200,
VG_RENDERING_QUALITY_FASTER = 0x1201,
VG_RENDERING_QUALITY_BETTER = 0x1202 /* Default */
} VGRenderingQuality;
typedef enum {
VG_PIXEL_LAYOUT_UNKNOWN = 0x1300,
VG_PIXEL_LAYOUT_RGB_VERTICAL = 0x1301,
VG_PIXEL_LAYOUT_BGR_VERTICAL = 0x1302,
VG_PIXEL_LAYOUT_RGB_HORIZONTAL = 0x1303,
VG_PIXEL_LAYOUT_BGR_HORIZONTAL = 0x1304
} VGPixelLayout;
typedef enum {
VG_MATRIX_PATH_USER_TO_SURFACE = 0x1400,
VG_MATRIX_IMAGE_USER_TO_SURFACE = 0x1401,
VG_MATRIX_FILL_PAINT_TO_USER = 0x1402,
VG_MATRIX_STROKE_PAINT_TO_USER = 0x1403
} VGMatrixMode;
typedef enum {
VG_CLEAR_MASK = 0x1500,
VG_FILL_MASK = 0x1501,
VG_SET_MASK = 0x1502,
VG_UNION_MASK = 0x1503,
VG_INTERSECT_MASK = 0x1504,
VG_SUBTRACT_MASK = 0x1505
} VGMaskOperation;
#define VG_PATH_FORMAT_STANDARD 0
typedef enum {
VG_PATH_DATATYPE_S_8 = 0,
VG_PATH_DATATYPE_S_16 = 1,
VG_PATH_DATATYPE_S_32 = 2,
VG_PATH_DATATYPE_F = 3
} VGPathDatatype;
typedef enum {
VG_ABSOLUTE = 0,
VG_RELATIVE = 1
} VGPathAbsRel;
typedef enum {
VG_CLOSE_PATH = ( 0 << 1),
VG_MOVE_TO = ( 1 << 1),
VG_LINE_TO = ( 2 << 1),
VG_HLINE_TO = ( 3 << 1),
VG_VLINE_TO = ( 4 << 1),
VG_QUAD_TO = ( 5 << 1),
VG_CUBIC_TO = ( 6 << 1),
VG_SQUAD_TO = ( 7 << 1),
VG_SCUBIC_TO = ( 8 << 1),
VG_SCCWARC_TO = ( 9 << 1),
VG_SCWARC_TO = (10 << 1),
VG_LCCWARC_TO = (11 << 1),
VG_LCWARC_TO = (12 << 1)
} VGPathSegment;
typedef enum {
VG_MOVE_TO_ABS = VG_MOVE_TO | VG_ABSOLUTE,
VG_MOVE_TO_REL = VG_MOVE_TO | VG_RELATIVE,
VG_LINE_TO_ABS = VG_LINE_TO | VG_ABSOLUTE,
VG_LINE_TO_REL = VG_LINE_TO | VG_RELATIVE,
VG_HLINE_TO_ABS = VG_HLINE_TO | VG_ABSOLUTE,
VG_HLINE_TO_REL = VG_HLINE_TO | VG_RELATIVE,
VG_VLINE_TO_ABS = VG_VLINE_TO | VG_ABSOLUTE,
VG_VLINE_TO_REL = VG_VLINE_TO | VG_RELATIVE,
VG_QUAD_TO_ABS = VG_QUAD_TO | VG_ABSOLUTE,
VG_QUAD_TO_REL = VG_QUAD_TO | VG_RELATIVE,
VG_CUBIC_TO_ABS = VG_CUBIC_TO | VG_ABSOLUTE,
VG_CUBIC_TO_REL = VG_CUBIC_TO | VG_RELATIVE,
VG_SQUAD_TO_ABS = VG_SQUAD_TO | VG_ABSOLUTE,
VG_SQUAD_TO_REL = VG_SQUAD_TO | VG_RELATIVE,
VG_SCUBIC_TO_ABS = VG_SCUBIC_TO | VG_ABSOLUTE,
VG_SCUBIC_TO_REL = VG_SCUBIC_TO | VG_RELATIVE,
VG_SCCWARC_TO_ABS = VG_SCCWARC_TO | VG_ABSOLUTE,
VG_SCCWARC_TO_REL = VG_SCCWARC_TO | VG_RELATIVE,
VG_SCWARC_TO_ABS = VG_SCWARC_TO | VG_ABSOLUTE,
VG_SCWARC_TO_REL = VG_SCWARC_TO | VG_RELATIVE,
VG_LCCWARC_TO_ABS = VG_LCCWARC_TO | VG_ABSOLUTE,
VG_LCCWARC_TO_REL = VG_LCCWARC_TO | VG_RELATIVE,
VG_LCWARC_TO_ABS = VG_LCWARC_TO | VG_ABSOLUTE,
VG_LCWARC_TO_REL = VG_LCWARC_TO | VG_RELATIVE
} VGPathCommand;
typedef VGHandle VGPath;
typedef enum {
VG_PATH_CAPABILITY_APPEND_FROM = (1 << 0),
VG_PATH_CAPABILITY_APPEND_TO = (1 << 1),
VG_PATH_CAPABILITY_MODIFY = (1 << 2),
VG_PATH_CAPABILITY_TRANSFORM_FROM = (1 << 3),
VG_PATH_CAPABILITY_TRANSFORM_TO = (1 << 4),
VG_PATH_CAPABILITY_INTERPOLATE_FROM = (1 << 5),
VG_PATH_CAPABILITY_INTERPOLATE_TO = (1 << 6),
VG_PATH_CAPABILITY_PATH_LENGTH = (1 << 7),
VG_PATH_CAPABILITY_POINT_ALONG_PATH = (1 << 8),
VG_PATH_CAPABILITY_TANGENT_ALONG_PATH = (1 << 9),
VG_PATH_CAPABILITY_PATH_BOUNDS = (1 << 10),
VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS = (1 << 11),
VG_PATH_CAPABILITY_ALL = (1 << 12) - 1
} VGPathCapabilities;
typedef enum {
VG_PATH_FORMAT = 0x1600,
VG_PATH_DATATYPE = 0x1601,
VG_PATH_SCALE = 0x1602,
VG_PATH_BIAS = 0x1603,
VG_PATH_NUM_SEGMENTS = 0x1604,
VG_PATH_NUM_COORDS = 0x1605
} VGPathParamType;
typedef enum {
VG_CAP_BUTT = 0x1700,
VG_CAP_ROUND = 0x1701,
VG_CAP_SQUARE = 0x1702
} VGCapStyle;
typedef enum {
VG_JOIN_MITER = 0x1800,
VG_JOIN_ROUND = 0x1801,
VG_JOIN_BEVEL = 0x1802
} VGJoinStyle;
typedef enum {
VG_EVEN_ODD = 0x1900,
VG_NON_ZERO = 0x1901
} VGFillRule;
typedef enum {
VG_STROKE_PATH = (1 << 0),
VG_FILL_PATH = (1 << 1)
} VGPaintMode;
typedef VGHandle VGPaint;
typedef enum {
/* Color paint parameters */
VG_PAINT_TYPE = 0x1A00,
VG_PAINT_COLOR = 0x1A01,
VG_PAINT_COLOR_RAMP_SPREAD_MODE = 0x1A02,
VG_PAINT_COLOR_RAMP_PREMULTIPLIED = 0x1A07,
VG_PAINT_COLOR_RAMP_STOPS = 0x1A03,
/* Linear gradient paint parameters */
VG_PAINT_LINEAR_GRADIENT = 0x1A04,
/* Radial gradient paint parameters */
VG_PAINT_RADIAL_GRADIENT = 0x1A05,
/* Pattern paint parameters */
VG_PAINT_PATTERN_TILING_MODE = 0x1A06
} VGPaintParamType;
typedef enum {
VG_PAINT_TYPE_COLOR = 0x1B00,
VG_PAINT_TYPE_LINEAR_GRADIENT = 0x1B01,
VG_PAINT_TYPE_RADIAL_GRADIENT = 0x1B02,
VG_PAINT_TYPE_PATTERN = 0x1B03
} VGPaintType;
typedef enum {
VG_COLOR_RAMP_SPREAD_PAD = 0x1C00,
VG_COLOR_RAMP_SPREAD_REPEAT = 0x1C01,
VG_COLOR_RAMP_SPREAD_REFLECT = 0x1C02
} VGColorRampSpreadMode;
typedef enum {
VG_TILE_FILL = 0x1D00,
VG_TILE_PAD = 0x1D01,
VG_TILE_REPEAT = 0x1D02,
VG_TILE_REFLECT = 0x1D03
} VGTilingMode;
typedef enum {
/* RGB{A,X} channel ordering */
VG_sRGBX_8888 = 0,
VG_sRGBA_8888 = 1,
VG_sRGBA_8888_PRE = 2,
VG_sRGB_565 = 3,
VG_sRGBA_5551 = 4,
VG_sRGBA_4444 = 5,
VG_sL_8 = 6,
VG_lRGBX_8888 = 7,
VG_lRGBA_8888 = 8,
VG_lRGBA_8888_PRE = 9,
VG_lL_8 = 10,
VG_A_8 = 11,
VG_BW_1 = 12,
/* {A,X}RGB channel ordering */
VG_sXRGB_8888 = 0 | (1 << 6),
VG_sARGB_8888 = 1 | (1 << 6),
VG_sARGB_8888_PRE = 2 | (1 << 6),
VG_sARGB_1555 = 4 | (1 << 6),
VG_sARGB_4444 = 5 | (1 << 6),
VG_lXRGB_8888 = 7 | (1 << 6),
VG_lARGB_8888 = 8 | (1 << 6),
VG_lARGB_8888_PRE = 9 | (1 << 6),
/* BGR{A,X} channel ordering */
VG_sBGRX_8888 = 0 | (1 << 7),
VG_sBGRA_8888 = 1 | (1 << 7),
VG_sBGRA_8888_PRE = 2 | (1 << 7),
VG_sBGR_565 = 3 | (1 << 7),
VG_sBGRA_5551 = 4 | (1 << 7),
VG_sBGRA_4444 = 5 | (1 << 7),
VG_lBGRX_8888 = 7 | (1 << 7),
VG_lBGRA_8888 = 8 | (1 << 7),
VG_lBGRA_8888_PRE = 9 | (1 << 7),
/* {A,X}BGR channel ordering */
VG_sXBGR_8888 = 0 | (1 << 6) | (1 << 7),
VG_sABGR_8888 = 1 | (1 << 6) | (1 << 7),
VG_sABGR_8888_PRE = 2 | (1 << 6) | (1 << 7),
VG_sABGR_1555 = 4 | (1 << 6) | (1 << 7),
VG_sABGR_4444 = 5 | (1 << 6) | (1 << 7),
VG_lXBGR_8888 = 7 | (1 << 6) | (1 << 7),
VG_lABGR_8888 = 8 | (1 << 6) | (1 << 7),
VG_lABGR_8888_PRE = 9 | (1 << 6) | (1 << 7)
} VGImageFormat;
typedef VGHandle VGImage;
typedef enum {
VG_IMAGE_QUALITY_NONANTIALIASED = (1 << 0),
VG_IMAGE_QUALITY_FASTER = (1 << 1),
VG_IMAGE_QUALITY_BETTER = (1 << 2)
} VGImageQuality;
typedef enum {
VG_IMAGE_FORMAT = 0x1E00,
VG_IMAGE_WIDTH = 0x1E01,
VG_IMAGE_HEIGHT = 0x1E02
} VGImageParamType;
typedef enum {
VG_DRAW_IMAGE_NORMAL = 0x1F00,
VG_DRAW_IMAGE_MULTIPLY = 0x1F01,
VG_DRAW_IMAGE_STENCIL = 0x1F02
} VGImageMode;
typedef enum {
VG_RED = (1 << 3),
VG_GREEN = (1 << 2),
VG_BLUE = (1 << 1),
VG_ALPHA = (1 << 0)
} VGImageChannel;
typedef enum {
VG_BLEND_SRC = 0x2000,
VG_BLEND_SRC_OVER = 0x2001,
VG_BLEND_DST_OVER = 0x2002,
VG_BLEND_SRC_IN = 0x2003,
VG_BLEND_DST_IN = 0x2004,
VG_BLEND_MULTIPLY = 0x2005,
VG_BLEND_SCREEN = 0x2006,
VG_BLEND_DARKEN = 0x2007,
VG_BLEND_LIGHTEN = 0x2008,
VG_BLEND_ADDITIVE = 0x2009,
VG_BLEND_SRC_OUT_SH = 0x200A,
VG_BLEND_DST_OUT_SH = 0x200B,
VG_BLEND_SRC_ATOP_SH = 0x200C,
VG_BLEND_DST_ATOP_SH = 0x200D
} VGBlendMode;
typedef enum {
VG_IMAGE_FORMAT_QUERY = 0x2100,
VG_PATH_DATATYPE_QUERY = 0x2101
} VGHardwareQueryType;
typedef enum {
VG_HARDWARE_ACCELERATED = 0x2200,
VG_HARDWARE_UNACCELERATED = 0x2201
} VGHardwareQueryResult;
typedef enum {
VG_VENDOR = 0x2300,
VG_RENDERER = 0x2301,
VG_VERSION = 0x2302,
VG_EXTENSIONS = 0x2303
} VGStringID;
/* Function Prototypes */
#if 0 // We are including ShivaVG directly into libSimGearScene and only using
// inside the library so there is no need for any dll import/export stuff
#if defined(_WIN32) || defined(__VC32__)
# if defined(VG_API_EXPORT)
# define VG_API_CALL __declspec(dllexport)
# else
# define VG_API_CALL __declspec(dllimport)
# endif
#else
# define VG_API_CALL extern
#endif
#else
# define VG_API_CALL
#endif
#if defined (__cplusplus)
extern "C" {
#endif
VG_API_CALL VGErrorCode vgGetError(void);
VG_API_CALL void vgFlush(void);
VG_API_CALL void vgFinish(void);
/* Getters and Setters */
VG_API_CALL void vgSetf (VGParamType type, VGfloat value);
VG_API_CALL void vgSeti (VGParamType type, VGint value);
VG_API_CALL void vgSetfv(VGParamType type, VGint count,
const VGfloat * values);
VG_API_CALL void vgSetiv(VGParamType type, VGint count,
const VGint * values);
VG_API_CALL VGfloat vgGetf(VGParamType type);
VG_API_CALL VGint vgGeti(VGParamType type);
VG_API_CALL VGint vgGetVectorSize(VGParamType type);
VG_API_CALL void vgGetfv(VGParamType type, VGint count, VGfloat * values);
VG_API_CALL void vgGetiv(VGParamType type, VGint count, VGint * values);
VG_API_CALL void vgSetParameterf(VGHandle object,
VGint paramType,
VGfloat value);
VG_API_CALL void vgSetParameteri(VGHandle object,
VGint paramType,
VGint value);
VG_API_CALL void vgSetParameterfv(VGHandle object,
VGint paramType,
VGint count, const VGfloat * values);
VG_API_CALL void vgSetParameteriv(VGHandle object,
VGint paramType,
VGint count, const VGint * values);
VG_API_CALL VGfloat vgGetParameterf(VGHandle object,
VGint paramType);
VG_API_CALL VGint vgGetParameteri(VGHandle object,
VGint paramType);
VG_API_CALL VGint vgGetParameterVectorSize(VGHandle object,
VGint paramType);
VG_API_CALL void vgGetParameterfv(VGHandle object,
VGint paramType,
VGint count, VGfloat * values);
VG_API_CALL void vgGetParameteriv(VGHandle object,
VGint paramType,
VGint count, VGint * values);
/* Matrix Manipulation */
VG_API_CALL void vgLoadIdentity(void);
VG_API_CALL void vgLoadMatrix(const VGfloat * m);
VG_API_CALL void vgGetMatrix(VGfloat * m);
VG_API_CALL void vgMultMatrix(const VGfloat * m);
VG_API_CALL void vgTranslate(VGfloat tx, VGfloat ty);
VG_API_CALL void vgScale(VGfloat sx, VGfloat sy);
VG_API_CALL void vgShear(VGfloat shx, VGfloat shy);
VG_API_CALL void vgRotate(VGfloat angle);
/* Masking and Clearing */
VG_API_CALL void vgMask(VGImage mask, VGMaskOperation operation,
VGint x, VGint y, VGint width, VGint height);
VG_API_CALL void vgClear(VGint x, VGint y, VGint width, VGint height);
/* Paths */
VG_API_CALL VGPath vgCreatePath(VGint pathFormat,
VGPathDatatype datatype,
VGfloat scale, VGfloat bias,
VGint segmentCapacityHint,
VGint coordCapacityHint,
VGbitfield capabilities);
VG_API_CALL void vgClearPath(VGPath path, VGbitfield capabilities);
VG_API_CALL void vgDestroyPath(VGPath path);
VG_API_CALL void vgRemovePathCapabilities(VGPath path,
VGbitfield capabilities);
VG_API_CALL VGbitfield vgGetPathCapabilities(VGPath path);
VG_API_CALL void vgAppendPath(VGPath dstPath, VGPath srcPath);
VG_API_CALL void vgAppendPathData(VGPath dstPath,
VGint numSegments,
const VGubyte * pathSegments,
const void * pathData);
VG_API_CALL void vgModifyPathCoords(VGPath dstPath, VGint startIndex,
VGint numSegments,
const void * pathData);
VG_API_CALL void vgTransformPath(VGPath dstPath, VGPath srcPath);
VG_API_CALL VGboolean vgInterpolatePath(VGPath dstPath,
VGPath startPath,
VGPath endPath,
VGfloat amount);
VG_API_CALL VGfloat vgPathLength(VGPath path,
VGint startSegment, VGint numSegments);
VG_API_CALL void vgPointAlongPath(VGPath path,
VGint startSegment, VGint numSegments,
VGfloat distance,
VGfloat * x, VGfloat * y,
VGfloat * tangentX, VGfloat * tangentY);
VG_API_CALL void vgPathBounds(VGPath path,
VGfloat * minX, VGfloat * minY,
VGfloat * width, VGfloat * height);
VG_API_CALL void vgPathTransformedBounds(VGPath path,
VGfloat * minX, VGfloat * minY,
VGfloat * width, VGfloat * height);
VG_API_CALL void vgDrawPath(VGPath path, VGbitfield paintModes);
/* Paint */
VG_API_CALL VGPaint vgCreatePaint(void);
VG_API_CALL void vgDestroyPaint(VGPaint paint);
VG_API_CALL void vgSetPaint(VGPaint paint, VGbitfield paintModes);
VG_API_CALL VGPaint vgGetPaint(VGPaintMode paintMode);
VG_API_CALL void vgSetColor(VGPaint paint, VGuint rgba);
VG_API_CALL VGuint vgGetColor(VGPaint paint);
VG_API_CALL void vgPaintPattern(VGPaint paint, VGImage pattern);
/* Images */
VG_API_CALL VGImage vgCreateImage(VGImageFormat format,
VGint width, VGint height,
VGbitfield allowedQuality);
VG_API_CALL void vgDestroyImage(VGImage image);
VG_API_CALL void vgClearImage(VGImage image,
VGint x, VGint y, VGint width, VGint height);
VG_API_CALL void vgImageSubData(VGImage image,
const void * data, VGint dataStride,
VGImageFormat dataFormat,
VGint x, VGint y, VGint width, VGint height);
VG_API_CALL void vgGetImageSubData(VGImage image,
void * data, VGint dataStride,
VGImageFormat dataFormat,
VGint x, VGint y,
VGint width, VGint height);
VG_API_CALL VGImage vgChildImage(VGImage parent,
VGint x, VGint y, VGint width, VGint height);
VG_API_CALL VGImage vgGetParent(VGImage image);
VG_API_CALL void vgCopyImage(VGImage dst, VGint dx, VGint dy,
VGImage src, VGint sx, VGint sy,
VGint width, VGint height,
VGboolean dither);
VG_API_CALL void vgDrawImage(VGImage image);
VG_API_CALL void vgSetPixels(VGint dx, VGint dy,
VGImage src, VGint sx, VGint sy,
VGint width, VGint height);
VG_API_CALL void vgWritePixels(const void * data, VGint dataStride,
VGImageFormat dataFormat,
VGint dx, VGint dy,
VGint width, VGint height);
VG_API_CALL void vgGetPixels(VGImage dst, VGint dx, VGint dy,
VGint sx, VGint sy,
VGint width, VGint height);
VG_API_CALL void vgReadPixels(void * data, VGint dataStride,
VGImageFormat dataFormat,
VGint sx, VGint sy,
VGint width, VGint height);
VG_API_CALL void vgCopyPixels(VGint dx, VGint dy,
VGint sx, VGint sy,
VGint width, VGint height);
/* Image Filters */
VG_API_CALL void vgColorMatrix(VGImage dst, VGImage src,
const VGfloat * matrix);
VG_API_CALL void vgConvolve(VGImage dst, VGImage src,
VGint kernelWidth, VGint kernelHeight,
VGint shiftX, VGint shiftY,
const VGshort * kernel,
VGfloat scale,
VGfloat bias,
VGTilingMode tilingMode);
VG_API_CALL void vgSeparableConvolve(VGImage dst, VGImage src,
VGint kernelWidth,
VGint kernelHeight,
VGint shiftX, VGint shiftY,
const VGshort * kernelX,
const VGshort * kernelY,
VGfloat scale,
VGfloat bias,
VGTilingMode tilingMode);
VG_API_CALL void vgGaussianBlur(VGImage dst, VGImage src,
VGfloat stdDeviationX,
VGfloat stdDeviationY,
VGTilingMode tilingMode);
VG_API_CALL void vgLookup(VGImage dst, VGImage src,
const VGubyte * redLUT,
const VGubyte * greenLUT,
const VGubyte * blueLUT,
const VGubyte * alphaLUT,
VGboolean outputLinear,
VGboolean outputPremultiplied);
VG_API_CALL void vgLookupSingle(VGImage dst, VGImage src,
const VGuint * lookupTable,
VGImageChannel sourceChannel,
VGboolean outputLinear,
VGboolean outputPremultiplied);
/* Hardware Queries */
VG_API_CALL VGHardwareQueryResult vgHardwareQuery(VGHardwareQueryType key,
VGint setting);
/* Renderer and Extension Information */
VG_API_CALL const VGubyte * vgGetString(VGStringID name);
/* Extensions */
#define OVG_SH_blend_src_out 1
#define OVG_SH_blend_dst_out 1
#define OVG_SH_blend_src_atop 1
#define OVG_SH_blend_dst_atop 1
VG_API_CALL VGboolean vgCreateContextSH(VGint width, VGint height);
VG_API_CALL void vgResizeSurfaceSH(VGint width, VGint height);
VG_API_CALL void vgDestroyContextSH(void);
#if defined (__cplusplus)
} /* extern "C" */
#endif
#endif /* _OPENVG_H */

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _VGU_H
#define _VGU_H
#include "openvg.h"
#define VGU_VERSION_1_0 1
#define VGU_VERSION_1_0_1 1
#ifndef VGU_API_CALL
#define VGU_API_CALL VG_API_CALL
#endif
typedef enum {
VGU_NO_ERROR = 0,
VGU_BAD_HANDLE_ERROR = 0xF000,
VGU_ILLEGAL_ARGUMENT_ERROR = 0xF001,
VGU_OUT_OF_MEMORY_ERROR = 0xF002,
VGU_PATH_CAPABILITY_ERROR = 0xF003,
VGU_BAD_WARP_ERROR = 0xF004
} VGUErrorCode;
typedef enum {
VGU_ARC_OPEN = 0xF100,
VGU_ARC_CHORD = 0xF101,
VGU_ARC_PIE = 0xF102
} VGUArcType;
#ifdef __cplusplus
extern "C" {
#endif
VGU_API_CALL VGUErrorCode vguLine(VGPath path,
VGfloat x0, VGfloat y0,
VGfloat x1, VGfloat y1);
VGU_API_CALL VGUErrorCode vguPolygon(VGPath path,
const VGfloat * points, VGint count,
VGboolean closed);
VGU_API_CALL VGUErrorCode vguRect(VGPath path,
VGfloat x, VGfloat y,
VGfloat width, VGfloat height);
VGU_API_CALL VGUErrorCode vguRoundRect(VGPath path,
VGfloat x, VGfloat y,
VGfloat width, VGfloat height,
VGfloat arcWidth, VGfloat arcHeight);
VGU_API_CALL VGUErrorCode vguEllipse(VGPath path,
VGfloat cx, VGfloat cy,
VGfloat width, VGfloat height);
VGU_API_CALL VGUErrorCode vguArc(VGPath path,
VGfloat x, VGfloat y,
VGfloat width, VGfloat height,
VGfloat startAngle, VGfloat angleExtent,
VGUArcType arcType);
VGU_API_CALL VGUErrorCode vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0,
VGfloat sx1, VGfloat sy1,
VGfloat sx2, VGfloat sy2,
VGfloat sx3, VGfloat sy3,
VGfloat * matrix);
VGU_API_CALL VGUErrorCode vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0,
VGfloat dx1, VGfloat dy1,
VGfloat dx2, VGfloat dy2,
VGfloat dx3, VGfloat dy3,
VGfloat * matrix);
VGU_API_CALL VGUErrorCode vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0,
VGfloat dx1, VGfloat dy1,
VGfloat dx2, VGfloat dy2,
VGfloat dx3, VGfloat dy3,
VGfloat sx0, VGfloat sy0,
VGfloat sx1, VGfloat sy1,
VGfloat sx2, VGfloat sy2,
VGfloat sx3, VGfloat sy3,
VGfloat * matrix);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* #ifndef _VGU_H */

View File

@@ -0,0 +1,30 @@
include(SimGearComponent)
set(HEADERS
../include/vg/openvg.h
../include/vg/vgu.h
)
set(SOURCES
shArrays.c
shArrays.h
shContext.c
shContext.h
shExtensions.c
shExtensions.h
shGeometry.c
shGeometry.h
shImage.c
shImage.h
shPaint.c
shPaint.h
shParams.c
shPath.c
shPath.h
shPipeline.c
shVectors.c
shVectors.h
shVgu.c
)
simgear_scene_component(ShivaVG canvas/ShivaVG "${SOURCES}" "${HEADERS}")

View File

@@ -0,0 +1,370 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*------------------------------------------------------------
* The base for any type of array. According to appropriate
* macro definitions, specific array types will be generated
* and their manipulation functions respectively.
*
* This code assumes the following are defined:
* _ITEM_T: the type of the items in the array
* _ARRAY_T: the name of the structure
* _FUNC_T: the prefix to prepend to each function
*
* And at least one of these:
* _ARRAY_DECLARE: generate structure declaration
* _ARRAY_DEFINE: generate function definitions
*-----------------------------------------------------------*/
#ifndef __SHARRAYBASE_H
#define __SHARRAYBASE_H
#include "shDefs.h"
#define VAL(x,y) x ## y
#define JN(x,y) VAL(x,y)
#endif
/*--------------------------------------------
* The rest is not #ifndef protected to allow
* for various array type definitions.
*--------------------------------------------*/
#ifdef _ARRAY_DECLARE
typedef struct
{
_ITEM_T *items;
SHint32 capacity;
SHint32 size;
SHint outofmemory;
} _ARRAY_T;
#endif
void JN(_ARRAY_T,_ctor) (_ARRAY_T *a)
#ifdef _ARRAY_DEFINE
{
a->items = (_ITEM_T*)malloc(sizeof(_ITEM_T));
if (!a->items) {
a->outofmemory = 1;
a->capacity = 0;
a->size = 0;
return;
}
a->outofmemory = 0;
a->capacity = 1;
a->size = 0;
}
#else
;
#endif
void JN(_ARRAY_T,_dtor) (_ARRAY_T *a)
#ifdef _ARRAY_DEFINE
{
if (a->items) {
free(a->items);
a->items = NULL;
}
}
#else
;
#endif
void JN(_FUNC_T,Clear) (_ARRAY_T *a)
#ifdef _ARRAY_DEFINE
{
a->size = 0;
}
#else
;
#endif
/*--------------------------------------------------------
* Set the capacity of the array. In case of reallocation
* the items are not preserved.
*--------------------------------------------------------*/
int JN(_FUNC_T,Realloc) (_ARRAY_T *a, SHint newsize)
#ifdef _ARRAY_DEFINE
{
_ITEM_T *newitems = 0;
SH_ASSERT(newsize > 0);
if (newsize == a->capacity)
return 1;
newitems = (_ITEM_T*)malloc(newsize * sizeof(_ITEM_T));
if (!newitems) {
a->outofmemory = 1;
return 0;
}
if (a->items)
free(a->items);
a->outofmemory = 0;
a->items = newitems;
a->capacity = newsize;
a->size = 0;
return 1;
}
#else
;
#endif
/*------------------------------------------------------
* Asserts the capacity is at least [newsize]. In case
* of reallocation items are not preserved.
*------------------------------------------------------*/
int JN(_FUNC_T,Reserve) (_ARRAY_T *a, SHint newsize)
#ifdef _ARRAY_DEFINE
{
_ITEM_T *newitems = 0;
SH_ASSERT(newsize >= 0);
if (newsize <= a->capacity)
return 1;
newitems = (_ITEM_T*)malloc(newsize * sizeof(_ITEM_T));
if (!newitems) {
a->outofmemory = 1;
return 0;
}
if (a->items)
free(a->items);
a->outofmemory = 0;
a->items = newitems;
a->capacity = newsize;
a->size = 0;
return 1;
}
#else
;
#endif
/*------------------------------------------------------
* Asserts the capacity is at least [newsize]. In case
* of reallocation items are copied.
*------------------------------------------------------*/
int JN(_FUNC_T,ReserveAndCopy) (_ARRAY_T *a, SHint newsize)
#ifdef _ARRAY_DEFINE
{
_ITEM_T *newitems = 0;
SH_ASSERT(newsize >= 0);
if (newsize <= a->capacity)
return 1;
newitems = (_ITEM_T*)realloc(a->items, newsize * sizeof(_ITEM_T));
if (!newitems) {
a->outofmemory = 1;
return 0;
}
a->outofmemory = 0;
a->items = newitems;
a->capacity = newsize;
return 1;
}
#else
;
#endif
int JN(_FUNC_T,PushBack) (_ARRAY_T *a, _ITEM_T item)
#ifdef _ARRAY_DEFINE
{
if (a->capacity == 0) {
JN(_FUNC_T,Realloc)(a, 1);
if (a->outofmemory)
return 0;
}
if (a->size + 1 > a->capacity)
JN(_FUNC_T,ReserveAndCopy)(a, a->capacity*2);
if (a->outofmemory)
return 0;
a->items[a->size++] = item;
return 1;
}
#else
;
#endif
int JN(_FUNC_T,PushBackP) (_ARRAY_T *a, _ITEM_T *item)
#ifdef _ARRAY_DEFINE
{
if (a->capacity == 0) {
JN(_FUNC_T,Realloc)(a, 1);
if (a->outofmemory)
return 0;
}
if (a->size + 1 > a->capacity)
JN(_FUNC_T,ReserveAndCopy)(a, a->capacity*2);
if (a->outofmemory)
return 0;
a->items[a->size++] = *item;
return 1;
}
#else
;
#endif
void JN(_FUNC_T,PopBack) (_ARRAY_T *a)
#ifdef _ARRAY_DEFINE
{
SH_ASSERT(a->size);
--a->size;
}
#else
;
#endif
_ITEM_T JN(_FUNC_T,Front) (_ARRAY_T *a)
#ifdef _ARRAY_DEFINE
{
SH_ASSERT(a->size);
return a->items[0];
}
#else
;
#endif
_ITEM_T* JN(_FUNC_T,FrontP) (_ARRAY_T *a)
#ifdef _ARRAY_DEFINE
{
SH_ASSERT(a->size);
return &a->items[0];
}
#else
;
#endif
_ITEM_T JN(_FUNC_T,Back) (_ARRAY_T *a)
#ifdef _ARRAY_DEFINE
{
SH_ASSERT(a->size);
return a->items[a->size - 1];
}
#else
;
#endif
_ITEM_T* JN(_FUNC_T,BackP) (_ARRAY_T *a)
#ifdef _ARRAY_DEFINE
{
SH_ASSERT(a->size);
return &a->items[a->size - 1];
}
#else
;
#endif
_ITEM_T JN(_FUNC_T,At) (_ARRAY_T *a, SHint index)
#ifdef _ARRAY_DEFINE
{
SH_ASSERT(index >= 0);
SH_ASSERT(index < a->size);
return a->items[index];
}
#else
;
#endif
_ITEM_T* JN(_FUNC_T,AtP) (_ARRAY_T *a, SHint index)
#ifdef _ARRAY_DEFINE
{
SH_ASSERT(index >= 0);
SH_ASSERT(index < a->size);
return &a->items[index];
}
#else
;
#endif
SHint JN(_FUNC_T,Find) (_ARRAY_T *a, _ITEM_T item)
#ifdef _ARRAY_DEFINE
{
int i;
for (i=0; i<a->size; ++i) {
#ifdef _COMPARE_T
if (_COMPARE_T(a->items[i], item))
return i;
#else
if (a->items[i] == item)
return i;
#endif
}
return -1;
}
#else
;
#endif
void JN(_FUNC_T,RemoveAt) (_ARRAY_T *a, SHint index)
#ifdef _ARRAY_DEFINE
{
int i;
SH_ASSERT(index >= 0);
SH_ASSERT(index < a->size);
for (i=index; i<a->size-1; ++i)
a->items[i] = a->items[i+1];
a->size--;
}
#else
;
#endif
#undef _ITEM_T
#undef _ARRAY_T
#undef _FUNC_T
#undef _COMPARE_T
#undef _ARRAY_DEFINE
#undef _ARRAY_DECLARE

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*--------------------------------------------
* Definitions of all the arrays used
*--------------------------------------------*/
#include "shArrays.h"
#define _ITEM_T SHint
#define _ARRAY_T SHIntArray
#define _FUNC_T shIntArray
#define _ARRAY_DEFINE
#include "shArrayBase.h"
#define _ITEM_T SHuint8
#define _ARRAY_T SHUint8Array
#define _FUNC_T shUint8Array
#define _ARRAY_DEFINE
#include "shArrayBase.h"
#define _ITEM_T SHfloat
#define _ARRAY_T SHFloatArray
#define _FUNC_T shFloatArray
#define _ARRAY_DEFINE
#include "shArrayBase.h"
#define _ITEM_T SHRectangle
#define _ARRAY_T SHRectArray
#define _FUNC_T shRectArray
#define _COMPARE_T(x,y) 1
#define _ARRAY_DEFINE
#include "shArrayBase.h"

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*--------------------------------------------
* Declarations of all the arrays used
*--------------------------------------------*/
#ifndef __SHARRAYS_H
#define __SHARRAYS_H
#include "shVectors.h"
#define _ITEM_T SHint
#define _ARRAY_T SHIntArray
#define _FUNC_T shIntArray
#define _ARRAY_DECLARE
#include "shArrayBase.h"
#define _ITEM_T SHuint8
#define _ARRAY_T SHUint8Array
#define _FUNC_T shUint8Array
#define _ARRAY_DECLARE
#include "shArrayBase.h"
#define _ITEM_T SHfloat
#define _ARRAY_T SHFloatArray
#define _FUNC_T shFloatArray
#define _ARRAY_DECLARE
#include "shArrayBase.h"
#define _ITEM_T SHRectangle
#define _ARRAY_T SHRectArray
#define _FUNC_T shRectArray
#define _ARRAY_DECLARE
#include "shArrayBase.h"
#endif

View File

@@ -0,0 +1,41 @@
#ifndef __SHCONFIG_H
#define __SHCONFIG_H
////////////////////////////////////////////////////////////
// Identify the operating system
////////////////////////////////////////////////////////////
#if defined(_WIN32) || defined(__WIN32__)
// Windows
#define VG_API_WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#elif defined(linux) || defined(__linux)
// Linux
#define VG_API_LINUX
#elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)
// MacOS
#define VG_API_MACOSX
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
// FreeBSD
#define VG_API_FREEBSD
#else
// Unsupported system
#error This operating system is not supported by SFML library
#endif
#endif // __SHCONFIG_H

View File

@@ -0,0 +1,495 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <vg/openvg.h>
#include "shContext.h"
#include <string.h>
#include <stdio.h>
/*-----------------------------------------------------
* Simple functions to create a VG context instance
* on top of an existing OpenGL context.
* TODO: There is no mechanics yet to asure the OpenGL
* context exists and to choose which context / window
* to bind to.
*-----------------------------------------------------*/
static VGContext *g_context = NULL;
VG_API_CALL VGboolean vgCreateContextSH(VGint width, VGint height)
{
/* return if already created */
if (g_context) return VG_TRUE;
/* create new context */
SH_NEWOBJ(VGContext, g_context);
if (!g_context) return VG_FALSE;
/* init surface info */
g_context->surfaceWidth = width;
g_context->surfaceHeight = height;
/* setup GL projection */
/* We handle viewport and projection ourselves...
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,width,0,height);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();*/
return VG_TRUE;
}
VG_API_CALL void vgResizeSurfaceSH(VGint width, VGint height)
{
VG_GETCONTEXT(VG_NO_RETVAL);
/* update surface info */
context->surfaceWidth = width;
context->surfaceHeight = height;
/* setup GL projection */
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,width,0,height);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
VG_RETURN(VG_NO_RETVAL);
}
VG_API_CALL void vgDestroyContextSH()
{
/* return if already released */
if (!g_context) return;
/* delete context object */
SH_DELETEOBJ(VGContext, g_context);
g_context = NULL;
}
VGContext* shGetContext()
{
SH_ASSERT(g_context);
return g_context;
}
/*-----------------------------------------------------
* VGContext constructor
*-----------------------------------------------------*/
void shLoadExtensions(VGContext *c);
void VGContext_ctor(VGContext *c)
{
/* Surface info */
c->surfaceWidth = 0;
c->surfaceHeight = 0;
/* GetString info */
strncpy(c->vendor, "Ivan Leben", sizeof(c->vendor));
strncpy(c->renderer, "ShivaVG 0.1.0", sizeof(c->renderer));
strncpy(c->version, "1.0", sizeof(c->version));
strncpy(c->extensions, "", sizeof(c->extensions));
/* Mode settings */
c->matrixMode = VG_MATRIX_PATH_USER_TO_SURFACE;
c->fillRule = VG_EVEN_ODD;
c->imageQuality = VG_IMAGE_QUALITY_FASTER;
c->renderingQuality = VG_RENDERING_QUALITY_BETTER;
c->blendMode = VG_BLEND_SRC_OVER;
c->imageMode = VG_DRAW_IMAGE_NORMAL;
/* Scissor rectangles */
SH_INITOBJ(SHRectArray, c->scissor);
c->scissoring = VG_FALSE;
c->masking = VG_FALSE;
/* Stroke parameters */
c->strokeLineWidth = 1.0f;
c->strokeCapStyle = VG_CAP_BUTT;
c->strokeJoinStyle = VG_JOIN_MITER;
c->strokeMiterLimit = 4.0f;
c->strokeDashPhase = 0.0f;
c->strokeDashPhaseReset = VG_FALSE;
SH_INITOBJ(SHFloatArray, c->strokeDashPattern);
/* Edge fill color for vgConvolve and pattern paint */
CSET(c->tileFillColor, 0,0,0,0);
/* Color for vgClear */
CSET(c->clearColor, 0,0,0,0);
/* Color components layout inside pixel */
c->pixelLayout = VG_PIXEL_LAYOUT_UNKNOWN;
/* Source format for image filters */
c->filterFormatLinear = VG_FALSE;
c->filterFormatPremultiplied = VG_FALSE;
c->filterChannelMask = VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA;
/* Matrices */
SH_INITOBJ(SHMatrix3x3, c->pathTransform);
SH_INITOBJ(SHMatrix3x3, c->imageTransform);
SH_INITOBJ(SHMatrix3x3, c->fillTransform);
SH_INITOBJ(SHMatrix3x3, c->strokeTransform);
/* Paints */
c->fillPaint = NULL;
c->strokePaint = NULL;
SH_INITOBJ(SHPaint, c->defaultPaint);
/* Error */
c->error = VG_NO_ERROR;
/* Resources */
SH_INITOBJ(SHPathArray, c->paths);
SH_INITOBJ(SHPaintArray, c->paints);
SH_INITOBJ(SHImageArray, c->images);
shLoadExtensions(c);
}
/*-----------------------------------------------------
* VGContext constructor
*-----------------------------------------------------*/
void VGContext_dtor(VGContext *c)
{
int i;
SH_DEINITOBJ(SHRectArray, c->scissor);
SH_DEINITOBJ(SHFloatArray, c->strokeDashPattern);
/* Destroy resources */
for (i=0; i<c->paths.size; ++i)
SH_DELETEOBJ(SHPath, c->paths.items[i]);
for (i=0; i<c->paints.size; ++i)
SH_DELETEOBJ(SHPaint, c->paints.items[i]);
for (i=0; i<c->images.size; ++i)
SH_DELETEOBJ(SHImage, c->images.items[i]);
}
/*--------------------------------------------------
* Tries to find resources in this context
*--------------------------------------------------*/
SHint shIsValidPath(VGContext *c, VGHandle h)
{
int index = shPathArrayFind(&c->paths, (SHPath*)h);
return (index == -1) ? 0 : 1;
}
SHint shIsValidPaint(VGContext *c, VGHandle h)
{
int index = shPaintArrayFind(&c->paints, (SHPaint*)h);
return (index == -1) ? 0 : 1;
}
SHint shIsValidImage(VGContext *c, VGHandle h)
{
int index = shImageArrayFind(&c->images, (SHImage*)h);
return (index == -1) ? 0 : 1;
}
/*--------------------------------------------------
* Tries to find a resources in this context and
* return its type or invalid flag.
*--------------------------------------------------*/
SHResourceType shGetResourceType(VGContext *c, VGHandle h)
{
if (shIsValidPath(c, h))
return SH_RESOURCE_PATH;
else if (shIsValidPaint(c, h))
return SH_RESOURCE_PAINT;
else if (shIsValidImage(c, h))
return SH_RESOURCE_IMAGE;
else
return SH_RESOURCE_INVALID;
}
/*-----------------------------------------------------
* Sets the specified error on the given context if
* there is no pending error yet
*-----------------------------------------------------*/
void shSetError(VGContext *c, VGErrorCode e)
{
if (c->error == VG_NO_ERROR)
c->error = e;
}
/*--------------------------------------------------
* Returns the oldest error pending on the current
* context and clears its error code
*--------------------------------------------------*/
VG_API_CALL VGErrorCode vgGetError(void)
{
VGErrorCode error;
VG_GETCONTEXT(VG_NO_CONTEXT_ERROR);
error = context->error;
context->error = VG_NO_ERROR;
VG_RETURN(error);
}
VG_API_CALL void vgFlush(void)
{
VG_GETCONTEXT(VG_NO_RETVAL);
glFlush();
VG_RETURN(VG_NO_RETVAL);
}
VG_API_CALL void vgFinish(void)
{
VG_GETCONTEXT(VG_NO_RETVAL);
glFinish();
VG_RETURN(VG_NO_RETVAL);
}
VG_API_CALL void vgMask(VGImage mask, VGMaskOperation operation,
VGint x, VGint y, VGint width, VGint height)
{
}
VG_API_CALL void vgClear(VGint x, VGint y, VGint width, VGint height)
{
VG_GETCONTEXT(VG_NO_RETVAL);
/* Clip to window */
if (x < 0) x = 0;
if (y < 0) y = 0;
if (width > context->surfaceWidth) width = context->surfaceWidth;
if (height > context->surfaceHeight) height = context->surfaceHeight;
/* Check if scissoring needed */
if (x > 0 || y > 0 ||
width < context->surfaceWidth ||
height < context->surfaceHeight) {
glScissor(x, y, width, height);
glEnable(GL_SCISSOR_TEST);
}
/* Clear GL color buffer */
/* TODO: what about stencil and depth? when do we clear that?
we would need some kind of special "begin" function at
beginning of each drawing or clear the planes prior to each
drawing where it takes places */
glClearColor(context->clearColor.r,
context->clearColor.g,
context->clearColor.b,
context->clearColor.a);
glClear(GL_COLOR_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
VG_RETURN(VG_NO_RETVAL);
}
/*-----------------------------------------------------------
* Returns the matrix currently selected via VG_MATRIX_MODE
*-----------------------------------------------------------*/
SHMatrix3x3* shCurrentMatrix(VGContext *c)
{
switch(c->matrixMode) {
case VG_MATRIX_PATH_USER_TO_SURFACE:
return &c->pathTransform;
case VG_MATRIX_IMAGE_USER_TO_SURFACE:
return &c->imageTransform;
case VG_MATRIX_FILL_PAINT_TO_USER:
return &c->fillTransform;
default:
return &c->strokeTransform;
}
}
/*--------------------------------------
* Sets the current matrix to identity
*--------------------------------------*/
VG_API_CALL void vgLoadIdentity(void)
{
SHMatrix3x3 *m;
VG_GETCONTEXT(VG_NO_RETVAL);
m = shCurrentMatrix(context);
IDMAT((*m));
VG_RETURN(VG_NO_RETVAL);
}
/*-------------------------------------------------------------
* Loads values into the current matrix from the given array.
* Matrix affinity is preserved if an affine matrix is loaded.
*-------------------------------------------------------------*/
VG_API_CALL void vgLoadMatrix(const VGfloat * mm)
{
SHMatrix3x3 *m;
VG_GETCONTEXT(VG_NO_RETVAL);
VG_RETURN_ERR_IF(!mm, VG_ILLEGAL_ARGUMENT_ERROR, VG_NO_RETVAL);
/* TODO: check matrix array alignment */
m = shCurrentMatrix(context);
if (context->matrixMode == VG_MATRIX_IMAGE_USER_TO_SURFACE) {
SETMAT((*m),
mm[0], mm[3], mm[6],
mm[1], mm[4], mm[7],
mm[2], mm[5], mm[8]);
}else{
SETMAT((*m),
mm[0], mm[3], mm[6],
mm[1], mm[4], mm[7],
0.0f, 0.0f, 1.0f);
}
VG_RETURN(VG_NO_RETVAL);
}
/*---------------------------------------------------------------
* Outputs the values of the current matrix into the given array
*---------------------------------------------------------------*/
VG_API_CALL void vgGetMatrix(VGfloat * mm)
{
SHMatrix3x3 *m; int i,j,k=0;
VG_GETCONTEXT(VG_NO_RETVAL);
VG_RETURN_ERR_IF(!mm, VG_ILLEGAL_ARGUMENT_ERROR, VG_NO_RETVAL);
/* TODO: check matrix array alignment */
m = shCurrentMatrix(context);
for (i=0; i<3; ++i)
for (j=0; j<3; ++j)
mm[k++] = m->m[j][i];
VG_RETURN(VG_NO_RETVAL);
}
/*-------------------------------------------------------------
* Right-multiplies the current matrix with the one specified
* in the given array. Matrix affinity is preserved if an
* affine matrix is begin multiplied.
*-------------------------------------------------------------*/
VG_API_CALL void vgMultMatrix(const VGfloat * mm)
{
SHMatrix3x3 *m, mul, temp;
VG_GETCONTEXT(VG_NO_RETVAL);
VG_RETURN_ERR_IF(!mm, VG_ILLEGAL_ARGUMENT_ERROR, VG_NO_RETVAL);
/* TODO: check matrix array alignment */
m = shCurrentMatrix(context);
if (context->matrixMode == VG_MATRIX_IMAGE_USER_TO_SURFACE) {
SETMAT(mul,
mm[0], mm[3], mm[6],
mm[1], mm[4], mm[7],
mm[2], mm[5], mm[8]);
}else{
SETMAT(mul,
mm[0], mm[3], mm[6],
mm[1], mm[4], mm[7],
0.0f, 0.0f, 1.0f);
}
MULMATMAT((*m), mul, temp);
SETMATMAT((*m), temp);
VG_RETURN(VG_NO_RETVAL);
}
VG_API_CALL void vgTranslate(VGfloat tx, VGfloat ty)
{
SHMatrix3x3 *m;
VG_GETCONTEXT(VG_NO_RETVAL);
m = shCurrentMatrix(context);
TRANSLATEMATR((*m), tx, ty);
VG_RETURN(VG_NO_RETVAL);
}
VG_API_CALL void vgScale(VGfloat sx, VGfloat sy)
{
SHMatrix3x3 *m;
VG_GETCONTEXT(VG_NO_RETVAL);
m = shCurrentMatrix(context);
SCALEMATR((*m), sx, sy);
VG_RETURN(VG_NO_RETVAL);
}
VG_API_CALL void vgShear(VGfloat shx, VGfloat shy)
{
SHMatrix3x3 *m;
VG_GETCONTEXT(VG_NO_RETVAL);
m = shCurrentMatrix(context);
SHEARMATR((*m), shx, shy);
VG_RETURN(VG_NO_RETVAL);
}
VG_API_CALL void vgRotate(VGfloat angle)
{
SHfloat a;
SHMatrix3x3 *m;
VG_GETCONTEXT(VG_NO_RETVAL);
a = SH_DEG2RAD(angle);
m = shCurrentMatrix(context);
ROTATEMATR((*m), a);
VG_RETURN(VG_NO_RETVAL);
}
VG_API_CALL VGHardwareQueryResult vgHardwareQuery(VGHardwareQueryType key,
VGint setting)
{
return VG_HARDWARE_UNACCELERATED;
}

View File

@@ -0,0 +1,169 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __SHCONTEXT_H
#define __SHCONTEXT_H
#include "shDefs.h"
#include "shVectors.h"
#include "shArrays.h"
#include "shPath.h"
#include "shPaint.h"
#include "shImage.h"
/*------------------------------------------------
* VGContext object
*------------------------------------------------*/
typedef enum
{
SH_RESOURCE_INVALID = 0,
SH_RESOURCE_PATH = 1,
SH_RESOURCE_PAINT = 2,
SH_RESOURCE_IMAGE = 3
} SHResourceType;
typedef struct
{
/* Surface info (since no EGL yet) */
SHint surfaceWidth;
SHint surfaceHeight;
/* GetString info */
char vendor[256];
char renderer[256];
char version[256];
char extensions[256];
/* Mode settings */
VGMatrixMode matrixMode;
VGFillRule fillRule;
VGImageQuality imageQuality;
VGRenderingQuality renderingQuality;
VGBlendMode blendMode;
VGImageMode imageMode;
/* Scissor rectangles */
SHRectArray scissor;
VGboolean scissoring;
VGboolean masking;
/* Stroke parameters */
SHfloat strokeLineWidth;
VGCapStyle strokeCapStyle;
VGJoinStyle strokeJoinStyle;
SHfloat strokeMiterLimit;
SHFloatArray strokeDashPattern;
SHfloat strokeDashPhase;
VGboolean strokeDashPhaseReset;
/* Edge fill color for vgConvolve and pattern paint */
SHColor tileFillColor;
/* Color for vgClear */
SHColor clearColor;
/* Color components layout inside pixel */
VGPixelLayout pixelLayout;
/* Source format for image filters */
VGboolean filterFormatLinear;
VGboolean filterFormatPremultiplied;
VGbitfield filterChannelMask;
/* Matrices */
SHMatrix3x3 pathTransform;
SHMatrix3x3 imageTransform;
SHMatrix3x3 fillTransform;
SHMatrix3x3 strokeTransform;
/* Paints */
SHPaint* fillPaint;
SHPaint* strokePaint;
SHPaint defaultPaint;
VGErrorCode error;
/* Resources */
SHPathArray paths;
SHPaintArray paints;
SHImageArray images;
/* Pointers to extensions */
SHint isGLAvailable_ClampToEdge;
SHint isGLAvailable_MirroredRepeat;
SHint isGLAvailable_Multitexture;
SHint isGLAvailable_TextureNonPowerOfTwo;
SH_PGLACTIVETEXTURE pglActiveTexture;
SH_PGLMULTITEXCOORD1F pglMultiTexCoord1f;
SH_PGLMULTITEXCOORD2F pglMultiTexCoord2f;
} VGContext;
void VGContext_ctor(VGContext *c);
void VGContext_dtor(VGContext *c);
void shSetError(VGContext *c, VGErrorCode e);
SHint shIsValidPath(VGContext *c, VGHandle h);
SHint shIsValidPaint(VGContext *c, VGHandle h);
SHint shIsValidImage(VGContext *c, VGHandle h);
SHResourceType shGetResourceType(VGContext *c, VGHandle h);
VGContext* shGetContext();
/*----------------------------------------------------
* TODO: Add mutex locking/unlocking to these macros
* to assure sequentiallity in multithreading.
*----------------------------------------------------*/
#define VG_NO_RETVAL
#define VG_GETCONTEXT(RETVAL) \
VGContext *context = shGetContext(); \
if (!context) return RETVAL;
#define VG_RETURN(RETVAL) \
{ return RETVAL; }
#define VG_RETURN_ERR(ERRORCODE, RETVAL) \
{ shSetError(context,ERRORCODE); return RETVAL; }
#define VG_RETURN_ERR_IF(COND, ERRORCODE, RETVAL) \
{ if (COND) {shSetError(context,ERRORCODE); return RETVAL;} }
/*-----------------------------------------------------------
* Same macros but no mutex handling - used by sub-functions
*-----------------------------------------------------------*/
#define SH_NO_RETVAL
#define SH_GETCONTEXT(RETVAL) \
VGContext *context = shGetContext(); \
if (!context) return RETVAL;
#define SH_RETURN(RETVAL) \
{ return RETVAL; }
#define SH_RETURN_ERR(ERRORCODE, RETVAL) \
{ shSetError(context,ERRORCODE); return RETVAL; }
#define SH_RETURN_ERR_IF(COND, ERRORCODE, RETVAL) \
{ if (COND) {shSetError(context,ERRORCODE); return RETVAL;} }
#endif /* __SHCONTEXT_H */

View File

@@ -0,0 +1,179 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __SHDEFS_H
#define __SHDEFS_H
/* Standard headers */
#include "shConfig.h"
#ifdef VG_API_WINDOWS
# include <windows.h>
#endif
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#ifndef VG_API_MACOSX
# include <malloc.h>
#endif
/* Disable VGHandle-pointer conversion warnings since we
do deal with it by defining VGHandle properly */
#if defined(_MSC_VER)
# pragma warning(disable:4311)
# pragma warning(disable:4312)
#endif
/* Type definitions */
#if HAVE_INTTYPES_H
#include <inttypes.h>
#else
#define int8_t char
#define uint8_t unsigned char
#define int16_t short
#define uint16_t unsigned short
#define int32_t int
#define uint32_t unsigned int
#define int64_t long long
#define uint64_t unsigned long long
#endif
typedef int8_t SHint8;
typedef uint8_t SHuint8;
typedef int16_t SHint16;
typedef uint16_t SHuint16;
typedef int32_t SHint32;
typedef uint32_t SHuint32;
typedef float SHfloat32;
#define SHint SHint32
#define SHuint SHuint32
#define SHfloat SHfloat32
/* Maximum / minimum values */
#define SH_MAX_INT (0x7fffffff)
#define SH_MIN_INT (-0x7fffffff-1)
#define SH_MANTISSA_BITS 23
#define SH_EXPONENT_BITS 8
/* all 1s in exponent yields NaN in IEEE 754 so we take
1 less then maximum representable with exponent bits */
#define SH_MAX_EXPONENT ((1 << SH_EXPONENT_BITS) - 2)
/* maximum representable with mantissa bits */
#define SH_MAX_MANTISSA ((1 << SH_MANTISSA_BITS) - 1)
/* compose into IEEE754 floating point bit value */
#define SH_MAX_FLOAT_BITS (SH_MAX_EXPONENT << SH_MANTISSA_BITS) | SH_MAX_MANTISSA
typedef union {
float f;
unsigned int i;
} SHfloatint;
SHfloat getMaxFloat();
/* Portable function definitions */
#define SH_SQRT (float)sqrt
#define SH_COS (float)cos
#define SH_SIN (float)sin
#define SH_ACOS (float)acos
#define SH_ASIN (float)asin
#define SH_ATAN (float)atan
#define SH_FLOOR (float)floor
#define SH_CEIL (float)ceil
#define SH_ASSERT assert
#if defined(__isnan) || (defined(__APPLE__) && (__GNUC__ == 3))
# define SH_ISNAN __isnan
#elif defined(_isnan) || defined(WIN32)
# define SH_ISNAN _isnan
#else
# define SH_ISNAN isnan
#endif
/* Helper macros */
#define PI 3.141592654f
#define SH_DEG2RAD(a) (a * PI / 180.0f)
#define SH_RAD2DEG(a) (a * 180.0f / PI)
#define SH_ABS(a) ((a < 0.0f) ? -a : a)
#define SH_MAX(a,b) ((a > b) ? a : b)
#define SH_MIN(a,b) ((a < b) ? a : b)
#define SH_NEARZERO(a) (a >= -0.0001 && a < 0.0001)
#define SH_SWAP(a,b) {SHfloat t=a; a=b; b=t;}
#define SH_CLAMP(a,min,max) {if (a<min) a=min; if (a>max) a=max; }
#define SH_NEWOBJ(type,obj) { obj = (type*)malloc(sizeof(type)); if(obj) type ## _ctor(obj); }
#define SH_INITOBJ(type,obj){ type ## _ctor(&obj); }
#define SH_DEINITOBJ(type,obj) { type ## _dtor(&obj); }
#define SH_DELETEOBJ(type,obj) { if(obj) type ## _dtor(obj); free(obj); }
/* Implementation limits */
#define SH_MAX_SCISSOR_RECTS 1
#define SH_MAX_DASH_COUNT VG_MAXINT
#define SH_MAX_IMAGE_WIDTH VG_MAXINT
#define SH_MAX_IMAGE_HEIGHT VG_MAXINT
#define SH_MAX_IMAGE_PIXELS VG_MAXINT
#define SH_MAX_IMAGE_BYTES VG_MAXINT
#define SH_MAX_COLOR_RAMP_STOPS 256
#define SH_MAX_VERTICES 999999999
#define SH_MAX_RECURSE_DEPTH 16
#define SH_GRADIENT_TEX_SIZE 1024
#define SH_GRADIENT_TEX_COORDSIZE 4096 /* 1024 * RGBA */
/* OpenGL headers */
#if defined(VG_API_LINUX)
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#elif defined(VG_API_MACOSX)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#elif defined(VG_API_WINDOWS)
#include <GL/gl.h>
#include <GL/glu.h>
#else
#define GL_GLEXT_LEGACY /* don't include glext.h */
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#endif
#include "shExtensions.h"
#endif /* __SHDEFS_H */

View File

@@ -0,0 +1,131 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <vg/openvg.h>
#include "shDefs.h"
#include "shExtensions.h"
#include "shContext.h"
#include <stdio.h>
#include <string.h>
/*-----------------------------------------------------
* Extensions check
*-----------------------------------------------------*/
void fallbackActiveTexture(GLenum texture) {
}
void fallbackMultiTexCoord1f(GLenum target, GLfloat x) {
glTexCoord1f(x);
}
void fallbackMultiTexCoord2f(GLenum target, GLfloat x, GLfloat y) {
glTexCoord2f(x, y);
}
static int checkExtension(const char *extensions, const char *name)
{
int nlen = (int)strlen(name);
int elen = (int)strlen(extensions);
const char *e = extensions;
SH_ASSERT(nlen > 0);
while (1) {
/* Try to find sub-string */
e = strstr(e, name);
if (e == NULL) return 0;
/* Check if last */
if (e == extensions + elen - nlen)
return 1;
/* Check if space follows (avoid same names with a suffix) */
if (*(e + nlen) == ' ')
return 1;
e += nlen;
}
return 0;
}
typedef void (*PFVOID)();
PFVOID shGetProcAddress(const char *name)
{
#if defined(_WIN32)
return (PFVOID)wglGetProcAddress(name);
#elif defined(__APPLE__)
/* TODO: Mac OS glGetProcAddress implementation */
return (PFVOID)NULL;
#else
return (PFVOID)glXGetProcAddress((const unsigned char *)name);
#endif
}
void shLoadExtensions(VGContext *c)
{
const char *ext = (const char*)glGetString(GL_EXTENSIONS);
/* GL_TEXTURE_CLAMP_TO_EDGE */
if (checkExtension(ext, "GL_EXT_texture_edge_clamp"))
c->isGLAvailable_ClampToEdge = 1;
else if (checkExtension(ext, "GL_SGIS_texture_edge_clamp"))
c->isGLAvailable_ClampToEdge = 1;
else /* Unavailable */
c->isGLAvailable_ClampToEdge = 0;
/* GL_TEXTURE_MIRRORED_REPEAT */
if (checkExtension(ext, "GL_ARB_texture_mirrored_repeat"))
c->isGLAvailable_MirroredRepeat = 1;
else if(checkExtension(ext, "GL_IBM_texture_mirrored_repeat"))
c->isGLAvailable_MirroredRepeat = 1;
else /* Unavailable */
c->isGLAvailable_MirroredRepeat = 0;
/* glActiveTexture, glMultiTexCoord1f */
if (checkExtension(ext, "GL_ARB_multitexture")) {
c->isGLAvailable_Multitexture = 1;
c->pglActiveTexture = (SH_PGLACTIVETEXTURE)
shGetProcAddress("glActiveTextureARB");
c->pglMultiTexCoord1f = (SH_PGLMULTITEXCOORD1F)
shGetProcAddress("glMultiTexCoord1fARB");
c->pglMultiTexCoord2f = (SH_PGLMULTITEXCOORD2F)
shGetProcAddress("glMultiTexCoord2fARB");
if (c->pglActiveTexture == NULL || c->pglMultiTexCoord1f == NULL ||
c->pglMultiTexCoord2f == NULL)
c->isGLAvailable_Multitexture = 0;
}else{ /* Unavailable */
c->isGLAvailable_Multitexture = 0;
c->pglActiveTexture = (SH_PGLACTIVETEXTURE)fallbackActiveTexture;
c->pglMultiTexCoord1f = (SH_PGLMULTITEXCOORD1F)fallbackMultiTexCoord1f;
c->pglMultiTexCoord2f = (SH_PGLMULTITEXCOORD2F)fallbackMultiTexCoord2f;
}
/* Non-power-of-two textures */
if (checkExtension(ext, "GL_ARB_texture_non_power_of_two"))
c->isGLAvailable_TextureNonPowerOfTwo = 1;
else /* Unavailable */
c->isGLAvailable_TextureNonPowerOfTwo = 0;
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2007 Ivan Leben
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __SHEXTENSIONS_H
#define __SHEXTENSIONS_H
/* Define missing constants and route missing
functions to extension pointers */
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GL_VERSION_1_2
# define GL_BGRA 0x80E1
# define GL_UNSIGNED_SHORT_5_6_5 0x8363
# define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
# define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
# define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
# define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
# define GL_UNSIGNED_INT_8_8_8_8 0x8035
# define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
# define GL_CLAMP_TO_EDGE 0x812F
#endif
#ifndef GL_VERSION_1_3
# define GL_MULTISAMPLE 0x809D
# define GL_TEXTURE0 0x84C0
# define GL_TEXTURE1 0x84C1
# define GL_CLAMP_TO_BORDER 0x812D
# define glActiveTexture context->pglActiveTexture
# define glMultiTexCoord1f context->pglMultiTexCoord1f
# define glMultiTexCoord2f context->pglMultiTexCoord2f
#endif
#ifndef GL_VERSION_1_4
# define GL_MIRRORED_REPEAT 0x8370
#endif
typedef void (APIENTRYP SH_PGLACTIVETEXTURE) (GLenum);
typedef void (APIENTRYP SH_PGLMULTITEXCOORD1F) (GLenum, GLfloat);
typedef void (APIENTRYP SH_PGLMULTITEXCOORD2F) (GLenum, GLfloat, GLfloat);
#endif

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