The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Support Multiple Screen Resolution on Mobile
matdennoigi


Joined: 11 Jun 2015
Posts: 7
Hi, guys!

I'm an indie mobile game developer (Android and Windows Phone). My problem is I always work with many screen sizes (spec Android). I always choose a logical resolution (ex 1289x720) and work with it, then render it to real screen (ex 800x480) with some options: Stretch, Uniform, Uniform To Fill. After moved to SDL, I used Cocos2d-x and Wave Engine, they support all types of fill. When I tried SDL on Windows Phone 8 (my device is 1280x720), I tried to create a window with size is 800x480 and flag SDL_WINDOW_FULLSCREEN, but render area I was got always is 1280x720 (real device size). So, how can I create a render area with logical size as i want?
I has an idea : I will create a render target with size equal logical size, draw all things to it, then draw it to real screen with scale and translate. But, I worry about performance, because the game can be has many thing like: Background, bullet, particles... Is my idea possible??? How performance cost when use render target (ex GUI System)?

I'm so sorry if I post to wrong mail-list, but I can't post thread, reply or sen private message on 4r. My 4r acc can be blocked, I create it few hours ago.

Thanks alot!
Re: Support Multiple Screen Resolution on Mobile
DLudwig


Joined: 09 Feb 2012
Posts: 179
Many Windows Phone devices, or at least any that I've worked with, typically don't allow one to switch resolutions. Things are always stuck at the device's own resolution, and there's no apparent way for apps to change this resolution.

Rendering to an off-screen texture, then scaling that to the device's screen, is definitely possible though, and is a fairly common practice.

-- David L.
VỀ: Support Multiple Screen Resolution on Mobile
matdennoigi


Joined: 11 Jun 2015
Posts: 7
I mean not changing resolution of device. Most of game engine support a technical of abstract screen (with abstract resolution), some one call it is "Camera", some one call "Viewport". It ensure the game can compatible with many device (with different resolutions) and reduce work for developer. Of course the touch coordinate will be also transformed to abs screen's coord system

TÆ°Ì€: DLudwig
Gửi: ‎12/‎06/‎2015 2:48 SA
Đến:
Chủ đề: Re: [SDL] Support Multiple Screen Resolution on Mobile


Many Windows Phone devices, or at least any that I've worked with, typically don't allow one to switch resolutions. Things are always stuck at the device's own resolution, and there's no apparent way for apps to change this resolution.

Rendering to an off-screen texture, then scaling that to the device's screen, is definitely possible though, and is a fairly common practice.

-- David L.
Support Multiple Screen Resolution on Mobile
matdennoigi


Joined: 11 Jun 2015
Posts: 7
@DLudwig: I have used your SDL Branch on Bitbucket for Windows Phone (8.0) porting, it's very awsome. But, I found a bug: "In my SDL App, when I press Windows Button to navigate to Home Screen, then come back, the app will be crashed". Did you know this bug?

On Fri, Jun 12, 2015 at 2:47 AM, DLudwig wrote:
Quote:
Many Windows Phone devices, or at least any that I've worked with, typically don't allow one to switch resolutions. Things are always stuck at the device's own resolution, and there's no apparent way for apps to change this resolution.

Rendering to an off-screen texture, then scaling that to the device's screen, is definitely possible though, and is a fairly common practice.

-- David L.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Re: Support Multiple Screen Resolution on Mobile
DLudwig


Joined: 09 Feb 2012
Posts: 179
matdennoigi wrote:
@DLudwig: I have used your SDL Branch on Bitbucket for Windows Phone (8.0) porting, it's very awsome. But, I found a bug: "In my SDL App, when I press Windows Button to navigate to Home Screen, then come back, the app will be crashed". Did you know this bug?


Unfortunately, this isn't a bug, it's defined behavior in Windows Phone 8.0 apps. If the back button is pressed, and is left unhandled, Windows will presume that the app was at its first screen, and go back to the previous app, killing your app in the process.

