123 Commits

Author SHA1 Message Date
2c6efbdf06 Remove native_app_glue linkage
We don't provide android_main(), Minetest does. This also didn't even work correctly.
2023-06-04 19:56:30 +02:00
510976f130 Prefer GLVND at CMake>=3.11
CMake 3.10 introduced GLVND support. CMake 3.11 introduced CMP0072,
which prefers GLVND when NEW behavior is set. I set default policies to
3.11 for CMake versions >=3.11 and did not bother with requesting GLVND
for CMake 3.10.
2023-05-14 20:54:03 +02:00
b958fdc271 Fix casing for Android device name (MATCHES is case sensitive) 2023-05-11 22:34:08 +02:00
1387370260 OpenGL3: Sort out texture color format support 2023-04-29 13:07:57 +02:00
49b6ccde72 SDL: Implement getDisplayDensity() and setWindowIcon() 2023-04-29 13:06:35 +02:00
acbc90a000 Add the platform-dependent stuff from renderingengine.cpp 2023-04-29 13:06:35 +02:00
6a2a569233 Add IImage::copyToNoScaling
(Useful for const-correctness.)
2023-04-29 13:06:35 +02:00
1f15fd0805 OpenGL3: Support min/max blend modes 2023-04-24 21:43:36 +02:00
81ad195aa3 OpenGL3: New extension listing system 2023-04-23 09:48:04 +02:00
13680ef42d OpenGL3: Use DrawBuffer[s] from mt_opengl 2023-04-18 23:22:53 +02:00
44f7c22bbf OpenGL3: Version asserts 2023-04-18 23:22:53 +02:00
2e477a07d1 OpenGL3: Add version check helper 2023-04-18 23:22:53 +02:00
78d0819a2c Add missing include 2023-04-18 23:22:53 +02:00
df07b3bf99 OpenGL3: Remove stencil buffer presence test 2023-04-18 23:22:53 +02:00
523590e16c OpenGL3: Refuse 3.0 and 3.1 2023-04-18 23:22:53 +02:00
8cf02ea27f OpenGL3: ExtensionHandler::initExtensionsNew: use GetInteger 2023-04-18 23:22:53 +02:00
efb660e7ed OpenGL3: drop unused ExtensionHandler functions 2023-04-18 23:22:53 +02:00
5f88555ed3 OpenGL3: restore MRT support 2023-04-18 23:22:53 +02:00
4ee1ab261e OpenGL3: Add driver-dependent feature checks 2023-04-18 23:22:53 +02:00
ab628e641c OpenGL3: Add two missing OpenGL extensions to COGLESCoreExtensionHandler 2023-04-18 23:22:53 +02:00
1d782702e1 OpenGL3: new version format 2023-04-18 23:22:53 +02:00
c4ab49201b Fix compile warning when appending UTF-8/ASCII strings to ustring16
String constants are (const char *), but UTF-8 strings must be treated as
an array of bytes when fiddling with the bits.

The following comparison fails without this change, as uchar8_t is a
signed char, which cannot be 0xC0:

   const uchar8_t* c2 = other;
   ...
   else if (c2[l] == 0xC0 || c2[l] == 0xC1)
   ...
2023-04-15 09:43:40 +02:00
896c825b9e Fix ComboBox changing on scroll when in a scroll container (#192) 2023-04-14 19:58:13 +01:00
7a3fc62ada Haiku: build fix 2023-04-11 20:16:35 +02:00
09043e3da7 Update MinGW dependencies 2023-04-11 18:19:36 +02:00
2d81374b34 Revert "Fix: Listbox was sometimes sending EGET_LISTBOX_SELECTED_AGAIN instead of EGET_LISTBOX_CHANGED."
This broke scrolling in listboxes, as they would always reset to top position.
reverts commit 1967d71cfb
2023-04-11 14:36:44 +02:00
aa1696a7e6 Use a buffer for quads indices
also use glDrawRangeElements for quad drawing
2023-04-08 19:08:03 +02:00
e01f285c8f Extract and use singular CNullDriver::checkImage 2023-04-08 19:07:16 +02:00
5eb607f86f Drop createImagesFromFile in favor of createImageFromFile 2023-04-08 19:07:16 +02:00
fc0440ff89 Drop IImageLoader::loadImages as only IImageLoader::loadImage is usable 2023-04-08 19:07:16 +02:00
462657960d OpenGL3: Drop always-zero vSpecularColor from the shaders 2023-04-07 17:42:54 +02:00
6a152e8629 OpenGL3: Drop unused material property uniforms 2023-04-07 17:42:54 +02:00
718ba69e1b OpenGL3: Drop unused fixed-function emulation materials 2023-04-07 17:42:54 +02:00
54314691ec Fix mistake in a677f5a01a 2023-04-06 15:00:12 +02:00
36a3a7f349 Don't compile unused driver sources 2023-04-06 12:38:25 +02:00
ca5f005b74 Fix OpenGL3 driver to compile standalone
also test this configuration in CI
2023-04-06 12:38:25 +02:00
e850bd102a Minor adjustments to configuration flow 2023-04-06 12:12:46 +02:00
a677f5a01a Only try to link libraries when relevant feature is enabled
fixes #182
2023-04-06 11:56:04 +02:00
f5d3448b17 Document new CMake options 2023-04-06 11:35:30 +02:00
3a074e4124 Merge branch 'opengl3' of https://github.com/numberZero/irrlicht 2023-04-06 11:20:03 +02:00
70ee4b05aa Indicate chosen OpenGL ES 2 driver during configuration 2023-04-05 22:52:43 +03:00
58a96b7d23 Mark the repo as root in the editorconfig
Necessary due to CR/LF mess, it shouldn’t inherit the LF setting from Minetest.
2023-04-02 21:50:56 +02:00
DS
ba1cd19983 Use non-static member vars for SDL clipboard / primary selection buffers 2023-03-26 14:13:58 +02:00
a67f3003de Revert "Avoid some broken calculations for IBoneSceneNode positions."
This was reported to cause broken models in some cases.
reverts commit edb381bd50
2023-03-26 14:09:40 +02:00
4dda28450f Provide sources as private to IRRVIDEOOBJ 2023-03-25 11:26:52 +03:00
219b7fd7d2 Fix line endings in the new driver 2023-03-25 11:11:09 +03:00
28d0e0644c Add shaders for COpenGL3DriverBase
Currently, they are identical to OGLES2 shaders, except of version specification.
2023-03-25 11:10:05 +03:00
d97d1708d6 Resolve conflicts with master 2023-03-25 10:42:47 +03:00
799c8b936f SDL: Support primary selection
Requires SDL >= 2.25.0 (newest master).
2023-03-24 17:59:06 +01:00
8da1bcf58b SDL: Support clipboard 2023-03-24 17:59:06 +01:00
d86abb40c1 CGUIEditBox: Use primary selection
This is essentially the same as the commit in the minetest repo for GUIEditBox.
2023-03-24 17:59:06 +01:00
53b9eaa831 Implement X11 primary selection 2023-03-24 17:59:06 +01:00
1967d71cfb Fix: Listbox was sometimes sending EGET_LISTBOX_SELECTED_AGAIN instead of EGET_LISTBOX_CHANGED.
When pressed mouse was moved over an item before releasing the mouse button it was sending immediately EGET_LISTBOX_SELECTED_AGAIN instead of expected EGET_LISTBOX_CHANGED (mouse  move changes do not send any events).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6454 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
c5373262ca Use qualifed id instead of virtual function calls in CVertexBuffer constructors
Another find by cppcheck tool

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6448 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
939b3f7bfb Avoid undefined arithmetic on nullptr in buffer_offset function
Not quite sure why it was done that way. Maybe to ensure we work with byte-pointers of correct size or something?
Anyway, this doesn't seem to be defined in c++, so let's try working with a cast instead.
Just something cppcheck tool complained about.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6447 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
9c2c91776e Fix spelling of enums in header comments
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6445 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
6f3435f349 Prevent potential 0 pointer access when release not acquired joystick.
Found by clang analyser. Not sure if it could really ever have happened, but won't hurt to fix

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6443 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
9f9d22ca33 Fix some problems with CMatrix4::getRotationDegrees
- Only the getRotationDegrees without parameter is allowed to try fixing scale.
  My fault when I added a new function which takes scale parameter, that one is
  not allowed to be changed.
  On the up-side - we know have for the first time an option which works in cases only
  scale and rotation had been used and the user still has the correct scale.
  Before any solution for that was broken
- getRotationDegrees fixes 2 places which caused wrong results due to floating point inaccuracies
  New test for that got added
- Document the current restrains and problems of getRotationDegrees and getScale some more.
- Improve docs for other matrix4 functions.
- Add some comments about further improvements (I'll try if I find time)

Note: Irrlicht still assumes in at least 2 places (getting bone animations and Collada loader) that matrix
decomposing works. Which it doesn't yet for matrices which switch handedness (or have further transformations like skewing axes)
The bone animation is mostly fine for now with recent workaround (but that might cause other problems as it may be used too often), haven't checked Collada yet in detail.

TL/DR: This improves things with getRotationDegrees, but does not yet fix all troubles.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6439 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
edb381bd50 Avoid some broken calculations for IBoneSceneNode positions.
This is based on bugreport #458 reported by viwrap who also made a nice test-case model.
Note: While solution seems to work and would even be faster, I'm not 100% sure yet if there are no downsides.
The other solution seems to regard last column in matrices - thought I don't think we ever set or use that.
And I also haven't found out yet _why_ the original solution goes wrong.
But animation system uses right-hand quaternions unlike rest of Irrlicht which is obviously a bit dangerous, will have to check the conversions some day.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6438 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
8ffa7eafea Fix warning
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6434 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
2bff147904 Fix: Make CBillboardSceneNode bounding-box large enough to fit the billboard inside.
It still won't work yet for scaled boundingboxes (or parents being scaled).
But at least it's now large enough for typical unscaled boundingboxes.
Before it was always too small - even for the simplest quadratic billboard case seen without rotation.
Now it's always a bit too large, but that's way less of a problem (collisions still work and culling simply happens a bit less often, but not too often which is way worse)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6431 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
3cf75cdce4 Fix IGUIElements not getting a tab order because of invisible or disabled parents.
First problem was that IGUIElement::getNextElement wasn't passing includeInvisible and includeDisabled flags recursively, so anything deeper than one level could fail if an element was disabled/invisible in between while it was created.
Second problem was that setTabOrder(-1) did ignore disabled elements. So when any parent was disabled when elements were created they never got a tab order.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6428 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
a7f9afd289 Avoid ambigious conversions when compiling with c++20
Yay, more ugly casts needed.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6427 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
98df6eae77 Unify & improve log messages
Lots of places where coders did not realize our Printer::log with hint adds a ": " string between message and hint
Which caused uglier messages in a few places (added documentation for that, maybe helps?)
Some added info in a few places
Some whitespace unification
Some spelling unification

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6414 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
3ce4b2b5dc Prevent crash when creating CCameraSceneNode while rendertarget has height 0
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6405 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
424eb85f4d Minor const changes.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6402 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
6a9e0f109c Avoid potential number overflows.
Found by VS code analyser

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6393 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
15e3f15b48 SpriteBank: error check on non existing textureNumber
seen in broken Fonts. unified getFrameNr

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6368 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
263f243523 S3DVertex initialize color always. It's derived classes now both accept const S3DVertex& constructor.
color intitialization has some cost, but we initialized all other values already (vectors are always set to 0).
Don't think it's a good idea to have one value around which is random.
S3DVertex2TCoords(S3DVertex& o) to S3DVertex2TCoords(const S3DVertex& o) simply because it makes more sense
S3DVertexTangents(const S3DVertex& o) added because I'll need it later (and no idea why only S3DVertex2TCoords got one of those before).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6359 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
c5ee8c8397 CVertexBuffer no longer re-allocates stuff when type doesn't change
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6339 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
b0c03b6f3b Add documentation that sourceRect of draw2dImage is based on the OriginalSize
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6324 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
679d3a8ba7 Avoid some more warnings when working with CMatrix4<f64>
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6304 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
d1f441787a Avoid warnings when working with CMatrix4<f64>
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6303 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
739a9eaf7c IVideoDriver::setMaterialRendererName now using u32 for index like other similar functions
Other functions like getMaterialRendererName got switched to u32 in the past. I can see no reason why this one was left out, so changing it to be same as the rest.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6300 dfc29bdd-3216-0410-991c-e03cc46cb475
2023-03-24 17:09:11 +01:00
0acf0de2db Delete changes.txt
Gets in the way of cherry-picking and isn't up to date anyway.
2023-03-20 14:46:27 +01:00
52a0b9d8e5 Drop dependency on FileSystem from SceneManager 2023-03-19 19:47:43 +01:00
0160cdc51d Drop unused dependency of SceneManager on GUIEnvironment 2023-03-19 19:47:43 +01:00
5a1565072a Drop unused dependency on FileSystem in mesh loaders 2023-03-19 19:47:43 +01:00
25a7074c9a Remove all mentions of iOS 2023-03-14 17:54:08 +01:00
df8881898d Remove CIrrDeviceiOS 2023-03-14 17:54:08 +01:00
ba77d01c91 Error out early on unsupported SDL2+GLES1 combo 2023-03-13 19:16:06 +03:00
f641500d01 Add xvfb (for tests) 2023-03-13 18:45:50 +03:00
02c6449f0d Add CI for the new GL ES 2 driver 2023-03-13 18:40:11 +03:00
2331083837 Add CI for the new OpenGL 3 driver 2023-03-13 18:40:06 +03:00
d84dc18e13 Add OpenGL3 support to the autotests 2023-03-13 18:38:47 +03:00
ea0ca7f917 Small Fixes 2023-03-13 18:33:58 +03:00
82d1feb933 Accommodate lack of ETS_TEXTURE_1 2023-03-13 18:17:47 +03:00
d81db9dd6d Merge branch 'drop-irr-compile-config' into opengl3 2023-03-13 18:07:25 +03:00
6c68217426 Merge branch 'master' into drop-irr-compile-config 2023-03-13 18:05:36 +03:00
21c61e9973 Bump revision early 2023-03-11 15:12:05 +01:00
5a5a7d04b7 Drop IrrCompileConfig (#163) 2023-03-11 15:04:09 +01:00
b279810437 Consolidate import/export attribute definitions 2023-03-06 17:32:03 +03:00
e484698ba2 Restrict X11 options to X11 device 2023-03-06 14:22:48 +03:00
5f76be9380 Restore isDriverSupported, but in a cpp file 2023-03-06 14:22:48 +03:00
6de0afa8b3 Drop ETS_TEXTURE_1
The transformation state itself is still available via ETS_TEXTURE_0+1
2023-03-06 14:22:48 +03:00
a6d062ebd9 Apply suggestions from code review
Co-authored-by: sfan5 <sfan5@live.de>
2023-03-04 22:27:43 +03:00
2e9ed529b1 Restore obsolete constants as they are still used in some code I don’t want to touch 2023-03-03 22:01:50 +03:00
ceb53be9e3 Merge branch 'master' into opengl3 2023-03-03 22:01:30 +03:00
df28a4cc46 Fix ifdefs around includes in CIrrDeviceSDL 2023-03-03 21:23:07 +03:00
8dd8652f5f Split new GL3/GLES2 drivers
The classes are tiny wrappers currently but should they be customized, they are there
2023-03-03 20:29:36 +03:00
2932065346 Report as OpenGL 3 2023-03-02 03:03:17 +03:00
1326dfbcb1 Error out on unsupported configurations 2023-03-02 02:44:52 +03:00
1bbe341daa Support both OpenGL3 and GLES2 on SDL2 2023-03-02 02:44:52 +03:00
d6716ec31b Support GLES2 2023-03-02 02:41:58 +03:00
620f4869a1 Drop obsolete video drivers 2023-03-02 01:22:04 +03:00
05384fdc5e Unify drawing functions 2023-02-28 00:51:29 +03:00
48270029cd Drop obsolete stuff 2023-02-27 23:36:56 +03:00
c5ce853148 Unify quad drawing 2023-02-27 23:36:47 +03:00
4fba496917 Unify plain image drawing 2023-02-27 21:27:23 +03:00
79fdab0551 Drop obsolete IVideoDriver features 2023-02-27 21:26:46 +03:00
608aa150ff Load extensions the OpenGL 3 way 2023-02-27 20:32:06 +03:00
1f750cd7b2 Add debug handler 2023-02-27 20:31:51 +03:00
8c521939b9 Enumerate extensions in the OpenGL 3 way 2023-02-27 17:41:03 +03:00
cfa8dd7845 Request OpenGL 3.2 2023-02-27 17:39:28 +03:00
01295c9ce6 Add OpenGL3 renderer 2023-02-27 17:05:11 +03:00
5a95b40a0e Reduce IrrCompileConfig usage to files that actually need it 2023-02-22 21:11:12 +03:00
8efd4527f6 Drop _IRR_MATERIAL_MAX_TEXTURES_ 2023-02-22 21:11:12 +03:00
a0e1e39ea7 Drop _IRR_SCENEMANAGER_DEBUG 2023-02-22 21:11:12 +03:00
d8e09f14bd Drop _IRR_COMPILE_WITH_GUI_ 2023-02-22 21:11:12 +03:00
67f852be57 Drop obsolete configuration macros 2023-02-22 21:11:12 +03:00
5a2b807890 Move import/export macros into CMake 2023-02-22 21:11:12 +03:00
06db7b7ab7 Move platform detection to CMake 2023-02-22 21:11:12 +03:00
38f18eec56 Drop unused stuff from IrrCompileConfig 2023-02-21 18:16:39 +03:00
183 changed files with 6044 additions and 9082 deletions

View File

@ -1,3 +1,5 @@
root = true
[*]
charset = utf-8

View File

@ -48,9 +48,7 @@ jobs:
- name: Build
run: |
sed '/#define _IRR_COMPILE_WITH_OGLES2_/ s|^//||g' -i include/IrrCompileConfig.h
sed '/#define _IRR_COMPILE_WITH_OPENGL_/ s|^|//|g' -i include/IrrCompileConfig.h
cmake . -DBUILD_EXAMPLES=1
cmake . -DBUILD_EXAMPLES=1 -DENABLE_OPENGL=OFF -DENABLE_GLES2=ON
make -j2
- name: Test (headless)
@ -61,7 +59,7 @@ jobs:
- name: Test (Xvfb)
run: |
cd bin/Linux
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2
linux-sdl:
runs-on: ubuntu-latest
@ -77,8 +75,7 @@ jobs:
- name: Build
run: |
sed '/#define _IRR_COMPILE_WITH_SDL_DEVICE_/ s|^//||g' -i include/IrrCompileConfig.h
cmake . -DBUILD_EXAMPLES=1
cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON
make -j2
- name: Test (headless)
@ -86,6 +83,60 @@ jobs:
cd bin/Linux
./AutomatedTest null
linux-sdl-gl3:
runs-on: ubuntu-latest
container:
image: ubuntu:jammy
env: { LANG: "C.UTF-8" }
steps:
- uses: actions/checkout@v3
- name: Install deps
run: |
apt-get update
apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy
- name: Build
run: |
cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON -DENABLE_OPENGL=OFF -DENABLE_OPENGL3=ON
make -j2
- name: Test (headless)
run: |
cd bin/Linux
./AutomatedTest null
- name: Test (Xvfb)
run: |
cd bin/Linux
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest opengl3
linux-sdl-gles2:
runs-on: ubuntu-latest
container:
image: ubuntu:jammy
env: { LANG: "C.UTF-8" }
steps:
- uses: actions/checkout@v3
- name: Install deps
run: |
apt-get update
apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy
- name: Build
run: |
cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON -DENABLE_OPENGL=OFF -DENABLE_GLES2=ON
make -j2
- name: Test (headless)
run: |
cd bin/Linux
./AutomatedTest null
- name: Test (Xvfb)
run: |
cd bin/Linux
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2
win32:
runs-on: ubuntu-20.04
steps:

View File

@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 3.5)
# Set policies up to 3.9 since we want to enable the IPO option
if(${CMAKE_VERSION} VERSION_LESS 3.9)
# >=3.9 enables IPO; >=3.11 prefers GLVND
if(${CMAKE_VERSION} VERSION_LESS 3.11)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.9)
cmake_policy(VERSION 3.11)
endif()
set(IRRLICHTMT_REVISION 10)
set(IRRLICHTMT_REVISION 11)
project(Irrlicht
VERSION 1.9.0.${IRRLICHTMT_REVISION}

View File

@ -20,6 +20,11 @@ The following libraries are required to be installed:
Aside from standard search options (`ZLIB_INCLUDE_DIR`, `ZLIB_LIBRARY`, ...) the following options are available:
* `BUILD_SHARED_LIBS` (default: `ON`) - Build IrrlichtMt as a shared library
* `BUILD_EXAMPLES` (default: `OFF`) - Build example applications
* `ENABLE_OPENGL` - Enable OpenGL driver
* `ENABLE_OPENGL3` (default: `OFF`) - Enable OpenGL 3+ driver
* `ENABLE_GLES1` - Enable OpenGL ES driver, legacy
* `ENABLE_GLES2` - Enable OpenGL ES 2+ driver
* `USE_SDL2` (default: `OFF`) - Use SDL2 instead of native platform device
e.g. on a Linux system you might want to build for local use like this:

File diff suppressed because it is too large Load Diff

View File

@ -10,15 +10,19 @@ static int test_fail = 0;
void test_irr_array();
void test_irr_string();
static video::E_DRIVER_TYPE chooseDriver(const char *arg_)
static video::E_DRIVER_TYPE chooseDriver(core::stringc arg_)
{
if (core::stringc(arg_) == "null")
if (arg_ == "null")
return video::EDT_NULL;
if (IrrlichtDevice::isDriverSupported(video::EDT_OGLES1))
if (arg_ == "ogles1")
return video::EDT_OGLES1;
if (IrrlichtDevice::isDriverSupported(video::EDT_OGLES2))
if (arg_ == "ogles2")
return video::EDT_OGLES2;
if (arg_ == "opengl")
return video::EDT_OPENGL;
if (arg_ == "opengl3")
return video::EDT_OPENGL3;
std::cerr << "Unknown driver type: " << arg_.c_str() << ". Trying OpenGL." << std::endl;
return video::EDT_OPENGL;
}
@ -83,8 +87,12 @@ int main(int argc, char *argv[])
const io::path mediaPath = getExampleMediaPath();
scene::IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "coolguy_opt.x");
auto mesh_file = device->getFileSystem()->createAndOpenFile(mediaPath + "coolguy_opt.x");
check(mesh_file, "mesh file loading");
scene::IAnimatedMesh* mesh = smgr->getMesh(mesh_file);
check(mesh, "mesh loading");
if (mesh_file)
mesh_file->drop();
if (mesh)
{
video::ITexture* tex = driver->getTexture(mediaPath + "cooltexture.png");

View File

@ -75,18 +75,18 @@ namespace scene
CVertexBuffer(video::E_VERTEX_TYPE vertexType) : Vertices(0),
MappingHint(EHM_NEVER), ChangedID(1)
{
setType(vertexType);
CVertexBuffer::setType(vertexType);
}
CVertexBuffer(const IVertexBuffer &VertexBufferCopy) :
Vertices(0), MappingHint(EHM_NEVER),
ChangedID(1)
{
setType(VertexBufferCopy.getType());
reallocate(VertexBufferCopy.size());
CVertexBuffer::setType(VertexBufferCopy.getType());
CVertexBuffer::reallocate(VertexBufferCopy.size());
for (u32 n=0;n<VertexBufferCopy.size();++n)
push_back(VertexBufferCopy[n]);
CVertexBuffer::push_back(VertexBufferCopy[n]);
}
virtual ~CVertexBuffer()
@ -97,6 +97,9 @@ namespace scene
void setType(video::E_VERTEX_TYPE vertexType) override
{
if ( Vertices && Vertices->getType() == vertexType )
return;
IVertexList *NewVertices=0;
switch (vertexType)

View File

@ -25,13 +25,9 @@ namespace irr
/** This device uses Apple's Cocoa API and works in Mac OSX 10.2 and above. */
EIDT_OSX,
//! A device native to the iOS
/** This device should be used with the OpenGL-ES driver. */
EIDT_IOS,
//! A device which uses Simple DirectMedia Layer
/** The SDL device works under all platforms supported by SDL but first must be compiled
in by defining the _IRR_COMPILE_WITH_SDL_DEVICE_ macro in IrrCompileConfig.h */
in by setting the USE_SDL2 CMake option to ON */
EIDT_SDL,
//! This selection allows Irrlicht to choose the best device from the ones available.

View File

@ -20,31 +20,11 @@ namespace video
render and display any graphics. */
EDT_NULL,
//! The Irrlicht Engine Software renderer.
/** Runs on all platforms, with every hardware. It should only
be used for 2d graphics, but it can also perform some primitive
3d functions. These 3d drawing functions are quite fast, but
very inaccurate, and don't even support clipping in 3D mode. */
// obsolete constants to make some code happy
// TODO delete
EDT_SOFTWARE,
//! The Burning's Software Renderer, an alternative software renderer
/** Basically it can be described as the Irrlicht Software
renderer on steroids. It rasterizes 3D geometry perfectly: It
is able to perform correct 3d clipping, perspective correct
texture mapping, perspective correct color mapping, and renders
sub pixel correct, sub texel correct primitives. In addition,
it does bilinear texel filtering and supports more materials
than the EDT_SOFTWARE driver. This renderer has been written
entirely by Thomas Alten, thanks a lot for this huge
contribution. */
EDT_BURNINGSVIDEO,
//! Direct3D8 device is longer supported in Irrlicht. You have to go back to Irrlicht 1.8 if you still need that.
DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS, // keep enum to avoid breaking enumeration order (might be used in ini-files, serialization, etc)
//! Direct3D 9 device, only available on Win32 platforms.
/** Performs hardware accelerated rendering of 3D and 2D
primitives. */
DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS,
EDT_DIRECT3D9,
//! OpenGL device, available on most platforms.
@ -62,38 +42,12 @@ namespace video
//! WebGL1 friendly subset of OpenGL-ES 2.x driver for Emscripten
EDT_WEBGL1,
EDT_OPENGL3,
//! No driver, just for counting the elements
EDT_COUNT
};
const c8* const DRIVER_TYPE_NAMES[] =
{
"NullDriver",
"Software Renderer",
"Burning's Video",
"Direct3D 8.1",
"Direct3D 9.0c",
"OpenGL 1.x/2.x/3.x",
"OpenGL ES1",
"OpenGL ES2",
"WebGL 1",
0
};
const c8* const DRIVER_TYPE_NAMES_SHORT[] =
{
"null",
"software",
"burning",
"d3d8",
"d3d9",
"opengl",
"ogles1",
"ogles2",
"webgl1",
0
};
} // end namespace video
} // end namespace irr

