summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java47
-rw-r--r--platform/android/java_glue.cpp33
-rw-r--r--platform/android/os_android.cpp140
-rw-r--r--platform/android/os_android.h2
-rw-r--r--platform/haiku/haiku_direct_window.cpp72
-rw-r--r--platform/iphone/SCsub1
-rw-r--r--platform/iphone/os_iphone.cpp98
-rw-r--r--platform/iphone/os_iphone.h4
-rw-r--r--platform/iphone/rasterizer_iphone.cpp2585
-rw-r--r--platform/iphone/rasterizer_iphone.h881
-rw-r--r--platform/javascript/os_javascript.cpp120
-rw-r--r--platform/javascript/os_javascript.h2
-rw-r--r--platform/osx/SCsub1
-rw-r--r--platform/osx/context_gl_osx.cpp103
-rw-r--r--platform/osx/context_gl_osx.h64
-rw-r--r--platform/osx/godot_osx.h38
-rw-r--r--platform/osx/godot_osx.mm208
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm246
-rw-r--r--platform/uwp/app.cpp38
-rw-r--r--platform/uwp/os_uwp.cpp16
-rw-r--r--platform/uwp/os_uwp.h2
-rw-r--r--platform/windows/os_windows.cpp263
-rw-r--r--platform/windows/os_windows.h1
-rw-r--r--platform/x11/os_x11.cpp117
-rw-r--r--platform/x11/os_x11.h2
26 files changed, 526 insertions, 4560 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
index 044efba1f3..6f308af360 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
@@ -355,36 +355,35 @@ public class PaymentsManager {
tempList.add(s);
}
packs.add(tempList);
-
- for (ArrayList<String> skuPartList : packs) {
- Bundle querySkus = new Bundle();
- querySkus.putStringArrayList("ITEM_ID_LIST", skuPartList);
- Bundle skuDetails = null;
- try {
- skuDetails = mService.getSkuDetails(3, activity.getPackageName(), "inapp", querySkus);
- if (!skuDetails.containsKey("DETAILS_LIST")) {
- int response = getResponseCodeFromBundle(skuDetails);
- if (response != BILLING_RESPONSE_RESULT_OK) {
- godotPaymentV3.errorSkuDetail(getResponseDesc(response));
- } else {
- godotPaymentV3.errorSkuDetail("No error but no detail list.");
- }
- return;
+ }
+ for (ArrayList<String> skuPartList : packs) {
+ Bundle querySkus = new Bundle();
+ querySkus.putStringArrayList("ITEM_ID_LIST", skuPartList);
+ Bundle skuDetails = null;
+ try {
+ skuDetails = mService.getSkuDetails(3, activity.getPackageName(), "inapp", querySkus);
+ if (!skuDetails.containsKey("DETAILS_LIST")) {
+ int response = getResponseCodeFromBundle(skuDetails);
+ if (response != BILLING_RESPONSE_RESULT_OK) {
+ godotPaymentV3.errorSkuDetail(getResponseDesc(response));
+ } else {
+ godotPaymentV3.errorSkuDetail("No error but no detail list.");
}
+ return;
+ }
- ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
+ ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
- for (String thisResponse : responseList) {
- Log.d("godot", "response = "+thisResponse);
- godotPaymentV3.addSkuDetail(thisResponse);
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- godotPaymentV3.errorSkuDetail("RemoteException error!");
+ for (String thisResponse : responseList) {
+ Log.d("godot", "response = "+thisResponse);
+ godotPaymentV3.addSkuDetail(thisResponse);
}
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ godotPaymentV3.errorSkuDetail("RemoteException error!");
}
- godotPaymentV3.completeSkuDetail();
}
+ godotPaymentV3.completeSkuDetail();
}
})).start();
}
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index 6882dad4f0..37f53a2478 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -610,7 +610,7 @@ struct JAndroidPointerEvent {
};
static List<JAndroidPointerEvent> pointer_events;
-static List<InputEvent> key_events;
+static List<Ref<InputEvent> > key_events;
static List<OS_Android::JoypadEvent> joy_events;
static bool initialized = false;
static Mutex *input_mutex = NULL;
@@ -1036,7 +1036,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job
while (key_events.size()) {
- InputEvent event = key_events.front()->get();
+ Ref<InputEvent> event = key_events.front()->get();
os_android->process_event(event);
key_events.pop_front();
@@ -1367,7 +1367,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env
jevent.device = p_device;
jevent.type = OS_Android::JOY_EVENT_BUTTON;
jevent.index = p_button;
- jevent.pressed = p_pressed;
+ jevent->is_pressed() = p_pressed;
input_mutex->lock();
joy_events.push_back(jevent);
@@ -1419,30 +1419,23 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jobject obj, jint p_scancode, jint p_unicode_char, jboolean p_pressed) {
- InputEvent ievent;
- ievent.type = InputEvent::KEY;
- ievent.device = 0;
+ Ref<InputEventKey> ievent;
int val = p_unicode_char;
int scancode = android_get_keysym(p_scancode);
- ievent.key.scancode = scancode;
- ievent.key.unicode = val;
- ievent.key.pressed = p_pressed;
+ ievent->set_scancode(scancode);
+ ievent->set_unicode(val);
+ ievent->set_pressed(p_pressed);
- print_line("Scancode: " + String::num(p_scancode) + ":" + String::num(ievent.key.scancode) + " Unicode: " + String::num(val));
-
- ievent.key.mod.shift = false;
- ievent.key.mod.alt = false;
- ievent.key.mod.control = false;
- ievent.key.echo = false;
+ print_line("Scancode: " + String::num(p_scancode) + ":" + String::num(ievent->get_scancode()) + " Unicode: " + String::num(val));
if (val == '\n') {
- ievent.key.scancode = KEY_ENTER;
+ ievent->set_scancode(KEY_ENTER);
} else if (val == 61448) {
- ievent.key.scancode = KEY_BACKSPACE;
- ievent.key.unicode = KEY_BACKSPACE;
+ ievent->set_scancode(KEY_BACKSPACE);
+ ievent->set_unicode(KEY_BACKSPACE);
} else if (val == 61453) {
- ievent.key.scancode = KEY_ENTER;
- ievent.key.unicode = KEY_ENTER;
+ ievent->set_scancode(KEY_ENTER);
+ ievent->set_unicode(KEY_ENTER);
} else if (p_scancode == 4) {
go_back_request = true;
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 6772964c2f..1c721c645c 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -344,7 +344,7 @@ void OS_Android::process_joy_event(OS_Android::JoypadEvent p_event) {
switch (p_event.type) {
case JOY_EVENT_BUTTON:
- input->joy_button(p_event.device, p_event.index, p_event.pressed);
+ input->joy_button(p_event.device, p_event.index, p_event->is_pressed());
break;
case JOY_EVENT_AXIS:
InputDefault::JoyAxis value;
@@ -360,7 +360,7 @@ void OS_Android::process_joy_event(OS_Android::JoypadEvent p_event) {
}
}
-void OS_Android::process_event(InputEvent p_event) {
+void OS_Android::process_event(Ref<InputEvent> p_event) {
input->parse_input_event(p_event);
}
@@ -374,25 +374,24 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
if (touch.size()) {
//end all if exist
- InputEvent ev;
- ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = BUTTON_LEFT;
- ev.mouse_button.button_mask = BUTTON_MASK_LEFT;
- ev.mouse_button.pressed = false;
- ev.mouse_button.x = touch[0].pos.x;
- ev.mouse_button.y = touch[0].pos.y;
- ev.mouse_button.global_x = touch[0].pos.x;
- ev.mouse_button.global_y = touch[0].pos.y;
- input->parse_input_event(ev);
+ {
+ Ref<InputEventMouseButton> ev;
+ ev.instance();
+ ev->set_button_index(BUTTON_LEFT);
+ ev->set_button_mask(BUTTON_MASK_LEFT);
+ ev->set_pressed(false);
+ ev->set_pos(touch[0].pos);
+ ev->set_global_pos(touch[0].pos);
+ input->parse_input_event(ev);
+ }
for (int i = 0; i < touch.size(); i++) {
- InputEvent ev;
- ev.type = InputEvent::SCREEN_TOUCH;
- ev.screen_touch.index = touch[i].id;
- ev.screen_touch.pressed = false;
- ev.screen_touch.x = touch[i].pos.x;
- ev.screen_touch.y = touch[i].pos.y;
+ Ref<InputEventScreenTouch> ev;
+ ev.instance();
+ ev->set_index(touch[i].id);
+ ev->set_pressed(false);
+ ev->set_pos(touch[i].pos);
input->parse_input_event(ev);
}
}
@@ -405,15 +404,14 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
{
//send mouse
- InputEvent ev;
- ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = BUTTON_LEFT;
- ev.mouse_button.button_mask = BUTTON_MASK_LEFT;
- ev.mouse_button.pressed = true;
- ev.mouse_button.x = touch[0].pos.x;
- ev.mouse_button.y = touch[0].pos.y;
- ev.mouse_button.global_x = touch[0].pos.x;
- ev.mouse_button.global_y = touch[0].pos.y;
+ Ref<InputEventMouseButton> ev;
+ ev.instance();
+ ev.type = Ref<InputEvent>::MOUSE_BUTTON;
+ ev->set_button_index(BUTTON_LEFT);
+ ev->set_button_mask(BUTTON_MASK_LEFT);
+ ev->set_pressed(true);
+ ev->set_pos(touch[0].pos);
+ ev->set_global_pos(touch[0].pos);
input->set_mouse_position(Point2(touch[0].pos.x, touch[0].pos.y));
last_mouse = touch[0].pos;
input->parse_input_event(ev);
@@ -422,12 +420,11 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
//send touch
for (int i = 0; i < touch.size(); i++) {
- InputEvent ev;
- ev.type = InputEvent::SCREEN_TOUCH;
- ev.screen_touch.index = touch[i].id;
- ev.screen_touch.pressed = true;
- ev.screen_touch.x = touch[i].pos.x;
- ev.screen_touch.y = touch[i].pos.y;
+ Ref<InputEventScreenTouch> ev;
+ ev.instance();
+ ev->set_index(touch[i].id);
+ ev->set_pressed(true);
+ ev->set_pos(touch[i].pos.x);
input->parse_input_event(ev);
}
@@ -436,16 +433,13 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
if (p_points.size()) {
//send mouse, should look for point 0?
- InputEvent ev;
- ev.type = InputEvent::MOUSE_MOTION;
- ev.mouse_motion.button_mask = BUTTON_MASK_LEFT;
- ev.mouse_motion.x = p_points[0].pos.x;
- ev.mouse_motion.y = p_points[0].pos.y;
+ Ref<InputEventMouseMotion> ev;
+ ev.instance();
+ ev->set_button_mask(BUTTON_MASK_LEFT);
+ ev->set_pos(p_points[0].pos.x);
input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
- ev.mouse_motion.speed_x = input->get_last_mouse_speed().x;
- ev.mouse_motion.speed_y = input->get_last_mouse_speed().y;
- ev.mouse_motion.relative_x = p_points[0].pos.x - last_mouse.x;
- ev.mouse_motion.relative_y = p_points[0].pos.y - last_mouse.y;
+ ev->set_speed(input->get_last_mouse_speed());
+ ev->set_relative(p_points[0].pos - last_mouse);
last_mouse = p_points[0].pos;
input->parse_input_event(ev);
}
@@ -468,13 +462,11 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
if (touch[i].pos == p_points[idx].pos)
continue; //no move unncesearily
- InputEvent ev;
- ev.type = InputEvent::SCREEN_DRAG;
- ev.screen_drag.index = touch[i].id;
- ev.screen_drag.x = p_points[idx].pos.x;
- ev.screen_drag.y = p_points[idx].pos.y;
- ev.screen_drag.relative_x = p_points[idx].pos.x - touch[i].pos.x;
- ev.screen_drag.relative_y = p_points[idx].pos.y - touch[i].pos.y;
+ Ref<InputEventScreenDrag> ev;
+ ev.instance();
+ ev->set_index(touch[i].id);
+ ev->set_pos(p_points[idx].pos.x);
+ ev->set_relative(p_points[idx].pos - touch[i].pos);
input->parse_input_event(ev);
touch[i].pos = p_points[idx].pos;
}
@@ -484,26 +476,23 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
if (touch.size()) {
//end all if exist
- InputEvent ev;
- ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = BUTTON_LEFT;
- ev.mouse_button.button_mask = BUTTON_MASK_LEFT;
- ev.mouse_button.pressed = false;
- ev.mouse_button.x = touch[0].pos.x;
- ev.mouse_button.y = touch[0].pos.y;
- ev.mouse_button.global_x = touch[0].pos.x;
- ev.mouse_button.global_y = touch[0].pos.y;
+ Ref<InputEventMouseButton> ev;
+ ev.instance();
+ ev->set_button_index(BUTTON_LEFT);
+ ev->set_button_mask(BUTTON_MASK_LEFT);
+ ev->set_pressed(false);
+ ev->set_pos(touch[0].pos.x);
+ ev->set_global_pos(touch[0].pos.x);
input->set_mouse_position(Point2(touch[0].pos.x, touch[0].pos.y));
input->parse_input_event(ev);
for (int i = 0; i < touch.size(); i++) {
- InputEvent ev;
- ev.type = InputEvent::SCREEN_TOUCH;
- ev.screen_touch.index = touch[i].id;
- ev.screen_touch.pressed = false;
- ev.screen_touch.x = touch[i].pos.x;
- ev.screen_touch.y = touch[i].pos.y;
+ Ref<InputEventScreenTouch> ev;
+ ev.instance();
+ ev->set_index(touch[i].id);
+ ev->set_pressed(false);
+ ev->set_pos(touch[i].pos);
input->parse_input_event(ev);
}
touch.clear();
@@ -517,12 +506,12 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
TouchPos tp = p_points[p_pointer];
touch.push_back(tp);
- InputEvent ev;
- ev.type = InputEvent::SCREEN_TOUCH;
- ev.screen_touch.index = tp.id;
- ev.screen_touch.pressed = true;
- ev.screen_touch.x = tp.pos.x;
- ev.screen_touch.y = tp.pos.y;
+ Ref<InputEventScreenTouch> ev;
+ ev.instance();
+
+ ev->set_index(tp.id);
+ ev->set_pressed(true);
+ ev->set_pos(tp.pos);
input->parse_input_event(ev);
} break;
@@ -531,12 +520,11 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
for (int i = 0; i < touch.size(); i++) {
if (touch[i].id == p_pointer) {
- InputEvent ev;
- ev.type = InputEvent::SCREEN_TOUCH;
- ev.screen_touch.index = touch[i].id;
- ev.screen_touch.pressed = false;
- ev.screen_touch.x = touch[i].pos.x;
- ev.screen_touch.y = touch[i].pos.y;
+ Ref<InputEventScreenTouch> ev;
+ ev.instance();
+ ev->set_index(touch[i].id);
+ ev->set_pressed(false);
+ ev->set_pos(touch[i].pos);
input->parse_input_event(ev);
touch.remove(i);
i--;
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index f1da2867f0..897c71a7df 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -231,7 +231,7 @@ public:
void process_gyroscope(const Vector3 &p_gyroscope);
void process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points);
void process_joy_event(JoypadEvent p_event);
- void process_event(InputEvent p_event);
+ void process_event(Ref<InputEvent> p_event);
void init_video_mode(int p_video_width, int p_video_height);
virtual Error native_video_play(String p_path, float p_volume);
diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp
index fb6d9afd85..4a9f8c780d 100644
--- a/platform/haiku/haiku_direct_window.cpp
+++ b/platform/haiku/haiku_direct_window.cpp
@@ -151,35 +151,35 @@ void HaikuDirectWindow::HandleMouseButton(BMessage *message) {
}
*/
- InputEvent mouse_event;
- mouse_event.type = InputEvent::MOUSE_BUTTON;
+ Ref<InputEvent> mouse_event;
+ mouse_event.type = Ref<InputEvent>::MOUSE_BUTTON;
mouse_event.device = 0;
mouse_event.mouse_button.mod = GetKeyModifierState(modifiers);
- mouse_event.mouse_button.button_mask = GetMouseButtonState(buttons);
- mouse_event.mouse_button.x = where.x;
- mouse_event.mouse_button.y = where.y;
+ mouse_event->get_button_mask() = GetMouseButtonState(buttons);
+ mouse_event->get_pos().x = where.x;
+ mouse_event->get_pos().y = where.y;
mouse_event.mouse_button.global_x = where.x;
mouse_event.mouse_button.global_y = where.y;
switch (button) {
default:
case B_PRIMARY_MOUSE_BUTTON:
- mouse_event.mouse_button.button_index = 1;
+ mouse_event->get_button_index() = 1;
break;
case B_SECONDARY_MOUSE_BUTTON:
- mouse_event.mouse_button.button_index = 2;
+ mouse_event->get_button_index() = 2;
break;
case B_TERTIARY_MOUSE_BUTTON:
- mouse_event.mouse_button.button_index = 3;
+ mouse_event->get_button_index() = 3;
break;
}
- mouse_event.mouse_button.pressed = (message->what == B_MOUSE_DOWN);
+ mouse_event->is_pressed() = (message->what == B_MOUSE_DOWN);
- if (message->what == B_MOUSE_DOWN && mouse_event.mouse_button.button_index == 1) {
+ if (message->what == B_MOUSE_DOWN && mouse_event->get_button_index() == 1) {
int32 clicks = message->FindInt32("clicks");
if (clicks > 1) {
@@ -207,12 +207,12 @@ void HaikuDirectWindow::HandleMouseMoved(BMessage *message) {
Point2i rel = pos - last_mouse_position;
- InputEvent motion_event;
- motion_event.type = InputEvent::MOUSE_MOTION;
+ Ref<InputEvent> motion_event;
+ motion_event.type = Ref<InputEvent>::MOUSE_MOTION;
motion_event.device = 0;
motion_event.mouse_motion.mod = GetKeyModifierState(modifiers);
- motion_event.mouse_motion.button_mask = GetMouseButtonState(buttons);
+ motion_event->get_button_mask() = GetMouseButtonState(buttons);
motion_event.mouse_motion.x = pos.x;
motion_event.mouse_motion.y = pos.y;
input->set_mouse_position(pos);
@@ -221,8 +221,8 @@ void HaikuDirectWindow::HandleMouseMoved(BMessage *message) {
motion_event.mouse_motion.speed_x = input->get_last_mouse_speed().x;
motion_event.mouse_motion.speed_y = input->get_last_mouse_speed().y;
- motion_event.mouse_motion.relative_x = rel.x;
- motion_event.mouse_motion.relative_y = rel.y;
+ motion_event->get_relative().x = rel.x;
+ motion_event->get_relative().y = rel.y;
last_mouse_position = pos;
@@ -235,22 +235,22 @@ void HaikuDirectWindow::HandleMouseWheelChanged(BMessage *message) {
return;
}
- InputEvent mouse_event;
- mouse_event.type = InputEvent::MOUSE_BUTTON;
+ Ref<InputEvent> mouse_event;
+ mouse_event.type = Ref<InputEvent>::MOUSE_BUTTON;
mouse_event.device = 0;
- mouse_event.mouse_button.button_index = wheel_delta_y < 0 ? 4 : 5;
+ mouse_event->get_button_index() = wheel_delta_y < 0 ? 4 : 5;
mouse_event.mouse_button.mod = GetKeyModifierState(last_key_modifier_state);
- mouse_event.mouse_button.button_mask = last_button_mask;
- mouse_event.mouse_button.x = last_mouse_position.x;
- mouse_event.mouse_button.y = last_mouse_position.y;
+ mouse_event->get_button_mask() = last_button_mask;
+ mouse_event->get_pos().x = last_mouse_position.x;
+ mouse_event->get_pos().y = last_mouse_position.y;
mouse_event.mouse_button.global_x = last_mouse_position.x;
mouse_event.mouse_button.global_y = last_mouse_position.y;
- mouse_event.mouse_button.pressed = true;
+ mouse_event->is_pressed() = true;
input->parse_input_event(mouse_event);
- mouse_event.mouse_button.pressed = false;
+ mouse_event->is_pressed() = false;
input->parse_input_event(mouse_event);
}
@@ -271,13 +271,13 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage *message) {
return;
}
- InputEvent event;
- event.type = InputEvent::KEY;
+ Ref<InputEvent> event;
+ event.type = Ref<InputEvent>::KEY;
event.device = 0;
event.key.mod = GetKeyModifierState(modifiers);
- event.key.pressed = (message->what == B_KEY_DOWN);
- event.key.scancode = KeyMappingHaiku::get_keysym(raw_char, key);
- event.key.echo = message->HasInt32("be:key_repeat");
+ event->is_pressed() = (message->what == B_KEY_DOWN);
+ event->get_scancode() = KeyMappingHaiku::get_keysym(raw_char, key);
+ event->is_echo() = message->HasInt32("be:key_repeat");
event.key.unicode = 0;
const char *bytes = NULL;
@@ -286,9 +286,9 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage *message) {
}
//make it consistent across platforms.
- if (event.key.scancode == KEY_BACKTAB) {
- event.key.scancode = KEY_TAB;
- event.key.mod.shift = true;
+ if (event->get_scancode() == KEY_BACKTAB) {
+ event->get_scancode() = KEY_TAB;
+ event->get_shift() = true;
}
input->parse_input_event(event);
@@ -308,13 +308,13 @@ void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage *message) {
int32 key = old_modifiers ^ modifiers;
- InputEvent event;
- event.type = InputEvent::KEY;
+ Ref<InputEvent> event;
+ event.type = Ref<InputEvent>::KEY;
event.device = 0;
event.key.mod = GetKeyModifierState(modifiers);
- event.key.pressed = ((modifiers & key) != 0);
- event.key.scancode = KeyMappingHaiku::get_modifier_keysym(key);
- event.key.echo = false;
+ event->is_pressed() = ((modifiers & key) != 0);
+ event->get_scancode() = KeyMappingHaiku::get_modifier_keysym(key);
+ event->is_echo() = false;
event.key.unicode = 0;
input->parse_input_event(event);
diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub
index 5d3267cff3..466b8241de 100644
--- a/platform/iphone/SCsub
+++ b/platform/iphone/SCsub
@@ -5,7 +5,6 @@ Import('env')
iphone_lib = [
'os_iphone.cpp',
- #'rasterizer_iphone.cpp',
'audio_driver_iphone.cpp',
'sem_iphone.cpp',
'gl_view.mm',
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index 0a9d776421..3e95d1a706 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -195,48 +195,45 @@ bool OSIPhone::iterate() {
void OSIPhone::key(uint32_t p_key, bool p_pressed) {
- InputEvent ev;
- ev.type = InputEvent::KEY;
- ev.key.echo = false;
- ev.key.pressed = p_pressed;
- ev.key.scancode = p_key;
- ev.key.unicode = p_key;
+ Ref<InputEventKey> ev;
+ ev.instance()
+ ev->set_echo(false);
+ ev->set_pressed(p_pressed);
+ ev->set_scancode(p_key);
+ ev->set_unicode(p_key);
queue_event(ev);
};
void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick, bool p_use_as_mouse) {
if (!GLOBAL_DEF("debug/disable_touch", false)) {
- InputEvent ev;
- ev.type = InputEvent::SCREEN_TOUCH;
- ev.screen_touch.index = p_idx;
- ev.screen_touch.pressed = p_pressed;
- ev.screen_touch.x = p_x;
- ev.screen_touch.y = p_y;
+ Ref<InputEventSreenTouch> ev;
+ ev.instance();
+
+ ev->set_index(p_idx);
+ ev->set_pressed(p_pressed);
+ ev->set_pos(Vector2(p_x, p_y));
queue_event(ev);
};
- mouse_list.pressed[p_idx] = p_pressed;
+ mouse_list->is_pressed()[p_idx] = p_pressed;
if (p_use_as_mouse) {
- InputEvent ev;
- ev.type = InputEvent::MOUSE_BUTTON;
- ev.device = 0;
- ev.mouse_button.pointer_index = p_idx;
-
+ Ref<InputEventMouseButton> ev;
+ ev.instance();
// swaped it for tilted screen
- //ev.mouse_button.x = ev.mouse_button.global_x = video_mode.height - p_y;
- //ev.mouse_button.y = ev.mouse_button.global_y = p_x;
- ev.mouse_button.x = ev.mouse_button.global_x = p_x;
- ev.mouse_button.y = ev.mouse_button.global_y = p_y;
+ //ev->get_pos().x = ev.mouse_button.global_x = video_mode.height - p_y;
+ //ev->get_pos().y = ev.mouse_button.global_y = p_x;
+ ev->set_pos(Vector2(ev.mouse_button.global_x, ev.mouse_button.global_y));
+ ev->set_global_pos(Vector2(ev.mouse_button.global_x, ev.mouse_button.global_y));
- //mouse_list.pressed[p_idx] = p_pressed;
+ //mouse_list->is_pressed()[p_idx] = p_pressed;
- input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
- ev.mouse_button.button_index = BUTTON_LEFT;
- ev.mouse_button.doubleclick = p_doubleclick;
- ev.mouse_button.pressed = p_pressed;
+ input->set_mouse_position(ev->get_pos());
+ ev->set_button_index(BUTTON_LEFT);
+ ev->set_doubleclick(p_doubleclick);
+ ev->set_pressed(p_pressed);
queue_event(ev);
};
@@ -246,46 +243,31 @@ void OSIPhone::mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_
if (!GLOBAL_DEF("debug/disable_touch", false)) {
- InputEvent ev;
- ev.type = InputEvent::SCREEN_DRAG;
- ev.screen_drag.index = p_idx;
- ev.screen_drag.x = p_x;
- ev.screen_drag.y = p_y;
- ev.screen_drag.relative_x = p_x - p_prev_x;
- ev.screen_drag.relative_y = p_y - p_prev_y;
+ Ref<InputEventScreenDrag> ev;
+ ev.instance();
+ ev->set_index(p_idx);
+ ev->set_pos(Vector2(p_x, p_y));
+ ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y));
queue_event(ev);
};
if (p_use_as_mouse) {
- InputEvent ev;
- ev.type = InputEvent::MOUSE_MOTION;
- ev.device = 0;
- ev.mouse_motion.pointer_index = p_idx;
-
- if (true) { // vertical
+ Ref<InputEventMouseMotion> ev;
+ ev.instance();
- ev.mouse_motion.x = ev.mouse_button.global_x = p_x;
- ev.mouse_motion.y = ev.mouse_button.global_y = p_y;
- ev.mouse_motion.relative_x = ev.mouse_motion.x - p_prev_x;
- ev.mouse_motion.relative_y = ev.mouse_motion.y - p_prev_y;
-
- } else { // horizontal?
- ev.mouse_motion.x = ev.mouse_button.global_x = video_mode.height - p_y;
- ev.mouse_motion.y = ev.mouse_button.global_y = p_x;
- ev.mouse_motion.relative_x = ev.mouse_motion.x - (video_mode.height - p_prev_x);
- ev.mouse_motion.relative_y = ev.mouse_motion.y - p_prev_x;
- };
+ ev->set_pos(Vector2(p_x, p_y));
+ ev->set_global_pos(Vector2(p_x, p_y));
+ ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y));
- input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
- ev.mouse_motion.speed_x = input->get_last_mouse_speed().x;
- ev.mouse_motion.speed_y = input->get_last_mouse_speed().y;
- ev.mouse_motion.button_mask = 1; // pressed
+ input->set_mouse_position(ev->get_pos());
+ ev->set_speed(input->get_last_mouse_speed());
+ ev->set_button_mask(BUTTON_LEFT); // pressed
queue_event(ev);
};
};
-void OSIPhone::queue_event(const InputEvent &p_event) {
+void OSIPhone::queue_event(const Ref<InputEvent> &p_event) {
ERR_FAIL_INDEX(event_count, MAX_EVENTS);
@@ -296,7 +278,7 @@ void OSIPhone::touches_cancelled() {
for (int i = 0; i < MAX_MOUSE_COUNT; i++) {
- if (mouse_list.pressed[i]) {
+ if (mouse_list->is_pressed()[i]) {
// send a mouse_up outside the screen
mouse_button(i, -1, -1, false, false, false);
@@ -416,7 +398,7 @@ Point2 OSIPhone::get_mouse_position() const {
int OSIPhone::get_mouse_button_state() const {
- return mouse_list.pressed[0];
+ return mouse_list->is_pressed()[0];
};
void OSIPhone::set_window_title(const String &p_title){};
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index 209bf00788..0da7e6d081 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -118,9 +118,9 @@ private:
Vector3 last_accel;
- InputEvent event_queue[MAX_EVENTS];
+ Ref<InputEvent> event_queue[MAX_EVENTS];
int event_count;
- void queue_event(const InputEvent &p_event);
+ void queue_event(const Ref<InputEvent> &p_event);
String data_dir;
String unique_ID;
diff --git a/platform/iphone/rasterizer_iphone.cpp b/platform/iphone/rasterizer_iphone.cpp
deleted file mode 100644
index ff13ff1b89..0000000000
--- a/platform/iphone/rasterizer_iphone.cpp
+++ /dev/null
@@ -1,2585 +0,0 @@
-/*************************************************************************/
-/* rasterizer_iphone.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifdef IPHONE_ENABLED
-
-#include "rasterizer_iphone.h"
-#include "global_config.h"
-#include "os/os.h"
-#include <stdio.h>
-
-_FORCE_INLINE_ static void _gl_load_transform(const Transform &tr) {
-
- GLfloat matrix[16] = { /* build a 16x16 matrix */
- tr.basis.elements[0][0],
- tr.basis.elements[1][0],
- tr.basis.elements[2][0],
- 0,
- tr.basis.elements[0][1],
- tr.basis.elements[1][1],
- tr.basis.elements[2][1],
- 0,
- tr.basis.elements[0][2],
- tr.basis.elements[1][2],
- tr.basis.elements[2][2],
- 0,
- tr.origin.x,
- tr.origin.y,
- tr.origin.z,
- 1
- };
-
- glLoadMatrixf(matrix);
-};
-
-_FORCE_INLINE_ static void _gl_mult_transform(const Transform &tr) {
-
- GLfloat matrix[16] = { /* build a 16x16 matrix */
- tr.basis.elements[0][0],
- tr.basis.elements[1][0],
- tr.basis.elements[2][0],
- 0,
- tr.basis.elements[0][1],
- tr.basis.elements[1][1],
- tr.basis.elements[2][1],
- 0,
- tr.basis.elements[0][2],
- tr.basis.elements[1][2],
- tr.basis.elements[2][2],
- 0,
- tr.origin.x,
- tr.origin.y,
- tr.origin.z,
- 1
- };
-
- glMultMatrixf(matrix);
-};
-
-static const GLenum prim_type[] = { GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
-
-static void _draw_primitive(int p_points, const float *p_vertices, const float *p_normals, const float *p_colors, const float *p_uvs, const Plane *p_tangents = NULL, int p_instanced = 1) {
-
- ERR_FAIL_COND(!p_vertices);
- ERR_FAIL_COND(p_points < 1 || p_points > 4);
-
- GLenum type = prim_type[p_points - 1];
-
- if (!p_colors) {
- glColor4f(1, 1, 1, 1);
- };
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, (GLvoid *)p_vertices);
-
- if (p_normals) {
-
- glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(GL_FLOAT, 0, (GLvoid *)p_normals);
- };
-
- if (p_colors) {
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer(4, GL_FLOAT, 0, p_colors);
- };
-
- if (p_uvs) {
-
- glClientActiveTexture(GL_TEXTURE0);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, 0, p_uvs);
- };
-
- glDrawArrays(type, 0, p_points);
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-};
-
-/* TEXTURE API */
-
-static Image _get_gl_image_and_format(const Image &p_image, Image::Format p_format, uint32_t p_flags, GLenum &r_gl_format, int &r_gl_components, bool &r_has_alpha_cache) {
-
- r_has_alpha_cache = false;
- Image image = p_image;
-
- switch (p_format) {
-
- case Image::FORMAT_L8: {
- r_gl_components = 1;
- r_gl_format = GL_LUMINANCE;
-
- } break;
- case Image::FORMAT_INTENSITY: {
-
- image.convert(Image::FORMAT_RGBA8);
- r_gl_components = 4;
- r_gl_format = GL_RGBA;
- r_has_alpha_cache = true;
- } break;
- case Image::FORMAT_LA8: {
-
- image.convert(Image::FORMAT_RGBA8);
- r_gl_components = 4;
- r_gl_format = GL_RGBA;
- r_has_alpha_cache = true;
- } break;
-
- case Image::FORMAT_INDEXED: {
-
- image.convert(Image::FORMAT_RGB8);
- r_gl_components = 3;
- r_gl_format = GL_RGB;
-
- } break;
-
- case Image::FORMAT_INDEXED_ALPHA: {
-
- image.convert(Image::FORMAT_RGBA8);
- r_gl_components = 4;
- r_gl_format = GL_RGB;
- r_has_alpha_cache = true;
-
- } break;
- case Image::FORMAT_RGB8: {
-
- r_gl_components = 3;
- r_gl_format = GL_RGB;
- } break;
- case Image::FORMAT_RGBA8: {
-
- r_gl_components = 4;
- r_gl_format = GL_RGBA;
- r_has_alpha_cache = true;
- } break;
- default: {
-
- ERR_FAIL_V(Image());
- }
- }
-
- return image;
-}
-
-RID RasterizerIPhone::texture_create() {
-
- Texture *texture = memnew(Texture);
- ERR_FAIL_COND_V(!texture, RID());
- glGenTextures(1, &texture->tex_id);
- texture->active = false;
-
- return texture_owner.make_rid(texture);
-}
-
-void RasterizerIPhone::texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags) {
-
- bool has_alpha_cache;
- int components;
- GLenum format;
-
- Texture *texture = texture_owner.get(p_texture);
- ERR_FAIL_COND(!texture);
- texture->width = p_width;
- texture->height = p_height;
- texture->format = p_format;
- texture->flags = p_flags;
- //texture->target = (p_flags & VS::TEXTURE_FLAG_CUBEMAP) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
- texture->target = GL_TEXTURE_2D;
-
- _get_gl_image_and_format(Image(), texture->format, texture->flags, format, components, has_alpha_cache);
-
- texture->gl_components_cache = components;
- texture->gl_format_cache = format;
- texture->format_has_alpha = has_alpha_cache;
- texture->has_alpha = false; //by default it doesn't have alpha unless something with alpha is blitteds
-
- glBindTexture(texture->target, texture->tex_id);
-
- if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS) {
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
- }
-
- if (texture->target == GL_TEXTURE_2D) {
- glTexImage2D(texture->target, 0, format, texture->width, texture->height, 0, format, GL_UNSIGNED_BYTE, NULL);
- }
-
- /*
- else {
- //cubemappor
- for (int i=0;i<6;i++)
- glTexImage2D(_cube_side_enum[i], 0, format, texture->width, texture->height, 0, format, GL_UNSIGNED_BYTE,NULL);
- }
- */
-
- glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtering
-
- if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
-
- glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering
- if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS) {
- //glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
- };
- }
-
- if (texture->flags & VS::TEXTURE_FLAG_REPEAT /* && texture->target != GL_TEXTURE_CUBE_MAP*/) {
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- } else {
-
- //glTexParameterf( texture->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE );
- glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
-
- texture->active = true;
-}
-
-void RasterizerIPhone::texture_blit_rect(RID p_texture, int p_x, int p_y, const Image &p_image, VS::CubeMapSide p_cube_side) {
-
- Texture *texture = texture_owner.get(p_texture);
-
- ERR_FAIL_COND(!texture);
- ERR_FAIL_COND(!texture->active);
- ERR_FAIL_COND(texture->format != p_image.get_format());
-
- int components;
- GLenum format;
- bool alpha;
-
- Image img = _get_gl_image_and_format(p_image, p_image.get_format(), texture->flags, format, components, alpha);
-
- if (img.detect_alpha())
- texture->has_alpha = true;
-
- GLenum blit_target = GL_TEXTURE_2D; //(texture->target == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D;
-
- PoolVector<uint8_t>::Read read = img.get_data().read();
-
- glBindTexture(texture->target, texture->tex_id);
- glTexSubImage2D(blit_target, 0, p_x, p_y, img.get_width(), img.get_height(), format, GL_UNSIGNED_BYTE, read.ptr());
-
- //glGenerateMipmap( texture->target );
-}
-
-Image RasterizerIPhone::texture_get_rect(RID p_texture, int p_x, int p_y, int p_width, int p_height, VS::CubeMapSide p_cube_side) const {
-
- return Image();
-}
-void RasterizerIPhone::texture_set_flags(RID p_texture, uint32_t p_flags) {
-
- Texture *texture = texture_owner.get(p_texture);
- ERR_FAIL_COND(!texture);
-
- glBindTexture(texture->target, texture->tex_id);
- uint32_t cube = texture->flags & VS::TEXTURE_FLAG_CUBEMAP;
- texture->flags = p_flags | cube; // can't remove a cube from being a cube
-
- if (texture->flags & VS::TEXTURE_FLAG_REPEAT /*&& texture->target != GL_TEXTURE_CUBE_MAP*/) {
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- } else {
- //glTexParameterf( texture->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE );
- glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
-
- if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
-
- glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering
- if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS)
- glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
-
- } else {
-
- glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // nearest
- }
-}
-uint32_t RasterizerIPhone::texture_get_flags(RID p_texture) const {
-
- Texture *texture = texture_owner.get(p_texture);
-
- ERR_FAIL_COND_V(!texture, 0);
-
- return texture->flags;
-}
-Image::Format RasterizerIPhone::texture_get_format(RID p_texture) const {
-
- Texture *texture = texture_owner.get(p_texture);
-
- ERR_FAIL_COND_V(!texture, Image::FORMAT_L8);
-
- return texture->format;
-}
-uint32_t RasterizerIPhone::texture_get_width(RID p_texture) const {
-
- Texture *texture = texture_owner.get(p_texture);
-
- ERR_FAIL_COND_V(!texture, 0);
-
- return texture->width;
-}
-uint32_t RasterizerIPhone::texture_get_height(RID p_texture) const {
-
- Texture *texture = texture_owner.get(p_texture);
-
- ERR_FAIL_COND_V(!texture, 0);
-
- return texture->height;
-}
-
-bool RasterizerIPhone::texture_has_alpha(RID p_texture) const {
-
- Texture *texture = texture_owner.get(p_texture);
-
- ERR_FAIL_COND_V(!texture, 0);
-
- return texture->has_alpha;
-}
-
-/* SHADER API */
-
-RID RasterizerIPhone::shader_create() {
-
- return RID();
-}
-
-void RasterizerIPhone::shader_node_add(RID p_shader, VS::ShaderNodeType p_type, int p_id) {
-}
-void RasterizerIPhone::shader_node_remove(RID p_shader, int p_id) {
-}
-void RasterizerIPhone::shader_node_change_type(RID p_shader, int p_id, VS::ShaderNodeType p_type) {
-}
-void RasterizerIPhone::shader_node_set_param(RID p_shader, int p_id, const Variant &p_value) {
-}
-
-void RasterizerIPhone::shader_get_node_list(RID p_shader, List<int> *p_node_list) const {
-}
-VS::ShaderNodeType RasterizerIPhone::shader_node_get_type(RID p_shader, int p_id) const {
-
- return VS::NODE_ADD;
-}
-Variant RasterizerIPhone::shader_node_get_param(RID p_shader, int p_id) const {
-
- return Variant();
-}
-
-void RasterizerIPhone::shader_connect(RID p_shader, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot) {
-}
-bool RasterizerIPhone::shader_is_connected(RID p_shader, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot) const {
-
- return false;
-}
-
-void RasterizerIPhone::shader_disconnect(RID p_shader, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot) {
-}
-
-void RasterizerIPhone::shader_get_connections(RID p_shader, List<VS::ShaderConnection> *p_connections) const {
-}
-
-void RasterizerIPhone::shader_clear(RID p_shader) {
-}
-
-/* COMMON MATERIAL API */
-
-void RasterizerIPhone::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
-}
-Variant RasterizerIPhone::material_get_param(RID p_material, const StringName &p_param) const {
-
- return Variant();
-}
-void RasterizerIPhone::material_get_param_list(RID p_material, List<String> *p_param_list) const {
-}
-
-void RasterizerIPhone::material_set_flag(RID p_material, VS::MaterialFlag p_flag, bool p_enabled) {
-}
-bool RasterizerIPhone::material_get_flag(RID p_material, VS::MaterialFlag p_flag) const {
-
- return false;
-}
-
-void RasterizerIPhone::material_set_blend_mode(RID p_material, VS::MaterialBlendMode p_mode) {
-}
-VS::MaterialBlendMode RasterizerIPhone::material_get_blend_mode(RID p_material) const {
-
- return VS::MATERIAL_BLEND_MODE_ADD;
-}
-
-void RasterizerIPhone::material_set_line_width(RID p_material, float p_line_width) {
-}
-float RasterizerIPhone::material_get_line_width(RID p_material) const {
-
- return 0;
-}
-
-/* FIXED MATERIAL */
-
-RID RasterizerIPhone::material_create() {
-
- return material_owner.make_rid(memnew(Material));
-}
-
-void RasterizerIPhone::fixed_material_set_parameter(RID p_material, VS::SpatialMaterialParam p_parameter, const Variant &p_value) {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND(!m);
- ERR_FAIL_INDEX(p_parameter, VisualServer::FIXED_MATERIAL_PARAM_MAX);
-
- m->parameters[p_parameter] = p_value;
-}
-Variant RasterizerIPhone::fixed_material_get_parameter(RID p_material, VS::SpatialMaterialParam p_parameter) const {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND_V(!m, Variant());
- ERR_FAIL_INDEX_V(p_parameter, VisualServer::FIXED_MATERIAL_PARAM_MAX, Variant());
-
- return m->parameters[p_parameter];
-}
-
-void RasterizerIPhone::fixed_material_set_texture(RID p_material, VS::SpatialMaterialParam p_parameter, RID p_texture) {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND(!m);
- ERR_FAIL_INDEX(p_parameter, VisualServer::FIXED_MATERIAL_PARAM_MAX);
-
- m->textures[p_parameter] = p_texture;
-}
-RID RasterizerIPhone::fixed_material_get_texture(RID p_material, VS::SpatialMaterialParam p_parameter) const {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND_V(!m, RID());
- ERR_FAIL_INDEX_V(p_parameter, VisualServer::FIXED_MATERIAL_PARAM_MAX, Variant());
-
- return m->textures[p_parameter];
-}
-
-void RasterizerIPhone::fixed_material_set_detail_blend_mode(RID p_material, VS::MaterialBlendMode p_mode) {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND(!m);
-
- m->detail_blend_mode = p_mode;
-}
-VS::MaterialBlendMode RasterizerIPhone::fixed_material_get_detail_blend_mode(RID p_material) const {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND_V(!m, VS::MATERIAL_BLEND_MODE_MIX);
-
- return m->detail_blend_mode;
-}
-
-void RasterizerIPhone::fixed_material_set_texcoord_mode(RID p_material, VS::SpatialMaterialParam p_parameter, VS::SpatialMaterialTexCoordMode p_mode) {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND(!m);
- ERR_FAIL_INDEX(p_parameter, VisualServer::FIXED_MATERIAL_PARAM_MAX);
-
- m->texcoord_mode[p_parameter] = p_mode;
-}
-VS::SpatialMaterialTexCoordMode RasterizerIPhone::fixed_material_get_texcoord_mode(RID p_material, VS::SpatialMaterialParam p_parameter) const {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND_V(!m, VS::FIXED_MATERIAL_TEXCOORD_TEXGEN);
- ERR_FAIL_INDEX_V(p_parameter, VisualServer::FIXED_MATERIAL_PARAM_MAX, VS::FIXED_MATERIAL_TEXCOORD_UV);
-
- return m->texcoord_mode[p_parameter]; // for now
-}
-
-void RasterizerIPhone::fixed_material_set_texgen_mode(RID p_material, VS::SpatialMaterialTexGenMode p_mode) {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND(!m);
-
- m->texgen_mode = p_mode;
-};
-
-VS::SpatialMaterialTexGenMode RasterizerIPhone::fixed_material_get_texgen_mode(RID p_material) const {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND_V(!m, VS::FIXED_MATERIAL_TEXGEN_SPHERE);
-
- return m->texgen_mode;
-};
-
-void RasterizerIPhone::fixed_material_set_uv_transform(RID p_material, const Transform &p_transform) {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND(!m);
-
- m->uv_transform = p_transform;
-}
-Transform RasterizerIPhone::fixed_material_get_uv_transform(RID p_material) const {
-
- Material *m = material_owner.get(p_material);
- ERR_FAIL_COND_V(!m, Transform());
-
- return m->uv_transform;
-}
-
-/* SHADER MATERIAL */
-
-RID RasterizerIPhone::shader_material_create() const {
-
- return RID();
-}
-
-void RasterizerIPhone::shader_material_set_vertex_shader(RID p_material, RID p_shader, bool p_owned) {
-}
-RID RasterizerIPhone::shader_material_get_vertex_shader(RID p_material) const {
-
- return RID();
-}
-
-void RasterizerIPhone::shader_material_set_fragment_shader(RID p_material, RID p_shader, bool p_owned) {
-}
-RID RasterizerIPhone::shader_material_get_fragment_shader(RID p_material) const {
-
- return RID();
-}
-
-/* MESH API */
-
-RID RasterizerIPhone::mesh_create() {
-
- return mesh_owner.make_rid(memnew(Mesh));
-}
-
-void RasterizerIPhone::mesh_add_surface(RID p_mesh, VS::PrimitiveType p_primitive, uint32_t p_format, int p_array_len, int p_index_array_len) {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND(!mesh);
-
- ERR_FAIL_COND((p_format & VS::ARRAY_FORMAT_VERTEX) == 0); // mandatory
- ERR_FAIL_COND(p_array_len <= 0);
- ERR_FAIL_COND(p_index_array_len == 0);
- ERR_FAIL_INDEX(p_primitive, VS::PRIMITIVE_MAX);
-
- Surface *surface = memnew(Surface);
- ERR_FAIL_COND(!surface);
-
- int total_elem_size = 0;
-
- bool use_VBO = true; //glGenBuffersARB!=NULL; // TODO detect if it's in there
- if (p_format & VS::ARRAY_FORMAT_WEIGHTS) {
-
- use_VBO = false;
- }
-
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
-
- Surface::ArrayData &ad = surface->array[i];
- ad.size = 0;
- ad.configured = false;
- ad.ofs = 0;
- int elem_size = 0;
- int elem_count = 0;
-
- if (!(p_format & (1 << i))) // no array
- continue;
-
- switch (i) {
-
- case VS::ARRAY_VERTEX:
- case VS::ARRAY_NORMAL: {
-
- elem_size = 3 * sizeof(GLfloat); // vertex
- elem_count = 3;
- } break;
- case VS::ARRAY_TANGENT: {
- elem_size = 4 * sizeof(GLfloat); // vertex
- elem_count = 4;
-
- } break;
- case VS::ARRAY_COLOR: {
-
- elem_size = 4; /* RGBA */
- elem_count = 4;
- } break;
- case VS::ARRAY_TEX_UV: {
- elem_size = 2 * sizeof(GLfloat);
- elem_count = 2;
-
- } break;
- case VS::ARRAY_WEIGHTS:
- case VS::ARRAY_BONES: {
-
- elem_size = VS::ARRAY_WEIGHTS_SIZE * sizeof(GLfloat);
- elem_count = VS::ARRAY_WEIGHTS_SIZE;
-
- } break;
- case VS::ARRAY_INDEX: {
-
- if (p_index_array_len <= 0) {
- ERR_PRINT("p_index_array_len==NO_INDEX_ARRAY");
- break;
- }
- /* determine wether using 8 or 16 bits indices */
- if (p_index_array_len > (1 << 8)) {
-
- elem_size = 2;
- } else {
- elem_size = 1;
- }
-
- if (use_VBO) {
-
- glGenBuffers(1, &surface->index_id);
- ERR_FAIL_COND(surface->index_id == 0);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surface->index_id);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, p_index_array_len * elem_size, NULL, GL_STATIC_DRAW);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); //unbind
- } else {
- surface->index_array_local = (uint8_t *)memalloc(p_index_array_len * elem_size);
- };
-
- surface->index_array_len = p_index_array_len; // only way it can exist
- ad.ofs = 0;
- ad.size = elem_size;
- ad.configured = false;
- ad.components = 1;
-
- continue;
- } break;
- default: {
- ERR_FAIL();
- }
- }
-
- ad.ofs = total_elem_size;
- ad.size = elem_size;
- ad.components = elem_count;
- total_elem_size += elem_size;
- ad.configured = false;
- }
-
- surface->stride = total_elem_size;
- surface->array_len = p_array_len;
- surface->format = p_format;
- surface->primitive = p_primitive;
-
- /* bind the bigass buffers */
- if (use_VBO) {
-
- glGenBuffers(1, &surface->vertex_id);
- ERR_FAIL_COND(surface->vertex_id == 0);
- glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id);
- glBufferData(GL_ARRAY_BUFFER, surface->array_len * surface->stride, NULL, GL_STATIC_DRAW);
- glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
- } else {
- surface->array_local = (uint8_t *)memalloc(surface->array_len * surface->stride);
- };
-
- mesh->surfaces.push_back(surface);
-}
-
-Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface, VS::ArrayType p_type, const Variant &p_array) {
-
- ERR_FAIL_INDEX_V(p_type, VS::ARRAY_MAX, ERR_INVALID_PARAMETER);
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND_V(!mesh, ERR_INVALID_PARAMETER);
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), ERR_INVALID_PARAMETER);
- Surface *surface = mesh->surfaces[p_surface];
- ERR_FAIL_COND_V(!surface, ERR_INVALID_PARAMETER);
-
- ERR_FAIL_COND_V(surface->array[p_type].size == 0, ERR_INVALID_PARAMETER);
-
- Surface::ArrayData &a = surface->array[p_type];
-
- switch (p_type) {
-
- case VS::ARRAY_INDEX: {
- ERR_FAIL_COND_V(surface->index_array_len <= 0, ERR_INVALID_DATA);
- ERR_FAIL_COND_V(p_array.get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER);
-
- PoolVector<int> indices = p_array;
- ERR_FAIL_COND_V(indices.size() == 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(indices.size() != surface->index_array_len, ERR_INVALID_PARAMETER);
-
- /* determine wether using 16 or 32 bits indices */
-
- if (surface->index_array_local == 0) {
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surface->index_id);
- };
-
- PoolVector<int>::Read read = indices.read();
- const int *src = read.ptr();
-
- for (int i = 0; i < surface->index_array_len; i++) {
-
- if (surface->index_array_local) {
-
- if (a.size <= (1 << 8)) {
- uint8_t v = src[i];
-
- copymem(&surface->array_local[i * a.size], &v, a.size);
- } else {
- uint16_t v = src[i];
-
- copymem(&surface->array_local[i * a.size], &v, a.size);
- }
-
- } else {
- if (a.size <= (1 << 8)) {
- uint8_t v = src[i];
-
- glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, i * a.size, a.size, &v);
- } else {
- uint16_t v = src[i];
-
- glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, i * a.size, a.size, &v);
- }
- };
- }
- if (surface->index_array_local == 0) {
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
- };
- a.configured = true;
- return OK;
- } break;
- case VS::ARRAY_VERTEX:
- case VS::ARRAY_NORMAL: {
-
- ERR_FAIL_COND_V(p_array.get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
-
- PoolVector<Vector3> array = p_array;
- ERR_FAIL_COND_V(array.size() != surface->array_len, ERR_INVALID_PARAMETER);
-
- if (surface->array_local == 0) {
- glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id);
- };
-
- PoolVector<Vector3>::Read read = array.read();
- const Vector3 *src = read.ptr();
-
- // setting vertices means regenerating the AABB
- if (p_type == VS::ARRAY_VERTEX)
- surface->aabb = AABB();
-
- for (int i = 0; i < surface->array_len; i++) {
-
- GLfloat vector[3] = { src[i].x, src[i].y, src[i].z };
-
- if (surface->array_local == 0) {
- glBufferSubData(GL_ARRAY_BUFFER, a.ofs + i * surface->stride, a.size, vector);
- } else {
- copymem(&surface->array_local[a.ofs + i * surface->stride], vector, a.size);
- }
-
- if (p_type == VS::ARRAY_VERTEX) {
-
- if (i == 0) {
-
- surface->aabb = AABB(src[i], Vector3());
- } else {
-
- surface->aabb.expand_to(src[i]);
- }
- }
- }
-
- if (surface->array_local == 0) {
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- };
-
- } break;
- case VS::ARRAY_TANGENT: {
-
- ERR_FAIL_COND_V(p_array.get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER);
-
- PoolVector<real_t> array = p_array;
-
- ERR_FAIL_COND_V(array.size() != surface->array_len * 4, ERR_INVALID_PARAMETER);
-
- if (surface->array_local == 0) {
- glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id);
- };
-
- PoolVector<real_t>::Read read = array.read();
- const real_t *src = read.ptr();
-
- for (int i = 0; i < surface->array_len; i++) {
-
- GLfloat xyzw[4] = {
- src[i * 4 + 0],
- src[i * 4 + 1],
- src[i * 4 + 2],
- src[i * 4 + 3]
- };
-
- if (surface->array_local == 0) {
-
- glBufferSubData(GL_ARRAY_BUFFER, a.ofs + i * surface->stride, a.size, xyzw);
- } else {
-
- copymem(&surface->array_local[a.ofs + i * surface->stride], xyzw, a.size);
- };
- }
-
- if (surface->array_local == 0) {
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- };
- } break;
- case VS::ARRAY_COLOR: {
-
- ERR_FAIL_COND_V(p_array.get_type() != Variant::COLOR_ARRAY, ERR_INVALID_PARAMETER);
-
- PoolVector<Color> array = p_array;
-
- ERR_FAIL_COND_V(array.size() != surface->array_len, ERR_INVALID_PARAMETER);
-
- if (surface->array_local == 0)
- glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id);
-
- PoolVector<Color>::Read read = array.read();
- const Color *src = read.ptr();
- surface->has_alpha_cache = false;
-
- for (int i = 0; i < surface->array_len; i++) {
-
- if (src[i].a < 0.98) // tolerate alpha a bit, for crappy exporters
- surface->has_alpha_cache = true;
- uint8_t colors[4] = { src[i].r * 255.0, src[i].g * 255.0, src[i].b * 255.0, src[i].a * 255.0 };
- // I'm not sure if this is correct, endianness-wise, i should re-check the GL spec
-
- if (surface->array_local == 0)
- glBufferSubData(GL_ARRAY_BUFFER, a.ofs + i * surface->stride, a.size, colors);
- else
- copymem(&surface->array_local[a.ofs + i * surface->stride], colors, a.size);
- }
-
- if (surface->array_local == 0)
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- } break;
- case VS::ARRAY_TEX_UV: {
-
- ERR_FAIL_COND_V(p_array.get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
-
- PoolVector<Vector3> array = p_array;
-
- ERR_FAIL_COND_V(array.size() != surface->array_len, ERR_INVALID_PARAMETER);
-
- if (surface->array_local == 0)
- glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id);
-
- PoolVector<Vector3>::Read read = array.read();
-
- const Vector3 *src = read.ptr();
-
- for (int i = 0; i < surface->array_len; i++) {
-
- GLfloat uv[2] = { src[i].x, src[i].y };
-
- if (surface->array_local == 0)
- glBufferSubData(GL_ARRAY_BUFFER, a.ofs + i * surface->stride, a.size, uv);
- else
- copymem(&surface->array_local[a.ofs + i * surface->stride], uv, a.size);
- }
-
- if (surface->array_local == 0)
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- } break;
- case VS::ARRAY_BONES:
- case VS::ARRAY_WEIGHTS: {
-
- ERR_FAIL_COND_V(p_array.get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER);
-
- PoolVector<real_t> array = p_array;
-
- ERR_FAIL_COND_V(array.size() != surface->array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER);
-
- if (surface->array_local == 0)
- glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id);
-
- PoolVector<real_t>::Read read = array.read();
-
- const real_t *src = read.ptr();
-
- for (int i = 0; i < surface->array_len; i++) {
-
- GLfloat data[VS::ARRAY_WEIGHTS_SIZE];
- for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++)
- data[j] = src[i * VS::ARRAY_WEIGHTS_SIZE + j];
-
- if (surface->array_local == 0)
- glBufferSubData(GL_ARRAY_BUFFER, a.ofs + i * surface->stride, a.size, data);
- else
- copymem(&surface->array_local[a.ofs + i * surface->stride], data, a.size);
- }
-
- if (surface->array_local == 0)
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- } break;
- default: { ERR_FAIL_V(ERR_INVALID_PARAMETER); }
- }
-
- a.configured = true;
-
- return OK;
-}
-Variant RasterizerIPhone::mesh_surface_get_array(RID p_mesh, int p_surface, VS::ArrayType p_type) const {
-
- return Variant();
-}
-
-void RasterizerIPhone::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material, bool p_owned) {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND(!mesh);
- ERR_FAIL_INDEX(p_surface, mesh->surfaces.size());
- Surface *surface = mesh->surfaces[p_surface];
- ERR_FAIL_COND(!surface);
-
- if (surface->material_owned && surface->material.is_valid())
- free(surface->material);
-
- surface->material_owned = p_owned;
-
- surface->material = p_material;
-}
-
-RID RasterizerIPhone::mesh_surface_get_material(RID p_mesh, int p_surface) const {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND_V(!mesh, RID());
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), RID());
- Surface *surface = mesh->surfaces[p_surface];
- ERR_FAIL_COND_V(!surface, RID());
-
- return surface->material;
-}
-
-int RasterizerIPhone::mesh_surface_get_array_len(RID p_mesh, int p_surface) const {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND_V(!mesh, -1);
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), -1);
- Surface *surface = mesh->surfaces[p_surface];
- ERR_FAIL_COND_V(!surface, -1);
-
- return surface->array_len;
-}
-int RasterizerIPhone::mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND_V(!mesh, -1);
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), -1);
- Surface *surface = mesh->surfaces[p_surface];
- ERR_FAIL_COND_V(!surface, -1);
-
- return surface->index_array_len;
-}
-uint32_t RasterizerIPhone::mesh_surface_get_format(RID p_mesh, int p_surface) const {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND_V(!mesh, 0);
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), 0);
- Surface *surface = mesh->surfaces[p_surface];
- ERR_FAIL_COND_V(!surface, 0);
-
- return surface->format;
-}
-VS::PrimitiveType RasterizerIPhone::mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND_V(!mesh, VS::PRIMITIVE_POINTS);
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), VS::PRIMITIVE_POINTS);
- Surface *surface = mesh->surfaces[p_surface];
- ERR_FAIL_COND_V(!surface, VS::PRIMITIVE_POINTS);
-
- return surface->primitive;
-}
-
-void RasterizerIPhone::mesh_erase_surface(RID p_mesh, int p_index) {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND(!mesh);
- ERR_FAIL_INDEX(p_index, mesh->surfaces.size());
- Surface *surface = mesh->surfaces[p_index];
- ERR_FAIL_COND(!surface);
-
- memdelete(mesh->surfaces[p_index]);
- mesh->surfaces.remove(p_index);
-}
-int RasterizerIPhone::mesh_get_surface_count(RID p_mesh) const {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND_V(!mesh, -1);
-
- return mesh->surfaces.size();
-}
-
-AABB RasterizerIPhone::mesh_get_aabb(RID p_mesh) const {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND_V(!mesh, AABB());
-
- AABB aabb;
-
- for (int i = 0; i < mesh->surfaces.size(); i++) {
-
- if (i == 0)
- aabb = mesh->surfaces[i]->aabb;
- else
- aabb.merge_with(mesh->surfaces[i]->aabb);
- }
-
- return aabb;
-}
-
-/* MULTIMESH API */
-
-RID RasterizerIPhone::multimesh_create() {
-
- return RID();
-}
-
-void RasterizerIPhone::multimesh_set_instance_count(RID p_multimesh, int p_count) {
-}
-int RasterizerIPhone::multimesh_get_instance_count(RID p_multimesh) const {
-
- return 0;
-}
-
-void RasterizerIPhone::multimesh_set_mesh(RID p_multimesh, RID p_mesh) {
-}
-void RasterizerIPhone::multimesh_set_aabb(RID p_multimesh, const AABB &p_aabb) {
-}
-void RasterizerIPhone::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform) {
-}
-void RasterizerIPhone::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {
-}
-
-RID RasterizerIPhone::multimesh_get_mesh(RID p_multimesh) const {
-
- return RID();
-}
-AABB RasterizerIPhone::multimesh_get_aabb(RID p_multimesh) const {
-
- return AABB();
-}
-
-Transform RasterizerIPhone::multimesh_instance_get_transform(RID p_multimesh, int p_index) const {
-
- return Transform();
-}
-Color RasterizerIPhone::multimesh_instance_get_color(RID p_multimesh, int p_index) const {
-
- return Color();
-}
-
-/* POLY API */
-
-RID RasterizerIPhone::poly_create() {
-
- return RID();
-}
-void RasterizerIPhone::poly_set_material(RID p_poly, RID p_material, bool p_owned) {
-}
-void RasterizerIPhone::poly_add_primitive(RID p_poly, const Vector<Vector3> &p_points, const Vector<Vector3> &p_normals, const Vector<Color> &p_colors, const Vector<Vector3> &p_uvs) {
-}
-void RasterizerIPhone::poly_clear(RID p_poly) {
-}
-
-AABB RasterizerIPhone::poly_get_aabb(RID p_poly) const {
-
- return AABB();
-}
-
-/* PARTICLES API */
-
-RID RasterizerIPhone::particles_create() {
-
- return RID();
-}
-
-void RasterizerIPhone::particles_set_amount(RID p_particles, int p_amount) {
-}
-int RasterizerIPhone::particles_get_amount(RID p_particles) const {
-
- return 0;
-}
-
-void RasterizerIPhone::particles_set_emitting(RID p_particles, bool p_emitting) {
-}
-
-bool RasterizerIPhone::particles_is_emitting(RID p_particles) const {
-
- return false;
-}
-
-void RasterizerIPhone::particles_set_visibility_aabb(RID p_particles, const AABB &p_visibility) {
-}
-AABB RasterizerIPhone::particles_get_visibility_aabb(RID p_particles) const {
-
- return AABB();
-}
-
-void RasterizerIPhone::particles_set_emission_half_extents(RID p_particles, const Vector3 &p_half_extents) {
-}
-Vector3 RasterizerIPhone::particles_get_emission_half_extents(RID p_particles) const {
-
- return Vector3();
-}
-
-void RasterizerIPhone::particles_set_gravity_normal(RID p_particles, const Vector3 &p_normal) {
-}
-Vector3 RasterizerIPhone::particles_get_gravity_normal(RID p_particles) const {
-
- return Vector3();
-}
-
-void RasterizerIPhone::particles_set_variable(RID p_particles, VS::ParticleVariable p_variable, float p_value) {
-}
-float RasterizerIPhone::particles_get_variable(RID p_particles, VS::ParticleVariable p_variable) const {
-
- return 0;
-}
-
-void RasterizerIPhone::particles_set_randomness(RID p_particles, VS::ParticleVariable p_variable, float p_randomness) {
-}
-float RasterizerIPhone::particles_get_randomness(RID p_particles, VS::ParticleVariable p_variable) const {
-
- return 0;
-}
-
-void RasterizerIPhone::particles_set_color_phase_pos(RID p_particles, int p_phase, float p_pos) {
-}
-float RasterizerIPhone::particles_get_color_phase_pos(RID p_particles, int p_phase) const {
-
- return 0;
-}
-
-void RasterizerIPhone::particles_set_color_phases(RID p_particles, int p_phases) {
-}
-int RasterizerIPhone::particles_get_color_phases(RID p_particles) const {
-
- return 0;
-}
-
-void RasterizerIPhone::particles_set_color_phase_color(RID p_particles, int p_phase, const Color &p_color) {
-}
-Color RasterizerIPhone::particles_get_color_phase_color(RID p_particles, int p_phase) const {
-
- return Color();
-}
-
-void RasterizerIPhone::particles_set_attractors(RID p_particles, int p_attractors) {
-}
-int RasterizerIPhone::particles_get_attractors(RID p_particles) const {
-
- return 0;
-}
-
-void RasterizerIPhone::particles_set_attractor_pos(RID p_particles, int p_attractor, const Vector3 &p_pos) {
-}
-Vector3 RasterizerIPhone::particles_get_attractor_pos(RID p_particles, int p_attractor) const {
-
- return Vector3();
-}
-
-void RasterizerIPhone::particles_set_attractor_strength(RID p_particles, int p_attractor, float p_force) {
-}
-float RasterizerIPhone::particles_get_attractor_strength(RID p_particles, int p_attractor) const {
-
- return 0;
-}
-
-void RasterizerIPhone::particles_set_material(RID p_particles, RID p_material, bool p_owned) {
-}
-
-RID RasterizerIPhone::particles_get_material(RID p_particles) const {
-
- return RID();
-}
-
-AABB RasterizerIPhone::particles_get_aabb(RID p_particles) const {
-
- return AABB();
-}
-/* BEAM API */
-
-RID RasterizerIPhone::beam_create() {
-
- return RID();
-}
-
-void RasterizerIPhone::beam_set_point_count(RID p_beam, int p_count) {
-}
-int RasterizerIPhone::beam_get_point_count(RID p_beam) const {
-
- return 0;
-}
-void RasterizerIPhone::beam_clear(RID p_beam) {
-}
-
-void RasterizerIPhone::beam_set_point(RID p_beam, int p_point, Vector3 &p_pos) {
-}
-Vector3 RasterizerIPhone::beam_get_point(RID p_beam, int p_point) const {
-
- return Vector3();
-}
-
-void RasterizerIPhone::beam_set_primitive(RID p_beam, VS::BeamPrimitive p_primitive) {
-}
-
-VS::BeamPrimitive RasterizerIPhone::beam_get_primitive(RID p_beam) const {
-
- return VS::BEAM_CUBIC;
-}
-
-void RasterizerIPhone::beam_set_material(RID p_beam, RID p_material) {
-}
-RID RasterizerIPhone::beam_get_material(RID p_beam) const {
-
- return RID();
-}
-
-AABB RasterizerIPhone::beam_get_aabb(RID p_particles) const {
-
- return AABB();
-}
-/* SKELETON API */
-
-RID RasterizerIPhone::skeleton_create() {
-
- Skeleton *skeleton = memnew(Skeleton);
- ERR_FAIL_COND_V(!skeleton, RID());
- return skeleton_owner.make_rid(skeleton);
-}
-void RasterizerIPhone::skeleton_resize(RID p_skeleton, int p_bones) {
-
- Skeleton *skeleton = skeleton_owner.get(p_skeleton);
- ERR_FAIL_COND(!skeleton);
- if (p_bones == skeleton->bones.size()) {
- return;
- };
- ERR_FAIL_COND(p_bones < 0 || p_bones > 256);
-
- skeleton->bones.resize(p_bones);
-}
-int RasterizerIPhone::skeleton_get_bone_count(RID p_skeleton) const {
-
- Skeleton *skeleton = skeleton_owner.get(p_skeleton);
- ERR_FAIL_COND_V(!skeleton, -1);
- return skeleton->bones.size();
-}
-void RasterizerIPhone::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform) {
-
- Skeleton *skeleton = skeleton_owner.get(p_skeleton);
- ERR_FAIL_COND(!skeleton);
- ERR_FAIL_INDEX(p_bone, skeleton->bones.size());
-
- skeleton->bones[p_bone] = p_transform;
-}
-Transform RasterizerIPhone::skeleton_bone_get_transform(RID p_skeleton, int p_bone) {
-
- Skeleton *skeleton = skeleton_owner.get(p_skeleton);
- ERR_FAIL_COND_V(!skeleton, Transform());
- ERR_FAIL_INDEX_V(p_bone, skeleton->bones.size(), Transform());
-
- // something
- return skeleton->bones[p_bone];
-}
-
-/* LIGHT API */
-
-RID RasterizerIPhone::light_create(VS::LightType p_type) {
-
- Light *light = memnew(Light);
- light->type = p_type;
- return light_owner.make_rid(light);
-}
-
-VS::LightType RasterizerIPhone::light_get_type(RID p_light) const {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_OMNI);
- return light->type;
-}
-
-void RasterizerIPhone::light_set_color(RID p_light, VS::LightColor p_type, const Color &p_color) {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND(!light);
- ERR_FAIL_INDEX(p_type, 3);
- light->colors[p_type] = p_color;
-}
-Color RasterizerIPhone::light_get_color(RID p_light, VS::LightColor p_type) const {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND_V(!light, Color());
- ERR_FAIL_INDEX_V(p_type, 3, Color());
- return light->colors[p_type];
-}
-
-void RasterizerIPhone::light_set_shadow(RID p_light, bool p_enabled) {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND(!light);
- light->shadow_enabled = p_enabled;
-}
-
-bool RasterizerIPhone::light_has_shadow(RID p_light) const {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND_V(!light, false);
- return light->shadow_enabled;
-}
-
-void RasterizerIPhone::light_set_volumetric(RID p_light, bool p_enabled) {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND(!light);
- light->volumetric_enabled = p_enabled;
-}
-bool RasterizerIPhone::light_is_volumetric(RID p_light) const {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND_V(!light, false);
- return light->volumetric_enabled;
-}
-
-void RasterizerIPhone::light_set_projector(RID p_light, RID p_texture) {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND(!light);
- light->projector = p_texture;
-}
-RID RasterizerIPhone::light_get_projector(RID p_light) const {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND_V(!light, RID());
- return light->projector;
-}
-
-void RasterizerIPhone::light_set_var(RID p_light, VS::LightParam p_var, float p_value) {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND(!light);
- ERR_FAIL_INDEX(p_var, VS::LIGHT_PARAM_MAX);
-
- light->vars[p_var] = p_value;
-}
-float RasterizerIPhone::light_get_var(RID p_light, VS::LightParam p_var) const {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND_V(!light, 0);
-
- ERR_FAIL_INDEX_V(p_var, VS::LIGHT_PARAM_MAX, 0);
-
- return light->vars[p_var];
-}
-
-AABB RasterizerIPhone::light_get_aabb(RID p_light) const {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND_V(!light, AABB());
-
- switch (light->type) {
-
- case VS::LIGHT_SPOT: {
-
- float len = light->vars[VS::LIGHT_PARAM_RADIUS];
- float size = Math::tan(Math::deg2rad(light->vars[VS::LIGHT_PARAM_SPOT_ANGLE])) * len;
- return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
- } break;
- case VS::LIGHT_OMNI: {
-
- float r = light->vars[VS::LIGHT_PARAM_RADIUS];
- return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2);
- } break;
- case VS::LIGHT_DIRECTIONAL: {
-
- return AABB();
- } break;
- default: {}
- }
-
- ERR_FAIL_V(AABB());
-}
-
-RID RasterizerIPhone::light_instance_create(RID p_light) {
-
- Light *light = light_owner.get(p_light);
- ERR_FAIL_COND_V(!light, RID());
-
- LightInstance *light_instance = memnew(LightInstance);
-
- light_instance->light = p_light;
- light_instance->base = light;
- light_instance->last_pass = 0;
-
- return light_instance_owner.make_rid(light_instance);
-}
-void RasterizerIPhone::light_instance_set_transform(RID p_light_instance, const Transform &p_transform) {
-
- LightInstance *lighti = light_instance_owner.get(p_light_instance);
- ERR_FAIL_COND(!lighti);
- lighti->transform = p_transform;
-}
-
-void RasterizerIPhone::light_instance_set_active_hint(RID p_light_instance) {
-
- LightInstance *lighti = light_instance_owner.get(p_light_instance);
- ERR_FAIL_COND(!lighti);
- lighti->last_pass = frame;
-}
-bool RasterizerIPhone::light_instance_has_shadow(RID p_light_instance) const {
-
- return false;
-}
-bool RasterizerIPhone::light_instance_assign_shadow(RID p_light_instance) {
-
- return false;
-}
-Rasterizer::ShadowType RasterizerIPhone::light_instance_get_shadow_type(RID p_light_instance) const {
-
- return Rasterizer::SHADOW_CUBE;
-}
-int RasterizerIPhone::light_instance_get_shadow_passes(RID p_light_instance) const {
-
- return 0;
-}
-void RasterizerIPhone::light_instance_set_pssm_split_info(RID p_light_instance, int p_split, float p_near, float p_far, const CameraMatrix &p_camera, const Transform &p_transform) {
-}
-
-/* PARTICLES INSTANCE */
-
-RID RasterizerIPhone::particles_instance_create(RID p_particles) {
-
- return RID();
-}
-void RasterizerIPhone::particles_instance_set_transform(RID p_particles_instance, const Transform &p_transform) {
-}
-
-/* RENDER API */
-/* all calls (inside begin/end shadow) are always warranted to be in the following order: */
-
-static GLfloat rtri; // Angle For The Triangle ( NEW )
-static GLfloat rquad; // Angle For The Quad ( NEW )
-
-void RasterizerIPhone::begin_frame() {
-
- window_size = Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height);
-
- double time = (OS::get_singleton()->get_ticks_usec() / 1000); // get msec
- time /= 1000.0; // make secs
- time_delta = time - last_time;
- last_time = time;
- frame++;
- glClearColor(0, 0, 1, 1);
- glClear(GL_COLOR_BUFFER_BIT);
-
-/* nehe ?*/
-
-#if 0
- glViewport(0,0,window_size.width,window_size.height); // Reset The Current Viewport
-
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
-
- // Calculate The Aspect Ratio Of The Window
- gluPerspective(45.0f,(GLfloat)window_size.width/(GLfloat)window_size.height,0.1f,100.0f);
-
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
-
-
-
- glShadeModel(GL_SMOOTH); // Enable Smooth Shading
- glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
- glClearDepth(1.0f); // Depth Buffer Setup
- glEnable(GL_DEPTH_TEST); // Enables Depth Testing
- glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
- glLoadIdentity(); // Reset The Current Modelview Matrix
- glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0
- glRotatef(rtri,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis ( NEW )
- glBegin(GL_TRIANGLES); // Start Drawing A Triangle
- glColor3f(1.0f,0.0f,0.0f); // Red
- glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Front)
- glColor3f(0.0f,1.0f,0.0f); // Green
- glVertex3f(-1.0f,-1.0f, 1.0f); // Left Of Triangle (Front)
- glColor3f(0.0f,0.0f,1.0f); // Blue
- glVertex3f( 1.0f,-1.0f, 1.0f); // Right Of Triangle (Front)
- glColor3f(1.0f,0.0f,0.0f); // Red
- glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Right)
- glColor3f(0.0f,0.0f,1.0f); // Blue
- glVertex3f( 1.0f,-1.0f, 1.0f); // Left Of Triangle (Right)
- glColor3f(0.0f,1.0f,0.0f); // Green
- glVertex3f( 1.0f,-1.0f, -1.0f); // Right Of Triangle (Right)
- glColor3f(1.0f,0.0f,0.0f); // Red
- glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Back)
- glColor3f(0.0f,1.0f,0.0f); // Green
- glVertex3f( 1.0f,-1.0f, -1.0f); // Left Of Triangle (Back)
- glColor3f(0.0f,0.0f,1.0f); // Blue
- glVertex3f(-1.0f,-1.0f, -1.0f); // Right Of Triangle (Back)
- glColor3f(1.0f,0.0f,0.0f); // Red
- glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Left)
- glColor3f(0.0f,0.0f,1.0f); // Blue
- glVertex3f(-1.0f,-1.0f,-1.0f); // Left Of Triangle (Left)
- glColor3f(0.0f,1.0f,0.0f); // Green
- glVertex3f(-1.0f,-1.0f, 1.0f); // Right Of Triangle (Left)
- glEnd(); // Done Drawing The Pyramid
-
- glLoadIdentity(); // Reset The Current Modelview Matrix
- glTranslatef(1.5f,0.0f,-7.0f); // Move Right 1.5 Units And Into The Screen 7.0
- glRotatef(rquad,1.0f,1.0f,1.0f); // Rotate The Quad On The X axis ( NEW )
- glBegin(GL_QUADS); // Draw A Quad
- glColor3f(0.0f,1.0f,0.0f); // Set The Color To Green
- glVertex3f( 1.0f, 1.0f,-1.0f); // Top Right Of The Quad (Top)
- glVertex3f(-1.0f, 1.0f,-1.0f); // Top Left Of The Quad (Top)
- glVertex3f(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top)
- glVertex3f( 1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top)
- glColor3f(1.0f,0.5f,0.0f); // Set The Color To Orange
- glVertex3f( 1.0f,-1.0f, 1.0f); // Top Right Of The Quad (Bottom)
- glVertex3f(-1.0f,-1.0f, 1.0f); // Top Left Of The Quad (Bottom)
- glVertex3f(-1.0f,-1.0f,-1.0f); // Bottom Left Of The Quad (Bottom)
- glVertex3f( 1.0f,-1.0f,-1.0f); // Bottom Right Of The Quad (Bottom)
- glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red
- glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front)
- glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front)
- glVertex3f(-1.0f,-1.0f, 1.0f); // Bottom Left Of The Quad (Front)
- glVertex3f( 1.0f,-1.0f, 1.0f); // Bottom Right Of The Quad (Front)
- glColor3f(1.0f,1.0f,0.0f); // Set The Color To Yellow
- glVertex3f( 1.0f,-1.0f,-1.0f); // Top Right Of The Quad (Back)
- glVertex3f(-1.0f,-1.0f,-1.0f); // Top Left Of The Quad (Back)
- glVertex3f(-1.0f, 1.0f,-1.0f); // Bottom Left Of The Quad (Back)
- glVertex3f( 1.0f, 1.0f,-1.0f); // Bottom Right Of The Quad (Back)
- glColor3f(0.0f,0.0f,1.0f); // Set The Color To Blue
- glVertex3f(-1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left)
- glVertex3f(-1.0f, 1.0f,-1.0f); // Top Left Of The Quad (Left)
- glVertex3f(-1.0f,-1.0f,-1.0f); // Bottom Left Of The Quad (Left)
- glVertex3f(-1.0f,-1.0f, 1.0f); // Bottom Right Of The Quad (Left)
- glColor3f(1.0f,0.0f,1.0f); // Set The Color To Violet
- glVertex3f( 1.0f, 1.0f,-1.0f); // Top Right Of The Quad (Right)
- glVertex3f( 1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right)
- glVertex3f( 1.0f,-1.0f, 1.0f); // Bottom Left Of The Quad (Right)
- glVertex3f( 1.0f,-1.0f,-1.0f); // Bottom Right Of The Quad (Right)
- glEnd(); // Done Drawing The Quad
-
- rtri+=0.2f; // Increase The Rotation Variable For The Triangle ( NEW )
- rquad-=0.15f; // Decrease The Rotation Variable For The Quad ( NEW )
-
-#endif
-}
-
-void RasterizerIPhone::set_viewport(const VS::ViewportRect &p_viewport) {
-
- viewport = p_viewport;
- canvas_transform = Transform();
- canvas_transform.translate(-(viewport.width / 2.0f), -(viewport.height / 2.0f), 0.0f);
- canvas_transform.scale(Vector3(2.0f / viewport.width, -2.0f / viewport.height, 1.0f));
-
- glViewport(viewport.x, window_size.height - (viewport.height + viewport.y), viewport.width, viewport.height);
-}
-
-void RasterizerIPhone::begin_scene(RID p_fx, VS::ScenarioDebugMode p_debug) {
-
- opaque_render_list.clear();
- alpha_render_list.clear();
- light_instance_count = 0;
- scene_fx = p_fx.is_valid() ? fx_owner.get(p_fx) : NULL;
-};
-
-void RasterizerIPhone::begin_shadow_map(RID p_light_instance, int p_shadow_pass) {
-}
-
-void RasterizerIPhone::set_camera(const Transform &p_world, const CameraMatrix &p_projection) {
-
- camera_transform = p_world;
- camera_transform_inverse = camera_transform.inverse();
- camera_projection = p_projection;
- camera_plane = Plane(camera_transform.origin, camera_transform.basis.get_axis(2));
- camera_z_near = camera_projection.get_z_near();
- camera_z_far = camera_projection.get_z_far();
- camera_projection.get_viewport_size(camera_vp_size.x, camera_vp_size.y);
-}
-
-void RasterizerIPhone::add_light(RID p_light_instance) {
-
-#define LIGHT_FADE_TRESHOLD 0.05
-
- ERR_FAIL_COND(light_instance_count >= MAX_LIGHTS);
-
- LightInstance *li = light_instance_owner.get(p_light_instance);
- ERR_FAIL_COND(!li);
-
- /* make light hash */
-
- // actually, not really a hash, but helps to sort the lights
- // and avoid recompiling redudant shader versions
-
- li->hash_aux = li->base->type;
-
- if (li->base->shadow_enabled)
- li->hash_aux |= (1 << 3);
-
- if (li->base->projector.is_valid())
- li->hash_aux |= (1 << 4);
-
- if (li->base->shadow_enabled && li->base->volumetric_enabled)
- li->hash_aux |= (1 << 5);
-
- switch (li->base->type) {
-
- case VisualServer::LIGHT_DIRECTIONAL: {
-
- Vector3 dir = li->transform.basis.get_axis(2);
- li->light_vector.x = dir.x;
- li->light_vector.y = dir.y;
- li->light_vector.z = dir.z;
-
- } break;
- case VisualServer::LIGHT_OMNI: {
-
- float radius = li->base->vars[VisualServer::LIGHT_PARAM_RADIUS];
- if (radius == 0)
- radius = 0.0001;
- li->linear_att = (1 / LIGHT_FADE_TRESHOLD) / radius;
- li->light_vector.x = li->transform.origin.x;
- li->light_vector.y = li->transform.origin.y;
- li->light_vector.z = li->transform.origin.z;
-
- } break;
- case VisualServer::LIGHT_SPOT: {
-
- float radius = li->base->vars[VisualServer::LIGHT_PARAM_RADIUS];
- if (radius == 0)
- radius = 0.0001;
- li->linear_att = (1 / LIGHT_FADE_TRESHOLD) / radius;
- li->light_vector.x = li->transform.origin.x;
- li->light_vector.y = li->transform.origin.y;
- li->light_vector.z = li->transform.origin.z;
- Vector3 dir = -li->transform.basis.get_axis(2);
- li->spot_vector.x = dir.x;
- li->spot_vector.y = dir.y;
- li->spot_vector.z = dir.z;
-
- } break;
- }
-
- light_instances[light_instance_count++] = li;
-}
-
-void RasterizerIPhone::_add_geometry(const Geometry *p_geometry, const Transform &p_world, uint32_t p_vertex_format, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides, const Skeleton *p_skeleton, GeometryOwner *p_owner) {
-
- Material *m = NULL;
-
- if (p_geometry->material.is_valid())
- m = material_owner.get(p_geometry->material);
-
- if (!m) {
- m = material_owner.get(default_material);
- }
-
- ERR_FAIL_COND(!m);
-
- LightInstance *lights[RenderList::MAX_LIGHTS];
- int light_count = 0;
-
- RenderList *render_list = &opaque_render_list;
- if (p_geometry->has_alpha || m->detail_blend_mode != VS::MATERIAL_BLEND_MODE_MIX) {
- render_list = &alpha_render_list;
- };
-
- if (!m->flags[VS::MATERIAL_FLAG_UNSHADED]) {
-
- light_count = p_light_count;
- for (int i = 0; i < light_count; i++) {
- lights[i] = light_instance_owner.get(p_light_instances[i]);
- }
- }
-
- render_list->add_element(p_geometry, m, p_world, lights, light_count, p_material_overrides, p_skeleton, camera_plane.distance(p_world.origin), p_owner);
-}
-
-void RasterizerIPhone::add_mesh(RID p_mesh, const Transform *p_world, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides, RID p_skeleton) {
-
- Mesh *mesh = mesh_owner.get(p_mesh);
-
- int ssize = mesh->surfaces.size();
-
- for (int i = 0; i < ssize; i++) {
-
- Surface *s = mesh->surfaces[i];
- Skeleton *sk = p_skeleton.is_valid() ? skeleton_owner.get(p_skeleton) : NULL;
-
- _add_geometry(s, *p_world, s->format, p_light_instances, p_light_count, p_material_overrides, sk, NULL);
- }
-
- mesh->last_pass = frame;
-}
-
-void RasterizerIPhone::add_multimesh(RID p_multimesh, const Transform *p_world, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides) {
-}
-
-void RasterizerIPhone::add_poly(RID p_poly, const Transform *p_world, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides) {
-
- Poly *p = poly_owner.get(p_poly);
- if (!p->primitives.empty()) {
- const Poly::Primitive *pp = &p->primitives[0];
-
- uint32_t format = VisualServer::ARRAY_FORMAT_VERTEX;
-
- if (!pp->normals.empty())
- format |= VisualServer::ARRAY_FORMAT_NORMAL;
- if (!pp->colors.empty())
- format |= VisualServer::ARRAY_FORMAT_COLOR;
- if (!pp->uvs.empty())
- format |= VisualServer::ARRAY_TEX_UV;
-
- _add_geometry(p, *p_world, format, p_light_instances, p_light_count, p_material_overrides, NULL, NULL);
- }
-}
-
-void RasterizerIPhone::add_beam(RID p_beam, const Transform *p_world, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides) {
-}
-
-void RasterizerIPhone::add_particles(RID p_particle_instance, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides) {
-}
-
-void RasterizerIPhone::_setup_material(const Geometry *p_geometry, const Material *p_material) {
-
- if (p_material->flags[VS::MATERIAL_FLAG_DOUBLE_SIDED])
- glDisable(GL_CULL_FACE);
- else {
- glEnable(GL_CULL_FACE);
- glCullFace((p_material->flags[VS::MATERIAL_FLAG_INVERT_FACES]) ? GL_FRONT : GL_BACK);
- }
-
- glEnable(GL_COLOR_MATERIAL); /* unused, unless color array */
- //glColorMaterial( GL_FRONT_AND_BACK, GL_DIFFUSE );
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- ///ambient @TODO offer global ambient group option
- float ambient_rgba[4] = {
- 1,
- 1,
- 1,
- 1.0
- };
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient_rgba);
-
- ///diffuse
- const Color &diffuse_color = p_material->parameters[VS::FIXED_MATERIAL_PARAM_DIFFUSE];
- float diffuse_rgba[4] = {
- (float)diffuse_color.r,
- (float)diffuse_color.g,
- (float)diffuse_color.b,
- (float)diffuse_color.a
- };
-
- glColor4f(diffuse_rgba[0], diffuse_rgba[1], diffuse_rgba[2], diffuse_rgba[3]);
-
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse_rgba);
-
- //specular
-
- const Color &specular_color = p_material->parameters[VS::FIXED_MATERIAL_PARAM_SPECULAR];
- float specular_rgba[4] = {
- (float)specular_color.r,
- (float)specular_color.g,
- (float)specular_color.b,
- 1.0
- };
-
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular_rgba);
-
- const Color &emission_color = p_material->parameters[VS::FIXED_MATERIAL_PARAM_EMISSION];
- float emission_rgba[4] = {
- (float)emission_color.r,
- (float)emission_color.g,
- (float)emission_color.b,
- 1.0
- };
-
- glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, emission_rgba);
-
- glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, p_material->parameters[VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP]);
-
- if (p_material->flags[VS::MATERIAL_FLAG_UNSHADED]) {
- glDisable(GL_LIGHTING);
- } else {
- glEnable(GL_LIGHTING);
- glDisable(GL_LIGHTING);
- }
-
- //depth test?
- /*
- if (p_material->flags[VS::MATERIAL_FLAG_WIREFRAME])
- glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
- else
- glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
- */
- if (p_material->textures[VS::FIXED_MATERIAL_PARAM_DIFFUSE]) {
-
- Texture *texture = texture_owner.get(p_material->textures[VS::FIXED_MATERIAL_PARAM_DIFFUSE]);
- ERR_FAIL_COND(!texture);
- glActiveTexture(GL_TEXTURE0);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, texture->tex_id);
- };
-};
-
-void RasterizerIPhone::_setup_light(LightInstance *p_instance, int p_idx) {
-
- Light *ld = p_instance->base;
-
- int glid = GL_LIGHT0 + p_idx;
- glLightfv(glid, GL_AMBIENT, ld->colors[VS::LIGHT_COLOR_AMBIENT].components);
- glLightfv(glid, GL_DIFFUSE, ld->colors[VS::LIGHT_COLOR_DIFFUSE].components);
- glLightfv(glid, GL_SPECULAR, ld->colors[VS::LIGHT_COLOR_SPECULAR].components);
-
- switch (ld->type) {
-
- case VS::LIGHT_DIRECTIONAL: {
- /* This doesn't have attenuation */
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
- Vector3 v(0.0, 0.0, -1.0); // directional lights point up by default
- v = p_instance->transform.get_basis().xform(v);
- v = camera_transform_inverse.get_basis().xform(v);
- v.normalize(); // this sucks, so it will be optimized at some point
- v = -v;
- float lightpos[4] = { v.x, v.y, v.z, 0.0 };
-
- glLightfv(glid, GL_POSITION, lightpos); //at modelview
-
- glPopMatrix();
-
- } break;
- case VS::LIGHT_OMNI: {
-
- glLightf(glid, GL_SPOT_CUTOFF, 180.0);
- glLightf(glid, GL_CONSTANT_ATTENUATION, ld->vars[VS::LIGHT_PARAM_ATTENUATION]);
- glLightf(glid, GL_LINEAR_ATTENUATION, ld->vars[VS::LIGHT_PARAM_RADIUS]);
- glLightf(glid, GL_QUADRATIC_ATTENUATION, ld->vars[VS::LIGHT_PARAM_ENERGY]); // wut?
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
- Vector3 pos = p_instance->transform.get_origin();
- pos = camera_transform_inverse.xform(pos);
- float lightpos[4] = { pos.x, pos.y, pos.z, 1.0 };
- glLightfv(glid, GL_POSITION, lightpos); //at modelview
-
- glPopMatrix();
-
- } break;
- case VS::LIGHT_SPOT: {
-
- glLightf(glid, GL_SPOT_CUTOFF, ld->vars[VS::LIGHT_PARAM_SPOT_ANGLE]);
- glLightf(glid, GL_SPOT_EXPONENT, ld->vars[VS::LIGHT_PARAM_SPOT_ATTENUATION]);
- glLightf(glid, GL_CONSTANT_ATTENUATION, ld->vars[VS::LIGHT_PARAM_ATTENUATION]);
- glLightf(glid, GL_LINEAR_ATTENUATION, ld->vars[VS::LIGHT_PARAM_RADIUS]);
- glLightf(glid, GL_QUADRATIC_ATTENUATION, ld->vars[VS::LIGHT_PARAM_ENERGY]); // wut?
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- Vector3 v(0.0, 0.0, -1.0); // directional lights point up by default
- v = p_instance->transform.get_basis().xform(v);
- v = camera_transform_inverse.get_basis().xform(v);
- v.normalize(); // this sucks, so it will be optimized at some point
- float lightdir[4] = { v.x, v.y, v.z, 1.0 };
- glLightfv(glid, GL_SPOT_DIRECTION, lightdir); //at modelview
-
- v = p_instance->transform.get_origin();
- v = camera_transform_inverse.xform(v);
- float lightpos[4] = { v.x, v.y, v.z, 1.0 };
- glLightfv(glid, GL_POSITION, lightpos); //at modelview
-
- glPopMatrix();
-
- } break;
- default: break;
- }
-};
-
-void RasterizerIPhone::_setup_lights(LightInstance **p_lights, int p_light_count) {
-
- for (int i = 0; i < MAX_LIGHTS; i++) {
-
- if (i < p_light_count) {
- glEnable(GL_LIGHT0 + i);
- _setup_light(p_lights[i], i);
- } else {
- glDisable(GL_LIGHT0 + i);
- }
- }
-}
-
-static const int gl_client_states[] = {
-
- GL_VERTEX_ARRAY,
- GL_NORMAL_ARRAY,
- -1, // ARRAY_TANGENT
- GL_COLOR_ARRAY,
- GL_TEXTURE_COORD_ARRAY, // ARRAY_TEX_UV
- GL_TEXTURE_COORD_ARRAY, // ARRAY_TEX_UV2
- -1, // ARRAY_BONES
- -1, // ARRAY_WEIGHTS
- -1, // ARRAY_INDEX
-};
-
-void RasterizerIPhone::_setup_geometry(const Geometry *p_geometry, const Material *p_material) {
-
- switch (p_geometry->type) {
-
- case Geometry::GEOMETRY_SURFACE: {
-
- Surface *surf = (Surface *)p_geometry;
- uint8_t *base = 0;
- bool use_VBO = (surf->array_local == 0);
-
- if (!use_VBO) {
-
- base = surf->array_local;
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- } else {
-
- glBindBuffer(GL_ARRAY_BUFFER, surf->vertex_id);
- };
-
- const Surface::ArrayData *a = surf->array;
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
-
- const Surface::ArrayData &ad = surf->array[i];
- if (ad.size == 0) {
- if (gl_client_states[i] != -1) {
- glDisableClientState(gl_client_states[i]);
- };
- continue; // this one is disabled.
- }
- ERR_CONTINUE(!ad.configured);
-
- if (gl_client_states[i] != -1) {
- glEnableClientState(gl_client_states[i]);
- };
-
- switch (i) {
-
- case VS::ARRAY_VERTEX:
- if (!use_VBO)
- glVertexPointer(3, GL_FLOAT, surf->stride, (GLvoid *)&base[a->ofs]);
- else if (surf->array[VS::ARRAY_BONES].size)
- glVertexPointer(3, GL_FLOAT, 0, skinned_buffer);
- else
- glVertexPointer(3, GL_FLOAT, surf->stride, (GLvoid *)a->ofs);
- break;
-
- case VS::ARRAY_NORMAL:
- if (use_VBO)
- glNormalPointer(GL_FLOAT, surf->stride, (GLvoid *)a->ofs);
- else
- glNormalPointer(GL_FLOAT, surf->stride, (GLvoid *)&base[a->ofs]);
- break;
- case VS::ARRAY_TANGENT:
- break;
- case VS::ARRAY_COLOR:
- if (use_VBO)
- glColorPointer(4, GL_UNSIGNED_BYTE, surf->stride, (GLvoid *)a->ofs);
- else
- glColorPointer(4, GL_UNSIGNED_BYTE, surf->stride, (GLvoid *)&base[a->ofs]);
- break;
- case VS::ARRAY_TEX_UV:
- case VS::ARRAY_TEX_UV2:
- if (use_VBO)
- glTexCoordPointer(2, GL_FLOAT, surf->stride, (GLvoid *)a->ofs);
- else
- glTexCoordPointer(2, GL_FLOAT, surf->stride, &base[a->ofs]);
- break;
- case VS::ARRAY_BONES:
- case VS::ARRAY_WEIGHTS:
- case VS::ARRAY_INDEX:
- break;
- };
- }
-
- // process skeleton here
-
- } break;
-
- default: break;
- };
-};
-
-static const GLenum gl_primitive[] = {
- GL_POINTS,
- GL_LINES,
- GL_LINE_STRIP,
- GL_LINE_LOOP,
- GL_TRIANGLES,
- GL_TRIANGLE_STRIP,
- GL_TRIANGLE_FAN
-};
-
-void RasterizerIPhone::_render(const Geometry *p_geometry, const Material *p_material, const Skeleton *p_skeleton) {
-
- switch (p_geometry->type) {
-
- case Geometry::GEOMETRY_SURFACE: {
-
- Surface *s = (Surface *)p_geometry;
-
- if (s->index_array_len > 0) {
-
- if (s->index_array_local) {
-
- glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->index_array_len > (1 << 8)) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE, s->index_array_local);
-
- } else {
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id);
- glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->index_array_len > (1 << 8)) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE, 0);
- }
-
- } else {
-
- glDrawArrays(gl_primitive[s->primitive], 0, s->array_len);
- };
- } break;
-
- default: break;
- };
-};
-
-void RasterizerIPhone::_render_list_forward(RenderList *p_render_list) {
-
- const Material *prev_material = NULL;
- uint64_t prev_light_hash = 0;
- const Skeleton *prev_skeleton = NULL;
- const Geometry *prev_geometry = NULL;
- const ParamOverrideMap *prev_overrides = NULL; // make it different than NULL
-
- Geometry::Type prev_geometry_type = Geometry::GEOMETRY_INVALID;
-
- glMatrixMode(GL_PROJECTION);
- glLoadMatrixf(&camera_projection.matrix[0][0]);
-
- for (int i = 0; i < p_render_list->element_count; i++) {
-
- RenderList::Element *e = p_render_list->elements[i];
- const Material *material = e->material;
- uint64_t light_hash = e->light_hash;
- const Skeleton *skeleton = e->skeleton;
- const Geometry *geometry = e->geometry;
- const ParamOverrideMap *material_overrides = e->material_overrides;
-
- if (material != prev_material || geometry->type != prev_geometry_type) {
- _setup_material(e->geometry, material);
- //_setup_material_overrides(e->material,NULL,material_overrides);
- //_setup_material_skeleton(material,skeleton);
- } else {
-
- if (material_overrides != prev_overrides) {
-
- //_setup_material_overrides(e->material,prev_overrides,material_overrides);
- }
-
- if (prev_skeleton != skeleton) {
- //_setup_material_skeleton(material,skeleton);
- };
- }
-
- if (geometry != prev_geometry || geometry->type != prev_geometry_type) {
-
- _setup_geometry(geometry, material);
- };
-
- if (i == 0 || light_hash != prev_light_hash)
- _setup_lights(e->lights, e->light_count);
-
- glMatrixMode(GL_MODELVIEW);
- _gl_load_transform(camera_transform_inverse);
- _gl_mult_transform(e->transform);
-
- _render(geometry, material, skeleton);
-
- prev_material = material;
- prev_skeleton = skeleton;
- prev_geometry = geometry;
- prev_light_hash = e->light_hash;
- prev_geometry_type = geometry->type;
- prev_overrides = material_overrides;
- }
-};
-
-void RasterizerIPhone::end_scene() {
-
- glEnable(GL_BLEND);
- glDepthMask(GL_FALSE);
-
- opaque_render_list.sort_mat_light();
- _render_list_forward(&opaque_render_list);
-
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE);
-
- alpha_render_list.sort_z();
- _render_list_forward(&alpha_render_list);
-}
-void RasterizerIPhone::end_shadow_map() {
-}
-
-void RasterizerIPhone::end_frame() {
-
- //ContextGL::get_singleton()->swap_buffers();
-}
-
-/* CANVAS API */
-
-void RasterizerIPhone::canvas_begin() {
-
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glLineWidth(1.0);
- glDisable(GL_LIGHTING);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-}
-void RasterizerIPhone::canvas_set_transparency(float p_transparency) {
-}
-
-void RasterizerIPhone::canvas_set_rect(const Rect2 &p_rect, bool p_clip) {
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glScalef(2.0 / window_size.x, -2.0 / window_size.y, 0);
- glTranslatef((-(window_size.x / 2.0)) + p_rect.pos.x, (-(window_size.y / 2.0)) + p_rect.pos.y, 0);
-
- if (p_clip) {
-
- glEnable(GL_SCISSOR_TEST);
- glScissor(viewport.x + p_rect.pos.x, viewport.y + (viewport.height - (p_rect.pos.y + p_rect.size.height)),
- p_rect.size.width, p_rect.size.height);
- } else {
-
- glDisable(GL_SCISSOR_TEST);
- }
-}
-void RasterizerIPhone::canvas_draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width) {
-
- glColor4f(1, 1, 1, 1);
-
- float verts[6] = {
- p_from.x, p_from.y, 0,
- p_to.x, p_to.y, 0
- };
-
- float colors[] = {
- p_color.r, p_color.g, p_color.b, p_color.a,
- p_color.r, p_color.g, p_color.b, p_color.a,
- };
- glLineWidth(p_width);
- _draw_primitive(2, verts, 0, colors, 0);
-}
-
-static void _draw_textured_quad(const Rect2 &p_rect, const Rect2 &p_src_region, const Size2 &p_tex_size) {
-
- float texcoords[] = {
- p_src_region.pos.x / p_tex_size.width,
- p_src_region.pos.y / p_tex_size.height,
-
- (p_src_region.pos.x + p_src_region.size.width) / p_tex_size.width,
- p_src_region.pos.y / p_tex_size.height,
-
- (p_src_region.pos.x + p_src_region.size.width) / p_tex_size.width,
- (p_src_region.pos.y + p_src_region.size.height) / p_tex_size.height,
-
- p_src_region.pos.x / p_tex_size.width,
- (p_src_region.pos.y + p_src_region.size.height) / p_tex_size.height,
- };
-
- float coords[] = {
- p_rect.pos.x, p_rect.pos.y, 0,
- p_rect.pos.x + p_rect.size.width, p_rect.pos.y, 0,
- p_rect.pos.x + p_rect.size.width, p_rect.pos.y + p_rect.size.height, 0,
- p_rect.pos.x, p_rect.pos.y + p_rect.size.height, 0
- };
-
- _draw_primitive(4, coords, 0, 0, texcoords);
-}
-
-static void _draw_quad(const Rect2 &p_rect) {
-
- float coords[] = {
- p_rect.pos.x, p_rect.pos.y, 0,
- p_rect.pos.x + p_rect.size.width, p_rect.pos.y, 0,
- p_rect.pos.x + p_rect.size.width, p_rect.pos.y + p_rect.size.height, 0,
- p_rect.pos.x, p_rect.pos.y + p_rect.size.height, 0
- };
-
- _draw_primitive(4, coords, 0, 0, 0);
-}
-
-void RasterizerIPhone::canvas_draw_rect(const Rect2 &p_rect, bool p_region, const Rect2 &p_source, bool p_tile, RID p_texture, const Color &p_modulate) {
-
- glColor4f(p_modulate.r, p_modulate.g, p_modulate.b, p_modulate.a);
-
- if (p_texture.is_valid()) {
-
- glEnable(GL_TEXTURE_2D);
- Texture *texture = texture_owner.get(p_texture);
- ERR_FAIL_COND(!texture);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texture->tex_id);
-
- if (!p_region) {
-
- Rect2 region = Rect2(0, 0, texture->width, texture->height);
- _draw_textured_quad(p_rect, region, region.size);
-
- } else {
-
- _draw_textured_quad(p_rect, p_source, Size2(texture->width, texture->height));
- }
- } else {
-
- _draw_quad(p_rect);
- }
-}
-void RasterizerIPhone::canvas_draw_style_box(const Rect2 &p_rect, const Rect2 &p_src_region, RID p_texture, const float *p_margin, bool p_draw_center) {
-
- glColor4f(1, 1, 1, 1);
-
- Texture *texture = texture_owner.get(p_texture);
- ERR_FAIL_COND(!texture);
-
- glEnable(GL_TEXTURE_2D);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texture->tex_id);
-
- Rect2 region = p_src_region;
- if (region.size.width <= 0)
- region.size.width = texture->width;
- if (region.size.height <= 0)
- region.size.height = texture->height;
- /* CORNERS */
- _draw_textured_quad( // top left
- Rect2(p_rect.pos, Size2(p_margin[MARGIN_LEFT], p_margin[MARGIN_TOP])),
- Rect2(region.pos, Size2(p_margin[MARGIN_LEFT], p_margin[MARGIN_TOP])),
- Size2(texture->width, texture->height));
-
- _draw_textured_quad( // top right
- Rect2(Point2(p_rect.pos.x + p_rect.size.width - p_margin[MARGIN_RIGHT], p_rect.pos.y), Size2(p_margin[MARGIN_RIGHT], p_margin[MARGIN_TOP])),
- Rect2(Point2(region.pos.x + region.size.width - p_margin[MARGIN_RIGHT], region.pos.y), Size2(p_margin[MARGIN_RIGHT], p_margin[MARGIN_TOP])),
- Size2(texture->width, texture->height));
-
- _draw_textured_quad( // bottom left
- Rect2(Point2(p_rect.pos.x, p_rect.pos.y + p_rect.size.height - p_margin[MARGIN_BOTTOM]), Size2(p_margin[MARGIN_LEFT], p_margin[MARGIN_BOTTOM])),
- Rect2(Point2(region.pos.x, region.pos.y + region.size.height - p_margin[MARGIN_BOTTOM]), Size2(p_margin[MARGIN_LEFT], p_margin[MARGIN_BOTTOM])),
- Size2(texture->width, texture->height));
-
- _draw_textured_quad( // bottom right
- Rect2(Point2(p_rect.pos.x + p_rect.size.width - p_margin[MARGIN_RIGHT], p_rect.pos.y + p_rect.size.height - p_margin[MARGIN_BOTTOM]), Size2(p_margin[MARGIN_RIGHT], p_margin[MARGIN_BOTTOM])),
- Rect2(Point2(region.pos.x + region.size.width - p_margin[MARGIN_RIGHT], region.pos.y + region.size.height - p_margin[MARGIN_BOTTOM]), Size2(p_margin[MARGIN_RIGHT], p_margin[MARGIN_BOTTOM])),
- Size2(texture->width, texture->height));
-
- Rect2 rect_center(p_rect.pos + Point2(p_margin[MARGIN_LEFT], p_margin[MARGIN_TOP]), Size2(p_rect.size.width - p_margin[MARGIN_LEFT] - p_margin[MARGIN_RIGHT], p_rect.size.height - p_margin[MARGIN_TOP] - p_margin[MARGIN_BOTTOM]));
-
- Rect2 src_center(Point2(region.pos.x + p_margin[MARGIN_LEFT], region.pos.y + p_margin[MARGIN_TOP]), Size2(region.size.width - p_margin[MARGIN_LEFT] - p_margin[MARGIN_RIGHT], region.size.height - p_margin[MARGIN_TOP] - p_margin[MARGIN_BOTTOM]));
-
- _draw_textured_quad( // top
- Rect2(Point2(rect_center.pos.x, p_rect.pos.y), Size2(rect_center.size.width, p_margin[MARGIN_TOP])),
- Rect2(Point2(src_center.pos.x, region.pos.y), Size2(src_center.size.width, p_margin[MARGIN_TOP])),
- Size2(texture->width, texture->height));
-
- _draw_textured_quad( // bottom
- Rect2(Point2(rect_center.pos.x, rect_center.pos.y + rect_center.size.height), Size2(rect_center.size.width, p_margin[MARGIN_BOTTOM])),
- Rect2(Point2(src_center.pos.x, src_center.pos.y + src_center.size.height), Size2(src_center.size.width, p_margin[MARGIN_BOTTOM])),
- Size2(texture->width, texture->height));
-
- _draw_textured_quad( // left
- Rect2(Point2(p_rect.pos.x, rect_center.pos.y), Size2(p_margin[MARGIN_LEFT], rect_center.size.height)),
- Rect2(Point2(region.pos.x, region.pos.y + p_margin[MARGIN_TOP]), Size2(p_margin[MARGIN_LEFT], src_center.size.height)),
- Size2(texture->width, texture->height));
-
- _draw_textured_quad( // right
- Rect2(Point2(rect_center.pos.x + rect_center.size.width, rect_center.pos.y), Size2(p_margin[MARGIN_RIGHT], rect_center.size.height)),
- Rect2(Point2(src_center.pos.x + src_center.size.width, region.pos.y + p_margin[MARGIN_TOP]), Size2(p_margin[MARGIN_RIGHT], src_center.size.height)),
- Size2(texture->width, texture->height));
-
- if (p_draw_center) {
-
- _draw_textured_quad(
- rect_center,
- src_center,
- Size2(texture->width, texture->height));
- }
-}
-void RasterizerIPhone::canvas_draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture) {
-
- ERR_FAIL_COND(p_points.size() < 1);
- float verts[12];
- float uvs[8];
- float colors[16];
-
- glColor4f(1, 1, 1, 1);
-
- int idx = 0;
- for (int i = 0; i < p_points.size(); i++) {
-
- verts[idx++] = p_points[i].x;
- verts[idx++] = p_points[i].y;
- verts[idx++] = 0;
- }
-
- idx = 0;
- for (int i = 0; i < p_uvs.size(); i++) {
-
- uvs[idx++] = p_uvs[i].x;
- uvs[idx++] = p_uvs[i].y;
- }
-
- idx = 0;
- for (int i = 0; i < p_colors.size(); i++) {
-
- colors[idx++] = p_colors[i].r;
- colors[idx++] = p_colors[i].g;
- colors[idx++] = p_colors[i].b;
- colors[idx++] = p_colors[i].a;
- };
-
- if (p_texture.is_valid()) {
- glEnable(GL_TEXTURE_2D);
- Texture *texture = texture_owner.get(p_texture);
- if (texture) {
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texture->tex_id);
- }
- }
-
- _draw_primitive(p_points.size(), &verts[0], NULL, p_colors.size() ? &colors[0] : NULL, p_uvs.size() ? uvs : NULL);
-}
-
-/* FX */
-
-RID RasterizerIPhone::fx_create() {
-
- return RID();
-}
-void RasterizerIPhone::fx_get_effects(RID p_fx, List<String> *p_effects) const {
-}
-void RasterizerIPhone::fx_set_active(RID p_fx, const String &p_effect, bool p_active) {
-}
-bool RasterizerIPhone::fx_is_active(RID p_fx, const String &p_effect) const {
-
- return false;
-}
-void RasterizerIPhone::fx_get_effect_params(RID p_fx, const String &p_effect, List<PropertyInfo> *p_params) const {
-}
-Variant RasterizerIPhone::fx_get_effect_param(RID p_fx, const String &p_effect, const String &p_param) const {
-
- return Variant();
-}
-void RasterizerIPhone::fx_set_effect_param(RID p_fx, const String &p_effect, const String &p_param, const Variant &p_pvalue) {
-}
-
-/*MISC*/
-
-bool RasterizerIPhone::is_texture(const RID &p_rid) const {
-
- return texture_owner.owns(p_rid);
-}
-bool RasterizerIPhone::is_material(const RID &p_rid) const {
-
- return material_owner.owns(p_rid);
-}
-bool RasterizerIPhone::is_mesh(const RID &p_rid) const {
-
- return mesh_owner.owns(p_rid);
-}
-bool RasterizerIPhone::is_multimesh(const RID &p_rid) const {
-
- return false;
-}
-bool RasterizerIPhone::is_poly(const RID &p_rid) const {
-
- return poly_owner.owns(p_rid);
-}
-bool RasterizerIPhone::is_particles(const RID &p_beam) const {
-
- return false;
-}
-
-bool RasterizerIPhone::is_beam(const RID &p_beam) const {
-
- return false;
-}
-
-bool RasterizerIPhone::is_light(const RID &p_rid) const {
-
- return light_owner.owns(p_rid);
-}
-bool RasterizerIPhone::is_light_instance(const RID &p_rid) const {
-
- return light_instance_owner.owns(p_rid);
-}
-bool RasterizerIPhone::is_particles_instance(const RID &p_rid) const {
-
- return false;
-}
-bool RasterizerIPhone::is_skeleton(const RID &p_rid) const {
-
- return skeleton_owner.owns(p_rid);
-}
-bool RasterizerIPhone::is_fx(const RID &p_rid) const {
-
- return fx_owner.owns(p_rid);
-}
-bool RasterizerIPhone::is_shader(const RID &p_rid) const {
-
- return false;
-}
-
-void RasterizerIPhone::free(const RID &p_rid) const {
-
- if (texture_owner.owns(p_rid)) {
-
- // delete the texture
- Texture *texture = texture_owner.get(p_rid);
-
- glDeleteTextures(1, &texture->tex_id);
-
- texture_owner.free(p_rid);
- memdelete(texture);
-
- } else if (material_owner.owns(p_rid)) {
-
- Material *material = material_owner.get(p_rid);
- ERR_FAIL_COND(!material);
-
- material_owner.free(p_rid);
- memdelete(material);
-
- } else if (mesh_owner.owns(p_rid)) {
-
- Mesh *mesh = mesh_owner.get(p_rid);
- ERR_FAIL_COND(!mesh);
- for (int i = 0; i < mesh->surfaces.size(); i++) {
-
- Surface *surface = mesh->surfaces[i];
- if (surface->array_local != 0) {
- memfree(surface->array_local);
- };
- if (surface->index_array_local != 0) {
- memfree(surface->index_array_local);
- };
-
- if (surface->vertex_id)
- glDeleteBuffers(1, &surface->vertex_id);
- if (surface->index_id)
- glDeleteBuffers(1, &surface->index_id);
-
- memdelete(surface);
- };
-
- mesh->surfaces.clear();
-
- mesh_owner.free(p_rid);
- memdelete(mesh);
-
- } else if (skeleton_owner.owns(p_rid)) {
-
- Skeleton *skeleton = skeleton_owner.get(p_rid);
- ERR_FAIL_COND(!skeleton)
-
- skeleton_owner.free(p_rid);
- memdelete(skeleton);
-
- } else if (light_owner.owns(p_rid)) {
-
- Light *light = light_owner.get(p_rid);
- ERR_FAIL_COND(!light)
-
- light_owner.free(p_rid);
- memdelete(light);
-
- } else if (light_instance_owner.owns(p_rid)) {
-
- LightInstance *light_instance = light_instance_owner.get(p_rid);
- ERR_FAIL_COND(!light_instance);
-
- light_instance_owner.free(p_rid);
- memdelete(light_instance);
-
- } else if (fx_owner.owns(p_rid)) {
-
- FX *fx = fx_owner.get(p_rid);
- ERR_FAIL_COND(!fx);
-
- fx_owner.free(p_rid);
- memdelete(fx);
- };
-}
-
-void RasterizerIPhone::init() {
-
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
- glFrontFace(GL_CW);
-
- glEnable(GL_TEXTURE_2D);
-}
-
-void RasterizerIPhone::finish() {
-}
-
-int RasterizerIPhone::get_render_info(VS::RenderInfo p_info) {
-
- return false;
-}
-
-RasterizerIPhone::RasterizerIPhone() {
-
- frame = 0;
-};
-
-RasterizerIPhone::~RasterizerIPhone(){
-
-};
-
-#endif
diff --git a/platform/iphone/rasterizer_iphone.h b/platform/iphone/rasterizer_iphone.h
deleted file mode 100644
index f886738da9..0000000000
--- a/platform/iphone/rasterizer_iphone.h
+++ /dev/null
@@ -1,881 +0,0 @@
-/*************************************************************************/
-/* rasterizer_iphone.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifdef IPHONE_ENABLED
-
-#ifndef RASTERIZER_IPHONE_H
-#define RASTERIZER_IPHONE_H
-
-#include "servers/visual/rasterizer.h"
-
-#include "camera_matrix.h"
-#include "image.h"
-#include "list.h"
-#include "map.h"
-#include "rid.h"
-#include "servers/visual_server.h"
-#include "sort.h"
-#include <ES1/gl.h>
-
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-class RasterizerIPhone : public Rasterizer {
-
- enum {
- SKINNED_BUFFER_SIZE = 1024 * 128, // 10k vertices
- MAX_LIGHTS = 8,
- };
-
- uint8_t skinned_buffer[SKINNED_BUFFER_SIZE];
-
- struct Texture {
-
- uint32_t flags;
- int width, height;
- Image::Format format;
-
- GLenum target;
- GLenum gl_format_cache;
- int gl_components_cache;
- bool has_alpha;
- bool format_has_alpha;
-
- bool active;
- GLuint tex_id;
- bool mipmap_dirty;
-
- Texture() {
-
- flags = width = height = 0;
- tex_id = 0;
- format = Image::FORMAT_L8;
- gl_components_cache = 0;
- format_has_alpha = false;
- has_alpha = false;
- active = false;
- mipmap_dirty = true;
- }
-
- ~Texture() {
-
- if (tex_id != 0) {
-
- glDeleteTextures(1, &tex_id);
- }
- }
- };
-
- mutable RID_Owner<Texture> texture_owner;
-
- struct Material {
-
- bool flags[VS::MATERIAL_FLAG_MAX];
- Variant parameters[VisualServer::FIXED_MATERIAL_PARAM_MAX];
- RID textures[VisualServer::FIXED_MATERIAL_PARAM_MAX];
-
- Transform uv_transform;
- VS::SpatialMaterialTexCoordMode texcoord_mode[VisualServer::FIXED_MATERIAL_PARAM_MAX];
-
- VS::MaterialBlendMode detail_blend_mode;
-
- VS::SpatialMaterialTexGenMode texgen_mode;
-
- Material() {
-
- flags[VS::MATERIAL_FLAG_VISIBLE] = true;
- flags[VS::MATERIAL_FLAG_DOUBLE_SIDED] = false;
- flags[VS::MATERIAL_FLAG_INVERT_FACES] = false;
- flags[VS::MATERIAL_FLAG_UNSHADED] = false;
- flags[VS::MATERIAL_FLAG_WIREFRAME] = false;
-
- parameters[VS::FIXED_MATERIAL_PARAM_DIFFUSE] = Color(0.8, 0.8, 0.8);
- parameters[VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP] = 12;
-
- for (int i = 0; i < VisualServer::FIXED_MATERIAL_PARAM_MAX; i++) {
- texcoord_mode[i] = VS::FIXED_MATERIAL_TEXCOORD_UV;
- };
- detail_blend_mode = VS::MATERIAL_BLEND_MODE_MIX;
- texgen_mode = VS::FIXED_MATERIAL_TEXGEN_SPHERE;
- }
- };
- mutable RID_Owner<Material> material_owner;
-
- struct Geometry {
-
- enum Type {
- GEOMETRY_INVALID,
- GEOMETRY_SURFACE,
- GEOMETRY_POLY,
- GEOMETRY_PARTICLES,
- GEOMETRY_BEAM,
- GEOMETRY_DETAILER,
- };
-
- Type type;
- RID material;
- bool has_alpha;
- bool material_owned;
-
- Vector3 scale;
- Vector3 uv_scale;
-
- Geometry()
- : scale(1, 1, 1) {
- has_alpha = false;
- material_owned = false;
- }
- virtual ~Geometry(){};
- };
-
- struct GeometryOwner {
-
- virtual ~GeometryOwner() {}
- };
-
- struct Surface : public Geometry {
-
- struct ArrayData {
-
- uint32_t ofs, size;
- bool configured;
- int components;
- ArrayData() {
- ofs = 0;
- size = 0;
- configured = false;
- }
- };
-
- ArrayData array[VS::ARRAY_MAX];
- // support for vertex array objects
- GLuint array_object_id;
- // support for vertex buffer object
- GLuint vertex_id; // 0 means, unconfigured
- GLuint index_id; // 0 means, unconfigured
- // no support for the above, array in localmem.
- uint8_t *array_local;
- uint8_t *index_array_local;
-
- AABB aabb;
-
- int array_len;
- int index_array_len;
-
- VS::PrimitiveType primitive;
-
- uint32_t format;
-
- int stride;
-
- bool active;
-
- Point2 uv_min;
- Point2 uv_max;
-
- bool has_alpha_cache;
-
- Surface() {
-
- array_len = 0;
- type = GEOMETRY_SURFACE;
- primitive = VS::PRIMITIVE_POINTS;
- index_array_len = VS::NO_INDEX_ARRAY;
- format = 0;
- stride = 0;
-
- array_local = index_array_local = 0;
- vertex_id = index_id = 0;
-
- active = false;
- }
-
- ~Surface() {
- }
- };
-
- struct Mesh {
-
- bool active;
- Vector<Surface *> surfaces;
-
- mutable uint64_t last_pass;
- Mesh() {
- last_pass = 0;
- active = false;
- }
- };
- mutable RID_Owner<Mesh> mesh_owner;
-
- struct Poly : public Geometry {
-
- struct Primitive {
-
- Vector<Vector3> vertices;
- Vector<Vector3> normals;
- Vector<Vector3> uvs;
- Vector<Color> colors;
- };
-
- AABB aabb;
- List<Primitive> primitives;
- Poly() {
-
- type = GEOMETRY_POLY;
- }
- };
-
- mutable RID_Owner<Poly> poly_owner;
-
- struct Skeleton {
-
- Vector<Transform> bones;
- };
-
- mutable RID_Owner<Skeleton> skeleton_owner;
-
- struct Light {
-
- VS::LightType type;
- float vars[VS::LIGHT_PARAM_MAX];
- Color colors[3];
- bool shadow_enabled;
- RID projector;
- bool volumetric_enabled;
- Color volumetric_color;
-
- Light() {
-
- vars[VS::LIGHT_PARAM_SPOT_ATTENUATION] = 1;
- vars[VS::LIGHT_PARAM_SPOT_ANGLE] = 45;
- vars[VS::LIGHT_PARAM_ATTENUATION] = 1.0;
- vars[VS::LIGHT_PARAM_ENERGY] = 1.0;
- vars[VS::LIGHT_PARAM_RADIUS] = 1.0;
- colors[VS::LIGHT_COLOR_AMBIENT] = Color(0, 0, 0);
- colors[VS::LIGHT_COLOR_DIFFUSE] = Color(1, 1, 1);
- colors[VS::LIGHT_COLOR_SPECULAR] = Color(1, 1, 1);
- shadow_enabled = false;
- volumetric_enabled = false;
- }
- };
-
- struct ShadowBuffer;
-
- struct LightInstance {
-
- struct SplitInfo {
-
- CameraMatrix camera;
- Transform transform;
- float near;
- float far;
- };
-
- RID light;
- Light *base;
- uint64_t last_pass;
- Transform transform;
-
- CameraMatrix projection;
- Vector<SplitInfo> splits;
-
- Vector3 light_vector;
- Vector3 spot_vector;
- float linear_att;
-
- uint64_t hash_aux;
- };
- mutable RID_Owner<Light> light_owner;
- mutable RID_Owner<LightInstance> light_instance_owner;
-
- LightInstance *light_instances[MAX_LIGHTS];
- int light_instance_count;
-
- struct RenderList {
-
- enum {
- MAX_ELEMENTS = 4096,
- MAX_LIGHTS = 4
- };
-
- struct Element {
-
- float depth;
- const Skeleton *skeleton;
- Transform transform;
- LightInstance *lights[MAX_LIGHTS];
- int light_count;
- const Geometry *geometry;
- const Material *material;
- uint64_t light_hash;
- GeometryOwner *owner;
- const ParamOverrideMap *material_overrides;
- };
-
- Element _elements[MAX_ELEMENTS];
- Element *elements[MAX_ELEMENTS];
- int element_count;
-
- void clear() {
-
- element_count = 0;
- }
-
- struct SortZ {
-
- _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
-
- return A->depth > B->depth;
- }
- };
-
- void sort_z() {
-
- SortArray<Element *, SortZ> sorter;
- sorter.sort(elements, element_count);
- }
-
- struct SortSkel {
-
- _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
-
- if (A->geometry < B->geometry)
- return true;
- else if (A->geometry > B->geometry)
- return false;
- else
- return (!A->skeleton && B->skeleton);
- }
- };
-
- void sort_skel() {
-
- SortArray<Element *, SortSkel> sorter;
- sorter.sort(elements, element_count);
- }
-
- struct SortMat {
-
- _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
-
- if (A->geometry == B->geometry) {
-
- if (A->material == B->material) {
-
- return (A->material_overrides < B->material_overrides);
- } else {
-
- return (A->material < B->material);
- }
- } else {
-
- return (A->geometry < B->geometry);
- }
- }
- };
-
- void sort_mat() {
-
- SortArray<Element *, SortMat> sorter;
- sorter.sort(elements, element_count);
- }
-
- struct SortMatLight {
-
- _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
-
- if (A->geometry == B->geometry) {
-
- if (A->material == B->material) {
-
- if (A->light_hash == B->light_hash)
- return (A->material_overrides < B->material_overrides);
- else
- return A->light_hash < B->light_hash;
- } else {
-
- return (A->material < B->material);
- }
- } else {
-
- return (A->geometry < B->geometry);
- }
- }
- };
-
- void sort_mat_light() {
-
- SortArray<Element *, SortMatLight> sorter;
- sorter.sort(elements, element_count);
- }
-
- struct LISort {
-
- _FORCE_INLINE_ bool operator()(const LightInstance *A, const LightInstance *B) const {
-
- return (A->hash_aux < B->hash_aux);
- }
- };
-
- _FORCE_INLINE_ void add_element(const Geometry *p_geometry, const Material *p_material, const Transform &p_transform, LightInstance **p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides, const Skeleton *p_skeleton, float p_depth, GeometryOwner *p_owner = NULL) {
-
- ERR_FAIL_COND(element_count >= MAX_ELEMENTS);
- Element *e = elements[element_count++];
-
- e->geometry = p_geometry;
- e->material = p_material;
- e->transform = p_transform;
- e->skeleton = p_skeleton;
- e->light_hash = 0;
- e->light_count = p_light_count;
- e->owner = p_owner;
- e->material_overrides = p_material_overrides;
-
- if (e->light_count > 0) {
-
- SortArray<LightInstance *, LISort> light_sort;
- light_sort.sort(p_light_instances, p_light_count);
- //@TODO OPTIOMIZE
-
- for (int i = 0; i < p_light_count; i++) {
-
- e->lights[i] = p_light_instances[i];
-
- if (i == 0)
- e->light_hash = hash_djb2_one_64(make_uint64_t(e->lights[i]));
- else
- e->light_hash = hash_djb2_one_64(make_uint64_t(e->lights[i]), e->light_hash);
- }
- }
- }
-
- RenderList() {
-
- for (int i = 0; i < MAX_ELEMENTS; i++)
- elements[i] = &_elements[i]; // assign elements
- }
- };
-
- RenderList opaque_render_list;
- RenderList alpha_render_list;
-
- RID default_material;
-
- struct FX {
-
- bool bgcolor_active;
- Color bgcolor;
-
- bool skybox_active;
- RID skybox_cubemap;
-
- bool antialias_active;
- float antialias_tolerance;
-
- bool glow_active;
- int glow_passes;
- float glow_attenuation;
- float glow_bloom;
-
- bool ssao_active;
- float ssao_attenuation;
- float ssao_radius;
- float ssao_max_distance;
- float ssao_range_max;
- float ssao_range_min;
- bool ssao_only;
-
- bool fog_active;
- float fog_distance;
- float fog_attenuation;
- Color fog_color_near;
- Color fog_color_far;
- bool fog_bg;
-
- bool toon_active;
- float toon_treshold;
- float toon_soft;
-
- bool edge_active;
- Color edge_color;
- float edge_size;
-
- FX();
- };
- mutable RID_Owner<FX> fx_owner;
-
- FX *scene_fx;
- CameraMatrix camera_projection;
- Transform camera_transform;
- Transform camera_transform_inverse;
- float camera_z_near;
- float camera_z_far;
- Size2 camera_vp_size;
-
- Plane camera_plane;
-
- void _add_geometry(const Geometry *p_geometry, const Transform &p_world, uint32_t p_vertex_format, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides, const Skeleton *p_skeleton, GeometryOwner *p_owner);
- void _render_list_forward(RenderList *p_render_list);
-
- void _setup_light(LightInstance *p_instance, int p_idx);
- void _setup_lights(LightInstance **p_lights, int p_light_count);
- void _setup_material(const Geometry *p_geometry, const Material *p_material);
-
- void _setup_geometry(const Geometry *p_geometry, const Material *p_material);
- void _render(const Geometry *p_geometry, const Material *p_material, const Skeleton *p_skeleton);
-
- /*********/
- /* FRAME */
- /*********/
-
- Size2 window_size;
- VS::ViewportRect viewport;
- Transform canvas_transform;
- double last_time;
- double time_delta;
- uint64_t frame;
-
-public:
- /* TEXTURE API */
-
- virtual RID texture_create();
- virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT);
- virtual void texture_blit_rect(RID p_texture, int p_x, int p_y, const Image &p_image, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT);
- virtual Image texture_get_rect(RID p_texture, int p_x, int p_y, int p_width, int p_height, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) const;
- virtual void texture_set_flags(RID p_texture, uint32_t p_flags);
- virtual uint32_t texture_get_flags(RID p_texture) const;
- virtual Image::Format texture_get_format(RID p_texture) const;
- virtual uint32_t texture_get_width(RID p_texture) const;
- virtual uint32_t texture_get_height(RID p_texture) const;
- virtual bool texture_has_alpha(RID p_texture) const;
-
- /* SHADER API */
-
- virtual RID shader_create();
-
- virtual void shader_node_add(RID p_shader, VS::ShaderNodeType p_type, int p_id);
- virtual void shader_node_remove(RID p_shader, int p_id);
- virtual void shader_node_change_type(RID p_shader, int p_id, VS::ShaderNodeType p_type);
- virtual void shader_node_set_param(RID p_shader, int p_id, const Variant &p_value);
-
- virtual void shader_get_node_list(RID p_shader, List<int> *p_node_list) const;
- virtual VS::ShaderNodeType shader_node_get_type(RID p_shader, int p_id) const;
- virtual Variant shader_node_get_param(RID p_shader, int p_id) const;
-
- virtual void shader_connect(RID p_shader, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot);
- virtual bool shader_is_connected(RID p_shader, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot) const;
- virtual void shader_disconnect(RID p_shader, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot);
-
- virtual void shader_get_connections(RID p_shader, List<VS::ShaderConnection> *p_connections) const;
-
- virtual void shader_clear(RID p_shader);
-
- /* COMMON MATERIAL API */
-
- virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value);
- virtual Variant material_get_param(RID p_material, const StringName &p_param) const;
- virtual void material_get_param_list(RID p_material, List<String> *p_param_list) const;
-
- virtual void material_set_flag(RID p_material, VS::MaterialFlag p_flag, bool p_enabled);
- virtual bool material_get_flag(RID p_material, VS::MaterialFlag p_flag) const;
-
- virtual void material_set_blend_mode(RID p_material, VS::MaterialBlendMode p_mode);
- virtual VS::MaterialBlendMode material_get_blend_mode(RID p_material) const;
-
- virtual void material_set_line_width(RID p_material, float p_line_width);
- virtual float material_get_line_width(RID p_material) const;
-
- /* FIXED MATERIAL */
-
- virtual RID material_create();
-
- virtual void fixed_material_set_parameter(RID p_material, VS::SpatialMaterialParam p_parameter, const Variant &p_value);
- virtual Variant fixed_material_get_parameter(RID p_material, VS::SpatialMaterialParam p_parameter) const;
-
- virtual void fixed_material_set_texture(RID p_material, VS::SpatialMaterialParam p_parameter, RID p_texture);
- virtual RID fixed_material_get_texture(RID p_material, VS::SpatialMaterialParam p_parameter) const;
-
- virtual void fixed_material_set_detail_blend_mode(RID p_material, VS::MaterialBlendMode p_mode);
- virtual VS::MaterialBlendMode fixed_material_get_detail_blend_mode(RID p_material) const;
-
- virtual void fixed_material_set_texgen_mode(RID p_material, VS::SpatialMaterialTexGenMode p_mode);
- virtual VS::SpatialMaterialTexGenMode fixed_material_get_texgen_mode(RID p_material) const;
-
- virtual void fixed_material_set_texcoord_mode(RID p_material, VS::SpatialMaterialParam p_parameter, VS::SpatialMaterialTexCoordMode p_mode);
- virtual VS::SpatialMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material, VS::SpatialMaterialParam p_parameter) const;
-
- virtual void fixed_material_set_uv_transform(RID p_material, const Transform &p_transform);
- virtual Transform fixed_material_get_uv_transform(RID p_material) const;
-
- /* SHADER MATERIAL */
-
- virtual RID shader_material_create() const;
-
- virtual void shader_material_set_vertex_shader(RID p_material, RID p_shader, bool p_owned = false);
- virtual RID shader_material_get_vertex_shader(RID p_material) const;
-
- virtual void shader_material_set_fragment_shader(RID p_material, RID p_shader, bool p_owned = false);
- virtual RID shader_material_get_fragment_shader(RID p_material) const;
-
- /* MESH API */
-
- virtual RID mesh_create();
-
- virtual void mesh_add_surface(RID p_mesh, VS::PrimitiveType p_primitive, uint32_t p_format, int p_array_len, int p_index_array_len = VS::NO_INDEX_ARRAY);
-
- virtual Error mesh_surface_set_array(RID p_mesh, int p_surface, VS::ArrayType p_type, const Variant &p_array);
- virtual Variant mesh_surface_get_array(RID p_mesh, int p_surface, VS::ArrayType p_type) const;
-
- virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material, bool p_owned = false);
- virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const;
-
- virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const;
- virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const;
- virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const;
- virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const;
-
- virtual void mesh_erase_surface(RID p_mesh, int p_index);
- virtual int mesh_get_surface_count(RID p_mesh) const;
-
- virtual AABB mesh_get_aabb(RID p_mesh) const;
-
- /* MULTIMESH API */
-
- virtual RID multimesh_create();
-
- virtual void multimesh_set_instance_count(RID p_multimesh, int p_count);
- virtual int multimesh_get_instance_count(RID p_multimesh) const;
-
- virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh);
- virtual void multimesh_set_aabb(RID p_multimesh, const AABB &p_aabb);
- virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform);
- virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color);
-
- virtual RID multimesh_get_mesh(RID p_multimesh) const;
- virtual AABB multimesh_get_aabb(RID p_multimesh) const;
-
- virtual Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const;
- virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const;
-
- /* POLY API */
-
- virtual RID poly_create();
- virtual void poly_set_material(RID p_poly, RID p_material, bool p_owned = false);
- virtual void poly_add_primitive(RID p_poly, const Vector<Vector3> &p_points, const Vector<Vector3> &p_normals, const Vector<Color> &p_colors, const Vector<Vector3> &p_uvs);
- virtual void poly_clear(RID p_poly);
-
- virtual AABB poly_get_aabb(RID p_poly) const;
-
- /* PARTICLES API */
-
- virtual RID particles_create();
-
- virtual void particles_set_amount(RID p_particles, int p_amount);
- virtual int particles_get_amount(RID p_particles) const;
-
- virtual void particles_set_emitting(RID p_particles, bool p_emitting);
- virtual bool particles_is_emitting(RID p_particles) const;
-
- virtual void particles_set_visibility_aabb(RID p_particles, const AABB &p_visibility);
- virtual AABB particles_get_visibility_aabb(RID p_particles) const;
-
- virtual void particles_set_emission_half_extents(RID p_particles, const Vector3 &p_half_extents);
- virtual Vector3 particles_get_emission_half_extents(RID p_particles) const;
-
- virtual void particles_set_gravity_normal(RID p_particles, const Vector3 &p_normal);
- virtual Vector3 particles_get_gravity_normal(RID p_particles) const;
-
- virtual void particles_set_variable(RID p_particles, VS::ParticleVariable p_variable, float p_value);
- virtual float particles_get_variable(RID p_particles, VS::ParticleVariable p_variable) const;
-
- virtual void particles_set_randomness(RID p_particles, VS::ParticleVariable p_variable, float p_randomness);
- virtual float particles_get_randomness(RID p_particles, VS::ParticleVariable p_variable) const;
-
- virtual void particles_set_color_phase_pos(RID p_particles, int p_phase, float p_pos);
- virtual float particles_get_color_phase_pos(RID p_particles, int p_phase) const;
-
- virtual void particles_set_color_phases(RID p_particles, int p_phases);
- virtual int particles_get_color_phases(RID p_particles) const;
-
- virtual void particles_set_color_phase_color(RID p_particles, int p_phase, const Color &p_color);
- virtual Color particles_get_color_phase_color(RID p_particles, int p_phase) const;
-
- virtual void particles_set_attractors(RID p_particles, int p_attractors);
- virtual int particles_get_attractors(RID p_particles) const;
-
- virtual void particles_set_attractor_pos(RID p_particles, int p_attractor, const Vector3 &p_pos);
- virtual Vector3 particles_get_attractor_pos(RID p_particles, int p_attractor) const;
-
- virtual void particles_set_attractor_strength(RID p_particles, int p_attractor, float p_force);
- virtual float particles_get_attractor_strength(RID p_particles, int p_attractor) const;
-
- virtual void particles_set_material(RID p_particles, RID p_material, bool p_owned = false);
- virtual RID particles_get_material(RID p_particles) const;
-
- virtual AABB particles_get_aabb(RID p_particles) const;
- /* BEAM API */
-
- virtual RID beam_create();
-
- virtual void beam_set_point_count(RID p_beam, int p_count);
- virtual int beam_get_point_count(RID p_beam) const;
- virtual void beam_clear(RID p_beam);
-
- virtual void beam_set_point(RID p_beam, int p_point, Vector3 &p_pos);
- virtual Vector3 beam_get_point(RID p_beam, int p_point) const;
-
- virtual void beam_set_primitive(RID p_beam, VS::BeamPrimitive p_primitive);
- virtual VS::BeamPrimitive beam_get_primitive(RID p_beam) const;
-
- virtual void beam_set_material(RID p_beam, RID p_material);
- virtual RID beam_get_material(RID p_beam) const;
-
- virtual AABB beam_get_aabb(RID p_particles) const;
- /* SKELETON API */
-
- virtual RID skeleton_create();
- virtual void skeleton_resize(RID p_skeleton, int p_bones);
- virtual int skeleton_get_bone_count(RID p_skeleton) const;
- virtual void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform);
- virtual Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone);
-
- /* LIGHT API */
-
- virtual RID light_create(VS::LightType p_type);
- virtual VS::LightType light_get_type(RID p_light) const;
-
- virtual void light_set_color(RID p_light, VS::LightColor p_type, const Color &p_color);
- virtual Color light_get_color(RID p_light, VS::LightColor p_type) const;
-
- virtual void light_set_shadow(RID p_light, bool p_enabled);
- virtual bool light_has_shadow(RID p_light) const;
-
- virtual void light_set_volumetric(RID p_light, bool p_enabled);
- virtual bool light_is_volumetric(RID p_light) const;
-
- virtual void light_set_projector(RID p_light, RID p_texture);
- virtual RID light_get_projector(RID p_light) const;
-
- virtual void light_set_var(RID p_light, VS::LightParam p_var, float p_value);
- virtual float light_get_var(RID p_light, VS::LightParam p_var) const;
-
- virtual AABB light_get_aabb(RID p_poly) const;
-
- virtual RID light_instance_create(RID p_light);
- virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform);
-
- virtual void light_instance_set_active_hint(RID p_light_instance);
- virtual bool light_instance_has_shadow(RID p_light_instance) const;
- virtual bool light_instance_assign_shadow(RID p_light_instance);
- virtual ShadowType light_instance_get_shadow_type(RID p_light_instance) const;
- virtual int light_instance_get_shadow_passes(RID p_light_instance) const;
- virtual void light_instance_set_pssm_split_info(RID p_light_instance, int p_split, float p_near, float p_far, const CameraMatrix &p_camera, const Transform &p_transform);
-
- /* PARTICLES INSTANCE */
-
- virtual RID particles_instance_create(RID p_particles);
- virtual void particles_instance_set_transform(RID p_particles_instance, const Transform &p_transform);
-
- /* RENDER API */
- /* all calls (inside begin/end shadow) are always warranted to be in the following order: */
-
- virtual void begin_frame();
-
- virtual void set_viewport(const VS::ViewportRect &p_viewport);
-
- virtual void begin_scene(RID p_fx = RID(), VS::ScenarioDebugMode p_debug = VS::SCENARIO_DEBUG_DISABLED);
- virtual void begin_shadow_map(RID p_light_instance, int p_shadow_pass);
-
- virtual void set_camera(const Transform &p_world, const CameraMatrix &p_projection);
-
- virtual void add_light(RID p_light_instance); ///< all "add_light" calls happen before add_geometry calls
-
- typedef Map<StringName, Variant> ParamOverrideMap;
-
- virtual void add_mesh(RID p_mesh, const Transform *p_world, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides = NULL, RID p_skeleton = RID());
- virtual void add_multimesh(RID p_multimesh, const Transform *p_world, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides = NULL);
- virtual void add_poly(RID p_poly, const Transform *p_world, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides = NULL);
- virtual void add_beam(RID p_beam, const Transform *p_world, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides = NULL);
- virtual void add_particles(RID p_particle_instance, const RID *p_light_instances, int p_light_count, const ParamOverrideMap *p_material_overrides = NULL);
-
- virtual void end_scene();
- virtual void end_shadow_map();
-
- virtual void end_frame();
-
- /* CANVAS API */
-
- virtual void canvas_begin();
- virtual void canvas_set_transparency(float p_transparency);
- virtual void canvas_set_rect(const Rect2 &p_rect, bool p_clip);
- virtual void canvas_draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width);
- virtual void canvas_draw_rect(const Rect2 &p_rect, bool p_region, const Rect2 &p_source, bool p_tile, RID p_texture, const Color &p_modulate);
- virtual void canvas_draw_style_box(const Rect2 &p_rect, RID p_texture, const float *p_margins, bool p_draw_center = true);
- virtual void canvas_draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture);
-
- /* FX */
-
- virtual RID fx_create();
- virtual void fx_get_effects(RID p_fx, List<String> *p_effects) const;
- virtual void fx_set_active(RID p_fx, const String &p_effect, bool p_active);
- virtual bool fx_is_active(RID p_fx, const String &p_effect) const;
- virtual void fx_get_effect_params(RID p_fx, const String &p_effect, List<PropertyInfo> *p_params) const;
- virtual Variant fx_get_effect_param(RID p_fx, const String &p_effect, const String &p_param) const;
- virtual void fx_set_effect_param(RID p_fx, const String &p_effect, const String &p_param, const Variant &p_pvalue);
-
- /*MISC*/
-
- virtual bool is_texture(const RID &p_rid) const;
- virtual bool is_material(const RID &p_rid) const;
- virtual bool is_mesh(const RID &p_rid) const;
- virtual bool is_multimesh(const RID &p_rid) const;
- virtual bool is_poly(const RID &p_rid) const;
- virtual bool is_particles(const RID &p_beam) const;
- virtual bool is_beam(const RID &p_beam) const;
-
- virtual bool is_light(const RID &p_rid) const;
- virtual bool is_light_instance(const RID &p_rid) const;
- virtual bool is_particles_instance(const RID &p_rid) const;
- virtual bool is_skeleton(const RID &p_rid) const;
- virtual bool is_fx(const RID &p_rid) const;
- virtual bool is_shader(const RID &p_rid) const;
-
- virtual void free(const RID &p_rid) const;
-
- virtual void init();
- virtual void finish();
-
- virtual int get_render_info(VS::RenderInfo p_info);
-
- RasterizerIPhone();
- virtual ~RasterizerIPhone();
-};
-
-#endif
-#endif
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index dda619a54d..ae00fb429e 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -151,26 +151,26 @@ static EM_BOOL _mousebutton_callback(int event_type, const EmscriptenMouseEvent
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_MOUSEDOWN && event_type != EMSCRIPTEN_EVENT_MOUSEUP, false);
- InputEvent ev;
- ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.pressed = event_type == EMSCRIPTEN_EVENT_MOUSEDOWN;
- ev.mouse_button.global_x = ev.mouse_button.x = mouse_event->canvasX;
- ev.mouse_button.global_y = ev.mouse_button.y = mouse_event->canvasY;
+ Ref<InputEvent> ev;
+ ev.type = Ref<InputEvent>::MOUSE_BUTTON;
+ ev->is_pressed() = event_type == EMSCRIPTEN_EVENT_MOUSEDOWN;
+ ev.mouse_button.global_x = ev->get_pos().x = mouse_event->canvasX;
+ ev.mouse_button.global_y = ev->get_pos().y = mouse_event->canvasY;
ev.mouse_button.mod = dom2godot_mod(mouse_event);
switch (mouse_event->button) {
- case DOM_BUTTON_LEFT: ev.mouse_button.button_index = BUTTON_LEFT; break;
- case DOM_BUTTON_MIDDLE: ev.mouse_button.button_index = BUTTON_MIDDLE; break;
- case DOM_BUTTON_RIGHT: ev.mouse_button.button_index = BUTTON_RIGHT; break;
+ case DOM_BUTTON_LEFT: ev->get_button_index() = BUTTON_LEFT; break;
+ case DOM_BUTTON_MIDDLE: ev->get_button_index() = BUTTON_MIDDLE; break;
+ case DOM_BUTTON_RIGHT: ev->get_button_index() = BUTTON_RIGHT; break;
default: return false;
}
- ev.mouse_button.button_mask = _input->get_mouse_button_mask();
- if (ev.mouse_button.pressed)
- ev.mouse_button.button_mask |= 1 << ev.mouse_button.button_index;
+ ev->get_button_mask() = _input->get_mouse_button_mask();
+ if (ev->is_pressed())
+ ev->get_button_mask() |= 1 << ev->get_button_index();
else
- ev.mouse_button.button_mask &= ~(1 << ev.mouse_button.button_index);
- ev.mouse_button.button_mask >>= 1;
+ ev->get_button_mask() &= ~(1 << ev->get_button_index());
+ ev->get_button_mask() >>= 1;
_input->parse_input_event(ev);
return true;
@@ -180,16 +180,16 @@ static EM_BOOL _mousemove_callback(int event_type, const EmscriptenMouseEvent *m
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_MOUSEMOVE, false);
- InputEvent ev;
- ev.type = InputEvent::MOUSE_MOTION;
+ Ref<InputEvent> ev;
+ ev.type = Ref<InputEvent>::MOUSE_MOTION;
ev.mouse_motion.mod = dom2godot_mod(mouse_event);
- ev.mouse_motion.button_mask = _input->get_mouse_button_mask() >> 1;
+ ev->get_button_mask() = _input->get_mouse_button_mask() >> 1;
ev.mouse_motion.global_x = ev.mouse_motion.x = mouse_event->canvasX;
ev.mouse_motion.global_y = ev.mouse_motion.y = mouse_event->canvasY;
- ev.mouse_motion.relative_x = _input->get_mouse_position().x - ev.mouse_motion.x;
- ev.mouse_motion.relative_y = _input->get_mouse_position().y - ev.mouse_motion.y;
+ ev->get_relative().x = _input->get_mouse_position().x - ev.mouse_motion.x;
+ ev->get_relative().y = _input->get_mouse_position().y - ev.mouse_motion.y;
_input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
ev.mouse_motion.speed_x = _input->get_last_mouse_speed().x;
@@ -203,31 +203,31 @@ static EM_BOOL _wheel_callback(int event_type, const EmscriptenWheelEvent *wheel
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_WHEEL, false);
- InputEvent ev;
- ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_mask = _input->get_mouse_button_mask() >> 1;
- ev.mouse_button.global_x = ev.mouse_button.x = _input->get_mouse_position().x;
- ev.mouse_button.global_y = ev.mouse_button.y = _input->get_mouse_position().y;
- ev.mouse_button.mod.shift = _input->is_key_pressed(KEY_SHIFT);
- ev.mouse_button.mod.alt = _input->is_key_pressed(KEY_ALT);
- ev.mouse_button.mod.control = _input->is_key_pressed(KEY_CONTROL);
- ev.mouse_button.mod.meta = _input->is_key_pressed(KEY_META);
+ Ref<InputEvent> ev;
+ ev.type = Ref<InputEvent>::MOUSE_BUTTON;
+ ev->get_button_mask() = _input->get_mouse_button_mask() >> 1;
+ ev.mouse_button.global_x = ev->get_pos().x = _input->get_mouse_position().x;
+ ev.mouse_button.global_y = ev->get_pos().y = _input->get_mouse_position().y;
+ ev.mouse_button->get_shift() = _input->is_key_pressed(KEY_SHIFT);
+ ev.mouse_button->get_alt() = _input->is_key_pressed(KEY_ALT);
+ ev.mouse_button->get_control() = _input->is_key_pressed(KEY_CONTROL);
+ ev.mouse_button->get_metakey() = _input->is_key_pressed(KEY_META);
if (wheel_event->deltaY < 0)
- ev.mouse_button.button_index = BUTTON_WHEEL_UP;
+ ev->get_button_index() = BUTTON_WHEEL_UP;
else if (wheel_event->deltaY > 0)
- ev.mouse_button.button_index = BUTTON_WHEEL_DOWN;
+ ev->get_button_index() = BUTTON_WHEEL_DOWN;
else if (wheel_event->deltaX > 0)
- ev.mouse_button.button_index = BUTTON_WHEEL_LEFT;
+ ev->get_button_index() = BUTTON_WHEEL_LEFT;
else if (wheel_event->deltaX < 0)
- ev.mouse_button.button_index = BUTTON_WHEEL_RIGHT;
+ ev->get_button_index() = BUTTON_WHEEL_RIGHT;
else
return false;
- ev.mouse_button.pressed = true;
+ ev->is_pressed() = true;
_input->parse_input_event(ev);
- ev.mouse_button.pressed = false;
+ ev->is_pressed() = false;
_input->parse_input_event(ev);
return true;
@@ -243,8 +243,8 @@ static EM_BOOL _touchpress_callback(int event_type, const EmscriptenTouchEvent *
event_type != EMSCRIPTEN_EVENT_TOUCHCANCEL,
false);
- InputEvent ev;
- ev.type = InputEvent::SCREEN_TOUCH;
+ Ref<InputEvent> ev;
+ ev.type = Ref<InputEvent>::SCREEN_TOUCH;
int lowest_id_index = -1;
for (int i = 0; i < touch_event->numTouches; ++i) {
@@ -256,20 +256,20 @@ static EM_BOOL _touchpress_callback(int event_type, const EmscriptenTouchEvent *
ev.screen_touch.index = touch.identifier;
_prev_touches[i].x = ev.screen_touch.x = touch.canvasX;
_prev_touches[i].y = ev.screen_touch.y = touch.canvasY;
- ev.screen_touch.pressed = event_type == EMSCRIPTEN_EVENT_TOUCHSTART;
+ ev.screen_touch->is_pressed() = event_type == EMSCRIPTEN_EVENT_TOUCHSTART;
_input->parse_input_event(ev);
}
if (touch_event->touches[lowest_id_index].isChanged) {
- ev.type = InputEvent::MOUSE_BUTTON;
+ ev.type = Ref<InputEvent>::MOUSE_BUTTON;
ev.mouse_button.mod = dom2godot_mod(touch_event);
- ev.mouse_button.button_mask = _input->get_mouse_button_mask() >> 1;
- ev.mouse_button.global_x = ev.mouse_button.x = touch_event->touches[lowest_id_index].canvasX;
- ev.mouse_button.global_y = ev.mouse_button.y = touch_event->touches[lowest_id_index].canvasY;
- ev.mouse_button.button_index = BUTTON_LEFT;
- ev.mouse_button.pressed = event_type == EMSCRIPTEN_EVENT_TOUCHSTART;
+ ev->get_button_mask() = _input->get_mouse_button_mask() >> 1;
+ ev.mouse_button.global_x = ev->get_pos().x = touch_event->touches[lowest_id_index].canvasX;
+ ev.mouse_button.global_y = ev->get_pos().y = touch_event->touches[lowest_id_index].canvasY;
+ ev->get_button_index() = BUTTON_LEFT;
+ ev->is_pressed() = event_type == EMSCRIPTEN_EVENT_TOUCHSTART;
_input->parse_input_event(ev);
}
@@ -280,8 +280,8 @@ static EM_BOOL _touchmove_callback(int event_type, const EmscriptenTouchEvent *t
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_TOUCHMOVE, false);
- InputEvent ev;
- ev.type = InputEvent::SCREEN_DRAG;
+ Ref<InputEvent> ev;
+ ev.type = Ref<InputEvent>::SCREEN_DRAG;
int lowest_id_index = -1;
for (int i = 0; i < touch_event->numTouches; ++i) {
@@ -304,13 +304,13 @@ static EM_BOOL _touchmove_callback(int event_type, const EmscriptenTouchEvent *t
if (touch_event->touches[lowest_id_index].isChanged) {
- ev.type = InputEvent::MOUSE_MOTION;
+ ev.type = Ref<InputEvent>::MOUSE_MOTION;
ev.mouse_motion.mod = dom2godot_mod(touch_event);
- ev.mouse_motion.button_mask = _input->get_mouse_button_mask() >> 1;
+ ev->get_button_mask() = _input->get_mouse_button_mask() >> 1;
ev.mouse_motion.global_x = ev.mouse_motion.x = touch_event->touches[lowest_id_index].canvasX;
ev.mouse_motion.global_y = ev.mouse_motion.y = touch_event->touches[lowest_id_index].canvasY;
- ev.mouse_motion.relative_x = _input->get_mouse_position().x - ev.mouse_motion.x;
- ev.mouse_motion.relative_y = _input->get_mouse_position().y - ev.mouse_motion.y;
+ ev->get_relative().x = _input->get_mouse_position().x - ev.mouse_motion.x;
+ ev->get_relative().y = _input->get_mouse_position().y - ev.mouse_motion.y;
_input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
ev.mouse_motion.speed_x = _input->get_last_mouse_speed().x;
@@ -321,13 +321,13 @@ static EM_BOOL _touchmove_callback(int event_type, const EmscriptenTouchEvent *t
return true;
}
-static InputEvent _setup_key_event(const EmscriptenKeyboardEvent *emscripten_event) {
+static Ref<InputEvent> _setup_key_event(const EmscriptenKeyboardEvent *emscripten_event) {
- InputEvent ev;
- ev.type = InputEvent::KEY;
- ev.key.echo = emscripten_event->repeat;
+ Ref<InputEvent> ev;
+ ev.type = Ref<InputEvent>::KEY;
+ ev->is_echo() = emscripten_event->repeat;
ev.key.mod = dom2godot_mod(emscripten_event);
- ev.key.scancode = dom2godot_scancode(emscripten_event->keyCode);
+ ev->get_scancode() = dom2godot_scancode(emscripten_event->keyCode);
String unicode = String::utf8(emscripten_event->key);
// check if empty or multi-character (e.g. `CapsLock`)
@@ -342,15 +342,15 @@ static InputEvent _setup_key_event(const EmscriptenKeyboardEvent *emscripten_eve
return ev;
}
-static InputEvent deferred_key_event;
+static Ref<InputEvent> deferred_key_event;
static EM_BOOL _keydown_callback(int event_type, const EmscriptenKeyboardEvent *key_event, void *user_data) {
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_KEYDOWN, false);
- InputEvent ev = _setup_key_event(key_event);
- ev.key.pressed = true;
- if (ev.key.unicode == 0 && keycode_has_unicode(ev.key.scancode)) {
+ Ref<InputEvent> ev = _setup_key_event(key_event);
+ ev->is_pressed() = true;
+ if (ev.key.unicode == 0 && keycode_has_unicode(ev->get_scancode())) {
// defer to keypress event for legacy unicode retrieval
deferred_key_event = ev;
return false; // do not suppress keypress event
@@ -372,10 +372,10 @@ static EM_BOOL _keyup_callback(int event_type, const EmscriptenKeyboardEvent *ke
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_KEYUP, false);
- InputEvent ev = _setup_key_event(key_event);
- ev.key.pressed = false;
+ Ref<InputEvent> ev = _setup_key_event(key_event);
+ ev->is_pressed() = false;
_input->parse_input_event(ev);
- return ev.key.scancode != KEY_UNKNOWN && ev.key.scancode != 0;
+ return ev->get_scancode() != KEY_UNKNOWN && ev->get_scancode() != 0;
}
static EM_BOOL joy_callback_func(int p_type, const EmscriptenGamepadEvent *p_event, void *p_user) {
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 2bc603d8d9..65269148ec 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -154,7 +154,7 @@ public:
virtual String get_resource_dir() const;
void process_accelerometer(const Vector3 &p_accelerometer);
- void push_input(const InputEvent &p_ev);
+ void push_input(const Ref<InputEvent> &p_ev);
virtual bool is_joy_known(int p_device);
virtual String get_joy_guid(int p_device) const;
diff --git a/platform/osx/SCsub b/platform/osx/SCsub
index 1427c2e00d..27117c2e8d 100644
--- a/platform/osx/SCsub
+++ b/platform/osx/SCsub
@@ -7,7 +7,6 @@ files = [
'godot_main_osx.mm',
'audio_driver_osx.cpp',
'sem_osx.cpp',
- # 'context_gl_osx.cpp',
'dir_access_osx.mm',
'joypad_osx.cpp',
'power_osx.cpp',
diff --git a/platform/osx/context_gl_osx.cpp b/platform/osx/context_gl_osx.cpp
deleted file mode 100644
index 1377d829b0..0000000000
--- a/platform/osx/context_gl_osx.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*************************************************************************/
-/* context_gl_osx.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "context_gl_osx.h"
-
-#ifdef OSX_ENABLED
-#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
-#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
-
-void ContextGL_OSX::release_current() {
-
- aglSetCurrentContext(context);
-}
-
-void ContextGL_OSX::make_current() {
-
- aglSetCurrentContext(NULL);
-}
-void ContextGL_OSX::swap_buffers() {
-
- aglSwapBuffers(context);
-}
-
-Error ContextGL_OSX::initialize() {
-
- if ((Ptr)kUnresolvedCFragSymbolAddress == (Ptr)aglChoosePixelFormat)
- return FAILED;
-
- GLint attributes[] = { AGL_RGBA,
- AGL_DOUBLEBUFFER,
- AGL_DEPTH_SIZE, 32,
- AGL_NO_RECOVERY,
- AGL_NONE,
- AGL_NONE };
-
- AGLPixelFormat format = NULL;
-
- format = aglChoosePixelFormat(NULL, 0, attributes);
-
- if (!format)
- return FAILED;
-
- context = aglCreateContext(format, 0);
-
- if (!context)
- return FAILED;
-
- aglDestroyPixelFormat(format);
-
- aglSetWindowRef(context, window);
-
- GLint swapInterval = 1;
- aglSetInteger(context, AGL_SWAP_INTERVAL, &swapInterval);
-
- aglSetCurrentContext(context);
-
- return OK;
-}
-
-ContextGL_OSX::ContextGL_OSX(WindowRef p_window) {
-
- window = p_window;
-}
-
-ContextGL_OSX::~ContextGL_OSX() {
-
- if (context)
- aglDestroyContext(context);
-}
-
-#endif
-#endif
diff --git a/platform/osx/context_gl_osx.h b/platform/osx/context_gl_osx.h
deleted file mode 100644
index d0e2a2c0d3..0000000000
--- a/platform/osx/context_gl_osx.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*************************************************************************/
-/* context_gl_osx.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef CONTEXT_GL_OSX_H
-#define CONTEXT_GL_OSX_H
-
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-#ifdef OSX_ENABLED
-
-#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
-
-#include "drivers/gl_context/context_gl.h"
-#include "os/os.h"
-#include <AGL/agl.h>
-#include <Carbon/Carbon.h>
-
-class ContextGL_OSX : public ContextGL {
-
- AGLContext context;
- WindowRef window;
-
-public:
- virtual void release_current();
- virtual void make_current();
- virtual void swap_buffers();
-
- virtual Error initialize();
-
- ContextGL_OSX(WindowRef window);
- ~ContextGL_OSX();
-};
-
-#endif
-
-#endif
-#endif
diff --git a/platform/osx/godot_osx.h b/platform/osx/godot_osx.h
deleted file mode 100644
index 48784ab7d5..0000000000
--- a/platform/osx/godot_osx.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*************************************************************************/
-/* godot_osx.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef GODOT_OSX_H
-#define GODOT_OSX_H
-
-#import <Cocoa/Cocoa.h>
-
-@interface GodotMain : NSObject
-@end
-
-#endif
diff --git a/platform/osx/godot_osx.mm b/platform/osx/godot_osx.mm
deleted file mode 100644
index 626406ad1d..0000000000
--- a/platform/osx/godot_osx.mm
+++ /dev/null
@@ -1,208 +0,0 @@
-/*************************************************************************/
-/* godot_osx.mm */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "godot_osx.h"
-
-#include <sys/param.h> /* for MAXPATHLEN */
-#include <unistd.h>
-
-/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
- but the method still is there and works. To avoid warnings, we declare
- it ourselves here. */
-@interface NSApplication ()
-- (void)setAppleMenu:(NSMenu *)menu;
-@end
-
-static int global_argc;
-static char **global_argv;
-static BOOL gCalledAppMainline = FALSE;
-
-static NSString *getApplicationName(void) {
- const NSDictionary *dict;
- NSString *appName = 0;
-
- /* Determine the application name */
- dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
- if (dict)
- appName = [dict objectForKey:@"CFBundleName"];
-
- if (![appName length])
- appName = [[NSProcessInfo processInfo] processName];
-
- return appName;
-}
-
-/* The main class of the application, the application's delegate */
-@implementation GodotMain
-
-static void setApplicationMenu(void) {
- /* warning: this code is very odd */
- NSMenu *appleMenu;
- NSMenuItem *menuItem;
- NSString *title;
- NSString *appName;
-
- appName = getApplicationName();
- appleMenu = [[NSMenu alloc] initWithTitle:@""];
-
- /* Add menu items */
- title = [@"About " stringByAppendingString:appName];
- [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
-
- [appleMenu addItem:[NSMenuItem separatorItem]];
-
- title = [@"Hide " stringByAppendingString:appName];
- [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
-
- menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
- [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
-
- [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
-
- [appleMenu addItem:[NSMenuItem separatorItem]];
-
- title = [@"Quit " stringByAppendingString:appName];
- [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
-
- /* Put menu into the menubar */
- menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
- [menuItem setSubmenu:appleMenu];
- [[NSApp mainMenu] addItem:menuItem];
-
- /* Tell the application object that this is now the application menu */
- [NSApp setAppleMenu:appleMenu];
-
- /* Finally give up our references to the objects */
- [appleMenu release];
- [menuItem release];
-}
-
-/* Create a window menu */
-static void setupWindowMenu(void) {
- NSMenu *windowMenu;
- NSMenuItem *windowMenuItem;
- NSMenuItem *menuItem;
-
- windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
-
- /* "Minimize" item */
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
- [windowMenu addItem:menuItem];
- [menuItem release];
-
- /* Put menu into the menubar */
- windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
- [windowMenuItem setSubmenu:windowMenu];
- [[NSApp mainMenu] addItem:windowMenuItem];
-
- /* Tell the application object that this is now the window menu */
- [NSApp setWindowsMenu:windowMenu];
-
- /* Finally give up our references to the objects */
- [windowMenu release];
- [windowMenuItem release];
-}
-
-/* Replacement for NSApplicationMain */
-static void CustomApplicationMain(int argc, char **argv) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- GodotMain *main;
-
- /* Ensure the application object is initialised */
- [NSApplication sharedApplication];
-
- /* Set up the menubar */
- [NSApp setMainMenu:[[NSMenu alloc] init]];
- setApplicationMenu();
- setupWindowMenu();
-
- main = [[main alloc] init];
- [NSApp setDelegate:main];
-
- /* Start the main event loop */
- [NSApp run];
-
- [main release];
- [pool release];
-}
-
-extern int godot_main(int argc, char **argv);
-
-/* Called when the internal event loop has just started running */
-- (void)applicationDidFinishLaunching:(NSNotification *)note {
- int status;
-
- /* Hand off to main application code */
- gCalledAppMainline = TRUE;
-
- int ret = godot_main(global_argc, global_argv);
-
- exit(ret);
-}
-@end
-
-#ifdef main
-#undef main
-#endif
-
-int main(int argc, char **argv) {
- /* Copy the arguments into a global variable */
- /* This is passed if we are launched by double-clicking */
- if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
- global_argv = (char **)malloc(sizeof(char *) * 2);
- global_argv[0] = argv[0];
- global_argv[1] = NULL;
- global_argc = 1;
-
- // chdir to binary's dir when launched from finder
- int len = strlen(global_argv[0]);
-
- while (len--) {
- if (global_argv[0][len] == '/') break;
- }
-
- if (len >= 0) {
- char *path = (char *)malloc(len + 1);
- memcpy(path, global_argv[0], len);
- path[len] = 0;
- printf("Path: %s\n", path);
- chdir(path);
- }
-
- } else {
- int i;
- global_argc = argc;
- global_argv = (char **)malloc(sizeof(char *) * (argc + 1));
- for (i = 0; i <= argc; i++)
- global_argv[i] = argv[i];
- }
-
- CustomApplicationMain(argc, argv);
- return 0;
-}
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index ff02bf0794..3a37d663ad 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -165,7 +165,7 @@ public:
virtual void swap_buffers();
Error shell_open(String p_uri);
- void push_input(const InputEvent &p_event);
+ void push_input(const Ref<InputEvent> &p_event);
String get_locale() const;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 065506c612..462a926674 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -53,35 +53,6 @@
#include <sys/types.h>
#include <unistd.h>
-//uses portions of glfw
-
-//========================================================================
-// GLFW 3.0 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-// claim that you wrote the original software. If you use this software
-// in a product, an acknowledgment in the product documentation would
-// be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-// be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-// distribution.
-//
-//========================================================================
-
static NSRect convertRectToBacking(NSRect contentRect) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
@@ -249,14 +220,7 @@ static int button_mask = 0;
+ (void)initialize {
if (self == [GodotContentView class]) {
- /*
- if (_glfw.ns.cursor == nil) {
- NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
- _glfw.ns.cursor = [[NSCursor alloc] initWithImage:data
- hotSpot:NSZeroPoint];
- [data release];
- }
-*/
+ // nothing left to do here at the moment..
}
}
@@ -324,25 +288,18 @@ static int button_mask = 0;
//print_line("mouse down:");
button_mask |= BUTTON_MASK_LEFT;
- InputEvent ev;
+ Ref<InputEvent> ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = BUTTON_LEFT;
- ev.mouse_button.pressed = true;
- ev.mouse_button.x = mouse_x;
- ev.mouse_button.y = mouse_y;
+ ev->get_button_index() = BUTTON_LEFT;
+ ev->is_pressed() = true;
+ ev->get_pos().x = mouse_x;
+ ev->get_pos().y = mouse_y;
ev.mouse_button.global_x = mouse_x;
ev.mouse_button.global_y = mouse_y;
- ev.mouse_button.button_mask = button_mask;
+ ev->get_button_mask() = button_mask;
ev.mouse_button.doubleclick = [event clickCount] == 2;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
-
- /*
- _glfwInputMouseClick(window,
- GLFW_MOUSE_BUTTON_LEFT,
- GLFW_PRESS,
- translateFlags([event modifierFlags]));
-*/
}
- (void)mouseDragged:(NSEvent *)event {
@@ -352,31 +309,24 @@ static int button_mask = 0;
- (void)mouseUp:(NSEvent *)event {
button_mask &= ~BUTTON_MASK_LEFT;
- InputEvent ev;
+ Ref<InputEvent> ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = BUTTON_LEFT;
- ev.mouse_button.pressed = false;
- ev.mouse_button.x = mouse_x;
- ev.mouse_button.y = mouse_y;
+ ev->get_button_index() = BUTTON_LEFT;
+ ev->is_pressed() = false;
+ ev->get_pos().x = mouse_x;
+ ev->get_pos().y = mouse_y;
ev.mouse_button.global_x = mouse_x;
ev.mouse_button.global_y = mouse_y;
- ev.mouse_button.button_mask = button_mask;
+ ev->get_button_mask() = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
-
- /*
- _glfwInputMouseClick(window,
- GLFW_MOUSE_BUTTON_LEFT,
- GLFW_RELEASE,
- translateFlags([event modifierFlags]));
-*/
}
- (void)mouseMoved:(NSEvent *)event {
- InputEvent ev;
+ Ref<InputEvent> ev;
ev.type = InputEvent::MOUSE_MOTION;
- ev.mouse_motion.button_mask = button_mask;
+ ev->get_button_mask() = button_mask;
prev_mouse_x = mouse_x;
prev_mouse_y = mouse_y;
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
@@ -387,46 +337,28 @@ static int button_mask = 0;
ev.mouse_motion.y = mouse_y;
ev.mouse_motion.global_x = mouse_x;
ev.mouse_motion.global_y = mouse_y;
- ev.mouse_motion.relative_x = [event deltaX] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
- ev.mouse_motion.relative_y = [event deltaY] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
+ ev->get_relative().x = [event deltaX] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
+ ev->get_relative().y = [event deltaY] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
ev.mouse_motion.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y));
OS_OSX::singleton->push_input(ev);
-
- /*
- if (window->cursorMode == GLFW_CURSOR_DISABLED)
- _glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
- else {
- const NSRect contentRect = [window->ns.view frame];
- const NSPoint p = [event locationInWindow];
-
- _glfwInputCursorMotion(window, p.x, contentRect.size.height - p.y);
- }
-*/
}
- (void)rightMouseDown:(NSEvent *)event {
button_mask |= BUTTON_MASK_RIGHT;
- InputEvent ev;
+ Ref<InputEvent> ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = BUTTON_RIGHT;
- ev.mouse_button.pressed = true;
- ev.mouse_button.x = mouse_x;
- ev.mouse_button.y = mouse_y;
+ ev->get_button_index() = BUTTON_RIGHT;
+ ev->is_pressed() = true;
+ ev->get_pos().x = mouse_x;
+ ev->get_pos().y = mouse_y;
ev.mouse_button.global_x = mouse_x;
ev.mouse_button.global_y = mouse_y;
- ev.mouse_button.button_mask = button_mask;
+ ev->get_button_mask() = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
-
- /*
- _glfwInputMouseClick(window,
- GLFW_MOUSE_BUTTON_RIGHT,
- GLFW_PRESS,
- translateFlags([event modifierFlags]));
-*/
}
- (void)rightMouseDragged:(NSEvent *)event {
@@ -436,24 +368,17 @@ static int button_mask = 0;
- (void)rightMouseUp:(NSEvent *)event {
button_mask &= ~BUTTON_MASK_RIGHT;
- InputEvent ev;
+ Ref<InputEvent> ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = BUTTON_RIGHT;
- ev.mouse_button.pressed = false;
- ev.mouse_button.x = mouse_x;
- ev.mouse_button.y = mouse_y;
+ ev->get_button_index() = BUTTON_RIGHT;
+ ev->is_pressed() = false;
+ ev->get_pos().x = mouse_x;
+ ev->get_pos().y = mouse_y;
ev.mouse_button.global_x = mouse_x;
ev.mouse_button.global_y = mouse_y;
- ev.mouse_button.button_mask = button_mask;
+ ev->get_button_mask() = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
-
- /*
- _glfwInputMouseClick(window,
- GLFW_MOUSE_BUTTON_RIGHT,
- GLFW_RELEASE,
- translateFlags([event modifierFlags]));
-*/
}
- (void)otherMouseDown:(NSEvent *)event {
@@ -462,24 +387,17 @@ static int button_mask = 0;
return;
button_mask |= BUTTON_MASK_MIDDLE;
- InputEvent ev;
+ Ref<InputEvent> ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = BUTTON_MIDDLE;
- ev.mouse_button.pressed = true;
- ev.mouse_button.x = mouse_x;
- ev.mouse_button.y = mouse_y;
+ ev->get_button_index() = BUTTON_MIDDLE;
+ ev->is_pressed() = true;
+ ev->get_pos().x = mouse_x;
+ ev->get_pos().y = mouse_y;
ev.mouse_button.global_x = mouse_x;
ev.mouse_button.global_y = mouse_y;
- ev.mouse_button.button_mask = button_mask;
+ ev->get_button_mask() = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
-
- /*
- _glfwInputMouseClick(window,
- (int) [event buttonNumber],
- GLFW_PRESS,
- translateFlags([event modifierFlags]));
-*/
}
- (void)otherMouseDragged:(NSEvent *)event {
@@ -492,24 +410,17 @@ static int button_mask = 0;
return;
button_mask &= ~BUTTON_MASK_MIDDLE;
- InputEvent ev;
+ Ref<InputEvent> ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = BUTTON_MIDDLE;
- ev.mouse_button.pressed = false;
- ev.mouse_button.x = mouse_x;
- ev.mouse_button.y = mouse_y;
+ ev->get_button_index() = BUTTON_MIDDLE;
+ ev->is_pressed() = false;
+ ev->get_pos().x = mouse_x;
+ ev->get_pos().y = mouse_y;
ev.mouse_button.global_x = mouse_x;
ev.mouse_button.global_y = mouse_y;
- ev.mouse_button.button_mask = button_mask;
+ ev->get_button_mask() = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
-
- /*
- _glfwInputMouseClick(window,
- (int) [event buttonNumber],
- GLFW_RELEASE,
- translateFlags([event modifierFlags]));
-*/
}
- (void)mouseExited:(NSEvent *)event {
@@ -520,11 +431,9 @@ static int button_mask = 0;
OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
if (OS_OSX::singleton->input)
OS_OSX::singleton->input->set_mouse_in_window(false);
- //_glfwInputCursorEnter(window, GL_FALSE);
}
- (void)mouseEntered:(NSEvent *)event {
- //_glfwInputCursorEnter(window, GL_TRUE);
if (!OS_OSX::singleton)
return;
if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode != OS::MOUSE_MODE_CAPTURED)
@@ -534,12 +443,7 @@ static int button_mask = 0;
}
- (void)viewDidChangeBackingProperties {
- /*
- const NSRect contentRect = [window->ns.view frame];
- const NSRect fbRect = convertRectToBacking(window, contentRect);
-
- _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
-*/
+ // nothing left to do here
}
- (void)updateTrackingAreas {
@@ -706,21 +610,21 @@ static int translateKey(unsigned int key) {
}
- (void)keyDown:(NSEvent *)event {
- InputEvent ev;
+ Ref<InputEvent> ev;
ev.type = InputEvent::KEY;
- ev.key.pressed = true;
+ ev->is_pressed() = true;
ev.key.mod = translateFlags([event modifierFlags]);
- ev.key.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode]));
- ev.key.echo = [event isARepeat];
+ ev->get_scancode() = latin_keyboard_keycode_convert(translateKey([event keyCode]));
+ ev->is_echo() = [event isARepeat];
NSString *characters = [event characters];
NSUInteger i, length = [characters length];
- if (length > 0 && keycode_has_unicode(ev.key.scancode)) {
+ if (length > 0 && keycode_has_unicode(ev->get_scancode())) {
for (i = 0; i < length; i++) {
ev.key.unicode = [characters characterAtIndex:i];
OS_OSX::singleton->push_input(ev);
- ev.key.scancode = 0;
+ ev->get_scancode() = 0;
}
} else {
OS_OSX::singleton->push_input(ev);
@@ -728,7 +632,7 @@ static int translateKey(unsigned int key) {
}
- (void)flagsChanged:(NSEvent *)event {
- InputEvent ev;
+ Ref<InputEvent> ev;
int key = [event keyCode];
int mod = [event modifierFlags];
@@ -737,70 +641,64 @@ static int translateKey(unsigned int key) {
if (key == 0x36 || key == 0x37) {
if (mod & NSCommandKeyMask) {
mod &= ~NSCommandKeyMask;
- ev.key.pressed = true;
+ ev->is_pressed() = true;
} else {
- ev.key.pressed = false;
+ ev->is_pressed() = false;
}
} else if (key == 0x38 || key == 0x3c) {
if (mod & NSShiftKeyMask) {
mod &= ~NSShiftKeyMask;
- ev.key.pressed = true;
+ ev->is_pressed() = true;
} else {
- ev.key.pressed = false;
+ ev->is_pressed() = false;
}
} else if (key == 0x3a || key == 0x3d) {
if (mod & NSAlternateKeyMask) {
mod &= ~NSAlternateKeyMask;
- ev.key.pressed = true;
+ ev->is_pressed() = true;
} else {
- ev.key.pressed = false;
+ ev->is_pressed() = false;
}
} else if (key == 0x3b || key == 0x3e) {
if (mod & NSControlKeyMask) {
mod &= ~NSControlKeyMask;
- ev.key.pressed = true;
+ ev->is_pressed() = true;
} else {
- ev.key.pressed = false;
+ ev->is_pressed() = false;
}
} else {
return;
}
ev.key.mod = translateFlags(mod);
- ev.key.scancode = latin_keyboard_keycode_convert(translateKey(key));
+ ev->get_scancode() = latin_keyboard_keycode_convert(translateKey(key));
OS_OSX::singleton->push_input(ev);
}
- (void)keyUp:(NSEvent *)event {
- InputEvent ev;
+ Ref<InputEvent> ev;
ev.type = InputEvent::KEY;
- ev.key.pressed = false;
+ ev->is_pressed() = false;
ev.key.mod = translateFlags([event modifierFlags]);
- ev.key.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode]));
+ ev->get_scancode() = latin_keyboard_keycode_convert(translateKey([event keyCode]));
OS_OSX::singleton->push_input(ev);
-
- /*
- const int key = translateKey([event keyCode]);
- const int mods = translateFlags([event modifierFlags]);
- _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
-*/
}
inline void sendScrollEvent(int button, double factor) {
- InputEvent ev;
- ev.type = InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index = button;
- ev.mouse_button.factor = factor;
- ev.mouse_button.pressed = true;
- ev.mouse_button.x = mouse_x;
- ev.mouse_button.y = mouse_y;
+ Ref<InputEvent> ev;
+ ev.type = Ref<InputEvent>::MOUSE_BUTTON;
+ ev->get_button_index() = button;
+ ev.mouse_button->get_factor() = factor;
+ ev->is_pressed() = true;
+ ev->get_pos().x = mouse_x;
+ ev->get_pos().y = mouse_y;
ev.mouse_button.global_x = mouse_x;
ev.mouse_button.global_y = mouse_y;
- ev.mouse_button.button_mask = button_mask;
+ ev->get_button_mask() = button_mask;
OS_OSX::singleton->push_input(ev);
- ev.mouse_button.pressed = false;
+ ev->is_pressed() = false;
OS_OSX::singleton->push_input(ev);
}
@@ -1617,9 +1515,9 @@ void OS_OSX::process_events() {
autoreleasePool = [[NSAutoreleasePool alloc] init];
}
-void OS_OSX::push_input(const InputEvent &p_event) {
+void OS_OSX::push_input(const Ref<InputEvent> &p_event) {
- InputEvent ev = p_event;
+ Ref<InputEvent> ev = p_event;
input->parse_input_event(ev);
}
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp
index 2946aa1eae..7c8f09b27b 100644
--- a/platform/uwp/app.cpp
+++ b/platform/uwp/app.cpp
@@ -259,10 +259,10 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor
int but = _get_button(point);
if (_is_touch(point)) {
- InputEvent event;
+ Ref<InputEvent> event;
event.type = InputEvent::SCREEN_TOUCH;
event.device = 0;
- event.screen_touch.pressed = p_pressed;
+ event.screen_touch->is_pressed() = p_pressed;
event.screen_touch.x = pos.X;
event.screen_touch.y = pos.Y;
event.screen_touch.index = _get_finger(point->PointerId);
@@ -276,21 +276,21 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor
}; // fallthrought of sorts
- InputEvent event;
+ Ref<InputEvent> event;
event.type = InputEvent::MOUSE_BUTTON;
event.device = 0;
- event.mouse_button.pressed = p_pressed;
- event.mouse_button.button_index = but;
- event.mouse_button.x = pos.X;
- event.mouse_button.y = pos.Y;
+ event->is_pressed() = p_pressed;
+ event->get_button_index() = but;
+ event->get_pos().x = pos.X;
+ event->get_pos().y = pos.Y;
event.mouse_button.global_x = pos.X;
event.mouse_button.global_y = pos.Y;
if (p_is_wheel) {
if (point->Properties->MouseWheelDelta > 0) {
- event.mouse_button.button_index = point->Properties->IsHorizontalMouseWheel ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_UP;
+ event->get_button_index() = point->Properties->IsHorizontalMouseWheel ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_UP;
} else if (point->Properties->MouseWheelDelta < 0) {
- event.mouse_button.button_index = point->Properties->IsHorizontalMouseWheel ? BUTTON_WHEEL_LEFT : BUTTON_WHEEL_DOWN;
+ event->get_button_index() = point->Properties->IsHorizontalMouseWheel ? BUTTON_WHEEL_LEFT : BUTTON_WHEEL_DOWN;
}
}
@@ -350,7 +350,7 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Co
if (point->IsInContact && _is_touch(point)) {
InputEvent event;
- event.type = InputEvent::SCREEN_DRAG;
+ event.type = Ref<InputEvent>::SCREEN_DRAG;
event.device = 0;
event.screen_drag.x = pos.X;
event.screen_drag.y = pos.Y;
@@ -369,14 +369,14 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Co
return;
InputEvent event;
- event.type = InputEvent::MOUSE_MOTION;
+ event.type = Ref<InputEvent>::MOUSE_MOTION;
event.device = 0;
event.mouse_motion.x = pos.X;
event.mouse_motion.y = pos.Y;
event.mouse_motion.global_x = pos.X;
event.mouse_motion.global_y = pos.Y;
- event.mouse_motion.relative_x = pos.X - last_touch_x[31];
- event.mouse_motion.relative_y = pos.Y - last_touch_y[31];
+ event->get_relative().x = pos.X - last_touch_x[31];
+ event->get_relative().y = pos.Y - last_touch_y[31];
last_mouse_pos = pos;
@@ -394,14 +394,14 @@ void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) {
pos.Y = last_mouse_pos.Y + args->MouseDelta.Y;
InputEvent event;
- event.type = InputEvent::MOUSE_MOTION;
+ event.type = Ref<InputEvent>::MOUSE_MOTION;
event.device = 0;
event.mouse_motion.x = pos.X;
event.mouse_motion.y = pos.Y;
event.mouse_motion.global_x = pos.X;
event.mouse_motion.global_y = pos.Y;
- event.mouse_motion.relative_x = args->MouseDelta.X;
- event.mouse_motion.relative_y = args->MouseDelta.Y;
+ event->get_relative().x = args->MouseDelta.X;
+ event->get_relative().y = args->MouseDelta.Y;
last_mouse_pos = pos;
@@ -420,20 +420,20 @@ void App::key_event(Windows::UI::Core::CoreWindow ^ sender, bool p_pressed, Wind
mod.shift = sender->GetAsyncKeyState(VirtualKey::Shift) == CoreVirtualKeyStates::Down;
ke.mod_state = mod;
- ke.pressed = p_pressed;
+ ke->is_pressed() = p_pressed;
if (key_args != nullptr) {
ke.type = OSUWP::KeyEvent::MessageType::KEY_EVENT_MESSAGE;
ke.unicode = 0;
- ke.scancode = KeyMappingWindows::get_keysym((unsigned int)key_args->VirtualKey);
+ ke->get_scancode() = KeyMappingWindows::get_keysym((unsigned int)key_args->VirtualKey);
ke.echo = (!p_pressed && !key_args->KeyStatus.IsKeyReleased) || (p_pressed && key_args->KeyStatus.WasKeyDown);
} else {
ke.type = OSUWP::KeyEvent::MessageType::CHAR_EVENT_MESSAGE;
ke.unicode = char_args->KeyCode;
- ke.scancode = 0;
+ ke->get_scancode() = 0;
ke.echo = (!p_pressed && !char_args->KeyStatus.IsKeyReleased) || (p_pressed && char_args->KeyStatus.WasKeyDown);
}
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index c68b2ffa33..47f4b3f3c8 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -330,14 +330,14 @@ String OSUWP::get_clipboard() const {
return "";
};
-void OSUWP::input_event(InputEvent &p_event) {
+void OSUWP::input_event(Ref<InputEvent> &p_event) {
input->parse_input_event(p_event);
- if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index > 3) {
+ if (p_event.type == Ref<InputEvent>::MOUSE_BUTTON && p_event->is_pressed() && p_event->get_button_index() > 3) {
//send release for mouse wheel
- p_event.mouse_button.pressed = false;
+ p_event->is_pressed() = false;
input->parse_input_event(p_event);
}
};
@@ -663,14 +663,14 @@ void OSUWP::process_key_events() {
for (int i = 0; i < key_event_pos; i++) {
KeyEvent &kev = key_event_buffer[i];
- InputEvent iev;
+ Ref<InputEvent> iev;
- iev.type = InputEvent::KEY;
+ iev.type = Ref<InputEvent>::KEY;
iev.key.mod = kev.mod_state;
- iev.key.echo = kev.echo;
- iev.key.scancode = kev.scancode;
+ iev->is_echo() = kev.echo;
+ iev->get_scancode() = kev->get_scancode();
iev.key.unicode = kev.unicode;
- iev.key.pressed = kev.pressed;
+ iev->is_pressed() = kev->is_pressed();
input_event(iev);
}
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index 22602e4564..d2a51aad4c 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -257,7 +257,7 @@ public:
virtual bool get_swap_ok_cancel() { return true; }
- void input_event(InputEvent &p_event);
+ void input_event(Ref<InputEvent> &p_event);
virtual PowerState get_power_state();
virtual int get_power_seconds_left();
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 42597f79c8..ba5db05dab 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -215,14 +215,11 @@ bool OS_Windows::can_draw() const {
void OS_Windows::_touch_event(bool p_pressed, int p_x, int p_y, int idx) {
- InputEvent event;
- event.type = InputEvent::SCREEN_TOUCH;
- event.screen_touch.index = idx;
-
- event.screen_touch.pressed = p_pressed;
-
- event.screen_touch.x = p_x;
- event.screen_touch.y = p_y;
+ Ref<InputEventScreenTouch> event;
+ event.instance();
+ event->set_index(idx);
+ event->set_pressed(p_pressed);
+ event->set_pos(Vector2(p_x, p_y));
if (main_loop) {
input->parse_input_event(event);
@@ -231,12 +228,10 @@ void OS_Windows::_touch_event(bool p_pressed, int p_x, int p_y, int idx) {
void OS_Windows::_drag_event(int p_x, int p_y, int idx) {
- InputEvent event;
- event.type = InputEvent::SCREEN_DRAG;
- event.screen_drag.index = idx;
-
- event.screen_drag.x = p_x;
- event.screen_drag.y = p_y;
+ Ref<InputEventScreenDrag> event;
+ event.instance();
+ event->set_index(idx);
+ event->set_pos(Vector2(p_x, p_y));
if (main_loop)
input->parse_input_event(event);
@@ -367,22 +362,23 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
};
*/
- InputEvent event;
- event.type = InputEvent::MOUSE_MOTION;
- InputEventMouseMotion &mm = event.mouse_motion;
+ Ref<InputEventMouseMotion> mm;
+ mm.instance();
+
+ mm->set_control((wParam & MK_CONTROL) != 0);
+ mm->set_shift((wParam & MK_SHIFT) != 0);
+ mm->set_alt(alt_mem);
- mm.mod.control = (wParam & MK_CONTROL) != 0;
- mm.mod.shift = (wParam & MK_SHIFT) != 0;
- mm.mod.alt = alt_mem;
+ int bmask = 0;
+ bmask |= (wParam & MK_LBUTTON) ? (1 << 0) : 0;
+ bmask |= (wParam & MK_RBUTTON) ? (1 << 1) : 0;
+ bmask |= (wParam & MK_MBUTTON) ? (1 << 2) : 0;
+ mm->set_button_mask(bmask);
- mm.button_mask |= (wParam & MK_LBUTTON) ? (1 << 0) : 0;
- mm.button_mask |= (wParam & MK_RBUTTON) ? (1 << 1) : 0;
- mm.button_mask |= (wParam & MK_MBUTTON) ? (1 << 2) : 0;
- last_button_state = mm.button_mask;
- /*mm.button_mask|=(wParam&MK_XBUTTON1)?(1<<5):0;
- mm.button_mask|=(wParam&MK_XBUTTON2)?(1<<6):0;*/
- mm.x = GET_X_LPARAM(lParam);
- mm.y = GET_Y_LPARAM(lParam);
+ last_button_state = mm->get_button_mask();
+ /*mm->get_button_mask()|=(wParam&MK_XBUTTON1)?(1<<5):0;
+ mm->get_button_mask()|=(wParam&MK_XBUTTON2)?(1<<6):0;*/
+ mm->set_pos(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
if (mouse_mode == MOUSE_MODE_CAPTURED) {
@@ -390,35 +386,33 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
old_x = c.x;
old_y = c.y;
- if (Point2i(mm.x, mm.y) == c) {
+ if (mm->get_pos() == c) {
center = c;
return 0;
}
- Point2i ncenter(mm.x, mm.y);
+ Point2i ncenter = mm->get_pos();
center = ncenter;
POINT pos = { (int)c.x, (int)c.y };
ClientToScreen(hWnd, &pos);
SetCursorPos(pos.x, pos.y);
}
- input->set_mouse_position(Point2(mm.x, mm.y));
- mm.speed_x = input->get_last_mouse_speed().x;
- mm.speed_y = input->get_last_mouse_speed().y;
+ input->set_mouse_position(mm->get_pos());
+ mm->set_speed(input->get_last_mouse_speed());
if (old_invalid) {
- old_x = mm.x;
- old_y = mm.y;
+ old_x = mm->get_pos().x;
+ old_y = mm->get_pos().y;
old_invalid = false;
}
- mm.relative_x = mm.x - old_x;
- mm.relative_y = mm.y - old_y;
- old_x = mm.x;
- old_y = mm.y;
+ mm->set_relative(Vector2(mm->get_pos() - Vector2(old_x, old_y)));
+ old_x = mm->get_pos().x;
+ old_y = mm->get_pos().y;
if (window_has_focus && main_loop)
- input->parse_input_event(event);
+ input->parse_input_event(mm);
} break;
case WM_LBUTTONDOWN:
@@ -447,114 +441,112 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
};
*/
- InputEvent event;
- event.type = InputEvent::MOUSE_BUTTON;
- InputEventMouseButton &mb = event.mouse_button;
+ Ref<InputEventMouseButton> mb;
+ mb.instance();
switch (uMsg) {
case WM_LBUTTONDOWN: {
- mb.pressed = true;
- mb.button_index = 1;
+ mb->set_pressed(true);
+ mb->set_button_index(1);
} break;
case WM_LBUTTONUP: {
- mb.pressed = false;
- mb.button_index = 1;
+ mb->set_pressed(false);
+ mb->set_button_index(1);
} break;
case WM_MBUTTONDOWN: {
- mb.pressed = true;
- mb.button_index = 3;
+ mb->set_pressed(true);
+ mb->set_button_index(3);
} break;
case WM_MBUTTONUP: {
- mb.pressed = false;
- mb.button_index = 3;
+ mb->set_pressed(false);
+ mb->set_button_index(3);
} break;
case WM_RBUTTONDOWN: {
- mb.pressed = true;
- mb.button_index = 2;
+ mb->set_pressed(true);
+ mb->set_button_index(2);
} break;
case WM_RBUTTONUP: {
- mb.pressed = false;
- mb.button_index = 2;
+ mb->set_pressed(false);
+ mb->set_button_index(2);
} break;
case WM_LBUTTONDBLCLK: {
- mb.pressed = true;
- mb.button_index = 1;
- mb.doubleclick = true;
+ mb->set_pressed(true);
+ mb->set_button_index(1);
+ mb->set_doubleclick(true);
} break;
case WM_RBUTTONDBLCLK: {
- mb.pressed = true;
- mb.button_index = 2;
- mb.doubleclick = true;
+ mb->set_pressed(true);
+ mb->set_button_index(2);
+ mb->set_doubleclick(true);
} break;
case WM_MOUSEWHEEL: {
- mb.pressed = true;
+ mb->set_pressed(true);
int motion = (short)HIWORD(wParam);
if (!motion)
return 0;
if (motion > 0)
- mb.button_index = BUTTON_WHEEL_UP;
+ mb->set_button_index(BUTTON_WHEEL_UP);
else
- mb.button_index = BUTTON_WHEEL_DOWN;
+ mb->set_button_index(BUTTON_WHEEL_DOWN);
} break;
case WM_MOUSEHWHEEL: {
- mb.pressed = true;
+ mb->set_pressed(true);
int motion = (short)HIWORD(wParam);
if (!motion)
return 0;
if (motion < 0) {
- mb.button_index = BUTTON_WHEEL_LEFT;
- mb.factor = fabs((double)motion / (double)WHEEL_DELTA);
+ mb->set_button_index(BUTTON_WHEEL_LEFT);
+ mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
} else {
- mb.button_index = BUTTON_WHEEL_RIGHT;
- mb.factor = fabs((double)motion / (double)WHEEL_DELTA);
+ mb->set_button_index(BUTTON_WHEEL_RIGHT);
+ mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
}
} break;
/*
case WM_XBUTTONDOWN: {
- mb.pressed=true;
- mb.button_index=(HIWORD(wParam)==XBUTTON1)?6:7;
+ mb->is_pressed()=true;
+ mb->get_button_index()=(HIWORD(wParam)==XBUTTON1)?6:7;
} break;
case WM_XBUTTONUP:
- mb.pressed=true;
- mb.button_index=(HIWORD(wParam)==XBUTTON1)?6:7;
+ mb->is_pressed()=true;
+ mb->get_button_index()=(HIWORD(wParam)==XBUTTON1)?6:7;
} break;*/
default: { return 0; }
}
- mb.mod.control = (wParam & MK_CONTROL) != 0;
- mb.mod.shift = (wParam & MK_SHIFT) != 0;
- mb.mod.alt = alt_mem;
- //mb.mod.alt=(wParam&MK_MENU)!=0;
- mb.button_mask |= (wParam & MK_LBUTTON) ? (1 << 0) : 0;
- mb.button_mask |= (wParam & MK_RBUTTON) ? (1 << 1) : 0;
- mb.button_mask |= (wParam & MK_MBUTTON) ? (1 << 2) : 0;
-
- last_button_state = mb.button_mask;
+ mb->set_control((wParam & MK_CONTROL) != 0);
+ mb->set_shift((wParam & MK_SHIFT) != 0);
+ mb->set_alt(alt_mem);
+ //mb->get_alt()=(wParam&MK_MENU)!=0;
+ int bmask = 0;
+ bmask |= (wParam & MK_LBUTTON) ? (1 << 0) : 0;
+ bmask |= (wParam & MK_RBUTTON) ? (1 << 1) : 0;
+ bmask |= (wParam & MK_MBUTTON) ? (1 << 2) : 0;
+ mb->set_button_mask(bmask);
+
+ last_button_state = mb->get_button_mask();
/*
- mb.button_mask|=(wParam&MK_XBUTTON1)?(1<<5):0;
- mb.button_mask|=(wParam&MK_XBUTTON2)?(1<<6):0;*/
- mb.x = GET_X_LPARAM(lParam);
- mb.y = GET_Y_LPARAM(lParam);
+ mb->get_button_mask()|=(wParam&MK_XBUTTON1)?(1<<5):0;
+ mb->get_button_mask()|=(wParam&MK_XBUTTON2)?(1<<6):0;*/
+ mb->set_pos(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
if (mouse_mode == MOUSE_MODE_CAPTURED) {
- mb.x = old_x;
- mb.y = old_y;
+ mb->set_pos(Vector2(old_x, old_y));
}
- mb.global_x = mb.x;
- mb.global_y = mb.y;
+ mb->set_global_pos(mb->get_pos());
if (uMsg != WM_MOUSEWHEEL) {
- if (mb.pressed) {
+ if (mb->is_pressed()) {
if (++pressrc > 0)
SetCapture(hWnd);
@@ -568,21 +560,21 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} else if (mouse_mode != MOUSE_MODE_CAPTURED) {
// for reasons unknown to mankind, wheel comes in screen cordinates
POINT coords;
- coords.x = mb.x;
- coords.y = mb.y;
+ coords.x = mb->get_pos().x;
+ coords.y = mb->get_pos().y;
ScreenToClient(hWnd, &coords);
- mb.x = coords.x;
- mb.y = coords.y;
+ mb->set_pos(coords);
}
if (main_loop) {
- input->parse_input_event(event);
- if (mb.pressed && mb.button_index > 3) {
+ input->parse_input_event(mb);
+ if (mb->is_pressed() && mb->get_button_index() > 3) {
//send release for mouse wheel
- mb.pressed = false;
- input->parse_input_event(event);
+ Ref<InputEventMouseButton> mbd = mb->duplicate();
+ mbd->set_pressed(false);
+ input->parse_input_event(mbd);
}
}
}
@@ -638,10 +630,10 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
// Make sure we don't include modifiers for the modifier key itself.
KeyEvent ke;
- ke.mod_state.shift = (wParam != VK_SHIFT) ? shift_mem : false;
- ke.mod_state.alt = (!(wParam == VK_MENU && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN))) ? alt_mem : false;
- ke.mod_state.control = (wParam != VK_CONTROL) ? control_mem : false;
- ke.mod_state.meta = meta_mem;
+ ke.shift = (wParam != VK_SHIFT) ? shift_mem : false;
+ ke.alt = (!(wParam == VK_MENU && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN))) ? alt_mem : false;
+ ke.control = (wParam != VK_CONTROL) ? control_mem : false;
+ ke.meta = meta_mem;
ke.uMsg = uMsg;
if (ke.uMsg == WM_SYSKEYDOWN)
@@ -777,23 +769,25 @@ void OS_Windows::process_key_events() {
case WM_CHAR: {
if ((i == 0 && ke.uMsg == WM_CHAR) || (i > 0 && key_event_buffer[i - 1].uMsg == WM_CHAR)) {
- InputEvent event;
- event.type = InputEvent::KEY;
- InputEventKey &k = event.key;
-
- k.mod = ke.mod_state;
- k.pressed = true;
- k.scancode = KeyMappingWindows::get_keysym(ke.wParam);
- k.unicode = ke.wParam;
- if (k.unicode && gr_mem) {
- k.mod.alt = false;
- k.mod.control = false;
+ Ref<InputEventKey> k;
+ k.instance();
+
+ k->set_shift(ke.shift);
+ k->set_alt(ke.alt);
+ k->set_control(ke.control);
+ k->set_metakey(ke.meta);
+ k->set_pressed(true);
+ k->set_scancode(KeyMappingWindows::get_keysym(ke.wParam));
+ k->set_unicode(ke.wParam);
+ if (k->get_unicode() && gr_mem) {
+ k->set_alt(false);
+ k->set_control(false);
}
- if (k.unicode < 32)
- k.unicode = 0;
+ if (k->get_unicode() < 32)
+ k->set_unicode(0);
- input->parse_input_event(event);
+ input->parse_input_event(k);
}
//do nothing
@@ -801,27 +795,32 @@ void OS_Windows::process_key_events() {
case WM_KEYUP:
case WM_KEYDOWN: {
- InputEvent event;
- event.type = InputEvent::KEY;
- InputEventKey &k = event.key;
+ Ref<InputEventKey> k;
+ k.instance();
+
+ k->set_shift(ke.shift);
+ k->set_alt(ke.alt);
+ k->set_control(ke.control);
+ k->set_metakey(ke.meta);
- k.mod = ke.mod_state;
- k.pressed = (ke.uMsg == WM_KEYDOWN);
+ k->set_pressed(ke.uMsg == WM_KEYDOWN);
- k.scancode = KeyMappingWindows::get_keysym(ke.wParam);
- if (i + 1 < key_event_pos && key_event_buffer[i + 1].uMsg == WM_CHAR)
- k.unicode = key_event_buffer[i + 1].wParam;
- if (k.unicode && gr_mem) {
- k.mod.alt = false;
- k.mod.control = false;
+ k->set_scancode(KeyMappingWindows::get_keysym(ke.wParam));
+
+ if (i + 1 < key_event_pos && key_event_buffer[i + 1].uMsg == WM_CHAR) {
+ k->set_unicode(key_event_buffer[i + 1].wParam);
+ }
+ if (k->get_unicode() && gr_mem) {
+ k->set_alt(false);
+ k->set_control(false);
}
- if (k.unicode < 32)
- k.unicode = 0;
+ if (k->get_unicode() < 32)
+ k->set_unicode(0);
- k.echo = (ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30)));
+ k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30))));
- input->parse_input_event(event);
+ input->parse_input_event(k);
} break;
}
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 4dd05928df..bd5acde417 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -69,6 +69,7 @@ class OS_Windows : public OS {
struct KeyEvent {
InputModifierState mod_state;
+ bool alt, shift, ctrl, meta;
UINT uMsg;
WPARAM wParam;
LPARAM lParam;
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 59ac1fed96..8534185389 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -958,16 +958,12 @@ void OS_X11::request_attention() {
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
-InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) {
+void OS_X11::get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state) {
- InputModifierState state;
-
- state.shift = (p_x11_state & ShiftMask);
- state.control = (p_x11_state & ControlMask);
- state.alt = (p_x11_state & Mod1Mask /*|| p_x11_state&Mod5Mask*/); //altgr should not count as alt
- state.meta = (p_x11_state & Mod4Mask);
-
- return state;
+ state->set_shift((p_x11_state & ShiftMask));
+ state->set_control((p_x11_state & ControlMask));
+ state->set_alt((p_x11_state & Mod1Mask /*|| p_x11_state&Mod5Mask*/)); //altgr should not count as alt
+ state->set_metakey((p_x11_state & Mod4Mask));
}
unsigned int OS_X11::get_mouse_button_state(unsigned int p_x11_state) {
@@ -1099,7 +1095,10 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
//print_line("mod1: "+itos(xkeyevent->state&Mod1Mask)+" mod 5: "+itos(xkeyevent->state&Mod5Mask));
- InputModifierState state = get_key_modifier_state(xkeyevent->state);
+ Ref<InputEventKey> k;
+ k.instance();
+
+ get_key_modifier_state(xkeyevent->state, k);
/* Phase 6, determine echo character */
@@ -1142,40 +1141,36 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
/* Phase 7, send event to Window */
- InputEvent event;
- event.type = InputEvent::KEY;
- event.device = 0;
- event.key.mod = state;
- event.key.pressed = keypress;
+ k->set_pressed(keypress);
if (keycode >= 'a' && keycode <= 'z')
keycode -= 'a' - 'A';
- event.key.scancode = keycode;
- event.key.unicode = unicode;
- event.key.echo = p_echo;
+ k->set_scancode(keycode);
+ k->set_unicode(unicode);
+ k->set_echo(p_echo);
- if (event.key.scancode == KEY_BACKTAB) {
+ if (k->get_scancode() == KEY_BACKTAB) {
//make it consistent across platforms.
- event.key.scancode = KEY_TAB;
- event.key.mod.shift = true;
+ k->set_scancode(KEY_TAB);
+ k->set_shift(true);
}
//don't set mod state if modifier keys are released by themselves
//else event.is_action() will not work correctly here
- if (!event.key.pressed) {
- if (event.key.scancode == KEY_SHIFT)
- event.key.mod.shift = false;
- else if (event.key.scancode == KEY_CONTROL)
- event.key.mod.control = false;
- else if (event.key.scancode == KEY_ALT)
- event.key.mod.alt = false;
- else if (event.key.scancode == KEY_META)
- event.key.mod.meta = false;
+ if (!k->is_pressed()) {
+ if (k->get_scancode() == KEY_SHIFT)
+ k->set_shift(false);
+ else if (k->get_scancode() == KEY_CONTROL)
+ k->set_control(false);
+ else if (k->get_scancode() == KEY_ALT)
+ k->set_alt(false);
+ else if (k->get_scancode() == KEY_META)
+ k->set_metakey(false);
}
- //printf("key: %x\n",event.key.scancode);
- input->parse_input_event(event);
+ //printf("key: %x\n",k->get_scancode());
+ input->parse_input_event(k);
}
struct Property {
@@ -1332,22 +1327,20 @@ void OS_X11::process_xevents() {
event.xbutton.y = last_mouse_pos.y;
}
- InputEvent mouse_event;
- mouse_event.type = InputEvent::MOUSE_BUTTON;
- mouse_event.device = 0;
- mouse_event.mouse_button.mod = get_key_modifier_state(event.xbutton.state);
- mouse_event.mouse_button.button_mask = get_mouse_button_state(event.xbutton.state);
- mouse_event.mouse_button.x = event.xbutton.x;
- mouse_event.mouse_button.y = event.xbutton.y;
- mouse_event.mouse_button.global_x = event.xbutton.x;
- mouse_event.mouse_button.global_y = event.xbutton.y;
- mouse_event.mouse_button.button_index = event.xbutton.button;
- if (mouse_event.mouse_button.button_index == 2)
- mouse_event.mouse_button.button_index = 3;
- else if (mouse_event.mouse_button.button_index == 3)
- mouse_event.mouse_button.button_index = 2;
-
- mouse_event.mouse_button.pressed = (event.type == ButtonPress);
+ Ref<InputEventMouseButton> mb;
+ mb.instance();
+
+ get_key_modifier_state(event.xbutton.state, mb);
+ mb->set_button_mask(get_mouse_button_state(event.xbutton.state));
+ mb->set_pos(Vector2(event.xbutton.x, event.xbutton.y));
+ mb->set_global_pos(mb->get_pos());
+ mb->set_button_index(event.xbutton.button);
+ if (mb->get_button_index() == 2)
+ mb->set_button_index(3);
+ else if (mb->get_button_index() == 3)
+ mb->set_button_index(2);
+
+ mb->set_pressed((event.type == ButtonPress));
if (event.type == ButtonPress && event.xbutton.button == 1) {
@@ -1357,7 +1350,7 @@ void OS_X11::process_xevents() {
last_click_ms = 0;
last_click_pos = Point2(-100, -100);
- mouse_event.mouse_button.doubleclick = true;
+ mb->set_doubleclick(true);
} else {
last_click_ms += diff;
@@ -1365,7 +1358,7 @@ void OS_X11::process_xevents() {
}
}
- input->parse_input_event(mouse_event);
+ input->parse_input_event(mb);
} break;
case MotionNotify: {
@@ -1443,22 +1436,16 @@ void OS_X11::process_xevents() {
Point2i rel = pos - last_mouse_pos;
- InputEvent motion_event;
- motion_event.type = InputEvent::MOUSE_MOTION;
- motion_event.device = 0;
+ Ref<InputEventMouseMotion> mm;
+ mm.instance();
- motion_event.mouse_motion.mod = get_key_modifier_state(event.xmotion.state);
- motion_event.mouse_motion.button_mask = get_mouse_button_state(event.xmotion.state);
- motion_event.mouse_motion.x = pos.x;
- motion_event.mouse_motion.y = pos.y;
+ get_key_modifier_state(event.xmotion.state, mm);
+ mm->set_button_mask(get_mouse_button_state(event.xmotion.state));
+ mm->set_pos(pos);
+ mm->set_global_pos(pos);
input->set_mouse_position(pos);
- motion_event.mouse_motion.global_x = pos.x;
- motion_event.mouse_motion.global_y = pos.y;
- motion_event.mouse_motion.speed_x = input->get_last_mouse_speed().x;
- motion_event.mouse_motion.speed_y = input->get_last_mouse_speed().y;
-
- motion_event.mouse_motion.relative_x = rel.x;
- motion_event.mouse_motion.relative_y = rel.y;
+ mm->set_speed(input->get_last_mouse_speed());
+ mm->set_relative(rel);
last_mouse_pos = pos;
@@ -1467,7 +1454,7 @@ void OS_X11::process_xevents() {
// this is so that the relative motion doesn't get messed up
// after we regain focus.
if (window_has_focus || !mouse_mode_grab)
- input->parse_input_event(motion_event);
+ input->parse_input_event(mm);
} break;
case KeyPress:
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 7f01f9c617..d62186e5bd 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -121,7 +121,7 @@ class OS_X11 : public OS_Unix {
PhysicsServer *physics_server;
unsigned int get_mouse_button_state(unsigned int p_x11_state);
- InputModifierState get_key_modifier_state(unsigned int p_x11_state);
+ void get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state);
Physics2DServer *physics_2d_server;
MouseMode mouse_mode;