We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 65

Summary: SDL_ListModes on winCE
Product: SDL Reporter: Sam Lantinga <slouken>
Component: videoAssignee: Dmitry Yakimov <support>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: support
Version: 1.2.8   
Hardware: x86   
OS: Windows (CE)/PocketPC   
Attachments: diff + updated project files
Diff + project files
forgotten SDL_config_wince.h

Description Sam Lantinga 2006-01-22 03:35:33 UTC
Date: Mon, 21 Nov 2005 12:24:12 -0800
From: Peter Hanely <cal@splitreflection.com>
Subject: [SDL] SDL_ListModes on winCE

As of the latest SDL source I've looked at (1.2.8), SDL_ListModes
returns -1 on winCE, implying any resolution is valid.  Would it not
make more sense to return a mode for the current desktop window size?
Code along the lines of:
   resx = GetDeviceCaps(GetDC(NULL), HORZRES);
   resy = GetDeviceCaps(GetDC(NULL), VERTRES);
should retrieve the info according to research.  (test and verify pending)

Also, when running in windowed mode it may be desired to know the max
window size that'll fit.
Comment 1 Sam Lantinga 2006-01-22 03:36:44 UTC
This is actually a valid comment for any platform.  There should probably be some way of querying the desktop resolution (on platforms that have a desktop)
Comment 2 Sam Lantinga 2006-01-22 03:38:27 UTC
> As of the latest SDL source I've looked at (1.2.8), SDL_ListModes
> returns -1 on winCE, implying any resolution is valid.  Would it not
> make more sense to return a mode for the current desktop window size?

I don't really know how the WinCE port works, is it always fullscreen?  If so, then your fix seems reasonable.  If there are "windows", then this is consistent with the rest of the drivers (-1 for windowed mode, list for fullscreen mode)
Comment 3 Ryan C. Gordon 2006-01-22 03:43:24 UTC
Dmitry's new GAPI driver for PocketPC from Bug #47 implements SDL_ListModes correctly for this platform, and is now in CVS, which should get you what you need.

--ryan.



*** This bug has been marked as a duplicate of 47 ***
Comment 4 Dmitry Yakimov 2006-01-23 01:09:17 UTC
WinCE GAPI patch correctly implements SDL_ListModes for GAPI that is always fullscreen. WinDib driver supports Win32 and WinCE at the same time, so DIB_ListModes recognize SDL_FULLSCREEN OK but I found that for WinCE WinDib is compiled with #define NO_CHANGEDISPLAYSETTINGS so it returns -1 all the time. (In fact WinCE apps could be non fullscreen). So I will fix WinDib SDL driver. Thank you Peter.

--Dmitry
Comment 5 Ryan C. Gordon 2006-01-27 11:23:20 UTC
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

Comment 6 Dmitry Yakimov 2006-03-02 15:04:42 UTC
Fixed!
As well new patch contains:
- SDL_config_wince.h for WinCE optimal settings.
- updated evc3/4, VS 2005 projects of SDL.
- added LoopWave example (please update loopwave.c too to be compiled on wce)
- new SDL build manner updated for wince.

-- Dmitry
Comment 7 Dmitry Yakimov 2006-03-02 15:05:54 UTC
Created attachment 74 [details]
diff + updated project files
Comment 8 Sam Lantinga 2006-03-02 23:57:01 UTC
(In reply to comment #7)
> Created an attachment (id=74) [edit]
> diff + updated project files

I committed a version of loopwave.c updated with generic versions of your changes, thanks!

I'm looking at the diff now, and it seems like sometimes you use a (new?) symbol __WINCE__ and sometimes you use the normal _WIN32_WCE symbol.  I don't see where __WINCE__ was defined.  I was simply treating Windows CE as __WIN32__ with a specialization as _WIN32_WCE where necessary.


In SDL_getenv.c, you use _WINCE__ instead of __WINCE__ at one point.

In SDL_systhread.h, you added __WINCE__ to the __WIN32__ || __OS2__ check.  Is __WIN32__ not defined in your setup?

You've reverted some changes in SDL_gapivideo.c and SDL_gapivideo.h, it appears accidentally.  It should have the new copyright notice and should use relative include paths.

I don't understand the patch in SDL_wingl.c at all:
@@ -96,7 +96,7 @@
                where = SDL_strstr(start, extension);
                if (!where) break;

-               terminator = where + SDL_strlen(extension);
+               terminator = where + (extension);
Is that really correct?

Instead of platform #ifdef'ing GetWindowLong, I was going to do this:
#ifndef GetWindowLongPtr
#define GetWindowLongPtr GetWindowLong
#endif
... etc. somewhere convenient - maybe in the SDL_config_*.h

Comment 9 Sam Lantinga 2006-03-02 23:57:41 UTC
Could you take a look at these and submit an updated patch?

Thanks!
--Sam
Comment 10 Dmitry Yakimov 2006-03-03 08:13:02 UTC
__WINCE__ is defined in SDL_platform.h (in diff).

> I was simply treating Windows CE as __WIN32__ with a specialization as _WIN32_WCE where necessary.

It seems to be correct. But it is better to make different config file for wince, just because there are many small differences.
May be it is better to add SDL_config_wince.h but not to add __WINCE__


> In SDL_getenv.c, you use _WINCE__ instead of __WINCE__ at one point.

oops, mistyped :)

> -               terminator = where + SDL_strlen(extension);
> +               terminator = where + (extension);

I did not add that line, do not know where it comes from.
May be just was quick selected and deleted, SDL_strlen(extension) seem to be correct version, of course.

I will review it. Thanks for your comments!
Comment 11 Dmitry Yakimov 2006-03-03 09:15:16 UTC
Created attachment 75 [details]
Diff + project files

Done! All the issues you noticed had been cleaned up.
Please review.
Comment 12 Dmitry Yakimov 2006-03-03 09:20:31 UTC
About loopwave.c - do you plan to sumbit wince specific additions?

-- Dmitry
Comment 13 Dmitry Yakimov 2006-03-03 09:49:22 UTC
Created attachment 76 [details]
forgotten SDL_config_wince.h

Added forgotten in the latest patch SDL_config_wince.h
Comment 14 Sam Lantinga 2006-03-04 03:26:36 UTC
Dmitry's patch is now in CVS!

Dmitry, I tweaked it a bit, so can you grab CVS to make sure everything works?
I built under eVC++ 3 and 4, and it seems fine here.
I did just use SDL_config_win32.h, since it seems to work well.  Feel free to send me WinCE specific tweaks though.
Comment 15 Dmitry Yakimov 2006-03-04 04:09:13 UTC
It is much better to disable using SDL implementations of string.c because WinCE platform contains memcpy, memset and other functions embedded in coredll.dll that are _much_ (several timer) faster even that DWORD copying (of course faster that single char SDL copying routine). These routines use ARM assembler tricks.

I'm to note that WinCE is an embedded platform without hdd and swap file, so its memory manager is optimized for such scenario and SDL internal malloc just won't do.

So it is highly desirable to use:

#define HAVE_MALLOC	1
#define HAVE_CALLOC	1
#define HAVE_REALLOC	1
#define HAVE_FREE	1
#define HAVE_ALLOCA	1
#define HAVE_MEMSET	1
#define HAVE_MEMCPY	1
#define HAVE_MEMMOVE	1
#define HAVE_MEMCMP	1
#define HAVE_STRLEN	1

in config file.

Did you check loopwave subproject? Current CVS version can't be compiled for wince because missed wince specific changes.

-- Dmitry