View File

@ -452,10 +452,10 @@ struct SEvent
/** Unlike other events, joystick events represent the result of polling
* each connected joystick once per run() of the device. Joystick events will
* not be generated by default. If joystick support is available for the
* active device, _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ is defined, and
* @ref irr::IrrlichtDevice::activateJoysticks() has been called, an event of
* this type will be generated once per joystick per @ref IrrlichtDevice::run()
* regardless of whether the state of the joystick has actually changed. */
* active device, and @ref irr::IrrlichtDevice::activateJoysticks() has been
* called, an event of this type will be generated once per joystick per
* @ref IrrlichtDevice::run() regardless of whether the state of the joystick
* has actually changed. */
struct SJoystickEvent
{
enum

View File

@ -54,9 +54,9 @@ namespace gui
//! Sets text justification of the text area
/** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text.
EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text.
\param vertical: EGUIA_UPPERLEFT to align with top edge,
EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
//! Set the maximal number of rows for the selection listbox

View File

@ -433,7 +433,7 @@ public:
if (el)
{
// find the highest element number
el->getNextElement(-1, true, IsTabGroup, first, closest, true);
el->getNextElement(-1, true, IsTabGroup, first, closest, true, true);
if (first)
{
TabOrder = first->getTabOrder() + 1;
@ -706,7 +706,7 @@ public:
}
}
// search within children
if ((*it)->getNextElement(startOrder, reverse, group, first, closest))
if ((*it)->getNextElement(startOrder, reverse, group, first, closest, includeInvisible, includeDisabled))
{
return true;
}

View File

@ -88,9 +88,9 @@ namespace gui
//! Sets text justification mode
/** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text.
EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text.
\param vertical: EGUIA_UPPERLEFT to align with top edge (default),
EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text. */
EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text. */
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
//! Enables or disables word wrap for using the static text as multiline text control.

View File

@ -329,6 +329,12 @@ public:
//! Sets a pixel
virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ) = 0;
//! Copies this surface into another, if it has the exact same size and format.
/** NOTE: mipmaps are ignored
\return True if it was copied, false otherwise.
*/
virtual bool copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) const = 0;
//! Copies the image into the target, scaling the image to fit
/** NOTE: mipmaps are ignored */
virtual void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) =0;

View File

@ -45,17 +45,6 @@ public:
/** \param file File handle to check.
\return Pointer to newly created image, or 0 upon error. */
virtual IImage* loadImage(io::IReadFile* file) const = 0;
//! Creates a multiple surfaces from the file eg. whole cube map.
/** \param file File handle to check.
\param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
\return Array of pointers to newly created images. */
virtual core::array<IImage*> loadImages(io::IReadFile* file, E_TEXTURE_TYPE* type) const
{
core::array<IImage*> image;
return image;
}
};

View File

