annotate src/video/picogui/SDL_pgvideo.c @ 1338:604d73db6802

Removed uses of stdlib.h and string.h
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 09:29:18 +0000
parents 3692456e7b0f
children c71e05b4dc2e
rev   line source
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
6 modify it under the terms of the GNU Lesser General Public
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
13 Lesser General Public License for more details.
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 Micah Dowty
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 micahjd@users.sourceforge.net
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #include "SDL.h"
1338
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
27 #include "SDL_stdlib.h"
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
28 #include "SDL_string.h"
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include "SDL_error.h"
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include "SDL_video.h"
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include "SDL_mouse.h"
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include "SDL_sysvideo.h"
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #include "SDL_pixels_c.h"
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include "SDL_events_c.h"
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include "SDL_pgvideo.h"
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include "SDL_pgevents_c.h"
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #define PGVID_DRIVER_NAME "picogui"
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 /* Initialization/Query functions */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 static int PG_VideoInit(_THIS, SDL_PixelFormat *vformat);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 static SDL_Rect **PG_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 static SDL_Surface *PG_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 static int PG_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 static void PG_VideoQuit(_THIS);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 /* Hardware surface functions */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 static int PG_AllocHWSurface(_THIS, SDL_Surface *surface);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 static int PG_LockHWSurface(_THIS, SDL_Surface *surface);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 static void PG_UnlockHWSurface(_THIS, SDL_Surface *surface);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 static void PG_FreeHWSurface(_THIS, SDL_Surface *surface);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 /* etc. */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 static void PG_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 // The implementation dependent data for the window manager cursor
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 struct WMcursor {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 /* Our cursor is a PicoGUI theme */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 pghandle theme;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 } ;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 /* WM functions */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 void PG_SetCaption(_THIS, const char *title, const char *icon);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 WMcursor * PG_CreateWMCursor (_THIS,Uint8 * data, Uint8 * mask,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 int w, int h, int hot_x, int hot_y);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 void PG_FreeWMCursor (_THIS, WMcursor * cursor);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 void PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 int PG_ShowWMCursor (_THIS, WMcursor * cursor);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 /* PicoGUI driver bootstrap functions */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 static int PG_Available(void)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 /* FIXME: The current client lib doesn't give a way to see if the picogui
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 * server is reachable without causing a fatal error if it isn't.
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 * This should be fixed in cli_c2, but until then assume we can
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 * connect. Since more common drivers like X11 are probed first anyway,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 * this shouldn't be a huge problem.
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 return(1);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 static void PG_DeleteDevice(SDL_VideoDevice *device)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
86 SDL_free(device->hidden);
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
87 SDL_free(device);
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 static SDL_VideoDevice *PG_CreateDevice(int devindex)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 SDL_VideoDevice *device;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 /* Initialize all variables that we clean on shutdown */
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
95 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 if ( device ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
97 SDL_memset(device, 0, (sizeof *device));
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 device->hidden = (struct SDL_PrivateVideoData *)
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
99 SDL_malloc((sizeof *device->hidden));
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 if ( (device == NULL) || (device->hidden == NULL) ) {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 SDL_OutOfMemory();
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 if ( device ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
104 SDL_free(device);
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 return(0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
108 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
433
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 /* Set the function pointers */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 device->VideoInit = PG_VideoInit;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 device->ListModes = PG_ListModes;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 device->SetVideoMode = PG_SetVideoMode;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 device->CreateYUVOverlay = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 device->SetColors = PG_SetColors;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 device->UpdateRects = PG_UpdateRects;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 device->VideoQuit = PG_VideoQuit;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 device->AllocHWSurface = PG_AllocHWSurface;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 device->CheckHWBlit = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 device->FillHWRect = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 device->SetHWColorKey = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 device->SetHWAlpha = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 device->LockHWSurface = PG_LockHWSurface;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 device->UnlockHWSurface = PG_UnlockHWSurface;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 device->FlipHWSurface = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 device->FreeHWSurface = PG_FreeHWSurface;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 device->SetCaption = PG_SetCaption;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 device->SetIcon = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 device->IconifyWindow = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 device->GrabInput = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 device->PumpEvents = PG_PumpEvents;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 device->InitOSKeymap = PG_InitOSKeymap;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 device->ShowWMCursor = PG_ShowWMCursor;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 device->CreateWMCursor = PG_CreateWMCursor;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 device->FreeWMCursor = PG_FreeWMCursor;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 device->WarpWMCursor = PG_WarpWMCursor;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 device->free = PG_DeleteDevice;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 return device;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 VideoBootStrap PG_bootstrap = {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 PGVID_DRIVER_NAME, "PicoGUI SDL driver",
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 PG_Available, PG_CreateDevice
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 };
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 int PG_VideoInit(_THIS, SDL_PixelFormat *vformat)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 /* Connect to the PicoGUI server. No way to process command line args yet,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 * but since this is based on SHM it's not important to be able to specify
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 * a remote PicoGUI server.
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 *
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 * FIXME: Another nitpick about the current client lib is there's no
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 * clean way to indicate that command line args are not available.
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 pgInit(0,(char**)"");
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 this->hidden->mi = *pgGetVideoMode();
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 /* Create a picogui application and canvas. We'll populate the canvas later. */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 this->hidden->wApp = pgRegisterApp(PG_APP_NORMAL,"SDL",0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 this->hidden->wCanvas = pgNewWidget(PG_WIDGET_CANVAS,0,0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 pgSetWidget(PGDEFAULT,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 PG_WP_SIDE, PG_S_ALL,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 PG_InitEvents(this);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 /* Determine the screen depth.
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 * We change this during the SDL_SetVideoMode implementation...
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 * Round up to the nearest Bytes per pixel
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 vformat->BitsPerPixel = this->hidden->mi.bpp;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 vformat->BytesPerPixel = this->hidden->mi.bpp >> 3;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 if (this->hidden->mi.bpp & 7)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 vformat->BytesPerPixel++;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 /* We're done! */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 return(0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 SDL_Rect **PG_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 return (SDL_Rect **) -1;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 SDL_Surface *PG_SetVideoMode(_THIS, SDL_Surface *current,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 int width, int height, int bpp, Uint32 flags)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 if ( this->hidden->bitmap ) {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 /* Free old bitmap */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 if (current->pixels) {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 shmdt(current->pixels);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 current->pixels = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 pgDelete(this->hidden->bitmap);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 /* Allocate the new pixel format for the screen */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 SDL_SetError("Couldn't allocate new pixel format for requested mode");
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 return(NULL);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 /* Create a new picogui bitmap */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 this->hidden->bitmap = pgCreateBitmap(width,height);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 this->hidden->shm = *pgMakeSHMBitmap(this->hidden->bitmap);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 current->pixels = shmat(shmget(this->hidden->shm.shm_key,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 this->hidden->shm.shm_length,0),NULL,0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 /* Reset the canvas, and draw persistent and incremental grops.
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 * Use mapping and offsets to center it.
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_NUKE, 0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 /* 0. Set the source position during incremental rendering
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 5, PG_GROP_SETSRC,0,0,0,0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, PG_GROPF_INCREMENTAL);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 /* 1. Incremental bitmap rendering
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 0,0,0,0,this->hidden->bitmap);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, PG_GROPF_INCREMENTAL);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 /* 2. Normal bitmap rendering
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 0,0,this->hidden->shm.width,this->hidden->shm.height,this->hidden->bitmap);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 /* Set up the new mode framebuffer */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 current->flags = 0;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 current->w = this->hidden->shm.width;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 current->h = this->hidden->shm.height;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 current->pitch = this->hidden->shm.pitch;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 /* Set up pixel format */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 current->format->BitsPerPixel = this->hidden->shm.bpp;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 current->format->BytesPerPixel = this->hidden->shm.bpp >> 3;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 if (this->hidden->shm.bpp & 7)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 current->format->BytesPerPixel++;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 current->format->palette = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 current->format->Rmask = this->hidden->shm.red_mask;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 current->format->Gmask = this->hidden->shm.green_mask;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 current->format->Bmask = this->hidden->shm.blue_mask;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 current->format->Amask = this->hidden->shm.alpha_mask;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 current->format->Rshift = this->hidden->shm.red_shift;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 current->format->Gshift = this->hidden->shm.green_shift;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 current->format->Bshift = this->hidden->shm.blue_shift;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 current->format->Ashift = this->hidden->shm.alpha_shift;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 current->format->Rloss = 8 - this->hidden->shm.red_length;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 current->format->Gloss = 8 - this->hidden->shm.green_length;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 current->format->Bloss = 8 - this->hidden->shm.blue_length;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 current->format->Aloss = 8 - this->hidden->shm.alpha_length;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 /* Draw the app */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 pgUpdate();
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 /* We're done */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 return(current);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 /* We don't actually allow hardware surfaces other than the main one */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 static int PG_AllocHWSurface(_THIS, SDL_Surface *surface)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 return(-1);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 static void PG_FreeHWSurface(_THIS, SDL_Surface *surface)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 return;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 /* We need to wait for vertical retrace on page flipped displays */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 static int PG_LockHWSurface(_THIS, SDL_Surface *surface)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 return(0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 static void PG_UnlockHWSurface(_THIS, SDL_Surface *surface)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 return;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 static void PG_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 int i;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 for (i = 0; i < numrects; i++) {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 if (rects[i].w <= 0 || rects[i].h <= 0)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 continue;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 /* Schedule an incremental update for this rectangle, using
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 * the canvas gropnodes we've loaded beforehand.
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 rects[i].x, rects[i].y,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 rects[i].w, rects[i].h);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 1);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 rects[i].x, rects[i].y,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 rects[i].w, rects[i].h);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 /* Go perform the update */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 pgWriteCmd(this->hidden->wCanvas, PGCANVAS_INCREMENTAL, 0);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 pgSubUpdate(this->hidden->wCanvas);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 int PG_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 /* do nothing of note. */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 return(1);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 /* Note: If we are terminated, this could be called in the middle of
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 another SDL video routine -- notably UpdateRects.
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 void PG_VideoQuit(_THIS)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 if (this->screen->pixels != NULL)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 shmdt(this->screen->pixels);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 this->screen->pixels = NULL;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 pgDelete(this->hidden->bitmap);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 pgDelete(this->hidden->wCanvas);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 pgDelete(this->hidden->wApp);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 void PG_SetCaption(_THIS, const char *title, const char *icon)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 if (title != NULL)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 pgReplaceText(this->hidden->wApp, title);
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 pgUpdate();
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 /* FIXME: The cursor stuff isn't implemented yet! */
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 WMcursor * PG_CreateWMCursor (_THIS,Uint8 * data, Uint8 * mask,
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 int w, int h, int hot_x, int hot_y)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 static WMcursor dummy;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 return &dummy;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 void PG_FreeWMCursor (_THIS, WMcursor * cursor)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 void PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 }
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 int PG_ShowWMCursor (_THIS, WMcursor * cursor)
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 {
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 return 1;
706de3956894 Added initial support for PicoGUI (thanks Micah!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 }