Merge branch 'master' of github.com:supertuxkart/stk-code
This commit is contained in:
commit
fba22def40
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,13 +1,14 @@
|
||||
## SuperTuxKart 0.9.3
|
||||
* Reduced RAM and VRAM usage, reducing load times by Auria and Benau
|
||||
* New kart Wilbert by Jymis
|
||||
* New kart Hexley by Jymis
|
||||
* New mesh format optimized for space and hardware skinning
|
||||
* Code refactoring of both render pipeline by Benau and Elderme
|
||||
* New kart Wilber and Hexley by Jymis
|
||||
* New kart Kiki by Benau
|
||||
* New tracks Cornfield Crossing and Candela City by samuncle
|
||||
* Physics improvements and various physics bugfixes by hiker
|
||||
* Kart GFX improvements (exhaust and headlight)
|
||||
* In-game screen recording feature by Benau and Stragus
|
||||
* Bug fixes on the old render pipeline by Benau and Stragus
|
||||
* Hardware skinning
|
||||
* In-game screen recording powered by libopenglrecorder
|
||||
* High quality mipmap generation by Stragus
|
||||
* New smoother camera by Auria
|
||||
* New grand prix win scene
|
||||
* Gamepad configuration bugfixes
|
||||
|
@ -250,20 +250,14 @@ if(NOT USE_GLES2 AND NOT SERVER_ONLY)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
if(UNIX AND NOT APPLE AND NOT SERVER_ONLY)
|
||||
find_package(X11 REQUIRED)
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
|
||||
if(USE_LIBBFD)
|
||||
find_package(Libbfd)
|
||||
if(LIBBFD_FOUND)
|
||||
add_definitions(-DENABLE_LIBBFD)
|
||||
include_directories(${LIBBFD_INCLUDE_DIRS})
|
||||
else()
|
||||
set(USE_LIBBFD OFF CACHE BOOL "Use libbfd for crash reporting and leak check" FORCE)
|
||||
message(WARNING "Libbfd not found, disable integrated stack trace.")
|
||||
endif()
|
||||
if(USE_LIBBFD)
|
||||
find_package(Libbfd)
|
||||
if(LIBBFD_FOUND)
|
||||
add_definitions(-DENABLE_LIBBFD)
|
||||
include_directories(${LIBBFD_INCLUDE_DIRS})
|
||||
else()
|
||||
set(USE_LIBBFD OFF CACHE BOOL "Use libbfd for crash reporting and leak check" FORCE)
|
||||
message(WARNING "Libbfd not found, disable integrated stack trace.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -414,7 +408,6 @@ if(NOT SERVER_ONLY)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(supertuxkart ${X11_X11_LIB})
|
||||
if(USE_LIBBFD)
|
||||
target_link_libraries(supertuxkart ${LIBBFD_LIBRARIES})
|
||||
endif()
|
||||
|
@ -16,4 +16,6 @@
|
||||
<karts number="3"/>
|
||||
<requirements position="1"/>
|
||||
</easy>
|
||||
|
||||
<unlock kart="sara_the_wizard"/>
|
||||
</challenge>
|
||||
|
@ -10,10 +10,10 @@
|
||||
</hard>
|
||||
<medium>
|
||||
<karts number="4"/>
|
||||
<requirements time="185"/>
|
||||
<requirements time="187"/>
|
||||
</medium>
|
||||
<easy>
|
||||
<karts number="4"/>
|
||||
<requirements time="220"/>
|
||||
<requirements time="260"/>
|
||||
</easy>
|
||||
</challenge>
|
||||
|
@ -1,6 +1,6 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the supertuxkart package.
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: supertuxkart\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-09-13 06:18+0200\n"
|
||||
"POT-Creation-Date: 2017-10-04 20:58-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -196,7 +196,7 @@ msgstr ""
|
||||
#: src/states_screens/arenas_screen.cpp:83
|
||||
#: src/states_screens/easter_egg_screen.cpp:145
|
||||
#: src/states_screens/grand_prix_editor_screen.cpp:339
|
||||
#: src/states_screens/kart_selection.cpp:286
|
||||
#: src/states_screens/kart_selection.cpp:287
|
||||
#: src/states_screens/tracks_and_gp_screen.cpp:148
|
||||
msgid "Add-Ons"
|
||||
msgstr ""
|
||||
@ -216,7 +216,7 @@ msgstr ""
|
||||
#: src/states_screens/edit_track_screen.cpp:147
|
||||
#: src/states_screens/gp_info_screen.cpp:76
|
||||
#: src/states_screens/grand_prix_editor_screen.cpp:336
|
||||
#: src/states_screens/kart_selection.cpp:278
|
||||
#: src/states_screens/kart_selection.cpp:279
|
||||
#: src/states_screens/options_screen_video.cpp:456
|
||||
#: src/states_screens/tracks_and_gp_screen.cpp:138
|
||||
#: src/states_screens/tracks_screen.cpp:141
|
||||
@ -1818,6 +1818,10 @@ msgid ""
|
||||
"Karts!"
|
||||
msgstr ""
|
||||
|
||||
#. I18N: ../stk-assets/tracks/lasdunasarena/track.xml
|
||||
msgid "Las Dunas Arena"
|
||||
msgstr ""
|
||||
|
||||
#. I18N: ../stk-assets/tracks/lighthouse/track.xml
|
||||
msgid "Around the lighthouse"
|
||||
msgstr ""
|
||||
@ -1894,10 +1898,6 @@ msgstr ""
|
||||
msgid "Beastie"
|
||||
msgstr ""
|
||||
|
||||
#. I18N: ../stk-assets/karts/elephpant/kart.xml
|
||||
msgid "Elephpant"
|
||||
msgstr ""
|
||||
|
||||
#. I18N: ../stk-assets/karts/emule/kart.xml
|
||||
msgid "Emule"
|
||||
msgstr ""
|
||||
@ -1914,6 +1914,10 @@ msgstr ""
|
||||
msgid "Hexley"
|
||||
msgstr ""
|
||||
|
||||
#. I18N: ../stk-assets/karts/kiki/kart.xml
|
||||
msgid "Kiki"
|
||||
msgstr ""
|
||||
|
||||
#. I18N: ../stk-assets/karts/konqi/kart.xml
|
||||
msgid "Konqi"
|
||||
msgstr ""
|
||||
@ -2031,20 +2035,20 @@ msgid ""
|
||||
"created."
|
||||
msgstr ""
|
||||
|
||||
#: src/graphics/irr_driver.cpp:618
|
||||
#: src/graphics/irr_driver.cpp:535
|
||||
msgid "Video recording started."
|
||||
msgstr ""
|
||||
|
||||
#: src/graphics/irr_driver.cpp:624
|
||||
#: src/graphics/irr_driver.cpp:541
|
||||
#, c-format
|
||||
msgid "Video saved in \"%s\"."
|
||||
msgstr ""
|
||||
|
||||
#: src/graphics/irr_driver.cpp:628
|
||||
#: src/graphics/irr_driver.cpp:545
|
||||
msgid "Encoding progress:"
|
||||
msgstr ""
|
||||
|
||||
#: src/graphics/irr_driver.cpp:1801
|
||||
#: src/graphics/irr_driver.cpp:1682
|
||||
#, c-format
|
||||
msgid "FPS: %d/%d/%d - %d KTris"
|
||||
msgstr ""
|
||||
@ -2053,26 +2057,14 @@ msgstr ""
|
||||
msgid "Loading"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiengine/widgets/kart_stats_widget.cpp:108
|
||||
msgid "WEIGHT"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiengine/widgets/kart_stats_widget.cpp:113
|
||||
msgid "SPEED"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiengine/widgets/kart_stats_widget.cpp:117
|
||||
msgid "POWER"
|
||||
msgstr ""
|
||||
|
||||
#. I18N: 'handicapped' indicates that per-player handicaps are
|
||||
#. activated for this kart (i.e. it will drive slower)
|
||||
#: src/guiengine/widgets/player_kart_widget.cpp:381
|
||||
#: src/guiengine/widgets/player_kart_widget.cpp:392
|
||||
#, c-format
|
||||
msgid "%s (handicapped)"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiengine/widgets/player_kart_widget.cpp:440
|
||||
#: src/guiengine/widgets/player_kart_widget.cpp:451
|
||||
#, c-format
|
||||
msgid "%s is ready"
|
||||
msgstr ""
|
||||
@ -2739,7 +2731,7 @@ msgstr ""
|
||||
msgid "You finished the race!"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1500
|
||||
#: src/main.cpp:1501
|
||||
msgid ""
|
||||
"SuperTuxKart may connect to a server to download add-ons and notify you of "
|
||||
"updates. We also collect anonymous hardware statistics to help with the "
|
||||
@ -2749,16 +2741,16 @@ msgid ""
|
||||
"edit \"Connect to the Internet\" and \"Send anonymous HW statistics\")."
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1653
|
||||
#: src/main.cpp:1654
|
||||
msgid "Your screen resolution is too low to run STK."
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1667
|
||||
#: src/main.cpp:1668
|
||||
msgid ""
|
||||
"Your driver version is too old. Please install the latest video drivers."
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1684
|
||||
#: src/main.cpp:1685
|
||||
#, c-format
|
||||
msgid ""
|
||||
"Your OpenGL version appears to be too old. Please verify if an update for "
|
||||
@ -2972,7 +2964,7 @@ msgstr ""
|
||||
#. I18N: track group name
|
||||
#: src/states_screens/arenas_screen.cpp:81
|
||||
#: src/states_screens/easter_egg_screen.cpp:143
|
||||
#: src/states_screens/kart_selection.cpp:284
|
||||
#: src/states_screens/kart_selection.cpp:285
|
||||
#: src/states_screens/tracks_and_gp_screen.cpp:146
|
||||
msgid "standard"
|
||||
msgstr ""
|
||||
@ -2981,8 +2973,8 @@ msgstr ""
|
||||
#: src/states_screens/arenas_screen.cpp:327
|
||||
#: src/states_screens/easter_egg_screen.cpp:225
|
||||
#: src/states_screens/easter_egg_screen.cpp:256
|
||||
#: src/states_screens/kart_selection.cpp:859
|
||||
#: src/states_screens/kart_selection.cpp:1464
|
||||
#: src/states_screens/kart_selection.cpp:864
|
||||
#: src/states_screens/kart_selection.cpp:1481
|
||||
#: src/states_screens/race_setup_screen.cpp:99
|
||||
msgid "Locked : solve active challenges to gain access to more!"
|
||||
msgstr ""
|
||||
@ -3347,32 +3339,32 @@ msgstr ""
|
||||
msgid "Select a track"
|
||||
msgstr ""
|
||||
|
||||
#: src/states_screens/feature_unlocked.cpp:200
|
||||
#: src/states_screens/feature_unlocked.cpp:201
|
||||
#, c-format
|
||||
msgid "You completed the easy challenge! Points earned on this level: %i/%i"
|
||||
msgstr ""
|
||||
|
||||
#: src/states_screens/feature_unlocked.cpp:204
|
||||
#: src/states_screens/feature_unlocked.cpp:205
|
||||
#, c-format
|
||||
msgid ""
|
||||
"You completed the intermediate challenge! Points earned on this level: %i/%i"
|
||||
msgstr ""
|
||||
|
||||
#: src/states_screens/feature_unlocked.cpp:208
|
||||
#: src/states_screens/feature_unlocked.cpp:209
|
||||
#, c-format
|
||||
msgid ""
|
||||
"You completed the difficult challenge! Points earned on this level: %i/%i"
|
||||
msgstr ""
|
||||
|
||||
#: src/states_screens/feature_unlocked.cpp:493
|
||||
#: src/states_screens/feature_unlocked.cpp:494
|
||||
msgid "Challenge Completed"
|
||||
msgstr ""
|
||||
|
||||
#: src/states_screens/feature_unlocked.cpp:530
|
||||
#: src/states_screens/feature_unlocked.cpp:531
|
||||
msgid "You unlocked track %0"
|
||||
msgstr ""
|
||||
|
||||
#: src/states_screens/feature_unlocked.cpp:568
|
||||
#: src/states_screens/feature_unlocked.cpp:569
|
||||
msgid "You unlocked grand prix %0"
|
||||
msgstr ""
|
||||
|
||||
@ -3430,7 +3422,7 @@ msgid "Name is too long."
|
||||
msgstr ""
|
||||
|
||||
#. I18N: when failing a GP
|
||||
#: src/states_screens/grand_prix_lose.cpp:154
|
||||
#: src/states_screens/grand_prix_lose.cpp:155
|
||||
msgid "Better luck next time!"
|
||||
msgstr ""
|
||||
|
||||
@ -3443,16 +3435,16 @@ msgstr ""
|
||||
msgid "You completed the Grand Prix!"
|
||||
msgstr ""
|
||||
|
||||
#: src/states_screens/kart_selection.cpp:840
|
||||
#: src/states_screens/kart_selection.cpp:1482
|
||||
#: src/states_screens/kart_selection.cpp:843
|
||||
#: src/states_screens/kart_selection.cpp:1499
|
||||
msgid "Random Kart"
|
||||
msgstr ""
|
||||
|
||||
#: src/states_screens/kart_selection.cpp:854
|
||||
#: src/states_screens/kart_selection.cpp:859
|
||||
msgid "Locked"
|
||||
msgstr ""
|
||||
|
||||
#: src/states_screens/kart_selection.cpp:944
|
||||
#: src/states_screens/kart_selection.cpp:961
|
||||
msgid ""
|
||||
"Everyone:\n"
|
||||
"Press the 'Select' button to join the game"
|
||||
|
File diff suppressed because it is too large
Load Diff
1958
data/replay/standard_expert_candela_city.replay
Normal file
1958
data/replay/standard_expert_candela_city.replay
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,12 @@ uniform float track_x;
|
||||
uniform float track_z;
|
||||
uniform float track_x_len;
|
||||
uniform float track_z_len;
|
||||
|
||||
#ifndef GL_ES
|
||||
uniform samplerBuffer heightmap;
|
||||
#else
|
||||
uniform sampler2D heightmap;
|
||||
#endif
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout (location = 4) in vec3 particle_position_initial;
|
||||
@ -45,7 +50,12 @@ void main(void)
|
||||
int i = int(i_as_float);
|
||||
int j = int(j_as_float);
|
||||
|
||||
#ifndef GL_ES
|
||||
float h = particle_position.y - texelFetch(heightmap, i * 256 + j).r;
|
||||
#else
|
||||
float h = particle_position.y - texelFetch(heightmap, ivec2(j, i), 0).r;
|
||||
#endif
|
||||
|
||||
reset = h < 0.;
|
||||
|
||||
vec4 initialposition = sourcematrix * vec4(particle_position_initial, 1.0);
|
||||
|
@ -36,9 +36,7 @@ float getShadowFactor(vec3 pos, int index)
|
||||
{
|
||||
for (float j = -1.; j <= 1.; j += 1.)
|
||||
{
|
||||
// result += texture(shadowtex, vec4(shadowtexcoord + vec2(i,j) / shadow_res, float(index), d));
|
||||
// Added a hack with j+1. to avoid ugly lines
|
||||
result += texture(shadowtex, vec4(shadowtexcoord + vec2(i,j+1.) / shadow_res, float(index), d));
|
||||
result += texture(shadowtex, vec4(shadowtexcoord + vec2(i,j) / shadow_res, float(index), d));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,8 +144,6 @@ source/Irrlicht/CImageWriterBMP.cpp
|
||||
source/Irrlicht/CImageWriterJPG.cpp
|
||||
source/Irrlicht/CImageWriterPNG.cpp
|
||||
source/Irrlicht/CIrrDeviceAndroid.cpp
|
||||
source/Irrlicht/CIrrDeviceConsole.cpp
|
||||
source/Irrlicht/CIrrDeviceFB.cpp
|
||||
source/Irrlicht/CIrrDeviceLinux.cpp
|
||||
source/Irrlicht/CIrrDeviceSDL.cpp
|
||||
source/Irrlicht/CIrrDeviceStub.cpp
|
||||
@ -278,8 +276,6 @@ source/Irrlicht/CImageWriterBMP.h
|
||||
source/Irrlicht/CImageWriterJPG.h
|
||||
source/Irrlicht/CImageWriterPNG.h
|
||||
source/Irrlicht/CIrrDeviceAndroid.h
|
||||
source/Irrlicht/CIrrDeviceConsole.h
|
||||
source/Irrlicht/CIrrDeviceFB.h
|
||||
source/Irrlicht/CIrrDeviceLinux.h
|
||||
source/Irrlicht/CIrrDeviceSDL.h
|
||||
source/Irrlicht/CIrrDeviceStub.h
|
||||
|
@ -32,12 +32,9 @@
|
||||
//! 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_WINDOWS_CE_DEVICE_ for Windows CE 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
|
||||
//! _IRR_COMPILE_WITH_CONSOLE_DEVICE_ for no windowing system, used as a fallback
|
||||
//! _IRR_COMPILE_WITH_FB_DEVICE_ for framebuffer systems
|
||||
|
||||
//! 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).
|
||||
@ -52,11 +49,6 @@
|
||||
#undef _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#endif
|
||||
|
||||
//! Comment this line to compile without the fallback console device.
|
||||
#define _IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
||||
#ifdef NO_IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
||||
#undef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
||||
#endif
|
||||
|
||||
//! WIN32 for Windows32
|
||||
//! WIN64 for Windows64
|
||||
@ -67,13 +59,6 @@
|
||||
#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
#endif
|
||||
|
||||
//! WINCE is a very restricted environment for mobile devices
|
||||
#if defined(_WIN32_WCE)
|
||||
#define _IRR_WINDOWS_
|
||||
#define _IRR_WINDOWS_API_
|
||||
#define _IRR_WINDOWS_CE_PLATFORM_
|
||||
#define _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1300)
|
||||
# error "Only Microsoft Visual Studio 7.0 and later are supported."
|
||||
|
@ -240,6 +240,15 @@ namespace irr
|
||||
//! Restore the window to normal size if possible.
|
||||
virtual void restoreWindow() =0;
|
||||
|
||||
//! Move window to requested position
|
||||
/** \return true if success */
|
||||
virtual bool moveWindow(int x, int y) = 0;
|
||||
|
||||
//! Get current window position.
|
||||
/** \return true if success */
|
||||
virtual bool getWindowPosition(int* x, int* y) = 0;
|
||||
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
/** Irrlicht contains support for joysticks, but does not generate joystick events by default,
|
||||
as this would consume joystick info that 3rd party libraries might rely on. Call this method to
|
||||
|
@ -33,6 +33,16 @@ bool CIrrDeviceAndroid::IsPaused = true;
|
||||
bool CIrrDeviceAndroid::IsFocused = false;
|
||||
bool CIrrDeviceAndroid::IsStarted = false;
|
||||
|
||||
// Execution of android_main() function is a kind of "onCreate" event, so this
|
||||
// function should be used there to make sure that global window state variables
|
||||
// have their default values on startup.
|
||||
void CIrrDeviceAndroid::onCreate()
|
||||
{
|
||||
IsPaused = true;
|
||||
IsFocused = false;
|
||||
IsStarted = false;
|
||||
}
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
|
||||
: CIrrDeviceStub(param),
|
||||
@ -276,6 +286,18 @@ void CIrrDeviceAndroid::restoreWindow()
|
||||
{
|
||||
}
|
||||
|
||||
bool CIrrDeviceAndroid::moveWindow(int x, int y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CIrrDeviceAndroid::getWindowPosition(int* x, int* y)
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
E_DEVICE_TYPE CIrrDeviceAndroid::getType() const
|
||||
{
|
||||
return EIDT_ANDROID;
|
||||
|
@ -47,6 +47,8 @@ namespace irr
|
||||
virtual void minimizeWindow();
|
||||
virtual void maximizeWindow();
|
||||
virtual void restoreWindow();
|
||||
virtual bool moveWindow(int x, int y);
|
||||
virtual bool getWindowPosition(int* x, int* y);
|
||||
virtual E_DEVICE_TYPE getType() const;
|
||||
virtual bool activateAccelerometer(float updateInterval);
|
||||
virtual bool deactivateAccelerometer();
|
||||
@ -94,6 +96,8 @@ namespace irr
|
||||
private:
|
||||
core::position2d<s32> CursorPos;
|
||||
};
|
||||
|
||||
static void onCreate();
|
||||
|
||||
private:
|
||||
android_app* Android;
|
||||
|
@ -1,477 +0,0 @@
|
||||
// Copyright (C) 2009-2012 Gaz Davidson
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CIrrDeviceConsole.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
||||
|
||||
#include "os.h"
|
||||
#include "IGUISkin.h"
|
||||
#include "IGUIEnvironment.h"
|
||||
|
||||
// to close the device on terminate signal
|
||||
irr::CIrrDeviceConsole *DeviceToClose;
|
||||
|
||||
#ifdef _IRR_WINDOWS_NT_CONSOLE_
|
||||
// Callback for Windows
|
||||
BOOL WINAPI ConsoleHandler(DWORD CEvent)
|
||||
{
|
||||
switch(CEvent)
|
||||
{
|
||||
case CTRL_C_EVENT:
|
||||
irr::os::Printer::log("Closing console device", "CTRL+C");
|
||||
break;
|
||||
case CTRL_BREAK_EVENT:
|
||||
irr::os::Printer::log("Closing console device", "CTRL+Break");
|
||||
break;
|
||||
case CTRL_CLOSE_EVENT:
|
||||
irr::os::Printer::log("Closing console device", "User closed console");
|
||||
break;
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
irr::os::Printer::log("Closing console device", "User is logging off");
|
||||
break;
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
irr::os::Printer::log("Closing console device", "Computer shutting down");
|
||||
break;
|
||||
}
|
||||
DeviceToClose->closeDevice();
|
||||
return TRUE;
|
||||
}
|
||||
#elif defined(_IRR_POSIX_API_)
|
||||
// sigterm handler
|
||||
#include <signal.h>
|
||||
|
||||
void sighandler(int sig)
|
||||
{
|
||||
irr::core::stringc code = "Signal ";
|
||||
code += sig;
|
||||
code += " received";
|
||||
irr::os::Printer::log("Closing console device", code.c_str());
|
||||
|
||||
DeviceToClose->closeDevice();
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
const c8 ASCIIArtChars[] = " .,'~:;!+>=icopjtJY56SB8XDQKHNWM"; //MWNHKQDX8BS65YJtjpoci=+>!;:~',. ";
|
||||
const u16 ASCIIArtCharsCount = 32;
|
||||
|
||||
//const c8 ASCIIArtChars[] = " \xb0\xb1\xf9\xb2\xdb";
|
||||
//const u16 ASCIIArtCharsCount = 5;
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params)
|
||||
: CIrrDeviceStub(params), IsWindowFocused(true), ConsoleFont(0), OutFile(stdout)
|
||||
{
|
||||
DeviceToClose = this;
|
||||
|
||||
#ifdef _IRR_WINDOWS_NT_CONSOLE_
|
||||
MouseButtonStates = 0;
|
||||
|
||||
WindowsSTDIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
WindowsSTDOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
PCOORD Dimensions = 0;
|
||||
|
||||
if (CreationParams.Fullscreen)
|
||||
{
|
||||
// Some mingw versions lack this define, so avoid it in case it does not exist
|
||||
#if (_WIN32_WINNT >= 0x0501) && defined(CONSOLE_FULLSCREEN_MODE)
|
||||
if (SetConsoleDisplayMode(WindowsSTDOut, CONSOLE_FULLSCREEN_MODE, Dimensions))
|
||||
{
|
||||
CreationParams.WindowSize.Width = Dimensions->X;
|
||||
CreationParams.WindowSize.Width = Dimensions->Y;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
COORD ConsoleSize;
|
||||
ConsoleSize.X = CreationParams.WindowSize.Width;
|
||||
ConsoleSize.X = CreationParams.WindowSize.Height;
|
||||
SetConsoleScreenBufferSize(WindowsSTDOut, ConsoleSize);
|
||||
}
|
||||
|
||||
// catch windows close/break signals
|
||||
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE);
|
||||
|
||||
#elif defined(_IRR_POSIX_API_)
|
||||
// catch other signals
|
||||
signal(SIGABRT, &sighandler);
|
||||
signal(SIGTERM, &sighandler);
|
||||
signal(SIGINT, &sighandler);
|
||||
|
||||
// set output stream
|
||||
if (params.WindowId)
|
||||
OutFile = (FILE*)(params.WindowId);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_VT100_CONSOLE_
|
||||
// reset terminal
|
||||
fprintf(OutFile, "%cc", 27);
|
||||
// disable line wrapping
|
||||
fprintf(OutFile, "%c[7l", 27);
|
||||
#endif
|
||||
|
||||
switch (params.DriverType)
|
||||
{
|
||||
case video::EDT_SOFTWARE:
|
||||
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
|
||||
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("Software driver was not compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case video::EDT_BURNINGSVIDEO:
|
||||
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case video::EDT_DIRECT3D8:
|
||||
case video::EDT_DIRECT3D9:
|
||||
case video::EDT_OPENGL:
|
||||
os::Printer::log("The console device cannot use hardware drivers yet.", ELL_ERROR);
|
||||
break;
|
||||
case video::EDT_NULL:
|
||||
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// set up output buffer
|
||||
for (u32 y=0; y<CreationParams.WindowSize.Height; ++y)
|
||||
{
|
||||
core::stringc str;
|
||||
str.reserve(CreationParams.WindowSize.Width);
|
||||
for (u32 x=0; x<CreationParams.WindowSize.Width; ++x)
|
||||
str += " ";
|
||||
OutputBuffer.push_back(str);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _IRR_WINDOWS_NT_CONSOLE_
|
||||
CursorControl = new CCursorControl(CreationParams.WindowSize);
|
||||
#endif
|
||||
|
||||
if (VideoDriver)
|
||||
{
|
||||
createGUIAndScene();
|
||||
#ifdef _IRR_USE_CONSOLE_FONT_
|
||||
if (GUIEnvironment)
|
||||
{
|
||||
ConsoleFont = new gui::CGUIConsoleFont(this);
|
||||
gui::IGUISkin *skin = GUIEnvironment->getSkin();
|
||||
if (skin)
|
||||
{
|
||||
for (u32 i=0; i < gui::EGDF_COUNT; ++i)
|
||||
skin->setFont(ConsoleFont, gui::EGUI_DEFAULT_FONT(i));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//! destructor
|
||||
CIrrDeviceConsole::~CIrrDeviceConsole()
|
||||
{
|
||||
// GUI and scene are dropped in the stub
|
||||
if (CursorControl)
|
||||
{
|
||||
CursorControl->drop();
|
||||
CursorControl = 0;
|
||||
}
|
||||
if (ConsoleFont)
|
||||
{
|
||||
ConsoleFont->drop();
|
||||
ConsoleFont = 0;
|
||||
}
|
||||
#ifdef _IRR_VT100_CONSOLE_
|
||||
// reset terminal
|
||||
fprintf(OutFile, "%cc", 27);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! runs the device. Returns false if device wants to be deleted
|
||||
bool CIrrDeviceConsole::run()
|
||||
{
|
||||
// increment timer
|
||||
os::Timer::tick();
|
||||
|
||||
// process Windows console input
|
||||
#ifdef _IRR_WINDOWS_NT_CONSOLE_
|
||||
|
||||
INPUT_RECORD in;
|
||||
DWORD oldMode;
|
||||
DWORD count, waste;
|
||||
|
||||
// get old input mode
|
||||
GetConsoleMode(WindowsSTDIn, &oldMode);
|
||||
SetConsoleMode(WindowsSTDIn, ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT);
|
||||
|
||||
GetNumberOfConsoleInputEvents(WindowsSTDIn, &count);
|
||||
|
||||
// read keyboard and mouse input
|
||||
while (count)
|
||||
{
|
||||
ReadConsoleInput(WindowsSTDIn, &in, 1, &waste );
|
||||
switch(in.EventType)
|
||||
{
|
||||
case KEY_EVENT:
|
||||
{
|
||||
SEvent e;
|
||||
e.EventType = EET_KEY_INPUT_EVENT;
|
||||
e.KeyInput.PressedDown = (in.Event.KeyEvent.bKeyDown == TRUE);
|
||||
e.KeyInput.Control = (in.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0;
|
||||
e.KeyInput.Shift = (in.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) != 0;
|
||||
e.KeyInput.Key = EKEY_CODE(in.Event.KeyEvent.wVirtualKeyCode);
|
||||
e.KeyInput.Char = in.Event.KeyEvent.uChar.UnicodeChar;
|
||||
postEventFromUser(e);
|
||||
break;
|
||||
}
|
||||
case MOUSE_EVENT:
|
||||
{
|
||||
SEvent e;
|
||||
e.EventType = EET_MOUSE_INPUT_EVENT;
|
||||
e.MouseInput.X = in.Event.MouseEvent.dwMousePosition.X;
|
||||
e.MouseInput.Y = in.Event.MouseEvent.dwMousePosition.Y;
|
||||
e.MouseInput.Wheel = 0.f;
|
||||
e.MouseInput.ButtonStates =
|
||||
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) ? EMBSM_LEFT : 0 ) |
|
||||
( (in.Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED) ? EMBSM_RIGHT : 0 ) |
|
||||
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED) ? EMBSM_MIDDLE : 0 ) |
|
||||
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_3RD_BUTTON_PRESSED) ? EMBSM_EXTRA1 : 0 ) |
|
||||
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_4TH_BUTTON_PRESSED) ? EMBSM_EXTRA2 : 0 );
|
||||
|
||||
if (in.Event.MouseEvent.dwEventFlags & MOUSE_MOVED)
|
||||
{
|
||||
CursorControl->setPosition(core::position2di(e.MouseInput.X, e.MouseInput.Y));
|
||||
|
||||
// create mouse moved event
|
||||
e.MouseInput.Event = EMIE_MOUSE_MOVED;
|
||||
postEventFromUser(e);
|
||||
}
|
||||
|
||||
if (in.Event.MouseEvent.dwEventFlags & MOUSE_WHEELED)
|
||||
{
|
||||
e.MouseInput.Event = EMIE_MOUSE_WHEEL;
|
||||
e.MouseInput.Wheel = (in.Event.MouseEvent.dwButtonState & 0xFF000000) ? -1.0f : 1.0f;
|
||||
postEventFromUser(e);
|
||||
}
|
||||
|
||||
if ( (MouseButtonStates & EMBSM_LEFT) != (e.MouseInput.ButtonStates & EMBSM_LEFT) )
|
||||
{
|
||||
e.MouseInput.Event = (e.MouseInput.ButtonStates & EMBSM_LEFT) ? EMIE_LMOUSE_PRESSED_DOWN : EMIE_LMOUSE_LEFT_UP;
|
||||
postEventFromUser(e);
|
||||
}
|
||||
|
||||
if ( (MouseButtonStates & EMBSM_RIGHT) != (e.MouseInput.ButtonStates & EMBSM_RIGHT) )
|
||||
{
|
||||
e.MouseInput.Event = (e.MouseInput.ButtonStates & EMBSM_RIGHT) ? EMIE_RMOUSE_PRESSED_DOWN : EMIE_RMOUSE_LEFT_UP;
|
||||
postEventFromUser(e);
|
||||
}
|
||||
|
||||
if ( (MouseButtonStates & EMBSM_MIDDLE) != (e.MouseInput.ButtonStates & EMBSM_MIDDLE) )
|
||||
{
|
||||
e.MouseInput.Event = (e.MouseInput.ButtonStates & EMBSM_MIDDLE) ? EMIE_MMOUSE_PRESSED_DOWN : EMIE_MMOUSE_LEFT_UP;
|
||||
postEventFromUser(e);
|
||||
}
|
||||
|
||||
// save current button states
|
||||
MouseButtonStates = e.MouseInput.ButtonStates;
|
||||
|
||||
break;
|
||||
}
|
||||
case WINDOW_BUFFER_SIZE_EVENT:
|
||||
VideoDriver->OnResize(
|
||||
core::dimension2d<u32>(in.Event.WindowBufferSizeEvent.dwSize.X,
|
||||
in.Event.WindowBufferSizeEvent.dwSize.Y));
|
||||
break;
|
||||
case FOCUS_EVENT:
|
||||
IsWindowFocused = (in.Event.FocusEvent.bSetFocus == TRUE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
GetNumberOfConsoleInputEvents(WindowsSTDIn, &count);
|
||||
}
|
||||
|
||||
// set input mode
|
||||
SetConsoleMode(WindowsSTDIn, oldMode);
|
||||
#else
|
||||
// todo: keyboard input from terminal in raw mode
|
||||
#endif
|
||||
|
||||
return !Close;
|
||||
}
|
||||
|
||||
//! Cause the device to temporarily pause execution and let other processes to run
|
||||
// This should bring down processor usage without major performance loss for Irrlicht
|
||||
void CIrrDeviceConsole::yield()
|
||||
{
|
||||
#ifdef _IRR_WINDOWS_API_
|
||||
Sleep(1);
|
||||
#else
|
||||
struct timespec ts = {0,0};
|
||||
nanosleep(&ts, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Pause execution and let other processes to run for a specified amount of time.
|
||||
void CIrrDeviceConsole::sleep(u32 timeMs, bool pauseTimer)
|
||||
{
|
||||
const bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
|
||||
#ifdef _IRR_WINDOWS_API_
|
||||
Sleep(timeMs);
|
||||
#else
|
||||
struct timespec ts;
|
||||
ts.tv_sec = (time_t) (timeMs / 1000);
|
||||
ts.tv_nsec = (long) (timeMs % 1000) * 1000000;
|
||||
|
||||
if (pauseTimer && !wasStopped)
|
||||
Timer->stop();
|
||||
|
||||
nanosleep(&ts, NULL);
|
||||
#endif
|
||||
|
||||
if (pauseTimer && !wasStopped)
|
||||
Timer->start();
|
||||
}
|
||||
|
||||
//! sets the caption of the window
|
||||
void CIrrDeviceConsole::setWindowCaption(const wchar_t* text)
|
||||
{
|
||||
#ifdef _IRR_WINDOWS_NT_CONSOLE_
|
||||
SetConsoleTitleW(text);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
bool CIrrDeviceConsole::isWindowActive() const
|
||||
{
|
||||
// there is no window, but we always assume it is active
|
||||
return true;
|
||||
}
|
||||
|
||||
//! returns if window has focus
|
||||
bool CIrrDeviceConsole::isWindowFocused() const
|
||||
{
|
||||
return IsWindowFocused;
|
||||
}
|
||||
|
||||
//! returns if window is minimized
|
||||
bool CIrrDeviceConsole::isWindowMinimized() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//! presents a surface in the client area
|
||||
bool CIrrDeviceConsole::present(video::IImage* surface, void* windowId, core::rect<s32>* src)
|
||||
{
|
||||
|
||||
if (surface)
|
||||
{
|
||||
for (u32 y=0; y < surface->getDimension().Height; ++y)
|
||||
{
|
||||
for (u32 x=0; x< surface->getDimension().Width; ++x)
|
||||
{
|
||||
// get average pixel
|
||||
u32 avg = surface->getPixel(x,y).getAverage() * (ASCIIArtCharsCount-1);
|
||||
avg /= 255;
|
||||
OutputBuffer[y] [x] = ASCIIArtChars[avg];
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef _IRR_USE_CONSOLE_FONT_
|
||||
for (u32 i=0; i< Text.size(); ++i)
|
||||
{
|
||||
s32 y = Text[i].Pos.Y;
|
||||
|
||||
if ( y < (s32)OutputBuffer.size() && y > 0)
|
||||
for (u32 c=0; c < Text[i].Text.size() && c + Text[i].Pos.X < OutputBuffer[y].size(); ++c)
|
||||
//if (Text[i].Text[c] != ' ')
|
||||
OutputBuffer[y] [c+Text[i].Pos.X] = Text[i].Text[c];
|
||||
}
|
||||
Text.clear();
|
||||
#endif
|
||||
|
||||
// draw output
|
||||
for (u32 y=0; y<OutputBuffer.size(); ++y)
|
||||
{
|
||||
setTextCursorPos(0,y);
|
||||
fprintf(OutFile, "%s", OutputBuffer[y].c_str());
|
||||
}
|
||||
return surface != 0;
|
||||
}
|
||||
|
||||
//! notifies the device that it should close itself
|
||||
void CIrrDeviceConsole::closeDevice()
|
||||
{
|
||||
// return false next time we run()
|
||||
Close = true;
|
||||
}
|
||||
|
||||
|
||||
//! Sets if the window should be resizable in windowed mode.
|
||||
void CIrrDeviceConsole::setResizable(bool resize)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
//! Minimize the window.
|
||||
void CIrrDeviceConsole::minimizeWindow()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
//! Maximize window
|
||||
void CIrrDeviceConsole::maximizeWindow()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
//! Restore original window size
|
||||
void CIrrDeviceConsole::restoreWindow()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void CIrrDeviceConsole::setTextCursorPos(s16 x, s16 y)
|
||||
{
|
||||
#ifdef _IRR_WINDOWS_NT_CONSOLE_
|
||||
// move WinNT cursor
|
||||
COORD Position;
|
||||
Position.X = x;
|
||||
Position.Y = y;
|
||||
SetConsoleCursorPosition(WindowsSTDOut, Position);
|
||||
#elif defined(_IRR_VT100_CONSOLE_)
|
||||
// send escape code
|
||||
fprintf(OutFile, "%c[%d;%dH", 27, y, x);
|
||||
#else
|
||||
// not implemented
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIrrDeviceConsole::addPostPresentText(s16 X, s16 Y, const wchar_t *text)
|
||||
{
|
||||
SPostPresentText p;
|
||||
p.Text = text;
|
||||
p.Pos.X = X;
|
||||
p.Pos.Y = Y;
|
||||
Text.push_back(p);
|
||||
}
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
@ -1,333 +0,0 @@
|
||||
// Copyright (C) 2009-2012 Gaz Davidson
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_IRR_DEVICE_CONSOLE_H_INCLUDED__
|
||||
#define __C_IRR_DEVICE_CONSOLE_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
||||
|
||||
//#define _IRR_USE_CONSOLE_FONT_
|
||||
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include "CIrrDeviceStub.h"
|
||||
#include "IImagePresenter.h"
|
||||
// for console font
|
||||
#include "IGUIFont.h"
|
||||
|
||||
#ifdef _IRR_WINDOWS_API_
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#if !defined(_IRR_XBOX_PLATFORM_)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#if(_WIN32_WINNT >= 0x0500)
|
||||
#define _IRR_WINDOWS_NT_CONSOLE_
|
||||
#endif
|
||||
#else
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
// for now we assume all other terminal types are VT100
|
||||
#ifndef _IRR_WINDOWS_NT_CONSOLE_
|
||||
#define _IRR_VT100_CONSOLE_
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
class CIrrDeviceConsole : public CIrrDeviceStub, video::IImagePresenter
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceConsole(const SIrrlichtCreationParameters& params);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceConsole();
|
||||
|
||||
//! runs the device. Returns false if device wants to be deleted
|
||||
virtual bool run();
|
||||
|
||||
//! Cause the device to temporarily pause execution and let other processes to run
|
||||
// This should bring down processor usage without major performance loss for Irrlicht
|
||||
virtual void yield();
|
||||
|
||||
//! Pause execution and let other processes to run for a specified amount of time.
|
||||
virtual void sleep(u32 timeMs, bool pauseTimer);
|
||||
|
||||
//! sets the caption of the window
|
||||
virtual void setWindowCaption(const wchar_t* text);
|
||||
|
||||
//! sets the class of the window
|
||||
virtual void setWindowClass(const char* text) {}
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
virtual bool isWindowActive() const;
|
||||
|
||||
//! returns if window has focus
|
||||
virtual bool isWindowFocused() const;
|
||||
|
||||
//! returns if window is minimized
|
||||
virtual bool isWindowMinimized() const;
|
||||
|
||||
//! presents a surface in the client area
|
||||
virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0);
|
||||
|
||||
//! notifies the device that it should close itself
|
||||
virtual void closeDevice();
|
||||
|
||||
//! Sets if the window should be resizable in windowed mode.
|
||||
virtual void setResizable(bool resize=false);
|
||||
|
||||
//! Minimizes the window.
|
||||
virtual void minimizeWindow();
|
||||
|
||||
//! Maximizes the window.
|
||||
virtual void maximizeWindow();
|
||||
|
||||
//! Restores the window size.
|
||||
virtual void restoreWindow();
|
||||
|
||||
//! Get the device type
|
||||
virtual E_DEVICE_TYPE getType() const
|
||||
{
|
||||
return EIDT_CONSOLE;
|
||||
}
|
||||
|
||||
void addPostPresentText(s16 X, s16 Y, const wchar_t *text);
|
||||
|
||||
//! Implementation of the win32 console mouse cursor
|
||||
class CCursorControl : public gui::ICursorControl
|
||||
{
|
||||
public:
|
||||
|
||||
CCursorControl(const core::dimension2d<u32>& wsize)
|
||||
: WindowSize(wsize), InvWindowSize(0.0f, 0.0f), IsVisible(true), UseReferenceRect(false)
|
||||
{
|
||||
if (WindowSize.Width!=0)
|
||||
InvWindowSize.Width = 1.0f / WindowSize.Width;
|
||||
|
||||
if (WindowSize.Height!=0)
|
||||
InvWindowSize.Height = 1.0f / WindowSize.Height;
|
||||
}
|
||||
|
||||
//! Changes the visible state of the mouse cursor.
|
||||
virtual void setVisible(bool visible)
|
||||
{
|
||||
if(visible != IsVisible)
|
||||
{
|
||||
IsVisible = visible;
|
||||
setPosition(CursorPos.X, CursorPos.Y);
|
||||
}
|
||||
}
|
||||
|
||||
//! Returns if the cursor is currently visible.
|
||||
virtual bool isVisible() const
|
||||
{
|
||||
return IsVisible;
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(const core::position2d<f32> &pos)
|
||||
{
|
||||
setPosition(pos.X, pos.Y);
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(f32 x, f32 y)
|
||||
{
|
||||
if (!UseReferenceRect)
|
||||
setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height));
|
||||
else
|
||||
setPosition((s32)(x*ReferenceRect.getWidth()), (s32)(y*ReferenceRect.getHeight()));
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(const core::position2d<s32> &pos)
|
||||
{
|
||||
setPosition(pos.X, pos.Y);
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(s32 x, s32 y)
|
||||
{
|
||||
setInternalCursorPosition(core::position2di(x,y));
|
||||
}
|
||||
|
||||
//! Returns the current position of the mouse cursor.
|
||||
virtual const core::position2d<s32>& getPosition()
|
||||
{
|
||||
return CursorPos;
|
||||
}
|
||||
|
||||
//! Returns the current position of the mouse cursor.
|
||||
virtual core::position2d<f32> getRelativePosition()
|
||||
{
|
||||
if (!UseReferenceRect)
|
||||
{
|
||||
return core::position2d<f32>(CursorPos.X * InvWindowSize.Width,
|
||||
CursorPos.Y * InvWindowSize.Height);
|
||||
}
|
||||
|
||||
return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(),
|
||||
CursorPos.Y / (f32)ReferenceRect.getHeight());
|
||||
}
|
||||
|
||||
//! Sets an absolute reference rect for calculating the cursor position.
|
||||
virtual void setReferenceRect(core::rect<s32>* rect=0)
|
||||
{
|
||||
if (rect)
|
||||
{
|
||||
ReferenceRect = *rect;
|
||||
UseReferenceRect = true;
|
||||
|
||||
// prevent division through zero and uneven sizes
|
||||
|
||||
if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2)
|
||||
ReferenceRect.LowerRightCorner.Y += 1;
|
||||
|
||||
if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2)
|
||||
ReferenceRect.LowerRightCorner.X += 1;
|
||||
}
|
||||
else
|
||||
UseReferenceRect = false;
|
||||
}
|
||||
|
||||
|
||||
//! Updates the internal cursor position
|
||||
void setInternalCursorPosition(const core::position2di &pos)
|
||||
{
|
||||
CursorPos = pos;
|
||||
|
||||
if (UseReferenceRect)
|
||||
CursorPos -= ReferenceRect.UpperLeftCorner;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
core::position2d<s32> CursorPos;
|
||||
core::dimension2d<u32> WindowSize;
|
||||
core::dimension2d<f32> InvWindowSize;
|
||||
bool IsVisible,
|
||||
UseReferenceRect;
|
||||
core::rect<s32> ReferenceRect;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
//! Set the position of the text caret
|
||||
void setTextCursorPos(s16 x, s16 y);
|
||||
|
||||
// text to be added after drawing the screen
|
||||
struct SPostPresentText
|
||||
{
|
||||
core::position2d<s16> Pos;
|
||||
core::stringc Text;
|
||||
};
|
||||
|
||||
bool IsWindowFocused;
|
||||
|
||||
core::array<core::stringc> OutputBuffer;
|
||||
gui::IGUIFont *ConsoleFont;
|
||||
core::array<SPostPresentText> Text;
|
||||
|
||||
FILE *OutFile;
|
||||
|
||||
#ifdef _IRR_WINDOWS_NT_CONSOLE_
|
||||
HANDLE WindowsSTDIn, WindowsSTDOut;
|
||||
u32 MouseButtonStates;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef _IRR_USE_CONSOLE_FONT_
|
||||
|
||||
namespace gui
|
||||
{
|
||||
class CGUIConsoleFont : public IGUIFont
|
||||
{
|
||||
public:
|
||||
|
||||
CGUIConsoleFont(CIrrDeviceConsole* device) : Device(device) { }
|
||||
|
||||
//! Draws some text and clips it to the specified rectangle if wanted.
|
||||
virtual void draw(const wchar_t* text, const core::rect<s32>& position,
|
||||
video::SColor color, bool hcenter=false, bool vcenter=false,
|
||||
const core::rect<s32>* clip=0)
|
||||
{
|
||||
core::rect<s32> Area = clip ? *clip : position;
|
||||
|
||||
if (Area.UpperLeftCorner.X < 0)
|
||||
Area.UpperLeftCorner.X = 0;
|
||||
|
||||
if (Area.UpperLeftCorner.Y < 0)
|
||||
Area.UpperLeftCorner.Y = 0;
|
||||
|
||||
core::position2d<s16> pos;
|
||||
|
||||
// centre vertically
|
||||
pos.Y = vcenter ? (position.UpperLeftCorner.Y + position.LowerRightCorner.Y) / 2 : position.UpperLeftCorner.Y;
|
||||
|
||||
// nothing to display?
|
||||
if (pos.Y < Area.UpperLeftCorner.Y || pos.Y > Area.LowerRightCorner.Y)
|
||||
return;
|
||||
|
||||
tempText = text;
|
||||
|
||||
// centre horizontally
|
||||
pos.X = hcenter ? position.getCenter().X - ( tempText.size() / 2) : position.UpperLeftCorner.X;
|
||||
|
||||
// clip
|
||||
u32 xlclip = 0,
|
||||
xrclip = 0;
|
||||
|
||||
// get right clip
|
||||
if (pos.X + (s32)tempText.size() > Area.LowerRightCorner.X)
|
||||
xrclip = Area.LowerRightCorner.X - pos.X;
|
||||
|
||||
// get left clip
|
||||
if (pos.X < Area.UpperLeftCorner.X)
|
||||
xlclip = Area.UpperLeftCorner.X - pos.X;
|
||||
|
||||
// totally clipped?
|
||||
if ((s32)tempText.size() - xlclip - xrclip < 0)
|
||||
return;
|
||||
|
||||
// null terminate the string
|
||||
if (xrclip > 0)
|
||||
tempText[xrclip] = L'\0';
|
||||
|
||||
Device->addPostPresentText(pos.X + xlclip, pos.Y, &(tempText.c_str()[xlclip]));
|
||||
}
|
||||
|
||||
//! Calculates the dimension of some text.
|
||||
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const
|
||||
{
|
||||
return core::dimension2d<u32>(wcslen(text),1);
|
||||
}
|
||||
|
||||
//! Calculates the index of the character in the text which is on a specific position.
|
||||
virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const { return pixel_x; };
|
||||
|
||||
//! No kerning
|
||||
virtual void setKerningWidth (s32 kerning) { }
|
||||
virtual void setKerningHeight (s32 kerning) { }
|
||||
virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const {return 0;}
|
||||
virtual s32 getKerningHeight() const { return 0;}
|
||||
virtual void setInvisibleCharacters( const wchar_t *s ) { }
|
||||
// I guess this is an OS specific font
|
||||
virtual EGUI_FONT_TYPE getType() const { return EGFT_OS; }
|
||||
private:
|
||||
CIrrDeviceConsole* Device;
|
||||
core::stringw tempText;
|
||||
};
|
||||
|
||||
} // end namespace gui
|
||||
|
||||
#endif // _IRR_USE_CONSOLE_FONT_
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
||||
#endif // __C_IRR_DEVICE_CONSOLE_H_INCLUDED__
|
||||
|
@ -1,405 +0,0 @@
|
||||
// Copyright (C) 2002-2007 Nikolaus Gebhardt
|
||||
// Copyright (C) 2007-2012 Christian Stehno
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CIrrDeviceFB.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "IEventReceiver.h"
|
||||
#include "os.h"
|
||||
#include "CTimer.h"
|
||||
#include "irrString.h"
|
||||
#include "Keycodes.h"
|
||||
#include "COSOperator.h"
|
||||
#include "CColorConverter.h"
|
||||
#include "SIrrCreationParameters.h"
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceFB::CIrrDeviceFB(const SIrrlichtCreationParameters& params)
|
||||
: CIrrDeviceStub(params), Framebuffer(-1), EventDevice(-1), SoftwareImage(0),
|
||||
Pitch(0), FBColorFormat(video::ECF_A8R8G8B8), Close(false)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CIrrDeviceFB");
|
||||
#endif
|
||||
|
||||
// print version, distribution etc.
|
||||
// thx to LynxLuna for pointing me to the uname function
|
||||
core::stringc linuxversion;
|
||||
struct utsname FBInfo;
|
||||
uname(&FBInfo);
|
||||
|
||||
linuxversion += FBInfo.sysname;
|
||||
linuxversion += " ";
|
||||
linuxversion += FBInfo.release;
|
||||
linuxversion += " ";
|
||||
linuxversion += FBInfo.version;
|
||||
linuxversion += " ";
|
||||
linuxversion += FBInfo.machine;
|
||||
|
||||
Operator = new COSOperator(linuxversion);
|
||||
os::Printer::log(linuxversion.c_str(), ELL_INFORMATION);
|
||||
|
||||
// create window
|
||||
if (params.DriverType != video::EDT_NULL)
|
||||
{
|
||||
// create the window, only if we do not use the null device
|
||||
if (!createWindow(params.WindowSize, params.Bits))
|
||||
return;
|
||||
}
|
||||
|
||||
// create cursor control
|
||||
CursorControl = new CCursorControl(this, params.DriverType == video::EDT_NULL);
|
||||
|
||||
// create driver
|
||||
createDriver();
|
||||
|
||||
if (!VideoDriver)
|
||||
return;
|
||||
|
||||
createGUIAndScene();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! destructor
|
||||
CIrrDeviceFB::~CIrrDeviceFB()
|
||||
{
|
||||
if (SoftwareImage)
|
||||
munmap(SoftwareImage, CreationParams.WindowSize.Height*Pitch);
|
||||
// go back to previous format
|
||||
if (ioctl(Framebuffer, FBIOPUT_VSCREENINFO, &oldscreeninfo) <0)
|
||||
perror("Restoring old fb mode");
|
||||
|
||||
if (KeyboardDevice != -1)
|
||||
if (ioctl(KeyboardDevice, KDSETMODE, &KeyboardMode) <0)
|
||||
perror("Restoring keyboard mode");
|
||||
if (EventDevice != -1)
|
||||
close(EventDevice);
|
||||
if (KeyboardDevice != -1)
|
||||
close(KeyboardDevice);
|
||||
if (Framebuffer != -1)
|
||||
close(Framebuffer);
|
||||
}
|
||||
|
||||
|
||||
bool CIrrDeviceFB::createWindow(const core::dimension2d<u32>& windowSize, u32 bits)
|
||||
{
|
||||
char buf[256];
|
||||
CreationParams.WindowSize.Width = windowSize.Width;
|
||||
CreationParams.WindowSize.Height = windowSize.Height;
|
||||
|
||||
KeyboardDevice = open("/dev/tty", O_RDWR);
|
||||
if (KeyboardDevice == -1)
|
||||
perror("Open keyboard");
|
||||
if (ioctl(KeyboardDevice, KDGETMODE, &KeyboardMode) <0)
|
||||
perror("Read keyboard mode");
|
||||
if (ioctl(KeyboardDevice, KDSETMODE, KD_GRAPHICS) <0)
|
||||
perror("Set keyboard mode");
|
||||
|
||||
Framebuffer=open("/dev/fb/0", O_RDWR);
|
||||
if (Framebuffer == -1)
|
||||
{
|
||||
Framebuffer=open("/dev/fb0", O_RDWR);
|
||||
if (Framebuffer == -1)
|
||||
{
|
||||
perror("Open framebuffer");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
EventDevice = open("/dev/input/event0", O_RDONLY | O_NONBLOCK);
|
||||
if (EventDevice == -1)
|
||||
perror("Open event device");
|
||||
|
||||
// make format settings
|
||||
ioctl(Framebuffer, FBIOGET_FSCREENINFO, &fbfixscreeninfo);
|
||||
ioctl(Framebuffer, FBIOGET_VSCREENINFO, &oldscreeninfo);
|
||||
snprintf(buf, 256, "Original resolution: %d x %d\nARGB%d%d%d%d\n",oldscreeninfo.xres,oldscreeninfo.yres,
|
||||
oldscreeninfo.transp.length,oldscreeninfo.red.length,oldscreeninfo.green.length,oldscreeninfo.blue.length);
|
||||
os::Printer::log(buf);
|
||||
memcpy(&fbscreeninfo, &oldscreeninfo, sizeof(struct fb_var_screeninfo));
|
||||
if (CreationParams.DriverType != video::EDT_NULL)
|
||||
{
|
||||
fbscreeninfo.xres = fbscreeninfo.xres_virtual = CreationParams.WindowSize.Width;
|
||||
fbscreeninfo.yres = fbscreeninfo.yres_virtual = CreationParams.WindowSize.Height;
|
||||
fbscreeninfo.bits_per_pixel = 16;
|
||||
fbscreeninfo.red.offset = 10;
|
||||
fbscreeninfo.red.length = 5;
|
||||
fbscreeninfo.green.offset = 5;
|
||||
fbscreeninfo.green.length = 5;
|
||||
fbscreeninfo.blue.offset = 0;
|
||||
fbscreeninfo.blue.length = 5;
|
||||
fbscreeninfo.transp.offset = 15;
|
||||
fbscreeninfo.transp.length = 1;
|
||||
ioctl(Framebuffer, FBIOPUT_VSCREENINFO, &fbscreeninfo);
|
||||
ioctl(Framebuffer, FBIOGET_VSCREENINFO, &fbscreeninfo);
|
||||
|
||||
snprintf(buf, 256, "New resolution: %d x %d (%d x %d)\nARGB%d%d%d%d\n",fbscreeninfo.xres,fbscreeninfo.yres,fbscreeninfo.xres_virtual,fbscreeninfo.yres_virtual,
|
||||
fbscreeninfo.transp.length,fbscreeninfo.red.length,fbscreeninfo.green.length,fbscreeninfo.blue.length);
|
||||
os::Printer::log(buf);
|
||||
|
||||
CreationParams.WindowSize.Width = fbscreeninfo.xres;
|
||||
CreationParams.WindowSize.Height = fbscreeninfo.yres;
|
||||
CreationParams.Bits = fbscreeninfo.bits_per_pixel;
|
||||
Pitch = fbfixscreeninfo.line_length;
|
||||
if (fbscreeninfo.bits_per_pixel == 16)
|
||||
{
|
||||
if (fbscreeninfo.transp.length == 0)
|
||||
FBColorFormat = video::ECF_R5G6B5;
|
||||
else
|
||||
FBColorFormat = video::ECF_A1R5G5B5;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fbscreeninfo.transp.length == 0)
|
||||
FBColorFormat = video::ECF_R8G8B8;
|
||||
else
|
||||
FBColorFormat = video::ECF_A8R8G8B8;
|
||||
}
|
||||
if (MAP_FAILED==(SoftwareImage=(u8*)mmap(0, CreationParams.WindowSize.Height*Pitch, PROT_READ|PROT_WRITE, MAP_SHARED, Framebuffer, 0)))
|
||||
{
|
||||
perror("mmap render target");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! create the driver
|
||||
void CIrrDeviceFB::createDriver()
|
||||
{
|
||||
switch(CreationParams.DriverType)
|
||||
{
|
||||
case video::EDT_SOFTWARE:
|
||||
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
|
||||
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("No Software driver support compiled in.", ELL_WARNING);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case video::EDT_BURNINGSVIDEO:
|
||||
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("Burning's video driver was not compiled in.", ELL_WARNING);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case video::EDT_OPENGL:
|
||||
case video::EDT_DIRECT3D8:
|
||||
case video::EDT_DIRECT3D9:
|
||||
os::Printer::log("This driver is not available in FB. Try Software renderer.",
|
||||
ELL_WARNING);
|
||||
break;
|
||||
|
||||
default:
|
||||
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! runs the device. Returns false if device wants to be deleted
|
||||
bool CIrrDeviceFB::run()
|
||||
{
|
||||
os::Timer::tick();
|
||||
|
||||
struct input_event ev;
|
||||
if (EventDevice>=0)
|
||||
{
|
||||
if ((read(EventDevice, &ev, sizeof(input_event)) < 0) &&
|
||||
errno != EAGAIN)
|
||||
perror("Read input event");
|
||||
if (ev.type == EV_KEY)
|
||||
{
|
||||
irr::SEvent irrevent;
|
||||
irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
|
||||
irrevent.KeyInput.PressedDown = true;
|
||||
|
||||
switch (ev.code)
|
||||
{
|
||||
case IRR_KEY_RIGHTCTRL:
|
||||
case IRR_KEY_LEFTCTRL:
|
||||
irrevent.KeyInput.Control = true;
|
||||
break;
|
||||
case IRR_KEY_RIGHTSHIFT:
|
||||
case IRR_KEY_LEFTSHIFT:
|
||||
irrevent.KeyInput.Shift = true;
|
||||
break;
|
||||
case IRR_KEY_ESC:
|
||||
irrevent.KeyInput.Key = (EKEY_CODE)0x1B;
|
||||
break;
|
||||
case IRR_KEY_SPACE:
|
||||
irrevent.KeyInput.Key = (EKEY_CODE)0x20;
|
||||
break;
|
||||
case IRR_KEY_UP:
|
||||
irrevent.KeyInput.Key = (EKEY_CODE)0x26;
|
||||
break;
|
||||
case IRR_KEY_LEFT:
|
||||
irrevent.KeyInput.Key = (EKEY_CODE)0x25;
|
||||
break;
|
||||
case IRR_KEY_RIGHT:
|
||||
irrevent.KeyInput.Key = (EKEY_CODE)0x27;
|
||||
break;
|
||||
case IRR_KEY_DOWN:
|
||||
irrevent.KeyInput.Key = (EKEY_CODE)0x28;
|
||||
break;
|
||||
default:
|
||||
irrevent.KeyInput.Key = (EKEY_CODE)0;
|
||||
break;
|
||||
}
|
||||
postEventFromUser(irrevent);
|
||||
}
|
||||
}
|
||||
|
||||
return !Close;
|
||||
}
|
||||
|
||||
|
||||
//! Pause the current process for the minimum time allowed only to allow other processes to execute
|
||||
void CIrrDeviceFB::yield()
|
||||
{
|
||||
struct timespec ts = {0,0};
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
|
||||
//! Pause execution and let other processes to run for a specified amount of time.
|
||||
void CIrrDeviceFB::sleep(u32 timeMs, bool pauseTimer=false)
|
||||
{
|
||||
bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
|
||||
struct timespec ts;
|
||||
ts.tv_sec = (time_t) (timeMs / 1000);
|
||||
ts.tv_nsec = (long) (timeMs % 1000) * 1000000;
|
||||
|
||||
if (pauseTimer && !wasStopped)
|
||||
Timer->stop();
|
||||
|
||||
nanosleep(&ts, NULL);
|
||||
|
||||
if (pauseTimer && !wasStopped)
|
||||
Timer->start();
|
||||
}
|
||||
|
||||
|
||||
//! presents a surface in the client area
|
||||
bool CIrrDeviceFB::present(video::IImage* image, void* windowId, core::rect<s32>* src )
|
||||
{
|
||||
// this is only necessary for software drivers.
|
||||
if (CreationParams.DriverType != video::EDT_SOFTWARE && CreationParams.DriverType != video::EDT_BURNINGSVIDEO)
|
||||
return false;
|
||||
|
||||
if (!SoftwareImage)
|
||||
return false;
|
||||
|
||||
u8* destData = SoftwareImage;
|
||||
u32 srcwidth = (u32)image->getDimension().Width;
|
||||
u32 srcheight = (u32)image->getDimension().Height;
|
||||
// clip images
|
||||
srcheight = core::min_(srcheight, CreationParams.WindowSize.Height);
|
||||
srcwidth = core::min_(srcwidth, CreationParams.WindowSize.Width);
|
||||
|
||||
u8* srcdata = (u8*)image->lock();
|
||||
for (u32 y=0; y<srcheight; ++y)
|
||||
{
|
||||
video::CColorConverter::convert_viaFormat(srcdata, image->getColorFormat(), srcwidth, destData, FBColorFormat);
|
||||
srcdata+=image->getPitch();
|
||||
destData+=Pitch;
|
||||
}
|
||||
image->unlock();
|
||||
msync(SoftwareImage,CreationParams.WindowSize.Width*CreationParams.WindowSize.Height,MS_ASYNC);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! notifies the device that it should close itself
|
||||
void CIrrDeviceFB::closeDevice()
|
||||
{
|
||||
Close = true;
|
||||
}
|
||||
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
bool CIrrDeviceFB::isWindowActive() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! returns if window has focus
|
||||
bool CIrrDeviceFB::isWindowFocused() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! returns if window is minimized
|
||||
bool CIrrDeviceFB::isWindowMinimized() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! sets the caption of the window
|
||||
void CIrrDeviceFB::setWindowCaption(const wchar_t* text)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//! Sets if the window should be resizeable in windowed mode.
|
||||
void CIrrDeviceFB::setResizable(bool resize)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//! Minimizes window
|
||||
void CIrrDeviceFB::minimizeWindow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//! Maximizes window
|
||||
void CIrrDeviceFB::maximizeWindow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//! Restores original window size
|
||||
void CIrrDeviceFB::restoreWindow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//! Returns the type of this device
|
||||
E_DEVICE_TYPE CIrrDeviceFB::getType() const
|
||||
{
|
||||
return EIDT_FRAMEBUFFER;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_USE_FB_DEVICE_
|
||||
|
@ -1,210 +0,0 @@
|
||||
// Copyright (C) 2002-2007 Nikolaus Gebhardt
|
||||
// Copyright (C) 2007-2012 Christian Stehno
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_IRR_DEVICE_FB_H_INCLUDED__
|
||||
#define __C_IRR_DEVICE_FB_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
|
||||
|
||||
#include "CIrrDeviceStub.h"
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include "IrrlichtDevice.h"
|
||||
#include "IImagePresenter.h"
|
||||
#include "ICursorControl.h"
|
||||
|
||||
#define KeySym s32
|
||||
#include <linux/fb.h>
|
||||
#include <linux/kd.h>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
class CIrrDeviceFB : public CIrrDeviceStub, public video::IImagePresenter
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceFB(const SIrrlichtCreationParameters& params);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceFB();
|
||||
|
||||
//! runs the device. Returns false if device wants to be deleted
|
||||
virtual bool run();
|
||||
|
||||
//! Cause the device to temporarily pause execution and let other processes to run
|
||||
// This should bring down processor usage without major performance loss for Irrlicht
|
||||
virtual void yield();
|
||||
|
||||
//! Pause execution and let other processes to run for a specified amount of time.
|
||||
virtual void sleep(u32 timeMs, bool pauseTimer);
|
||||
|
||||
//! sets the caption of the window
|
||||
virtual void setWindowCaption(const wchar_t* text);
|
||||
|
||||
//! sets the class of the window
|
||||
virtual void setWindowClass(const char* text) {}
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
virtual bool isWindowActive() const;
|
||||
|
||||
//! returns if window has focus
|
||||
virtual bool isWindowFocused() const;
|
||||
|
||||
//! returns if window is minimized
|
||||
virtual bool isWindowMinimized() const;
|
||||
|
||||
//! Minimizes window
|
||||
virtual void minimizeWindow();
|
||||
|
||||
//! Maximizes window
|
||||
virtual void maximizeWindow();
|
||||
|
||||
//! Restores original window size
|
||||
virtual void restoreWindow();
|
||||
|
||||
//! presents a surface in the client area
|
||||
virtual bool present(video::IImage* surface, void* windowId = 0, core::rect<s32>* src=0 );
|
||||
|
||||
//! notifies the device that it should close itself
|
||||
virtual void closeDevice();
|
||||
|
||||
//! Sets if the window should be resizeable in windowed mode.
|
||||
virtual void setResizable(bool resize=false);
|
||||
|
||||
//! Returns the type of this device
|
||||
virtual E_DEVICE_TYPE getType() const;
|
||||
|
||||
private:
|
||||
|
||||
//! create the driver
|
||||
void createDriver();
|
||||
|
||||
bool createWindow(const core::dimension2d<u32>& windowSize, u32 bits);
|
||||
|
||||
//! Implementation of the cursor control
|
||||
class CCursorControl : public gui::ICursorControl
|
||||
{
|
||||
public:
|
||||
|
||||
CCursorControl(CIrrDeviceFB* dev, bool null)
|
||||
: Device(dev), IsVisible(true), Null(null)
|
||||
{
|
||||
Device->grab();
|
||||
}
|
||||
|
||||
~CCursorControl()
|
||||
{
|
||||
Device->drop();
|
||||
}
|
||||
|
||||
//! Changes the visible state of the mouse cursor.
|
||||
virtual void setVisible(bool visible)
|
||||
{
|
||||
IsVisible = visible;
|
||||
}
|
||||
|
||||
//! Returns if the cursor is currently visible.
|
||||
virtual bool isVisible() const
|
||||
{
|
||||
return IsVisible;
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(const core::position2d<f32> &pos)
|
||||
{
|
||||
setPosition(pos.X, pos.Y);
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(f32 x, f32 y)
|
||||
{
|
||||
setPosition((s32)(x*Device->CreationParams.WindowSize.Width), (s32)(y*Device->CreationParams.WindowSize.Height));
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(const core::position2d<s32> &pos)
|
||||
{
|
||||
setPosition(pos.X, pos.Y);
|
||||
}
|
||||
|
||||
//! Sets the new position of the cursor.
|
||||
virtual void setPosition(s32 x, s32 y)
|
||||
{
|
||||
}
|
||||
|
||||
//! Returns the current position of the mouse cursor.
|
||||
virtual const core::position2d<s32>& getPosition()
|
||||
{
|
||||
updateCursorPos();
|
||||
return CursorPos;
|
||||
}
|
||||
|
||||
//! Returns the current position of the mouse cursor.
|
||||
virtual core::position2d<f32> getRelativePosition()
|
||||
{
|
||||
updateCursorPos();
|
||||
return core::position2d<f32>(CursorPos.X / (f32)Device->CreationParams.WindowSize.Width,
|
||||
CursorPos.Y / (f32)Device->CreationParams.WindowSize.Height);
|
||||
}
|
||||
|
||||
virtual void setReferenceRect(core::rect<s32>* rect=0)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void updateCursorPos()
|
||||
{
|
||||
}
|
||||
|
||||
core::position2d<s32> CursorPos;
|
||||
CIrrDeviceFB* Device;
|
||||
bool IsVisible;
|
||||
bool Null;
|
||||
};
|
||||
|
||||
friend class CCursorControl;
|
||||
|
||||
int Framebuffer;
|
||||
int EventDevice;
|
||||
int KeyboardDevice;
|
||||
struct fb_fix_screeninfo fbfixscreeninfo;
|
||||
struct fb_var_screeninfo fbscreeninfo;
|
||||
struct fb_var_screeninfo oldscreeninfo;
|
||||
long KeyboardMode;
|
||||
u8* SoftwareImage;
|
||||
|
||||
u32 Pitch;
|
||||
video::ECOLOR_FORMAT FBColorFormat;
|
||||
bool Close;
|
||||
|
||||
struct SKeyMap
|
||||
{
|
||||
SKeyMap() {}
|
||||
SKeyMap(s32 x11, s32 win32)
|
||||
: X11Key(x11), Win32Key(win32)
|
||||
{
|
||||
}
|
||||
|
||||
KeySym X11Key;
|
||||
s32 Win32Key;
|
||||
|
||||
bool operator<(const SKeyMap& o) const
|
||||
{
|
||||
return X11Key<o.X11Key;
|
||||
}
|
||||
};
|
||||
|
||||
core::array<SKeyMap> KeyMap;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_USE_FB_DEVICE_
|
||||
#endif // __C_IRR_DEVICE_FB_H_INCLUDED__
|
||||
|
@ -277,7 +277,7 @@ bool CIrrDeviceLinux::restoreResolution()
|
||||
}
|
||||
#endif
|
||||
#ifdef _IRR_LINUX_X11_RANDR_
|
||||
if (UseXRandR && CreationParams.Fullscreen && old_mode != BadRRMode)
|
||||
if (UseXRandR && CreationParams.Fullscreen && old_mode != 0)
|
||||
{
|
||||
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
|
||||
if (!res)
|
||||
@ -385,7 +385,7 @@ bool CIrrDeviceLinux::changeResolution()
|
||||
#ifdef _IRR_LINUX_X11_RANDR_
|
||||
while (XRRQueryExtension(display, &eventbase, &errorbase))
|
||||
{
|
||||
if (output_id == BadRROutput)
|
||||
if (output_id == 0)
|
||||
break;
|
||||
|
||||
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
|
||||
@ -2057,8 +2057,8 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
|
||||
}
|
||||
#endif
|
||||
#ifdef _IRR_LINUX_X11_RANDR_
|
||||
output_id = BadRROutput;
|
||||
old_mode = BadRRMode;
|
||||
output_id = 0;
|
||||
old_mode = 0;
|
||||
|
||||
while (XRRQueryExtension(display, &eventbase, &errorbase))
|
||||
{
|
||||
@ -2089,7 +2089,7 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
|
||||
}
|
||||
|
||||
if (res->outputs[i] == primary_id ||
|
||||
output_id == BadRROutput || crtc_tmp->x < crtc->x ||
|
||||
output_id == 0 || crtc_tmp->x < crtc->x ||
|
||||
(crtc_tmp->x == crtc->x && crtc_tmp->y < crtc->y))
|
||||
{
|
||||
XRRFreeCrtcInfo(crtc);
|
||||
@ -2109,7 +2109,7 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
|
||||
break;
|
||||
}
|
||||
|
||||
if (output_id == BadRROutput)
|
||||
if (output_id == 0)
|
||||
{
|
||||
os::Printer::log("Could not get video output.", ELL_WARNING);
|
||||
break;
|
||||
@ -2194,6 +2194,101 @@ void CIrrDeviceLinux::restoreWindow()
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the parent window of "window" (i.e. the ancestor of window
|
||||
that is a direct child of the root, or window itself if it is a direct child).
|
||||
If window is the root window, returns window.
|
||||
*/
|
||||
bool get_toplevel_parent(Display* display, Window window, Window* tp_window)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
Window current_window = window;
|
||||
Window parent;
|
||||
Window root;
|
||||
Window* children;
|
||||
unsigned int num_children;
|
||||
|
||||
while (true)
|
||||
{
|
||||
bool success = XQueryTree(display, current_window, &root,
|
||||
&parent, &children, &num_children);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
os::Printer::log("XQueryTree error", ELL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (children)
|
||||
{
|
||||
XFree(children);
|
||||
}
|
||||
|
||||
if (current_window == root || parent == root)
|
||||
{
|
||||
*tp_window = current_window;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_window = parent;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Move window to requested position
|
||||
bool CIrrDeviceLinux::moveWindow(int x, int y)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
if (CreationParams.DriverType == video::EDT_NULL || CreationParams.Fullscreen)
|
||||
return false;
|
||||
|
||||
int display_width = XDisplayWidth(display, screennr);
|
||||
int display_height = XDisplayHeight(display, screennr);
|
||||
|
||||
core::min_(x, display_width - (int)Width);
|
||||
core::min_(y, display_height - (int)Height);
|
||||
|
||||
XMoveWindow(display, window, x, y);
|
||||
return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Get current window position.
|
||||
bool CIrrDeviceLinux::getWindowPosition(int* x, int* y)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
if (CreationParams.DriverType == video::EDT_NULL || CreationParams.Fullscreen)
|
||||
return false;
|
||||
|
||||
Window tp_window;
|
||||
|
||||
bool success = get_toplevel_parent(display, window, &tp_window);
|
||||
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
XWindowAttributes xwa;
|
||||
success = XGetWindowAttributes(display, tp_window, &xwa);
|
||||
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
*x = xwa.x;
|
||||
*y = xwa.y;
|
||||
|
||||
return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CIrrDeviceLinux::createKeyMap()
|
||||
{
|
||||
|
@ -99,6 +99,12 @@ namespace irr
|
||||
|
||||
//! Restores the window size.
|
||||
virtual void restoreWindow();
|
||||
|
||||
//! Move window to requested position
|
||||
virtual bool moveWindow(int x, int y);
|
||||
|
||||
//! Get current window position.
|
||||
virtual bool getWindowPosition(int* x, int* y);
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
|
||||
|
@ -761,6 +761,18 @@ void CIrrDeviceSDL::restoreWindow()
|
||||
// do nothing
|
||||
}
|
||||
|
||||
//! Move window to requested position
|
||||
bool CIrrDeviceSDL::moveWindow(int x, int y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Get current window position.
|
||||
bool CIrrDeviceSDL::getWindowPosition(int* x, int* y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
bool CIrrDeviceSDL::isWindowActive() const
|
||||
|
@ -79,6 +79,12 @@ namespace irr
|
||||
|
||||
//! Restores the window size.
|
||||
virtual void restoreWindow();
|
||||
|
||||
//! Move window to requested position
|
||||
virtual bool moveWindow(int x, int y);
|
||||
|
||||
//! Get current window position.
|
||||
virtual bool getWindowPosition(int* x, int* y);
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
|
||||
|
@ -1073,6 +1073,18 @@ void CIrrDeviceWayland::restoreWindow()
|
||||
{
|
||||
}
|
||||
|
||||
//! Move window to requested position
|
||||
bool CIrrDeviceWayland::moveWindow(int x, int y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Get current window position.
|
||||
bool CIrrDeviceWayland::getWindowPosition(int* x, int* y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Set the current Gamma Value for the Display
|
||||
bool CIrrDeviceWayland::setGammaRamp(f32 red, f32 green, f32 blue,
|
||||
f32 brightness, f32 contrast)
|
||||
|
@ -104,6 +104,12 @@ namespace irr
|
||||
|
||||
//! Restores the window size.
|
||||
virtual void restoreWindow();
|
||||
|
||||
//! Move window to requested position
|
||||
virtual bool moveWindow(int x, int y);
|
||||
|
||||
//! Get current window position.
|
||||
virtual bool getWindowPosition(int* x, int* y);
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo>& joystickInfo);
|
||||
|
@ -2131,6 +2131,38 @@ void CIrrDeviceWin32::restoreWindow()
|
||||
SetWindowPlacement(HWnd, &wndpl);
|
||||
}
|
||||
|
||||
//! Move window to requested position
|
||||
bool CIrrDeviceWin32::moveWindow(int x, int y)
|
||||
{
|
||||
if (CreationParams.DriverType == video::EDT_NULL || CreationParams.Fullscreen)
|
||||
return false;
|
||||
|
||||
bool success = SetWindowPos(HWnd, HWND_TOP, x, y, -1, -1,
|
||||
SWP_NOOWNERZORDER | SWP_NOSIZE);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//! Get current window position.
|
||||
bool CIrrDeviceWin32::getWindowPosition(int* x, int* y)
|
||||
{
|
||||
if (CreationParams.DriverType == video::EDT_NULL || CreationParams.Fullscreen)
|
||||
return false;
|
||||
|
||||
WINDOWPLACEMENT placement;
|
||||
placement.length = sizeof(WINDOWPLACEMENT);
|
||||
|
||||
bool success = GetWindowPlacement(HWnd, &placement);
|
||||
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
*x = (int)placement.rcNormalPosition.left;
|
||||
*y = (int)placement.rcNormalPosition.top;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CIrrDeviceWin32::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
|
||||
{
|
||||
|
@ -87,6 +87,12 @@ namespace irr
|
||||
|
||||
//! Restores the window size.
|
||||
virtual void restoreWindow();
|
||||
|
||||
//! Move window to requested position
|
||||
virtual bool moveWindow(int x, int y);
|
||||
|
||||
//! Get current window position.
|
||||
virtual bool getWindowPosition(int* x, int* y);
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
|
||||
|
@ -2886,7 +2886,7 @@ namespace irr
|
||||
namespace video
|
||||
{
|
||||
|
||||
#if !defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_) && (defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_SDL_DEVICE_) || defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_CONSOLE_DEVICE_))
|
||||
#if !defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_) && (defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_SDL_DEVICE_) || defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_))
|
||||
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
video::SExposedVideoData& data, io::IFileSystem* io)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ namespace video
|
||||
friend class COGLES2Texture;
|
||||
|
||||
public:
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_SDL_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_CONSOLE_DEVICE_)
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_SDL_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
COGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
const SExposedVideoData& data,
|
||||
io::IFileSystem* io);
|
||||
|
@ -22,10 +22,6 @@
|
||||
#include "MacOSX/CIrrDeviceMacOSX.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
|
||||
#include "CIrrDeviceWinCE.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
#include "CIrrDeviceWayland.h"
|
||||
#endif
|
||||
@ -38,14 +34,6 @@
|
||||
#include "CIrrDeviceSDL.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
|
||||
#include "CIrrDeviceFB.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
||||
#include "CIrrDeviceConsole.h"
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
|
||||
#include "CIrrDeviceAndroid.h"
|
||||
#include <android/log.h>
|
||||
@ -94,12 +82,6 @@ namespace irr
|
||||
device_type = EIDT_OSX;
|
||||
}
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
|
||||
if (strcmp(irr_device_type, "wince") == 0)
|
||||
{
|
||||
device_type = EIDT_WINCE;
|
||||
}
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
if (strcmp(irr_device_type, "wayland") == 0)
|
||||
{
|
||||
@ -118,23 +100,11 @@ namespace irr
|
||||
device_type = EIDT_SDL;
|
||||
}
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
|
||||
if (strcmp(irr_device_type, "framebuffer") == 0)
|
||||
{
|
||||
device_type = EIDT_FRAMEBUFFER;
|
||||
}
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
|
||||
if (strcmp(irr_device_type, "android") == 0)
|
||||
{
|
||||
device_type = EIDT_ANDROID;
|
||||
}
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
||||
if (strcmp(irr_device_type, "console") == 0)
|
||||
{
|
||||
device_type = EIDT_CONSOLE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -156,11 +126,6 @@ namespace irr
|
||||
dev = new CIrrDeviceMacOSX(creation_params);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
|
||||
if (creation_params.DeviceType == EIDT_WINCE || (!dev && creation_params.DeviceType == EIDT_BEST))
|
||||
dev = new CIrrDeviceWinCE(creation_params);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
if (creation_params.DeviceType == EIDT_WAYLAND || (!dev && creation_params.DeviceType == EIDT_BEST))
|
||||
{
|
||||
@ -181,21 +146,11 @@ namespace irr
|
||||
dev = new CIrrDeviceSDL(creation_params);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
|
||||
if (creation_params.DeviceType == EIDT_FRAMEBUFFER || (!dev && creation_params.DeviceType == EIDT_BEST))
|
||||
dev = new CIrrDeviceFB(creation_params);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
|
||||
if (creation_params.DeviceType == EIDT_ANDROID || (!dev && creation_params.DeviceType == EIDT_BEST))
|
||||
dev = new CIrrDeviceAndroid(creation_params);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
|
||||
if (creation_params.DeviceType == EIDT_CONSOLE || (!dev && creation_params.DeviceType == EIDT_BEST))
|
||||
dev = new CIrrDeviceConsole(creation_params);
|
||||
#endif
|
||||
|
||||
if (dev && !dev->getVideoDriver() && creation_params.DriverType != video::EDT_NULL)
|
||||
{
|
||||
dev->closeDevice(); // destroy window
|
||||
|
@ -83,6 +83,12 @@ namespace irr
|
||||
//! Restore the window to normal size if possible.
|
||||
virtual void restoreWindow();
|
||||
|
||||
//! Move window to requested position
|
||||
virtual bool moveWindow(int x, int y);
|
||||
|
||||
//! Get current window position.
|
||||
virtual bool getWindowPosition(int* x, int* y);
|
||||
|
||||
//! Activate any joysticks, and generate events for them.
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
|
||||
|
||||
|
@ -1528,6 +1528,18 @@ void CIrrDeviceMacOSX::restoreWindow()
|
||||
[Window deminiaturize:[NSApp self]];
|
||||
}
|
||||
|
||||
//! Move window to requested position
|
||||
bool CIrrDeviceMacOSX::moveWindow(int x, int y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Get current window position.
|
||||
bool CIrrDeviceMacOSX::getWindowPosition(int* x, int* y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rect<s32>* src )
|
||||
{
|
||||
|
@ -294,7 +294,12 @@ void reportHardwareStats()
|
||||
#else
|
||||
json.add("os_macosx", 0);
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#ifdef ANDROID
|
||||
json.add("os_android", 1);
|
||||
#else
|
||||
json.add("os_android", 0);
|
||||
#endif
|
||||
#if defined(__linux__) && !defined(ANDROID)
|
||||
json.add("os_linux", 1);
|
||||
json.add("os_unix", 1);
|
||||
#else
|
||||
|
@ -61,7 +61,6 @@ extern "C" {
|
||||
#if defined(USE_GLES2)
|
||||
#define GL_BGRA 0x80E1
|
||||
#define GL_BGR 0x80E0
|
||||
#define GL_FRAMEBUFFER_SRGB 0x8DB9
|
||||
#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE
|
||||
|
||||
// The glDrawElementsBaseVertex is available only in OpenGL ES 3.2. At this
|
||||
|
@ -91,7 +91,6 @@ public:
|
||||
|
||||
// ============================================================================
|
||||
/** */
|
||||
#if !defined(USE_GLES2)
|
||||
class HeightmapSimulationShader :
|
||||
public TextureShader<HeightmapSimulationShader, 1,
|
||||
core::matrix4, int, int,
|
||||
@ -106,12 +105,15 @@ public:
|
||||
loadTFBProgram("particlesimheightmap.vert", varyings, 4);
|
||||
assignUniforms("sourcematrix", "dt", "level", "size_increase_factor",
|
||||
"track_x", "track_x_len", "track_z", "track_z_len");
|
||||
#if !defined(USE_GLES2)
|
||||
assignSamplerNames(0, "heightmap", ST_TEXTURE_BUFFER);
|
||||
#else
|
||||
assignSamplerNames(0, "heightmap", ST_NEAREST_FILTERED);
|
||||
#endif
|
||||
} // HeightmapSimulationShader
|
||||
|
||||
|
||||
}; // class HeightmapSimulationShader
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
|
||||
@ -186,7 +188,6 @@ void ParticleSystemProxy::setFlip()
|
||||
void ParticleSystemProxy::setHeightmap(const std::vector<std::vector<float> > &hm,
|
||||
float f1, float f2, float f3, float f4)
|
||||
{
|
||||
#if !defined(USE_GLES2)
|
||||
track_x = f1, track_z = f2, track_x_len = f3, track_z_len = f4;
|
||||
|
||||
unsigned width = (unsigned)hm.size();
|
||||
@ -200,6 +201,8 @@ void ParticleSystemProxy::setHeightmap(const std::vector<std::vector<float> > &h
|
||||
}
|
||||
}
|
||||
has_height_map = true;
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
glGenBuffers(1, &heighmapbuffer);
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, heighmapbuffer);
|
||||
glBufferData(GL_TEXTURE_BUFFER, width * height * sizeof(float), hm_array, GL_STREAM_COPY);
|
||||
@ -208,9 +211,14 @@ void ParticleSystemProxy::setHeightmap(const std::vector<std::vector<float> > &h
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, heighmapbuffer);
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, 0);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
#else
|
||||
glGenTextures(1, &heightmaptexture);
|
||||
glBindTexture(GL_TEXTURE_2D, heightmaptexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, width, height, 0, GL_RED, GL_FLOAT, hm_array);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#endif
|
||||
|
||||
delete[] hm_array;
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
@ -505,11 +513,9 @@ void ParticleSystemProxy::simulate()
|
||||
glEnable(GL_RASTERIZER_DISCARD);
|
||||
if (has_height_map)
|
||||
{
|
||||
#if !defined(USE_GLES2)
|
||||
HeightmapSimulationShader::getInstance()->use();
|
||||
HeightmapSimulationShader::getInstance()->setTextureUnits(heightmaptexture);
|
||||
HeightmapSimulationShader::getInstance()->setUniforms(matrix, timediff, active_count, size_increase_factor, track_x, track_x_len, track_z, track_z_len);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -91,15 +91,6 @@ please use the included version."
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#if defined(__linux__) && !defined(ANDROID)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#endif
|
||||
|
||||
/** singleton */
|
||||
IrrDriver *irr_driver = NULL;
|
||||
|
||||
@ -228,45 +219,6 @@ std::unique_ptr<RenderTarget> IrrDriver::createRenderTarget(const irr::core::dim
|
||||
} // createRenderTarget
|
||||
#endif // ~SERVER_ONLY
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__linux__) && !defined(ANDROID)
|
||||
/*
|
||||
Returns the parent window of "window" (i.e. the ancestor of window
|
||||
that is a direct child of the root, or window itself if it is a direct child).
|
||||
If window is the root window, returns window.
|
||||
*/
|
||||
Window get_toplevel_parent(Display* display, Window window)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
Window parent;
|
||||
Window root;
|
||||
Window * children;
|
||||
unsigned int num_children;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (0 == XQueryTree(display, window, &root,
|
||||
&parent, &children, &num_children))
|
||||
{
|
||||
Log::fatal("irr_driver", "XQueryTree error\n");
|
||||
}
|
||||
if (children) { //must test for null
|
||||
XFree(children);
|
||||
}
|
||||
if (window == root || parent == root) {
|
||||
return window;
|
||||
}
|
||||
else {
|
||||
window = parent;
|
||||
}
|
||||
}
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** If the position of the window should be remembered, store it in the config
|
||||
* file.
|
||||
@ -278,61 +230,26 @@ void IrrDriver::updateConfigIfRelevant()
|
||||
if (!UserConfigParams::m_fullscreen &&
|
||||
UserConfigParams::m_remember_window_location)
|
||||
{
|
||||
#ifdef WIN32
|
||||
const video::SExposedVideoData& videoData = m_device->getVideoDriver()
|
||||
->getExposedVideoData();
|
||||
// this should work even if using DirectX in theory because the HWnd is
|
||||
// always third pointer in the struct, no matter which union is used
|
||||
HWND window = (HWND)videoData.OpenGLWin32.HWnd;
|
||||
WINDOWPLACEMENT placement;
|
||||
placement.length = sizeof(WINDOWPLACEMENT);
|
||||
if (GetWindowPlacement(window, &placement))
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
bool success = m_device->getWindowPosition(&x, &y);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
int x = (int)placement.rcNormalPosition.left;
|
||||
int y = (int)placement.rcNormalPosition.top;
|
||||
// If the windows position is saved, it must be a non-negative
|
||||
// number. So if the window is partly off screen, move it to the
|
||||
// corresponding edge.
|
||||
if(x<0) x = 0;
|
||||
if(y<0) y = 0;
|
||||
Log::verbose("irr_driver",
|
||||
"Retrieved window location for config : %i %i\n", x, y);
|
||||
|
||||
if (UserConfigParams::m_window_x != x || UserConfigParams::m_window_y != y)
|
||||
{
|
||||
UserConfigParams::m_window_x = x;
|
||||
UserConfigParams::m_window_y = y;
|
||||
}
|
||||
Log::warn("irr_driver", "Could not retrieve window location");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::warn("irr_driver", "Could not retrieve window location\n");
|
||||
}
|
||||
#elif defined(__linux__) && !defined(ANDROID)
|
||||
if (m_device->getType() == EIDT_X11)
|
||||
{
|
||||
const video::SExposedVideoData& videoData =
|
||||
m_device->getVideoDriver()->getExposedVideoData();
|
||||
Display* display = (Display*)videoData.OpenGLLinux.X11Display;
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes(display, get_toplevel_parent(display,
|
||||
videoData.OpenGLLinux.X11Window), &xwa);
|
||||
int wx = xwa.x;
|
||||
int wy = xwa.y;
|
||||
Log::verbose("irr_driver",
|
||||
"Retrieved window location for config : %i %i\n", wx, wy);
|
||||
|
||||
|
||||
if (UserConfigParams::m_window_x != wx ||
|
||||
UserConfigParams::m_window_y != wy)
|
||||
{
|
||||
UserConfigParams::m_window_x = wx;
|
||||
UserConfigParams::m_window_y = wy;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Log::verbose("irr_driver", "Retrieved window location for config: "
|
||||
"%i %i", x, y);
|
||||
|
||||
// If the windows position is saved, it must be a non-negative
|
||||
// number. So if the window is partly off screen, move it to the
|
||||
// corresponding edge.
|
||||
UserConfigParams::m_window_x = std::max(0, x);
|
||||
UserConfigParams::m_window_y = std::max(0, y);
|
||||
}
|
||||
|
||||
#endif // !SERVER_ONLY
|
||||
} // updateConfigIfRelevant
|
||||
|
||||
@ -867,49 +784,13 @@ core::position2di IrrDriver::getMouseLocation()
|
||||
bool IrrDriver::moveWindow(int x, int y)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
#ifdef WIN32
|
||||
const video::SExposedVideoData& videoData =
|
||||
m_video_driver->getExposedVideoData();
|
||||
// this should work even if using DirectX in theory,
|
||||
// because the HWnd is always third pointer in the struct,
|
||||
// no matter which union is used
|
||||
HWND window = (HWND)videoData.OpenGLWin32.HWnd;
|
||||
if (SetWindowPos(window, HWND_TOP, x, y, -1, -1,
|
||||
SWP_NOOWNERZORDER | SWP_NOSIZE))
|
||||
{
|
||||
// everything OK
|
||||
return true;
|
||||
}
|
||||
else
|
||||
bool success = m_device->moveWindow(x, y);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Log::warn("irr_driver", "Could not set window location\n");
|
||||
return false;
|
||||
}
|
||||
#elif defined(__linux__) && !defined(ANDROID)
|
||||
if (m_device->getType() == EIDT_X11)
|
||||
{
|
||||
const video::SExposedVideoData& videoData =
|
||||
m_video_driver->getExposedVideoData();
|
||||
|
||||
Display* display = (Display*)videoData.OpenGLLinux.X11Display;
|
||||
int screen = DefaultScreen(display);
|
||||
int screen_w = DisplayWidth(display, screen);
|
||||
int screen_h = DisplayHeight(display, screen);
|
||||
|
||||
if (x + UserConfigParams::m_width > screen_w)
|
||||
{
|
||||
x = screen_w - UserConfigParams::m_width;
|
||||
}
|
||||
|
||||
if (y + UserConfigParams::m_height > screen_h)
|
||||
{
|
||||
y = screen_h - UserConfigParams::m_height;
|
||||
}
|
||||
|
||||
// TODO: Actually handle possible failure
|
||||
XMoveWindow(display, videoData.OpenGLLinux.X11Window, x, y);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
@ -1577,7 +1577,9 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
|
||||
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKING))
|
||||
return in_fbo;
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
out_fbo = &rtts->getFBO(FBO_MLAA_COLORS);
|
||||
out_fbo->bind();
|
||||
renderPassThrough(in_fbo->getRTT()[0],
|
||||
@ -1593,7 +1595,9 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
|
||||
*out_fbo);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
#if !defined(USE_GLES2)
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
|
||||
return out_fbo;
|
||||
} // render
|
||||
|
@ -147,12 +147,16 @@ void GL3RenderTarget::draw2DImage(const irr::core::rect<s32>& dest_rect,
|
||||
assert(m_frame_buffer != NULL);
|
||||
irr::core::rect<s32> source_rect(0, 0, m_frame_buffer->getWidth(),
|
||||
m_frame_buffer->getHeight());
|
||||
#if !defined(USE_GLES2)
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
draw2DImageFromRTT(m_frame_buffer->getRTT()[0],
|
||||
m_frame_buffer->getWidth(), m_frame_buffer->getHeight(),
|
||||
dest_rect, source_rect,
|
||||
clip_rect, colors, use_alpha_channel_of_texture);
|
||||
#if !defined(USE_GLES2)
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
|
||||
} // draw2DImage
|
||||
|
||||
|
@ -304,8 +304,10 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
else
|
||||
{
|
||||
// We need a cleared depth buffer for some effect (eg particles depth blending)
|
||||
#if !defined(USE_GLES2)
|
||||
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKING))
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
m_rtts->getFBO(FBO_NORMAL_AND_DEPTHS).bind();
|
||||
// Bind() modifies the viewport. In order not to affect anything else,
|
||||
// the viewport is just reset here and not removed in Bind().
|
||||
@ -315,8 +317,10 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
vp.LowerRightCorner.X - vp.UpperLeftCorner.X,
|
||||
vp.LowerRightCorner.Y - vp.UpperLeftCorner.Y);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
#if !defined(USE_GLES2)
|
||||
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_WORKING))
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
@ -490,7 +494,9 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
|
||||
}
|
||||
if (!CVS->isDefferedEnabled() && !forceRTT)
|
||||
{
|
||||
#if !defined(USE_GLES2)
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
return;
|
||||
@ -596,11 +602,15 @@ void ShaderBasedRenderer::renderPostProcessing(Camera * const camera)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(USE_GLES2)
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
camera->activate();
|
||||
m_post_processing->renderPassThrough(fbo->getRTT()[0], viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y);
|
||||
#if !defined(USE_GLES2)
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
}
|
||||
} //renderPostProcessing
|
||||
|
||||
@ -800,8 +810,10 @@ void ShaderBasedRenderer::render(float dt)
|
||||
rg->preRenderCallback(camera); // adjusts start referee
|
||||
irr_driver->getSceneManager()->setActiveCamera(camnode);
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
if (!CVS->isDefferedEnabled())
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
#endif
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("UBO upload", 0x0, 0xFF, 0x0);
|
||||
computeMatrixesAndCameras(camnode, m_rtts->getWidth(), m_rtts->getHeight());
|
||||
|
@ -425,7 +425,7 @@ void DeviceManager::updateMultitouchDevice()
|
||||
if (m_multitouch_device->getPlayer() != m_single_player)
|
||||
m_multitouch_device->setPlayer(m_single_player);
|
||||
}
|
||||
else if (m_assign_mode == NO_ASSIGN) // Don't set the player in NO_ASSIGN mode
|
||||
else
|
||||
{
|
||||
m_multitouch_device->setPlayer(NULL);
|
||||
}
|
||||
|
@ -1185,6 +1185,8 @@ EventPropagation InputManager::input(const SEvent& event)
|
||||
|
||||
if (device && device->isAccelerometerActive())
|
||||
{
|
||||
m_device_manager->updateMultitouchDevice();
|
||||
|
||||
for (unsigned int i = 0; i < device->getButtonsCount(); i++)
|
||||
{
|
||||
MultitouchButton* button = device->getButton(i);
|
||||
|
@ -111,14 +111,24 @@ KartGFX::KartGFX(const AbstractKart *kart, bool is_day)
|
||||
addEffect(KGFX_NITRO2, "nitro.xml", rear_nitro_left, true );
|
||||
addEffect(KGFX_NITROSMOKE1, "nitro-smoke.xml", rear_nitro_left, false);
|
||||
addEffect(KGFX_NITROSMOKE2, "nitro-smoke.xml", rear_nitro_right, false);
|
||||
addEffect(KGFX_EXHAUST1, "kart_exhaust.xml",rear_nitro_right, false );
|
||||
addEffect(KGFX_EXHAUST2, "kart_exhaust.xml",rear_nitro_left, false );
|
||||
addEffect(KGFX_ZIPPER, "zipper_fire.xml", rear_center, true );
|
||||
addEffect(KGFX_TERRAIN, "smoke.xml", Vec3(0, 0, 0), false);
|
||||
addEffect(KGFX_SKID1L, "skid1.xml", rear_left, true );
|
||||
addEffect(KGFX_SKID1R, "skid1.xml", rear_right, true );
|
||||
addEffect(KGFX_SKID2L, "skid2.xml", rear_left, true );
|
||||
addEffect(KGFX_SKID2R, "skid2.xml", rear_right, true );
|
||||
if (!kart->getKartModel()->getExhaustXML().empty())
|
||||
{
|
||||
const std::string& ex = kart->getKartModel()->getExhaustXML();
|
||||
addEffect(KGFX_EXHAUST1, ex, rear_nitro_right, false);
|
||||
addEffect(KGFX_EXHAUST2, ex, rear_nitro_left, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_all_emitters.push_back(NULL);
|
||||
m_all_emitters.push_back(NULL);
|
||||
}
|
||||
|
||||
} // KartGFX
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -49,8 +49,6 @@ public:
|
||||
KGFX_NITRO2,
|
||||
KGFX_NITROSMOKE1,
|
||||
KGFX_NITROSMOKE2,
|
||||
KGFX_EXHAUST1,
|
||||
KGFX_EXHAUST2,
|
||||
KGFX_ZIPPER,
|
||||
KGFX_TERRAIN,
|
||||
KGFX_SKIDL,
|
||||
@ -59,6 +57,8 @@ public:
|
||||
KGFX_SKID1R = KGFX_SKIDR,
|
||||
KGFX_SKID2L,
|
||||
KGFX_SKID2R,
|
||||
KGFX_EXHAUST1,
|
||||
KGFX_EXHAUST2,
|
||||
KGFX_COUNT};
|
||||
|
||||
private:
|
||||
|
@ -215,6 +215,10 @@ void KartModel::loadInfo(const XMLNode &node)
|
||||
}
|
||||
}
|
||||
|
||||
if (const XMLNode* exhaust = node.getNode("exhaust"))
|
||||
{
|
||||
exhaust->get("file", &m_exhaust_xml);
|
||||
}
|
||||
} // loadInfo
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -336,6 +340,7 @@ KartModel* KartModel::makeCopy(KartRenderType krt)
|
||||
km->m_render_info = new RenderInfo();
|
||||
km->m_inverse_bone_matrices = m_inverse_bone_matrices;
|
||||
km->m_version = m_version;
|
||||
km->m_exhaust_xml = m_exhaust_xml;
|
||||
km->m_render_info->setKartModelRenderInfo(krt);
|
||||
|
||||
km->m_nitro_emitter_position[0] = m_nitro_emitter_position[0];
|
||||
@ -1206,6 +1211,12 @@ void KartModel::toggleHeadlights(bool on)
|
||||
} // toggleHeadlights
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called when a kart is load. this will load all the inverse bone matrices
|
||||
* for each bone in straight frame. The location, rotation and scale in
|
||||
* kart.xml for attachments (speedweighted objects, headlight, hat...) are in
|
||||
* object space, so if you use a inverse bone matrix * that matrix, it will be
|
||||
* relative to the bone, and you can use the result to set parent.
|
||||
*/
|
||||
void KartModel::initInverseBoneMatrices()
|
||||
{
|
||||
if (m_version < 3)
|
||||
@ -1225,16 +1236,19 @@ void KartModel::initInverseBoneMatrices()
|
||||
m_model_filename.c_str());
|
||||
striaght_frame = 0.0f;
|
||||
}
|
||||
node->setCurrentFrame(striaght_frame);
|
||||
|
||||
const unsigned total_joint = node->getJointCount();
|
||||
for (unsigned i = 0; i < total_joint; i++)
|
||||
{
|
||||
node->setCurrentFrame(striaght_frame);
|
||||
node->OnAnimate(0);
|
||||
scene::IBoneSceneNode* bone = node->getJointNode(i);
|
||||
bone->updateAbsolutePosition();
|
||||
const core::matrix4 mat = bone->getAbsoluteTransformation();
|
||||
node->setCurrentFrame(striaght_frame);
|
||||
node->OnAnimate(0);
|
||||
bone->updateAbsolutePosition();
|
||||
core::matrix4 inv;
|
||||
mat.getInverse(inv);
|
||||
bone->getAbsoluteTransformation().getInverse(inv);
|
||||
const std::string bone_name = bone->getName();
|
||||
auto ret = m_inverse_bone_matrices.find(bone_name);
|
||||
if (ret != m_inverse_bone_matrices.end())
|
||||
|
@ -310,16 +310,27 @@ private:
|
||||
/** Pointer to the kart object belonging to this kart model. */
|
||||
AbstractKart* m_kart;
|
||||
|
||||
/** Tell the render type of this kart model, either colorized (red / blue now)
|
||||
* or transparent (ghost kart). */
|
||||
KartRenderType m_krt;
|
||||
|
||||
/** For our engine to get the desired hue / saturation for colorization. */
|
||||
RenderInfo* m_render_info;
|
||||
|
||||
/** True if this kart model can be colorization in red / blue (now only
|
||||
* used in soccer mode). */
|
||||
bool m_support_colorization;
|
||||
|
||||
/** Used to cache inverse bone matrices for each bone in straight frame
|
||||
* for attachment. */
|
||||
std::unordered_map<std::string, core::matrix4> m_inverse_bone_matrices;
|
||||
|
||||
/** Version of kart model (in kart.xml). */
|
||||
unsigned m_version;
|
||||
|
||||
/** Exhaust particle file (xml) for the kart, empty if disabled. */
|
||||
std::string m_exhaust_xml;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void initInverseBoneMatrices();
|
||||
// ------------------------------------------------------------------------
|
||||
@ -444,6 +455,8 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
const core::matrix4&
|
||||
getInverseBoneMatrix(const std::string& bone_name) const;
|
||||
// ------------------------------------------------------------------------
|
||||
const std::string& getExhaustXML() const { return m_exhaust_xml; }
|
||||
|
||||
}; // KartModel
|
||||
#endif
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
|
||||
|
||||
extern int main(int argc, char *argv[]);
|
||||
|
||||
struct android_app* global_android_app;
|
||||
@ -62,6 +64,9 @@ void android_main(struct android_app* app)
|
||||
|
||||
app_dummy();
|
||||
|
||||
// Initialize global Android window state variables
|
||||
CIrrDeviceAndroid::onCreate();
|
||||
|
||||
override_default_params();
|
||||
|
||||
global_android_app = app;
|
||||
|
@ -274,6 +274,8 @@ namespace Online
|
||||
uagent += (std::string)" (Macintosh)";
|
||||
#elif defined(__FreeBSD__)
|
||||
uagent += (std::string)" (FreeBSD)";
|
||||
#elif defined(ANDROID)
|
||||
uagent += (std::string)" (Android)";
|
||||
#elif defined(linux)
|
||||
uagent += (std::string)" (Linux)";
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user