@ -26,12 +26,23 @@ public:
}
//! Copies text to the clipboard
//! \param text: text in utf-8
virtual void copyToClipboard(const c8* text) const = 0;
//! Copies text to the primary selection
//! This is a no-op on some platforms.
//! \param text: text in utf-8
virtual void copyToPrimarySelection(const c8* text) const = 0;
//! Get text from the clipboard
/** \return Returns 0 if no string is in there. */
//! \return Returns 0 if no string is in there, otherwise an utf-8 string.
virtual const c8* getTextFromClipboard() const = 0;
//! Get text from the primary selection
//! This is a no-op on some platforms.
//! \return Returns 0 if no string is in there, otherwise an utf-8 string.
virtual const c8* getTextFromPrimarySelection() const = 0;
//! Get the total and available system RAM
/** \param totalBytes: will contain the total system memory in Kilobytes (1024 B)
\param availableBytes: will contain the available memory in Kilobytes (1024 B)

View File

@ -318,20 +318,10 @@ namespace scene
* \endcode
* If you would like to implement and add your own file format loader to Irrlicht,
* see addExternalMeshLoader().
* \param filename: Filename of the mesh to load.
* \param alternativeCacheName: In case you want to have the mesh under another name in the cache (to create real copies)
* \param file File handle of the mesh to load.
* \return Null if failed, otherwise pointer to the mesh.
* This pointer should not be dropped. See IReferenceCounted::drop() for more information.
**/
virtual IAnimatedMesh* getMesh(const io::path& filename, const io::path& alternativeCacheName=io::path("")) = 0;
//! Get pointer to an animateable mesh. Loads the file if not loaded already.
/** Works just as getMesh(const char* filename). If you want to
remove a loaded mesh from the cache again, use removeMesh().
\param file File handle of the mesh to load.
\return NULL if failed and pointer to the mesh if successful.
This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */
virtual IAnimatedMesh* getMesh(io::IReadFile* file) = 0;
//! Get interface to the mesh cache which is shared between all existing scene managers.
@ -345,16 +335,6 @@ namespace scene
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual video::IVideoDriver* getVideoDriver() = 0;
//! Get the active GUIEnvironment
/** \return Pointer to the GUIEnvironment
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual gui::IGUIEnvironment* getGUIEnvironment() = 0;
//! Get the active FileSystem
/** \return Pointer to the FileSystem
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual io::IFileSystem* getFileSystem() = 0;
//! Adds a scene node for rendering an animated mesh model.
/** \param mesh: Pointer to the loaded animated mesh to be displayed.
\param parent: Parent of the scene node. Can be NULL if no parent.

View File

@ -56,32 +56,11 @@ namespace video
ETS_WORLD,
//! Projection transformation
ETS_PROJECTION,
//! Texture transformation
//! Texture 0 transformation
//! Use E_TRANSFORMATION_STATE(ETS_TEXTURE_0 + texture_number) to access other texture transformations
ETS_TEXTURE_0,
//! Texture transformation
ETS_TEXTURE_1,
//! Texture transformation
ETS_TEXTURE_2,
//! Texture transformation
ETS_TEXTURE_3,
#if _IRR_MATERIAL_MAX_TEXTURES_>4
//! Texture transformation
ETS_TEXTURE_4,
#if _IRR_MATERIAL_MAX_TEXTURES_>5
//! Texture transformation
ETS_TEXTURE_5,
#if _IRR_MATERIAL_MAX_TEXTURES_>6
//! Texture transformation
ETS_TEXTURE_6,
#if _IRR_MATERIAL_MAX_TEXTURES_>7
//! Texture transformation
ETS_TEXTURE_7,
#endif
#endif
#endif
#endif
//! Only used internally
ETS_COUNT = ETS_TEXTURE_0 + _IRR_MATERIAL_MAX_TEXTURES_
ETS_COUNT = ETS_TEXTURE_0 + MATERIAL_MAX_TEXTURES
};
//! Special render targets, which usually map to dedicated hardware
@ -738,23 +717,6 @@ namespace video
virtual void draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color = SColor(255,255,255,255)) =0;
//! Draws a 3d triangle.
/** This method calls drawVertexPrimitiveList for some triangles.
This method works with all drivers because it simply calls
drawVertexPrimitiveList, but it is hence not very fast.
Note that the triangle is drawn using the current
transformation matrix and material. So if you need to draw it
independently of the current transformation, use
\code
driver->setMaterial(someMaterial);
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
\endcode
for some properly set up material before drawing the triangle.
\param triangle The triangle to draw.
\param color Color of the line. */
virtual void draw3DTriangle(const core::triangle3df& triangle,
SColor color = SColor(255,255,255,255)) =0;
//! Draws a 3d axis aligned box.
/** This method simply calls draw3DLine for the edges of the
box. Note that the box is drawn using the current transformation
@ -785,7 +747,7 @@ namespace video
\param texture Texture to be drawn.
\param destPos Upper left 2d destination position where the
image will be drawn.
\param sourceRect Source rectangle in the image.
\param sourceRect Source rectangle in the texture (based on it's OriginalSize)
\param clipRect Pointer to rectangle on the screen where the
image is clipped to.
If this pointer is NULL the image is not clipped.
@ -799,35 +761,6 @@ namespace video
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0;
//! Draws a set of 2d images, using a color and the alpha channel of the texture.
/** The images are drawn beginning at pos and concatenated in
one line. All drawings are clipped against clipRect (if != 0).
The subtextures are defined by the array of sourceRects and are
chosen by the indices given.
\param texture Texture to be drawn.
\param pos Upper left 2d destination position where the image
will be drawn.
\param sourceRects Source rectangles of the image.
\param indices List of indices which choose the actual
rectangle used each time.
\param kerningWidth Offset to Position on X
\param clipRect Pointer to rectangle on the screen where the
image is clipped to.
If this pointer is 0 then the image is not clipped.
\param color Color with which the image is drawn.
Note that the alpha component is used. If alpha is other than
255, the image will be transparent.
\param useAlphaChannelOfTexture: If true, the alpha channel of
the texture is used to draw the image. */
virtual void draw2DImageBatch(const video::ITexture* texture,
const core::position2d<s32>& pos,
const core::array<core::rect<s32> >& sourceRects,
const core::array<s32>& indices,
s32 kerningWidth=0,
const core::rect<s32>* clipRect=0,
SColor color=SColor(255,255,255,255),
bool useAlphaChannelOfTexture=false) =0;
//! Draws a set of 2d images, using a color and the alpha channel of the texture.
/** All drawings are clipped against clipRect (if != 0).
The subtextures are defined by the array of sourceRects and are
@ -835,7 +768,7 @@ namespace video
\param texture Texture to be drawn.
\param positions Array of upper left 2d destinations where the
images will be drawn.
\param sourceRects Source rectangles of the image.
\param sourceRects Source rectangles of the texture (based on it's OriginalSize)
\param clipRect Pointer to rectangle on the screen where the
images are clipped to.
If this pointer is 0 then the image is not clipped.
@ -855,7 +788,7 @@ namespace video
/** Suggested and first implemented by zola.
\param texture The texture to draw from
\param destRect The rectangle to draw into
\param sourceRect The rectangle denoting a part of the texture
\param sourceRect The rectangle denoting a part of the texture (based on it's OriginalSize)
\param clipRect Clips the destination rectangle (may be 0)
\param colors Array of 4 colors denoting the color values of
the corners of the destRect
@ -898,13 +831,6 @@ namespace video
SColor colorLeftDown, SColor colorRightDown,
const core::rect<s32>* clip =0) =0;
//! Draws the outline of a 2D rectangle.
/** \param pos Position of the rectangle.
\param color Color of the rectangle to draw. The alpha component
specifies how transparent the rectangle outline will be. */
virtual void draw2DRectangleOutline(const core::recti& pos,
SColor color=SColor(255,255,255,255)) =0;
//! Draws a 2d line.
/** In theory both start and end will be included in coloring.
BUG: Currently d3d ignores the last pixel
@ -918,72 +844,6 @@ namespace video
const core::position2d<s32>& end,
SColor color=SColor(255,255,255,255)) =0;
//! Draws a pixel.
/** \param x The x-position of the pixel.
\param y The y-position of the pixel.
\param color Color of the pixel to draw. */
virtual void drawPixel(u32 x, u32 y, const SColor& color) =0;
//! Draws a non filled concyclic regular 2d polygon.
/** This method can be used to draw circles, but also
triangles, tetragons, pentagons, hexagons, heptagons, octagons,
enneagons, decagons, hendecagons, dodecagon, triskaidecagons,
etc. I think you'll got it now. And all this by simply
specifying the vertex count. Welcome to the wonders of
geometry.
\param center Position of center of circle (pixels).
\param radius Radius of circle in pixels.
\param color Color of the circle.
\param vertexCount Amount of vertices of the polygon. Specify 2
to draw a line, 3 to draw a triangle, 4 for tetragons and a lot
(>10) for nearly a circle. */
virtual void draw2DPolygon(core::position2d<s32> center,
f32 radius,
video::SColor color=SColor(100,255,255,255),
s32 vertexCount=10) =0;
//! Draws a shadow volume into the stencil buffer.
/** To draw a stencil shadow, do this: First, draw all geometry.
Then use this method, to draw the shadow volume. Then, use
IVideoDriver::drawStencilShadow() to visualize the shadow.
Please note that the code for the opengl version of the method
is based on free code sent in by Philipp Dortmann, lots of
thanks go to him!
\param triangles Array of 3d vectors, specifying the shadow
volume.
\param zfail If set to true, zfail method is used, otherwise
zpass.
\param debugDataVisible The debug data that is enabled for this
shadow node
*/
virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail=true, u32 debugDataVisible=0) =0;
//! Fills the stencil shadow with color.
/** After the shadow volume has been drawn into the stencil
buffer using IVideoDriver::drawStencilShadowVolume(), use this
to draw the color of the shadow.
Please note that the code for the opengl version of the method
is based on free code sent in by Philipp Dortmann, lots of
thanks go to him!
\param clearStencilBuffer Set this to false, if you want to
draw every shadow with the same color, and only want to call
drawStencilShadow() once after all shadow volumes have been
drawn. Set this to true, if you want to paint every shadow with
its own color.
\param leftUpEdge Color of the shadow in the upper left corner
of screen.
\param rightUpEdge Color of the shadow in the upper right
corner of screen.
\param leftDownEdge Color of the shadow in the lower left
corner of screen.
\param rightDownEdge Color of the shadow in the lower right
corner of screen. */
virtual void drawStencilShadow(bool clearStencilBuffer=false,
video::SColor leftUpEdge = video::SColor(255,0,0,0),
video::SColor rightUpEdge = video::SColor(255,0,0,0),
video::SColor leftDownEdge = video::SColor(255,0,0,0),
video::SColor rightDownEdge = video::SColor(255,0,0,0)) =0;
//! Draws a mesh buffer
/** \param mb Buffer to draw */
virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) =0;
@ -1099,28 +959,6 @@ namespace video
\return The current texture creation flag enabled mode. */
virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const =0;
//! Creates a software images from a file.
/** No hardware texture will be created for those images. This
method is useful for example if you want to read a heightmap
for a terrain renderer.
\param filename Name of the file from which the images are created.
\param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
\return The array of created images.
If you no longer need those images, you should call IImage::drop() on each of them.
See IReferenceCounted::drop() for more information. */
virtual core::array<IImage*> createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type = 0) = 0;
//! Creates a software images from a file.
/** No hardware texture will be created for those images. This
method is useful for example if you want to read a heightmap
for a terrain renderer.
\param file File from which the image is created.
\param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
\return The array of created images.
If you no longer need those images, you should call IImage::drop() on each of them.
See IReferenceCounted::drop() for more information. */
virtual core::array<IImage*> createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type = 0) = 0;
//! Creates a software image from a file.
/** No hardware texture will be created for this image. This
method is useful for example if you want to read a heightmap
@ -1130,15 +968,7 @@ namespace video
\return The created image.
If you no longer need the image, you should call IImage::drop().
See IReferenceCounted::drop() for more information. */
IImage* createImageFromFile(const io::path& filename)
{
core::array<IImage*> imageArray = createImagesFromFile(filename);
for (u32 i = 1; i < imageArray.size(); ++i)
imageArray[i]->drop();
return (imageArray.size() > 0) ? imageArray[0] : 0;
}
virtual IImage* createImageFromFile(const io::path& filename) = 0;
//! Creates a software image from a file.
/** No hardware texture will be created for this image. This
@ -1148,15 +978,7 @@ namespace video
\return The created image.
If you no longer need the image, you should call IImage::drop().
See IReferenceCounted::drop() for more information. */
IImage* createImageFromFile(io::IReadFile* file)
{
core::array<IImage*> imageArray = createImagesFromFile(file);
for (u32 i = 1; i < imageArray.size(); ++i)
imageArray[i]->drop();
return (imageArray.size() > 0) ? imageArray[0] : 0;
}
virtual IImage* createImageFromFile(io::IReadFile* file) = 0;
//! Writes the provided image to a file.
/** Requires that there is a suitable image writer registered
@ -1300,7 +1122,7 @@ namespace video
E_MATERIAL_TYPE enum or a value which was returned by
addMaterialRenderer().
\param name: New name of the material renderer. */
virtual void setMaterialRendererName(s32 idx, const c8* name) =0;
virtual void setMaterialRendererName(u32 idx, const c8* name) =0;
//! Swap the material renderers used for certain id's
/** Swap the IMaterialRenderers responsible for rendering specific

View File

@ -6,8 +6,8 @@
#define __IRR_COMPILE_CONFIG_H_INCLUDED__
//! Identifies the IrrlichtMt fork customized for the Minetest engine
#define IRRLICHT_VERSION_MT_REVISION 10
#define IRRLICHT_VERSION_MT "mt10"
#define IRRLICHT_VERSION_MT_REVISION 11
#define IRRLICHT_VERSION_MT "mt11"
//! Irrlicht SDK Version
#define IRRLICHT_VERSION_MAJOR 1
@ -20,454 +20,14 @@
#include <stdio.h> // TODO: Although included elsewhere this is required at least for mingw
//! The defines for different operating system are:
//! _IRR_WINDOWS_ for all irrlicht supported Windows versions
//! _IRR_WINDOWS_API_ for Windows or XBox
//! _IRR_LINUX_PLATFORM_ for Linux (it is defined here if no other os is defined)
//! _IRR_SOLARIS_PLATFORM_ for Solaris
//! _IRR_OSX_PLATFORM_ for Apple systems running OSX
//! _IRR_IOS_PLATFORM_ for Apple devices running iOS
//! _IRR_ANDROID_PLATFORM_ for devices running Android
//! _IRR_POSIX_API_ for Posix compatible systems
//! Note: PLATFORM defines the OS specific layer, API can group several platforms
//! DEVICE is the windowing system used, several PLATFORMs support more than one DEVICE
//! Irrlicht can be compiled with more than one device
//! _IRR_COMPILE_WITH_WINDOWS_DEVICE_ for Windows API based device
//! _IRR_COMPILE_WITH_OSX_DEVICE_ for Cocoa native windowing on OSX
//! _IRR_COMPILE_WITH_X11_DEVICE_ for Linux X11 based device
//! _IRR_COMPILE_WITH_SDL_DEVICE_ for platform independent SDL framework
//! Passing defines to the compiler which have NO in front of the _IRR definename is an alternative
//! way which can be used to disable defines (instead of outcommenting them in this header).
//! So defines can be controlled from Makefiles or Projectfiles which allows building
//! different library versions without having to change the sources.
//! Example: NO_IRR_COMPILE_WITH_X11_ would disable X11
//! Uncomment this line to compile with the SDL device
//#define _IRR_COMPILE_WITH_SDL_DEVICE_
#ifdef NO_IRR_COMPILE_WITH_SDL_DEVICE_
#undef _IRR_COMPILE_WITH_SDL_DEVICE_
#endif
//! WIN32 for Windows32
//! WIN64 for Windows64
// The windows platform and API support SDL and WINDOW device
#if defined(_WIN32) || defined(_WIN64)
#define _IRR_WINDOWS_
#define _IRR_WINDOWS_API_
#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_
#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#endif
#endif
#if defined(__APPLE__)
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#define _IRR_IOS_PLATFORM_
#define _IRR_COMPILE_WITH_IOS_DEVICE_
#define NO_IRR_COMPILE_WITH_OPENGL_
// The application state events and following methods: IrrlichtDevice::isWindowActive, IrrlichtDevice::isWindowFocused,
// IrrlichtDevice::isWindowMinimized works out of box only if you'll use built-in CIrrDelegateiOS,
// so _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ must be enabled in this case. If you need a custom UIApplicationDelegate
// you must disable _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ definition and handle all application events yourself.
#define _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
#else
#define _IRR_OSX_PLATFORM_
#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_
#define _IRR_COMPILE_WITH_OSX_DEVICE_
#endif
#define NO_IRR_COMPILE_WITH_OGLES1_
#define NO_IRR_COMPILE_WITH_OGLES2_
#define NO_IRR_COMPILE_WITH_WEBGL1_
#endif
#endif
#if defined(__EMSCRIPTEN__)
#define _IRR_EMSCRIPTEN_PLATFORM_
#define NO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_
#define NO_IRR_COMPILE_WITH_OPENGL_
#define NO_IRR_COMPILE_WITH_OGLES1_
#define _IRR_COMPILE_WITH_OGLES2_
#define _IRR_COMPILE_WITH_WEBGL1_
#define _IRR_COMPILE_WITH_EGL_MANAGER_
#define _IRR_COMPILE_WITH_SDL_DEVICE_
#define NO_IRR_COMPILE_WITH_X11_DEVICE_
#define _IRR_LINUX_PLATFORM_ // emscripten basically working like a unix
#endif // __EMSCRIPTEN__
#if defined(__ANDROID__)
#define _IRR_ANDROID_PLATFORM_
#define _IRR_COMPILE_WITH_ANDROID_DEVICE_
#define _IRR_COMPILE_ANDROID_ASSET_READER_
#define NO_IRR_COMPILE_WITH_OPENGL_
#endif
#if defined(__SVR4) && defined(__sun)
#define _IRR_SOLARIS_PLATFORM_
#if defined(__sparc)
#define __BIG_ENDIAN__
#endif
#endif
#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_IOS_PLATFORM_) && !defined(_IRR_ANDROID_PLATFORM_) && !defined(_IRR_EMSCRIPTEN_PLATFORM_)
#ifndef _IRR_SOLARIS_PLATFORM_
#define _IRR_LINUX_PLATFORM_
#endif
#define _IRR_POSIX_API_
#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_
#define _IRR_COMPILE_WITH_X11_DEVICE_
#endif
#endif
//! Define _IRR_COMPILE_WITH_JOYSTICK_SUPPORT_ if you want joystick events.
#if !(defined(__FreeBSD__) || defined(__OpenBSD__))
#define _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
#endif
#ifdef NO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_
#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
#endif
//! Maximum number of texture an SMaterial can have, up to 8 are supported by Irrlicht.
#define _IRR_MATERIAL_MAX_TEXTURES_ 4
//! Add a leak-hunter to Irrlicht which helps finding unreleased reference counted objects.
//! NOTE: This is slow and should only be used for debugging
//#define _IRR_COMPILE_WITH_LEAK_HUNTER_
#ifdef NO_IRR_COMPILE_WITH_LEAK_HUNTER_
#undef _IRR_COMPILE_WITH_LEAK_HUNTER_
#endif
//! Enable profiling information in the engine
/** NOTE: The profiler itself always exists and can be used by applications.
This define is about the engine creating profile data
while it runs and enabling it will slow down the engine. */
//#define _IRR_COMPILE_WITH_PROFILING_
#ifdef NO_IRR_COMPILE_WITH_PROFILING_
#undef _IRR_COMPILE_WITH_PROFILING_
#endif
//! Define _IRR_COMPILE_WITH_DIRECT3D_9_ to compile the Irrlicht engine with DIRECT3D9.
/** If you only want to use the software device or opengl you can disable those defines.
This switch is mostly disabled because people do not get the g++ compiler compile
directX header files, and directX is only available on Windows platforms. If you
are using Dev-Cpp, and want to compile this using a DX dev pack, you can define
_IRR_COMPILE_WITH_DX9_DEV_PACK_. So you simply need to add something like this
to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK
and this to the linker settings: -ld3dx9
*/
#if defined(_IRR_WINDOWS_API_) && defined(IRR_COMPILE_WITH_DX9_DEV_PACK)
//! Define _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ if you want to use DirectInput for joystick handling.
/** This only applies to Windows devices, currently only supported under Win32 device.
If not defined, Windows Multimedia library is used, which offers also broad support for joystick devices. */
#define _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_
#ifdef NO_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_
#undef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_
#endif
#endif
//! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL.
/** If you do not wish the engine to be compiled with OpenGL, comment this
define out. */
#define _IRR_COMPILE_WITH_OPENGL_
#ifdef NO_IRR_COMPILE_WITH_OPENGL_
#undef _IRR_COMPILE_WITH_OPENGL_
#endif
//! Define required options for OpenGL drivers.
#if defined(_IRR_COMPILE_WITH_OPENGL_)
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
#define _IRR_OPENGL_USE_EXTPOINTER_
#define _IRR_COMPILE_WITH_WGL_MANAGER_
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
#define _IRR_OPENGL_USE_EXTPOINTER_
#define _IRR_COMPILE_WITH_GLX_MANAGER_
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
#define _IRR_COMPILE_WITH_NSOGL_MANAGER_
#elif defined(_IRR_SOLARIS_PLATFORM_)
#define _IRR_COMPILE_WITH_GLX_MANAGER_
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
#define _IRR_OPENGL_USE_EXTPOINTER_
#endif
#endif
//! Define _IRR_COMPILE_WITH_OGLES1_ to compile the Irrlicht engine with OpenGL ES 1.1.
/** If you do not wish the engine to be compiled with OpenGL ES 1.1, comment this
define out.
Depending on platform you may have to enable _IRR_OGLES1_USE_KHRONOS_API_HEADERS_ as well when using it.
*/
#if defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_IOS_PLATFORM_)
#define _IRR_COMPILE_WITH_OGLES1_
#endif
#ifdef NO_IRR_COMPILE_WITH_OGLES1_
#undef _IRR_COMPILE_WITH_OGLES1_
#endif
#ifdef _IRR_COMPILE_WITH_OGLES1_
//! Define _IRR_OGLES1_USE_KHRONOS_API_HEADERS_ to use the OpenGL ES headers from the Debian Khronos-api package
//#define _IRR_OGLES1_USE_KHRONOS_API_HEADERS_
#endif
//! Define required options for OpenGL ES 1.1 drivers.
#if defined(_IRR_COMPILE_WITH_OGLES1_)
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
#define _IRR_OGLES1_USE_EXTPOINTER_
#ifndef _IRR_COMPILE_WITH_EGL_MANAGER_
#define _IRR_COMPILE_WITH_EGL_MANAGER_
#endif
#elif defined(_IRR_COMPILE_WITH_IOS_DEVICE_)
#ifndef _IRR_COMPILE_WITH_EAGL_MANAGER_
#define _IRR_COMPILE_WITH_EAGL_MANAGER_
#endif
#endif
#endif
//! Define _IRR_COMPILE_WITH_OGLES2_ to compile the Irrlicht engine with OpenGL ES 2.0.
/** If you do not wish the engine to be compiled with OpenGL ES 2.0, comment this
define out. */
#if defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_IOS_PLATFORM_)
#define _IRR_COMPILE_WITH_OGLES2_
#else
//#define _IRR_COMPILE_WITH_OGLES2_
#endif
#ifdef NO_IRR_COMPILE_WITH_OGLES2_
#undef _IRR_COMPILE_WITH_OGLES2_
#endif
//! Define _IRR_COMPILE_WITH_WEBGL1_ to compile Irrlicht engine with a WebGL friendly
//! subset of the OpenGL ES 2.0 driver.
//#define _IRR_COMPILE_WITH_WEBGL1_
#ifdef NO_IRR_COMPILE_WITH_WEBGL1_
#undef _IRR_COMPILE_WITH_WEBGL1_
#endif
#ifdef _IRR_COMPILE_WITH_WEBGL1_
#define _IRR_COMPILE_WITH_OGLES2_ // it's a subset of OGL ES2, so always needed when using WebGL
#endif
//! Define required options for OpenGL ES 2.0 drivers.
#if defined(_IRR_COMPILE_WITH_OGLES2_)
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(__EMSCRIPTEN__)
#define _IRR_OGLES2_USE_EXTPOINTER_
#ifndef _IRR_COMPILE_WITH_EGL_MANAGER_
#define _IRR_COMPILE_WITH_EGL_MANAGER_
#endif
#elif defined(_IRR_COMPILE_WITH_IOS_DEVICE_)
#ifndef _IRR_COMPILE_WITH_EAGL_MANAGER_
#define _IRR_COMPILE_WITH_EAGL_MANAGER_
#endif
#endif
#endif
//! Define _IRR_COMPILE_WITH_X11_ to compile the Irrlicht engine with X11 support.
/** If you do not wish the engine to be compiled with X11, comment this
define out. */
// Only used in LinuxDevice.
#define _IRR_COMPILE_WITH_X11_
#ifdef NO_IRR_COMPILE_WITH_X11_
#undef _IRR_COMPILE_WITH_X11_
#endif
#if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_)
//! XInput2 (library called Xi) is currently only used to support touch-input.
#define _IRR_LINUX_X11_XINPUT2_
#ifdef NO_IRR_LINUX_X11_XINPUT2_
#undef _IRR_LINUX_X11_XINPUT2_
#endif
//! X11 has by default only monochrome cursors, but using the Xcursor library we can also get color cursor support.
//! If you have the need for custom color cursors on X11 then enable this and make sure you also link
//! to the Xcursor library in your Makefile/Projectfile.
//#define _IRR_LINUX_XCURSOR_
#ifdef NO_IRR_LINUX_XCURSOR_
#undef _IRR_LINUX_XCURSOR_
#endif
#endif
//! Define _IRR_COMPILE_WITH_GUI_ to compile the engine with the built-in GUI
/** Disable this if you are using an external library to draw the GUI. If you disable this then
you will not be able to use anything provided by the GUI Environment, including loading fonts. */
#define _IRR_COMPILE_WITH_GUI_
#ifdef NO_IRR_COMPILE_WITH_GUI_
#undef _IRR_COMPILE_WITH_GUI_
#endif
//! Define _IRR_COMPILE_WITH_LIBJPEG_ to enable compiling the engine using libjpeg.
/** This enables the engine to read jpeg images. If you comment this out,
the engine will no longer read .jpeg images. */
#define _IRR_COMPILE_WITH_LIBJPEG_
#ifdef NO_IRR_COMPILE_WITH_LIBJPEG_
#undef _IRR_COMPILE_WITH_LIBJPEG_
#endif
//! Define _IRR_COMPILE_WITH_LIBPNG_ to enable compiling the engine using libpng.
/** This enables the engine to read png images. If you comment this out,
the engine will no longer read .png images. */
#define _IRR_COMPILE_WITH_LIBPNG_
#ifdef NO_IRR_COMPILE_WITH_LIBPNG_
#undef _IRR_COMPILE_WITH_LIBPNG_
#endif
//! Uncomment the following line if you want to ignore the deprecated warnings
//#define IGNORE_DEPRECATED_WARNING
//! Define _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ to support BillboardSceneNodes
#define _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_
#ifdef NO_IRR_COMPILE_WITH_BILLBOARD_SCENENODE_
#undef _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_
#endif
//! Define _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ if you want to use bone based
/** animated meshes. If you compile without this, you will be unable to load
B3D, MS3D or X meshes */
#define _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
#ifdef NO_IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
#undef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
#endif
#ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
//! Define _IRR_COMPILE_WITH_B3D_LOADER_ if you want to use Blitz3D files
#define _IRR_COMPILE_WITH_B3D_LOADER_
#ifdef NO_IRR_COMPILE_WITH_B3D_LOADER_
#undef _IRR_COMPILE_WITH_B3D_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_X_LOADER_ if you want to use Microsoft X files
#define _IRR_COMPILE_WITH_X_LOADER_
#ifdef NO_IRR_COMPILE_WITH_X_LOADER_
#undef _IRR_COMPILE_WITH_X_LOADER_
#endif
#endif // _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
//! Define _IRR_COMPILE_WITH_OBJ_LOADER_ if you want to load Wavefront OBJ files
#define _IRR_COMPILE_WITH_OBJ_LOADER_
#ifdef NO_IRR_COMPILE_WITH_OBJ_LOADER_
#undef _IRR_COMPILE_WITH_OBJ_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_BMP_LOADER_ if you want to load .bmp files
//! Disabling this loader will also disable the built-in font
#define _IRR_COMPILE_WITH_BMP_LOADER_
#ifdef NO_IRR_COMPILE_WITH_BMP_LOADER_
#undef _IRR_COMPILE_WITH_BMP_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_JPG_LOADER_ if you want to load .jpg files
#define _IRR_COMPILE_WITH_JPG_LOADER_
#ifdef NO_IRR_COMPILE_WITH_JPG_LOADER_
#undef _IRR_COMPILE_WITH_JPG_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_PNG_LOADER_ if you want to load .png files
#define _IRR_COMPILE_WITH_PNG_LOADER_
#ifdef NO_IRR_COMPILE_WITH_PNG_LOADER_
#undef _IRR_COMPILE_WITH_PNG_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_TGA_LOADER_ if you want to load .tga files
#define _IRR_COMPILE_WITH_TGA_LOADER_
#ifdef NO_IRR_COMPILE_WITH_TGA_LOADER_
#undef _IRR_COMPILE_WITH_TGA_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_JPG_WRITER_ if you want to write .jpg files
#define _IRR_COMPILE_WITH_JPG_WRITER_
#ifdef NO_IRR_COMPILE_WITH_JPG_WRITER_
#undef _IRR_COMPILE_WITH_JPG_WRITER_
#endif
//! Define _IRR_COMPILE_WITH_PNG_WRITER_ if you want to write .png files
#define _IRR_COMPILE_WITH_PNG_WRITER_
#ifdef NO_IRR_COMPILE_WITH_PNG_WRITER_
#undef _IRR_COMPILE_WITH_PNG_WRITER_
#endif
//! Define __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ if you want to open ZIP and GZIP archives
/** ZIP reading has several more options below to configure. */
#define __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_
#ifdef NO__IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_
#undef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_
#endif
#ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_
//! Define _IRR_COMPILE_WITH_ZLIB_ to enable compiling the engine using zlib.
/** This enables the engine to read from compressed .zip archives. If you
disable this feature, the engine can still read archives, but only uncompressed
ones. */
#define _IRR_COMPILE_WITH_ZLIB_
#ifdef NO_IRR_COMPILE_WITH_ZLIB_
#undef _IRR_COMPILE_WITH_ZLIB_
#endif
#endif
//! Define __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ if you want to mount folders as archives
#define __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#ifdef NO__IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#undef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#endif
// Some cleanup and standard stuff
#ifdef _IRR_WINDOWS_API_
// To build Irrlicht as a static library, you must define _IRR_STATIC_LIB_ in both the
// Irrlicht build, *and* in the user application, before #including <irrlicht.h>
#ifndef _IRR_STATIC_LIB_
#ifdef IRRLICHT_EXPORTS
#define IRRLICHT_API __declspec(dllexport)
#else
#define IRRLICHT_API __declspec(dllimport)
#endif // IRRLICHT_EXPORT
#else
#define IRRLICHT_API
#endif // _IRR_STATIC_LIB_
// Declare the calling convention.
#if defined(_STDCALL_SUPPORTED)
#ifdef _WIN32
#define IRRCALLCONV __stdcall
#else
#define IRRCALLCONV __cdecl
#endif // STDCALL_SUPPORTED
#else // _IRR_WINDOWS_API_
// Force symbol export in shared libraries built with gcc.
#if defined(__GNUC__) && !defined(_IRR_STATIC_LIB_) && defined(IRRLICHT_EXPORTS)
#define IRRLICHT_API __attribute__ ((visibility("default")))
#else
#define IRRLICHT_API
#endif
#define IRRCALLCONV
#endif // _IRR_WINDOWS_API_
#if defined(_IRR_SOLARIS_PLATFORM_)
#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
#endif
//! Define __IRR_HAS_S64 if the irr::s64 type should be enable (needs long long, available on most platforms, but not part of ISO C++ 98)
#define __IRR_HAS_S64
#ifdef NO__IRR_HAS_S64
#undef __IRR_HAS_S64
#endif
#ifndef __has_feature
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
#ifdef _DEBUG
//! A few attributes are written in CSceneManager when _IRR_SCENEMANAGER_DEBUG is enabled
// NOTE: Those attributes were used always until 1.8.0 and became a global define for 1.8.1
// which is only enabled in debug because it had a large (sometimes >5%) impact on speed.
// A better solution in the long run is to break the interface and remove _all_ attribute
// access in functions like CSceneManager::drawAll and instead put that information in some
// own struct/class or in CSceneManager.
// See http://irrlicht.sourceforge.net/forum/viewtopic.php?f=2&t=48211 for the discussion.
#define _IRR_SCENEMANAGER_DEBUG
#ifdef NO_IRR_SCENEMANAGER_DEBUG
#undef _IRR_SCENEMANAGER_DEBUG
#endif
#ifndef IRRLICHT_API
#define IRRLICHT_API
#endif
#endif // __IRR_COMPILE_CONFIG_H_INCLUDED__

