annotate src/video/windows/SDL_gapirender.c @ 5092:327f181542f1

Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share. I think this also fixes the bug relating to non-latin characters in filenames, since UNICODE wasn't defined in SDL_rwops.c
author Sam Lantinga <slouken@libsdl.org>
date Mon, 24 Jan 2011 21:20:30 -0800
parents c2539ff054c8
children da10636e5eca
rev   line source
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1 /***************************************************************************
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
2 * Copyright (C) 2010 by Andrey Afletdinov <afletdinov@gmail.com> *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
3 * *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
4 * WinCE RAW/GAPI video driver *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
5 * *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
6 * Part of the SDL - (Simple DirectMedia Layer) *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
7 * http://www.libsdl.org *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
8 * *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
9 * This program is free software; you can redistribute it and/or modify *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
10 * it under the terms of the GNU General Public License as published by *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
12 * (at your option) any later version. *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
13 * *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
14 * This program is distributed in the hope that it will be useful, *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
17 * GNU General Public License for more details. *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
18 * *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
19 * You should have received a copy of the GNU General Public License *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
20 * along with this program; if not, write to the *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
21 * Free Software Foundation, Inc., *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
23 ***************************************************************************/
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #include "SDL_config.h"
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #if SDL_VIDEO_RENDER_GAPI
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 4929
diff changeset
29 #include "SDL_windowsvideo.h"
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 4929
diff changeset
30 #include "SDL_windowswindow.h"
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include "../SDL_yuv_sw_c.h"
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
33 // RawFrameBufferInfo
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
34 typedef struct
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
35 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
36 WORD wFormat;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
37 WORD wBPP;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
38 VOID *pFramePointer;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
39 int cxStride;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
40 int cyStride;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
41 int cxPixels;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
42 int cyPixels;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
43 } RawFrameBufferInfo;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
45 // GXDeviceInfo
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
46 typedef struct
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
47 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
48 long Version;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
49 void* pvFrameBuffer;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
50 unsigned long cbStride;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
51 unsigned long cxWidth;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
52 unsigned long cyHeight;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
53 unsigned long cBPP;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
54 unsigned long ffFormat;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
55 char unknown[0x84 - 7 * 4];
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
56 } GXDeviceInfo;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
58 // wince: GXDisplayProperties
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
59 struct GXDisplayProperties
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
60 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
61 DWORD cxWidth;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
62 DWORD cyHeight;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
63 long cbxPitch;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
64 long cbyPitch;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
65 long cBPP;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
66 DWORD ffFormat;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 };
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
69 // gx.dll
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
70 typedef int (*PFNGXOpenDisplay)(HWND hWnd, DWORD dwFlags);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
71 typedef int (*PFNGXCloseDisplay)();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
72 typedef void* (*PFNGXBeginDraw)();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
73 typedef int (*PFNGXEndDraw)();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
74 typedef struct GXDisplayProperties (*PFNGXGetDisplayProperties)();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
75 typedef int (*PFNGXSuspend)();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
76 typedef int (*PFNGXResume)();
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
78 typedef struct
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
79 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
80 // gx.dll
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
81 void* hGapiLib;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
82 PFNGXOpenDisplay GXOpenDisplay;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
83 PFNGXCloseDisplay GXCloseDisplay;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
84 PFNGXBeginDraw GXBeginDraw;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
85 PFNGXEndDraw GXEndDraw;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
86 PFNGXGetDisplayProperties GXGetDisplayProperties;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
87 PFNGXSuspend GXSuspend;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
88 PFNGXResume GXResume;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
89 } GapiInfo;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
90
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
91 //#ifndef DM_DISPLAYORIENTATION
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
92 //#define DM_DISPLAYORIENTATION 0x00800000L
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
93 //#endif
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
94
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
95 #define FORMAT_565 1
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
96 #define FORMAT_555 2
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
97 #define FORMAT_OTHER 3
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
98
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
99 #define GETRAWFRAMEBUFFER 0x00020001
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
100 #define GETGXINFO 0x00020000
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
101
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
102 #define kfPalette 0x10
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
103 #define kfDirect 0x20
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
104 #define kfDirect555 0x40
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
105 #define kfDirect565 0x80
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
107 #define GX_FULLSCREEN 0x01
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
108
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
109 enum ScreenOrientation { ORIENTATION_UNKNOWN = -1, ORIENTATION_UP = DMDO_0, ORIENTATION_DOWN = DMDO_180, ORIENTATION_LEFT = DMDO_270, ORIENTATION_RIGHT = DMDO_90 };
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
110 enum ScreenGeometry { GEOMETRY_UNKNOWN, GEOMETRY_PORTRAIT, GEOMETRY_LANDSCAPE, GEOMETRY_SQUARE };
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
111 enum FrameBufferFlags { FB_SKIP_OFFSET = 0x0001, FB_RAW_MODE = 0x0002, FB_SUSPENDED = 0x0004 };
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
112
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
113 // private framebuffer info
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
114 typedef struct
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
115 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
116 int width;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
117 int height;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
118 int xpitch;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
119 int ypitch;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
120 int offset;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
121 } FrameBufferInfo;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
123 // private display data
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
124 typedef struct
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
125 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
126 unsigned char* pixels; // video memory
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
127 int format; // video format
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
128 FrameBufferInfo fb; // framebuffer geometry
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
129 GapiInfo* gapi; // GAPI module
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
130 int userOrientation;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
131 int systemOrientation;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
132 int hardwareGeometry;
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
133 int flags; // fb flags
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
134 float scale; // scale pointer position
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
135 int debug;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
137 } WINCE_RenderData;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
138
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
139 typedef struct
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
140 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
141 SDL_SW_YUVTexture *yuv;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
142 Uint32 format;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
143 void *pixels;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
144 int pitch;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
145
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
146 } WINCE_TextureData;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
149 // system func
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
150 SDL_Renderer* WINCE_CreateRenderer(SDL_Window* window, Uint32 flags);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
151 void WINCE_DestroyRenderer(SDL_Renderer* renderer);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
152
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
153 int WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
154 void WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
155 int WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
156 int WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
157 int WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
158 void WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
159
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
160 int WINCE_Available(void);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
161 void WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
162
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
163 int WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
164 void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
165
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
166 void WINCE_RenderPresent(SDL_Renderer* renderer);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
167 int WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
168 int WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
169 int WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
170 int WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
171
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
172 void WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
173 void WINCE_DumpVideoInfo(WINCE_RenderData* data);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
174 void WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
175 void WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
176 void WINCE_SquareTransform(WINCE_RenderData* data, int width, int height);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
177 int WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
178 int WINCE_GetDMOrientation(void);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
179 int WINCE_SetDMOrientation(int orientation);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
180 void WINCE_UpdateYUVTextureData(SDL_Texture* texture);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
181
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
182 // gapi engine specific
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
183 int GAPI_Init(WINCE_RenderData* data, HWND hwnd);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
184 void GAPI_Quit(WINCE_RenderData* data);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
185
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
186 // raw engine specific
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
187 int RAW_Init(WINCE_RenderData* data);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
188 void RAW_Quit(WINCE_RenderData* data);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
189
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
190 // tools
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
191 void FrameBufferRotate(FrameBufferInfo* src, int orientation);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
192 int GetFrameBufferOrientation(const FrameBufferInfo* src);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
193 void PointerRotate(POINT* pt, const FrameBufferInfo* fb, int orientation);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
194 void FrameBufferInitialize(FrameBufferInfo* fb);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
195 void FrameBufferDumpInfo(const FrameBufferInfo* fb, const char*);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
196 const char* GetOrientationName(int orientation);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
197 void UpdateLine16to16(const FrameBufferInfo* fb, const Uint16* src, Uint16* dst, Uint16 width);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
198
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
199 // stdlib
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
200 static __inline__ int __abs(int x){ return x < 0 ? -x : x; };
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
201 static __inline__ void __swap(int* a, int* b){ int t = *a; *a = *b; *b = t; };
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
203 #define GAPI_RENDER_NAME "gapi"
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
204 #define RAW_RENDER_NAME "raw"
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
205 //
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
206 SDL_RenderDriver GAPI_RenderDriver = {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
207 WINCE_CreateRenderer,
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
208 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
209 GAPI_RENDER_NAME,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
210 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
211 (SDL_TEXTUREMODULATE_NONE),
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
212 (SDL_BLENDMODE_NONE),
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
213 (SDL_SCALEMODE_NONE),
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
214 7,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
215 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
216 SDL_PIXELFORMAT_RGB555,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
217 SDL_PIXELFORMAT_RGB565,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
218 SDL_PIXELFORMAT_YV12,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
219 SDL_PIXELFORMAT_IYUV,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
220 SDL_PIXELFORMAT_YUY2,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
221 SDL_PIXELFORMAT_UYVY,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
222 SDL_PIXELFORMAT_YVYU
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
223 },
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
224 0,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
225 0
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
227 };
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
228
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
229 SDL_RenderDriver RAW_RenderDriver = {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
230 WINCE_CreateRenderer,
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
231 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
232 RAW_RENDER_NAME,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
233 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
234 (SDL_TEXTUREMODULATE_NONE),
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
235 (SDL_BLENDMODE_NONE),
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
236 (SDL_SCALEMODE_NONE),
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
237 7,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
238 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
239 SDL_PIXELFORMAT_RGB555,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
240 SDL_PIXELFORMAT_RGB565,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
241 SDL_PIXELFORMAT_YV12,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
242 SDL_PIXELFORMAT_IYUV,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
243 SDL_PIXELFORMAT_YUY2,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
244 SDL_PIXELFORMAT_UYVY,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
245 SDL_PIXELFORMAT_YVYU
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
246 },
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
247 0,
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
248 0
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
249 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
250 };
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
251
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
252 int WINCE_Available(void)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
253 {
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
254 void* render_gapi;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
255 const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
256
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
257 // raw check
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
258 RawFrameBufferInfo rfbi = { 0 };
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
259 HDC hdc = GetDC(NULL);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
260 int render_raw = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
261 ReleaseDC(NULL, hdc);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
262
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
263 if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 &&
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
264 rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
265 render_raw = 1;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
266
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
267 if(preferably && 0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0 != render_raw;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
268
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
269 // gapi check
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
270 render_gapi = SDL_LoadObject("\\Windows\\gx.dll");
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
271 if(0 == render_gapi)
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
272 render_gapi = SDL_LoadObject("gx.dll");
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
273 SDL_UnloadObject(render_gapi);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
274
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
275 if(preferably && 0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0 != render_gapi;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
276
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
277 return 0 != render_raw || 0 != render_gapi;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
280 void WINCE_AddRenderDriver(_THIS)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 {
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
282 HDC hdc;
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
283 void* render_gapi;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
284 int render_raw, ii;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
285 const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
3520
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3168
diff changeset
286
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
287 // raw check
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
288 RawFrameBufferInfo rfbi = { 0 };
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
289 hdc = GetDC(NULL);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
290 render_raw = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
291 ReleaseDC(NULL, hdc);
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
293 if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 &&
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
294 rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
295 render_raw = 1;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
297 // gapi check
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
298 render_gapi = SDL_LoadObject("\\Windows\\gx.dll");
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
299 if(0 == render_gapi)
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
300 render_gapi = SDL_LoadObject("gx.dll");
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
301
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
302 if(render_gapi)
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
303 SDL_UnloadObject(render_gapi);
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
305 for(ii = 0; ii < _this->num_displays; ++ii)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
306 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
307 if(preferably)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
308 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
309 if(0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME) && render_raw)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
310 SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
311 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
312 if(0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME) && render_gapi)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
313 SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
314 }
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
315 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
316 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
317 if(render_raw)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
318 SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
319 if(render_gapi)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
320 SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
321 }
3520
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3168
diff changeset
322 }
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
325 SDL_Renderer* WINCE_CreateRenderer(SDL_Window* window, Uint32 flags)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 {
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
327 SDL_VideoDisplay* display = window->display;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
328 SDL_DisplayMode* displayMode = &display->current_mode;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
329 SDL_WindowData* windowdata = (SDL_WindowData *) window->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
330 SDL_Renderer* renderer;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
331 WINCE_RenderData* data;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
332 int bpp;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
333 Uint32 Rmask, Gmask, Bmask, Amask;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
335 if(!(window->flags & SDL_WINDOW_FULLSCREEN))
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
336 window->flags |= SDL_WINDOW_FULLSCREEN;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
338 if(!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask))
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
339 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
340 SDL_SetError("Unknown display format");
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
344 switch(window->fullscreen_mode.format)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
345 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
346 case SDL_PIXELFORMAT_RGB555:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
347 case SDL_PIXELFORMAT_RGB565:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
348 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
349
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
350 default:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
351 SDL_SetError("Support only 16 or 15 bpp");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
352 return NULL;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
355 renderer = (SDL_Renderer*) SDL_calloc(1, sizeof(SDL_Renderer));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
356 if(!renderer)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
357 {
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
362 data = (WINCE_RenderData*) SDL_calloc(1, sizeof(WINCE_RenderData));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
363 if(!data)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
364 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
365 WINCE_DestroyRenderer(renderer);
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
370 // initialize internal engine
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
371 if(!RAW_Init(data) && !GAPI_Init(data, windowdata->hwnd))
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 {
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
373 WINCE_DestroyRenderer(renderer);
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
378 // set debug
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
379 data->debug = SDL_getenv("DEBUG_VIDEO_GAPI") || SDL_getenv("GAPI_RENDERER_DEBUG") ? 1 : 0;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
380 #if defined(DEBUG_VIDEO_GAPI) || defined(GAPI_RENDERER_DEBUG)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
381 data->debug = 1;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
382 #endif
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
384 windowdata->videodata->render = data->gapi ? RENDER_GAPI : RENDER_RAW;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
385 windowdata->videodata->CoordTransform = WINCE_PointerCoordinateTransform;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
387 window->display->device->MaximizeWindow = NULL;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
388 window->display->device->MinimizeWindow = NULL;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
390 WINCE_SetupOrientation(data, window->w, window->h);
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
392 renderer->CreateTexture = WINCE_CreateTexture;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
393 renderer->DestroyTexture = WINCE_DestroyTexture;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
394 renderer->QueryTexturePixels = WINCE_QueryTexturePixels;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
395 renderer->UpdateTexture = WINCE_UpdateTexture;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
396 renderer->LockTexture = WINCE_LockTexture;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
397 renderer->UnlockTexture = WINCE_UnlockTexture;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
399 renderer->RenderCopy = WINCE_RenderCopy;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
400 renderer->DestroyRenderer = WINCE_DestroyRenderer;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
402 renderer->RenderPresent = WINCE_RenderPresent;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
403 renderer->RenderDrawPoints = WINCE_RenderDrawPoints;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
404 renderer->RenderDrawLines = WINCE_RenderDrawLines;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
405 renderer->RenderDrawRects = WINCE_RenderDrawRects;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
406 renderer->RenderFillRects = WINCE_RenderFillRects;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
408 renderer->info = data->gapi ? GAPI_RenderDriver.info : RAW_RenderDriver.info;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3612
diff changeset
410 renderer->window = window;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 renderer->driverdata = data;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 return renderer;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
416 void WINCE_DestroyRenderer(SDL_Renderer* renderer)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
417 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
418 WINCE_RenderData *renderdata = (WINCE_RenderData*) renderer->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
419
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
420 if(renderdata)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
421 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
422 if(renderdata->gapi)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
423 GAPI_Quit(renderdata);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
424 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
425 RAW_Quit(renderdata);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
426
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
427 SDL_free(renderdata);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
428 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
429
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
430 SDL_free(renderer);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
431 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
432
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
433 int WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
434 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
435 WINCE_TextureData* texturedata = (WINCE_TextureData*) SDL_calloc(1, sizeof(WINCE_TextureData));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
436 if(NULL == texturedata)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
437 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
438 SDL_OutOfMemory();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
439 return -1;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
440 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
441
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
442 texturedata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
443 texturedata->pixels = SDL_malloc(texture->h * texturedata->pitch);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
444 if(NULL == texturedata->pixels)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
445 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
446 SDL_OutOfMemory();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
447 return -1;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
448 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
449
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
450 if(SDL_ISPIXELFORMAT_FOURCC(texture->format))
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
451 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
452 SDL_Window* window = renderer->window;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
453 SDL_VideoDisplay* display = window->display;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
454
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
455 texturedata->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
456 if(NULL == texturedata->yuv)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
457 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
458 SDL_OutOfMemory();
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
459 return -1;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
460 }
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
461 texturedata->format = display->current_mode.format;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
462 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
463 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
464 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
465 texturedata->yuv = NULL;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
466 texturedata->format = texture->format;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
467 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
468
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
469 texture->driverdata = texturedata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
470
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
471 return 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
472 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
473
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
474 void WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
475 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
476 WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
477
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
478 if(texturedata)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
479 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
480 if(texturedata->yuv) SDL_SW_DestroyYUVTexture(texturedata->yuv);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
481 if(texturedata->pixels) SDL_free(texturedata->pixels);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
482 SDL_free(texturedata);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
483 texture->driverdata = NULL;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
484 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
485 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
486
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
487 int WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
488 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
489 WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
490
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
491 if(texturedata->yuv)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
492 return SDL_SW_QueryYUVTexturePixels(texturedata->yuv, pixels, pitch);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
493
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
494 *pixels = texturedata->pixels;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
495 *pitch = texturedata->pitch;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
496
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
497 return 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
498 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
499
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
500 int WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 {
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
502 WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
503
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
504 if(texturedata->yuv)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
505 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
506 if(SDL_SW_UpdateYUVTexture(texturedata->yuv, rect, pixels, pitch) < 0)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
507 return -1;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
508 WINCE_UpdateYUVTextureData(texture);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
509 return 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
510 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
511
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
512 if(0 < rect->w && 0 < rect->h)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
513 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
514 const unsigned char *src = ((const unsigned char*) pixels);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
515 unsigned char *dst = ((unsigned char*) texturedata->pixels) +
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
516 rect->y * texturedata->pitch +
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
517 rect->x * SDL_BYTESPERPIXEL(texture->format);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
518 int length = rect->w * SDL_BYTESPERPIXEL(texture->format);
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
519 int height = rect->h;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
520
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
521 while(height--)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
522 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
523 SDL_memcpy(dst, src, length);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
524 dst += texturedata->pitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
525 src += pitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
526 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
527 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
528
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
529 return 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
530 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
531
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
532 int WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
533 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
534 WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
535
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
536 if(texturedata->yuv)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
537 return SDL_SW_LockYUVTexture(texturedata->yuv, rect, dirty, pixels, pitch);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
538
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
539 *pixels = (void *) ((unsigned char*) texturedata->pixels +
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
540 rect->y * texturedata->pitch +
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
541 rect->x * SDL_BYTESPERPIXEL(texture->format));
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
542 *pitch = texturedata->pitch;
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
543 return 0;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
544 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
545
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
546 void WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
547 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
548 WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
549
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
550 if(texturedata->yuv)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
551 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
552 SDL_SW_UnlockYUVTexture(texturedata->yuv);
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
553 WINCE_UpdateYUVTextureData(texture);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
554 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
555 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
556
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
557 int WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
558 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
559 WINCE_RenderData* dstdata = (WINCE_RenderData*) renderer->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
560 WINCE_TextureData* srcdata = (WINCE_TextureData*) texture->driverdata;
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
561 const unsigned char *src;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
562 unsigned char *dst;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
563
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
564 if((dstdata->flags & FB_SUSPENDED) ||
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
565 0 >= srect->w || 0 >= srect->h) return 0;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
566
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
567 // lock gapi
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
568 if(dstdata->gapi) dstdata->gapi->GXBeginDraw();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
569
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
570 src = ((const unsigned char*) srcdata->pixels);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
571 dst = dstdata->pixels + (dstdata->flags & FB_SKIP_OFFSET ? 0 : dstdata->fb.offset) +
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
572 drect->y * dstdata->fb.ypitch +
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
573 drect->x * dstdata->fb.xpitch;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
574 if(srcdata->yuv)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
575 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
576 return SDL_SW_CopyYUVToRGB(srcdata->yuv,
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
577 srect, srcdata->format,
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
578 drect->w, drect->h, dst,
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
579 dstdata->fb.ypitch);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
580 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
581 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
582 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
583 int height = drect->h;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
584 int length = drect->w * SDL_BYTESPERPIXEL(texture->format); // in bytes
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
585
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
586 while(height--)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
587 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
588 switch(SDL_BYTESPERPIXEL(texture->format))
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
589 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
590 case 2: UpdateLine16to16(&dstdata->fb, (Uint16*) src, (Uint16*) dst, length >> 1); break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
591
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
592 default: break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
593 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
594
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
595 dst += dstdata->fb.ypitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
596 src += srcdata->pitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
597 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
598 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
599
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
600 // unlock gapi
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
601 if(dstdata->gapi) dstdata->gapi->GXEndDraw();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
602
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
603 return 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
604 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
605
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
606 void WINCE_RenderPresent(SDL_Renderer* renderer)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
607 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
608 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
609
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
610 int WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
611 {
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
612 SDL_Unsupported();
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 return -1;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
616 int WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 {
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
618 SDL_Unsupported();
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
619 return -1;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
622 int WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 {
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
624 SDL_Unsupported();
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
625 return -1;
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
626 }
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
627
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
628 int WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count)
3612
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
629 {
ce7d4942d18b I can't compile this, but it should be updated for the new rendering API now.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
630 SDL_Unsupported();
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 return -1;
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
632 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
634
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
635
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
636 void WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
638 const float maxW1 = (float)(GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) ? GetSystemMetrics(SM_CXSCREEN) : GetSystemMetrics(SM_CYSCREEN));
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
639 const float maxW2 = (float)(data->fb.width > data->fb.height ? data->fb.width : data->fb.height);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
640
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
641 // scale define
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
642 data->scale = maxW2 / maxW1;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
643
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
644 // init fb values
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
645 FrameBufferInitialize(&data->fb);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
646
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
647 // orientation values
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
648 data->userOrientation = ORIENTATION_UP;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
649 data->systemOrientation = WINCE_GetDMOrientation();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
650 data->hardwareGeometry = data->fb.width == data->fb.height ? GEOMETRY_SQUARE :
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
651 (data->fb.width < data->fb.height ? GEOMETRY_PORTRAIT : GEOMETRY_LANDSCAPE);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
652
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
653 if(data->debug)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
654 WINCE_DumpVideoInfo(data);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
655
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
656 if(data->systemOrientation == ORIENTATION_UNKNOWN)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
657 data->systemOrientation = ORIENTATION_UP;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
658
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
659 data->userOrientation = ORIENTATION_UP;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
660
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
661 switch(data->hardwareGeometry)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
662 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
663 case GEOMETRY_PORTRAIT: WINCE_PortraitTransform(data, width, height); break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
664 case GEOMETRY_LANDSCAPE: WINCE_LandscapeTransform(data, width, height); break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
665 case GEOMETRY_SQUARE: WINCE_SquareTransform(data, width, height); break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
666 default: break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
667 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
668
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
669 // debug
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
670 if(data->debug)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
671 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
672 printf("\n");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
673 printf("user video width: %d\n", width);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
674 printf("user video height: %d\n", height);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
675 FrameBufferDumpInfo(&data->fb, "user");
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
676 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
677 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
678
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
679 void WINCE_DumpVideoInfo(WINCE_RenderData* data)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
680 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
681 // get oem info
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
682 WCHAR oemInfo[48];
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
683 SDL_memset(oemInfo, 0, sizeof(oemInfo));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
684 SystemParametersInfo(SPI_GETOEMINFO, sizeof(oemInfo) - sizeof(WCHAR), oemInfo, 0);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
685
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
686 printf("hardware oem: ");
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
687 wprintf(oemInfo);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
688 printf("\n");
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
690 printf("video driver mode: %s\n", (data->flags & FB_RAW_MODE ? RAW_RENDER_NAME : GAPI_RENDER_NAME));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
691 printf("GetSystemMetrics(SM_CXSCREEN): %d\n", GetSystemMetrics(SM_CXSCREEN));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
692 printf("GetSystemMetrics(SM_CYSCREEN): %d\n", GetSystemMetrics(SM_CYSCREEN));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
693 printf("scale coord: %f\n", data->scale);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
694
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
695 FrameBufferDumpInfo(&data->fb, "hardware");
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
696
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
697 printf("display format: %p\n", data->format);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
698 printf("display bits per pixel: %d\n", SDL_BITSPERPIXEL(data->format));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
699 printf("display bytes per pixel: %d\n", SDL_BYTESPERPIXEL(data->format));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
700 printf("display memory: %p\n", data->pixels);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
701 printf("system orientation: %d, %s\n", data->systemOrientation, GetOrientationName(data->systemOrientation));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
702 printf("hardware geometry: %d\n", data->hardwareGeometry);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
703 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
704
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
705 void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
706 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
707 SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
708 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
709 SDL_Renderer* renderer = (SDL_Renderer*) window->renderer;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
710
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
711 if(visible)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
712 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
713 if(window->flags & SDL_WINDOW_FULLSCREEN)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
714 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
715 if(videodata->SHFullScreen)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
716 videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
717 ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
718 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
719
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
720 ShowWindow(windowdata->hwnd, SW_SHOW);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
721 SetForegroundWindow(windowdata->hwnd);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
722
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
723 if(renderer &&
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
724 (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
725 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
726 WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
727 renderdata->flags &= ~FB_SUSPENDED;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
728 if(renderdata->gapi) renderdata->gapi->GXResume();
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
729 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
730 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
731 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
732 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
733 if(renderer &&
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
734 (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
735 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
736 WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
737 if(renderdata->gapi) renderdata->gapi->GXSuspend();
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
738 renderdata->flags |= FB_SUSPENDED;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
739 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
740
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
741 ShowWindow(windowdata->hwnd, SW_HIDE);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
742
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
743 if(window->flags & SDL_WINDOW_FULLSCREEN)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
744 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
745 if(videodata->SHFullScreen)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
746 videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
747 ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
748 }
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
749 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
750 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
751
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
752
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
753 void WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
754 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
755 WINCE_RenderData* data = (WINCE_RenderData*) window->renderer->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
756
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
757 pt->x = (LONG)(pt->x * data->scale);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
758 pt->y = (LONG)(pt->y * data->scale);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
759
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
760 PointerRotate(pt, &data->fb, data->userOrientation);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
761 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
762
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
763 void WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
764 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
765 if(data->systemOrientation != ORIENTATION_UP)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
766 FrameBufferRotate(&data->fb, data->systemOrientation);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
767
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
768 if(data->fb.width != width || data->fb.height != height) {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
769 switch(data->systemOrientation)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
770 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
771 case ORIENTATION_UP:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
772 case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
773 case ORIENTATION_RIGHT:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
774 case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
775 default: break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
776 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
777 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
778
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
779 if(data->userOrientation != ORIENTATION_UP)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
780 FrameBufferRotate(&data->fb, data->userOrientation);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
781 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
782
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
783 void WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
784 {
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
785 switch(data->systemOrientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
786 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
787 case ORIENTATION_UP: FrameBufferRotate(&data->fb, ORIENTATION_LEFT); break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
788 case ORIENTATION_LEFT:FrameBufferRotate(&data->fb, ORIENTATION_DOWN); break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
789 case ORIENTATION_DOWN:FrameBufferRotate(&data->fb, ORIENTATION_RIGHT); break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
790 default: break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
791 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
792
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
793 if(data->fb.width != width || data->fb.height != height)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
794 switch(data->systemOrientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
795 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
796 case ORIENTATION_UP:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
797 case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
798 case ORIENTATION_RIGHT:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
799 case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
800 default: break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
801 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
802
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
803 if(data->userOrientation != ORIENTATION_UP)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
804 FrameBufferRotate(&data->fb, data->userOrientation);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
805 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
806
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
807 void WINCE_SquareTransform(WINCE_RenderData* data, int width, int height)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
808 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
809 WINCE_PortraitTransform(data, width, height);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
810 }
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
811
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
812 int WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
813 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
814 // check square
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
815 if(GetSystemMetrics(SM_CXSCREEN) == GetSystemMetrics(SM_CYSCREEN) &&
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
816 fb->width != fb->height)
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
817 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
818 if(fb->width < fb->height)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
819 fb->height = fb->width;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
820 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
821 if(fb->height < fb->width)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
822 fb->width = fb->height;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
823 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
824
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
825 // check width
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
826 if(__abs(fb->xpitch) == bpp &&
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
827 fb->width != __abs(fb->ypitch) / bpp)
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
828 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
829 if(fb->height == __abs(fb->ypitch) / bpp)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
830 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
831 __swap(&fb->width, &fb->height);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
832
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
833 if(debug)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
834 printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
835 }
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
836 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
837 return -1;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
838 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
839 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
840 // check height
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
841 if(__abs(fb->ypitch) == bpp &&
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
842 fb->height != __abs(fb->xpitch) / bpp)
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
843 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
844 if(fb->width == __abs(fb->xpitch) / bpp)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
845 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
846 __swap(&fb->width, &fb->height);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
847
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
848 if(debug)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
849 printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
850 }
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
851 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
852 return -1;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
853 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
854
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
855 return 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
856 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
857
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
858 void WINCE_UpdateYUVTextureData(SDL_Texture* texture)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
859 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
860 WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
861 SDL_Rect rect;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
862
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
863 rect.x = 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
864 rect.y = 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
865 rect.w = texture->w;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
866 rect.h = texture->h;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
867 SDL_SW_CopyYUVToRGB(texturedata->yuv, &rect, texturedata->format, texture->w, texture->h, texturedata->pixels, texturedata->pitch);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
868 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
869
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
870 int GAPI_Init(WINCE_RenderData* data, HWND hwnd)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
871 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
872 if(NULL == data->gapi)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
873 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
874 struct GXDisplayProperties gxProperties;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
875 GXDeviceInfo gxInfo = { 0 };
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
876 HDC hdc;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
877 int enable, result;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
878 const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
879 if(preferably && 0 != SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
880
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
881 data->gapi = (GapiInfo *) SDL_calloc(1, sizeof(GapiInfo));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
882 if(NULL == data->gapi)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
883 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
884 SDL_OutOfMemory();
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
885 return 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
886 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
887
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
888 data->gapi->hGapiLib = SDL_LoadObject("\\Windows\\gx.dll");
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
889 if(0 == data->gapi->hGapiLib)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
890 {
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
891 data->gapi->hGapiLib = SDL_LoadObject("gx.dll");
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
892 if(0 == data->gapi->hGapiLib) return 0;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
893 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
894
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
895 // load gapi library
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
896 #define LINK(type,name,import) name=(PFN##type)SDL_LoadFunction(data->gapi->hGapiLib,import)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
897 LINK(GXOpenDisplay, data->gapi->GXOpenDisplay, "?GXOpenDisplay@@YAHPAUHWND__@@K@Z");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
898 LINK(GXCloseDisplay, data->gapi->GXCloseDisplay, "?GXCloseDisplay@@YAHXZ");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
899 LINK(GXBeginDraw, data->gapi->GXBeginDraw, "?GXBeginDraw@@YAPAXXZ");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
900 LINK(GXEndDraw, data->gapi->GXEndDraw, "?GXEndDraw@@YAHXZ");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
901 LINK(GXGetDisplayProperties,data->gapi->GXGetDisplayProperties,"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
902 LINK(GXSuspend, data->gapi->GXSuspend, "?GXSuspend@@YAHXZ");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
903 LINK(GXResume, data->gapi->GXResume, "?GXResume@@YAHXZ");
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
904 #undef LINK
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
905
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
906 enable = data->gapi->GXGetDisplayProperties && data->gapi->GXCloseDisplay && data->gapi->GXOpenDisplay &&
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
907 data->gapi->GXBeginDraw && data->gapi->GXEndDraw && data->gapi->GXSuspend && data->gapi->GXResume;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
908
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
909 if(!enable)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
910 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
911 SDL_SetError("GAPI_Init: error gx.dll: internal error");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
912 GAPI_Quit(data);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
913 return 0;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
914 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
915
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
916 if(0 == data->gapi->GXOpenDisplay(hwnd, GX_FULLSCREEN))
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
917 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
918 SDL_SetError("GAPI_Init: couldn't initialize GAPI");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
919 GAPI_Quit(data);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
920 return 0;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
921 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
922
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
923 gxProperties = data->gapi->GXGetDisplayProperties();
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
924
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
925 // fill FrameBufferInfo
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
926 data->fb.xpitch = gxProperties.cbxPitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
927 data->fb.ypitch = gxProperties.cbyPitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
928 data->fb.width = gxProperties.cxWidth;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
929 data->fb.height = gxProperties.cyHeight;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
930 data->fb.offset = 0;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
931
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
932 if((gxProperties.ffFormat & kfDirect565) || 16 == gxProperties.cBPP)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
933 data->format = SDL_PIXELFORMAT_RGB565;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
934 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
935 if((gxProperties.ffFormat & kfDirect555) || 15 == gxProperties.cBPP)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
936 data->format = SDL_PIXELFORMAT_RGB555;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
937 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
938 data->format = 0;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
939
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
940 // get pixels
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
941 hdc = GetDC(NULL);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
942
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
943 gxInfo.Version = 100;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
944 result = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo), (char *) &gxInfo);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
945 ReleaseDC(NULL, hdc);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
946
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
947 if(result > 0)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
948 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
949 // more debug
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
950 if(data->debug)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
951 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
952 int i;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
953
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
954 printf("GXDeviceInfo.pvFrameBuffer: %p\n", gxInfo.pvFrameBuffer);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
955 printf("GXDeviceInfo.cxWidth: %d\n", gxInfo.cxWidth);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
956 printf("GXDeviceInfo.cyHeight: %d\n", gxInfo.cyHeight);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
957 printf("GXDeviceInfo.cbStride: %d\n", gxInfo.cbStride);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
958 printf("GXDeviceInfo.cBPP: %d\n", gxInfo.cBPP);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
959 printf("GXDeviceInfo.ffFormat: 0x%x\n", gxInfo.ffFormat);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
960
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
961 printf("GXDeviceInfo.unk:\n");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
962 for(i = 0; i < sizeof(gxInfo.unknown); ++i)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
963 printf("0x%02hhX,", gxInfo.unknown[i]);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
964 printf("\n");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
965 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
966
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
967 if(gxInfo.ffFormat && gxInfo.ffFormat != gxProperties.ffFormat) {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
968 if((gxInfo.ffFormat & kfDirect565) || 16 == gxInfo.cBPP)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
969 data->format = SDL_PIXELFORMAT_RGB565;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
970 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
971 if((gxInfo.ffFormat & kfDirect555) || 15 == gxInfo.cBPP)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
972 data->format = SDL_PIXELFORMAT_RGB555;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
973 }
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
974
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
975 data->pixels = gxInfo.pvFrameBuffer;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
976 }
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
977 else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
978 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
979 data->flags |= FB_SKIP_OFFSET;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
980 data->pixels = data->gapi->GXBeginDraw();
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
981 data->gapi->GXEndDraw();
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
982
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
983 if(data->debug)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
984 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
985 printf("GAPI_Init\n");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
986 printf("use GXBeginDraw: %p\n", data->pixels);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
987 printf("use skip offset\n");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
988 }
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
989 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
990
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
991 if(0 == data->format ||
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
992 0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug))
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
993 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
994 SDL_SetError("GAPI_Init: unknown hardware");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
995 GAPI_Quit(data);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
996 return 0;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
997 }
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
998 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
999
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1000 return data->gapi && data->pixels ? 1 : 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1001 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1002
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1003 void GAPI_Quit(WINCE_RenderData* data)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1004 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1005 if(data->gapi)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1006 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1007 if(data->gapi->GXCloseDisplay) data->gapi->GXCloseDisplay();
5092
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5088
diff changeset
1008 if(data->gapi->hGapiLib) SDL_UnloadObject(data->gapi->hGapiLib);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1009
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1010 SDL_free(data->gapi);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1011 data->gapi = NULL;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1012 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1013 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1014
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1015 int RAW_Init(WINCE_RenderData* data)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1016 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1017 RawFrameBufferInfo rfbi = { 0 };
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1018 HDC hdc;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1019 int result;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1020 const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1021 if(preferably && 0 != SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1022
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1023 hdc = GetDC(NULL);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1024 result = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1025 ReleaseDC(NULL, hdc);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1026
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1027 //disable
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1028 if(result == 0 || rfbi.pFramePointer == 0 ||
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1029 rfbi.cxPixels == 0 || rfbi.cyPixels == 0 ||
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1030 rfbi.cxStride == 0 || rfbi.cyStride == 0) return 0;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1031
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1032 data->flags = FB_RAW_MODE;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1033
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1034 // fill FrameBufferInfo
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1035 SDL_memset(&data->fb, 0, sizeof(FrameBufferInfo));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1036
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1037 data->fb.xpitch = rfbi.cxStride;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1038 data->fb.ypitch = rfbi.cyStride;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1039 data->fb.width = rfbi.cxPixels;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1040 data->fb.height = rfbi.cyPixels;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1041 data->fb.offset = 0;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1042
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1043 if((FORMAT_565 & rfbi.wFormat) || 16 == rfbi.wBPP)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1044 data->format = SDL_PIXELFORMAT_RGB565;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1045 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1046 if((FORMAT_555 & rfbi.wFormat) || 15 == rfbi.wBPP)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1047 data->format = SDL_PIXELFORMAT_RGB555;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1048 else
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1049 data->format = 0;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1050
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1051 if(0 == data->format ||
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1052 0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug))
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1053 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1054 SDL_SetError("RAW_Init: unknown hardware");
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1055 RAW_Quit(data);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1056 return 0;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1057 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1058
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1059 data->pixels = rfbi.pFramePointer;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1060
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1061 return data->pixels ? 1 : 0;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1062 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1063
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1064 void RAW_Quit(WINCE_RenderData* data)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1065 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1066 }
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1067
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1068 void FrameBufferInitialize(FrameBufferInfo* fb)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1069 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1070 int orientation = GetFrameBufferOrientation(fb);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1071
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1072 // set correct start offset
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1073 switch(orientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1074 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1075 case ORIENTATION_UP:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1076 fb->offset = 0;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1077 break;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1078
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1079 case ORIENTATION_LEFT:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1080 fb->offset = __abs(fb->ypitch * (fb->height - 1));
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1081 break;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1082
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1083 case ORIENTATION_RIGHT:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1084 fb->offset = __abs(fb->xpitch * (fb->width - 1));
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1085 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1086
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1087 case ORIENTATION_DOWN:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1088 fb->offset = __abs(fb->xpitch * (fb->width - 1) +
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1089 fb->ypitch * (fb->height - 1));
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1090 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1091
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1092 default: break;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1093 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1094
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1095 //if(orientation != ORIENTATION_UP)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1096 switch(orientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1097 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1098 case ORIENTATION_LEFT: FrameBufferRotate(fb, ORIENTATION_RIGHT); break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1099 case ORIENTATION_RIGHT:FrameBufferRotate(fb, ORIENTATION_LEFT); break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1100 case ORIENTATION_DOWN: FrameBufferRotate(fb, ORIENTATION_DOWN); break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1101
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1102 default: break;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1103 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1104 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1105
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1106 int GetFrameBufferOrientation(const FrameBufferInfo* src)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1107 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1108 if(src->xpitch > 0 && src->ypitch > 0)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1109 return ORIENTATION_UP;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1110 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1111 if(src->xpitch > 0 && src->ypitch < 0)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1112 return ORIENTATION_LEFT;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1113 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1114 if(src->xpitch < 0 && src->ypitch > 0)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1115 return ORIENTATION_RIGHT;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1116 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1117 if(src->xpitch < 0 && src->ypitch < 0)
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1118 return ORIENTATION_DOWN;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1119
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1120 return ORIENTATION_UNKNOWN;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1121 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1122
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1123 void FrameBufferRotate(FrameBufferInfo* dst, int orientation)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1124 {
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1125 FrameBufferInfo src;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1126 // copy dst -> src
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1127 SDL_memcpy(&src, dst, sizeof(FrameBufferInfo));
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1128
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1129 switch(orientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1130 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1131 case ORIENTATION_LEFT:
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1132 dst->width = src.height;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1133 dst->height = src.width;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1134 dst->xpitch = src.ypitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1135 dst->ypitch = -src.xpitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1136 dst->offset = src.offset + src.xpitch * (src.width - 1);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1137 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1138
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1139 case ORIENTATION_RIGHT:
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1140 dst->width = src.height;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1141 dst->height = src.width;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1142 dst->xpitch = -src.ypitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1143 dst->ypitch = src.xpitch;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1144 dst->offset = src.offset + src.ypitch * (src.height - 1);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1145 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1146
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1147 case ORIENTATION_DOWN:
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1148 FrameBufferRotate(dst, ORIENTATION_LEFT);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1149 FrameBufferRotate(dst, ORIENTATION_LEFT);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1150 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1151
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1152 default:
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1153 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1154 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1155 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1156
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1157 void PointerRotate(POINT* pt, const FrameBufferInfo* fb, int orientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1158 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1159 switch(orientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1160 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1161 case ORIENTATION_UP:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1162 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1163
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1164 case ORIENTATION_LEFT:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1165 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1166 int temp = pt->y;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1167 pt->y = fb->height - pt->x;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1168 pt->x = temp;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1169 }
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1170 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1171
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1172 case ORIENTATION_RIGHT:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1173 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1174 int temp = pt->x;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1175 pt->x = fb->width - pt->y;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1176 pt->y = temp;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1177 }
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1178 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1179
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1180 case ORIENTATION_DOWN:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1181 pt->x = fb->width - pt->x;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1182 pt->y = fb->height - pt->y;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1183 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1184
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1185 default: break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1186 }
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1187 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1188
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1189 const char* GetOrientationName(int orientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1190 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1191 switch(orientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1192 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1193 case ORIENTATION_UP: return "UP";
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1194 case ORIENTATION_DOWN: return "DOWN";
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1195 case ORIENTATION_LEFT: return "LEFT";
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1196 case ORIENTATION_RIGHT: return "RIGHT";
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1197 default: break;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1198 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1199
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1200 return "UNKNOWN";
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1201 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1202
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1203 int WINCE_GetDMOrientation(void)
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1204 {
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1205 DEVMODE sDevMode = {0};
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1206 sDevMode.dmSize = sizeof(DEVMODE);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1207 sDevMode.dmFields = DM_DISPLAYORIENTATION;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1208
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1209 // DMDO_0, DMDO_90, DMDO_180, DMDO_270
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1210 if(DISP_CHANGE_BADMODE != ChangeDisplaySettingsEx(NULL, &sDevMode, 0, CDS_TEST, NULL))
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1211 switch(sDevMode.dmDisplayOrientation)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1212 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1213 case DMDO_0: return DMDO_0;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1214 case DMDO_90: return DMDO_90;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1215 case DMDO_180: return DMDO_180;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1216 case DMDO_270: return DMDO_270;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1217 default: break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1218 }
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1219
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1220 SDL_SetError("WINCE_GetDMOrientation: ChangeDisplaySettingsEx return BADMODE");
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1221 return -1;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1222 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1223
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1224 int WINCE_SetDMOrientation(int orientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1225 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1226 DEVMODE sDevMode = {0};
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1227 sDevMode.dmSize = sizeof(DEVMODE);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1228 sDevMode.dmFields = DM_DISPLAYORIENTATION;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1229
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1230 switch(orientation)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1231 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1232 case DMDO_0: sDevMode.dmDisplayOrientation = DMDO_0; break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1233 case DMDO_90: sDevMode.dmDisplayOrientation = DMDO_90; break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1234 case DMDO_180: sDevMode.dmDisplayOrientation = DMDO_180; break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1235 case DMDO_270: sDevMode.dmDisplayOrientation = DMDO_270; break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1236 default: return 0;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1237 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1238
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1239 if(DISP_CHANGE_BADMODE != ChangeDisplaySettingsEx(NULL, &sDevMode, 0, CDS_RESET, NULL))
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1240 return 1;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1241
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1242 SDL_SetError("WINCE_SetDMOrientation: ChangeDisplaySettingsEx return BADMODE");
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1243 return -1;
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1244 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1245
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1246 void FrameBufferDumpInfo(const FrameBufferInfo* fb, const char* name)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1247 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1248 int orientation;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1249
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1250 printf("%s fb.width: %d\n", name, fb->width);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1251 printf("%s fb.height: %d\n", name, fb->height);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1252 printf("%s fb.xpitch: %d\n", name, fb->xpitch);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1253 printf("%s fb.ypitch: %d\n", name, fb->ypitch);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1254 printf("%s fb.offset: %d\n", name, fb->offset);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1255
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1256 orientation = GetFrameBufferOrientation(fb);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1257 printf("%s fb.orientation: %d, %s\n", name, orientation, GetOrientationName(orientation));
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1258 }
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1259
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1260 void UpdateLine16to16(const FrameBufferInfo* fb, const Uint16* src, Uint16* dst, Uint16 width)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1261 {
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1262 if(2 == fb->xpitch)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1263 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1264 switch(width)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1265 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1266 case 1:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1267 *dst = *src;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1268 break;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1269
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1270 case 2:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1271 *((Uint32*) dst) = *((Uint32*) src);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1272 break;
3168
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1273
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1274 default:
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1275 SDL_memcpy(dst, src, width * 2);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1276 break;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1277 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1278 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1279 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1280 if(-2 == fb->xpitch)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1281 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1282 while(width--)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1283 *dst-- = *src++;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1284 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1285 else
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1286 {
5088
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1287 while(width--)
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1288 {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1289 *dst = *src++;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1290 dst += fb->xpitch / 2;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
1291 }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1292 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1293 }
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1294
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1295 #endif // SDL_VIDEO_RENDER_GAPI