summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/detect.py6
-rw-r--r--platform/android/java/res/drawable/icon.pngbin12574 -> 12525 bytes
-rw-r--r--platform/iphone/rasterizer_iphone.cpp26
-rw-r--r--platform/osx/dir_access_osx.mm4
-rw-r--r--platform/osx/os_osx.h19
-rw-r--r--platform/osx/os_osx.mm185
-rw-r--r--platform/windows/context_gl_win.cpp17
-rw-r--r--platform/windows/context_gl_win.h8
-rw-r--r--platform/windows/detect.py2
-rw-r--r--platform/windows/godot.icobin370070 -> 370070 bytes
-rw-r--r--platform/windows/os_windows.cpp107
-rw-r--r--platform/windows/os_windows.h3
-rw-r--r--platform/x11/context_gl_x11.cpp38
-rw-r--r--platform/x11/context_gl_x11.h4
-rw-r--r--platform/x11/os_x11.cpp14
-rw-r--r--platform/x11/os_x11.h3
16 files changed, 360 insertions, 76 deletions
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 11b14eb989..ba6b73a89f 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -168,11 +168,11 @@ def configure(env):
env['neon_enabled']=False
if env['android_arch']=='x86':
- env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__GLIBC__ -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__GLIBC__ -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
elif env["android_arch"]=="armv6":
- env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_6__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_6__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
elif env["android_arch"]=="armv7":
- env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -D__GLIBC__ -Wno-psabi -march=armv7-a -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -D__GLIBC__ -Wno-psabi -march=armv7-a -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
if env['android_neon']=='yes':
env['neon_enabled']=True
env.Append(CCFLAGS=['-mfpu=neon','-D__ARM_NEON__'])
diff --git a/platform/android/java/res/drawable/icon.png b/platform/android/java/res/drawable/icon.png
index 013632ddf1..e334f5fa78 100644
--- a/platform/android/java/res/drawable/icon.png
+++ b/platform/android/java/res/drawable/icon.png
Binary files differ
diff --git a/platform/iphone/rasterizer_iphone.cpp b/platform/iphone/rasterizer_iphone.cpp
index f06f12547f..99e83343d0 100644
--- a/platform/iphone/rasterizer_iphone.cpp
+++ b/platform/iphone/rasterizer_iphone.cpp
@@ -2446,7 +2446,7 @@ void RasterizerIPhone::canvas_draw_rect(const Rect2& p_rect, bool p_region, cons
}
-void RasterizerIPhone::canvas_draw_style_box(const Rect2& p_rect, RID p_texture,const float *p_margin, bool p_draw_center) {
+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);
@@ -2458,52 +2458,56 @@ void RasterizerIPhone::canvas_draw_style_box(const Rect2& p_rect, RID p_texture,
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( Point2(), 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(texture->width-p_margin[MARGIN_RIGHT],0), 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(0,texture->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(texture->width-p_margin[MARGIN_RIGHT],texture->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( p_margin[MARGIN_LEFT], p_margin[MARGIN_TOP]), Size2( texture->width - p_margin[MARGIN_LEFT] - p_margin[MARGIN_RIGHT], texture->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(p_margin[MARGIN_LEFT],0), Size2(src_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(p_margin[MARGIN_LEFT],src_center.pos.y+src_center.size.height), Size2(src_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(0,p_margin[MARGIN_TOP]), Size2(p_margin[MARGIN_LEFT],src_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,p_margin[MARGIN_TOP]), Size2(p_margin[MARGIN_RIGHT],src_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) {
diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm
index 20dc1df8f4..d123c5c648 100644
--- a/platform/osx/dir_access_osx.mm
+++ b/platform/osx/dir_access_osx.mm
@@ -319,10 +319,10 @@ size_t DirAccessOSX::get_space_left() {
struct statvfs vfs;
if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
- return -1;
+ return 0;
};
- return vfs.f_bfree * vfs.f_bsize;
+ return (size_t) (vfs.f_bavail * vfs.f_bsize);
#else
#warning THIS IS BROKEN
return 0;
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index d88dd89002..8d64686335 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -59,7 +59,7 @@ public:
bool force_quit;
Rasterizer *rasterizer;
VisualServer *visual_server;
- VideoMode current_videomode;
+
List<String> args;
MainLoop *main_loop;
unsigned int event_id;
@@ -104,9 +104,22 @@ public:
bool minimized;
bool maximized;
bool zoomed;
+
Vector<Rect2> screens;
+ Vector<int> screen_dpi;
+
+ Size2 window_size;
int current_screen;
Rect2 restore_rect;
+
+ float _mouse_scale(float p_scale) {
+ if (display_scale>1.0)
+ return p_scale;
+ else
+ return 1.0;
+ }
+
+ float display_scale;
protected:
virtual int get_video_driver_count() const;
@@ -173,6 +186,9 @@ public:
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
virtual Point2 get_screen_position(int p_screen=0) const;
+ virtual Size2 get_screen_size(int p_screen=0) const;
+ virtual int get_screen_dpi(int p_screen=0) const;
+
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2& p_position);
virtual void set_window_size(const Size2 p_size);
@@ -184,7 +200,6 @@ public:
virtual bool is_window_minimized() const;
virtual void set_window_maximized(bool p_enabled);
virtual bool is_window_maximized() const;
- Size2 get_screen_size(int p_screen=0) const;
void run();
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index c443fc2d0e..b5503fcd73 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -139,12 +139,10 @@ static int button_mask=0;
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
-/* _Godotwindow* window;
+ if (OS_OSX::singleton->get_main_loop())
+ OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
- for (window = _Godot.windowListHead; window; window = window->next)
- _GodotInputWindowCloseRequest(window);
-*/
- return NSTerminateCancel;
+ return NSTerminateCancel;
}
- (void)applicationDidHide:(NSNotification *)notification
@@ -202,10 +200,10 @@ static int button_mask=0;
[OS_OSX::singleton->context update];
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSRect fbRect = convertRectToBacking(contentRect);
+ const NSRect fbRect = contentRect;//convertRectToBacking(contentRect);
- OS_OSX::singleton->current_videomode.width=fbRect.size.width;
- OS_OSX::singleton->current_videomode.height=fbRect.size.height;
+ OS_OSX::singleton->window_size.width=fbRect.size.width*OS_OSX::singleton->display_scale;
+ OS_OSX::singleton->window_size.height=fbRect.size.height*OS_OSX::singleton->display_scale;
// _GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
@@ -291,16 +289,52 @@ static int button_mask=0;
self = [super init];
trackingArea = nil;
[self updateTrackingAreas];
-
+ [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
return self;
}
+
-(void)dealloc
{
[trackingArea release];
[super dealloc];
}
+- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender {
+ return NSDragOperationCopy;
+}
+
+- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender {
+ return NSDragOperationCopy;
+}
+
+- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
+
+
+ NSPasteboard *pboard = [sender draggingPasteboard];
+ NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
+
+ Vector<String> files;
+ for(int i=0;i<filenames.count;i++) {
+ NSString *ns = [filenames objectAtIndex:i];
+ char *utfs = strdup([ns UTF8String]);
+ String ret;
+ ret.parse_utf8(utfs);
+ free(utfs);
+ files.push_back(ret);
+
+
+ }
+
+ if (files.size()) {
+ OS_OSX::singleton->main_loop->drop_files(files,0);
+ OS_OSX::singleton->move_window_to_foreground();
+ }
+
+ return NO;
+}
+
+
- (BOOL)isOpaque
{
return YES;
@@ -324,7 +358,7 @@ static int button_mask=0;
- (void)mouseDown:(NSEvent *)event
{
- print_line("mouse down:");
+ //print_line("mouse down:");
button_mask|=BUTTON_MASK_LEFT;
InputEvent ev;
ev.type=InputEvent::MOUSE_BUTTON;
@@ -383,14 +417,14 @@ static int button_mask=0;
prev_mouse_y=mouse_y;
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
const NSPoint p = [event locationInWindow];
- mouse_x = p.x * [[event window] backingScaleFactor];
- mouse_y = (contentRect.size.height - p.y) * [[event window] backingScaleFactor];
+ mouse_x = p.x * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
+ mouse_y = (contentRect.size.height - p.y) * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
ev.mouse_motion.x=mouse_x;
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] * [[event window] backingScaleFactor];
- ev.mouse_motion.relative_y=[event deltaY] * [[event window] backingScaleFactor];
+ 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.mouse_motion.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->input->set_mouse_pos(Point2(mouse_x,mouse_y));
@@ -736,20 +770,48 @@ static int translateKey(unsigned int key)
- (void)flagsChanged:(NSEvent *)event
{
- /* int action;
- unsigned int newModifierFlags =
- [event modifierFlags] & NSDeviceIndependentModifierFlagsMask;
+ InputEvent ev;
+ int key = [event keyCode];
+ int mod = [event modifierFlags];
- if (newModifierFlags > window->ns.modifierFlags)
- action = GLFW_PRESS;
- else
- action = GLFW_RELEASE;
+ ev.type=InputEvent::KEY;
- window->ns.modifierFlags = newModifierFlags;
+ if (key == 0x36 || key == 0x37) {
+ if (mod & NSCommandKeyMask) {
+ mod&= ~NSCommandKeyMask;
+ ev.key.pressed = true;
+ } else {
+ ev.key.pressed = false;
+ }
+ } else if (key == 0x38 || key == 0x3c) {
+ if (mod & NSShiftKeyMask) {
+ mod&= ~NSShiftKeyMask;
+ ev.key.pressed = true;
+ } else {
+ ev.key.pressed = false;
+ }
+ } else if (key == 0x3a || key == 0x3d) {
+ if (mod & NSAlternateKeyMask) {
+ mod&= ~NSAlternateKeyMask;
+ ev.key.pressed = true;
+ } else {
+ ev.key.pressed = false;
+ }
+ } else if (key == 0x3b || key == 0x3e) {
+ if (mod & NSControlKeyMask) {
+ mod&= ~NSControlKeyMask;
+ ev.key.pressed = true;
+ } else {
+ ev.key.pressed = false;
+ }
+ } else {
+ return;
+ }
- const int key = translateKey([event keyCode]);
- const int mods = translateFlags([event modifierFlags]);
- _glfwInputKey(window, key, [event keyCode], action, mods);*/
+ ev.key.mod=translateFlags(mod);
+ ev.key.scancode = latin_keyboard_keycode_convert(translateKey(key));
+
+ OS_OSX::singleton->push_input(ev);
}
- (void)keyUp:(NSEvent *)event
@@ -833,6 +895,7 @@ static int translateKey(unsigned int key)
@implementation GodotWindow
+
- (BOOL)canBecomeKeyWindow
{
// Required for NSBorderlessWindowMask windows
@@ -893,6 +956,15 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
kTISNotifySelectedKeyboardInputSourceChanged, NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
+ if (is_hidpi_allowed() && [[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) {
+ for (NSScreen *screen in [NSScreen screens]) {
+ float s = [screen backingScaleFactor];
+ if (s > display_scale) {
+ display_scale=s;
+ }
+ }
+ }
+
window_delegate = [[GodotWindowDelegate alloc] init];
// Don't use accumulation buffer support; it's not accelerated
@@ -902,7 +974,7 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
window_object = [[GodotWindow alloc]
- initWithContentRect:NSMakeRect(0, 0, p_desired.width, p_desired.height)
+ initWithContentRect:NSMakeRect(0, 0, p_desired.width/display_scale, p_desired.height/display_scale)
styleMask:styleMask
backing:NSBackingStoreBuffered
defer:NO];
@@ -911,15 +983,11 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
window_view = [[GodotContentView alloc] init];
- current_videomode = p_desired;
-
- // Adjust for display density
- const NSRect fbRect = convertRectToBacking(NSMakeRect(0, 0, p_desired.width, p_desired.height));
- current_videomode.width = fbRect.size.width;
- current_videomode.height = fbRect.size.height;
+ window_size.width = p_desired.width;
+ window_size.height = p_desired.height;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && display_scale>1) {
[window_view setWantsBestResolutionOpenGLSurface:YES];
//if (current_videomode.resizable)
[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
@@ -1062,9 +1130,28 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
printf("nscreen count %i\n", (int)[screenArray count]);
for (int i=0; i<[screenArray count]; i++) {
+ float displayScale = 1.0;
+
+ if (display_scale>1.0 && [[screenArray objectAtIndex: i] respondsToSelector:@selector(backingScaleFactor)]) {
+ displayScale = [[screenArray objectAtIndex: i] backingScaleFactor];
+ }
+
NSRect nsrect = [[screenArray objectAtIndex: i] visibleFrame];
- screens.push_back(Rect2(nsrect.origin.x, nsrect.origin.y, nsrect.size.width, nsrect.size.height));
- printf("added screen %i\n", screens.size());
+ Rect2 rect = Rect2(nsrect.origin.x, nsrect.origin.y, nsrect.size.width, nsrect.size.height);
+ rect.pos*=displayScale;
+ rect.size*=displayScale;
+ screens.push_back(rect);
+
+ NSDictionary *description = [[screenArray objectAtIndex: i] deviceDescription];
+ NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
+ CGSize displayPhysicalSize = CGDisplayScreenSize(
+ [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
+
+ //printf("width: %i pwidth %i rect width %i\n",int(displayPixelSize.width*displayScale),int(displayPhysicalSize.width*displayScale),int(nsrect.size.width));
+ int dpi = (displayPixelSize.width * 25.4f / displayPhysicalSize.width)*displayScale;
+
+ screen_dpi.push_back(dpi);
+
};
restore_rect = Rect2(get_window_position(), get_window_size());
}
@@ -1326,7 +1413,11 @@ void OS_OSX::set_video_mode(const VideoMode& p_video_mode,int p_screen) {
OS::VideoMode OS_OSX::get_video_mode(int p_screen) const {
- return current_videomode;
+ VideoMode vm;
+ vm.width=window_size.width;
+ vm.height=window_size.height;
+
+ return vm;
}
void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
@@ -1354,6 +1445,12 @@ Point2 OS_OSX::get_screen_position(int p_screen) const {
return screens[p_screen].pos;
};
+int OS_OSX::get_screen_dpi(int p_screen) const {
+
+ ERR_FAIL_INDEX_V(p_screen, screens.size(), 72);
+ return screen_dpi[p_screen];
+}
+
Size2 OS_OSX::get_screen_size(int p_screen) const {
ERR_FAIL_INDEX_V(p_screen, screens.size(), Point2());
@@ -1362,24 +1459,30 @@ Size2 OS_OSX::get_screen_size(int p_screen) const {
Point2 OS_OSX::get_window_position() const {
- return Size2([window_object frame].origin.x, [window_object frame].origin.y);
+ Size2 wp([window_object frame].origin.x, [window_object frame].origin.y);
+ wp*=display_scale;
+ return wp;
};
void OS_OSX::set_window_position(const Point2& p_position) {
- [window_object setFrame:NSMakeRect(p_position.x, p_position.y, [window_object frame].size.width, [window_object frame].size.height) display:YES];
+ Point2 size=p_position;
+ size/=display_scale;
+ [window_object setFrame:NSMakeRect(size.x, size.y, [window_object frame].size.width, [window_object frame].size.height) display:YES];
};
Size2 OS_OSX::get_window_size() const {
- return Size2([window_object frame].size.width, [window_object frame].size.height);
+ return window_size;
+
};
void OS_OSX::set_window_size(const Size2 p_size) {
+ Size2 size=p_size;
NSRect frame = [window_object frame];
- [window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, p_size.x, p_size.y) display:YES];
+ [window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES];
};
void OS_OSX::set_window_fullscreen(bool p_enabled) {
@@ -1690,5 +1793,7 @@ OS_OSX::OS_OSX() {
maximized = false;
minimized = false;
+ window_size=Vector2(1024,600);
zoomed = false;
+ display_scale=1.0;
}
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp
index ab66b81421..fd9e895370 100644
--- a/platform/windows/context_gl_win.cpp
+++ b/platform/windows/context_gl_win.cpp
@@ -96,6 +96,20 @@ static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) {
}
*/
+void ContextGL_Win::set_use_vsync(bool p_use) {
+
+ if (wglSwapIntervalEXT) {
+ wglSwapIntervalEXT(p_use?1:0);
+ }
+ use_vsync=p_use;
+
+}
+
+bool ContextGL_Win::is_using_vsync() const {
+
+ return use_vsync;
+}
+
Error ContextGL_Win::initialize() {
@@ -184,7 +198,7 @@ Error ContextGL_Win::initialize() {
printf("Activated GL 3.1 context");
}
-
+ wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress ("wglSwapIntervalEXT");
// glWrapperInit(wrapper_get_proc_address);
return OK;
@@ -194,6 +208,7 @@ ContextGL_Win::ContextGL_Win(HWND hwnd,bool p_opengl_3_context) {
opengl_3_context=p_opengl_3_context;
hWnd=hwnd;
+ use_vsync=false;
}
ContextGL_Win::~ContextGL_Win() {
diff --git a/platform/windows/context_gl_win.h b/platform/windows/context_gl_win.h
index 055e0b2f51..e1ab6fb26a 100644
--- a/platform/windows/context_gl_win.h
+++ b/platform/windows/context_gl_win.h
@@ -49,6 +49,8 @@
#include <windows.h>
+typedef bool (APIENTRY *PFNWGLSWAPINTERVALEXTPROC) (int interval);
+
class ContextGL_Win : public ContextGL {
HDC hDC;
@@ -56,6 +58,10 @@ class ContextGL_Win : public ContextGL {
unsigned int pixel_format;
HWND hWnd;
bool opengl_3_context;
+ bool use_vsync;
+
+
+ PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
public:
@@ -69,6 +75,8 @@ public:
virtual Error initialize();
+ virtual void set_use_vsync(bool p_use);
+ virtual bool is_using_vsync() const;
ContextGL_Win(HWND hwnd,bool p_opengl_3_context);
~ContextGL_Win();
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 4edae9cceb..97d2461e58 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -243,7 +243,7 @@ def configure(env):
env.Append(CCFLAGS=['/DGLES2_ENABLED'])
env.Append(CCFLAGS=['/DGLEW_ENABLED'])
- LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shcore','Shlwapi', 'wsock32', 'shell32','advapi32','dinput8','dxguid']
+ LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shlwapi', 'wsock32', 'shell32','advapi32','dinput8','dxguid']
env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS])
env.Append(LIBPATH=[os.getenv("WindowsSdkDir")+"/Lib"])
diff --git a/platform/windows/godot.ico b/platform/windows/godot.ico
index e57ce36529..3e52f2e52f 100644
--- a/platform/windows/godot.ico
+++ b/platform/windows/godot.ico
Binary files differ
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 8bb5de5d5d..5e3dc438d0 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -57,13 +57,6 @@
#include <regstr.h>
#include <process.h>
-#if (_MSC_VER >= 1700)
-#define HIDPI_SUPPORT
-#endif
-
-#ifdef HIDPI_SUPPORT
-#include <ShellScalingAPI.h>
-#endif
static const WORD MAX_CONSOLE_LINES = 1500;
extern "C" {
@@ -781,6 +774,8 @@ LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
}
+
+
void OS_Windows::process_key_events() {
for(int i=0;i<key_event_pos;i++) {
@@ -800,7 +795,7 @@ void OS_Windows::process_key_events() {
k.mod=ke.mod_state;
k.pressed=true;
k.scancode=KeyMappingWindows::get_keysym(ke.wParam);
- k.unicode=ke.wParam;
+ k.unicode=ke.wParam;
if (k.unicode && gr_mem) {
k.mod.alt=false;
k.mod.control=false;
@@ -852,6 +847,75 @@ void OS_Windows::process_key_events() {
key_event_pos=0;
}
+enum _MonitorDpiType
+{
+ MDT_Effective_DPI = 0,
+ MDT_Angular_DPI = 1,
+ MDT_Raw_DPI = 2,
+ MDT_Default = MDT_Effective_DPI
+};
+
+
+static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType= MDT_Default)
+{
+
+
+ int dpiX = 96, dpiY = 96;
+
+ static HMODULE Shcore = NULL;
+ typedef HRESULT (WINAPI* GetDPIForMonitor_t)(HMONITOR hmonitor, _MonitorDpiType dpiType, UINT *dpiX, UINT *dpiY);
+ static GetDPIForMonitor_t getDPIForMonitor = NULL;
+
+ if (Shcore == NULL)
+ {
+ Shcore = LoadLibraryW(L"Shcore.dll");
+ getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : NULL;
+
+ if ((Shcore == NULL) || (getDPIForMonitor == NULL))
+ {
+ if (Shcore)
+ FreeLibrary(Shcore);
+ Shcore = (HMODULE)INVALID_HANDLE_VALUE;
+ }
+ }
+
+ UINT x = 0, y = 0;
+ HRESULT hr = E_FAIL;
+ bool bSet = false;
+ if (hmon && (Shcore != (HMODULE)INVALID_HANDLE_VALUE))
+ {
+ hr = getDPIForMonitor(hmon, dpiType/*MDT_Effective_DPI*/, &x, &y);
+ if (SUCCEEDED(hr) && (x > 0) && (y > 0))
+ {
+
+ dpiX = (int)x;
+ dpiY = (int)y;
+ }
+ }
+ else
+ {
+ static int overallX = 0, overallY = 0;
+ if (overallX <= 0 || overallY <= 0)
+ {
+ HDC hdc = GetDC(NULL);
+ if (hdc)
+ {
+ overallX = GetDeviceCaps(hdc, LOGPIXELSX);
+ overallY = GetDeviceCaps(hdc, LOGPIXELSY);
+ ReleaseDC(NULL, hdc);
+ }
+ }
+ if (overallX > 0 && overallY > 0)
+ {
+ dpiX = overallX; dpiY = overallY;
+ }
+ }
+
+
+ return (dpiX+dpiY)/2;
+}
+
+
BOOL CALLBACK OS_Windows::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
OS_Windows *self=(OS_Windows*)OS::get_singleton();
MonitorInfo minfo;
@@ -861,13 +925,9 @@ BOOL CALLBACK OS_Windows::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPR
minfo.rect.pos.y=lprcMonitor->top;
minfo.rect.size.x=lprcMonitor->right - lprcMonitor->left;
minfo.rect.size.y=lprcMonitor->bottom - lprcMonitor->top;
-#ifdef HIDPI_SUPPORT
- UINT dpix,dpiy;
- GetDpiForMonitor(hMonitor,MDT_EFFECTIVE_DPI,&dpix,&dpiy);
- minfo.dpi=(dpix + dpiy)/2;
-#else
- minfo.dpi=72;
-#endif
+
+ minfo.dpi = QueryDpiForMonitor(hMonitor);
+
self->monitor_info.push_back(minfo);
return TRUE;
@@ -2183,7 +2243,7 @@ String OS_Windows::get_system_dir(SystemDir p_dir) const {
}
String OS_Windows::get_data_dir() const {
- String an = Globals::get_singleton()->get("application/name");
+ String an = get_safe_application_name();
if (an!="") {
if (has_environment("APPDATA")) {
@@ -2209,6 +2269,21 @@ String OS_Windows::get_joy_guid(int p_device) const {
return input->get_joy_guid_remapped(p_device);
}
+void OS_Windows::set_use_vsync(bool p_enable) {
+
+ if (gl_context)
+ gl_context->set_use_vsync(p_enable);
+}
+
+bool OS_Windows::is_vsnc_enabled() const{
+
+ if (gl_context)
+ return gl_context->is_using_vsync();
+
+ return true;
+}
+
+
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
key_event_pos=0;
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 6dd5b78bfd..509d76abbf 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -283,6 +283,9 @@ public:
virtual bool is_joy_known(int p_device);
virtual String get_joy_guid(int p_device) const;
+ virtual void set_use_vsync(bool p_enable);
+ virtual bool is_vsnc_enabled() const;
+
OS_Windows(HINSTANCE _hInstance);
~OS_Windows();
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp
index 9f987e1376..cd325dfc99 100644
--- a/platform/x11/context_gl_x11.cpp
+++ b/platform/x11/context_gl_x11.cpp
@@ -34,7 +34,9 @@
#include <unistd.h>
#include <stdlib.h>
+#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h>
+#include <GL/glxext.h>
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
@@ -176,6 +178,41 @@ int ContextGL_X11::get_window_height() {
return xwa.height;
}
+void ContextGL_X11::set_use_vsync(bool p_use) {
+ static bool setup = false;
+ static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = NULL;
+ static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = NULL;
+ static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL;
+
+ if (!setup) {
+ setup = true;
+ String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
+ if (extensions.find("GLX_EXT_swap_control") != -1)
+ glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
+ if (extensions.find("GLX_MESA_swap_control") != -1)
+ glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalMESA");
+ if (extensions.find("GLX_SGI_swap_control") != -1)
+ glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalSGI");
+ }
+ int val = p_use ? 1:0;
+ if (glXSwapIntervalMESA) {
+ glXSwapIntervalMESA(val);
+ }
+ else if (glXSwapIntervalSGI) {
+ glXSwapIntervalSGI(val);
+ }
+ else if (glXSwapIntervalEXT) {
+ GLXDrawable drawable = glXGetCurrentDrawable();
+ glXSwapIntervalEXT(x11_display, drawable, val);
+ }
+ else return;
+ use_vsync = p_use;
+}
+bool ContextGL_X11::is_using_vsync() const {
+
+ return use_vsync;
+}
+
ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context) : x11_window(p_x11_window) {
@@ -189,6 +226,7 @@ ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,con
glx_minor=glx_major=0;
p = memnew( ContextGL_X11_Private );
p->glx_context=0;
+ use_vsync=false;
}
diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h
index c77fb3e333..4474542c0b 100644
--- a/platform/x11/context_gl_x11.h
+++ b/platform/x11/context_gl_x11.h
@@ -55,6 +55,7 @@ class ContextGL_X11 : public ContextGL {
bool direct_render;
int glx_minor,glx_major;
bool opengl_3_context;
+ bool use_vsync;
public:
virtual void release_current();
@@ -65,6 +66,9 @@ public:
virtual Error initialize();
+ virtual void set_use_vsync(bool p_use);
+ virtual bool is_using_vsync() const;
+
ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context);
~ContextGL_X11();
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 66723c0295..b089436a17 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1952,6 +1952,20 @@ String OS_X11::get_joy_guid(int p_device) const {
return input->get_joy_guid_remapped(p_device);
}
+void OS_X11::set_use_vsync(bool p_enable) {
+ if (context_gl)
+ return context_gl->set_use_vsync(p_enable);
+}
+
+bool OS_X11::is_vsnc_enabled() const {
+
+ if (context_gl)
+ return context_gl->is_using_vsync();
+
+ return true;
+}
+
+
void OS_X11::set_context(int p_context) {
XClassHint* classHint = NULL;
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 1369340b04..311f26d4d3 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -240,6 +240,9 @@ public:
virtual void set_context(int p_context);
+ virtual void set_use_vsync(bool p_enable);
+ virtual bool is_vsnc_enabled() const;
+
void run();
OS_X11();