View File

@ -14,6 +14,7 @@
#include "ICursorControl.h"
#include "ITimer.h"
#include "IOSOperator.h"
#include "IrrCompileConfig.h"
namespace irr
{
@ -34,6 +35,7 @@ namespace irr
namespace video {
class IContextManager;
extern "C" IRRLICHT_API bool IRRCALLCONV isDriverSupported(E_DRIVER_TYPE driver);
} // end namespace video
//! The Irrlicht device. You can create it with createDevice() or createDeviceEx().
@ -130,6 +132,11 @@ namespace irr
/** \param text: New text of the window caption. */
virtual void setWindowCaption(const wchar_t* text) = 0;
//! Sets the window icon.
/** \param img The icon texture.
\return False if no icon was set. */
virtual bool setWindowIcon(const video::IImage *img) = 0;
//! Returns if the window is active.
/** If the window is inactive,
nothing needs to be drawn. So if you don't want to draw anything
@ -235,8 +242,8 @@ namespace irr
as this would consume joystick info that 3rd party libraries might rely on. Call this method to
activate joystick support in Irrlicht and to receive irr::SJoystickEvent events.
\param joystickInfo On return, this will contain an array of each joystick that was found and activated.
\return true if joysticks are supported on this device and _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
is defined, false if joysticks are not supported or support is compiled out.
\return true if joysticks are supported on this device, false if joysticks are not
supported or support is compiled out.
*/
virtual bool activateJoysticks(core::array<SJoystickInfo>& joystickInfo) =0;
@ -305,42 +312,16 @@ namespace irr
used. */
virtual E_DEVICE_TYPE getType() const = 0;
//! Get the display density in dots per inch.
//! Returns 0.0f on failure.
virtual float getDisplayDensity() const = 0;
//! Check if a driver type is supported by the engine.
/** Even if true is returned the driver may not be available
for a configuration requested when creating the device. */
static bool isDriverSupported(video::E_DRIVER_TYPE driver)
{
switch (driver)
{
case video::EDT_NULL:
return true;
case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_
return true;
#else
return false;
#endif
case video::EDT_OGLES1:
#ifdef _IRR_COMPILE_WITH_OGLES1_
return true;
#else
return false;
#endif
case video::EDT_OGLES2:
#ifdef _IRR_COMPILE_WITH_OGLES2_
return true;
#else
return false;
#endif
case video::EDT_WEBGL1:
#ifdef _IRR_COMPILE_WITH_WEBGL1_
return true;
#else
return false;
#endif
default:
return false;
}
return video::isDriverSupported(driver);
}
};

View File

@ -44,7 +44,7 @@ const char* const sBuiltInVertexTypeNames[] =
struct S3DVertex
{
//! default constructor
S3DVertex() {}
S3DVertex() : Color(0xffffffff) {}
//! constructor
S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
@ -142,7 +142,7 @@ struct S3DVertex2TCoords : public S3DVertex
: S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords) {}
//! constructor from S3DVertex
S3DVertex2TCoords(S3DVertex& o) : S3DVertex(o) {}
S3DVertex2TCoords(const S3DVertex& o) : S3DVertex(o) {}
//! Second set of texture coordinates
core::vector2d<f32> TCoords2;
@ -150,21 +150,21 @@ struct S3DVertex2TCoords : public S3DVertex
//! Equality operator
bool operator==(const S3DVertex2TCoords& other) const
{
return ((static_cast<S3DVertex>(*this)==other) &&
return ((static_cast<S3DVertex>(*this)==static_cast<const S3DVertex&>(other)) &&
(TCoords2 == other.TCoords2));
}
//! Inequality operator
bool operator!=(const S3DVertex2TCoords& other) const
{
return ((static_cast<S3DVertex>(*this)!=other) ||
return ((static_cast<S3DVertex>(*this)!=static_cast<const S3DVertex&>(other)) ||
(TCoords2 != other.TCoords2));
}
bool operator<(const S3DVertex2TCoords& other) const
{
return ((static_cast<S3DVertex>(*this) < other) ||
((static_cast<S3DVertex>(*this) == other) && (TCoords2 < other.TCoords2)));
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex&>(other)) && (TCoords2 < other.TCoords2)));
}
static E_VERTEX_TYPE getType()
@ -214,6 +214,9 @@ struct S3DVertexTangents : public S3DVertex
const core::vector3df& binormal=core::vector3df())
: S3DVertex(pos, normal, c, tcoords), Tangent(tangent), Binormal(binormal) { }
//! constructor from S3DVertex
S3DVertexTangents(const S3DVertex& o) : S3DVertex(o) {}
//! Tangent vector along the x-axis of the texture
core::vector3df Tangent;
@ -222,14 +225,14 @@ struct S3DVertexTangents : public S3DVertex
bool operator==(const S3DVertexTangents& other) const
{
return ((static_cast<S3DVertex>(*this)==other) &&
return ((static_cast<S3DVertex>(*this)==static_cast<const S3DVertex&>(other)) &&
(Tangent == other.Tangent) &&
(Binormal == other.Binormal));
}
bool operator!=(const S3DVertexTangents& other) const
{
return ((static_cast<S3DVertex>(*this)!=other) ||
return ((static_cast<S3DVertex>(*this)!=static_cast<const S3DVertex&>(other)) ||
(Tangent != other.Tangent) ||
(Binormal != other.Binormal));
}
@ -237,8 +240,8 @@ struct S3DVertexTangents : public S3DVertex
bool operator<(const S3DVertexTangents& other) const
{
return ((static_cast<S3DVertex>(*this) < other) ||
((static_cast<S3DVertex>(*this) == other) && (Tangent < other.Tangent)) ||
((static_cast<S3DVertex>(*this) == other) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex&>(other)) && (Tangent < other.Tangent)) ||
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex&>(other)) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
}
static E_VERTEX_TYPE getType()

View File

@ -79,21 +79,6 @@ struct SExposedVideoData
void* Window;
};
struct SOpenGLiOS
{
//! The EAGLContext object.
void* Context;
//! The subview UIView object where the drawing happens.
void* View;
//! The UIViewController object.
void* ViewController;
//! The UIWindow object.
void* Window;
};
struct SOGLESAndroid
{
//! The ANativeWindow object.
@ -107,7 +92,6 @@ struct SExposedVideoData
SOpenGLLinux OpenGLLinux;
SOpenGLOSX OpenGLOSX;
SOpenGLFB OpenGLFB;
SOpenGLiOS OpenGLiOS;
SOGLESAndroid OGLESAndroid;
};
};