Back button presses have to be dealt with immediately, as well. You can't (easily) get them working via SDL_PollEvent(), for example. There is a special hint, SDL_HINT_WINRT_HANDLE_BACK_BUTTON, which when set to "1", will mark these back-button events as handled. If it's set to anything else, it won't handle it. SDL will also emit SDL_KEYDOWN and SDL_KEYUP events, with a scancode of SDL_SCANCODE_AC_BACK, however the only way to process these in time is to set up an event-listening callback function via SDL_AddEventWatch. Once SDL for Windows Phone's internal back-button handler function returns control back to Windows, there won't be any further opportunity to mark the event as handled (due to limitations in Windows itself).


Also, as a side-note, unless you're trying out the still-experimental XAML features in my own Bitbucket branch, I'd recommend using a clone of hg.libsdl.org/SDL, rather than my own repo. For many things, it's considerably more stable than my own branch/repo.

Cheers!
-- David L.
Support Multiple Screen Resolution on Mobile
matdennoigi


Joined: 11 Jun 2015
Posts: 7
Thank for your reply, DLugwig!

I extremely need XAML feature, most of our services only run on C#: In-App Purchase, AdMob, Facebook, Game Service... Unfortunately, SDL has not yet supported XAML feature well. I most work on Windows Phone platform, but SDL not support XAML on it, even on your branch Sad . I have used SDL as a render framework for my own game engine, but it still is trial, because it lack XAML


On Sat, Jun 13, 2015 at 2:12 AM, DLudwig wrote:
Quote:



matdennoigi wrote:

@DLudwig: I have used your SDL Branch on Bitbucket for Windows Phone (8.0) porting, it's very awsome. But, I found a bug: "In my SDL App, when I press Windows Button to navigate to Home Screen, then come back, the app will be crashed". Did you know this bug?




Unfortunately, this isn't a bug, it's defined behavior in Windows Phone 8.0 apps. If the back button is pressed, and is left unhandled, Windows will presume that the app was at its first screen, and go back to the previous app, killing your app in the process.

Back button presses have to be dealt with immediately, as well. You can't (easily) get them working via SDL_PollEvent(), for example. There is a special hint, SDL_HINT_WINRT_HANDLE_BACK_BUTTON, which when set to "1", will mark these back-button events as handled. If it's set to anything else, it won't handle it. SDL will also emit SDL_KEYDOWN and SDL_KEYUP events, with a scancode of SDL_SCANCODE_AC_BACK, however the only way to process these in time is to set up an event-listening callback function via SDL_AddEventWatch. Once SDL for Windows Phone's internal back-button handler function returns control back to Windows, there won't be any further opportunity to mark the event as handled (due to limitations in Windows itself).


Also, as a side-note, unless you're trying out the still-experimental XAML features in my own Bitbucket branch, I'd recommend using a clone of hg.libsdl.org/SDL, rather than my own repo. For many things, it's considerably more stable than my own branch/repo.

Cheers!
-- David L.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Re: Support Multiple Screen Resolution on Mobile
DLudwig


Joined: 09 Feb 2012
Posts: 179
matdennoigi wrote:
I extremely need XAML feature, most of our services only run on C#: In-App Purchase, AdMob, Facebook, Game Service... Unfortunately, SDL has not yet supported XAML feature well. I most work on Windows Phone platform, but SDL not support XAML on it, even on your branch Sad . I have used SDL as a render framework for my own game engine, but it still is trial, because it lack XAML


Hi again,