View File

@ -11,7 +11,7 @@
#include "ILogger.h"
#include "position2d.h"
#include "path.h"
#include "IrrCompileConfig.h"
#include "IrrCompileConfig.h" // for IRRLICHT_SDK_VERSION
namespace irr
{
@ -24,7 +24,7 @@ namespace irr
//! Constructs a SIrrlichtCreationParameters structure with default values.
SIrrlichtCreationParameters() :
DeviceType(EIDT_BEST),
DriverType(video::EDT_BURNINGSVIDEO),
DriverType(video::EDT_OPENGL),
WindowSize(core::dimension2d<u32>(800, 600)),
WindowPosition(core::position2di(-1,-1)),
Bits(32),
@ -53,7 +53,7 @@ namespace irr
UsePerformanceTimer(true),
SDK_version_do_not_use(IRRLICHT_SDK_VERSION),
PrivateData(0),
#if defined(_IRR_COMPILE_WITH_IOS_DEVICE_) || defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_EMSCRIPTEN_PLATFORM_)
#ifdef IRR_MOBILE_PATHS
OGLES2ShaderPath("media/Shaders/")
#else
OGLES2ShaderPath("../../media/Shaders/")
@ -235,7 +235,6 @@ namespace irr
/** If this is set to a value other than 0, the Irrlicht Engine
will be created in an already existing window.
For Windows, set this to the HWND of the window you want.
For iOS, assign UIView to this variable.
The windowSize and FullScreen options will be ignored when using
the WindowId parameter. Default this is set to 0.
To make Irrlicht run inside the custom window, you still will

View File

@ -12,6 +12,7 @@
#include "EMaterialTypes.h"
#include "EMaterialFlags.h"
#include "SMaterialLayer.h"
#include "IrrCompileConfig.h" // for IRRLICHT_API
namespace irr
{
@ -280,7 +281,7 @@ namespace video
/** SMaterial might ignore some textures in most function, like assignment and comparison,
when SIrrlichtCreationParameters::MaxTextureUnits is set to a lower number.
*/
const u32 MATERIAL_MAX_TEXTURES = _IRR_MATERIAL_MAX_TEXTURES_;
const u32 MATERIAL_MAX_TEXTURES = 4;
//! Struct for holding parameters for a material renderer
// Note for implementors: Serialization is in CNullDriver

View File

@ -5,7 +5,6 @@
#ifndef __EXAMPLE_HELPER_H_INCLUDED__
#define __EXAMPLE_HELPER_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "path.h"
namespace irr
@ -13,7 +12,7 @@ namespace irr
static io::path getExampleMediaPath()
{
#if defined (_IRR_IOS_PLATFORM_) || defined (_IRR_ANDROID_PLATFORM_) || defined (_IRR_OSX_PLATFORM_) || defined (_IRR_EMSCRIPTEN_PLATFORM_)
#ifdef IRR_MOBILE_PATHS
return io::path("media/");
#else
return io::path("../../media/");

View File

@ -5,7 +5,6 @@
#ifndef __IRR_MATH_H_INCLUDED__
#define __IRR_MATH_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "irrTypes.h"
#include <math.h>
#include <float.h>
@ -21,9 +20,7 @@ namespace core
const s32 ROUNDING_ERROR_S32 = 0;
#ifdef __IRR_HAS_S64
const s64 ROUNDING_ERROR_S64 = 0;
#endif
const f32 ROUNDING_ERROR_f32 = 0.000001f;
const f64 ROUNDING_ERROR_f64 = 0.00000001;
@ -186,7 +183,6 @@ namespace core
return ROUNDING_ERROR_S32;
}
#ifdef __IRR_HAS_S64
template <>
inline s64 roundingError()
{
@ -198,7 +194,6 @@ namespace core
{
return ROUNDING_ERROR_S64;
}
#endif
template <class T>
inline T relativeErrorFactor()
@ -310,13 +305,11 @@ namespace core
return a <= tolerance;
}
#ifdef __IRR_HAS_S64
//! returns if a equals zero, taking rounding errors into account
inline bool iszero(const s64 a, const s64 tolerance = 0)
{
return abs_(a) <= tolerance;
}
#endif
inline s32 s32_min(s32 a, s32 b)
{
@ -406,13 +399,11 @@ namespace core
return static_cast<s32>(squareroot(static_cast<f32>(f)));
}
#ifdef __IRR_HAS_S64
// calculate: sqrt ( x )
REALINLINE s64 squareroot(const s64 f)
{
return static_cast<s64>(squareroot(static_cast<f64>(f)));
}
#endif
// calculate: 1 / sqrt ( x )
REALINLINE f64 reciprocal_squareroot(const f64 x)

View File

@ -5,7 +5,6 @@
#ifndef __IRR_TYPES_H_INCLUDED__
#define __IRR_TYPES_H_INCLUDED__
#include "IrrCompileConfig.h"
#include <stdint.h>
namespace irr
@ -38,13 +37,11 @@ typedef uint32_t u32;
typedef int32_t s32;
#ifdef __IRR_HAS_S64
//! 64 bit unsigned variable.
typedef uint64_t u64;
//! 64 bit signed variable.
typedef int64_t s64;
#endif // __IRR_HAS_S64

View File

@ -174,7 +174,7 @@ inline core::array<u8> getUnicodeBOM(EUTF_ENCODE mode)
COPY_ARRAY(BOM_ENCODE_UTF8, BOM_ENCODE_UTF8_LEN);
break;
case EUTFE_UTF16:
#ifdef __BIG_ENDIAN__
#if __BYTE_ORDER == __BIG_ENDIAN
COPY_ARRAY(BOM_ENCODE_UTF16_BE, BOM_ENCODE_UTF16_LEN);
#else
COPY_ARRAY(BOM_ENCODE_UTF16_LE, BOM_ENCODE_UTF16_LEN);
@ -187,7 +187,7 @@ inline core::array<u8> getUnicodeBOM(EUTF_ENCODE mode)
COPY_ARRAY(BOM_ENCODE_UTF16_LE, BOM_ENCODE_UTF16_LEN);
break;
case EUTFE_UTF32:
#ifdef __BIG_ENDIAN__
#if __BYTE_ORDER == __BIG_ENDIAN
COPY_ARRAY(BOM_ENCODE_UTF32_BE, BOM_ENCODE_UTF32_LEN);
#else
COPY_ARRAY(BOM_ENCODE_UTF32_LE, BOM_ENCODE_UTF32_LEN);
@ -1323,7 +1323,7 @@ public:
// Determine if the string is long enough for a BOM.
u32 len = 0;
const uchar8_t* p = other;
const u8* p = reinterpret_cast<const u8*>(other);
do
{
++len;
@ -1338,10 +1338,10 @@ public:
}
// If a BOM was found, don't include it in the string.
const uchar8_t* c2 = other;
const u8* c2 = reinterpret_cast<const u8*>(other);
if (c_bom != unicode::EUTFE_NONE)
{
c2 = other + unicode::BOM_UTF8_LEN;
c2 += unicode::BOM_UTF8_LEN;
length -= unicode::BOM_UTF8_LEN;
}

View File

@ -29,7 +29,6 @@
#ifndef __IRRLICHT_H_INCLUDED__
#define __IRRLICHT_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "aabbox3d.h"
#include "CIndexBuffer.h"
#include "CMeshBuffer.h"
@ -135,6 +134,7 @@
#include "triangle3d.h"
#include "vector2d.h"
#include "vector3d.h"
#include "IrrCompileConfig.h" // for IRRLICHT_API and IRRCALLCONV
/*! \mainpage Irrlicht Engine 1.9 API documentation
*
@ -271,7 +271,7 @@ namespace irr
device could not be created.
*/
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(
video::E_DRIVER_TYPE driverType = video::EDT_SOFTWARE,
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL,
// parentheses are necessary for some compilers
const core::dimension2d<u32>& windowSize = (core::dimension2d<u32>(640,480)),
u32 bits = 32,

View File

@ -12,6 +12,7 @@
#include "aabbox3d.h"
#include "rect.h"
#include "irrString.h"
#include "IrrCompileConfig.h" // for IRRLICHT_API
// enable this to keep track of changes to the matrix
// and make simpler identity check for seldom changing matrices
@ -142,7 +143,7 @@ namespace core
//! Set this matrix to the product of two matrices
/** Calculate b*a, no optimization used,
use it if you know you never have a identity matrix */
use it if you know you never have an identity matrix */
CMatrix4<T>& setbyproduct_nocheck(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b );
//! Multiply by another matrix.
@ -150,7 +151,8 @@ namespace core
CMatrix4<T> operator*(const CMatrix4<T>& other) const;
//! Multiply by another matrix.
/** Calculate and return other*this */
/** Like calling: (*this) = (*this) * other
*/
CMatrix4<T>& operator*=(const CMatrix4<T>& other);
//! Multiply by scalar.
@ -186,14 +188,25 @@ namespace core
//! Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
CMatrix4<T>& setRotationDegrees( const vector3d<T>& rotation );
//! Get the rotation, as set by setRotation() when you already know the scale.
/** If you already know the scale then this function is faster than the other getRotationDegrees overload.
NOTE: You will have the same end-rotation as used in setRotation, but it might not use the same axis values.
//! Get the rotation, as set by setRotation() when you already know the scale used to create the matrix
/** NOTE: The scale needs to be the correct one used to create this matrix.
You can _not_ use the result of getScale(), but have to save your scale
variable in another place (like ISceneNode does).
NOTE: No scale value can be 0 or the result is undefined.
NOTE: It does not necessarily return the *same* Euler angles as those set by setRotationDegrees(),
but the rotation will be equivalent, i.e. will have the same result when used to rotate a vector or node.
NOTE: It will (usually) give wrong results when further transformations have been added in the matrix (like shear).
WARNING: There have been troubles with this function over the years and we may still have missed some corner cases.
It's generally safer to keep the rotation and scale you used to create the matrix around and work with those.
*/
core::vector3d<T> getRotationDegrees(const vector3d<T>& scale) const;
//! Returns the rotation, as set by setRotation().
/** NOTE: You will have the same end-rotation as used in setRotation, but it might not use the same axis values.
NOTE: This only works correct if no other matrix operations have been done on the inner 3x3 matrix besides
setting rotation (so no scale/shear). Thought it (probably) works as long as scale doesn't flip handedness.
NOTE: It does not necessarily return the *same* Euler angles as those set by setRotationDegrees(),
but the rotation will be equivalent, i.e. will have the same result when used to rotate a vector or node.
*/
core::vector3d<T> getRotationDegrees() const;
@ -827,11 +840,9 @@ namespace core
//! Returns the absolute values of the scales of the matrix.
/**
Note that this returns the absolute (positive) values unless only scale is set.
Unfortunately it does not appear to be possible to extract any original negative
values. The best that we could do would be to arbitrarily make one scale
negative if one or three of them were negative.
FIXME - return the original values.
Note: You only get back original values if the matrix only set the scale.
Otherwise the result is a scale you can use to normalize the matrix axes,
but it's usually no longer what you did set with setScale.
*/
template <class T>
inline vector3d<T> CMatrix4<T>::getScale() const
@ -894,33 +905,16 @@ namespace core
}
//! Returns a rotation that is equivalent to that set by setRotationDegrees().
/** This code was sent in by Chev. Note that it does not necessarily return
the *same* Euler angles as those set by setRotationDegrees(), but the rotation will
be equivalent, i.e. will have the same result when used to rotate a vector or node.
This code was originally written by by Chev.
//! Returns a rotation which (mostly) works in combination with the given scale
/**
This code was originally written by by Chev (assuming no scaling back then,
we can be blamed for all problems added by regarding scale)
*/
template <class T>
inline core::vector3d<T> CMatrix4<T>::getRotationDegrees(const vector3d<T>& scale_) const
{
const CMatrix4<T> &mat = *this;
core::vector3d<T> scale(scale_);
// we need to check for negative scale on to axes, which would bring up wrong results
if (scale.Y<0 && scale.Z<0)
{
scale.Y =-scale.Y;
scale.Z =-scale.Z;
}
else if (scale.X<0 && scale.Z<0)
{
scale.X =-scale.X;
scale.Z =-scale.Z;
}
else if (scale.X<0 && scale.Y<0)
{
scale.X =-scale.X;
scale.Y =-scale.Y;
}
const core::vector3d<f64> scale(core::iszero(scale_.X) ? FLT_MAX : scale_.X , core::iszero(scale_.Y) ? FLT_MAX : scale_.Y, core::iszero(scale_.Z) ? FLT_MAX : scale_.Z);
const core::vector3d<f64> invScale(core::reciprocal(scale.X),core::reciprocal(scale.Y),core::reciprocal(scale.Z));
f64 Y = -asin(core::clamp(mat[2]*invScale.X, -1.0, 1.0));
@ -929,7 +923,7 @@ namespace core
f64 rotx, roty, X, Z;
if (!core::iszero(C))
if (!core::iszero((T)C))
{
const f64 invC = core::reciprocal(C);
rotx = mat[10] * invC * invScale.Z;
@ -956,14 +950,37 @@ namespace core
}
//! Returns a rotation that is equivalent to that set by setRotationDegrees().
/** This code was sent in by Chev. Note that it does not necessarily return
the *same* Euler angles as those set by setRotationDegrees(), but the rotation will
be equivalent, i.e. will have the same result when used to rotate a vector or node.
This code was originally written by by Chev. */
template <class T>
inline core::vector3d<T> CMatrix4<T>::getRotationDegrees() const
{
return getRotationDegrees(getScale());
// Note: Using getScale() here make it look like it could do matrix decomposition.
// It can't! It works (or should work) as long as rotation doesn't flip the handedness
// aka scale swapping 1 or 3 axes. (I think we could catch that as well by comparing
// crossproduct of first 2 axes to direction of third axis, but TODO)
// And maybe it should also offer the solution for the simple calculation
// without regarding scaling as Irrlicht did before 1.7
core::vector3d<T> scale(getScale());
// We assume the matrix uses rotations instead of negative scaling 2 axes.
// Otherwise it fails even for some simple cases, like rotating around
// 2 axes by 180<38> which getScale thinks is a negative scaling.
if (scale.Y<0 && scale.Z<0)
{
scale.Y =-scale.Y;
scale.Z =-scale.Z;
}
else if (scale.X<0 && scale.Z<0)
{
scale.X =-scale.X;
scale.Z =-scale.Z;
}
else if (scale.X<0 && scale.Y<0)
{
scale.X =-scale.X;
scale.Y =-scale.Y;
}
return getRotationDegrees(scale);
}
@ -1155,10 +1172,10 @@ namespace core
template <class T>
inline void CMatrix4<T>::rotateVect( vector3df& vect ) const
{
vector3df tmp = vect;
vect.X = tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8];
vect.Y = tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9];
vect.Z = tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10];
vector3d<T> tmp(static_cast<T>(vect.X), static_cast<T>(vect.Y), static_cast<T>(vect.Z));
vect.X = static_cast<f32>(tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8]);
vect.Y = static_cast<f32>(tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9]);
vect.Z = static_cast<f32>(tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10]);
}
//! An alternate transform vector method, writing into a second vector
@ -1182,24 +1199,24 @@ namespace core
template <class T>
inline void CMatrix4<T>::inverseRotateVect( vector3df& vect ) const
{
vector3df tmp = vect;
vect.X = tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2];
vect.Y = tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6];
vect.Z = tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10];
vector3d<T> tmp(static_cast<T>(vect.X), static_cast<T>(vect.Y), static_cast<T>(vect.Z));
vect.X = static_cast<f32>(tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2]);
vect.Y = static_cast<f32>(tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6]);
vect.Z = static_cast<f32>(tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10]);
}
template <class T>
inline void CMatrix4<T>::transformVect( vector3df& vect) const
{
f32 vector[3];
T vector[3];
vector[0] = vect.X*M[0] + vect.Y*M[4] + vect.Z*M[8] + M[12];
vector[1] = vect.X*M[1] + vect.Y*M[5] + vect.Z*M[9] + M[13];
vector[2] = vect.X*M[2] + vect.Y*M[6] + vect.Z*M[10] + M[14];
vect.X = vector[0];
vect.Y = vector[1];
vect.Z = vector[2];
vect.X = static_cast<f32>(vector[0]);
vect.Y = static_cast<f32>(vector[1]);
vect.Z = static_cast<f32>(vector[2]);
}
template <class T>

View File

@ -5,7 +5,7 @@
#include <string>
#include <unordered_set>
#include "IrrCompileConfig.h"
#include "IrrCompileConfig.h" // for IRRLICHT_API
#include "irrTypes.h"
#include "IContextManager.h"
#include <KHR/khrplatform.h>

View File

@ -0,0 +1,75 @@
#version 100
precision mediump float;
/* Uniforms */
uniform int uTextureUsage0;
uniform sampler2D uTextureUnit0;
uniform int uBlendType;
uniform int uFogEnable;
uniform int uFogType;
uniform vec4 uFogColor;
uniform float uFogStart;
uniform float uFogEnd;
uniform float uFogDensity;
/* Varyings */
varying vec2 vTextureCoord0;
varying vec4 vVertexColor;
varying float vFogCoord;
float computeFog()
{
const float LOG2 = 1.442695;
float FogFactor = 0.0;
if (uFogType == 0) // Exp
{
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
}
else if (uFogType == 1) // Linear
{
float Scale = 1.0 / (uFogEnd - uFogStart);
FogFactor = (uFogEnd - vFogCoord) * Scale;
}
else if (uFogType == 2) // Exp2
{
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
}
FogFactor = clamp(FogFactor, 0.0, 1.0);
return FogFactor;
}
void main()
{
vec4 Color0 = vVertexColor;
vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
if (bool(uTextureUsage0))
Color1 = texture2D(uTextureUnit0, vTextureCoord0);
vec4 FinalColor = Color0 * Color1;
if (uBlendType == 1)
{
FinalColor.w = Color0.w;
}
else if (uBlendType == 2)
{
FinalColor.w = Color1.w;
}
if (bool(uFogEnable))
{
float FogFactor = computeFog();
vec4 FogColor = uFogColor;
FogColor.a = 1.0;
FinalColor = mix(FogColor, FinalColor, FogFactor);
}
gl_FragColor = FinalColor;
}

View File

@ -0,0 +1,23 @@
#version 100
precision mediump float;
/* Uniforms */
uniform int uTextureUsage;
uniform sampler2D uTextureUnit;
/* Varyings */
varying vec2 vTextureCoord;
varying vec4 vVertexColor;
void main()
{
vec4 Color = vVertexColor;
if (bool(uTextureUsage))
Color *= texture2D(uTextureUnit, vTextureCoord);
gl_FragColor = Color;
}

View File

@ -0,0 +1,24 @@
#version 100
/* Attributes */
attribute vec4 inVertexPosition;
attribute vec4 inVertexColor;
attribute vec2 inTexCoord0;
/* Uniforms */
uniform float uThickness;
/* Varyings */
varying vec2 vTextureCoord;
varying vec4 vVertexColor;
void main()
{
gl_Position = inVertexPosition;
gl_PointSize = uThickness;
vTextureCoord = inTexCoord0;
vVertexColor = inVertexColor.bgra;
}

View File

@ -0,0 +1,11 @@
#version 100
precision mediump float;
/* Varyings */
varying vec4 vVertexColor;
void main()
{
gl_FragColor = vVertexColor;
}

62
media/Shaders/Solid.fsh Normal file
View File

@ -0,0 +1,62 @@
#version 100
precision mediump float;
/* Uniforms */
uniform int uTextureUsage0;
uniform sampler2D uTextureUnit0;
uniform int uFogEnable;
uniform int uFogType;
uniform vec4 uFogColor;
uniform float uFogStart;
uniform float uFogEnd;
uniform float uFogDensity;
/* Varyings */
varying vec2 vTextureCoord0;
varying vec4 vVertexColor;
varying float vFogCoord;
float computeFog()
{
const float LOG2 = 1.442695;
float FogFactor = 0.0;
if (uFogType == 0) // Exp
{
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
}
else if (uFogType == 1) // Linear
{
float Scale = 1.0 / (uFogEnd - uFogStart);
FogFactor = (uFogEnd - vFogCoord) * Scale;
}
else if (uFogType == 2) // Exp2
{
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
}
FogFactor = clamp(FogFactor, 0.0, 1.0);
return FogFactor;
}
void main()
{
vec4 Color = vVertexColor;
if (bool(uTextureUsage0))
Color *= texture2D(uTextureUnit0, vTextureCoord0);
if (bool(uFogEnable))
{
float FogFactor = computeFog();
vec4 FogColor = uFogColor;
FogColor.a = 1.0;
Color = mix(FogColor, Color, FogFactor);
}
gl_FragColor = Color;
}

38
media/Shaders/Solid.vsh Normal file
View File

@ -0,0 +1,38 @@
#version 100
/* Attributes */
attribute vec3 inVertexPosition;
attribute vec3 inVertexNormal;
attribute vec4 inVertexColor;
attribute vec2 inTexCoord0;
/* Uniforms */
uniform mat4 uWVPMatrix;
uniform mat4 uWVMatrix;
uniform mat4 uNMatrix;
uniform mat4 uTMatrix0;
uniform float uThickness;
/* Varyings */
varying vec2 vTextureCoord0;
varying vec4 vVertexColor;
varying float vFogCoord;
void main()
{
gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
gl_PointSize = uThickness;
vec4 TextureCoord0 = vec4(inTexCoord0.x, inTexCoord0.y, 1.0, 1.0);
vTextureCoord0 = vec4(uTMatrix0 * TextureCoord0).xy;
vVertexColor = inVertexColor.bgra;
vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz;
vFogCoord = length(Position);
}

View File

@ -0,0 +1,69 @@
#version 100
precision mediump float;
/* Uniforms */
uniform float uAlphaRef;
uniform int uTextureUsage0;
uniform sampler2D uTextureUnit0;
uniform int uFogEnable;
uniform int uFogType;
uniform vec4 uFogColor;
uniform float uFogStart;
uniform float uFogEnd;
uniform float uFogDensity;
/* Varyings */
varying vec2 vTextureCoord0;
varying vec4 vVertexColor;
varying float vFogCoord;
float computeFog()
{
const float LOG2 = 1.442695;
float FogFactor = 0.0;
if (uFogType == 0) // Exp
{
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
}
else if (uFogType == 1) // Linear
{
float Scale = 1.0 / (uFogEnd - uFogStart);
FogFactor = (uFogEnd - vFogCoord) * Scale;
}
else if (uFogType == 2) // Exp2
{
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
}
FogFactor = clamp(FogFactor, 0.0, 1.0);
return FogFactor;
}
void main()
{
vec4 Color = vVertexColor;
if (bool(uTextureUsage0))
{
Color *= texture2D(uTextureUnit0, vTextureCoord0);
// TODO: uAlphaRef should rather control sharpness of alpha, don't know how to do that right now and this works in most cases.
if (Color.a < uAlphaRef)
discard;
}
if (bool(uFogEnable))
{
float FogFactor = computeFog();
vec4 FogColor = uFogColor;
FogColor.a = 1.0;
Color = mix(FogColor, Color, FogFactor);
}
gl_FragColor = Color;
}

View File

@ -0,0 +1,66 @@
#version 100
precision mediump float;
/* Uniforms */
uniform float uAlphaRef;
uniform int uTextureUsage0;
uniform sampler2D uTextureUnit0;
uniform int uFogEnable;
uniform int uFogType;
uniform vec4 uFogColor;
uniform float uFogStart;
uniform float uFogEnd;
uniform float uFogDensity;
/* Varyings */
varying vec2 vTextureCoord0;
varying vec4 vVertexColor;
varying float vFogCoord;
float computeFog()
{
const float LOG2 = 1.442695;
float FogFactor = 0.0;
if (uFogType == 0) // Exp
{
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
}
else if (uFogType == 1) // Linear
{
float Scale = 1.0 / (uFogEnd - uFogStart);
FogFactor = (uFogEnd - vFogCoord) * Scale;
}
else if (uFogType == 2) // Exp2
{
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
}
FogFactor = clamp(FogFactor, 0.0, 1.0);
return FogFactor;
}
void main()
{
vec4 Color = vVertexColor;
if (bool(uTextureUsage0))
Color *= texture2D(uTextureUnit0, vTextureCoord0);
if (Color.a < uAlphaRef)
discard;
if (bool(uFogEnable))
{
float FogFactor = computeFog();
vec4 FogColor = uFogColor;
FogColor.a = 1.0;
Color = mix(FogColor, Color, FogFactor);
}
gl_FragColor = Color;
}

View File

@ -0,0 +1,62 @@
#version 100
precision mediump float;
/* Uniforms */
uniform int uTextureUsage0;
uniform sampler2D uTextureUnit0;
uniform int uFogEnable;
uniform int uFogType;
uniform vec4 uFogColor;
uniform float uFogStart;
uniform float uFogEnd;
uniform float uFogDensity;
/* Varyings */
varying vec2 vTextureCoord0;
varying vec4 vVertexColor;
varying float vFogCoord;
float computeFog()
{
const float LOG2 = 1.442695;
float FogFactor = 0.0;
if (uFogType == 0) // Exp
{
FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
}
else if (uFogType == 1) // Linear
{
float Scale = 1.0 / (uFogEnd - uFogStart);
FogFactor = (uFogEnd - vFogCoord) * Scale;
}
else if (uFogType == 2) // Exp2
{
FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
}
FogFactor = clamp(FogFactor, 0.0, 1.0);
return FogFactor;
}
void main()
{
vec4 Color = vVertexColor;
if (bool(uTextureUsage0))
Color *= texture2D(uTextureUnit0, vTextureCoord0);
if (bool(uFogEnable))
{
float FogFactor = computeFog();
vec4 FogColor = uFogColor;
FogColor.a = 1.0;
Color = mix(FogColor, Color, FogFactor);
}
gl_FragColor = Color;
}

View File

@ -349,7 +349,7 @@ f:write[[
#include <string>
#include <unordered_set>
#include "IrrCompileConfig.h"
#include "IrrCompileConfig.h" // for IRRLICHT_API
#include "irrTypes.h"
#include "IContextManager.h"
#include <KHR/khrplatform.h>

View File

@ -5,21 +5,19 @@
variant=win32
[[ "$(basename "$CXX")" == "x86_64-"* ]] && variant=win64
libjpeg_version=2.1.2
libpng_version=1.6.37
zlib_version=1.2.11
libjpeg_version=2.1.5.1
libpng_version=1.6.39
zlib_version=1.2.13
mkdir -p libs
pushd libs
libs=$PWD
tmp=
[ "$variant" = win32 ] && tmp=dw2/
[ -e libjpeg.zip ] || \
wget "http://minetest.kitsunemimi.pw/libjpeg-$libjpeg_version-$variant.zip" -O libjpeg.zip
[ -e libpng.zip ] || \
wget "http://minetest.kitsunemimi.pw/${tmp}libpng-$libpng_version-$variant.zip" -O libpng.zip
wget "http://minetest.kitsunemimi.pw/libpng-$libpng_version-$variant.zip" -O libpng.zip
[ -e zlib.zip ] || \
wget "http://minetest.kitsunemimi.pw/${tmp}zlib-$zlib_version-$variant.zip" -O zlib.zip
wget "http://minetest.kitsunemimi.pw/zlib-$zlib_version-$variant.zip" -O zlib.zip
[ -d libjpeg ] || unzip -o libjpeg.zip -d libjpeg
[ -d libpng ] || unzip -o libpng.zip -d libpng
[ -d zlib ] || unzip -o zlib.zip -d zlib

View File

@ -2,7 +2,6 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_ANDROID_ASSET_READER_

View File

@ -6,7 +6,6 @@
#define __C_ANDROID_ASSET_FILE_ARCHIVE_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_ANDROID_ASSET_READER_

View File

@ -2,7 +2,6 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_ANDROID_ASSET_READER_

View File

@ -6,7 +6,6 @@
#define __C_ANDROID_ASSET_READER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_ANDROID_ASSET_READER_

View File

@ -5,7 +5,6 @@
#ifndef __C_IRR_DEVICE_ANDROID_H_INCLUDED__
#define __C_IRR_DEVICE_ANDROID_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_

View File

@ -4,7 +4,6 @@
#ifndef __C_IRR_KEY_EVENT_WRAPPER_H_INCLUDED__
#define __C_IRR_KEY_EVENT_WRAPPER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_

View File

@ -5,8 +5,6 @@
#ifndef __BUILD_IN_FONT_H_INCLUDED__
#define __BUILD_IN_FONT_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
// header file generated by Bin2H, copyright 2002 by N.Gebhardt.
// Bin2H is Freeware. Download it freely from www.code3d.com.
@ -16,7 +14,6 @@ namespace irr
{
namespace gui
{
#ifdef _IRR_COMPILE_WITH_BMP_LOADER_
const u8 BuiltInFontData[] =
{
0x42, 0x4d, 0x4a, 0x20, 0x00, 0x00, 0x00, 0x00,
@ -1056,20 +1053,7 @@ const u8 BuiltInFontData[] =
};
const u32 BuiltInFontDataSize = sizeof(BuiltInFontData);
#else // !defined(_IRR_COMPILE_WITH_BMP_LOADER_)
// built-in font cannot be loaded if there is no BMP loader
const u8 * const BuiltInFontData=0;
const u32 BuiltInFontDataSize = 0;
#endif
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -7,7 +7,9 @@
#include "ISceneManager.h"
#include "S3DVertex.h"
#include "os.h"
#ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
#include "CSkinnedMesh.h"
#endif
#include "IDummyTransformationSceneNode.h"
#include "IBoneSceneNode.h"
#include "IMaterialRenderer.h"

View File

@ -5,7 +5,6 @@
#ifndef __C_ATTRIBUTES_H_INCLUDED__
#define __C_ATTRIBUTES_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "IAttributes.h"
#include "IAttribute.h"

View File

@ -6,9 +6,6 @@
// File format designed by Mark Sibly for the Blitz3D engine and has been
// declared public domain
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_B3D_LOADER_
#include "CB3DMeshFileLoader.h"
#include "IVideoDriver.h"
@ -1055,7 +1052,3 @@ void CB3DMeshFileLoader::readFloats(f32* vec, u32 count)
} // end namespace scene
} // end namespace irr
#endif // _IRR_COMPILE_WITH_B3D_LOADER_

View File

@ -6,7 +6,6 @@
// File format designed by Mark Sibly for the Blitz3D engine and has been
// declared public domain
#include "IrrCompileConfig.h"
#ifndef __C_B3D_MESH_LOADER_H_INCLUDED__
#define __C_B3D_MESH_LOADER_H_INCLUDED__

View File

@ -4,9 +4,6 @@
// TODO: replace printf's by logging messages
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_B3D_WRITER_
#include "CB3DMeshWriter.h"
#include "os.h"
@ -97,7 +94,7 @@ bool CB3DMeshWriter::writeMesh(io::IWriteFile* file, IMesh* const mesh, s32 flag
u32 numTexture = texs.size();
for (u32 i = 0; i < numTexture; i++)
{
file->write(texs[i].TextureName.c_str(), texs[i].TextureName.size() + 1);
file->write(texs[i].TextureName.c_str(), (size_t)texs[i].TextureName.size() + 1);
file->write(&texs[i].Flags, 7*4);
}
@ -479,7 +476,7 @@ core::array<ISkinnedMesh::SJoint*> CB3DMeshWriter::getRootJoints(const ISkinnedM
return roots;
}
u32 CB3DMeshWriter::getUVlayerCount(IMesh* mesh)
u32 CB3DMeshWriter::getUVlayerCount(const IMesh* mesh)
{
const u32 numBeshBuffers = mesh->getMeshBufferCount();
for (u32 i = 0; i < numBeshBuffers; i++)
@ -531,6 +528,3 @@ void CB3DMeshWriter::writeSizeFrom(io::IWriteFile* file, const u32 from, const u
} // end namespace
} // end namespace
#endif // _IRR_COMPILE_WITH_B3D_WRITER_

View File

@ -37,7 +37,7 @@ private:
u32 getJointChunkSize(const ISkinnedMesh* mesh, ISkinnedMesh::SJoint* joint);
core::array<ISkinnedMesh::SJoint*> getRootJoints(const ISkinnedMesh* mesh);
u32 getUVlayerCount(IMesh *mesh);
u32 getUVlayerCount(const IMesh *mesh);
ISkinnedMesh* getSkinned (IMesh *mesh);
inline void writeVector2(io::IWriteFile* file, const core::vector2df& vec);

View File

@ -2,8 +2,6 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_
#include "CBillboardSceneNode.h"
#include "IVideoDriver.h"
#include "ISceneManager.h"
@ -143,7 +141,7 @@ void CBillboardSceneNode::updateMesh(const irr::scene::ICameraSceneNode* camera)
//! returns the axis aligned bounding box of this node
const core::aabbox3d<f32>& CBillboardSceneNode::getBoundingBox() const
{
// Really wrong when scaled.
// Really wrong when scaled (as the node does not scale it's vertices - maybe it should?)
return BBoxSafe;
}
@ -164,9 +162,9 @@ void CBillboardSceneNode::setSize(const core::dimension2d<f32>& size)
if (core::equals(Size.Height, 0.0f))
Size.Height = 1.0f;
const f32 avg = (Size.Width + Size.Height)/6;
BBoxSafe.MinEdge.set(-avg,-avg,-avg);
BBoxSafe.MaxEdge.set(avg,avg,avg);
const f32 extent = 0.5f*sqrtf(Size.Width*Size.Width + Size.Height*Size.Height);
BBoxSafe.MinEdge.set(-extent,-extent,-extent);
BBoxSafe.MaxEdge.set(extent,extent,extent);
}
@ -184,9 +182,9 @@ void CBillboardSceneNode::setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWi
TopEdgeWidth = 1.0f;
}
const f32 avg = (core::max_(Size.Width,TopEdgeWidth) + Size.Height)/6;
BBoxSafe.MinEdge.set(-avg,-avg,-avg);
BBoxSafe.MaxEdge.set(avg,avg,avg);
const f32 extent = 0.5f*sqrtf(Size.Width*Size.Width + Size.Height*Size.Height);
BBoxSafe.MinEdge.set(-extent,-extent,-extent);
BBoxSafe.MaxEdge.set(extent,extent,extent);
}
@ -281,5 +279,3 @@ ISceneNode* CBillboardSceneNode::clone(ISceneNode* newParent, ISceneManager* new
} // end namespace scene
} // end namespace irr
#endif // _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_