My current Bitbucket branch does have newer, experimental code for XAML (than what's in hg.libsdl.org/SDL). You're welcome to try to use it, if you like, just note that it's likely somewhat buggy. Having someone use it and report bugs, though, would be a tremendous help. :-)

Do note that my XAML work has focused on WP 8.1's XAML API. WP 8.0 used a vastly different means of rendering content (than 8.1), one that appears to have been deprecated by MS, and which is substantially more difficult to work with. I have no plans on supporting WP 8.0 XAML.

If you'd like to try my still-experimental Windows [Phone] 8.1+ XAML support, you'll need to start with one of MSVC's XAML projects, create a 'SwapChainPanel' XAML control, cast it to an 'IInspectable *', then pass that to SDL_CreateWindowFrom(), which will create the SDL_Window. From there, you should be able to use either the SDL_Render API, or OpenGL ES 2.x content via ANGLE. If you have any questions about this, feel free to let me know.

-- David L.
Re: Support Multiple Screen Resolution on Mobile
DLudwig


Joined: 09 Feb 2012
Posts: 179
DLudwig wrote:
My current Bitbucket branch does have newer, experimental code for XAML (than what's in hg.libsdl.org/SDL). You're welcome to try to use it, if you like, just note that it's likely somewhat buggy. Having someone use it and report bugs, though, would be a tremendous help.


FYI, in theory, I just updated my Bitbucket repo such that the experimental XAML code is now:

1. in the "xaml" branch
2. updated to use the latest changes in SDL 2.0.4

The old branch should still work, in theory, but if you want to try the latest experimental XAML code, I'd recommend that you try updating to the newer, "xaml" branch (at https://bitbucket.org/DavidLudwig/sdl ). Do backup your old clone of the XAML repo though, as I can't guarantee that I didn't muck things up when working with Mercurial (in my own Bitbucket repo -- hg.libsdl.org should be fine :-) ).

Cheers,
-- David L.
VỀ: Support Multiple Screen Resolution on Mobile
matdennoigi


Joined: 11 Jun 2015
Posts: 7
Thanks, very much. I will try to use it

TÆ°Ì€: DLudwig
Gửi: ‎17/‎06/‎2015 9:32 SA
Đến:
Chủ đề: Re: [SDL] Support Multiple Screen Resolution on Mobile









DLudwig wrote: My current Bitbucket branch does have newer, experimental code for XAML (than what's in hg.libsdl.org/SDL). You're welcome to try to use it, if you like, just note that it's likely somewhat buggy. Having someone use it and report bugs, though, would be a tremendous help.


FYI, in theory, I just updated my Bitbucket repo such that the experimental XAML code is now:

1. in the "xaml" branch
2. updated to use the latest changes in SDL 2.0.4

The old branch should still work, in theory, but if you want to try the latest experimental XAML code, I'd recommend that you try updating to the newer, "xaml" branch (at https://bitbucket.org/DavidLudwig/sdl ). Do backup your old clone of the XAML repo though, as I can't guarantee that I didn't muck things up when working with Mercurial (in my own Bitbucket repo -- hg.libsdl.org should be fine ).

Cheers,
-- David L.
Support Multiple Screen Resolution on Mobile
matdennoigi


Joined: 11 Jun 2015
Posts: 7
​ TestSDLXaml.zip
​Hi again,


Today, I tried to create Xaml + SDL project on Windows Phone 8.1 follow:


Step 1: I create Windows Phone 8.1 C#/Xaml project (using Windows Runtime libary). On XAML code of Main Page, I create a SwapChainPanel (named "swapChainPanel").


Step 2: I create Windows Phone 8.1 Runtime Component project (also using WRT lib) called "GameStarter". Then, create a C++/CX class "DirectXAdapter" with method "Initialize" got SwapChainPanel^ as a parameter.


Step 3: I add SDL-WinPhone81 to solution and refrenece "GameStarter" proj to it, and init SDL in "Initalize" with casting SwapChainPanel to IInspectable. 


Step 4: I referenced main project to "GameStarter", create instance of DirectXAdapter then called Initialize with "swapChainPanel"


But, when I run it, SDL_Init was not worked (return a value != 0). Please, show me how I wrong?


My source code was attached on this mail!
Re: Support Multiple Screen Resolution on Mobile
DLudwig


Joined: 09 Feb 2012
Posts: 179
Can you try calling SDL_SetMainReady() at some point before calling SDL_Init(), and see if that makes a difference?

If that doesn't help, use SDL_GetError() to get details of the error (from SDL_Init()), then post that info back here.

Cheers,
-- David L.
Support Multiple Screen Resolution on Mobile
matdennoigi


Joined: 11 Jun 2015
Posts: 7
I tried call "SDL_SetMainReady()", past through "SDL_Init()" but failed at "SDL_CreateWindowFrom()" with error "That operation not supported".

On Sat, Jun 20, 2015 at 10:05 PM, DLudwig wrote:
Quote:
Can you try calling SDL_SetMainReady() at some point before calling SDL_Init(), and see if that makes a difference?

If that doesn't help, use SDL_GetError() to get details of the error (from SDL_Init()), then post that info back here.

Cheers,
-- David L.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org