View File

@ -2,9 +2,6 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
#include "CBoneSceneNode.h"
namespace irr
@ -98,6 +95,3 @@ void CBoneSceneNode::updateAbsolutePositionOfAllChildren()
} // namespace scene
} // namespace irr
#endif

View File

@ -28,16 +28,16 @@ CCameraSceneNode::CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 i
// set default projection
Fovy = core::PI / 2.5f; // Field of view, in radians.
Aspect = 4.0f / 3.0f; // Aspect ratio.
const video::IVideoDriver* const d = mgr?mgr->getVideoDriver():0;
if (d)
{
if ( d->getCurrentRenderTargetSize().Height )
Aspect = (f32)d->getCurrentRenderTargetSize().Width /
(f32)d->getCurrentRenderTargetSize().Height;
HasD3DStyleProjectionMatrix = d->getDriverType() != video::EDT_OPENGL;
}
else
Aspect = 4.0f / 3.0f; // Aspect ratio.
ViewArea.setFarNearDistance(ZFar - ZNear);
recalculateProjectionMatrix();

View File

@ -1,87 +0,0 @@
// Copyright (C) 2015 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#ifndef __C_EAGL_MANAGER_H_INCLUDED__
#define __C_EAGL_MANAGER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_EAGL_MANAGER_
#include "SIrrCreationParameters.h"
#include "SExposedVideoData.h"
#include "IContextManager.h"
namespace irr
{
namespace video
{
// EAGL manager.
class CEAGLManager : public IContextManager
{
public:
//! Constructor.
CEAGLManager();
//! Destructor.
virtual ~CEAGLManager();
// Initialize EAGL.
/* This method checks if a view has CAEAGLLayer and grabs it if it does, anyway surface and context
aren't create. */
bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data);
// Terminate EAGL.
/* Terminate EAGL context. This method break both existed surface and context. */
void terminate();
// Create EAGL surface.
/* This method configure CAEAGLLayer. */
bool generateSurface();
// Destroy EAGL surface.
/* This method reset CAEAGLLayer states. */
void destroySurface();
// Create EAGL context.
/* This method create and activate EAGL context. */
bool generateContext();
// Destroy EAGL context.
/* This method destroy EAGL context. */
void destroyContext();
const SExposedVideoData& getContext() const;
bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero);
// Swap buffers.
bool swapBuffers();
private:
SIrrlichtCreationParameters Params;
SExposedVideoData Data;
bool Configured;
void* DataStorage;
struct SFrameBuffer
{
SFrameBuffer() : BufferID(0), ColorBuffer(0), DepthBuffer(0)
{
}
u32 BufferID;
u32 ColorBuffer;
u32 DepthBuffer;
};
SFrameBuffer FrameBuffer;
};
}
}
#endif
#endif

View File

@ -1,273 +0,0 @@
// Copyright (C) 2015 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#include "CEAGLManager.h"
#ifdef _IRR_COMPILE_WITH_EAGL_MANAGER_
#include "irrString.h"
#include "os.h"
#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#if defined(_IRR_COMPILE_WITH_OGLES1_)
#include <OpenGLES/ES1/gl.h>
#include <OpenGLES/ES1/glext.h>
#elif defined(_IRR_COMPILE_WITH_OGLES2_)
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#endif
namespace irr
{
namespace video
{
struct SEAGLManagerDataStorage
{
SEAGLManagerDataStorage() : Layer(0), Context(0)
{
}
CAEAGLLayer* Layer;
EAGLContext* Context;
};
CEAGLManager::CEAGLManager() : IContextManager(), Configured(false), DataStorage(0)
{
#ifdef _DEBUG
setDebugName("CEAGLManager");
#endif
DataStorage = new SEAGLManagerDataStorage();
}
CEAGLManager::~CEAGLManager()
{
destroyContext();
destroySurface();
terminate();
delete static_cast<SEAGLManagerDataStorage*>(DataStorage);
}
bool CEAGLManager::initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data)
{
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
if (dataStorage->Layer != nil)
return true;
Params = params;
Data = data;
UIView* view = (__bridge UIView*)data.OpenGLiOS.View;
if (view == nil || ![[view layer] isKindOfClass:[CAEAGLLayer class]])
{
os::Printer::log("Could not get EAGL display.");
return false;
}
dataStorage->Layer = (CAEAGLLayer*)[view layer];
return true;
}
void CEAGLManager::terminate()
{
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
[EAGLContext setCurrentContext:0];
destroySurface();
if (dataStorage->Layer != nil)
dataStorage->Layer = 0;
}
bool CEAGLManager::generateSurface()
{
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
CAEAGLLayer* layer = dataStorage->Layer;
if (layer == nil)
return false;
if (Configured)
return true;
NSDictionary* attribs = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO],
kEAGLDrawablePropertyRetainedBacking,
(Params.Bits > 16) ? kEAGLColorFormatRGBA8 : kEAGLColorFormatRGB565,
kEAGLDrawablePropertyColorFormat,
nil];
[layer setOpaque:(Params.WithAlphaChannel) ? YES : NO];
[layer setDrawableProperties:attribs];
Configured = true;
return true;
}
void CEAGLManager::destroySurface()
{
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
CAEAGLLayer* layer = dataStorage->Layer;
if (layer == nil)
return;
[layer setOpaque:NO];
[layer setDrawableProperties:nil];
Configured = false;
}
bool CEAGLManager::generateContext()
{
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
if (dataStorage->Context != nil || !Configured)
return false;
EAGLRenderingAPI OpenGLESVersion = kEAGLRenderingAPIOpenGLES2;
switch (Params.DriverType)
{
case EDT_OGLES1:
OpenGLESVersion = kEAGLRenderingAPIOpenGLES1;
break;
case EDT_OGLES2:
OpenGLESVersion = kEAGLRenderingAPIOpenGLES2;
break;
default:
break;
}
dataStorage->Context = [[EAGLContext alloc] initWithAPI:OpenGLESVersion];
if (dataStorage->Context == nil)
{
os::Printer::log("Could not create EAGL context.", ELL_ERROR);
return false;
}
Data.OpenGLiOS.Context = (__bridge void*)dataStorage->Context;
os::Printer::log("EAGL context created with OpenGLESVersion: ", core::stringc(static_cast<int>(OpenGLESVersion)), ELL_DEBUG);
return true;
}
void CEAGLManager::destroyContext()
{
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
[dataStorage->Context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:nil];
if (FrameBuffer.BufferID != 0)
{
glDeleteFramebuffersOES(1, &FrameBuffer.BufferID);
FrameBuffer.BufferID = 0;
}
if (FrameBuffer.ColorBuffer != 0)
{
glDeleteRenderbuffersOES(1, &FrameBuffer.ColorBuffer);
FrameBuffer.ColorBuffer = 0;
}
if (FrameBuffer.DepthBuffer != 0)
{
glDeleteRenderbuffersOES(1, &FrameBuffer.DepthBuffer);
FrameBuffer.DepthBuffer = 0;
}
[EAGLContext setCurrentContext:0];
if (dataStorage->Context != nil)
dataStorage->Context = 0;
Data.OpenGLiOS.Context = 0;
}
bool CEAGLManager::activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero)
{
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
EAGLContext* context = dataStorage->Context;
bool status = false;
if (context != nil)
{
status = ([EAGLContext currentContext] == context || [EAGLContext setCurrentContext:context]);
}
if (status)
{
if (FrameBuffer.ColorBuffer == 0)
{
glGenRenderbuffersOES(1, &FrameBuffer.ColorBuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer);
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:dataStorage->Layer];
}
if (FrameBuffer.DepthBuffer == 0)
{
GLenum depth = (Params.ZBufferBits >= 24) ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16_OES;
glGenRenderbuffersOES(1, &FrameBuffer.DepthBuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.DepthBuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depth, Params.WindowSize.Width, Params.WindowSize.Height);
}
if (FrameBuffer.BufferID == 0)
{
glGenFramebuffersOES(1, &FrameBuffer.BufferID);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, FrameBuffer.BufferID);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, FrameBuffer.DepthBuffer);
}
glBindFramebufferOES(GL_FRAMEBUFFER_OES, FrameBuffer.BufferID);
}
else
{
os::Printer::log("Could not make EGL context current.");
}
return status;
}
const SExposedVideoData& CEAGLManager::getContext() const
{
return Data;
}
bool CEAGLManager::swapBuffers()
{
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
EAGLContext* context = dataStorage->Context;
bool status = false;
if (context != nil && context == [EAGLContext currentContext])
{
glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
status = true;
}
return status;
}
}
}
#endif

View File

@ -5,7 +5,6 @@
#ifndef __C_EGL_MANAGER_H_INCLUDED__
#define __C_EGL_MANAGER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_EGL_MANAGER_

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CFileList.h"
#include "IrrCompileConfig.h"
#include "irrArray.h"
#include "coreutil.h"

View File

@ -2,7 +2,6 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#include "CFileSystem.h"
#include "IReadFile.h"
@ -25,7 +24,7 @@
#include <direct.h> // for _chdir
#include <io.h> // for _access
#include <tchar.h>
#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_IOS_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_))
#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_))
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -54,9 +53,7 @@ CFileSystem::CFileSystem()
//! reset current working directory
getWorkingDirectory();
#ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderZIP(this));
#endif
}
@ -799,7 +796,7 @@ IFileList* CFileSystem::createFileList()
size = buf.st_size;
isDirectory = S_ISDIR(buf.st_mode);
}
#if !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__CYGWIN__)
#if !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__CYGWIN__) && !defined(__HAIKU__)
// only available on some systems
else
{

View File

@ -5,7 +5,6 @@
#ifndef __C_GLX_MANAGER_H_INCLUDED__
#define __C_GLX_MANAGER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GLX_MANAGER_

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIButton.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
@ -558,6 +557,3 @@ bool CGUIButton::isDrawingBorder() const
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_BUTTON_H_INCLUDED__
#define __C_GUI_BUTTON_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIButton.h"
#include "IGUISpriteBank.h"
#include "ITexture.h"
@ -244,7 +241,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_BUTTON_H_INCLUDED__

View File

@ -4,8 +4,6 @@
#include "CGUICheckBox.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
@ -227,6 +225,3 @@ bool CGUICheckBox::isDrawBorderEnabled() const
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_CHECKBOX_H_INCLUDED__
#define __C_GUI_CHECKBOX_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUICheckBox.h"
namespace irr
@ -61,5 +58,3 @@ namespace gui
} // end namespace irr
#endif // __C_GUI_CHECKBOX_H_INCLUDED__
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIComboBox.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
@ -321,6 +320,10 @@ bool CGUIComboBox::OnEvent(const SEvent& event)
}
case EMIE_MOUSE_WHEEL:
{
// Try scrolling parent first
if (IGUIElement::OnEvent(event))
return true;
s32 oldSelected = Selected;
setSelected( Selected + ((event.MouseInput.Wheel < 0) ? 1 : -1));
@ -330,11 +333,12 @@ bool CGUIComboBox::OnEvent(const SEvent& event)
if (Selected >= (s32)Items.size())
setSelected((s32)Items.size() -1);
if (Selected != oldSelected)
{
if (Selected != oldSelected) {
sendSelectionChangedEvent();
return true;
}
return false;
}
default:
break;
@ -488,7 +492,3 @@ void CGUIComboBox::openCloseMenu()
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_COMBO_BOX_H_INCLUDED__
#define __C_GUI_COMBO_BOX_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIComboBox.h"
#include "IGUIStaticText.h"
#include "irrString.h"
@ -107,7 +104,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_COMBO_BOX_H_INCLUDED__

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIEditBox.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
@ -1136,6 +1135,34 @@ bool CGUIEditBox::processMouse(const SEvent& event)
return true;
}
}
case EMIE_MMOUSE_PRESSED_DOWN: {
if (!AbsoluteClippingRect.isPointInside(core::position2d<s32>(
event.MouseInput.X, event.MouseInput.Y)))
return false;
if (!Environment->hasFocus(this)) {
BlinkStartTime = os::Timer::getTime();
}
// move cursor and disable marking
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
MouseMarking = false;
setTextMarkers(CursorPos, CursorPos);
// paste from the primary selection
inputString([&] {
irr::core::stringw inserted_text;
if (!Operator)
return inserted_text;
const c8 *inserted_text_utf8 = Operator->getTextFromPrimarySelection();
if (!inserted_text_utf8)
return inserted_text;
core::multibyteToWString(inserted_text, inserted_text_utf8);
return inserted_text;
}());
return true;
}
default:
break;
}
@ -1625,6 +1652,17 @@ void CGUIEditBox::setTextMarkers(s32 begin, s32 end)
{
MarkBegin = begin;
MarkEnd = end;
if (!PasswordBox && Operator && MarkBegin != MarkEnd) {
// copy to primary selection
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
core::stringc s;
wStringToMultibyte(s, Text.subString(realmbgn, realmend - realmbgn));
Operator->copyToPrimarySelection(s.c_str());
}
sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED);
}
}
@ -1652,6 +1690,3 @@ bool CGUIEditBox::acceptsIME()
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_EDIT_BOX_H_INCLUDED__
#define __C_GUI_EDIT_BOX_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEditBox.h"
#include "irrArray.h"
#include "IOSOperator.h"
@ -201,6 +198,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_EDIT_BOX_H_INCLUDED__

View File

@ -5,8 +5,6 @@
#include "CGUIEnvironment.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IVideoDriver.h"
#include "CGUISkin.h"
@ -25,8 +23,9 @@
#include "CGUIComboBox.h"
#include "IWriteFile.h"
#ifdef IRR_ENABLE_BUILTIN_FONT
#include "BuiltInFont.h"
#endif
#include "os.h"
namespace irr
@ -143,6 +142,7 @@ CGUIEnvironment::~CGUIEnvironment()
void CGUIEnvironment::loadBuiltInFont()
{
#ifdef IRR_ENABLE_BUILTIN_FONT
io::IReadFile* file = FileSystem->createMemoryReadFile(BuiltInFontData,
BuiltInFontDataSize, DefaultFontName, false);
@ -161,6 +161,7 @@ void CGUIEnvironment::loadBuiltInFont()
Fonts.push_back(f);
file->drop();
#endif
}
@ -1107,6 +1108,3 @@ IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs,
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_ENVIRONMENT_H_INCLUDED__
#define __C_GUI_ENVIRONMENT_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEnvironment.h"
#include "IGUIElement.h"
#include "irrArray.h"
@ -231,8 +228,4 @@ private:
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_ENVIRONMENT_H_INCLUDED__

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIFileOpenDialog.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
@ -411,5 +410,3 @@ void CGUIFileOpenDialog::sendCancelEvent()
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__
#define __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIFileOpenDialog.h"
#include "IGUIButton.h"
#include "IGUIListBox.h"
@ -90,7 +87,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIFont.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "os.h"
#include "coreutil.h"
@ -594,6 +593,3 @@ IGUISpriteBank* CGUIFont::getSpriteBank() const
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_FONT_H_INCLUDED__
#define __C_GUI_FONT_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIFontBitmap.h"
#include "irrString.h"
#include "IReadFile.h"
@ -111,7 +108,4 @@ private:
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_FONT_H_INCLUDED__

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIImage.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
@ -177,7 +176,3 @@ core::rect<f32> CGUIImage::getDrawBounds() const
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_IMAGE_H_INCLUDED__
#define __C_GUI_IMAGE_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIImage.h"
namespace irr
@ -102,6 +99,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_IMAGE_H_INCLUDED__

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIListBox.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "CGUIListBox.h"
#include "IGUISkin.h"
@ -841,6 +840,3 @@ IGUIScrollBar* CGUIListBox::getVerticalScrollBar() const
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_LIST_BOX_H_INCLUDED__
#define __C_GUI_LIST_BOX_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIListBox.h"
#include "irrArray.h"
@ -178,6 +175,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIScrollBar.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
@ -534,6 +533,3 @@ void CGUIScrollBar::refreshControls()
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_SCROLL_BAR_H_INCLUDED__
#define __C_GUI_SCROLL_BAR_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIScrollBar.h"
#include "IGUIButton.h"
@ -101,7 +98,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUISkin.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIFont.h"
#include "IGUISpriteBank.h"
@ -973,6 +972,3 @@ void CGUISkin::draw2DRectangle(IGUIElement* element,
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_SKIN_H_INCLUDED__
#define __C_GUI_SKIN_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "irrString.h"
@ -234,8 +231,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUISpriteBank.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
@ -32,10 +31,7 @@ CGUISpriteBank::CGUISpriteBank(IGUIEnvironment* env) :
CGUISpriteBank::~CGUISpriteBank()
{
// drop textures
for (u32 i=0; i<Textures.size(); ++i)
if (Textures[i])
Textures[i]->drop();
clear();
// drop video driver
if (Driver)
@ -133,15 +129,38 @@ s32 CGUISpriteBank::addTextureAsSprite(video::ITexture* texture)
return Sprites.size() - 1;
}
// get FrameNr for time. return true on exisiting frame
inline bool CGUISpriteBank::getFrameNr(u32& frame,u32 index, u32 time, bool loop) const
{
frame = 0;
if (index >= Sprites.size())
return false;
const SGUISprite& sprite = Sprites[index];
const u32 frameSize = sprite.Frames.size();
if (frameSize < 1)
return false;
if (sprite.frameTime)
{
u32 f = (time / sprite.frameTime);
if (loop)
frame = f % frameSize;
else
frame = (f >= frameSize) ? frameSize - 1 : f;
}
return true;
}
//! draws a sprite in 2d with scale and color
void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos,
const core::rect<s32>* clip, const video::SColor& color,
u32 starttime, u32 currenttime, bool loop, bool center)
{
if (index >= Sprites.size() || Sprites[index].Frames.empty() )
u32 frame = 0;
if (!getFrameNr(frame, index, currenttime - starttime, loop))
return;
u32 frame = getFrameNr(index, currenttime - starttime, loop);
const video::ITexture* tex = getTexture(Sprites[index].Frames[frame].textureNumber);
if (!tex)
return;
@ -163,10 +182,10 @@ void CGUISpriteBank::draw2DSprite(u32 index, const core::rect<s32>& destRect,
const core::rect<s32>* clip, const video::SColor * const colors,
u32 timeTicks, bool loop)
{
if (index >= Sprites.size() || Sprites[index].Frames.empty() )
u32 frame = 0;
if (!getFrameNr(frame,index, timeTicks, loop))
return;
u32 frame = getFrameNr(index, timeTicks, loop);
const video::ITexture* tex = getTexture(Sprites[index].Frames[frame].textureNumber);
if (!tex)
return;
@ -201,21 +220,16 @@ void CGUISpriteBank::draw2DSpriteBatch( const core::array<u32>& indices,
{
const u32 index = indices[i];
if (index >= Sprites.size() || Sprites[index].Frames.empty() )
continue;
// work out frame number
u32 frame = 0;
if (Sprites[index].frameTime)
{
u32 f = ((currenttime - starttime) / Sprites[index].frameTime);
if (loop)
frame = f % Sprites[index].Frames.size();
else
frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f;
}
if (!getFrameNr(frame, index, currenttime - starttime, loop))
return;
const u32 texNum = Sprites[index].Frames[frame].textureNumber;
if (texNum >= drawBatches.size())
{
continue;
}
SDrawBatch& currentBatch = drawBatches[texNum];
const u32 rn = Sprites[index].Frames[frame].rectNumber;
@ -249,5 +263,3 @@ void CGUISpriteBank::draw2DSpriteBatch( const core::array<u32>& indices,
} // namespace gui
} // namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_SPRITE_BANK_H_INCLUDED__
#define __C_GUI_SPRITE_BANK_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISpriteBank.h"
namespace irr
@ -67,19 +64,7 @@ public:
protected:
inline u32 getFrameNr(u32 index, u32 time, bool loop) const
{
u32 frame = 0;
if (Sprites[index].frameTime && Sprites[index].Frames.size() )
{
u32 f = (time / Sprites[index].frameTime);
if (loop)
frame = f % Sprites[index].Frames.size();
else
frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f;
}
return frame;
}
bool getFrameNr(u32& frameNr, u32 index, u32 time, bool loop) const;
struct SDrawBatch
{
@ -99,7 +84,4 @@ protected:
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_SPRITE_BANK_H_INCLUDED__

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIStaticText.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
@ -592,6 +591,3 @@ s32 CGUIStaticText::getTextWidth() const
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_STATIC_TEXT_H_INCLUDED__
#define __C_GUI_STATIC_TEXT_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIStaticText.h"
#include "irrArray.h"
@ -136,7 +133,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUITabControl.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "CGUIButton.h"
#include "IGUISkin.h"
@ -1030,6 +1029,3 @@ void CGUITabControl::updateAbsolutePosition()
} // end namespace irr
} // end namespace gui
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -5,9 +5,6 @@
#ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__
#define __C_GUI_TAB_CONTROL_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUITabControl.h"
#include "irrArray.h"
#include "IGUISkin.h"
@ -184,7 +181,4 @@ namespace gui
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -173,6 +173,50 @@ void CImage::copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, c
}
//! copies this surface into another, if it has the exact same size and format.
bool CImage::copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch) const
{
if (IImage::isCompressedFormat(Format))
{
os::Printer::log("IImage::copyToNoScaling method doesn't work with compressed images.", ELL_WARNING);
return false;
}
if (!target || !width || !height || !Size.Width || !Size.Height)
return false;
const u32 bpp=getBitsPerPixelFromFormat(format)/8;
if (0==pitch)
pitch = width*bpp;
if (!(Format==format && Size.Width==width && Size.Height==height))
return false;
if (pitch==Pitch)
{
memcpy(target, Data, (size_t)height*pitch);
}
else
{
u8* tgtpos = (u8*) target;
u8* srcpos = Data;
const u32 bwidth = width*bpp;
const u32 rest = pitch-bwidth;
for (u32 y=0; y<height; ++y)
{
// copy scanline
memcpy(tgtpos, srcpos, bwidth);
// clear pitch
memset(tgtpos+bwidth, 0, rest);
tgtpos += pitch;
srcpos += Pitch;
}
}
return true;
}
//! copies this surface into another, scaling it to the target image size
// note: this is very very slow.
void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch)
@ -190,31 +234,8 @@ void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT fo
if (0==pitch)
pitch = width*bpp;
if (Format==format && Size.Width==width && Size.Height==height)
{
if (pitch==Pitch)
{
memcpy(target, Data, height*pitch);
if (copyToNoScaling(target, width, height, format, pitch))
return;
}
else
{
u8* tgtpos = (u8*) target;
u8* srcpos = Data;
const u32 bwidth = width*bpp;
const u32 rest = pitch-bwidth;
for (u32 y=0; y<height; ++y)
{
// copy scanline
memcpy(tgtpos, srcpos, bwidth);
// clear pitch
memset(tgtpos+bwidth, 0, rest);
tgtpos += pitch;
srcpos += Pitch;
}
return;
}
}
// NOTE: Scaling is coded to keep the border pixels intact.
// Alternatively we could for example work with first pixel being taken at half step-size.

View File

@ -42,6 +42,9 @@ public:
//! sets a pixel
void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ) override;
//! copies this surface into another, if it has the exact same size and format.
bool copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch=0) const override;
//! copies this surface into another, scaling it to fit.
void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch=0) override;

View File

@ -4,8 +4,6 @@
#include "CImageLoaderBMP.h"
#ifdef _IRR_COMPILE_WITH_BMP_LOADER_
#include "IReadFile.h"
#include "SColor.h"
#include "CColorConverter.h"
@ -371,6 +369,3 @@ IImageLoader* createImageLoaderBMP()
} // end namespace video
} // end namespace irr
#endif

View File

@ -5,7 +5,6 @@
#ifndef __C_IMAGE_LOADER_BMP_H_INCLUDED__
#define __C_IMAGE_LOADER_BMP_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "IImageLoader.h"
@ -15,9 +14,6 @@ namespace irr
namespace video
{
#if defined(_IRR_COMPILE_WITH_BMP_LOADER_) || defined(_IRR_COMPILE_WITH_BMP_WRITER_)
// byte-align structures
#include "irrpack.h"
@ -59,10 +55,6 @@ namespace video
// Default alignment
#include "irrunpack.h"
#endif // defined with loader or writer
#ifdef _IRR_COMPILE_WITH_BMP_LOADER_
/*!
Surface Loader for Windows bitmaps
*/
@ -91,10 +83,7 @@ private:
};
#endif // compiled with loader
} // end namespace video
} // end namespace irr
#endif

View File

@ -4,8 +4,6 @@
#include "CImageLoaderJPG.h"
#ifdef _IRR_COMPILE_WITH_JPG_LOADER_
#include "IReadFile.h"
#include "CImage.h"
#include "os.h"
@ -40,9 +38,6 @@ bool CImageLoaderJPG::isALoadableFileExtension(const io::path& filename) const
return core::hasFileExtension ( filename, "jpg", "jpeg" );
}
#ifdef _IRR_COMPILE_WITH_LIBJPEG_
// struct for handling jpeg errors
struct irr_jpeg_error_mgr
{
@ -116,31 +111,20 @@ void CImageLoaderJPG::output_message(j_common_ptr cinfo)
errMsg += *myerr->filename;
os::Printer::log(errMsg.c_str(),temp1, ELL_ERROR);
}
#endif // _IRR_COMPILE_WITH_LIBJPEG_
//! returns true if the file maybe is able to be loaded by this class
bool CImageLoaderJPG::isALoadableFileFormat(io::IReadFile* file) const
{
#ifndef _IRR_COMPILE_WITH_LIBJPEG_
return false;
#else
if (!(file && file->seek(0)))
return false;
unsigned char header[3];
size_t headerLen = file->read(header, sizeof(header));
return headerLen >= 3 && !memcmp(header, "\xFF\xD8\xFF", 3);
#endif
}
//! creates a surface from the file
IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const
{
#ifndef _IRR_COMPILE_WITH_LIBJPEG_
os::Printer::log("Can't load as not compiled with _IRR_COMPILE_WITH_LIBJPEG_:", file->getFileName(), ELL_DEBUG);
return 0;
#else
if (!file)
return 0;
@ -288,8 +272,6 @@ IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const
delete [] input;
return image;
#endif
}
@ -302,6 +284,3 @@ IImageLoader* createImageLoaderJPG()
} // end namespace video
} // end namespace irr
#endif

View File

@ -5,19 +5,12 @@
#ifndef __C_IMAGE_LOADER_JPG_H_INCLUDED__
#define __C_IMAGE_LOADER_JPG_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_JPG_LOADER_
#include "IImageLoader.h"
#include <stdio.h> // required for jpeglib.h
#ifdef _IRR_COMPILE_WITH_LIBJPEG_
extern "C" {
#include <jpeglib.h> // use system lib
#include <setjmp.h>
}
#endif // _IRR_COMPILE_WITH_LIBJPEG_
namespace irr
@ -48,8 +41,6 @@ public:
IImage* loadImage(io::IReadFile* file) const override;
private:
#ifdef _IRR_COMPILE_WITH_LIBJPEG_
// several methods used via function pointers by jpeglib
/* Receives control for a fatal error. Information sufficient to
@ -95,8 +86,6 @@ private:
/* Terminate source --- called by jpeg_finish_decompress() after all
data has been read. Often a no-op. */
static void term_source (j_decompress_ptr cinfo);
#endif // _IRR_COMPILE_WITH_LIBJPEG_
};
@ -105,5 +94,3 @@ private:
#endif
#endif

View File

@ -4,11 +4,7 @@
#include "CImageLoaderPNG.h"
#ifdef _IRR_COMPILE_WITH_PNG_LOADER_
#ifdef _IRR_COMPILE_WITH_LIBPNG_
#include <png.h> // use system lib png
#endif // _IRR_COMPILE_WITH_LIBPNG_
#include "CImage.h"
#include "CReadFile.h"
@ -19,7 +15,6 @@ namespace irr
namespace video
{
#ifdef _IRR_COMPILE_WITH_LIBPNG_
// PNG function for error handling
static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg)
{
@ -46,25 +41,19 @@ void PNGAPI user_read_data_fcn(png_structp png_ptr, png_bytep data, png_size_t l
if (check != length)
png_error(png_ptr, "Read Error");
}
#endif // _IRR_COMPILE_WITH_LIBPNG_
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".tga")
bool CImageLoaderPng::isALoadableFileExtension(const io::path& filename) const
{
#ifdef _IRR_COMPILE_WITH_LIBPNG_
return core::hasFileExtension ( filename, "png" );
#else
return false;
#endif // _IRR_COMPILE_WITH_LIBPNG_
}
//! returns true if the file maybe is able to be loaded by this class
bool CImageLoaderPng::isALoadableFileFormat(io::IReadFile* file) const
{
#ifdef _IRR_COMPILE_WITH_LIBPNG_
if (!file)
return false;
@ -75,16 +64,12 @@ bool CImageLoaderPng::isALoadableFileFormat(io::IReadFile* file) const
// Check if it really is a PNG file
return !png_sig_cmp(buffer, 0, 8);
#else
return false;
#endif // _IRR_COMPILE_WITH_LIBPNG_
}
// load in the image data
IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
{
#ifdef _IRR_COMPILE_WITH_LIBPNG_
if (!file)
return 0;
@ -95,14 +80,14 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
// Read the first few bytes of the PNG file
if( file->read(buffer, 8) != 8 )
{
os::Printer::log("LOAD PNG: can't read file\n", file->getFileName(), ELL_ERROR);
os::Printer::log("LOAD PNG: can't read file (filesize < 8)", file->getFileName(), ELL_ERROR);
return 0;
}
// Check if it really is a PNG file
if( png_sig_cmp(buffer, 0, 8) )
{
os::Printer::log("LOAD PNG: not really a png\n", file->getFileName(), ELL_ERROR);
os::Printer::log("LOAD PNG: not really a png (wrong signature)", file->getFileName(), ELL_ERROR);
return 0;
}
@ -111,7 +96,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
NULL, (png_error_ptr)png_cpexcept_error, (png_error_ptr)png_cpexcept_warn);
if (!png_ptr)
{
os::Printer::log("LOAD PNG: Internal PNG create read struct failure\n", file->getFileName(), ELL_ERROR);
os::Printer::log("LOAD PNG: Internal PNG create read struct failure", file->getFileName(), ELL_ERROR);
return 0;
}
@ -119,7 +104,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
os::Printer::log("LOAD PNG: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR);
os::Printer::log("LOAD PNG: Internal PNG create info struct failure", file->getFileName(), ELL_ERROR);
png_destroy_read_struct(&png_ptr, NULL, NULL);
return 0;
}
@ -227,7 +212,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
image = new CImage(ECF_R8G8B8, core::dimension2d<u32>(Width, Height));
if (!image)
{
os::Printer::log("LOAD PNG: Internal PNG create image struct failure\n", file->getFileName(), ELL_ERROR);
os::Printer::log("LOAD PNG: Internal PNG create image struct failure", file->getFileName(), ELL_ERROR);
png_destroy_read_struct(&png_ptr, NULL, NULL);
return 0;
}
@ -236,7 +221,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
RowPointers = new png_bytep[Height];
if (!RowPointers)
{
os::Printer::log("LOAD PNG: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR);
os::Printer::log("LOAD PNG: Internal PNG create row pointers failure", file->getFileName(), ELL_ERROR);
png_destroy_read_struct(&png_ptr, NULL, NULL);
delete image;
return 0;
@ -267,9 +252,6 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const
png_destroy_read_struct(&png_ptr,&info_ptr, 0); // Clean up memory
return image;
#else
return 0;
#endif // _IRR_COMPILE_WITH_LIBPNG_
}
@ -281,6 +263,3 @@ IImageLoader* createImageLoaderPNG()
}// end namespace irr
}//end namespace video
#endif

View File

@ -9,9 +9,6 @@
#ifndef __C_IMAGE_LOADER_PNG_H_INCLUDED__
#define __C_IMAGE_LOADER_PNG_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_PNG_LOADER_
#include "IImageLoader.h"
@ -41,5 +38,3 @@ public:
} // end namespace irr
#endif
#endif

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